00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifndef SVTK_VIEWWINDOW_H
00024 #define SVTK_VIEWWINDOW_H
00025
00026 #ifdef WIN32
00027 #pragma warning( disable:4251 )
00028 #endif
00029
00030 #include "SVTK.h"
00031 #include "SVTK_Selection.h"
00032 #include "SUIT_ViewWindow.h"
00033
00034 #include "SALOME_InteractiveObject.hxx"
00035
00036 #include <QImage>
00037 #include <vtkSmartPointer.h>
00038
00039 class SUIT_Desktop;
00040 class SUIT_ResourceMgr;
00041
00042 class VTKViewer_Actor;
00043 class VTKViewer_Trihedron;
00044
00045 class SVTK_ViewModelBase;
00046
00047 class SVTK_Selector;
00048 class SVTK_View;
00049
00050 class SVTK_CubeAxesActor2D;
00051
00052 class vtkRenderer;
00053 class vtkRenderWindow;
00054 class vtkRenderWindowInteractor;
00055 class vtkInteractorStyle;
00056 class SVTK_RenderWindowInteractor;
00057 class SVTK_Renderer;
00058 class SVTK_NonIsometricDlg;
00059 class SVTK_UpdateRateDlg;
00060 class SVTK_CubeAxesDlg;
00061 class SVTK_SetRotationPointDlg;
00062 class SVTK_InteractorStyle;
00063 class SVTK_KeyFreeInteractorStyle;
00064 class SVTK_ViewParameterDlg;
00065 class SVTK_Recorder;
00066
00067 class vtkPVAxesWidget;
00068
00069 class vtkObject;
00070 class QtxAction;
00071
00072 namespace SVTK
00073 {
00074 SVTK_EXPORT
00075 int convertAction( const int );
00076 }
00077
00079 class SVTK_EXPORT SVTK_ViewWindow : public SUIT_ViewWindow
00080 {
00081 Q_OBJECT;
00082
00083 public:
00085 SVTK_ViewWindow(SUIT_Desktop* theDesktop);
00086
00087 virtual ~SVTK_ViewWindow();
00088
00089 virtual QImage dumpView();
00090
00092 virtual void Initialize(SVTK_ViewModelBase* theModel);
00093
00095 SVTK_View* getView();
00096
00098
00099
00101 vtkRenderWindow* getRenderWindow();
00102
00104 vtkRenderWindowInteractor* getInteractor() const;
00105
00107 SVTK_RenderWindowInteractor* GetInteractor() const;
00108
00109 vtkInteractorStyle* GetInteractorStyle() const;
00110
00112 void PushInteractorStyle(vtkInteractorStyle* theStyle);
00113
00115 void PopInteractorStyle();
00116
00118 vtkRenderer* getRenderer() const;
00119
00120 SVTK_Renderer* GetRenderer() const;
00121
00123 SVTK_Selector* GetSelector() const;
00124
00126 Selection_Mode SelectionMode() const;
00127
00129 virtual void SetSelectionMode(Selection_Mode theMode);
00130
00132 virtual void setBackgroundColor( const QColor& );
00133
00135 QColor backgroundColor() const;
00136
00138 bool isTrihedronDisplayed();
00139
00141 bool isCubeAxesDisplayed();
00142
00143
00145 virtual void highlight(const Handle(SALOME_InteractiveObject)& theIO,
00146 bool theIsHighlight = true,
00147 bool theIsUpdate = true);
00148
00150 virtual void unHighlightAll();
00151
00153 bool isInViewer(const Handle(SALOME_InteractiveObject)& theIObject);
00154
00156 bool isVisible(const Handle(SALOME_InteractiveObject)& theIObject);
00157
00159
00160 Handle(SALOME_InteractiveObject) FindIObject(const char* theEntry);
00161
00162
00163
00165 virtual void Display(const Handle(SALOME_InteractiveObject)& theIObject,
00166 bool theImmediatly = true);
00167
00169 virtual void DisplayOnly(const Handle(SALOME_InteractiveObject)& theIObject);
00170
00172 virtual void Erase(const Handle(SALOME_InteractiveObject)& theIObject,
00173 bool theImmediatly = true);
00174
00176 virtual void DisplayAll();
00177
00179 virtual void EraseAll();
00180
00182 virtual void Repaint(bool theUpdateTrihedron = true);
00183
00184
00186 virtual void SetScale( double theScale[3] );
00187
00189 virtual void GetScale( double theScale[3] );
00190
00192 virtual void AddActor(VTKViewer_Actor* theActor,
00193 bool theIsUpdate = false,
00194 bool theIsAdjustActors = true);
00195
00197 virtual void RemoveActor(VTKViewer_Actor* theActor,
00198 bool theIsUpdate = false,
00199 bool theIsAdjustActors = true);
00200
00201
00203 virtual void AdjustTrihedrons(const bool theIsForced);
00204
00206 VTKViewer_Trihedron* GetTrihedron();
00207
00209 SVTK_CubeAxesActor2D* GetCubeAxes();
00210
00212 vtkFloatingPointType GetTrihedronSize() const;
00213
00215 virtual void SetTrihedronSize( const vtkFloatingPointType, const bool = true );
00216
00218 virtual void SetIncrementalSpeed( const int, const int = 0 );
00219
00221 virtual void SetProjectionMode( const int );
00222
00224 virtual void SetInteractionStyle( const int );
00225
00227 virtual void SetZoomingStyle( const int );
00228
00230 virtual void SetSpacemouseButtons( const int, const int, const int );
00231
00233 virtual void SetSelectionProp(const double& theRed = 1,
00234 const double& theGreen = 1,
00235 const double& theBlue = 0,
00236 const int& theWidth = 5);
00237
00239 virtual void SetPreselectionProp(const double& theRed = 0,
00240 const double& theGreen = 1,
00241 const double& theBlue = 1,
00242 const int& theWidth = 5);
00243
00245 virtual void SetSelectionTolerance(const double& theTolNodes = 0.025,
00246 const double& theTolCell = 0.001,
00247 const double& theTolObjects = 0.025);
00248
00250 bool IsStaticTrihedronVisible() const;
00251
00253 virtual void SetStaticTrihedronVisible( const bool );
00254
00256 virtual QString getVisualParameters();
00257
00258 virtual void setVisualParameters( const QString& parameters );
00259
00260 virtual bool eventFilter( QObject*, QEvent* );
00261
00262 virtual void RefreshDumpImage();
00263
00265 void InvokeEvent(unsigned long theEvent, void* theCallData);
00266
00267 signals:
00268 void Show( QShowEvent * );
00269 void Hide( QHideEvent * );
00270
00271 public slots:
00272 virtual void showEvent( QShowEvent * );
00273 virtual void hideEvent( QHideEvent * );
00274 virtual void onSelectionChanged();
00275
00276 void onChangeRotationPoint(bool theIsActivate);
00277
00278 void activateSetRotationGravity();
00279 void activateSetRotationSelected(void* theData);
00280 void activateStartPointSelection();
00281
00282 void onUpdateRate(bool theIsActivate);
00283 void onNonIsometric(bool theIsActivate);
00284 void onGraduatedAxes(bool theIsActivate);
00285
00286 void activateZoom();
00287 void activateWindowFit();
00288 void activateRotation();
00289 void activatePanning();
00290 void activateGlobalPanning();
00291
00292 void onPerspectiveMode();
00293
00294 void activateProjectionMode(int);
00295
00296 void activateSetFocalPointGravity();
00297 void activateSetFocalPointSelected();
00298 void activateStartFocalPointSelection();
00299
00300 void onViewParameters(bool theIsActivate);
00301
00302 void onSwitchInteractionStyle(bool theOn);
00303 void onSwitchZoomingStyle(bool theOn);
00304
00305 void onStartRecording();
00306 void onPlayRecording();
00307 void onPauseRecording();
00308 void onStopRecording();
00309
00310 signals:
00311 void selectionChanged();
00312 void actorAdded(VTKViewer_Actor*);
00313 void actorRemoved(VTKViewer_Actor*);
00314
00315 public slots:
00317 virtual void onFrontView();
00318
00320 virtual void onBackView();
00321
00323 virtual void onTopView();
00324
00326 virtual void onBottomView();
00327
00329 virtual void onRightView();
00330
00332 virtual void onLeftView();
00333
00335 virtual void onClockWiseView();
00336
00338 virtual void onAntiClockWiseView();
00339
00341 virtual void onResetView();
00342
00344 virtual void onFitAll();
00345
00347 virtual void onViewTrihedron();
00348
00350 virtual void onViewCubeAxes();
00351
00353 virtual void onAdjustTrihedron();
00354
00356 virtual void onAdjustCubeAxes();
00357
00358 protected slots:
00359 void onKeyPressed(QKeyEvent* event);
00360 void onKeyReleased(QKeyEvent* event);
00361 void onMousePressed(QMouseEvent* event);
00362 void onMouseDoubleClicked(QMouseEvent* event);
00363 void onMouseReleased(QMouseEvent* event);
00364 void onMouseMoving(QMouseEvent* event);
00365
00366 protected:
00367 virtual void Initialize(SVTK_View* theView,
00368 SVTK_ViewModelBase* theModel);
00369
00370 void doSetVisualParameters( const QString& );
00371 void SetEventDispatcher(vtkObject* theDispatcher);
00372
00373 QImage dumpViewContent();
00374
00375 virtual QString filter() const;
00376 virtual bool dumpViewToFormat( const QImage& img, const QString& fileName, const QString& format );
00377
00378 virtual bool action( const int );
00379
00380 QtxAction* getAction( int ) const;
00381 void createToolBar();
00382 void createActions(SUIT_ResourceMgr* theResourceMgr);
00383
00384 enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId,
00385 ChangeRotationPointId, RotationId,
00386 FrontId, BackId, TopId, BottomId, LeftId, RightId, ClockWiseId, AntiClockWiseId, ResetId,
00387 ViewTrihedronId, NonIsometric, GraduatedAxes, UpdateRate,
00388 ParallelModeId, ProjectionModeId, ViewParametersId, SwitchInteractionStyleId,
00389 SwitchZoomingStyleId,
00390 StartRecordingId, PlayRecordingId, PauseRecordingId, StopRecordingId };
00391
00392
00393 SVTK_View* myView;
00394
00395 SVTK_ViewModelBase* myModel;
00396
00397 SVTK_RenderWindowInteractor* myInteractor;
00398 vtkSmartPointer<SVTK_InteractorStyle> myDefaultInteractorStyle;
00399 vtkSmartPointer<SVTK_KeyFreeInteractorStyle> myKeyFreeInteractorStyle;
00400
00401 QString myVisualParams;
00402
00403 vtkSmartPointer<vtkObject> myEventDispatcher;
00404
00405 SVTK_NonIsometricDlg* myNonIsometricDlg;
00406 SVTK_UpdateRateDlg* myUpdateRateDlg;
00407 SVTK_CubeAxesDlg* myCubeAxesDlg;
00408 SVTK_SetRotationPointDlg* mySetRotationPointDlg;
00409 SVTK_ViewParameterDlg* myViewParameterDlg;
00410
00411 QSize myPreRecordingMinSize;
00412 QSize myPreRecordingMaxSize;
00413
00414 SVTK_Recorder* myRecorder;
00415 QtxAction* myStartAction;
00416 QtxAction* myPlayAction;
00417 QtxAction* myPauseAction;
00418 QtxAction* myStopAction;
00419
00420 int myToolBar;
00421 int myRecordingToolBar;
00422
00423 vtkPVAxesWidget* myAxesWidget;
00424
00425 private:
00426 QImage myDumpImage;
00427 };
00428
00429 #ifdef WIN32
00430 #pragma warning( default:4251 )
00431 #endif
00432
00433 #endif