BALL  1.4.1
representation.h
Go to the documentation of this file.
00001 // -*- Mode: C++; tab-width: 2; -*-
00002 // vi: set ts=2:
00003 //
00004 
00005 #ifndef  BALL_VIEW_KERNEL_REPRESENTATION_H
00006 #define  BALL_VIEW_KERNEL_REPRESENTATION_H
00007 
00008 #ifndef BALL_CONCEPT_PROPERTY_H
00009 # include <BALL/CONCEPT/property.h>
00010 #endif
00011 
00012 #ifndef BALL_CONCEPT_COMPOSITE_H
00013 # include <BALL/CONCEPT/composite.h>
00014 #endif
00015 
00016 #ifndef BALL_VIEW_KERNEL_COMMON_H
00017 # include <BALL/VIEW/KERNEL/common.h>
00018 #endif
00019 
00020 #ifndef BALL_CONCEPT_MOLECULARINFORMATION_H
00021 # include <BALL/CONCEPT/molecularInformation.h>
00022 #endif
00023 
00024 #ifndef BALL_VIEW_KERNEL_MODELINFORMATION_H
00025 # include <BALL/VIEW/KERNEL/modelInformation.h>
00026 #endif
00027 
00028 // next two defines need to be included in header file, because of iC file
00029 #ifndef BALL_VIEW_MODELS_MODELPROCESSOR_H
00030 # include <BALL/VIEW/MODELS/modelProcessor.h>
00031 #endif
00032 
00033 #ifndef BALL_VIEW_MODELS_COLORPROCESSOR_H
00034 # include <BALL/VIEW/MODELS/colorProcessor.h>
00035 #endif
00036 
00037 
00038 namespace BALL
00039 {
00040   namespace VIEW
00041   {
00042     class ModelProcessor;
00043     class ColorProcessor;
00044     class GeometricObject;
00045     class UpdateRepresentationThread;
00046     class RepresentationManager;
00047 
00057     class BALL_VIEW_EXPORT Representation
00058       : public PropertyManager
00059     {
00060       friend class UpdateRepresentationThread;
00061       friend class RepresentationManager;
00062       public:
00063 
00064       BALL_CREATE(Representation)
00065 
00066       
00069       
00070       
00071       enum Properties
00072       {
00074         PROPERTY__ALWAYS_FRONT = 0,
00075         
00077         PROPERTY__IS_COORDINATE_SYSTEM
00078       };
00079         
00081 
00084 
00087       Representation();
00088 
00090       Representation(ModelType model_type,
00091                      DrawingPrecision drawing_precision,
00092                      DrawingMode drawing_mode);
00093 
00096       Representation(const Representation& representation);
00097 
00100       virtual ~Representation();
00101 
00103 
00106       
00108       const Representation& operator = (const Representation& rep);
00109       
00111       void clear();
00112 
00114       void setHidden(bool state) ;
00115 
00117       bool isHidden() const;
00118 
00120       void setDrawingPrecision(DrawingPrecision precision);
00121 
00123       DrawingPrecision getDrawingPrecision() const;
00124 
00126       float getSurfaceDrawingPrecision() const;
00127 
00129       void setSurfaceDrawingPrecision(float precision);
00130 
00132       void setDrawingMode(DrawingMode mode);
00133 
00135       DrawingMode getDrawingMode() const;
00136       
00138       Size getTransparency() const;
00139 
00141       void setTransparency(Size value);
00142       
00144       const GeometricObjectList& getGeometricObjects() const;
00145 
00147       GeometricObjectList& getGeometricObjects();
00148 
00150       void setGeometricObjects(GeometricObjectList& gol) 
00151         { geometric_objects_ = gol;}
00152 
00154       void insert(GeometricObject& object) ;
00155 
00157       const std::list<const Composite*>& getComposites() const
00158         { return composites_;}
00159 
00161       void setComposites(const std::list<const Composite*>& composites);
00162 
00164       void setComposite(const Composite* composite);
00165 
00167       const ModelProcessor* getModelProcessor() const;
00168 
00170       ModelProcessor* getModelProcessor();
00171 
00173       void setModelProcessor(ModelProcessor* processor);
00174       
00176       ColorProcessor* getColorProcessor();
00177 
00179       void setColorProcessor(ColorProcessor* processor);
00180 
00182       void setModelType(ModelType type);
00183 
00185       ModelType getModelType() const;
00186 
00188       String getName() const;
00189 
00191       void setName(const String& name);
00192 
00194       String getCompositeName() const;
00195 
00197       void setColoringMethod(ColoringMethod type);
00198 
00200       ColoringMethod getColoringMethod() const;
00201 
00203       void enableModelUpdate(bool state);
00204 
00206       void enableColoringUpdate(bool state) { coloring_update_enabled_ = state;}
00207 
00209       bool modelUpdateEnabled() const { return model_update_enabled_;}
00210 
00212       bool coloringUpdateEnabled() const { return coloring_update_enabled_;}
00213 
00215       String getProperties() const;
00216       
00218       bool isValid() const;
00219 
00224       void update(bool rebuild);
00225 
00227       void clearGeometricObjects();
00228 
00234       const PreciseTime& getModelBuildTime() const;
00235 
00240       bool needsUpdate() const;
00241 
00243       void setNeedsUpdate(bool state=true);
00244 
00246       void dump(std::ostream& s = std::cout, Size depth = 0) const;
00247 
00249       String toString() const;
00250 
00252       void setModelInformation(const ModelInformation& mi);
00253 
00255       const ModelInformation& getModelInformation() const;
00256 
00258       bool operator == (const Representation& object) const;
00259 
00260     
00262       bool operator < (const Representation& object) const
00263         { return this < &object;}
00264 
00266 
00267       protected:
00268 
00273       void update_();
00274 
00275       // Create a hashmap with the numerical position of every composite in its root Composite. 
00276       // Needed for toString().
00277       void collectRecursive_(const Composite& c, HashMap<const Composite*, Position>& hashmap) const;
00278 
00279       //_
00280       DrawingMode         drawing_mode_;
00281 
00282       //_
00283       DrawingPrecision    drawing_precision_;
00284 
00285       //_
00286       float               surface_drawing_precision_;
00287 
00288       //_
00289       ModelType           model_type_;
00290 
00291       //_
00292       ColoringMethod      coloring_method_;
00293 
00294       //_
00295       Size                transparency_;
00296 
00297       //_
00298       ModelProcessor*     model_processor_;
00299 
00300       //_
00301       ColorProcessor*     color_processor_;
00302 
00303       //_
00304       std::list<const Composite*> composites_;
00305 
00306       //_
00307       PreciseTime         model_build_time_;
00308 
00309       //_ set to true, if update is called, while representation is hidden
00310       bool                needs_update_;
00311 
00312       //_ true means the ModelProcessor will be applied in the next update
00313       bool                rebuild_;
00314 
00315       //_ true means the ColorProcessor was changed since the last update call, so apply it!
00316       bool                changed_color_processor_;
00317 
00318       //_
00319       bool                hidden_;
00320 
00321       //_
00322       GeometricObjectList geometric_objects_;
00323 
00324       //_
00325       bool                model_update_enabled_;
00326 
00327       //_
00328       bool                coloring_update_enabled_;
00329 
00330       String              name_;
00331 
00332       //_                 used for getName()
00333       static              MolecularInformation information_;
00334       
00335       //_                 used for getName()
00336       static              ModelInformation model_information_;
00337 
00338       const ModelInformation* custom_model_information_;
00339     };
00340 
00342     typedef std::list<Representation*> RepresentationList;
00343 
00344 # ifndef BALL_NO_INLINE_FUNCTIONS
00345 #   include <BALL/VIEW/KERNEL/representation.iC>
00346 # endif
00347 
00348   } // namespace VIEW
00349 } // namespace BALL
00350 
00351 #endif // BALL_VIEW_KERNEL_REPRESENTATION_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines