BALL  1.4.1
representationManager.h
Go to the documentation of this file.
00001 // -*- Mode: C++; tab-width: 2; -*-
00002 // vi: set ts=2:
00003 //
00004 // $Id: representationManager.h,v 1.1.4.2 2007/03/28 13:11:43 amoll Exp $
00005 
00006 #ifndef  BALL_VIEW_KERNEL_REPRESENTATIONMANAGER_H
00007 #define  BALL_VIEW_KERNEL_REPRESENTATIONMANAGER_H
00008 
00009 #ifndef BALL_VIEW_KERNEL_REPRESENTATION_H
00010 # include <BALL/VIEW/KERNEL/representation.h>
00011 #endif
00012 
00013 #ifndef BALL_SYSTEM_MUTEX_H
00014 #include <BALL/SYSTEM/mutex.h>
00015 #endif
00016 
00017 #include <QtCore/QCoreApplication>
00018 #include <QtCore/QWaitCondition>
00019 
00020 #include <vector>
00021 
00022 using std::vector;
00023 
00024 namespace BALL
00025 {
00026   class Composite;
00027   class INIFile;
00028 
00029   namespace VIEW
00030   {
00031     class MainControl;
00032     class UpdateRepresentationThread;
00033     class ClippingPlane;
00034 
00045     class BALL_VIEW_EXPORT RepresentationManager
00046       : public Object
00047     {
00048       friend class Representation;
00049       friend class UpdateRepresentationThread;
00050       friend class BALLThread;
00051       friend class MainControl;
00052 
00053       public:
00054 
00055       BALL_CREATE(RepresentationManager)
00056 
00057       
00060 
00061 
00062       typedef HashSet<Representation*> RepresentationSet;
00063 
00065       typedef RepresentationList::iterator RepresentationsIterator;
00066 
00068       typedef RepresentationList::const_iterator RepresentationsConstIterator;
00069 
00071 
00074 
00078       RepresentationManager(MainControl* mc = 0);
00079 
00082       RepresentationManager(const RepresentationManager& pm);
00083 
00086       virtual ~RepresentationManager();
00087 
00089 
00092       
00094       const RepresentationManager& operator = (const RepresentationManager& pm);
00095 
00097       bool operator == (const RepresentationManager& pm) const;
00098       
00100       void clear();
00101 
00108       bool remove(Representation& representation, bool send_message = true);
00109 
00114       bool insert(Representation& representation, bool send_message = true);
00115 
00117       const RepresentationList& getRepresentations() const
00118         { return representations_;}
00119 
00121       Size getNumberOfRepresentations() const
00122         { return representations_.size();}
00123 
00125       Representation* createRepresentation();
00126 
00128       bool has(const Representation& representation) const;
00129       
00131       void dump(std::ostream& s, Size depth = 0) const;
00132 
00134       RepresentationsIterator begin() 
00135         { return representations_.begin();}
00136 
00138       RepresentationsConstIterator begin() const
00139         { return representations_.begin();}
00140       
00142       RepresentationsIterator end() 
00143         { return representations_.end();}
00144 
00146       RepresentationsConstIterator end() const
00147         { return representations_.end();}
00148 
00156       RepresentationList removedComposite(const Composite& composite, bool update = true);
00157 
00162       RepresentationList getRepresentationsOf(const Composite& composite);
00163 
00165       void rebuildAllRepresentations();
00166 
00168       const vector<ClippingPlane*>& getClippingPlanes() const { return clipping_planes_;}
00169 
00171       bool removeClippingPlane(ClippingPlane* plane);
00172 
00174       void insertClippingPlane(ClippingPlane* plane);
00175 
00177       void storeRepresentations(INIFile& out);
00178       
00180       void restoreRepresentations(const INIFile& in, const vector<const Composite*>& new_systems);
00181 
00183       void focusRepresentation(const Representation& rep);
00184       
00186       bool willBeUpdated(const Representation& rep) const;
00187 
00189       bool updateRunning() const ;
00190 
00192       bool startRendering(Representation* rep);
00193 
00195       void finishedRendering(Representation* rep);
00196       
00198       bool isBeeingRendered(const Representation* rep) const;
00199 
00200       protected:
00201     
00203       Representation* popRepresentationToUpdate();
00204 
00205       void finishedUpdate_(Representation* rep);
00206 
00207       /*_ Called by Representation::update() to start a multithreaded
00208           Update of the Representation.
00209           (Only used in Multithreaded code.)
00210       */
00211       void update_(Representation& rep);
00212 
00213       //_ List with all representations
00214       RepresentationList representations_;
00215       
00216       HashSet<Representation*> beeing_rendered_;
00217       HashSet<Representation*> beeing_updated_;
00218       HashSet<Representation*> to_update_;
00219 
00220       vector<ClippingPlane*> clipping_planes_;
00221       
00222       // we need to ensure that the mutex is always created correctly before
00223       // the thread that tries to access it!
00224       mutable Mutex               update_mutex_;
00225 
00226       UpdateRepresentationThread* thread_;
00227       bool                        no_update_;
00228       bool                        still_to_notify_;
00229 
00230       MainControl*  main_control_;
00231     };
00232 
00233   } // namespace VIEW
00234 } // namespace BALL
00235 
00236 #endif // BALL_VIEW_KERNEL_REPRESENTATIONMANAGER_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines