![]() |
VR-Forces 4.0.4 Class Documentation
|
00001 /********************************************************************* 00002 ** Copyright (c) 2001 MAK Technologies, Inc. 00003 ** All rights reserved. 00004 *********************************************************************/ 00005 /********************************************************************* 00006 ** $RCSfile: tmArea.h,v $ $Revision: 1.67 $ $State: Exp $ 00007 *********************************************************************/ 00008 00011 00012 #ifndef TMAREA_H 00013 #define TMAREA_H 00014 00015 #include "tmqt/viewDriver.h" 00016 #include <symbolMapper/modelData.h> 00017 00018 #include <QtCore/QTimer> 00019 #include <QtGui/QWidget> 00020 00021 #include "archiver/archiver.h" 00022 00023 class DtViewDriver; 00024 class DtTMFactory; 00025 class DtBaseSymbolMapper; 00026 class DtDataSymbolList; 00027 class DtTMBackground; 00028 class DtSymbolLensArea; 00029 class QTextStream; 00030 class DtBaseWindow; 00031 00032 #include "tmqt/tmqtDefines.h" 00033 class DT_DLL_tmqt DtTMArea : public QWidget 00034 { 00035 Q_OBJECT 00036 00037 public: 00038 DtTMArea(QWidget * parent = 0, const Qt::WindowFlags& flags = 0); 00039 00040 virtual ~DtTMArea(); 00041 00043 virtual bool init(const DtTMFactory* f); 00044 00045 //Symbol mapper creates new Symbols out of keys 00046 virtual void setSymbolMapper(DtBaseSymbolMapper* mapper); 00047 00048 //Symbol mapper creates new Symbols out of keys 00049 virtual DtBaseSymbolMapper* getSymbolMapper(); 00050 00051 virtual DtTMSymbolUpdater* symbolUpdater(); 00052 00054 virtual DtTMViewportExtents* viewportExtents() const; 00055 00057 virtual DtViewDriver* viewDriver() const; 00058 00060 virtual void setViewDriver(DtViewDriver* v); 00061 00063 virtual DtTMBackground* background() const; 00064 00066 virtual void setBackground(DtTMBackground* v); 00067 00068 //Set the SymbolLensArea to whatever you want 00069 virtual void setSymbolLensArea(DtSymbolLensArea* area); 00070 virtual DtSymbolLensArea* symbolLensArea(); 00071 00072 //Tick the symbol - passed into the LensArea. Returns true if this 00074 virtual bool tick(); 00075 00076 virtual bool isInitialized(); 00077 00079 virtual DtModelDataDict& ModelDataDict(); 00080 00082 virtual DtModelDataIter* ModelDataIter() const; 00083 00085 virtual DtModelDataIter* CombinedModelDataIter() const; 00086 00089 virtual void setUpdateOnTick(bool b); 00090 00093 virtual void markForUpdate(const QVector<DtModelKey>&, bool emitSignal = true); 00094 virtual void markForUpdate(DtModelDataIter* iter, bool emitSignal = true); 00095 virtual void markForUpdate(const DtModelData &data, bool emitSignal = true); 00096 00098 virtual void removeFromUpdate(DtModelDataIter* iter); 00099 virtual void removeFromUpdate(const DtModelData& data); 00100 00102 virtual void removeDictionaryEntry(const DtModelKey& key); 00103 00105 virtual void setUpdateBackgroundOnTick(bool b); 00106 00110 void setNextTickIsRepaint(bool b); 00111 bool nextTickIsRepaint() const; 00112 00114 virtual bool needsTick() const; 00115 00117 virtual bool needsUpdate() const; 00118 00124 virtual DtSymbol* addSymbol(const DtModelData& data, DtSymbol* symbol); 00125 00127 virtual void read(QTextStream& ts); 00128 virtual void write(QTextStream& ts); 00129 00132 virtual void clear(); 00133 virtual void clearSymbols(); 00134 00137 virtual void setForceTickOnViewportChange(bool b); 00138 virtual bool forceTickOnViewportChange() const; 00139 00141 virtual void paint(QPainter* painter, bool paintBackground = true); 00142 00143 virtual void redrawBackground(); 00144 00146 virtual DtSymbol* getSymbol(const DtModelKey&) const; 00147 00149 void setAlwaysResizeToGlobalView(bool); 00150 bool alwaysResizeToGlobalView() const; 00151 00152 virtual bool terrainLoaded() const; 00153 00154 void setWindow(DtBaseWindow*); 00155 DtBaseWindow* window() const; 00156 00160 virtual bool needsDrawOrder() const; 00161 00163 virtual void insertIntoDrawOrder(DtSymbol*); 00164 00165 signals: 00166 00168 void viewportExtentsSet(const DtTMViewportExtents* v); 00169 00171 void viewportExtentsChanged(const DtTMViewportExtents* v); 00172 00173 //called after the loadDatabaseFile slot gets called 00174 void newDatabaseFile(const QString&); 00175 00177 void removingSymbol(const DtModelKey& data); 00178 void addingSymbol(const DtModelKey& data); 00179 void modifyingSymbol(const DtModelKey& data); 00180 00182 void resized(); 00183 00184 void modelDataMarkedForUpdated(const DtModelData& d); 00185 void modelDataRemovedFromUpdate(const DtModelData&); 00186 00187 public slots: 00188 00189 virtual void loadDatabaseFile(const QString&); 00190 00191 //The viewport extents alternate between screen and db coordinates 00192 virtual void setViewportExtents(const DtTMViewportExtents* v); 00193 00195 virtual bool updateAllSymbols(); 00196 00197 //if the background map has to be changed, this is the place to do it 00198 virtual void updateBackground(); 00199 00200 virtual void resizeMapArea(); 00201 00202 virtual DtSymbol* addSymbol(const DtModelData& data, bool force = false); 00203 00204 virtual void removeSymbol(const DtModelData& data, bool force = false); 00205 00206 virtual void modifySymbol(const DtModelData& data); 00207 00208 virtual void removeSymbol(const DtModelKey& data, bool force = false); 00209 00212 virtual void setDrawOrderSymbols(bool b); 00213 00215 virtual void signalDrawOrderSymbols(); 00216 00218 virtual void drawOrderSymbols(); 00219 00220 protected slots: 00221 virtual void catchViewportChange(const DtTMViewportExtents* v); 00222 00224 virtual void symbolAdded(const DtModelKey& data); 00225 virtual void symbolAdded(const DtSymbol*); 00226 virtual void symbolRemoved(const DtModelKey& data); 00227 virtual void symbolRemoved(const DtSymbol*); 00228 00229 protected: 00230 00232 DtTMArea(const DtTMArea& orig); 00233 00235 DtTMArea& operator=(const DtTMArea& rhs); 00236 00237 virtual bool initViewportExtents(const DtTMFactory* f); 00238 00239 virtual bool initViewDriver(const DtTMFactory* f); 00240 00241 virtual bool initLensArea(const DtTMFactory* f, bool useGL = false); 00242 00243 virtual bool initBackground(const DtTMFactory* f); 00244 00246 virtual void resizeEvent(QResizeEvent* e); 00247 virtual void showEvent ( QShowEvent * e); 00248 00249 protected: 00250 DtViewDriver* myViewDriver; 00251 DtTMViewportExtents* myViewportExtents; 00252 bool myDelayGlobalResize; 00253 DtSymbolLensArea* myLensArea; 00254 bool myDeleteLensArea; 00255 QPixmap * myBackground; 00256 QTimer myResizeTimer; 00257 DtTMBackground * myTMBackground; 00258 bool myDeleteBackground; 00259 DtModelDataDict myModelDataDict; 00260 DtModelDataIter* myModelDataIter; 00261 DtModelDataIter* myCombinedModelDataIter; 00262 bool myFirstTick; 00263 bool myUpdateOnTick; 00264 QHash<DtModelKey, DtModelData*> myUpdateData; 00265 bool myUpdateOnlyModified; 00266 bool myIsInitialized; 00267 bool myUpdateBackgroundOnTick; 00268 bool myForceTickOnViewportChange; 00269 bool myNextTickIsRepaint; 00270 00272 DtArchiver myArchiver; 00273 00274 bool myAlwaysResizeToGlobalView; 00275 00276 DtBaseWindow* myWindow; 00277 bool myNeedsDrawOrder; 00278 00279 bool myInTick; 00280 }; 00281 00283 QTextStream& operator<<(QTextStream& ts, DtTMArea& area); 00284 QTextStream& operator>>(QTextStream& ts, DtTMArea& area); 00285 00286 inline void DtTMArea::setAlwaysResizeToGlobalView(bool b) 00287 { 00288 myAlwaysResizeToGlobalView = b; 00289 } 00290 00291 inline bool DtTMArea::alwaysResizeToGlobalView() const 00292 { 00293 return myAlwaysResizeToGlobalView; 00294 } 00295 00296 inline void DtTMArea::setWindow(DtBaseWindow* w) 00297 { 00298 myWindow = w; 00299 } 00300 00301 inline DtBaseWindow* DtTMArea::window() const 00302 { 00303 return myWindow; 00304 } 00305 00306 inline void DtTMArea::setNextTickIsRepaint(bool b) 00307 { 00308 myNextTickIsRepaint = b; 00309 } 00310 00311 inline bool DtTMArea::nextTickIsRepaint() const 00312 { 00313 return myNextTickIsRepaint; 00314 } 00315 00316 #endif //TMAREA_H