<parameter name="trihedron_size" value="100" />
</section>
<section name="VTKViewer" >
- <!-- OCC viewer preferences -->
+ <!-- VTK viewer preferences -->
<parameter name="background" value="0, 0, 0"/>
+ <parameter name="projection_mode" value="0" />
<parameter name="trihedron_size" value="100" />
<parameter name="relative_size" value="true" />
<parameter name="use_advanced_selection_algorithm" value="true" />
+ <parameter name="navigation_mode" value="0" />
+ <parameter name="speed_value" val ue="10" />
+ <parameter name="speed_mode" value="0" />
+ <parameter name="spacemouse_func1_btn" value="1" />
+ <parameter name="spacemouse_func2_btn" value="2" />
+ <parameter name="spacemouse_func5_btn" value="9" />
</section>
<section name="Plot2d" >
<!-- Plot2d viewer preferences -->
<source>PREF_STORE_POS</source>
<translation>Store positions of windows</translation>
</message>
+ <message>
+ <source>PREF_PROJECTION_MODE</source>
+ <translation>Projection mode:</translation>
+ </message>
+ <message>
+ <source>PREF_ORTHOGRAPHIC</source>
+ <translation>Orthogonal</translation>
+ </message>
+ <message>
+ <source>PREF_PERSPECTIVE</source>
+ <translation>Perspective</translation>
+ </message>
+ <message>
+ <source>PREF_NAVIGATION</source>
+ <translation>Navigation:</translation>
+ </message>
+ <message>
+ <source>PREF_STANDARD_STYLE</source>
+ <translation>Salome standard controls</translation>
+ </message>
+ <message>
+ <source>PREF_KEYFREE_STYLE</source>
+ <translation>Keyboard free style</translation>
+ </message>
+ <message>
+ <source>PREF_INCREMENTAL_SPEED</source>
+ <translation>Speed increment:</translation>
+ </message>
+ <message>
+ <source>PREF_INCREMENTAL_SPEED_MODE</source>
+ <translation>Modification mode:</translation>
+ </message>
+ <message>
+ <source>PREF_ARITHMETIC</source>
+ <translation>Arithmetic progression</translation>
+ </message>
+ <message>
+ <source>PREF_GEOMETRICAL</source>
+ <translation>Geometrical progression</translation>
+ </message>
+ <message>
+ <source>PREF_FRAME_SPACEMOUSE</source>
+ <translation>Spacemouse</translation>
+ </message>
+ <message>
+ <source>PREF_SPACEMOUSE_FUNC_1</source>
+ <translation>Decrease speed increment</translation>
+ </message>
+ <message>
+ <source>PREF_SPACEMOUSE_FUNC_2</source>
+ <translation>Increase speed increment</translation>
+ </message>
+ <message>
+ <source>PREF_SPACEMOUSE_FUNC_3</source>
+ <translation>Dominant / combined switch</translation>
+ </message>
+ <message>
+ <source>PREF_SPACEMOUSE_BTN_1</source>
+ <translation>Button 1</translation>
+ </message>
+ <message>
+ <source>PREF_SPACEMOUSE_BTN_2</source>
+ <translation>Button 2</translation>
+ </message>
+ <message>
+ <source>PREF_SPACEMOUSE_BTN_3</source>
+ <translation>Button 3</translation>
+ </message>
+ <message>
+ <source>PREF_SPACEMOUSE_BTN_4</source>
+ <translation>Button 4</translation>
+ </message>
+ <message>
+ <source>PREF_SPACEMOUSE_BTN_5</source>
+ <translation>Button 5</translation>
+ </message>
+ <message>
+ <source>PREF_SPACEMOUSE_BTN_6</source>
+ <translation>Button 6</translation>
+ </message>
+ <message>
+ <source>PREF_SPACEMOUSE_BTN_7</source>
+ <translation>Button 7</translation>
+ </message>
+ <message>
+ <source>PREF_SPACEMOUSE_BTN_8</source>
+ <translation>Button 8</translation>
+ </message>
+ <message>
+ <source>PREF_SPACEMOUSE_BTN_*</source>
+ <translation>Button *</translation>
+ </message>
+ <message>
+ <source>PREF_SPACEMOUSE_BTN_10</source>
+ <translation>Button 10</translation>
+ </message>
+ <message>
+ <source>PREF_SPACEMOUSE_BTN_11</source>
+ <translation>Button 11</translation>
+ </message>
+ <message>
+ <source>PREF_FRAME_RECORDING</source>
+ <translation>AVI Recording</translation>
+ </message>
+ <message>
+ <source>PREF_ALL_DISLPAYED_FRAMES</source>
+ <translation>Recording all displayed frames</translation>
+ </message>
+ <message>
+ <source>PREF_FPS</source>
+ <translation>FPS</translation>
+ </message>
+ <message>
+ <source>PREF_GROUP_TTL</source>
+ <translation>Settings</translation>
+ </message>
+ <message>
+ <source>PREF_PROGRESSIVE</source>
+ <translation>Progressive</translation>
+ </message>
+ <message>
+ <source>PREF_QUALITY</source>
+ <translation>Quality</translation>
+ </message>
+ <message>
+ <source>PREF_RECORDING_MODE</source>
+ <translation>Mode</translation>
+ </message>
+ <message>
+ <source>PREF_SKIPPED_FRAMES</source>
+ <translation>Recording at a given FPS</translation>
+ </message>
<message>
<source>PREF_BOTTOM</source>
<translation>Bottom</translation>
int nb = szList.count();
int new_prev = int( splitter_size * position / item_ind );
+ if (nb == item_ind) return;
int new_next = int( splitter_size * ( 1.0 - position ) / ( nb - item_ind ) );
setSizes( szList, item_ind, new_prev, new_next, new_next );
split->setSizes( szList );
lib_LTLIBRARIES = libSVTK.la
-salomeinclude_HEADERS = \
- SVTK.h \
- SVTK_Prs.h \
- SVTK_Actor.h \
- SALOME_Actor.h \
- SVTK_RectPicker.h \
- SVTK_DeviceActor.h \
- SVTK_DialogBase.h \
- SVTK_FontWidget.h \
- SVTK_CubeAxesActor2D.h \
- SVTK_Functor.h \
- SVTK_MainWindow.h \
- SVTK_View.h \
- SVTK_ViewManager.h \
- SVTK_ViewModel.h \
- SVTK_ViewWindow.h \
- SVTK_Renderer.h \
- SVTK_InteractorStyle.h \
- SVTK_RenderWindowInteractor.h \
- SVTK_GenericRenderWindowInteractor.h \
- SVTK_Selector.h \
- SVTK_Selection.h \
- SVTK_SelectionEvent.h \
- SVTK_SpaceMouse.h \
- SVTK_Event.h \
- SVTK_ViewModelBase.h \
- SVTK_SetRotationPointDlg.h \
- SVTK_Extension.h
+salomeinclude_HEADERS= \
+ SVTK.h \
+ SVTK_Prs.h \
+ SVTK_Actor.h \
+ SALOME_Actor.h \
+ SVTK_RectPicker.h \
+ SVTK_DeviceActor.h \
+ SVTK_DialogBase.h \
+ SVTK_FontWidget.h \
+ SVTK_CubeAxesActor2D.h \
+ SVTK_Functor.h \
+ SVTK_View.h \
+ SVTK_ViewManager.h \
+ SVTK_ViewModel.h \
+ SVTK_ViewWindow.h \
+ SVTK_Renderer.h \
+ SVTK_InteractorStyle.h \
+ SVTK_KeyFreeInteractorStyle.h \
+ SVTK_RenderWindowInteractor.h \
+ SVTK_GenericRenderWindowInteractor.h \
+ SVTK_Selector.h \
+ SVTK_Selection.h \
+ SVTK_SelectionEvent.h \
+ SVTK_SpaceMouse.h \
+ SVTK_Event.h \
+ SVTK_ViewModelBase.h \
+ SVTK_SetRotationPointDlg.h \
+ SVTK_ViewParameterDlg.h \
+ SVTK_ComboAction.h \
+ SVTK_Extension.h \
+ SVTK_Recorder.h \
+ SVTK_RecorderDlg.h \
+ SVTK_ImageWriter.h \
+ SVTK_ImageWriterMgr.h
+
+dist_libSVTK_la_SOURCES= \
+ SVTK_Prs.cxx \
+ SVTK_Actor.cxx \
+ SALOME_Actor.cxx \
+ SVTK_RectPicker.cxx \
+ SVTK_DeviceActor.cxx \
+ SVTK_CubeAxesActor2D.cxx \
+ SVTK_NonIsometricDlg.cxx \
+ SVTK_UpdateRateDlg.cxx \
+ SVTK_CubeAxesDlg.cxx \
+ SVTK_DialogBase.cxx \
+ SVTK_FontWidget.cxx \
+ SVTK_Trihedron.cxx \
+ SVTK_View.cxx \
+ SVTK_ViewManager.cxx \
+ SVTK_ViewModel.cxx \
+ SVTK_Renderer.cxx \
+ SVTK_ViewWindow.cxx \
+ SVTK_InteractorStyle.cxx \
+ SVTK_KeyFreeInteractorStyle.cxx \
+ SVTK_RenderWindowInteractor.cxx \
+ SVTK_GenericRenderWindowInteractor.cxx \
+ SVTK_SpaceMouse.cxx \
+ SVTK_Selector.cxx \
+ SVTK_SetRotationPointDlg.cxx \
+ SVTK_ViewParameterDlg.cxx \
+ SVTK_ComboAction.cxx \
+ SVTK_Extension.cxx \
+ SVTK_Recorder.cxx \
+ SVTK_RecorderDlg.cxx \
+ SVTK_ImageWriter.cxx \
+ SVTK_ImageWriterMgr.cxx
-dist_libSVTK_la_SOURCES = \
- SVTK_Prs.cxx \
- SVTK_Actor.cxx \
- SALOME_Actor.cxx \
- SVTK_RectPicker.cxx \
- SVTK_DeviceActor.cxx \
- SVTK_CubeAxesActor2D.cxx \
- SVTK_NonIsometricDlg.cxx \
- SVTK_UpdateRateDlg.cxx \
- SVTK_CubeAxesDlg.cxx \
- SVTK_DialogBase.cxx \
- SVTK_FontWidget.cxx \
- SVTK_Trihedron.cxx \
- SVTK_MainWindow.cxx \
- SVTK_View.cxx \
- SVTK_ViewManager.cxx \
- SVTK_ViewModel.cxx \
- SVTK_Renderer.cxx \
- SVTK_ViewWindow.cxx \
- SVTK_InteractorStyle.cxx \
- SVTK_RenderWindowInteractor.cxx \
- SVTK_GenericRenderWindowInteractor.cxx \
- SVTK_SpaceMouse.cxx \
- SVTK_Selector.cxx \
- SVTK_SetRotationPointDlg.cxx \
- SVTK_Extension.cxx
# internal headers
EXTRA_DIST += SVTK_SelectorDef.h SVTK_Trihedron.h
-MOC_FILES = \
- SVTK_GenericRenderWindowInteractor_moc.cxx \
- SVTK_RenderWindowInteractor_moc.cxx \
- SVTK_NonIsometricDlg_moc.cxx \
- SVTK_UpdateRateDlg_moc.cxx \
- SVTK_CubeAxesDlg_moc.cxx \
- SVTK_FontWidget_moc.cxx \
- SVTK_DialogBase_moc.cxx \
- SVTK_ViewModelBase_moc.cxx \
- SVTK_ViewManager_moc.cxx \
- SVTK_ViewWindow_moc.cxx \
- SVTK_MainWindow_moc.cxx \
- SVTK_ViewModel_moc.cxx \
- SVTK_View_moc.cxx \
- SVTK_SetRotationPointDlg_moc.cxx
-nodist_libSVTK_la_SOURCES = $(MOC_FILES)
+MOC_FILES= \
+ SVTK_GenericRenderWindowInteractor_moc.cxx \
+ SVTK_RenderWindowInteractor_moc.cxx \
+ SVTK_NonIsometricDlg_moc.cxx \
+ SVTK_UpdateRateDlg_moc.cxx \
+ SVTK_CubeAxesDlg_moc.cxx \
+ SVTK_FontWidget_moc.cxx \
+ SVTK_DialogBase_moc.cxx \
+ SVTK_ViewModelBase_moc.cxx \
+ SVTK_ViewManager_moc.cxx \
+ SVTK_ViewWindow_moc.cxx \
+ SVTK_ViewModel_moc.cxx \
+ SVTK_View_moc.cxx \
+ SVTK_SetRotationPointDlg_moc.cxx \
+ SVTK_ViewParameterDlg_moc.cxx \
+ SVTK_ComboAction_moc.cxx \
+ SVTK_RecorderDlg_moc.cxx
+nodist_libSVTK_la_SOURCES= $(MOC_FILES)
-dist_salomeres_DATA = \
- resources/vtk_view_graduated_axes.png \
- resources/vtk_view_scaling.png \
- resources/vtk_view_update_rate.png \
- resources/vtk_view_rotation_point.png
+dist_salomeres_DATA=\
+ resources/vtk_view_graduated_axes.png \
+ resources/vtk_view_scaling.png \
+ resources/vtk_view_update_rate.png \
+ resources/vtk_view_rotation_point.png \
+ resources/vtk_view_parallel.png \
+ resources/vtk_view_perspective.png \
+ resources/vtk_view_parameters.png \
+ resources/vtk_view_style_switch.png \
+ resources/vtk_view_recording_start.png \
+ resources/vtk_view_recording_play.png \
+ resources/vtk_view_recording_pause.png \
+ resources/vtk_view_recording_stop.png
nodist_salomeres_DATA = \
SVTK_msg_en.qm \
{
if ( !GetPickable() )
return false;
-
+
vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer();
//
myPreHighlightActor->SetVisibility( false );
#include "SVTK_CubeAxesActor2D.h"
#include "SVTK_Functor.h"
#include "SVTK_View.h"
-#include "SVTK_MainWindow.h"
-#include "SVTK_MainWindow.h"
+//#include "SVTK_MainWindow.h"
#include "SVTK_NonIsometricDlg.h"
#include "SVTK_CubeAxesDlg.h"
#include "SVTK_FontWidget.h"
HEADERS += SVTK_FontWidget.h
HEADERS += SVTK_CubeAxesActor2D.h
HEADERS += SVTK_Functor.h
-HEADERS += SVTK_MainWindow.h
HEADERS += SVTK_View.h
HEADERS += SVTK_ViewManager.h
HEADERS += SVTK_ViewModel.h
HEADERS += SVTK_ViewWindow.h
HEADERS += SVTK_Renderer.h
HEADERS += SVTK_InteractorStyle.h
+HEADERS += SVTK_KeyFreeInteractorStyle.h
HEADERS += SVTK_RenderWindowInteractor.h
HEADERS += SVTK_GenericRenderWindowInteractor.h
HEADERS += SVTK_Selector.h
HEADERS += SVTK_Event.h
HEADERS += SVTK_ViewModelBase.h
HEADERS += SVTK_SetRotationPointDlg.h
+HEADERS += SVTK_ViewParametersDlg.h
+HEADERS += SVTK_ComboAction.h
HEADERS += SVTK_Extension.h
SOURCES = SVTK_Prs.cxx
SOURCES += SVTK_DialogBase.cxx
SOURCES += SVTK_FontWidget.cxx
SOURCES += SVTK_Trihedron.cxx
-SOURCES += SVTK_MainWindow.cxx
SOURCES += SVTK_View.cxx
SOURCES += SVTK_ViewManager.cxx
SOURCES += SVTK_ViewModel.cxx
SOURCES += SVTK_Renderer.cxx
SOURCES += SVTK_ViewWindow.cxx
SOURCES += SVTK_InteractorStyle.cxx
+SOURCES += SVTK_KeyFreeInteractorStyle.cxx
SOURCES += SVTK_RenderWindowInteractor.cxx
SOURCES += SVTK_GenericRenderWindowInteractor.cxx
SOURCES += SVTK_SpaceMouse.cxx
SOURCES += SVTK_Selector.cxx
SOURCES += SVTK_SetRotationPointDlg.cxx
+SOURCES += SVTK_ViewParametersDlg.cxx
+SOURCES += SVTK_ComboAction.cxx
SOURCES += SVTK_Extension.cxx
TRANSLATIONS = resources/SVTK_images.ts \
--- /dev/null
+// SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+// File :
+// Author :
+// Module : SALOME
+// $Header:
+
+#include "SVTK_ComboAction.h"
+
+#include <QComboBox>
+#include <QHBoxLayout>
+
+SVTK_ComboAction::SVTK_ComboAction( QObject* parent )
+ : QWidgetAction( parent )
+{
+ myCurId = -1;
+}
+
+SVTK_ComboAction::SVTK_ComboAction( const QString& text, QObject* parent )
+ : QWidgetAction( parent )
+{
+ setToolTip( text );
+ myCurId = -1;
+}
+
+SVTK_ComboAction::~SVTK_ComboAction()
+{
+ myIcons.clear();
+}
+
+void SVTK_ComboAction::insertItem( const QIcon& icon, const int index )
+{
+ if ( index < 0 || index > myIcons.size() )
+ myIcons.append( icon );
+ else
+ myIcons.insert( index, icon );
+
+ update();
+}
+
+void SVTK_ComboAction::clear()
+{
+ myIcons.clear();
+ update();
+}
+
+void SVTK_ComboAction::setCurrentIndex( const int id )
+{
+ if ( myCurId != id )
+ {
+ myCurId = id;
+ update();
+ }
+}
+
+int SVTK_ComboAction::currentIndex() const
+{
+ return myCurId;
+}
+
+QWidget* SVTK_ComboAction::createWidget( QWidget* parent )
+{
+ QWidget* w = 0;
+ if ( parent->inherits("QToolBar") )
+ {
+ w = new QWidget( parent );
+ QHBoxLayout* l = new QHBoxLayout( w );
+ l->setSpacing(0); l->setMargin(0);
+ QComboBox* combo = new QComboBox( w );
+ combo->setFocusPolicy( Qt::NoFocus );
+ combo->setSizeAdjustPolicy( QComboBox::AdjustToContents );
+ l->addSpacing( 3 );
+ l->addWidget( combo );
+ l->addSpacing( 3 );
+
+ updateCombo( combo );
+ connect( combo, SIGNAL( activated( int ) ), this, SIGNAL( triggered( int ) ) );
+ }
+ return w;
+}
+
+void SVTK_ComboAction::update()
+{
+ QList<QWidget*> aList = createdWidgets();
+ for ( QList<QWidget*>::const_iterator it = aList.begin(); it != aList.end(); ++it )
+ updateCombo( qFindChild<QComboBox*>(*it) );
+}
+
+void SVTK_ComboAction::updateCombo( QComboBox* combo )
+{
+ if ( !combo ) return;
+
+ combo->clear();
+
+ for ( QList<QIcon>::const_iterator it = myIcons.begin(); it != myIcons.end(); ++it )
+ combo->addItem( *it, "" );
+
+ if ( combo->count() > 0 ) {
+ if ( myCurId < 0 ) myCurId = 0;
+ combo->setCurrentIndex( myCurId );
+ }
+}
--- /dev/null
+// SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+// File :
+// Author :
+// Module : SALOME
+// $Header:
+
+#ifndef SVTK_COMBOACTION_H
+#define SVTK_COMBOACTION_H
+
+#include "SVTK.h"
+
+#include <QWidgetAction>
+
+class QComboBox;
+class SVTK_EXPORT SVTK_ComboAction : public QWidgetAction
+{
+ Q_OBJECT
+
+public:
+ SVTK_ComboAction( QObject* = 0 );
+ SVTK_ComboAction( const QString&, QObject* = 0 );
+ virtual ~SVTK_ComboAction();
+
+ void insertItem( const QIcon&, const int = -1 );
+ void clear();
+
+ void setCurrentIndex( const int );
+ int currentIndex() const;
+
+signals:
+ void triggered( int );
+
+protected:
+ virtual QWidget* createWidget( QWidget* );
+
+ virtual void update();
+ virtual void updateCombo( QComboBox* );
+
+private:
+ QList<QIcon> myIcons;
+ int myCurId;
+};
+
+#endif // SVTK_COMBOACTION_H
#include "SVTK_CubeAxesDlg.h"
-#include "SVTK_MainWindow.h"
+#include "SVTK_ViewWindow.h"
#include "SVTK_FontWidget.h"
#include "SVTK_CubeAxesActor2D.h"
Constructor
*/
SVTK_CubeAxesDlg::SVTK_CubeAxesDlg(QtxAction* theAction,
- SVTK_MainWindow* theParent,
+ SVTK_ViewWindow* theParent,
const char* theName):
SVTK_DialogBase(theAction,
theParent,
class QtxAction;
class SVTK_CubeAxesActor2D;
-class SVTK_MainWindow;
+
+class SVTK_FontWidget;
+class SVTK_AxisWidget;
+class SVTK_ViewWindow;
/*!
* Class : SVTK_CubeAxesDlg
public:
SVTK_CubeAxesDlg(QtxAction* theAction,
- SVTK_MainWindow* theParent,
+ SVTK_ViewWindow* theParent,
const char* theName);
virtual ~SVTK_CubeAxesDlg();
bool isValid() const;
private:
- SVTK_MainWindow *myMainWindow;
+ SVTK_ViewWindow *myMainWindow;
SVTK_CubeAxesActor2D* myActor;
QTabWidget* myTabWg;
// VTK Includes
#include <vtkObjectFactory.h>
#include <vtkShrinkFilter.h>
+#include <vtkFeatureEdges.h>
#include <vtkPolyData.h>
#include <vtkUnstructuredGrid.h>
myIsShrunk = false;
myIsShrinkable = true;
+ myIsFeatureEdgesAllowed = false;
+ myIsFeatureEdgesEnabled = false;
+
myIsShaded = true;
myProperty = vtkProperty::New();
myRepresentation = SVTK::Representation::Surface;
myShrinkFilter = vtkShrinkFilter::New();
+ myFeatureEdges = vtkFeatureEdges::New();
+
myGeomFilter = VTKViewer_GeometryFilter::New();
myTransformFilter = VTKViewer_TransformFilter::New();
myShrinkFilter->Delete();
+ myFeatureEdges->Delete();
+
for(int i = 0, iEnd = myPassFilter.size(); i < iEnd; i++)
myPassFilter[i]->Delete();
}
if(myIsShrunk)
mTime = max(mTime,myShrinkFilter->GetMTime());
+ if(myIsFeatureEdgesEnabled)
+ mTime = max(mTime,myFeatureEdges->GetMTime());
+
for(int i = 0, iEnd = myPassFilter.size(); i < iEnd; i++)
max(mTime,myPassFilter[i]->GetMTime());
myShrinkFilter->SetShrinkFactor(theValue);
}
+/*!
+ \return true if feature edges are allowed for this actor
+*/
+bool
+SVTK_DeviceActor
+::IsFeatureEdgesAllowed()
+{
+ return myIsFeatureEdgesAllowed;
+}
+
+/*!
+ Allows feature edges for this actor on or off
+ \param theIsFeatureEdgesAllowed - flag which allows feature edges for this actor on or off
+*/
+void
+SVTK_DeviceActor
+::SetFeatureEdgesAllowed(bool theIsFeatureEdgesAllowed)
+{
+ myIsFeatureEdgesAllowed = theIsFeatureEdgesAllowed;
+}
+
+/*!
+ \return true if feature edges are enabled
+*/
+bool
+SVTK_DeviceActor
+::IsFeatureEdgesEnabled()
+{
+ return myIsFeatureEdgesEnabled;
+}
+
+/*!
+ Enables feature edges on or off
+ \param theIsFeatureEdgesEnabled - flag which enables feature edges on or off
+*/
+void
+SVTK_DeviceActor
+::SetFeatureEdgesEnabled(bool theIsFeatureEdgesEnabled)
+{
+ if ( !myIsFeatureEdgesAllowed || myIsFeatureEdgesEnabled == theIsFeatureEdgesEnabled )
+ return;
+
+ if ( vtkPolyData* aPolyData = myPassFilter[ 2 ]->GetPolyDataOutput() )
+ {
+ if( theIsFeatureEdgesEnabled )
+ {
+ aPolyData->Update();
+ myFeatureEdges->SetInput( aPolyData );
+ myPassFilter[ 3 ]->SetInput( myFeatureEdges->GetOutput() );
+ myIsFeatureEdgesEnabled = true;
+ }
+ else
+ {
+ myPassFilter[3]->SetInput( aPolyData );
+ myIsFeatureEdgesEnabled = false;
+ }
+ myIsFeatureEdgesEnabled = theIsFeatureEdgesEnabled;
+ }
+}
+
+/*!
+ \return angle of feature edges' filter
+*/
+vtkFloatingPointType
+SVTK_DeviceActor
+::GetFeatureEdgesAngle()
+{
+ return myFeatureEdges->GetFeatureAngle();
+}
+
+/*!
+ Sets angle of feature edges' filter
+ \param theAngle angle of feature edges' filter
+*/
+void
+SVTK_DeviceActor
+::SetFeatureEdgesAngle(vtkFloatingPointType theAngle)
+{
+ myFeatureEdges->SetFeatureAngle(theAngle);
+}
+
+/*!
+ Gets information about kinds of edges which are displayed by feature edges' filter
+ \param theIsFeatureEdges flag which shows whether feature edges are displayed
+ \param theIsBoundaryEdges flag which shows whether boundary edges are displayed
+ \param theIsManifoldEdges flag which shows whether manifold edges are displayed
+ \param theIsNonManifoldEdges flag which shows whether non-manifold edges are displayed
+*/
+void
+SVTK_DeviceActor
+::GetFeatureEdgesFlags(bool& theIsFeatureEdges,
+ bool& theIsBoundaryEdges,
+ bool& theIsManifoldEdges,
+ bool& theIsNonManifoldEdges)
+{
+ theIsFeatureEdges = myFeatureEdges->GetFeatureEdges();
+ theIsBoundaryEdges = myFeatureEdges->GetBoundaryEdges();
+ theIsManifoldEdges = myFeatureEdges->GetManifoldEdges();
+ theIsNonManifoldEdges = myFeatureEdges->GetNonManifoldEdges();
+}
+
+/*!
+ Sets different kinds of edges to be displayed by feature edges' filter
+ \param theIsFeatureEdges flag which displays feature edges
+ \param theIsBoundaryEdges flag which displays boundary edges
+ \param theIsManifoldEdges flag which displays manifold edges
+ \param theIsNonManifoldEdges flag which displays non-manifold edges
+*/
+void
+SVTK_DeviceActor
+::SetFeatureEdgesFlags(bool theIsFeatureEdges,
+ bool theIsBoundaryEdges,
+ bool theIsManifoldEdges,
+ bool theIsNonManifoldEdges)
+{
+ myFeatureEdges->SetFeatureEdges(theIsFeatureEdges);
+ myFeatureEdges->SetBoundaryEdges(theIsBoundaryEdges);
+ myFeatureEdges->SetManifoldEdges(theIsManifoldEdges);
+ myFeatureEdges->SetNonManifoldEdges(theIsNonManifoldEdges);
+}
+
+/*!
+ \return feature edges' coloring flag
+*/
+bool
+SVTK_DeviceActor
+::GetFeatureEdgesColoring()
+{
+ return myFeatureEdges->GetColoring();
+}
+
+/*!
+ Sets feature edges' coloring flag
+ \param theIsColoring feature edges' coloring flag
+*/
+void
+SVTK_DeviceActor
+::SetFeatureEdgesColoring(bool theIsColoring)
+{
+ myFeatureEdges->SetColoring(theIsColoring);
+}
+
/*!
Set representation (VTK_SURFACE, VTK_POINTS, VTK_WIREFRAME and so on)
param theMode - new mode
class vtkCell;
class vtkDataSet;
class vtkShrinkFilter;
+class vtkFeatureEdges;
class vtkDataSetMapper;
class vtkPassThroughFilter;
UnShrink();
//@}
+ /** @name For feature edges management purpose */
+ //@{
+ virtual
+ bool
+ IsFeatureEdgesAllowed();
+
+ virtual
+ void
+ SetFeatureEdgesAllowed(bool theIsFeatureEdgesAllowed);
+
+ virtual
+ bool
+ IsFeatureEdgesEnabled();
+
+ virtual
+ void
+ SetFeatureEdgesEnabled(bool theIsFeatureEdgesEnabled);
+
+ virtual
+ vtkFloatingPointType
+ GetFeatureEdgesAngle();
+
+ virtual
+ void
+ SetFeatureEdgesAngle(vtkFloatingPointType theAngle);
+
+ virtual
+ void
+ GetFeatureEdgesFlags(bool& theIsFeatureEdges,
+ bool& theIsBoundaryEdges,
+ bool& theIsManifoldEdges,
+ bool& theIsNonManifoldEdges);
+ virtual
+ void
+ SetFeatureEdgesFlags(bool theIsFeatureEdges,
+ bool theIsBoundaryEdges,
+ bool theIsManifoldEdges,
+ bool theIsNonManifoldEdges);
+
+ virtual
+ bool
+ GetFeatureEdgesColoring();
+
+ virtual
+ void
+ SetFeatureEdgesColoring(bool theIsColoring);
+ //@}
+
/** @name For representation mamnagement purpose */
virtual
void
VTKViewer_TransformFilter *myTransformFilter;
std::vector<vtkPassThroughFilter*> myPassFilter;
vtkShrinkFilter* myShrinkFilter;
+ vtkFeatureEdges* myFeatureEdges;
vtkDataSetMapper* myMapper;
bool myIsShrinkable;
bool myIsShrunk;
+ bool myIsFeatureEdgesAllowed;
+ bool myIsFeatureEdgesEnabled;
+
bool myIsResolveCoincidentTopology;
vtkFloatingPointType myPolygonOffsetFactor;
vtkFloatingPointType myPolygonOffsetUnits;
StartFitArea,
SetRotateGravity,
- StartPointSelection,
SetRotateSelected,
+ StartPointSelection,
BBCenterChanged,
RotationPointChanged,
ChangeRotationPoint,
+
+ SetFocalPointGravity,
+ SetFocalPointSelected,
+ StartFocalPointSelection,
+ FocalPointChanged,
LastEvent
};
--- /dev/null
+// Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
+#include "SVTK_ImageWriter.h"
+
+#include <QSemaphore>
+
+#include <vtkImageData.h>
+#include <vtkImageClip.h>
+#include <vtkJPEGWriter.h>
+#include <vtkSmartPointer.h>
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+
+//----------------------------------------------------------------------------
+SVTK_ImageWriter
+::SVTK_ImageWriter(QSemaphore* theSemaphore,
+ vtkImageData* theImageData,
+ const std::string& theName,
+ int theProgressive,
+ int theQuality):
+ mySemaphore(theSemaphore),
+ myImageData(theImageData),
+ myName(theName),
+ myProgressive(theProgressive),
+ myQuality(theQuality),
+ myConstraint16Flag(true)
+{}
+
+//----------------------------------------------------------------------------
+SVTK_ImageWriter
+::~SVTK_ImageWriter()
+{
+ if(MYDEBUG) cout<<"SVTK_ImageWriter::~SVTK_ImageWriter - this = "<<this<<endl;
+}
+
+
+//----------------------------------------------------------------------------
+void
+SVTK_ImageWriter
+::run()
+{
+ vtkJPEGWriter *aWriter = vtkJPEGWriter::New();
+ vtkImageData *anImageData = myImageData;
+ vtkSmartPointer<vtkImageClip> anImageClip;
+ //
+ if(myConstraint16Flag){
+ int uExtent[6];
+ myImageData->UpdateInformation();
+ myImageData->GetUpdateExtent(uExtent);
+ unsigned int width = uExtent[1] - uExtent[0] + 1;
+ unsigned int height = uExtent[3] - uExtent[2] + 1;
+ width = (width / 16) * 16;
+ height= (height / 16) * 16;
+ uExtent[1] = uExtent[0] + width - 1;
+ uExtent[3] = uExtent[2] + height - 1;
+ //
+ anImageClip = vtkImageClip::New();
+ anImageClip->Delete();
+
+ anImageClip->SetInput(myImageData);
+ anImageClip->SetOutputWholeExtent(uExtent);
+ anImageClip->ClipDataOn();
+ anImageData = anImageClip->GetOutput();
+ }
+ //
+ aWriter->WriteToMemoryOff();
+ aWriter->SetFileName(myName.c_str());
+ aWriter->SetQuality(myQuality);
+ aWriter->SetProgressive(myProgressive);
+ aWriter->SetInput(anImageData);
+ aWriter->Write();
+
+ aWriter->Delete();
+ myImageData->Delete();
+
+ if(MYDEBUG) cout<<"SVTK_ImageWriter::run "<<
+ "- this = "<<this<<
+ //"; total = "<<mySemaphore->total()<<
+ "; available = "<<mySemaphore->available()<<endl;
+ mySemaphore->release();
+}
+
--- /dev/null
+// Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
+#ifndef SVTK_IMAGEWRITER_H
+#define SVTK_IMAGEWRITER_H
+
+#include <QThread>
+#include <string>
+
+class vtkImageData;
+class QSemaphore;
+
+class SVTK_ImageWriter : public QThread
+{
+public:
+ SVTK_ImageWriter(QSemaphore* theSemaphore,
+ vtkImageData* theImageData,
+ const std::string& theName,
+ int theProgressive,
+ int theQuality);
+
+ ~SVTK_ImageWriter();
+
+ protected:
+ virtual
+ void
+ run();
+
+ protected:
+ QSemaphore* mySemaphore;
+ vtkImageData *myImageData;
+ std::string myName;
+ int myProgressive;
+ int myQuality;
+ bool myConstraint16Flag;
+};
+
+#endif
--- /dev/null
+// Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
+#include "SVTK_ImageWriterMgr.h"
+#include "SVTK_ImageWriter.h"
+
+#include <vtkImageData.h>
+
+#include <QSemaphore>
+
+#include <limits>
+
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+//----------------------------------------------------------------------------
+SVTK_ImageWriterMgr
+::SVTK_ImageWriterMgr()
+{
+ int aMax = std::numeric_limits<int>::max() / 2;
+ mySemaphore = new QSemaphore(aMax);
+ mySemaphore->acquire( aMax );
+ if(MYDEBUG) cout<<"SVTK_ImageWriterMgr::SVTK_ImageWriterMgr "<<
+ //"- total = "<<mySemaphore->total()<<
+ "; available = "<<mySemaphore->available()<<endl;
+}
+
+
+//----------------------------------------------------------------------------
+SVTK_ImageWriterMgr
+::~SVTK_ImageWriterMgr()
+{
+ Stop();
+ delete mySemaphore;
+}
+
+
+//----------------------------------------------------------------------------
+void
+SVTK_ImageWriterMgr
+::StartImageWriter(vtkImageData *theImageData,
+ const std::string& theName,
+ const int theProgressive,
+ const int theQuality)
+{
+ SVTK_ImageWriter *anImageWriter =
+ new SVTK_ImageWriter(mySemaphore,
+ theImageData,
+ theName,
+ theProgressive,
+ theQuality);
+ myThreads.push_back(anImageWriter);
+
+ anImageWriter->start();
+
+}
+
+
+//----------------------------------------------------------------------------
+void
+SVTK_ImageWriterMgr
+::Stop()
+{
+ if(MYDEBUG) cout<<"SVTK_ImageWriterMgr::Stop "<<
+ //"- total = "<<mySemaphore->total()<<
+ "; available = "<<mySemaphore->available()<<endl;
+ if(MYDEBUG) cout<<"SVTK_ImageWriterMgr::Stop - *mySemaphore += "<<myThreads.size()<<endl;
+ mySemaphore->acquire( myThreads.size() );
+
+ for(size_t anId = 0, anEnd = myThreads.size(); anId < anEnd; anId++){
+ SVTK_ImageWriter* anImageWriter = myThreads[anId];
+ anImageWriter->wait();
+ delete anImageWriter;
+ }
+ myThreads.clear();
+}
--- /dev/null
+// Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
+#ifndef SVTK_IMAGEWRITERMGR_H
+#define SVTK_IMAGEWRITERMGR_H
+
+#include <string>
+#include <vector>
+
+class QString;
+class vtkImageData;
+class SVTK_ImageWriter;
+class QSemaphore;
+
+class SVTK_ImageWriterMgr
+{
+ public:
+ SVTK_ImageWriterMgr();
+ ~SVTK_ImageWriterMgr();
+
+ void
+ StartImageWriter(vtkImageData *theImageData,
+ const std::string& theName,
+ const int theProgressive,
+ const int theQuality);
+
+ void
+ Stop();
+
+ typedef std::vector<SVTK_ImageWriter*> TWriterThreads;
+
+ protected:
+ TWriterThreads myThreads;
+
+ QSemaphore* mySemaphore;
+};
+
+#endif
+
namespace
{
- inline
- void
- GetEventPosition(vtkRenderWindowInteractor* theInteractor,
- int& theX,
- int& theY)
+ inline void GetEventPosition(vtkRenderWindowInteractor* theInteractor,
+ int& theX,
+ int& theY)
{
theInteractor->GetEventPosition(theX,theY);
theY = theInteractor->GetSize()[1] - theY - 1;
/*!
Constructor
*/
-SVTK_InteractorStyle
-::SVTK_InteractorStyle():
+SVTK_InteractorStyle::SVTK_InteractorStyle():
mySelectionEvent(new SVTK_SelectionEvent()),
myPointPicker(vtkPointPicker::New()),
myLastHighlitedActor(NULL),
myLastPreHighlitedActor(NULL),
myControllerIncrement(SVTK_ControllerIncrement::New()),
myControllerOnKeyDown(SVTK_ControllerOnKeyDown::New()),
- myHighlightRotationPointActor(SVTK_Actor::New()),
+ myHighlightSelectionPointActor(SVTK_Actor::New()),
myRectBand(0)
{
myPointPicker->Delete();
myCurrRotationPointType = SVTK::SetRotateGravity;
myPrevRotationPointType = myCurrRotationPointType;
- myHighlightRotationPointActor->Delete();
- myHighlightRotationPointActor->Initialize();
- myHighlightRotationPointActor->PickableOff();
- myHighlightRotationPointActor->SetVisibility( false );
+ myCurrFocalPointType = SVTK::SetFocalPointSelected;
+ myPrevFocalPointType = myCurrFocalPointType;
+
+ myHighlightSelectionPointActor->Delete();
+ myHighlightSelectionPointActor->Initialize();
+ myHighlightSelectionPointActor->PickableOff();
+ myHighlightSelectionPointActor->SetVisibility( false );
- myHighlightRotationPointActor->GetProperty()->SetPointSize(SALOME_POINT_SIZE+2);
- myHighlightRotationPointActor->GetProperty()->SetLineWidth(SALOME_LINE_WIDTH+2);
- myHighlightRotationPointActor->GetProperty()->SetRepresentationToPoints();
+ myHighlightSelectionPointActor->GetProperty()->SetPointSize(SALOME_POINT_SIZE+2);
+ myHighlightSelectionPointActor->GetProperty()->SetLineWidth(SALOME_LINE_WIDTH+2);
+ myHighlightSelectionPointActor->GetProperty()->SetRepresentationToPoints();
myBBFirstCheck = true;
}
/*!
Destructor
*/
-SVTK_InteractorStyle
-::~SVTK_InteractorStyle()
+SVTK_InteractorStyle::~SVTK_InteractorStyle()
{
endDrawRect();
}
/*!
\return widget for rendering
*/
-QWidget*
-SVTK_InteractorStyle
-::GetRenderWidget()
+QWidget* SVTK_InteractorStyle::GetRenderWidget()
{
return myInteractor->GetRenderWidget();
}
/*!
\return selector
*/
-SVTK_Selector*
-SVTK_InteractorStyle
-::GetSelector()
+SVTK_Selector* SVTK_InteractorStyle::GetSelector()
{
return myInteractor->GetSelector();
}
/*!
Generate special SVTK_SelectionEvent
*/
-SVTK_SelectionEvent*
-SVTK_InteractorStyle
-::GetSelectionEvent()
+SVTK_SelectionEvent* SVTK_InteractorStyle::GetSelectionEvent()
{
mySelectionEvent->mySelectionMode = GetSelector()->SelectionMode();
/*!
Generate special SVTK_SelectionEvent with flipped Y coordinate
*/
-SVTK_SelectionEvent*
-SVTK_InteractorStyle
-::GetSelectionEventFlipY()
+SVTK_SelectionEvent* SVTK_InteractorStyle::GetSelectionEventFlipY()
{
mySelectionEvent->mySelectionMode = GetSelector()->SelectionMode();
return mySelectionEvent.get();
}
-void
-SVTK_InteractorStyle
-::RotateXY(int dx, int dy)
+void SVTK_InteractorStyle::RotateXY(int dx, int dy)
{
/* if(GetCurrentRenderer() == NULL)
return;
this->Render();
}
-void
-SVTK_InteractorStyle
-::PanXY(int x, int y, int oldX, int oldY)
+void SVTK_InteractorStyle::PanXY(int x, int y, int oldX, int oldY)
{
TranslateView(x, y, oldX, oldY);
this->Render();
}
-
-void
-SVTK_InteractorStyle
-::DollyXY(int dx, int dy)
+void SVTK_InteractorStyle::DollyXY(int dx, int dy)
{
if (GetCurrentRenderer() == NULL)
return;
if (aCam->GetParallelProjection())
aCam->SetParallelScale(aCam->GetParallelScale()/zoomFactor);
else{
- aCam->Dolly(zoomFactor);
+ aCam->Dolly(zoomFactor); // Move camera in/out along projection direction
GetCurrentRenderer()->ResetCameraClippingRange();
}
this->Render();
}
-void
-SVTK_InteractorStyle
-::SpinXY(int x, int y, int oldX, int oldY)
+void SVTK_InteractorStyle::SpinXY(int x, int y, int oldX, int oldY)
{
vtkCamera *cam;
/*!
To reset reset view
*/
-void
-SVTK_InteractorStyle
-::OnConfigure()
+void SVTK_InteractorStyle::OnConfigure()
{
this->FindPokedRenderer(0,0);
this->GetCurrentRenderer()->InvokeEvent(vtkCommand::ConfigureEvent,NULL);
/*!
To handle mouse move event
*/
-void
-SVTK_InteractorStyle
-::OnMouseMove()
+void SVTK_InteractorStyle::OnMouseMove()
{
int x, y;
GetEventPosition( this->Interactor, x, y );
/*!
To handle left mouse button down event (reimplemented from vtkInteractorStyle)
*/
-void
-SVTK_InteractorStyle
-::OnLeftButtonDown()
+void SVTK_InteractorStyle::OnLeftButtonDown()
{
int x, y;
GetEventPosition( this->Interactor, x, y );
/*!
To handle left mouse button up event (reimplemented from vtkInteractorStyle)
*/
-void
-SVTK_InteractorStyle
-::OnLeftButtonUp()
+void SVTK_InteractorStyle::OnLeftButtonUp()
{
int x, y;
GetEventPosition( this->Interactor, x, y );
/*!
To handle middle mouse button down event (reimplemented from vtkInteractorStyle)
*/
-void
-SVTK_InteractorStyle
-::OnMiddleButtonDown()
+void SVTK_InteractorStyle::OnMiddleButtonDown()
{
int x, y;
GetEventPosition( this->Interactor, x, y );
/*!
To handle middle mouse button up event (reimplemented from vtkInteractorStyle)
*/
-void
-SVTK_InteractorStyle
-::OnMiddleButtonUp()
+void SVTK_InteractorStyle::OnMiddleButtonUp()
{
int x, y;
GetEventPosition( this->Interactor, x, y );
/*!
To handle right mouse button down event (reimplemented from vtkInteractorStyle)
*/
-void
-SVTK_InteractorStyle
-::OnRightButtonDown()
+void SVTK_InteractorStyle::OnRightButtonDown()
{
int x, y;
GetEventPosition( this->Interactor, x, y );
/*!
To handle right mouse button up event (reimplemented from vtkInteractorStyle)
*/
-void
-SVTK_InteractorStyle
-::OnRightButtonUp()
+void SVTK_InteractorStyle::OnRightButtonUp()
{
int x, y;
GetEventPosition( this->Interactor, x, y );
/*!
To handle mouse move event
*/
-void
-SVTK_InteractorStyle
-::OnMouseMove(int vtkNotUsed(ctrl),
- int shift,
- int x, int y)
+void SVTK_InteractorStyle::OnMouseMove(int vtkNotUsed(ctrl),
+ int shift,
+ int x, int y)
{
myShiftState = shift;
if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
/*!
To handle left mouse button down event (reimplemented from vtkInteractorStyle)
*/
-void
-SVTK_InteractorStyle
-::OnLeftButtonDown(int ctrl, int shift,
- int x, int y)
+void SVTK_InteractorStyle::OnLeftButtonDown(int ctrl, int shift,
+ int x, int y)
{
this->FindPokedRenderer(x, y);
if(GetCurrentRenderer() == NULL)
} else {
if (ctrl)
startOperation(VTK_INTERACTOR_STYLE_CAMERA_ZOOM);
- else if ( myCurrRotationPointType == SVTK::StartPointSelection )
+ else if ( myCurrRotationPointType == SVTK::StartPointSelection ||
+ myCurrFocalPointType == SVTK::StartFocalPointSelection )
{
SVTK_SelectionEvent* aSelectionEvent = GetSelectionEventFlipY();
int anObjId = anActor->GetNodeObjId( aVtkId );
vtkFloatingPointType* aCoords = anActor->GetNodeCoord(anObjId);
- myCurrRotationPointType = SVTK::SetRotateSelected;
+ if (myCurrRotationPointType == SVTK::StartPointSelection) {
+ myCurrRotationPointType = SVTK::SetRotateSelected;
- // invoke event for update coordinates in SVTK_SetRotationPointDlg
- InvokeEvent(SVTK::RotationPointChanged,(void*)aCoords);
+ // invoke event for update coordinates in SVTK_SetRotationPointDlg
+ InvokeEvent(SVTK::RotationPointChanged,(void*)aCoords);
+ }
+ else if (myCurrFocalPointType == SVTK::StartFocalPointSelection) {
+ myCurrFocalPointType = SVTK::SetFocalPointSelected;
+
+ // invoke event for update coordinates in SVTK_ViewParameterDlg
+ InvokeEvent(SVTK::FocalPointChanged,(void*)aCoords);
+ }
}
else
{
- // invoke event with no data (for SVTK_SetRotationPointDlg)
- InvokeEvent(SVTK::RotationPointChanged,0);
- myCurrRotationPointType = myPrevRotationPointType;
+ if (myCurrRotationPointType == SVTK::StartPointSelection) {
+ // invoke event with no data (for SVTK_SetRotationPointDlg)
+ InvokeEvent(SVTK::RotationPointChanged,0);
+ myCurrRotationPointType = myPrevRotationPointType;
+ }
+ else if (myCurrFocalPointType == SVTK::StartFocalPointSelection) {
+ // invoke event with no data (for SVTK_ViewParameterDlg)
+ InvokeEvent(SVTK::FocalPointChanged,0);
+ myCurrFocalPointType = myPrevFocalPointType;
+ }
}
}
else
{
- // invoke event with no data (for SVTK_SetRotationPointDlg)
- InvokeEvent(SVTK::RotationPointChanged,0);
- myCurrRotationPointType = myPrevRotationPointType;
+ if (myCurrRotationPointType == SVTK::StartPointSelection) {
+ // invoke event with no data (for SVTK_SetRotationPointDlg)
+ InvokeEvent(SVTK::RotationPointChanged,0);
+ myCurrRotationPointType = myPrevRotationPointType;
+ }
+ else if (myCurrFocalPointType == SVTK::StartFocalPointSelection) {
+ // invoke event with no data (for SVTK_ViewParameterDlg)
+ InvokeEvent(SVTK::FocalPointChanged,0);
+ myCurrFocalPointType = myPrevFocalPointType;
+ }
}
- myHighlightRotationPointActor->SetVisibility( false );
+ myHighlightSelectionPointActor->SetVisibility( false );
if(GetCurrentRenderer() != NULL)
- GetCurrentRenderer()->RemoveActor( myHighlightRotationPointActor.GetPointer() );
+ GetCurrentRenderer()->RemoveActor( myHighlightSelectionPointActor.GetPointer() );
GetRenderWidget()->setCursor(myDefCursor);
}
/*!
To handle left mouse button up event (reimplemented from vtkInteractorStyle)
*/
-void
-SVTK_InteractorStyle
-::OnLeftButtonUp(int vtkNotUsed(ctrl),
- int shift,
- int vtkNotUsed(x),
- int vtkNotUsed(y))
+void SVTK_InteractorStyle::OnLeftButtonUp(int vtkNotUsed(ctrl),
+ int shift,
+ int vtkNotUsed(x),
+ int vtkNotUsed(y))
{
myShiftState = shift;
// finishing current viewer operation
/*!
To handle middle mouse button down event (reimplemented from vtkInteractorStyle)
*/
-void
-SVTK_InteractorStyle
-::OnMiddleButtonDown(int ctrl,
- int shift,
- int x, int y)
+void SVTK_InteractorStyle::OnMiddleButtonDown(int ctrl,
+ int shift,
+ int x, int y)
{
this->FindPokedRenderer(x, y);
if(GetCurrentRenderer() == NULL)
/*!
To handle middle mouse button up event (reimplemented from vtkInteractorStyle)
*/
-void
-SVTK_InteractorStyle
-::OnMiddleButtonUp(int vtkNotUsed(ctrl),
- int shift,
- int vtkNotUsed(x),
- int vtkNotUsed(y))
+void SVTK_InteractorStyle::OnMiddleButtonUp(int vtkNotUsed(ctrl),
+ int shift,
+ int vtkNotUsed(x),
+ int vtkNotUsed(y))
{
myShiftState = shift;
// finishing current viewer operation
/*!
To handle right mouse button down event (reimplemented from vtkInteractorStyle)
*/
-void
-SVTK_InteractorStyle
-::OnRightButtonDown(int ctrl,
- int shift,
- int x, int y)
+void SVTK_InteractorStyle::OnRightButtonDown(int ctrl,
+ int shift,
+ int x, int y)
{
this->FindPokedRenderer(x, y);
if(GetCurrentRenderer() == NULL)
/*!
To handle right mouse button up event (reimplemented from vtkInteractorStyle)
*/
-void
-SVTK_InteractorStyle
-::OnRightButtonUp(int vtkNotUsed(ctrl),
- int shift,
- int vtkNotUsed(x),
- int vtkNotUsed(y))
+void SVTK_InteractorStyle::OnRightButtonUp(int vtkNotUsed(ctrl),
+ int shift,
+ int vtkNotUsed(x),
+ int vtkNotUsed(y))
{
myShiftState = shift;
// finishing current viewer operation
/*!
loads cursors for viewer operations - zoom, pan, etc...
*/
-void
-SVTK_InteractorStyle
-::loadCursors()
+void SVTK_InteractorStyle::loadCursors()
{
myDefCursor = QCursor(Qt::ArrowCursor);
myHandCursor = QCursor(Qt::PointingHandCursor);
/*!
Starts Zoom operation (e.g. through menu command)
*/
-void
-SVTK_InteractorStyle
-::startZoom()
+void SVTK_InteractorStyle::startZoom()
{
if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
{
/*!
Starts Pan operation (e.g. through menu command)
*/
-void
-SVTK_InteractorStyle
-::startPan()
+void SVTK_InteractorStyle::startPan()
{
if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
{
/*!
Starts Rotate operation (e.g. through menu command)
*/
-void
-SVTK_InteractorStyle
-::startRotate()
+void SVTK_InteractorStyle::startRotate()
{
if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
{
/*!
Set rotation point selected by user
*/
-void
-SVTK_InteractorStyle
-::startPointSelection()
+void SVTK_InteractorStyle::startPointSelection()
{
myCurrRotationPointType = SVTK::StartPointSelection;
if(GetCurrentRenderer() != NULL) {
- GetCurrentRenderer()->AddActor( myHighlightRotationPointActor.GetPointer() );
+ GetCurrentRenderer()->AddActor( myHighlightSelectionPointActor.GetPointer() );
+ vtkFloatingPointType aColor[3];
+ GetCurrentRenderer()->GetBackground( aColor );
+ myHighlightSelectionPointActor->GetProperty()->SetColor(1. - aColor[0],
+ 1. - aColor[1],
+ 1. - aColor[2]);
+ }
+
+ setCursor(VTK_INTERACTOR_STYLE_CAMERA_NONE);
+}
+
+/*!
+ Set focal point selected by user
+*/
+void SVTK_InteractorStyle::startFocalPointSelection()
+{
+ myCurrFocalPointType = SVTK::StartFocalPointSelection;
+
+ if(GetCurrentRenderer() != NULL) {
+ GetCurrentRenderer()->AddActor( myHighlightSelectionPointActor.GetPointer() );
vtkFloatingPointType aColor[3];
GetCurrentRenderer()->GetBackground( aColor );
- myHighlightRotationPointActor->GetProperty()->SetColor(1. - aColor[0],
- 1. - aColor[1],
- 1. - aColor[2]);
+ myHighlightSelectionPointActor->GetProperty()->SetColor(1. - aColor[0],
+ 1. - aColor[1],
+ 1. - aColor[2]);
}
setCursor(VTK_INTERACTOR_STYLE_CAMERA_NONE);
/*!
Starts Spin operation (e.g. through menu command)
*/
-void
-SVTK_InteractorStyle
-::startSpin()
+void SVTK_InteractorStyle::startSpin()
{
if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
{
/*!
Starts Fit Area operation (e.g. through menu command)
*/
-void
-SVTK_InteractorStyle
-::startFitArea()
+void SVTK_InteractorStyle::startFitArea()
{
if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
{
/*!
Starts Global Panning operation (e.g. through menu command)
*/
-void
-SVTK_InteractorStyle
-::startGlobalPan()
+void SVTK_InteractorStyle::startGlobalPan()
{
if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
{
/*!
Fits viewer contents to rect
*/
-void
-SVTK_InteractorStyle
-::fitRect(const int left,
- const int top,
- const int right,
- const int bottom)
+void SVTK_InteractorStyle::fitRect(const int left,
+ const int top,
+ const int right,
+ const int bottom)
{
if (GetCurrentRenderer() == NULL)
return;
/*!
Starts viewer operation (!internal usage!)
*/
-void
-SVTK_InteractorStyle
-::startOperation(int operation)
+void SVTK_InteractorStyle::startOperation(int operation)
{
switch(operation)
{
/*!
Sets proper cursor for window when viewer operation is activated
*/
-void
-SVTK_InteractorStyle
-::setCursor(const int operation)
+void SVTK_InteractorStyle::setCursor(const int operation)
{
if (!GetRenderWidget()) return;
switch (operation)
break;
case VTK_INTERACTOR_STYLE_CAMERA_NONE:
default:
- if ( myCurrRotationPointType == SVTK::StartPointSelection )
+ if ( myCurrRotationPointType == SVTK::StartPointSelection ||
+ myCurrFocalPointType == SVTK::StartFocalPointSelection )
GetRenderWidget()->setCursor(myHandCursor);
else
GetRenderWidget()->setCursor(myDefCursor);
/*!
Called when viewer operation started (!put necessary initialization here!)
*/
-void
-SVTK_InteractorStyle
-::onStartOperation()
+void SVTK_InteractorStyle::onStartOperation()
{
if (!GetRenderWidget())
return;
/*!
Called when viewer operation finished (!put necessary post-processing here!)
*/
-void
-SVTK_InteractorStyle
-::onFinishOperation()
+void SVTK_InteractorStyle::onFinishOperation()
{
if (!GetRenderWidget())
return;
{
if(myLastHighlitedActor.GetPointer() && myLastHighlitedActor.GetPointer() != anActor)
myLastHighlitedActor->Highlight( this, aSelectionEvent, false );
- myLastHighlitedActor = anActor;
}
+ myLastHighlitedActor = anActor;
}
else
{
/*!
Called during viewer operation when user moves mouse (!put necessary processing here!)
*/
-void
-SVTK_InteractorStyle
-::onOperation(QPoint mousePos)
+void SVTK_InteractorStyle::onOperation(QPoint mousePos)
{
if (!GetRenderWidget())
return;
Called when user moves mouse inside viewer window and there is no active viewer operation
(!put necessary processing here!)
*/
-void
-SVTK_InteractorStyle
-::onCursorMove(QPoint mousePos)
+void SVTK_InteractorStyle::onCursorMove(QPoint mousePos)
{
// processing highlighting
SVTK_SelectionEvent* aSelectionEvent = GetSelectionEventFlipY();
SALOME_Actor *anActor = GetSelector()->Pick(aSelectionEvent, GetCurrentRenderer());
- if ( myCurrRotationPointType == SVTK::StartPointSelection )
+ if ( myCurrRotationPointType == SVTK::StartPointSelection ||
+ myCurrFocalPointType == SVTK::StartFocalPointSelection )
{
- myHighlightRotationPointActor->SetVisibility( false );
+ myHighlightSelectionPointActor->SetVisibility( false );
if ( anActor )
{
TColStd_IndexedMapOfInteger aMapIndex;
aMapIndex.Add( anObjId );
- myHighlightRotationPointActor->MapPoints( anActor, aMapIndex );
+ myHighlightSelectionPointActor->MapPoints( anActor, aMapIndex );
- myHighlightRotationPointActor->SetVisibility( true );
+ myHighlightSelectionPointActor->SetVisibility( true );
anIsChanged = true;
}
}
/*!
Called on finsh GlobalPan operation
*/
-void
-SVTK_InteractorStyle
-::Place(const int theX, const int theY)
+void SVTK_InteractorStyle::Place(const int theX, const int theY)
{
if (GetCurrentRenderer() == NULL)
return;
/*!
Translates view from Point to Point
*/
-void
-SVTK_InteractorStyle
-::TranslateView(int toX, int toY, int fromX, int fromY)
+void SVTK_InteractorStyle::TranslateView(int toX, int toY, int fromX, int fromY)
{
vtkCamera *cam = GetCurrentRenderer()->GetActiveCamera();
double viewFocus[4], focalDepth, viewPoint[3];
motionVector[2] + viewPoint[2]);
}
-void
-SVTK_InteractorStyle
-::IncrementalPan( const int incrX, const int incrY )
+void SVTK_InteractorStyle::IncrementalPan( const int incrX, const int incrY )
{
this->PanXY( incrX, incrY, 0, 0 );
}
-void
-SVTK_InteractorStyle
-::IncrementalZoom( const int incr )
+void SVTK_InteractorStyle::IncrementalZoom( const int incr )
{
this->DollyXY( incr, incr );
}
-void
-SVTK_InteractorStyle
-::IncrementalRotate( const int incrX, const int incrY )
+void SVTK_InteractorStyle::IncrementalRotate( const int incrX, const int incrY )
{
this->RotateXY( incrX, -incrY );
}
/*!
Redefined in order to add an observer (callback) for custorm event (space mouse event)
*/
-void
-SVTK_InteractorStyle
-::SetInteractor( vtkRenderWindowInteractor* theInteractor )
+void SVTK_InteractorStyle::SetInteractor( vtkRenderWindowInteractor* theInteractor )
{
// register EventCallbackCommand as observer of standard events (keypress, mousemove, etc)
Superclass::SetInteractor( theInteractor );
theInteractor->AddObserver( SVTK::StartPointSelection, EventCallbackCommand, Priority );
theInteractor->AddObserver( SVTK::ChangeRotationPoint, EventCallbackCommand, Priority );
+
+ theInteractor->AddObserver( SVTK::SetFocalPointGravity, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::StartFocalPointSelection, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::SetFocalPointSelected, EventCallbackCommand, Priority );
}
}
/*!
To implement cached rendering
*/
-void
-SVTK_InteractorStyle
-::OnTimer()
+void SVTK_InteractorStyle::OnTimer()
{
//vtkInteractorStyle::OnTimer();
this->Interactor->Render();
/*!
To invoke #vtkRenderWindowInteractor::CreateTimer
*/
-void
-SVTK_InteractorStyle
-::Render()
+void SVTK_InteractorStyle::Render()
{
this->Interactor->CreateTimer(VTKI_TIMER_FIRST);
}
-void
-SVTK_InteractorStyle
-::onSpaceMouseMove( double* data )
+void SVTK_InteractorStyle::onSpaceMouseMove( double* data )
{
// general things, do SetCurrentRenderer() within FindPokedRenderer()
int x, y;
IncrementalRotate( (int)data[3], 0 ); // 5. tilt the control forward/backward = rotate around X axis (Z axis of local coordinate system of space mouse)
}
-void
-SVTK_InteractorStyle
-::onSpaceMouseButton( int button )
+void SVTK_InteractorStyle::onSpaceMouseButton( int button )
{
if( mySMDecreaseSpeedBtn == button ) {
ControllerIncrement()->Decrease();
DominantCombinedSwitch();
}
-void
-SVTK_InteractorStyle
-::DominantCombinedSwitch()
+void SVTK_InteractorStyle::DominantCombinedSwitch()
{
printf( "\n--DominantCombinedSwitch() NOT IMPLEMENTED--\n" );
}
/*!
Draws rectangle by starting and current points
*/
-void
-SVTK_InteractorStyle
-::drawRect()
+void SVTK_InteractorStyle::drawRect()
{
if ( !myRectBand ) {
myRectBand = new QRubberBand( QRubberBand::Rectangle, GetRenderWidget() );
/*!
\brief Delete rubber band on the end on the dragging operation.
*/
-void
-SVTK_InteractorStyle
-::endDrawRect()
+void SVTK_InteractorStyle::endDrawRect()
{
if ( myRectBand ) myRectBand->hide();
/*!
Main process event method (reimplemented from #vtkInteractorStyle)
*/
-void
-SVTK_InteractorStyle
-::ProcessEvents( vtkObject* object,
- unsigned long event,
- void* clientData,
- void* callData )
+void SVTK_InteractorStyle::ProcessEvents( vtkObject* object,
+ unsigned long event,
+ void* clientData,
+ void* callData )
{
if ( clientData ) {
vtkObject* anObject = reinterpret_cast<vtkObject*>( clientData );
case SVTK::SetRotateGravity:
if ( self->myCurrRotationPointType == SVTK::StartPointSelection )
{
- self->myHighlightRotationPointActor->SetVisibility( false );
+ self->myHighlightSelectionPointActor->SetVisibility( false );
if( self->GetCurrentRenderer() != NULL )
- self->GetCurrentRenderer()->RemoveActor( self->myHighlightRotationPointActor.GetPointer() );
+ self->GetCurrentRenderer()->RemoveActor( self->myHighlightSelectionPointActor.GetPointer() );
self->GetRenderWidget()->setCursor(self->myDefCursor);
}
self->myPrevRotationPointType = self->myCurrRotationPointType;
case SVTK::ChangeRotationPoint:
if ( self->myCurrRotationPointType == SVTK::StartPointSelection )
{
- self->myHighlightRotationPointActor->SetVisibility( false );
+ self->myHighlightSelectionPointActor->SetVisibility( false );
if( self->GetCurrentRenderer() != NULL )
- self->GetCurrentRenderer()->RemoveActor( self->myHighlightRotationPointActor.GetPointer() );
+ self->GetCurrentRenderer()->RemoveActor( self->myHighlightSelectionPointActor.GetPointer() );
self->GetRenderWidget()->setCursor(self->myDefCursor);
}
self->myPrevRotationPointType = self->myCurrRotationPointType;
self->myRotationPointY = aSelectedPoint[1];
self->myRotationPointZ = aSelectedPoint[2];
return;
+
+ case SVTK::SetFocalPointGravity:
+ if ( self->myCurrFocalPointType == SVTK::StartPointSelection )
+ {
+ self->myHighlightSelectionPointActor->SetVisibility( false );
+ if( self->GetCurrentRenderer() != NULL )
+ self->GetCurrentRenderer()->RemoveActor( self->myHighlightSelectionPointActor.GetPointer() );
+ self->GetRenderWidget()->setCursor(self->myDefCursor);
+ }
+ self->myCurrFocalPointType = SVTK::SetFocalPointGravity;
+ if ( ComputeBBCenter(self->GetCurrentRenderer(),aCenter) ) {
+ // invoke event for update coordinates in SVTK_ViewParameterDlg
+ self->InvokeEvent(SVTK::FocalPointChanged,(void*)aCenter);
+ }
+ return;
+ case SVTK::StartFocalPointSelection:
+ self->startFocalPointSelection();
+ return;
+
+ case SVTK::SetFocalPointSelected:
+ if ( self->myCurrFocalPointType == SVTK::StartFocalPointSelection )
+ {
+ self->myHighlightSelectionPointActor->SetVisibility( false );
+ if( self->GetCurrentRenderer() != NULL )
+ self->GetCurrentRenderer()->RemoveActor( self->myHighlightSelectionPointActor.GetPointer() );
+ self->GetRenderWidget()->setCursor(self->myDefCursor);
+ }
+ self->myPrevFocalPointType = self->myCurrFocalPointType;
+ self->myCurrFocalPointType = SVTK::SetFocalPointSelected;
+ return;
}
}
}
*/
void SVTK_InteractorStyle::OnChar()
{
+ char key = GetInteractor()->GetKeyCode();
+ switch ( key ) {
+ case '+': ControllerIncrement()->Increase(); break;
+ case '-': ControllerIncrement()->Decrease(); break;
+ }
}
/*!
}
/*!
- To get current increment controller
+ To set current increment controller
*/
void SVTK_InteractorStyle::SetControllerIncrement(SVTK_ControllerIncrement* theController)
{
myControllerIncrement=theController;
}
+/*!
+ To modify current increment controller
+*/
+void SVTK_InteractorStyle::SetIncrementSpeed(const int theValue, const int theMode)
+{
+ SVTK_ControllerIncrement* c = 0;
+ switch (theMode) {
+ case 0: c = SVTK_ControllerIncrement::New(); break;
+ case 1: c = SVTK_GeomControllerIncrement::New(); break;
+ }
+ c->SetStartValue(theValue);
+
+ SetControllerIncrement(c);
+ c->Delete();
+}
+
/*!
To get current increment controller
*/
return myIncrement;
}
+vtkStandardNewMacro(SVTK_GeomControllerIncrement);
+SVTK_GeomControllerIncrement::SVTK_GeomControllerIncrement()
+{
+}
+SVTK_GeomControllerIncrement::~SVTK_GeomControllerIncrement()
+{
+}
+int SVTK_GeomControllerIncrement::Increase()
+{
+ myIncrement*=2;
+ return myIncrement;
+}
+int SVTK_GeomControllerIncrement::Decrease()
+{
+ myIncrement/=2;
+ if (myIncrement<1){
+ myIncrement=1;
+ }
+ return myIncrement;
+}
+
vtkStandardNewMacro(SVTK_ControllerOnKeyDown);
/*!
#endif
//
-//! Control the value of increment in SALOME way.
+//! Control the value of increment in arithmetic progression mode.
/*!
This class controls of value of increment,
- for pan/rotate/zoom operations in SALOME way
+ for pan/rotate/zoom operations in arithmetic progression mode
*/
class SVTK_EXPORT SVTK_ControllerIncrement : public vtkObject{
public:
SVTK_ControllerIncrement(const SVTK_ControllerIncrement&);//Not implemented
void operator=(const SVTK_ControllerIncrement&); //Not implemented
};
+
+//
+//! Control the value of increment in geometric progression mode.
+/*!
+ This class controls of value of increment,
+ for pan/rotate/zoom operations in geometric progression mode.
+*/
+class SVTK_EXPORT SVTK_GeomControllerIncrement : public SVTK_ControllerIncrement{
+ public:
+ vtkTypeMacro(SVTK_GeomControllerIncrement, SVTK_ControllerIncrement);
+ static SVTK_GeomControllerIncrement* New();
+
+ //! Increace the increment value by add 1
+ virtual int Increase();
+
+ //! Decreace the increment value by subtract 1
+ virtual int Decrease();
+ protected:
+ SVTK_GeomControllerIncrement();
+ virtual ~SVTK_GeomControllerIncrement();
+ private:
+ SVTK_GeomControllerIncrement(const SVTK_GeomControllerIncrement&);//Not implemented
+ void operator=(const SVTK_GeomControllerIncrement&); //Not implemented
+};
//
//! Control the behaviour of KeyDown event in SALOME way.
/*!
//! Generate special #SVTK_SelectionEvent
- virtual
- SVTK_SelectionEvent*
- GetSelectionEvent();
+ virtual SVTK_SelectionEvent* GetSelectionEvent();
//! Generate special #SVTK_SelectionEvent with flipped Y coordinate
- virtual
- SVTK_SelectionEvent*
- GetSelectionEventFlipY();
+ virtual SVTK_SelectionEvent* GetSelectionEventFlipY();
//! Redefined in order to add an observer (callback) for custom event (space mouse event)
- virtual
- void
- SetInteractor( vtkRenderWindowInteractor* );
+ virtual void SetInteractor( vtkRenderWindowInteractor* );
//! To invoke #vtkRenderWindowInteractor::CreateTimer
- virtual
- void
- Render();
+ virtual void Render();
//! To implement cached rendering
- virtual
- void
- OnTimer();
+ virtual void OnTimer();
//! To reset reset view
- virtual
- void
- OnConfigure();
+ virtual void OnConfigure();
//! To handle mouse move event
- virtual
- void
- OnMouseMove();
+ virtual void OnMouseMove();
//! To handle left mouse button down event (reimplemented from #vtkInteractorStyle)
- virtual
- void
- OnLeftButtonDown();
+ virtual void OnLeftButtonDown();
//! To handle left mouse button up event (reimplemented from #vtkInteractorStyle)
- virtual
- void
- OnLeftButtonUp();
+ virtual void OnLeftButtonUp();
//! To handle middle mouse button down event (reimplemented from #vtkInteractorStyle)
- virtual
- void
- OnMiddleButtonDown();
+ virtual void OnMiddleButtonDown();
//! To handle middle mouse button up event (reimplemented from #vtkInteractorStyle)
- virtual
- void
- OnMiddleButtonUp();
+ virtual void OnMiddleButtonUp();
//! To handle right mouse button down event (reimplemented from #vtkInteractorStyle)
- virtual
- void
- OnRightButtonDown();
+ virtual void OnRightButtonDown();
//! To handle right mouse button up event (reimplemented from #vtkInteractorStyle)
- virtual
- void
- OnRightButtonUp();
+ virtual void OnRightButtonUp();
//! To handle keyboard event (reimplemented from #vtkInteractorStyle)
- virtual
- void
- OnChar();
+ virtual void OnChar();
//! To set current increment controller
void SetControllerIncrement(SVTK_ControllerIncrement*);
+ //! To modify current increment controller
+ void SetIncrementSpeed(const int, const int = 0);
+
//! To get current increment controller
SVTK_ControllerIncrement* ControllerIncrement();
void startSpin();
void startPointSelection();
+ void startFocalPointSelection();
protected:
void loadCursors();
unsigned long myCurrRotationPointType;
unsigned long myPrevRotationPointType;
+ unsigned long myCurrFocalPointType;
+ unsigned long myPrevFocalPointType;
+
double myRotationPointX;
double myRotationPointY;
double myRotationPointZ;
- vtkSmartPointer<SVTK_Actor> myHighlightRotationPointActor;
+ vtkSmartPointer<SVTK_Actor> myHighlightSelectionPointActor;
vtkSmartPointer<vtkPointPicker> myPointPicker;
vtkFloatingPointType myBBCenter[3];
--- /dev/null
+// SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+// File : SVTK_KeyFreeInteractorStyle.cxx
+// Author : Christophe ATTANASIO
+// Module : SALOME
+// $Header$
+
+
+#include "SVTK_KeyFreeInteractorStyle.h"
+#include "SVTK_Selector.h"
+
+#include <vtkObjectFactory.h>
+#include <vtkRenderWindowInteractor.h>
+#include <vtkCallbackCommand.h>
+#include <vtkCommand.h>
+#include <vtkRenderer.h>
+#include <vtkCamera.h>
+
+
+//----------------------------------------------------------------------------
+vtkStandardNewMacro(SVTK_KeyFreeInteractorStyle);
+//----------------------------------------------------------------------------
+
+SVTK_KeyFreeInteractorStyle::SVTK_KeyFreeInteractorStyle():
+ myIsMidButtonDown( false ),
+ myIsLeftButtonDown( false )
+{
+}
+
+//----------------------------------------------------------------------------
+SVTK_KeyFreeInteractorStyle::~SVTK_KeyFreeInteractorStyle()
+{
+}
+
+//----------------------------------------------------------------------------
+void SVTK_KeyFreeInteractorStyle::OnLeftButtonDown(int ctrl, int shift,
+ int x, int y)
+{
+ myIsLeftButtonDown = true;
+
+ if (this->HasObserver(vtkCommand::LeftButtonPressEvent)) {
+ this->InvokeEvent(vtkCommand::LeftButtonPressEvent,NULL);
+ return;
+ }
+ this->FindPokedRenderer(x, y);
+ if (this->CurrentRenderer == NULL) {
+ return;
+ }
+ myShiftState = shift;
+ // finishing current viewer operation
+ if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
+ onFinishOperation();
+ startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
+ }
+ myOtherPoint = myPoint = QPoint(x, y);
+ if (ForcedState != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
+ startOperation(ForcedState);
+ }
+ else {
+ if (!(ctrl||shift)){
+ if (myIsMidButtonDown){
+ startOperation(VTK_INTERACTOR_STYLE_CAMERA_ZOOM);
+ }
+ else{
+ startOperation(VTK_INTERACTOR_STYLE_CAMERA_ROTATE);
+ }
+ }
+ }
+ return;
+}
+
+//----------------------------------------------------------------------------
+void SVTK_KeyFreeInteractorStyle::OnMiddleButtonDown(int ctrl,
+ int shift,
+ int x, int y)
+{
+ myIsMidButtonDown = true;
+
+ if (this->HasObserver(vtkCommand::MiddleButtonPressEvent)) {
+ this->InvokeEvent(vtkCommand::MiddleButtonPressEvent,NULL);
+ return;
+ }
+ this->FindPokedRenderer(x, y);
+ if (this->CurrentRenderer == NULL) {
+ return;
+ }
+ myShiftState = shift;
+ // finishing current viewer operation
+ if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
+ onFinishOperation();
+ startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
+ }
+ myOtherPoint = myPoint = QPoint(x, y);
+ if (ForcedState != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
+ startOperation(ForcedState);
+ }
+ else {
+ if (!(ctrl||shift)){
+ if ( myIsLeftButtonDown ){
+ startOperation(VTK_INTERACTOR_STYLE_CAMERA_ZOOM);
+ }
+ else{
+ startOperation(VTK_INTERACTOR_STYLE_CAMERA_PAN);
+ }
+ }
+ }
+}
+
+//----------------------------------------------------------------------------
+void SVTK_KeyFreeInteractorStyle::OnLeftButtonUp(int ctrl, int shift, int x, int y)
+{
+ myIsLeftButtonDown = false;
+ SVTK_InteractorStyle::OnLeftButtonUp( ctrl, shift, x, y );
+
+ if ( myIsMidButtonDown )
+ OnMiddleButtonDown( ctrl, shift, x, y );
+}
+
+//----------------------------------------------------------------------------
+void SVTK_KeyFreeInteractorStyle::OnMiddleButtonUp(int ctrl, int shift, int x, int y)
+{
+ myIsMidButtonDown = false;
+ SVTK_InteractorStyle::OnMiddleButtonUp( ctrl, shift, x, y );
+
+ if ( myIsLeftButtonDown )
+ OnLeftButtonDown( ctrl, shift, x, y );
+}
+
+//----------------------------------------------------------------------------
+void SVTK_KeyFreeInteractorStyle::OnChar()
+{
+ char key = GetInteractor()->GetKeyCode();
+ switch (key) {
+ case 's':
+ case 'S':
+ ActionPicking();
+ EventCallbackCommand->AbortFlagOn();
+ return;
+ }
+ SVTK_InteractorStyle::OnChar();
+}
--- /dev/null
+// SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+// File : SVTK_KeyFreeInteractorStyle.h
+// Author : Christophe ATTANASIO
+// Module : SALOME
+// $Header$
+
+#ifndef __SVTK_KeyFreeInteractorStyle_h
+#define __SVTK_KeyFreeInteractorStyle_h
+
+
+#include "SVTK.h"
+
+#include "SVTK_InteractorStyle.h"
+
+//! Introduce new style of interaction (keyboard free)
+class SVTK_EXPORT SVTK_KeyFreeInteractorStyle : public SVTK_InteractorStyle
+{
+ public:
+ static SVTK_KeyFreeInteractorStyle *New();
+ vtkTypeMacro(SVTK_KeyFreeInteractorStyle,SVTK_InteractorStyle);
+
+ protected:
+ SVTK_KeyFreeInteractorStyle();
+ ~SVTK_KeyFreeInteractorStyle();
+
+ SVTK_KeyFreeInteractorStyle(const SVTK_KeyFreeInteractorStyle&); // Not implemented
+ void operator=(const SVTK_KeyFreeInteractorStyle&); // Not implemented
+
+ // Generic event bindings must be overridden in subclasses
+
+ //! Redefine SVTK_InteractorStyle::OnLeftButtonDown
+ virtual void OnLeftButtonDown(int ctrl, int shift, int x, int y);
+
+ //! Redefine SVTK_InteractorStyle::OnMiddleButtonDown
+ virtual void OnMiddleButtonDown(int ctrl, int shift, int x, int y);
+
+ //! Redefine SVTK_InteractorStyle::OnLeftButtonUp
+ virtual void OnLeftButtonUp(int ctrl, int shift, int x, int y);
+
+ //! Redefine SVTK_InteractorStyle::OnMiddleButtonUp
+ virtual void OnMiddleButtonUp(int ctrl, int shift, int x, int y);
+
+ //! Redefine SVTK_InteractorStyle::OnChar
+ virtual void OnChar();
+
+ bool myIsMidButtonDown;
+ bool myIsLeftButtonDown;
+};
+
+#endif
#include <vtkGenericRenderWindowInteractor.h>
#include <vtkRenderer.h>
-#include <vtkRenderWindow.h>
+#include <vtkCamera.h>
#include <QtxAction.h>
#include <QtxMultiAction.h>
#include "SVTK_UpdateRateDlg.h"
#include "SVTK_CubeAxesDlg.h"
#include "SVTK_SetRotationPointDlg.h"
+#include "SVTK_ViewParameterDlg.h"
#include "SVTK_MainWindow.h"
#include "SVTK_Event.h"
#include "SVTK_Renderer.h"
#include "SVTK_RenderWindowInteractor.h"
#include "SVTK_InteractorStyle.h"
+#include "SVTK_KeyFreeInteractorStyle.h"
#include "SVTK_Selector.h"
+#include "SVTK_ComboAction.h"
+#include "SVTK_Recorder.h"
+#include "SVTK_RecorderDlg.h"
/*!
Constructor
*/
-SVTK_MainWindow
-::SVTK_MainWindow(QWidget* theParent,
- const char* theName,
- SUIT_ResourceMgr* theResourceMgr,
- SUIT_ViewWindow* theViewWindow) :
+SVTK_MainWindow::SVTK_MainWindow(QWidget* theParent,
+ const char* theName,
+ SUIT_ResourceMgr* theResourceMgr,
+ SUIT_ViewWindow* theViewWindow) :
QMainWindow(theParent),
- myViewWindow(theViewWindow)
+ myViewWindow(theViewWindow),
+ myKeyFreeInteractorStyle(SVTK_KeyFreeInteractorStyle::New())
{
setObjectName(theName);
setWindowFlags( windowFlags() & ~Qt::Window );
+ // specific of vtkSmartPointer
+ myKeyFreeInteractorStyle->Delete();
}
/*!
To initialize the class
*/
-void
-SVTK_MainWindow
-::Initialize(SVTK_RenderWindowInteractor* theInteractor)
+void SVTK_MainWindow::Initialize(SVTK_RenderWindowInteractor* theInteractor)
{
myToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_LABEL"), -1, this );
+ myRecordingToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_RECORD_LABEL"), -1, this );
createActions( SUIT_Session::session()->activeApplication()->resourceMgr() );
createToolBar();
myCubeAxesDlg = new SVTK_CubeAxesDlg( action( GraduatedAxes ), this, "SVTK_CubeAxesDlg" );
mySetRotationPointDlg = new SVTK_SetRotationPointDlg
( action( ChangeRotationPointId ), this, "SVTK_SetRotationPointDlg" );
+ myViewParameterDlg = new SVTK_ViewParameterDlg
+ ( action( ViewParametersId ), this, "SVTK_ViewParameterDlg" );
+
+ myRecorder = SVTK_Recorder::New();
+ //myRecorder->CheckExistAVIMaker();
+ //if(myRecorder->ErrorStatus())
+ // myRecordingToolBar->setEnabled(false);
+
+ myRecorder->SetNbFPS( 17.3 );
+ myRecorder->SetQuality( 100 );
+ myRecorder->SetProgressiveMode( true );
+ myRecorder->SetUseSkippedFrames( true );
+ myRecorder->SetRenderWindow( theInteractor->getRenderWindow() );
}
/*!
Destructor
*/
-SVTK_MainWindow
-::~SVTK_MainWindow()
+SVTK_MainWindow::~SVTK_MainWindow()
{
+ if(myRecorder)
+ myRecorder->Delete();
}
/*!
/*!
\return used SVTK_RenderWindowInteractor
*/
-SVTK_RenderWindowInteractor*
-SVTK_MainWindow
-::GetInteractor()
+SVTK_RenderWindowInteractor* SVTK_MainWindow::GetInteractor()
{
return myInteractor;
}
/*!
\return used #vtkRenderWindowInteractor (obsolete)
*/
-vtkRenderWindowInteractor*
-SVTK_MainWindow
-::getInteractor()
+vtkRenderWindowInteractor* SVTK_MainWindow::getInteractor()
{
return GetInteractor()->GetDevice();
}
/*!
\return used vtkRenderWindow (obsolete)
*/
-vtkRenderWindow*
-SVTK_MainWindow
-::getRenderWindow()
+vtkRenderWindow* SVTK_MainWindow::getRenderWindow()
{
return GetInteractor()->getRenderWindow();
}
To repaint the view
\param theUpdateTrihedron - adjust trihedron
*/
-void
-SVTK_MainWindow
-::Repaint(bool theUpdateTrihedron)
+void SVTK_MainWindow::Repaint(bool theUpdateTrihedron)
{
if(theUpdateTrihedron)
GetRenderer()->OnAdjustTrihedron();
/*!
To invoke a VTK event on SVTK_RenderWindowInteractor instance
*/
-void
-SVTK_MainWindow
-::InvokeEvent(unsigned long theEvent, void* theCallData)
+void SVTK_MainWindow::InvokeEvent(unsigned long theEvent, void* theCallData)
{
GetInteractor()->InvokeEvent(theEvent,theCallData);
}
/*!
Redirect the request to SVTK_RenderWindowInteractor::GetInteractorStyle
*/
-vtkInteractorStyle*
-SVTK_MainWindow
-::GetInteractorStyle()
+vtkInteractorStyle* SVTK_MainWindow::GetInteractorStyle()
{
return GetInteractor()->GetInteractorStyle();
}
/*!
Redirect the request to SVTK_RenderWindowInteractor::PushInteractorStyle
*/
-void
-SVTK_MainWindow
-::PushInteractorStyle(vtkInteractorStyle* theStyle)
+void SVTK_MainWindow::PushInteractorStyle(vtkInteractorStyle* theStyle)
{
GetInteractor()->PushInteractorStyle(theStyle);
}
/*!
Redirect the request to SVTK_RenderWindowInteractor::PopInteractorStyle
*/
-void
-SVTK_MainWindow
-::PopInteractorStyle()
+void SVTK_MainWindow::PopInteractorStyle()
{
GetInteractor()->PopInteractorStyle();
}
/*!
Redirect the request to SVTK_RenderWindowInteractor::GetSelector
*/
-SVTK_Selector*
-SVTK_MainWindow
-::GetSelector()
+SVTK_Selector* SVTK_MainWindow::GetSelector()
{
return GetInteractor()->GetSelector();
}
/*!
Redirect the request to SVTK_RenderWindowInteractor::SelectionMode
*/
-Selection_Mode
-SVTK_MainWindow
-::SelectionMode()
+Selection_Mode SVTK_MainWindow::SelectionMode()
{
return GetSelector()->SelectionMode();
}
/*!
Redirect the request to SVTK_RenderWindowInteractor::SetSelectionMode
*/
-void
-SVTK_MainWindow
-::SetSelectionMode(Selection_Mode theMode)
+void SVTK_MainWindow::SetSelectionMode(Selection_Mode theMode)
{
GetSelector()->SetSelectionMode(theMode);
}
/*!
Redirect the request to SVTK_RenderWindowInteractor::GetRenderer
*/
-SVTK_Renderer*
-SVTK_MainWindow
-::GetRenderer()
+SVTK_Renderer* SVTK_MainWindow::GetRenderer()
{
return GetInteractor()->GetRenderer();
}
/*!
Redirect the request to SVTK_RenderWindowInteractor::getRenderer
*/
-vtkRenderer*
-SVTK_MainWindow
-::getRenderer()
+vtkRenderer* SVTK_MainWindow::getRenderer()
{
return GetInteractor()->getRenderer();
}
Sets background color of the view
\param theColor - new background color
*/
-void
-SVTK_MainWindow
-::SetBackgroundColor(const QColor& theColor)
+void SVTK_MainWindow::SetBackgroundColor(const QColor& theColor)
{
getRenderer()->SetBackground(theColor.red()/255.0,
theColor.green()/255.0,
/*!
\return background color of the view
*/
-QColor
-SVTK_MainWindow
-::BackgroundColor()
+QColor SVTK_MainWindow::BackgroundColor()
{
vtkFloatingPointType aBackgroundColor[3];
getRenderer()->GetBackground(aBackgroundColor);
/*!
Redirect the request to SVTK_Renderer::GetScale
*/
-void
-SVTK_MainWindow
-::GetScale( double theScale[3] )
+void SVTK_MainWindow::GetScale( double theScale[3] )
{
GetRenderer()->GetScale( theScale );
}
/*!
Redirect the request to SVTK_Renderer::SetScale
*/
-void
-SVTK_MainWindow
-::SetScale( double theScale[3] )
+void SVTK_MainWindow::SetScale( double theScale[3] )
{
GetRenderer()->SetScale( theScale );
Repaint();
/*!
Redirect the request to SVTK_Renderer::AddActor
*/
-void
-SVTK_MainWindow
-::AddActor(VTKViewer_Actor* theActor,
- bool theIsUpdate)
+void SVTK_MainWindow::AddActor(VTKViewer_Actor* theActor,
+ bool theIsUpdate)
{
GetRenderer()->AddActor(theActor);
if(theIsUpdate)
/*!
Redirect the request to SVTK_Renderer::RemoveActor
*/
-void
-SVTK_MainWindow
-::RemoveActor(VTKViewer_Actor* theActor,
- bool theIsUpdate)
+void SVTK_MainWindow::RemoveActor(VTKViewer_Actor* theActor,
+ bool theIsUpdate)
{
GetRenderer()->RemoveActor(theActor);
if(theIsUpdate)
Repaint();
}
+/*!
+ Redirect the request to SVTK_InteractorStyle::SetTrihedronSize
+*/
+void SVTK_MainWindow::SetIncrementalSpeed( const int theValue, const int theMode )
+{
+ if ( (SVTK_InteractorStyle*)GetInteractorStyle() )
+ ((SVTK_InteractorStyle*)GetInteractorStyle())->SetIncrementSpeed(theValue, theMode);
+}
+
+/*!
+ Redirect the request to SVTK_InteractorStyle
+*/
+void SVTK_MainWindow::SetSMButtons( const int theBtn1, const int theBtn2, const int theBtn3 )
+{
+ int val = theBtn1;
+ myEventDispatcher->InvokeEvent(SVTK::SetSMDecreaseSpeedEvent, &val);
+ val = theBtn2;
+ myEventDispatcher->InvokeEvent(SVTK::SetSMIncreaseSpeedEvent, &val);
+ val = theBtn3;
+ myEventDispatcher->InvokeEvent(SVTK::SetSMDominantCombinedSwitchEvent, &val);
+}
+
+
/*!
Redirect the request to SVTK_Renderer::GetTrihedronSize
*/
-vtkFloatingPointType
-SVTK_MainWindow
-::GetTrihedronSize()
+vtkFloatingPointType SVTK_MainWindow::GetTrihedronSize()
{
return GetRenderer()->GetTrihedronSize();
}
/*!
Redirect the request to SVTK_Renderer::SetTrihedronSize
*/
-void
-SVTK_MainWindow
-::SetTrihedronSize( const vtkFloatingPointType theSize, const bool theRelative )
+void SVTK_MainWindow::SetTrihedronSize( const vtkFloatingPointType theSize, const bool theRelative )
{
GetRenderer()->SetTrihedronSize(theSize, theRelative);
Repaint();
/*! If parameter theIsForcedUpdate is true, recalculate parameters for
* trihedron and cube axes, even if trihedron and cube axes is invisible.
*/
-void
-SVTK_MainWindow
-::AdjustActors()
+void SVTK_MainWindow::AdjustActors()
{
GetRenderer()->AdjustActors();
Repaint();
/*!
Redirect the request to SVTK_Renderer::IsTrihedronDisplayed
*/
-bool
-SVTK_MainWindow
-::IsTrihedronDisplayed()
+bool SVTK_MainWindow::IsTrihedronDisplayed()
{
return GetRenderer()->IsTrihedronDisplayed();
}
/*!
Redirect the request to SVTK_Renderer::IsCubeAxesDisplayed
*/
-bool
-SVTK_MainWindow
-::IsCubeAxesDisplayed()
+bool SVTK_MainWindow::IsCubeAxesDisplayed()
{
return GetRenderer()->IsCubeAxesDisplayed();
}
/*!
Redirect the request to SVTK_Renderer::GetTrihedron
*/
-VTKViewer_Trihedron*
-SVTK_MainWindow
-::GetTrihedron()
+VTKViewer_Trihedron* SVTK_MainWindow::GetTrihedron()
{
return GetRenderer()->GetTrihedron();
}
/*!
Redirect the request to SVTK_Renderer::GetCubeAxes
*/
-SVTK_CubeAxesActor2D*
-SVTK_MainWindow
-::GetCubeAxes()
+SVTK_CubeAxesActor2D* SVTK_MainWindow::GetCubeAxes()
{
return GetRenderer()->GetCubeAxes();
}
/*!
\return toolbar of svtk main window
*/
-QToolBar*
-SVTK_MainWindow
-::getToolBar()
+QToolBar* SVTK_MainWindow::getToolBar()
{
return toolMgr()->toolBar( myToolBar );
}
-void
-SVTK_MainWindow
-::SetEventDispatcher(vtkObject* theDispatcher)
+void SVTK_MainWindow::SetEventDispatcher(vtkObject* theDispatcher)
{
myEventDispatcher = theDispatcher;
}
/*!
Creates all actions of svtk main window
*/
-void
-SVTK_MainWindow
-::createActions(SUIT_ResourceMgr* theResourceMgr)
+void SVTK_MainWindow::createActions(SUIT_ResourceMgr* theResourceMgr)
{
QtxAction* anAction;
QtxActionToolMgr* mgr = toolMgr();
anAction->setCheckable(true);
connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onUpdateRate(bool)));
mgr->registerAction( anAction, UpdateRate );
+
+ // Set projection mode
+ SVTK_ComboAction* aModeAction = new SVTK_ComboAction(tr("MNU_SVTK_PROJECTION_MODE"), this);
+ aModeAction->setStatusTip(tr("DSC_SVTK_PROJECTION_MODE"));
+ aModeAction->insertItem(theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_PARALLEL" ) ) );
+ aModeAction->insertItem(theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_PERSPECTIVE" ) ) );
+ connect(aModeAction, SIGNAL(triggered(int)), this, SLOT(onProjectionMode(int)));
+ mgr->registerAction( aModeAction, ProjectionModeId );
+
+ // View Parameters
+ anAction = new QtxAction(tr("MNU_VIEWPARAMETERS_VIEW"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_PARAMETERS" ) ),
+ tr( "MNU_VIEWPARAMETERS_VIEW" ), 0, this);
+ anAction->setStatusTip(tr("DSC_VIEWPARAMETERS_VIEW"));
+ anAction->setCheckable(true);
+ connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onViewParameters(bool)));
+ mgr->registerAction( anAction, ViewParametersId );
+
+ // Switch between interaction styles
+ anAction = new QtxAction(tr("MNU_SVTK_STYLE_SWITCH"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_STYLE_SWITCH" ) ),
+ tr( "MNU_SVTK_STYLE_SWITCH" ), 0, this);
+ anAction->setStatusTip(tr("DSC_SVTK_STYLE_SWITCH"));
+ anAction->setCheckable(true);
+ connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchInteractionStyle(bool)));
+ mgr->registerAction( anAction, SwitchInteractionStyleId );
+
+ // Start recording
+ myStartAction = new QtxAction(tr("MNU_SVTK_RECORDING_START"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_START" ) ),
+ tr( "MNU_SVTK_RECORDING_START" ), 0, this);
+ myStartAction->setStatusTip(tr("DSC_SVTK_RECORDING_START"));
+ connect( myStartAction, SIGNAL( triggered ( bool ) ), this, SLOT( onStartRecording() ) );
+ mgr->registerAction( myStartAction, StartRecordingId );
+
+ // Play recording
+ myPlayAction = new QtxAction(tr("MNU_SVTK_RECORDING_PLAY"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_PLAY" ) ),
+ tr( "MNU_SVTK_RECORDING_PLAY" ), 0, this);
+ myPlayAction->setStatusTip(tr("DSC_SVTK_RECORDING_PLAY"));
+ myPlayAction->setEnabled( false );
+ connect( myPlayAction, SIGNAL( triggered ( bool ) ), this, SLOT( onPlayRecording() ) );
+ mgr->registerAction( myPlayAction, PlayRecordingId );
+
+ // Pause recording
+ myPauseAction = new QtxAction(tr("MNU_SVTK_RECORDING_PAUSE"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_PAUSE" ) ),
+ tr( "MNU_SVTK_RECORDING_PAUSE" ), 0, this);
+ myPauseAction->setStatusTip(tr("DSC_SVTK_RECORDING_PAUSE"));
+ myPauseAction->setEnabled( false );
+ connect( myPauseAction, SIGNAL( triggered ( bool ) ), this, SLOT( onPauseRecording() ) );
+ mgr->registerAction( myPauseAction, PauseRecordingId );
+
+ // Stop recording
+ myStopAction = new QtxAction(tr("MNU_SVTK_RECORDING_STOP"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_STOP" ) ),
+ tr( "MNU_SVTK_RECORDING_STOP" ), 0, this);
+ myStopAction->setStatusTip(tr("DSC_SVTK_RECORDING_STOP"));
+ myStopAction->setEnabled( false );
+ connect( myStopAction, SIGNAL( triggered ( bool ) ), this, SLOT( onStopRecording() ) );
+ mgr->registerAction( myStopAction, StopRecordingId );
}
#if defined(WIN32) && !defined(_DEBUG)
/*!
Creates toolbar of svtk main window
*/
-void
-SVTK_MainWindow
-::createToolBar()
+void SVTK_MainWindow::createToolBar()
{
QtxActionToolMgr* mgr = toolMgr();
mgr->append( DumpId, myToolBar );
+ mgr->append( SwitchInteractionStyleId, myToolBar );
mgr->append( ViewTrihedronId, myToolBar );
QtxMultiAction* aScaleAction = new QtxMultiAction( this );
mgr->append( UpdateRate, myToolBar );
mgr->append( NonIsometric, myToolBar );
mgr->append( GraduatedAxes, myToolBar );
+
+ mgr->append( ViewParametersId, myToolBar );
+ mgr->append( ProjectionModeId, myToolBar );
+
+ mgr->append( StartRecordingId, myRecordingToolBar );
+ mgr->append( PlayRecordingId, myRecordingToolBar );
+ mgr->append( PauseRecordingId, myRecordingToolBar );
+ mgr->append( StopRecordingId, myRecordingToolBar );
}
/*!
Custom show event handler
*/
-void
-SVTK_MainWindow
-::showEvent( QShowEvent * theEvent )
+void SVTK_MainWindow::showEvent( QShowEvent * theEvent )
{
emit Show( theEvent );
}
/*!
Custom hide event handler
*/
-void
-SVTK_MainWindow
-::hideEvent( QHideEvent * theEvent )
+void SVTK_MainWindow::hideEvent( QHideEvent * theEvent )
{
emit Hide( theEvent );
}
/*!
Starts zoom transformation
*/
-void
-SVTK_MainWindow
-::activateZoom()
+void SVTK_MainWindow::activateZoom()
{
myEventDispatcher->InvokeEvent(SVTK::StartZoom,0);
}
/*!
Starts panning transformation
*/
-void
-SVTK_MainWindow
-::activatePanning()
+void SVTK_MainWindow::activatePanning()
{
myEventDispatcher->InvokeEvent(SVTK::StartPan,0);
}
/*!
Starts rotation transformation
*/
-void
-SVTK_MainWindow
-::activateRotation()
+void SVTK_MainWindow::activateRotation()
{
myEventDispatcher->InvokeEvent(SVTK::StartRotate,0);
}
/*!
Change rotation point
*/
-void
-SVTK_MainWindow
-::onChangeRotationPoint(bool theIsActivate)
+void SVTK_MainWindow::onChangeRotationPoint(bool theIsActivate)
{
if(theIsActivate){
mySetRotationPointDlg->addObserver();
/*!
Set the gravity center as a rotation point
*/
-void
-SVTK_MainWindow
-::activateSetRotationGravity()
+void SVTK_MainWindow::activateSetRotationGravity()
{
myEventDispatcher->InvokeEvent(SVTK::SetRotateGravity,0);
}
/*!
Set the selected point as a rotation point
*/
-void
-SVTK_MainWindow
-::activateSetRotationSelected(void* theData)
+void SVTK_MainWindow::activateSetRotationSelected(void* theData)
{
myEventDispatcher->InvokeEvent(SVTK::ChangeRotationPoint,theData);
}
/*!
Set the point selected by user as a rotation point
*/
-void
-SVTK_MainWindow
-::activateStartPointSelection()
+void SVTK_MainWindow::activateStartPointSelection()
{
myEventDispatcher->InvokeEvent(SVTK::StartPointSelection,0);
}
/*!
- Starts global panning transformation
+ Set the view projection mode: orthogonal or perspective
+*/
+void SVTK_MainWindow::onProjectionMode(int mode)
+{
+ vtkCamera* aCamera = getRenderer()->GetActiveCamera();
+ aCamera->SetParallelProjection(mode==0);
+ GetInteractor()->GetDevice()->CreateTimer(VTKI_TIMER_FIRST);
+}
+
+/*!
+ Modify view parameters
+*/
+void SVTK_MainWindow::onViewParameters(bool theIsActivate)
+{
+ if(theIsActivate){
+ myViewParameterDlg->addObserver();
+ myViewParameterDlg->show();
+ }else
+ myViewParameterDlg->hide();
+}
+
+/*!
+ Set the gravity center as a focal point
+*/
+void SVTK_MainWindow::activateSetFocalPointGravity()
+{
+ myEventDispatcher->InvokeEvent(SVTK::SetFocalPointGravity, 0);
+}
+
+/*!
+ Set the selected point as a focal point
+*/
+void SVTK_MainWindow::activateSetFocalPointSelected()
+{
+ myEventDispatcher->InvokeEvent(SVTK::SetFocalPointSelected, 0);
+}
+
+/*!
+ Set the point selected by user as a focal point
*/
void
SVTK_MainWindow
-::activateGlobalPanning()
+::activateStartFocalPointSelection()
+{
+ myEventDispatcher->InvokeEvent(SVTK::StartFocalPointSelection,0);
+}
+
+void SVTK_MainWindow::activateProjectionMode(int mode)
+{
+ SVTK_ComboAction* a = ::qobject_cast<SVTK_ComboAction*>( toolMgr()->action( ProjectionModeId ) );
+ if ( a ) a->setCurrentIndex(mode);
+}
+
+/*!
+ Starts global panning transformation
+*/
+void SVTK_MainWindow::activateGlobalPanning()
{
myEventDispatcher->InvokeEvent(SVTK::StartGlobalPan,0);
}
/*!
Starts window fit transformation
*/
-void
-SVTK_MainWindow
-::activateWindowFit()
+void SVTK_MainWindow::activateWindowFit()
{
myEventDispatcher->InvokeEvent(SVTK::StartFitArea,0);
}
+/*!
+ Switches "keyboard free" interaction style on/off
+*/
+void SVTK_MainWindow::onSwitchInteractionStyle(bool theOn)
+{
+ if (theOn) {
+ // check if style is already set
+ if ( GetInteractorStyle() != myKeyFreeInteractorStyle.GetPointer() )
+ {
+ // keep the same style extensions
+ SVTK_InteractorStyle* aStyle = (SVTK_InteractorStyle*)GetInteractorStyle();
+ if ( aStyle ) {
+ myKeyFreeInteractorStyle->SetControllerIncrement(aStyle->ControllerIncrement());
+ myKeyFreeInteractorStyle->SetControllerOnKeyDown(aStyle->ControllerOnKeyDown());
+ }
+
+ PushInteractorStyle(myKeyFreeInteractorStyle.GetPointer());
+ }
+ }
+ else {
+ // pop only key free style
+ if ( GetInteractorStyle() == myKeyFreeInteractorStyle.GetPointer() )
+ PopInteractorStyle();
+ }
+
+ // update action state if method is called outside
+ QtxAction* a = action( SwitchInteractionStyleId );
+ if ( a->isChecked() != theOn ) a->setChecked( theOn );
+}
+
/*!
Processes transformation "front view"
*/
-void
-SVTK_MainWindow
-::onFrontView()
+void SVTK_MainWindow::onFrontView()
{
GetRenderer()->OnFrontView();
Repaint();
/*!
Processes transformation "back view"
*/
-void
-SVTK_MainWindow
-::onBackView()
+void SVTK_MainWindow::onBackView()
{
GetRenderer()->OnBackView();
Repaint();
/*!
Processes transformation "top view"
*/
-void
-SVTK_MainWindow
-::onTopView()
+void SVTK_MainWindow::onTopView()
{
GetRenderer()->OnTopView();
Repaint();
/*!
Processes transformation "bottom view"
*/
-void
-SVTK_MainWindow
-::onBottomView()
+void SVTK_MainWindow::onBottomView()
{
GetRenderer()->OnBottomView();
Repaint();
/*!
Processes transformation "left view"
*/
-void
-SVTK_MainWindow
-::onLeftView()
+void SVTK_MainWindow::onLeftView()
{
GetRenderer()->OnLeftView();
Repaint();
/*!
Processes transformation "right view"
*/
-void
-SVTK_MainWindow
-::onRightView()
+void SVTK_MainWindow::onRightView()
{
GetRenderer()->OnRightView();
Repaint();
/*!
Processes transformation "reset view": sets default orientation of viewport camera
*/
-void
-SVTK_MainWindow
-::onResetView()
+void SVTK_MainWindow::onResetView()
{
GetRenderer()->OnResetView();
Repaint();
/*!
Processes transformation "fit all"
*/
-void
-SVTK_MainWindow
-::onFitAll()
+void SVTK_MainWindow::onFitAll()
{
GetRenderer()->OnFitAll();
Repaint();
/*!
Shows trihedron
*/
-void
-SVTK_MainWindow
-::onViewTrihedron()
+void SVTK_MainWindow::onViewTrihedron()
{
GetRenderer()->OnViewTrihedron();
Repaint();
/*!
Shows cube axes
*/
-void
-SVTK_MainWindow
-::onViewCubeAxes()
+void SVTK_MainWindow::onViewCubeAxes()
{
GetRenderer()->OnViewCubeAxes();
Repaint();
}
-void
-SVTK_MainWindow
-::onUpdateRate(bool theIsActivate)
+void SVTK_MainWindow::onUpdateRate(bool theIsActivate)
{
if(theIsActivate){
myUpdateRateDlg->Update();
myUpdateRateDlg->hide();
}
-void
-SVTK_MainWindow
-::onNonIsometric(bool theIsActivate)
+void SVTK_MainWindow::onNonIsometric(bool theIsActivate)
{
if(theIsActivate){
myNonIsometricDlg->Update();
myNonIsometricDlg->hide();
}
-void
-SVTK_MainWindow
-::onGraduatedAxes(bool theIsActivate)
+void SVTK_MainWindow::onGraduatedAxes(bool theIsActivate)
{
if(theIsActivate){
myCubeAxesDlg->Update();
myCubeAxesDlg->hide();
}
-void
-SVTK_MainWindow
-::onAdjustTrihedron()
+void SVTK_MainWindow::onAdjustTrihedron()
{
GetRenderer()->OnAdjustTrihedron();
}
-void
-SVTK_MainWindow
-::onAdjustCubeAxes()
+void SVTK_MainWindow::onAdjustCubeAxes()
{
GetRenderer()->OnAdjustCubeAxes();
}
/*!
\return QImage, containing all scene rendering in window
*/
-QImage
-SVTK_MainWindow
-::dumpView()
+QImage SVTK_MainWindow::dumpView()
{
vtkRenderWindow* aWindow = GetInteractor()->getRenderWindow();
int* aSize = aWindow->GetSize();
{
return dynamic_cast<QtxAction*>( toolMgr()->action( id ) );
}
+
+void SVTK_MainWindow::onStartRecording()
+{
+ myRecorder->CheckExistAVIMaker();
+ if (myRecorder->ErrorStatus()) {
+ SUIT_MessageBox::warning(this, tr("ERROR"), tr("MSG_NO_AVI_MAKER") );
+ }
+ else {
+ SVTK_RecorderDlg* aRecorderDlg = new SVTK_RecorderDlg( this, myRecorder );
+
+ if( !aRecorderDlg->exec() )
+ return;
+
+ myStartAction->setEnabled( false );
+ myPlayAction->setEnabled( false );
+ myPauseAction->setEnabled( true );
+ myStopAction->setEnabled( true );
+
+ // to prevent resizing the window while recording
+ myPreRecordingMinSize = minimumSize();
+ myPreRecordingMaxSize = maximumSize();
+ setFixedSize( size() );
+
+ myRecorder->Record();
+ }
+}
+
+void SVTK_MainWindow::onPlayRecording()
+{
+ myStartAction->setEnabled( false );
+ myPlayAction->setEnabled( false );
+ myPauseAction->setEnabled( true );
+ myStopAction->setEnabled( true );
+
+ myRecorder->Pause();
+}
+
+void SVTK_MainWindow::onPauseRecording()
+{
+ myStartAction->setEnabled( false );
+ myPlayAction->setEnabled( true );
+ myPauseAction->setEnabled( false );
+ myStopAction->setEnabled( true );
+
+ myRecorder->Pause();
+}
+
+void SVTK_MainWindow::onStopRecording()
+{
+ myStartAction->setEnabled( true );
+ myPlayAction->setEnabled( false );
+ myPauseAction->setEnabled( false );
+ myStopAction->setEnabled( false );
+
+ myRecorder->Stop();
+
+ setMinimumSize( myPreRecordingMinSize );
+ setMaximumSize( myPreRecordingMaxSize );
+}
class SVTK_CubeAxesActor2D;
class SVTK_CubeAxesDlg;
class SVTK_SetRotationPointDlg;
+class SVTK_ViewParameterDlg;
class SVTK_Renderer;
class SVTK_Selector;
+class SVTK_KeyFreeInteractorStyle;
+class SVTK_Recorder;
class VTKViewer_Trihedron;
class VTKViewer_Actor;
SUIT_ViewWindow* theViewWindow);
//! To initialize the class
- virtual
- void
- Initialize(SVTK_RenderWindowInteractor* theInteractor);
+ virtual void Initialize(SVTK_RenderWindowInteractor* theInteractor);
- virtual
- ~SVTK_MainWindow();
+ virtual ~SVTK_MainWindow();
//----------------------------------------------------------------------------
//! Get used #SVTK_RenderWindowInteractor
- SVTK_RenderWindowInteractor*
- GetInteractor();
+ SVTK_RenderWindowInteractor* GetInteractor();
//! Get used #vtkRenderWindowInteractor (obsolete)
- vtkRenderWindowInteractor*
- getInteractor();
+ vtkRenderWindowInteractor* getInteractor();
//! Get used #vtkRenderWindow (obsolete)
- vtkRenderWindow*
- getRenderWindow();
+ vtkRenderWindow* getRenderWindow();
//! To repaint the view
- void
- Repaint(bool theUpdateTrihedron = true);
+ void Repaint(bool theUpdateTrihedron = true);
//! To invoke a VTK event on #SVTK_RenderWindowInteractor instance
- void
- InvokeEvent(unsigned long theEvent, void* theCallData);
+ void InvokeEvent(unsigned long theEvent, void* theCallData);
//----------------------------------------------------------------------------
//! Redirect the request to #SVTK_RenderWindowInteractor::GetInteractorStyle
- vtkInteractorStyle*
- GetInteractorStyle();
+ vtkInteractorStyle* GetInteractorStyle();
//! Redirect the request to #SVTK_RenderWindowInteractor::PushInteractorStyle
- void
- PushInteractorStyle(vtkInteractorStyle* theStyle);
+ void PushInteractorStyle(vtkInteractorStyle* theStyle);
//! Redirect the request to #SVTK_RenderWindowInteractor::PopInteractorStyle
- void
- PopInteractorStyle();
+ void PopInteractorStyle();
//----------------------------------------------------------------------------
//! Redirect the request to #SVTK_RenderWindowInteractor::GetSelector
- SVTK_Selector*
- GetSelector();
+ SVTK_Selector* GetSelector();
//! Redirect the request to #SVTK_RenderWindowInteractor::SelectionMode
- Selection_Mode
- SelectionMode();
+ Selection_Mode SelectionMode();
//! Redirect the request to #SVTK_RenderWindowInteractor::SetSelectionMode
- void
- SetSelectionMode(Selection_Mode theMode);
+ void SetSelectionMode(Selection_Mode theMode);
//----------------------------------------------------------------------------
//! Redirect the request to #SVTK_RenderWindowInteractor::GetRenderer
- SVTK_Renderer*
- GetRenderer();
+ SVTK_Renderer* GetRenderer();
//! Redirect the request to #SVTK_RenderWindowInteractor::getRenderer
- vtkRenderer*
- getRenderer();
+ vtkRenderer* getRenderer();
//! Set background color to the view
- void
- SetBackgroundColor(const QColor& theColor);
+ void SetBackgroundColor(const QColor& theColor);
//! Get background color of the view
- QColor
- BackgroundColor();
+ QColor BackgroundColor();
//! Redirect the request to #SVTK_Renderer::SetScale
- void
- SetScale(double theScale[3]);
+ void SetScale(double theScale[3]);
//! Redirect the request to #SVTK_Renderer::GetScale
- void
- GetScale(double theScale[3]);
+ void GetScale(double theScale[3]);
//! Redirect the request to #SVTK_Renderer::AddActor
- virtual
- void
- AddActor(VTKViewer_Actor* theActor,
- bool theIsUpdate = false);
+ virtual void AddActor(VTKViewer_Actor* theActor,
+ bool theIsUpdate = false);
//! Redirect the request to #SVTK_Renderer::RemoveActor
- virtual
- void
- RemoveActor(VTKViewer_Actor* theActor,
- bool theIsUpdate = false);
+ virtual void RemoveActor(VTKViewer_Actor* theActor,
+ bool theIsUpdate = false);
+
+ //! Redirect the request to #SVTK_InteractorStyle::SetIncrementalSpeed
+ void SetIncrementalSpeed( const int, const int = 0 );
+
+ //! Redirect the request to #SVTK_InteractorStyle::SetIncrementalSpeed
+ void SetSMButtons( const int, const int, const int );
//! Redirect the request to #SVTK_Renderer::GetTrihedronSize
- vtkFloatingPointType
- GetTrihedronSize();
+ vtkFloatingPointType GetTrihedronSize();
//! Redirect the request to #SVTK_Renderer::SetTrihedronSize
- void
- SetTrihedronSize(const vtkFloatingPointType theSize, const bool theRelative = true);
+ void SetTrihedronSize(const vtkFloatingPointType theSize, const bool theRelative = true);
//! Redirect the request to #SVTK_Renderer::AdjustActors
- void
- AdjustActors();
+ void AdjustActors();
//! Redirect the request to #SVTK_Renderer::IsTrihedronDisplayed
- bool
- IsTrihedronDisplayed();
+ bool IsTrihedronDisplayed();
//! Redirect the request to #SVTK_Renderer::IsCubeAxesDisplayed
- bool
- IsCubeAxesDisplayed();
+ bool IsCubeAxesDisplayed();
//! Redirect the request to #SVTK_Renderer::GetTrihedron
- VTKViewer_Trihedron*
- GetTrihedron();
+ VTKViewer_Trihedron* GetTrihedron();
//! Redirect the request to #SVTK_Renderer::GetCubeAxes
- SVTK_CubeAxesActor2D*
- GetCubeAxes();
+ SVTK_CubeAxesActor2D* GetCubeAxes();
//----------------------------------------------------------------------------
QToolBar* getToolBar();
void onResetView();
void onFitAll();
+ void onViewParameters(bool theIsActivate);
+
+ void activateProjectionMode(int);
+
+ void activateSetFocalPointGravity();
+ void activateSetFocalPointSelected();
+ void activateStartFocalPointSelection();
+
void onViewTrihedron();
void onViewCubeAxes();
void onAdjustTrihedron();
void onAdjustCubeAxes();
+ void onProjectionMode(int mode);
+
+ void onSwitchInteractionStyle(bool theOn);
+
+ void onStartRecording();
+ void onPlayRecording();
+ void onPauseRecording();
+ void onStopRecording();
+
public:
QImage dumpView();
protected:
virtual QtxActionToolMgr* toolMgr() const;
- void
- createActions(SUIT_ResourceMgr* theResourceMgr);
+ void createActions(SUIT_ResourceMgr* theResourceMgr);
- void
- createToolBar();
+ void createToolBar();
- void
- SetEventDispatcher(vtkObject* theDispatcher);
+ void SetEventDispatcher(vtkObject* theDispatcher);
QtxAction* action( int ) const;
enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId,
ChangeRotationPointId, RotationId,
FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId,
- ViewTrihedronId, NonIsometric, GraduatedAxes, UpdateRate};
+ ViewTrihedronId, NonIsometric, GraduatedAxes, UpdateRate,
+ ProjectionModeId, ViewParametersId, SwitchInteractionStyleId,
+ StartRecordingId, PlayRecordingId, PauseRecordingId, StopRecordingId };
SUIT_ViewWindow* myViewWindow;
SVTK_UpdateRateDlg* myUpdateRateDlg;
SVTK_CubeAxesDlg* myCubeAxesDlg;
SVTK_SetRotationPointDlg* mySetRotationPointDlg;
+ SVTK_ViewParameterDlg* myViewParameterDlg;
vtkSmartPointer<vtkObject> myEventDispatcher;
int myToolBar;
+ int myRecordingToolBar;
SVTK_RenderWindowInteractor* myInteractor;
+ vtkSmartPointer<SVTK_KeyFreeInteractorStyle> myKeyFreeInteractorStyle;
+
+ QSize myPreRecordingMinSize;
+ QSize myPreRecordingMaxSize;
+
+ SVTK_Recorder* myRecorder;
+ QtxAction* myStartAction;
+ QtxAction* myPlayAction;
+ QtxAction* myPauseAction;
+ QtxAction* myStopAction;
};
#ifdef WIN32
// $Header$
#include "SVTK_NonIsometricDlg.h"
-#include "SVTK_MainWindow.h"
+#include "SVTK_ViewWindow.h"
#include "SVTK_Renderer.h"
#include "QtxDoubleSpinBox.h"
*/
SVTK_NonIsometricDlg
::SVTK_NonIsometricDlg(QtxAction* theAction,
- SVTK_MainWindow* theParent,
+ SVTK_ViewWindow* theParent,
const char* theName):
SVTK_DialogBase(theAction,
theParent,
#include "SVTK_DialogBase.h"
-class SVTK_MainWindow;
+class SVTK_ViewWindow;
class QtxDoubleSpinBox;
class QtxAction;
public:
SVTK_NonIsometricDlg(QtxAction* theAction,
- SVTK_MainWindow* theParent,
+ SVTK_ViewWindow* theParent,
const char* theName);
~SVTK_NonIsometricDlg();
void Update();
protected:
- SVTK_MainWindow *m_MainWindow;
+ SVTK_ViewWindow *m_MainWindow;
QtxDoubleSpinBox* m_sbXcoeff;
QtxDoubleSpinBox* m_sbYcoeff;
--- /dev/null
+// Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
+#include "SVTK_Recorder.h"
+
+#include "SVTK_ImageWriter.h"
+#include "SVTK_ImageWriterMgr.h"
+
+#include <vtkObjectFactory.h>
+#include <vtkObject.h>
+#include <vtkCallbackCommand.h>
+#include <vtkRenderWindow.h>
+#include <vtkTimerLog.h>
+#include <vtkWindowToImageFilter.h>
+#include <vtkJPEGWriter.h>
+#include <vtkImageData.h>
+
+#include <sstream>
+#include <iomanip>
+#include <iostream>
+
+#ifndef WIN32
+#include <unistd.h>
+#endif
+
+#include <QApplication>
+#include <QFileInfo>
+#include <QDir>
+
+//#include "utilities.h"
+
+#ifdef _DEBUG_
+static int MYDEBUG = 0;
+#else
+static int MYDEBUG = 0;
+#endif
+
+
+namespace
+{
+ //----------------------------------------------------------------------------
+ inline
+ void
+ GetNameJPEG(const std::string& thePreffix,
+ const int theIndex,
+ std::string& theName)
+ {
+ using namespace std;
+ ostringstream aStream;
+ aStream<<thePreffix<<"_"<<setw(6)<<setfill('0')<<theIndex<<".jpeg";
+ theName = aStream.str();
+ }
+}
+
+//----------------------------------------------------------------------------
+vtkCxxRevisionMacro(SVTK_Recorder,"$Revision$");
+vtkStandardNewMacro(SVTK_Recorder);
+
+
+//----------------------------------------------------------------------------
+SVTK_Recorder
+::SVTK_Recorder():
+ myRenderWindow(NULL),
+ myState(SVTK_Recorder_Stop),
+ myNbFPS(5.5),
+ myQuality(100),
+ myProgressiveMode(true),
+ myUseSkippedFrames(true),
+ myErrorStatus(0),
+ myCommand(vtkCallbackCommand::New()),
+ myPriority(0.0),
+ myTimeStart(0.0),
+ myFrameIndex(0),
+ myPaused(0),
+ myFilter(vtkWindowToImageFilter::New()),
+ myWriterMgr(new SVTK_ImageWriterMgr),
+ myNbWrittenFrames(0),
+ myNameAVIMaker("jpeg2yuv")
+{
+ myCommand->SetClientData(this);
+ myCommand->SetCallback(SVTK_Recorder::ProcessEvents);
+}
+
+
+//----------------------------------------------------------------------------
+SVTK_Recorder
+::~SVTK_Recorder()
+{
+ myCommand->Delete();
+ myFilter->Delete();
+ delete myWriterMgr;
+}
+
+
+//----------------------------------------------------------------------------
+void
+SVTK_Recorder
+::CheckExistAVIMaker()
+{
+ myErrorStatus = 0;
+ using namespace std;
+ ostringstream aStream;
+ aStream<<"which "<<myNameAVIMaker<<" >& /dev/null";
+ std::string anAVIMakeCheck = aStream.str();
+ int iErr = system(anAVIMakeCheck.c_str());
+ if(iErr != 0)
+ myErrorStatus = 127;
+}
+
+
+//----------------------------------------------------------------------------
+void
+SVTK_Recorder
+::SetName(const char* theName)
+{
+ myName = theName;
+}
+
+const char*
+SVTK_Recorder::Name() const
+{
+ return myName.c_str();
+}
+
+
+//----------------------------------------------------------------------------
+void
+SVTK_Recorder
+::SetNbFPS(const double theNbFPS)
+{
+ myNbFPS = theNbFPS;
+}
+
+double
+SVTK_Recorder
+::NbFPS() const
+{
+ return myNbFPS;
+}
+
+
+//----------------------------------------------------------------------------
+void
+SVTK_Recorder
+::SetQuality(int theQuality)
+{
+ myQuality = theQuality;
+}
+
+int
+SVTK_Recorder
+::GetQuality() const
+{
+ return myQuality;
+}
+
+
+//----------------------------------------------------------------------------
+void
+SVTK_Recorder
+::SetRenderWindow(vtkRenderWindow* theRenderWindow)
+{
+ myRenderWindow = theRenderWindow;
+}
+
+vtkRenderWindow*
+SVTK_Recorder
+::RenderWindow()
+{
+ return myRenderWindow;
+}
+
+
+//----------------------------------------------------------------------------
+void
+SVTK_Recorder
+::SetProgressiveMode(bool theProgressiveMode)
+{
+ myProgressiveMode = theProgressiveMode;
+}
+
+bool
+SVTK_Recorder
+::GetProgressiveMode() const
+{
+ return myProgressiveMode;
+}
+
+
+//----------------------------------------------------------------------------
+void
+SVTK_Recorder
+::SetUseSkippedFrames(bool theUseSkippedFrames)
+{
+ myUseSkippedFrames = theUseSkippedFrames;
+}
+
+bool
+SVTK_Recorder
+::UseSkippedFrames() const
+{
+ return myUseSkippedFrames;
+}
+
+
+//----------------------------------------------------------------------------
+int
+SVTK_Recorder
+::ErrorStatus() const
+{
+ return myErrorStatus;
+}
+
+int
+SVTK_Recorder
+::State() const
+{
+ return myState;
+}
+
+
+//----------------------------------------------------------------------------
+void
+SVTK_Recorder
+::ProcessEvents(vtkObject* vtkNotUsed(theObject),
+ unsigned long theEvent,
+ void* theClientData,
+ void* vtkNotUsed(theCallData))
+{
+ if(vtkObject* anObj = reinterpret_cast<vtkObject*>(theClientData)){
+ if(SVTK_Recorder* aSelf = dynamic_cast<SVTK_Recorder*>(anObj)){
+ if(theEvent==vtkCommand::EndEvent){
+ if(aSelf->State() == SVTK_Recorder::SVTK_Recorder_Record){
+ aSelf->DoRecord();
+ }
+ }
+ }
+ }
+}
+
+
+//----------------------------------------------------------------------------
+void
+SVTK_Recorder
+::Record()
+{
+ if(myState == SVTK_Recorder_Stop){
+ if(myRenderWindow){
+ myState = SVTK_Recorder_Record;
+ myFilter->SetInput(myRenderWindow);
+ myFrameIndex = -1;
+ myNbWrittenFrames = 0;
+ myRenderWindow->RemoveObserver(myCommand);
+ myRenderWindow->AddObserver(vtkCommand::EndEvent,
+ myCommand,
+ myPriority);
+ myRenderWindow->Render();
+ }
+ }
+}
+
+
+//----------------------------------------------------------------------------
+void
+SVTK_Recorder
+::Stop()
+{
+ QApplication::setOverrideCursor( Qt::WaitCursor );
+
+ if(myState == SVTK_Recorder_Record){
+ if(!myPaused)
+ DoRecord();
+
+ myWriterMgr->Stop();
+
+ if(myUseSkippedFrames)
+ AddSkippedFrames();
+
+ myFrameIndexes.clear();
+
+ MakeFileAVI();
+ }
+ myState = SVTK_Recorder_Stop;
+ myPaused = 0;
+
+ QApplication::restoreOverrideCursor();
+}
+
+
+//----------------------------------------------------------------------------
+void
+SVTK_Recorder
+::Pause()
+{
+ myPaused = myPaused ? 0 : 1;
+ if(myPaused && !myFrameIndexes.empty()){
+ myFrameIndexes.back() *= -1;
+ if(MYDEBUG) cout<<"SVTK_Recorder::Pause - myFrameIndexes.back() = "<<myFrameIndexes.back()<<endl;
+ }
+}
+
+
+//----------------------------------------------------------------------------
+inline
+int
+GetFrameIndex(double theStartTime,
+ double theFPS)
+{
+ double aTimeNow = vtkTimerLog::GetCurrentTime();
+ double aDelta = aTimeNow - theStartTime;
+ return int(aDelta*theFPS);
+}
+
+void
+SVTK_Recorder
+::DoRecord()
+{
+ if(myPaused)
+ return;
+
+ if(myFrameIndex < 0){
+ myFrameIndex = 0;
+ myTimeStart = vtkTimerLog::GetCurrentTime();
+ }else{
+ int aFrameIndex = GetFrameIndex(myTimeStart,myNbFPS);
+ if(aFrameIndex <= myFrameIndex)
+ return;
+
+ // If there was a "pause" we correct the myTimeStart
+ int aLastFrameIndex = myFrameIndexes.back();
+ if(aLastFrameIndex < 0){
+ myFrameIndexes.back() = abs(myFrameIndexes.back());
+ double aPauseTime = fabs((double)(aFrameIndex - myFrameIndex - 1)) / myNbFPS;
+ if(MYDEBUG)
+ cout<<"SVTK_Recorder::DoRecord - aFrameIndex = "<<aFrameIndex<<
+ "; aPauseTime = "<<aPauseTime<<endl;
+ myTimeStart += aPauseTime;
+ }
+
+ aFrameIndex = GetFrameIndex(myTimeStart,myNbFPS);
+ if(aFrameIndex <= myFrameIndex)
+ return;
+
+ myFrameIndex = aFrameIndex;
+ }
+
+ myFrameIndexes.push_back(myFrameIndex);
+ if(MYDEBUG) cout<<"SVTK_Recorder::DoRecord - myFrameIndex = "<<myFrameIndex<<endl;
+
+ myRenderWindow->RemoveObserver(myCommand);
+ myFilter->Modified();
+
+ std::string aName;
+ GetNameJPEG(myName,myFrameIndex,aName);
+
+ PreWrite();
+
+ vtkImageData *anImageData = vtkImageData::New();
+ anImageData->DeepCopy(myFilter->GetOutput());
+
+ myWriterMgr->StartImageWriter(anImageData,aName,myProgressiveMode,myQuality);
+ myNbWrittenFrames++;
+
+ myRenderWindow->AddObserver(vtkCommand::EndEvent,
+ myCommand,
+ myPriority);
+}
+
+
+//----------------------------------------------------------------------------
+void
+SVTK_Recorder
+::PreWrite()
+{
+ vtkImageData *anImageData = myFilter->GetOutput();
+ //
+ if(!anImageData){
+ myErrorStatus = 20;
+ return;
+ }
+ anImageData->UpdateInformation();
+ int *anExtent = anImageData->GetWholeExtent();
+ anImageData->SetUpdateExtent(anExtent[0], anExtent[1],
+ anExtent[2], anExtent[3],
+ 0,0);
+ anImageData->UpdateData();
+}
+
+
+//----------------------------------------------------------------------------
+void
+SVTK_Recorder
+::AddSkippedFrames()
+{
+ myErrorStatus = 0;
+
+ if(myFrameIndexes.size() < 2)
+ return;
+
+ size_t anId = 0, anEnd = myFrameIndexes.size() - 1;
+ for(; anId < anEnd; anId++){
+ int aStartIndex = myFrameIndexes[anId];
+ if(aStartIndex < 0)
+ continue;
+
+ int aFinishIndex = abs(myFrameIndexes[anId + 1]);
+ if(aStartIndex + 1 == aFinishIndex)
+ continue;
+
+ std::string anInitialName;
+ std::ostringstream aStream;
+ GetNameJPEG(myName,aStartIndex,anInitialName);
+ for(int anIndex = aStartIndex + 1; anIndex < aFinishIndex; anIndex++){
+ myNbWrittenFrames++;
+ std::string anCurrentName;
+ GetNameJPEG(myName,anIndex,anCurrentName);
+ aStream<<"ln -s "<< anInitialName<<" "<<anCurrentName<<";";
+ if(anIndex + 1 < aFinishIndex)
+ aStream<<" \\";
+ aStream<<endl;
+ }
+ std::string aString(aStream.str());
+ system(aString.c_str());
+ if(MYDEBUG) cout<<"SVTK_Recorder::AddSkippedFrames - "<<aString<<endl;
+ }
+}
+
+
+//----------------------------------------------------------------------------
+void
+SVTK_Recorder
+::MakeFileAVI()
+{
+ myErrorStatus = 0;
+ std::ostringstream aStream;
+ aStream<<myNameAVIMaker<<
+ " -I p"<<
+ " -v 0"<<
+ //" -f "<<int(myNbFPS)<<" "<<
+ " -f "<<myNbFPS<<" "<<
+ " -n "<<myNbWrittenFrames<<" "<<
+ " -j "<<myName<<"_\%06d.jpeg "<<
+ "| yuv2lav"<<
+ " -o "<<myName;
+
+ std::string aString(aStream.str());
+ myErrorStatus = system(aString.c_str());
+
+ if(MYDEBUG) cout<<"SVTK_Recorder::MakeFileAVI - "<<aString<<endl;
+
+ QFileInfo aFileInfo(myName.c_str());
+ QString aDirPath = aFileInfo.absoluteDir().path();
+ QString aBaseName = aFileInfo.fileName();
+ QString aCommand =
+ QString("(cd ") + aDirPath +
+ "; ls " +
+ " | egrep '" + aBaseName + "_[0-9]*.jpeg'" +
+ " | xargs rm " +
+ ")";
+
+ aCommand =
+ QString("rm ") + aDirPath + "/" + aBaseName + "*.jpeg";
+
+ if(MYDEBUG) cout<<"SVTK_Recorder::MakeFileAVI - "<<(const char*)aCommand.toLatin1()<<endl;
+ system((const char*)aCommand.toLatin1());
+}
--- /dev/null
+// Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
+#ifndef SVTK_RECORDER_H
+#define SVTK_RECORDER_H
+
+#include <list>
+#include <string>
+#include <vector>
+
+#include <vtkObject.h>
+
+class vtkRenderWindow;
+class vtkCallbackCommand;
+class vtkWindowToImageFilter;
+class SVTK_ImageWriterMgr;
+
+class SVTK_Recorder : public vtkObject
+{
+ protected:
+ enum State {
+ SVTK_Recorder_Unknown=0,
+ SVTK_Recorder_Record,
+ SVTK_Recorder_Stop
+ };
+
+ public:
+ static SVTK_Recorder *New();
+ vtkTypeRevisionMacro(SVTK_Recorder,vtkObject);
+
+ void
+ SetRenderWindow(vtkRenderWindow* theRenderWindow);
+
+ vtkRenderWindow*
+ RenderWindow();
+
+ void
+ SetName(const char *theName);
+
+ const char*
+ Name() const;
+
+ void
+ SetNbFPS(const double theNbFPS);
+
+ double
+ NbFPS() const;
+
+ void
+ SetQuality(int theQuality);
+
+ int
+ GetQuality() const;
+
+ void
+ SetProgressiveMode(bool theProgressiveMode);
+
+ bool
+ GetProgressiveMode() const;
+
+ void
+ SetUseSkippedFrames(bool theUseSkippedFrames);
+
+ bool
+ UseSkippedFrames() const;
+
+ void
+ Record();
+
+ void
+ Pause();
+
+ void
+ Stop();
+
+ int
+ State() const;
+
+ int
+ ErrorStatus() const;
+
+ void
+ CheckExistAVIMaker();
+
+protected :
+ SVTK_Recorder();
+
+ ~SVTK_Recorder();
+
+ void
+ DoRecord();
+
+ void
+ MakeFileAVI();
+
+ void
+ AddSkippedFrames();
+
+ void
+ PreWrite();
+
+ static
+ void
+ ProcessEvents(vtkObject* theObject,
+ unsigned long theEvent,
+ void* theClientData,
+ void* theCallData);
+
+protected :
+ int myState;
+ int myPaused;
+ int myErrorStatus;
+
+ float myPriority;
+ double myTimeStart;
+
+ int myFrameIndex;
+ int myNbWrittenFrames;
+
+ double myNbFPS;
+ int myQuality;
+ bool myProgressiveMode;
+
+ typedef std::vector<int> TFrameIndexes;
+ TFrameIndexes myFrameIndexes;
+ bool myUseSkippedFrames;
+
+ std::string myName;
+ std::string myNameAVIMaker;
+
+ vtkCallbackCommand *myCommand;
+ vtkRenderWindow *myRenderWindow;
+ vtkWindowToImageFilter *myFilter;
+ SVTK_ImageWriterMgr *myWriterMgr;
+
+private:
+ SVTK_Recorder(const SVTK_Recorder&); //Not implemented
+ void operator=(const SVTK_Recorder&); //Not implemented
+};
+
+#endif
--- /dev/null
+// Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
+#include "SVTK_RecorderDlg.h"
+#include "SVTK_Recorder.h"
+
+#include <SUIT_FileDlg.h>
+#include <SUIT_MessageBox.h>
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
+
+#include <QtxDoubleSpinBox.h>
+#include <QtxIntSpinBox.h>
+
+#include <QCheckBox>
+#include <QComboBox>
+#include <QGroupBox>
+#include <QKeyEvent>
+#include <QLabel>
+#include <QLayout>
+#include <QLineEdit>
+#include <QPushButton>
+
+/*!
+ * Constructor
+ */
+SVTK_RecorderDlg::SVTK_RecorderDlg( QWidget* theParent, SVTK_Recorder* theRecorder ):
+ QDialog( theParent ),
+ myRecorder( theRecorder )
+{
+ setWindowTitle( tr( "DLG_RECORDER_TITLE" ) );
+
+ SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
+
+ QVBoxLayout* aTopLayout = new QVBoxLayout( this );
+ aTopLayout->setSpacing( 6 );
+ aTopLayout->setMargin( 6 );
+
+ // Settings
+ QGroupBox* mySettingsBox = new QGroupBox( tr( "SETTINGS" ), this );
+
+ QGridLayout* aSettingsLayout = new QGridLayout( mySettingsBox );
+ aSettingsLayout->setSpacing( 6 );
+ aSettingsLayout->setMargin( 11 );
+
+ QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAME" ), mySettingsBox );
+ myFileNameLineEdit = new QLineEdit( mySettingsBox );
+ myFileNameLineEdit->setMinimumWidth( 250 );
+ myFileNameLineEdit->setReadOnly( true );
+
+ QLabel* aRecordingModeLabel = new QLabel( tr( "RECORDING_MODE" ), mySettingsBox );
+ myRecordingModeComboBox = new QComboBox( mySettingsBox );
+ myRecordingModeComboBox->addItem( tr( "SKIPPED_FRAMES" ) );
+ myRecordingModeComboBox->addItem( tr( "ALL_DISLPAYED_FRAMES" ) );
+ myRecordingModeComboBox->setCurrentIndex( aResourceMgr->integerValue( "VTKViewer", "recorder_mode", 1 ) );
+
+ QLabel* aFPSLabel = new QLabel( tr( "FPS" ), mySettingsBox );
+ myFPSSpinBox = new QtxDoubleSpinBox( 0.1, 100.0, 1.0, mySettingsBox );
+ myFPSSpinBox->setValue( aResourceMgr->doubleValue( "VTKViewer", "recorder_fps", 10.0 ) );
+
+ QLabel* aQualityLabel = new QLabel( tr( "QUALITY" ), mySettingsBox );
+ myQualitySpinBox = new QtxIntSpinBox( 1, 100, 1, mySettingsBox );
+ myQualitySpinBox->setValue( aResourceMgr->integerValue( "VTKViewer", "recorder_quality", 80 ) );
+
+ myProgressiveCheckBox = new QCheckBox( tr( "PROGRESSIVE" ), mySettingsBox );
+ myProgressiveCheckBox->setChecked( aResourceMgr->booleanValue( "VTKViewer", "recorder_progressive", false ) );
+
+ aSettingsLayout->addWidget( aFileNameLabel, 0, 0 );
+ aSettingsLayout->addWidget( myFileNameLineEdit, 1, 0, 1, 2 );
+ aSettingsLayout->addWidget( aRecordingModeLabel, 2, 0 );
+ aSettingsLayout->addWidget( myRecordingModeComboBox, 2, 1 );
+ aSettingsLayout->addWidget( aFPSLabel, 3, 0 );
+ aSettingsLayout->addWidget( myFPSSpinBox, 3, 1 );
+ aSettingsLayout->addWidget( aQualityLabel, 4, 0 );
+ aSettingsLayout->addWidget( myQualitySpinBox, 4, 1 );
+ aSettingsLayout->addWidget( myProgressiveCheckBox, 5, 0 );
+
+ aTopLayout->addWidget( mySettingsBox );
+
+ // Start / Close
+ QGroupBox* CommonGroup = new QGroupBox( this );
+ QGridLayout* CommonGroupLayout = new QGridLayout( CommonGroup );
+ CommonGroupLayout->setAlignment( Qt::AlignTop );
+ CommonGroupLayout->setSpacing( 6 );
+ CommonGroupLayout->setMargin( 11 );
+
+ QPushButton* aStartButton = new QPushButton( tr( "START" ), CommonGroup );
+ aStartButton->setAutoDefault( true );
+ aStartButton->setDefault( true );
+ CommonGroupLayout->addWidget( aStartButton, 0, 0 );
+ CommonGroupLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
+
+ QPushButton* aCloseButton = new QPushButton( tr( "CLOSE" ), CommonGroup );
+ aCloseButton->setAutoDefault( true );
+ CommonGroupLayout->addWidget( aCloseButton, 0, 2 );
+
+ //QPushButton* aHelpButton = new QPushButton( tr( "HELP" ), CommonGroup );
+ //aHelpButton->setAutoDefault( true );
+ //CommonGroupLayout->addWidget( aHelpButton, 0, 3 );
+
+ aTopLayout->addWidget( CommonGroup );
+
+ connect( aStartButton, SIGNAL( clicked() ), this, SLOT( onStart() ) );
+ connect( aCloseButton, SIGNAL( clicked() ), this, SLOT( onClose() ) );
+ //connect( aHelpButton, SIGNAL( clicked() ), this, SLOT( onHelp() ) );
+}
+
+SVTK_RecorderDlg::~SVTK_RecorderDlg()
+{
+}
+
+void SVTK_RecorderDlg::onStart()
+{
+ if( myFileName.isNull() )
+ return;
+
+ myRecorder->SetName( (const char*)myFileName.toLatin1() );
+
+ myRecorder->SetUseSkippedFrames( myRecordingModeComboBox->currentIndex() == 0 );
+ myRecorder->SetNbFPS( myFPSSpinBox->value() );
+ myRecorder->SetQuality( myQualitySpinBox->value() );
+ myRecorder->SetProgressiveMode( myProgressiveCheckBox->isChecked() );
+
+ accept();
+
+}
+
+void SVTK_RecorderDlg::onClose()
+{
+ reject();
+}
+
+void SVTK_RecorderDlg::onHelp()
+{
+ /*
+ QString aHelpFileName = "animation_in_gauss_viewer.htm";
+ LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
+ if (app)
+ app->onHelpContextModule(app->activeModule() ? app->moduleName(app->activeModule()->moduleName()) : QString(""), aHelpFileName);
+ else {
+ QString platform;
+#ifdef WIN32
+ platform = "winapplication";
+#else
+ platform = "application";
+#endif
+ SUIT_MessageBox::warning(0, QObject::tr("WRN_WARNING"),
+ QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
+ arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(aHelpFileName) );
+ }
+ */
+}
+
+bool SVTK_RecorderDlg::onBrowseFile()
+{
+ QStringList aFilter;
+ aFilter.append( tr( "FLT_AVI_FILES" ) );
+ aFilter.append( tr( "FLT_ALL_FILES" ) );
+
+ QString aFileName = SUIT_FileDlg::getFileName( this, getenv( "HOME" ), aFilter,
+ tr( "FILE_NAME" ), false );
+
+ if( aFileName.isNull() )
+ return false;
+
+ myFileName = aFileName;
+ myFileNameLineEdit->setText( aFileName.section( '/', -1 ) );
+
+ return true;
+}
+
+int SVTK_RecorderDlg::exec()
+{
+ if( !onBrowseFile() )
+ {
+ reject();
+ return 0;
+ }
+ return QDialog::exec();
+}
+
+void SVTK_RecorderDlg::keyPressEvent( QKeyEvent* e )
+{
+ QDialog::keyPressEvent( e );
+ if ( e->isAccepted() )
+ return;
+
+ if ( e->key() == Qt::Key_F1 )
+ {
+ e->accept();
+ onHelp();
+ }
+}
--- /dev/null
+// Copyright (C) 2005 CEA/DEN, EDF R&D, OPEN CASCADE, PRINCIPIA R&D
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
+#ifndef SVTK_RECORDERDLG_H
+#define SVTK_RECORDERDLG_H
+
+#include <QDialog>
+
+class QCheckBox;
+class QComboBox;
+class QGroupBox;
+class QLCDNumber;
+class QLineEdit;
+class QPushButton;
+class QTimer;
+
+class QtxDoubleSpinBox;
+class QtxIntSpinBox;
+
+class SVTK_Recorder;
+
+class SVTK_RecorderDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+ SVTK_RecorderDlg( QWidget*, SVTK_Recorder* );
+ ~SVTK_RecorderDlg();
+
+ int exec();
+
+ QString fileName() const { return myFileName; }
+
+private:
+ virtual void keyPressEvent( QKeyEvent* );
+
+protected slots:
+ void onStart();
+ void onClose();
+ void onHelp();
+
+ bool onBrowseFile();
+
+private:
+ SVTK_Recorder* myRecorder;
+ QString myFileName;
+
+ QLineEdit* myFileNameLineEdit;
+
+ QComboBox* myRecordingModeComboBox;
+ QtxDoubleSpinBox* myFPSSpinBox;
+ QtxIntSpinBox* myQualitySpinBox;
+ QCheckBox* myProgressiveCheckBox;
+};
+
+#endif
// $Header$
#include "SVTK_SetRotationPointDlg.h"
-#include "SVTK_MainWindow.h"
+#include "SVTK_ViewWindow.h"
#include "SVTK_RenderWindowInteractor.h"
#include "SVTK_Event.h"
#include "SVTK_InteractorStyle.h"
*/
SVTK_SetRotationPointDlg
::SVTK_SetRotationPointDlg(QtxAction* theAction,
- SVTK_MainWindow* theParent,
+ SVTK_ViewWindow* theParent,
const char* theName):
SVTK_DialogBase(theAction,
theParent,
#include <vtkSmartPointer.h>
-class SVTK_MainWindow;
+class SVTK_ViewWindow;
class SVTK_RenderWindowInteractor;
class QtxAction;
public:
SVTK_SetRotationPointDlg(QtxAction* theAction,
- SVTK_MainWindow* theParent,
+ SVTK_ViewWindow* theParent,
const char* theName);
~SVTK_SetRotationPointDlg();
bool IsFirstShown();
protected:
- SVTK_MainWindow *myMainWindow;
+ SVTK_ViewWindow *myMainWindow;
SVTK_RenderWindowInteractor* myRWInteractor;
bool myIsObserverAdded;
#include "SVTK_UpdateRateDlg.h"
-#include "SVTK_MainWindow.h"
+#include "SVTK_ViewWindow.h"
#include "SVTK_RenderWindowInteractor.h"
#include "VTKViewer_Algorithm.h"
#include "SALOME_Actor.h"
*/
SVTK_UpdateRateDlg
::SVTK_UpdateRateDlg(QtxAction* theAction,
- SVTK_MainWindow* theParent,
+ SVTK_ViewWindow* theParent,
const char* theName):
SVTK_DialogBase(theAction,
theParent,
#include <vtkSmartPointer.h>
-class SVTK_MainWindow;
+class SVTK_ViewWindow;
class SVTK_RenderWindowInteractor;
class QtxDoubleSpinBox;
public:
SVTK_UpdateRateDlg(QtxAction* theAction,
- SVTK_MainWindow* theParent,
+ SVTK_ViewWindow* theParent,
const char* theName);
~SVTK_UpdateRateDlg();
#include "SVTK_View.h"
#include "SVTK_Renderer.h"
-#include "SVTK_MainWindow.h"
+#include "SVTK_ViewWindow.h"
#include "SVTK_RenderWindowInteractor.h"
#include "SALOME_ListIteratorOfListIO.hxx"
Constructor
*/
SVTK_SignalHandler
-::SVTK_SignalHandler(SVTK_MainWindow* theMainWindow):
+::SVTK_SignalHandler(SVTK_ViewWindow* theMainWindow):
QObject(theMainWindow),
myMainWindow(theMainWindow)
{
/*!
\return corresponding svtk main window
*/
-SVTK_MainWindow*
+SVTK_ViewWindow*
SVTK_SignalHandler
::GetMainWindow()
{
/*!
- Redirect the request to #SVTK_MainWindow::Repaint (just for flexibility)
+ Redirect the request to #SVTK_ViewWindow::Repaint (just for flexibility)
*/
void
SVTK_SignalHandler
}
/*!
- Redirect the request to #SVTK_MainWindow::GetRenderer (just for flexibility)
+ Redirect the request to #SVTK_ViewWindow::GetRenderer (just for flexibility)
*/
SVTK_Renderer*
SVTK_SignalHandler
}
/*!
- Redirect the request to #SVTK_MainWindow::getRenderer (just for flexibility)
+ Redirect the request to #SVTK_ViewWindow::getRenderer (just for flexibility)
*/
vtkRenderer*
SVTK_SignalHandler
Constructor
*/
SVTK_View
-::SVTK_View(SVTK_MainWindow* theMainWindow) :
+::SVTK_View(SVTK_ViewWindow* theMainWindow) :
SVTK_SignalHandler(theMainWindow)
{
}
class vtkActorCollection;
class vtkRenderer;
-class SVTK_MainWindow;
+class SVTK_ViewWindow;
class SVTK_Renderer;
class SALOME_Actor;
class QColor;
-//! Main purpose of the class is to provide a way to customize #SVTK_MainWindow.
+//! Main purpose of the class is to provide a way to customize #SVTK_ViewWindow.
/*!
- This class is initialized by #SVTK_MainWindow and just pass Qt signals from
- corresponding #SVTK_RenderWindowInteractor of the #SVTK_MainWindow.
- Its main purpose is to provide a simple and flexible way to customize the #SVTK_MainWindow.
- So, in your own viewer it is possible to derive new #SVTK_MainWindow and
+ This class is initialized by #SVTK_ViewWindow and just pass Qt signals from
+ corresponding #SVTK_RenderWindowInteractor of the #SVTK_ViewWindow.
+ Its main purpose is to provide a simple and flexible way to customize the #SVTK_ViewWindow.
+ So, in your own viewer it is possible to derive new #SVTK_ViewWindow and
use existing functionality without any modifications.
*/
class SVTK_EXPORT SVTK_SignalHandler : public QObject
Q_OBJECT;
public:
- SVTK_SignalHandler(SVTK_MainWindow* theMainWindow);
+ SVTK_SignalHandler(SVTK_ViewWindow* theMainWindow);
virtual
~SVTK_SignalHandler();
- //! Get reference to its #SVTK_MainWindow
- SVTK_MainWindow*
+ //! Get reference to its #SVTK_ViewWindow
+ SVTK_ViewWindow*
GetMainWindow();
//----------------------------------------------------------------------------
- //! Redirect the request to #SVTK_MainWindow::Repaint (just for flexibility)
+ //! Redirect the request to #SVTK_ViewWindow::Repaint (just for flexibility)
void
Repaint(bool theUpdateTrihedron = true);
//----------------------------------------------------------------------------
- //! Redirect the request to #SVTK_MainWindow::GetRenderer (just for flexibility)
+ //! Redirect the request to #SVTK_ViewWindow::GetRenderer (just for flexibility)
SVTK_Renderer*
GetRenderer();
- //! Redirect the request to #SVTK_MainWindow::getRenderer (just for flexibility)
+ //! Redirect the request to #SVTK_ViewWindow::getRenderer (just for flexibility)
vtkRenderer*
getRenderer();
void selectionChanged();
protected:
- SVTK_MainWindow* myMainWindow;
+ SVTK_ViewWindow* myMainWindow;
};
Q_OBJECT;
public:
- SVTK_View(SVTK_MainWindow* theMainWindow);
+ SVTK_View(SVTK_ViewWindow* theMainWindow);
virtual
~SVTK_View();
#include <vtkActorCollection.h>
//#include "SUIT_Session.h"
-#include "SUIT_ViewModel.h"
-#include "SUIT_ViewManager.h"
-
#include "SVTK_Selection.h"
#include "SVTK_ViewModel.h"
#include "SVTK_ViewWindow.h"
#include "SVTK_View.h"
-#include "SVTK_MainWindow.h"
+//#include "SVTK_MainWindow.h"
#include "SVTK_Prs.h"
#include "VTKViewer_ViewModel.h"
+#include "SUIT_ViewModel.h"
+#include "SUIT_ViewManager.h"
+
#include <SALOME_Actor.h>
+#include <QtxActionToolMgr.h>
+
// in order NOT TO link with SalomeApp, here the code returns SALOMEDS_Study.
// SalomeApp_Study::studyDS() does it as well, but -- here it is retrieved from
// SALOMEDS::StudyManager - no linkage with SalomeApp.
{
myTrihedronSize = 105;
myTrihedronRelative = true;
+ myIncrementSpeed = 10;
+ myIncrementMode = 0;
+ myProjMode = 0;
+ myStyle = 0;
+ mySpaceBtn[0] = 1;
+ mySpaceBtn[1] = 2;
+ mySpaceBtn[2] = 9;
}
/*!
/*!
\return background color
*/
-QColor
-SVTK_Viewer
-::backgroundColor() const
+QColor SVTK_Viewer::backgroundColor() const
{
return myBgColor;
}
Changes background color
\param theColor - new background color
*/
-void
-SVTK_Viewer
-::setBackgroundColor( const QColor& theColor )
+void SVTK_Viewer::setBackgroundColor( const QColor& theColor )
{
if ( !theColor.isValid() )
return;
/*!Create new instance of view window on desktop \a theDesktop.
*\retval SUIT_ViewWindow* - created view window pointer.
*/
-SUIT_ViewWindow*
-SVTK_Viewer::
-createView( SUIT_Desktop* theDesktop )
+SUIT_ViewWindow* SVTK_Viewer::createView( SUIT_Desktop* theDesktop )
{
TViewWindow* aViewWindow = new TViewWindow(theDesktop);
aViewWindow->Initialize(this);
aViewWindow->setBackgroundColor( backgroundColor() );
aViewWindow->SetTrihedronSize( trihedronSize(), trihedronRelative() );
+ aViewWindow->SetProjectionMode( projectionMode() );
+ aViewWindow->SetInteractionStyle( interactionStyle() );
+ aViewWindow->SetIncrementalSpeed( incrementalSpeed(), incrementalSpeedMode() );
+ aViewWindow->SetSpacemouseButtons( spacemouseBtn(1), spacemouseBtn(2), spacemouseBtn(3) );
+
+ connect(aViewWindow, SIGNAL( actorAdded(VTKViewer_Actor*) ),
+ this, SLOT(onActorAdded(VTKViewer_Actor*)));
+ connect(aViewWindow, SIGNAL( actorRemoved(VTKViewer_Actor*) ),
+ this, SLOT(onActorRemoved(VTKViewer_Actor*)));
return aViewWindow;
}
}
}
+
+/*!
+ \return projection mode
+*/
+int SVTK_Viewer::projectionMode() const
+{
+ return myProjMode;
+}
+
+
+/*!
+ Sets projection mode: 0 - orthogonal, 1 - perspective projection
+ \param theMode - new projection mode
+*/
+void SVTK_Viewer::setProjectionMode( const int theMode )
+{
+ if ( myProjMode != theMode ) {
+ myProjMode = theMode;
+
+ if (SUIT_ViewManager* aViewManager = getViewManager()) {
+ QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
+ for ( uint i = 0; i < aViews.count(); i++ )
+ {
+ if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
+ aView->SetProjectionMode( theMode );
+ }
+ }
+ }
+}
+
+/*!
+ \return interaction style
+*/
+int SVTK_Viewer::interactionStyle() const
+{
+ return myStyle;
+}
+
+/*!
+ Sets interaction style: 0 - standard, 1 - keyboard free interaction
+ \param theStyle - new interaction style
+*/
+void SVTK_Viewer::setInteractionStyle( const int theStyle )
+{
+ myStyle = theStyle;
+
+ if (SUIT_ViewManager* aViewManager = getViewManager()) {
+ QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
+ for ( uint i = 0; i < aViews.count(); i++ )
+ {
+ if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
+ aView->SetInteractionStyle( theStyle );
+ }
+ }
+}
+
+/*!
+ \return incremental speed value
+*/
+int SVTK_Viewer::incrementalSpeed() const
+{
+ return myIncrementSpeed;
+}
+
+/*!
+ \return modification mode of the incremental speed
+*/
+int SVTK_Viewer::incrementalSpeedMode() const
+{
+ return myIncrementMode;
+}
+
+/*!
+ Set the incremental speed value and modification mode
+ \param theValue - new value
+ \param theMode - new mode: 0 - arithmetic, 1 - geometrical progression
+*/
+void SVTK_Viewer::setIncrementalSpeed( const int theValue, const int theMode )
+{
+ myIncrementSpeed = theValue;
+ myIncrementMode = theMode;
+
+ if (SUIT_ViewManager* aViewManager = getViewManager()) {
+ QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
+ for ( uint i = 0; i < aViews.count(); i++ )
+ {
+ if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
+ aView->SetIncrementalSpeed( theValue, theMode );
+ }
+ }
+}
+
+/*!
+ \return spacemouse button assigned to the specified function
+ \param theIndex - function by number (from 1 to 3)
+*/
+int SVTK_Viewer::spacemouseBtn( const int theIndex ) const
+{
+ if ( theIndex < 1 || theIndex > 3 )
+ return -1;
+ return mySpaceBtn[theIndex-1];
+}
+
+/*!
+ Set the spacemouse buttons
+ \param theBtn1, theBtn2, theBtn3 - new buttons
+*/
+void SVTK_Viewer::setSpacemouseButtons( const int theBtn1, const int theBtn2, const int theBtn3 )
+{
+ mySpaceBtn[0] = theBtn1;
+ mySpaceBtn[1] = theBtn2;
+ mySpaceBtn[2] = theBtn3;
+
+ if (SUIT_ViewManager* aViewManager = getViewManager()) {
+ QVector<SUIT_ViewWindow*> aViews = aViewManager->getViews();
+ for ( uint i = 0; i < aViews.count(); i++ )
+ {
+ if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
+ aView->SetSpacemouseButtons( theBtn1, theBtn2, theBtn3 );
+ }
+ }
+}
+
/*!
Sets new view manager
\param theViewManager - new view manager
/*!
Builds popup for vtk viewer
*/
-void
-SVTK_Viewer
-::contextMenuPopup( QMenu* thePopup )
+void SVTK_Viewer::contextMenuPopup( QMenu* thePopup )
{
thePopup->addAction( VTKViewer_Viewer::tr( "MEN_DUMP_VIEW" ), this, SLOT( onDumpView() ) );
thePopup->addAction( VTKViewer_Viewer::tr( "MEN_CHANGE_BACKGROUD" ), this, SLOT( onChangeBgColor() ) );
/*!
SLOT: called on mouse button press, empty implementation
*/
-void
-SVTK_Viewer
-::onMousePress(SUIT_ViewWindow* vw, QMouseEvent* event)
+void SVTK_Viewer::onMousePress(SUIT_ViewWindow* vw, QMouseEvent* event)
{}
/*!
SLOT: called on mouse move, empty implementation
*/
-void
-SVTK_Viewer
-::onMouseMove(SUIT_ViewWindow* vw, QMouseEvent* event)
+void SVTK_Viewer::onMouseMove(SUIT_ViewWindow* vw, QMouseEvent* event)
{}
/*!
SLOT: called on mouse button release, empty implementation
*/
-void
-SVTK_Viewer
-::onMouseRelease(SUIT_ViewWindow* vw, QMouseEvent* event)
+void SVTK_Viewer::onMouseRelease(SUIT_ViewWindow* vw, QMouseEvent* event)
{}
/*!
Enables/disables selection
\param isEnabled - new state
*/
-void
-SVTK_Viewer
-::enableSelection(bool isEnabled)
+void SVTK_Viewer::enableSelection(bool isEnabled)
{
mySelectionEnabled = isEnabled;
//!! To be done for view windows
Enables/disables selection of many object
\param isEnabled - new state
*/
-void
-SVTK_Viewer
-::enableMultiselection(bool isEnable)
+void SVTK_Viewer::enableMultiselection(bool isEnable)
{
myMultiSelectionEnabled = isEnable;
//!! To be done for view windows
/*!
SLOT: called on dump view operation is activated, stores scene to raster file
*/
-void
-SVTK_Viewer
-::onDumpView()
+void SVTK_Viewer::onDumpView()
{
if(SUIT_ViewWindow* aView = myViewManager->getActiveView())
aView->onDumpView();
/*!
SLOT: called if background color is to be changed changed, passes new color to view port
*/
-void
-SVTK_Viewer
-::onChangeBgColor()
+void SVTK_Viewer::onChangeBgColor()
{
if(SUIT_ViewWindow* aView = myViewManager->getActiveView()){
QColor aColor = QColorDialog::getColor( backgroundColor(), aView);
Display presentation
\param prs - presentation
*/
-void
-SVTK_Viewer
-::Display( const SALOME_VTKPrs* prs )
+void SVTK_Viewer::Display( const SALOME_VTKPrs* prs )
{
// try do downcast object
if(const SVTK_Prs* aPrs = dynamic_cast<const SVTK_Prs*>( prs )){
\param prs - presentation
\param forced - removes object from view
*/
-void
-SVTK_Viewer
-::Erase( const SALOME_VTKPrs* prs, const bool forced )
+void SVTK_Viewer::Erase( const SALOME_VTKPrs* prs, const bool forced )
{
// try do downcast object
if(const SVTK_Prs* aPrs = dynamic_cast<const SVTK_Prs*>( prs )){
Erase all presentations
\param forced - removes all objects from view
*/
-void
-SVTK_Viewer
-::EraseAll( const bool forced )
+void SVTK_Viewer::EraseAll( const bool forced )
{
// Temporarily commented to avoid awful dependecy on SALOMEDS
// TODO: better mechanism of storing display/erse status in a study
Create presentation corresponding to the entry
\param entry - entry
*/
-SALOME_Prs*
-SVTK_Viewer
-::CreatePrs( const char* entry )
+SALOME_Prs* SVTK_Viewer::CreatePrs( const char* entry )
{
SVTK_Prs* prs = new SVTK_Prs();
if ( entry ) {
/*!
Auxiliary method called before displaying of objects
*/
-void
-SVTK_Viewer
-::BeforeDisplay( SALOME_Displayer* d )
+void SVTK_Viewer::BeforeDisplay( SALOME_Displayer* d )
{
d->BeforeDisplay( this, SALOME_VTKViewType() );
}
/*!
Auxiliary method called after displaying of objects
*/
-void
-SVTK_Viewer::AfterDisplay( SALOME_Displayer* d )
+void SVTK_Viewer::AfterDisplay( SALOME_Displayer* d )
{
d->AfterDisplay( this, SALOME_VTKViewType() );
}
\return true if object is displayed in viewer
\param obj - object to be checked
*/
-bool
-SVTK_Viewer
-::isVisible( const Handle(SALOME_InteractiveObject)& io )
+bool SVTK_Viewer::isVisible( const Handle(SALOME_InteractiveObject)& io )
{
QVector<SUIT_ViewWindow*> aViews = myViewManager->getViews();
for(int i = 0, iEnd = aViews.size(); i < iEnd; i++)
/*!
Updates current viewer
*/
-void
-SVTK_Viewer
-::Repaint()
+void SVTK_Viewer::Repaint()
{
// if (theUpdateTrihedron) onAdjustTrihedron();
QVector<SUIT_ViewWindow*> aViews = myViewManager->getViews();
if(SVTK_View* aView = aViewWindow->getView())
aView->Repaint();
}
+
+
+void SVTK_Viewer::onActorAdded(VTKViewer_Actor* theActor)
+{
+ emit actorAdded((SVTK_ViewWindow*)sender(), theActor);
+}
+
+void SVTK_Viewer::onActorRemoved(VTKViewer_Actor* theActor)
+{
+ emit actorRemoved((SVTK_ViewWindow*)sender(), theActor);
+}
#include "SALOME_InteractiveObject.hxx"
#include <QColor>
+#include <QMap>
class QMouseEvent;
class SVTK_ViewWindow;
+class VTKViewer_Actor;
//! Extends two interfaces #SVTK_ViewModelBase and #SALOME_View
class SVTK_EXPORT SVTK_Viewer : public SVTK_ViewModelBase, public SALOME_View
//! Set size of trihedron of the viewer (see #SVTK_Renderer::SetTrihedronSize)
void setTrihedronSize( const vtkFloatingPointType, const bool = true );
+ //! Gets projection mode
+ int projectionMode() const;
+
+ //! Sets projection mode
+ void setProjectionMode( const int );
+
+ //! Gets interaction style
+ int interactionStyle() const;
+
+ //! Sets interaction style
+ void setInteractionStyle( const int );
+
+ //! Get incremental speed (see #SVTK_InteractorStyle::ControllerIncrement)
+ int incrementalSpeed() const;
+
+ //! Returns modification mode of incremental speed (see #SVTK_InteractorStyle::ControllerIncrement)
+ int incrementalSpeedMode() const;
+
+ //! Set the incremental speed for view operation (see #SVTK_InteractorStyle::ControllerIncrement)
+ void setIncrementalSpeed( const int, const int = 0 );
+
+ //! Gets spacemouse button for specified function
+ int spacemouseBtn( const int ) const;
+
+ //! Sets spacemouse buttons
+ void setSpacemouseButtons( const int, const int, const int );
+
public:
void enableSelection(bool isEnabled);
bool isSelectionEnabled() const { return mySelectionEnabled; }
//! See #SALOME_View::Repaint()
virtual void Repaint();
+ signals:
+ void actorAdded(SVTK_ViewWindow*, VTKViewer_Actor*);
+ void actorRemoved(SVTK_ViewWindow*, VTKViewer_Actor*);
+
protected slots:
void onMousePress(SUIT_ViewWindow*, QMouseEvent*);
void onMouseMove(SUIT_ViewWindow*, QMouseEvent*);
void onDumpView();
void onChangeBgColor();
+ void onActorAdded(VTKViewer_Actor*);
+ void onActorRemoved(VTKViewer_Actor*);
+
private:
+ void updateToolBars();
+
+
QColor myBgColor;
vtkFloatingPointType myTrihedronSize;
bool myTrihedronRelative;
bool mySelectionEnabled;
bool myMultiSelectionEnabled;
+ int myIncrementSpeed;
+ int myIncrementMode;
+ int myProjMode;
+ int myStyle;
+ int mySpaceBtn[3];
};
#endif
--- /dev/null
+// SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+// File :
+// Author :
+// Module : SALOME
+// $Header:
+
+#include "SVTK_ViewParameterDlg.h"
+#include "SVTK_ViewWindow.h"
+#include "SVTK_RenderWindowInteractor.h"
+#include "SVTK_Event.h"
+#include "SVTK_InteractorStyle.h"
+
+#include "VTKViewer_Utilities.h"
+
+#include "QtxAction.h"
+
+#include <QLineEdit>
+#include <QGroupBox>
+#include <QLabel>
+#include <QPushButton>
+#include <QGridLayout>
+#include <QDoubleValidator>
+#include <QCheckBox>
+#include <QRadioButton>
+#include <QButtonGroup>
+
+#include <vtkCallbackCommand.h>
+#include <vtkRenderer.h>
+#include <vtkCamera.h>
+#include <vtkGenericRenderWindowInteractor.h>
+
+using namespace std;
+
+/*!
+ Constructor
+*/
+SVTK_ViewParameterDlg::SVTK_ViewParameterDlg(QtxAction* theAction,
+ SVTK_ViewWindow* theParent,
+ const char* theName):
+ SVTK_DialogBase(theAction, theParent, theName),
+ myMainWindow(theParent),
+ myPriority(0.0),
+ myEventCallbackCommand(vtkCallbackCommand::New()),
+ myRWInteractor(theParent->GetInteractor())
+{
+ setWindowTitle(tr("DLG_TITLE"));
+ setSizeGripEnabled(TRUE);
+
+ // Top layout
+ QVBoxLayout* aTopLayout = new QVBoxLayout(this);
+ aTopLayout->setSpacing(6);
+ aTopLayout->setMargin(11);
+
+ // Projection mode
+ QGroupBox* aGroupBoxMode = new QGroupBox(tr("PROJECTION_MODE"), this);
+ QHBoxLayout* aLayout1 = new QHBoxLayout(aGroupBoxMode);
+
+ QRadioButton* aOrtho = new QRadioButton(tr("ORTHOGONAL_MODE"), aGroupBoxMode);
+ QRadioButton* aPersp = new QRadioButton(tr("PERSPECTIVE_MODE"), aGroupBoxMode);
+
+ aLayout1->addWidget(aOrtho);
+ aLayout1->addWidget(aPersp);
+
+ myProjectionMode = new QButtonGroup(aGroupBoxMode);
+ myProjectionMode->addButton(aOrtho, 0);
+ myProjectionMode->addButton(aPersp, 1);
+ connect(myProjectionMode, SIGNAL(buttonClicked(int)), SLOT(onProjectionModeChanged(int)));
+
+ // Focal point
+ QGroupBox* aGroupBoxFocal = new QGroupBox(tr("FOCAL_POINT"), this);
+ QVBoxLayout* aLayout2 = new QVBoxLayout(aGroupBoxFocal);
+
+ myToBBCenter = new QPushButton(aGroupBoxFocal);
+ myToBBCenter->setText(tr("LBL_TOBBCENTER"));
+ aLayout2->addWidget(myToBBCenter);
+ connect(myToBBCenter, SIGNAL(clicked()), this, SLOT(onToBBCenter()));
+
+ myToOrigin = new QPushButton(aGroupBoxFocal);
+ myToOrigin->setText(tr("LBL_TOORIGIN"));
+ aLayout2->addWidget(myToOrigin);
+ connect(myToOrigin, SIGNAL(clicked()), this, SLOT(onToOrigin()));
+
+ mySelectPoint = new QPushButton(aGroupBoxFocal);
+ mySelectPoint->setText(tr("LBL_SELECTPOINT"));
+ mySelectPoint->setCheckable(true);
+ aLayout2->addWidget(mySelectPoint);
+ connect(mySelectPoint, SIGNAL(clicked()), this, SLOT(onSelectPoint()));
+
+ // Focal point coordinates
+ myFocalCoords = new QFrame(aGroupBoxFocal);
+ myFocalCoords->setObjectName("FocalPointCoordinates");
+
+ QHBoxLayout* aCoordLayout = new QHBoxLayout(myFocalCoords);
+ aCoordLayout->setSpacing(6);
+ aCoordLayout->setMargin(0);
+
+ QLabel* aLabelX = new QLabel(tr("LBL_X"), myFocalCoords);
+ aLabelX->setFixedWidth(25);
+ myFocalX = new QLineEdit(myFocalCoords);
+ myFocalX->setValidator(new QDoubleValidator(myFocalX));
+ myFocalX->setText(QString::number(0.0));
+ connect(myFocalX, SIGNAL(textChanged(const QString&)), SLOT(onFocalCoordChanged()));
+
+ QLabel* aLabelY = new QLabel(tr("LBL_Y"), myFocalCoords);
+ aLabelY->setFixedWidth(25);
+ myFocalY = new QLineEdit(myFocalCoords);
+ myFocalY->setValidator(new QDoubleValidator(myFocalY));
+ myFocalY->setText(QString::number(0.0));
+ connect(myFocalY, SIGNAL(textChanged(const QString&)), SLOT(onFocalCoordChanged()));
+
+ QLabel* aLabelZ = new QLabel(tr("LBL_Z"), myFocalCoords);
+ aLabelZ->setFixedWidth(25);
+ myFocalZ = new QLineEdit(myFocalCoords);
+ myFocalZ->setValidator(new QDoubleValidator(myFocalZ));
+ myFocalZ->setText(QString::number(0.0));
+ connect(myFocalZ, SIGNAL(textChanged(const QString&)), SLOT(onFocalCoordChanged()));
+
+ aCoordLayout->addWidget(aLabelX);
+ aCoordLayout->addWidget(myFocalX);
+ aCoordLayout->addWidget(aLabelY);
+ aCoordLayout->addWidget(myFocalY);
+ aCoordLayout->addWidget(aLabelZ);
+ aCoordLayout->addWidget(myFocalZ);
+ aLayout2->addWidget(myFocalCoords);
+
+ // Camera position
+ QGroupBox* aGroupBoxCamera = new QGroupBox(tr("CAMERA_POSITION"), this);
+ QVBoxLayout* aLayout3 = new QVBoxLayout(aGroupBoxCamera);
+
+ QRadioButton* aWorld = new QRadioButton(tr("WORLD_COORDINATES"), aGroupBoxCamera);
+ QRadioButton* aRelative = new QRadioButton(tr("FOCAL_RELATIVE"), aGroupBoxCamera);
+
+ QHBoxLayout* aHLayout = new QHBoxLayout;
+ aHLayout->addWidget(aWorld);
+ aHLayout->addWidget(aRelative);
+ aLayout3->addLayout(aHLayout);
+
+ myCameraPositionMode = new QButtonGroup(aGroupBoxCamera);
+ myCameraPositionMode->addButton(aWorld, 0);
+ myCameraPositionMode->addButton(aRelative, 1);
+ connect(myCameraPositionMode, SIGNAL(buttonClicked(int)), SLOT(onPositionModeChanged(int)));
+
+ // Camera coordinates
+ myCameraCoords = new QFrame(aGroupBoxCamera);
+ myCameraCoords->setObjectName("CameraCoordinates");
+
+ aCoordLayout = new QHBoxLayout(myCameraCoords);
+ aCoordLayout->setSpacing(6);
+ aCoordLayout->setMargin(0);
+
+ aLabelX = new QLabel(tr("LBL_X"), myCameraCoords);
+ aLabelX->setFixedWidth(25);
+ myCameraX = new QLineEdit(myCameraCoords);
+ myCameraX->setValidator(new QDoubleValidator(myCameraX));
+ myCameraX->setText(QString::number(0.0));
+ connect(myCameraX, SIGNAL(textChanged(const QString&)), SLOT(onCameraCoordChanged()));
+
+ aLabelY = new QLabel(tr("LBL_Y"), myCameraCoords);
+ aLabelY->setFixedWidth(25);
+ myCameraY = new QLineEdit(myCameraCoords);
+ myCameraY->setValidator(new QDoubleValidator(myCameraY));
+ myCameraY->setText(QString::number(0.0));
+ connect(myCameraY, SIGNAL(textChanged(const QString&)), SLOT(onCameraCoordChanged()));
+
+ aLabelZ = new QLabel(tr("LBL_Z"), myCameraCoords);
+ aLabelZ->setFixedWidth(25);
+ myCameraZ = new QLineEdit(myCameraCoords);
+ myCameraZ->setValidator(new QDoubleValidator(myCameraZ));
+ myCameraZ->setText(QString::number(1.0));
+ connect(myCameraZ, SIGNAL(textChanged(const QString&)), SLOT(onCameraCoordChanged()));
+
+ aCoordLayout->addWidget(aLabelX);
+ aCoordLayout->addWidget(myCameraX);
+ aCoordLayout->addWidget(aLabelY);
+ aCoordLayout->addWidget(myCameraY);
+ aCoordLayout->addWidget(aLabelZ);
+ aCoordLayout->addWidget(myCameraZ);
+ aLayout3->addWidget(myCameraCoords);
+
+ // Projection direction
+ QFrame* line1 = new QFrame(aGroupBoxCamera);
+ line1->setFrameStyle(QFrame::HLine | QFrame::Sunken);
+ aLayout3->addWidget(line1);
+
+ QLabel* aLabel = new QLabel(tr("PROJECTION_DIRECTION"), aGroupBoxCamera);
+ aLayout3->addWidget(aLabel);
+
+ myProjDirection = new QFrame(aGroupBoxCamera);
+ myProjDirection->setObjectName("ProjectionDirection");
+
+ aCoordLayout = new QHBoxLayout(myProjDirection);
+ aCoordLayout->setSpacing(6);
+ aCoordLayout->setMargin(0);
+
+ aLabelX = new QLabel(tr("LBL_DX"), myProjDirection);
+ aLabelX->setFixedWidth(25);
+ myProjDirX = new QLineEdit(myProjDirection);
+ myProjDirX->setValidator(new QDoubleValidator(myProjDirX));
+ myProjDirX->setText(QString::number(0.0));
+ connect(myProjDirX, SIGNAL(textChanged(const QString&)), SLOT(onDirectionChanged()));
+
+ aLabelY = new QLabel(tr("LBL_DY"), myProjDirection);
+ aLabelY->setFixedWidth(25);
+ myProjDirY = new QLineEdit(myProjDirection);
+ myProjDirY->setValidator(new QDoubleValidator(myProjDirY));
+ myProjDirY->setText(QString::number(0.0));
+ connect(myProjDirY, SIGNAL(textChanged(const QString&)), SLOT(onDirectionChanged()));
+
+ aLabelZ = new QLabel(tr("LBL_DZ"), myProjDirection);
+ aLabelZ->setFixedWidth(25);
+ myProjDirZ = new QLineEdit(myProjDirection);
+ myProjDirZ->setValidator(new QDoubleValidator(myProjDirZ));
+ myProjDirZ->setText(QString::number(-1.0));
+ connect(myProjDirZ, SIGNAL(textChanged(const QString&)), SLOT(onDirectionChanged()));
+
+ aCoordLayout->addWidget(aLabelX);
+ aCoordLayout->addWidget(myProjDirX);
+ aCoordLayout->addWidget(aLabelY);
+ aCoordLayout->addWidget(myProjDirY);
+ aCoordLayout->addWidget(aLabelZ);
+ aCoordLayout->addWidget(myProjDirZ);
+ aLayout3->addWidget(myProjDirection);
+
+ // Distance to focal point
+ QHBoxLayout* aHorLayout = new QHBoxLayout;
+ aHorLayout->setSpacing(6);
+
+ aLabel = new QLabel(tr("FOCAL_DISTANCE"), aGroupBoxCamera);
+ myDistance = new QLineEdit(aGroupBoxCamera);
+ QDoubleValidator* aVal = new QDoubleValidator(myDistance);
+ aVal->setBottom(0.0002); // VTK minimal distance
+ myDistance->setValidator(aVal);
+ myDistance->setText(QString::number(1.0));
+ connect(myDistance, SIGNAL(textChanged(const QString&)), SLOT(onDistanceChanged()));
+
+ aHorLayout->addWidget(aLabel);
+ aHorLayout->addWidget(myDistance);
+ aLayout3->addLayout(aHorLayout);
+
+ // View Up direction
+ QFrame* line2 = new QFrame(aGroupBoxCamera);
+ line2->setFrameStyle(QFrame::HLine | QFrame::Sunken);
+ aLayout3->addWidget(line2);
+
+ aLabel = new QLabel(tr("VIEW_UP_DIRECTION"), aGroupBoxCamera);
+ aLayout3->addWidget(aLabel);
+
+ myViewDirection = new QFrame(aGroupBoxCamera);
+ myViewDirection->setObjectName("ViewUpDirection");
+ aLayout3->addWidget(myViewDirection);
+
+ aCoordLayout = new QHBoxLayout(myViewDirection);
+ aCoordLayout->setSpacing(6);
+ aCoordLayout->setMargin(0);
+
+ aLabelX = new QLabel(tr("LBL_DX"), myViewDirection);
+ aLabelX->setFixedWidth(25);
+ myViewDirX = new QLineEdit(myViewDirection);
+ myViewDirX->setValidator(new QDoubleValidator(myViewDirX));
+ myViewDirX->setText(QString::number(0.0));
+ connect(myViewDirX, SIGNAL(textChanged(const QString&)), SLOT(onViewDirectionChanged()));
+
+ aLabelY = new QLabel(tr("LBL_DY"), myViewDirection);
+ aLabelY->setFixedWidth(25);
+ myViewDirY = new QLineEdit(myViewDirection);
+ myViewDirY->setValidator(new QDoubleValidator(myViewDirY));
+ myViewDirY->setText(QString::number(1.0));
+ connect(myViewDirY, SIGNAL(textChanged(const QString&)), SLOT(onViewDirectionChanged()));
+
+ aLabelZ = new QLabel(tr("LBL_DZ"), myViewDirection);
+ aLabelZ->setFixedWidth(25);
+ myViewDirZ = new QLineEdit(myViewDirection);
+ myViewDirZ->setValidator(new QDoubleValidator(myViewDirZ));
+ myViewDirZ->setText(QString::number(0.0));
+ connect(myViewDirZ, SIGNAL(textChanged(const QString&)), SLOT(onViewDirectionChanged()));
+
+ aCoordLayout->addWidget(aLabelX);
+ aCoordLayout->addWidget(myViewDirX);
+ aCoordLayout->addWidget(aLabelY);
+ aCoordLayout->addWidget(myViewDirY);
+ aCoordLayout->addWidget(aLabelZ);
+ aCoordLayout->addWidget(myViewDirZ);
+
+ // Zooming
+ QGroupBox* aGroupBoxZoom = new QGroupBox(tr("ZOOMING"), this);
+ QVBoxLayout* aLayout4 = new QVBoxLayout(aGroupBoxZoom);
+
+ // Parallel scale
+ myScaleBox = new QFrame(aGroupBoxZoom);
+ myScaleBox->setObjectName("ScaleValue");
+
+ aHorLayout = new QHBoxLayout(myScaleBox);
+ aHorLayout->setSpacing(6);
+ aHorLayout->setMargin(0);
+
+ aLabel = new QLabel(tr("LBL_SCALE"), myScaleBox);
+ myScale = new QLineEdit(myScaleBox);
+ QDoubleValidator* aVal2 = new QDoubleValidator(myScale);
+ aVal2->setBottom(0.000001); // VTK minimal scale
+ myScale->setValidator(aVal2);
+ myScale->setText(QString::number(1.0));
+ connect(myScale, SIGNAL(textChanged(const QString&)), SLOT(onZoomChanged()));
+
+ aHorLayout->addWidget(aLabel);
+ aHorLayout->addWidget(myScale);
+ aLayout4->addWidget(myScaleBox);
+
+ // View Angle
+ myViewAngleBox = new QFrame(aGroupBoxZoom);
+ myViewAngleBox->setObjectName("ViewAngle");
+
+ aHorLayout = new QHBoxLayout(myViewAngleBox);
+ aHorLayout->setSpacing(6);
+ aHorLayout->setMargin(0);
+
+ aLabel = new QLabel(tr("LBL_VIEW_ANGLE"), myViewAngleBox);
+ myViewAngle = new QLineEdit(myViewAngleBox);
+ QDoubleValidator* aVal3 = new QDoubleValidator(myViewAngle);
+ aVal3->setBottom(0.000001); // VTK minimal scale
+ aVal3->setTop(179); // VTK minimal scale
+ myViewAngle->setValidator(aVal3);
+ myViewAngle->setText(QString::number(30.0));
+ connect(myViewAngle, SIGNAL(textChanged(const QString&)), SLOT(onZoomChanged()));
+
+ aHorLayout->addWidget(aLabel);
+ aHorLayout->addWidget(myViewAngle);
+ aLayout4->addWidget(myViewAngleBox);
+
+ // "Close" button
+ QGroupBox* aGroupBox = new QGroupBox(this);
+ QHBoxLayout* aHBoxLayout2 = new QHBoxLayout(aGroupBox);
+ aHBoxLayout2->setMargin(11);
+ aHBoxLayout2->setSpacing(6);
+
+ QPushButton* m_bClose = new QPushButton(tr("&Close"), aGroupBox );
+ m_bClose->setObjectName("m_bClose");
+ m_bClose->setAutoDefault(TRUE);
+ m_bClose->setFixedSize(m_bClose->sizeHint());
+ connect(m_bClose, SIGNAL(clicked()), this, SLOT(onClickClose()));
+
+ // Layout buttons
+ aHBoxLayout2->addWidget(m_bClose);
+
+ // Layout top level widgets
+ aTopLayout->addWidget(aGroupBoxMode);
+ aTopLayout->addWidget(aGroupBoxFocal);
+ aTopLayout->addWidget(aGroupBoxCamera);
+ aTopLayout->addWidget(aGroupBoxZoom);
+ aTopLayout->addWidget(aGroupBox);
+ aTopLayout->addStretch();
+
+ // initial state
+ myProjectionMode->button(0)->setChecked(true);
+ myCameraPositionMode->button(0)->setChecked(true);
+
+ setEnabled(myCameraCoords, myCameraPositionMode->checkedId() == 0);
+
+ myScaleBox->setVisible(myProjectionMode->checkedId() == 0);
+ myViewAngleBox->setVisible(myProjectionMode->checkedId() == 1);
+
+ updateData();
+
+ this->resize(400, this->sizeHint().height());
+
+ myEventCallbackCommand->Delete();
+ myEventCallbackCommand->SetClientData(this);
+ myEventCallbackCommand->SetCallback(SVTK_ViewParameterDlg::ProcessEvents);
+ myIsObserverAdded = false;
+ myBusy = false;
+}
+
+/*
+ * Destroys the object and frees any allocated resources
+ */
+SVTK_ViewParameterDlg::~SVTK_ViewParameterDlg()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+void SVTK_ViewParameterDlg::addObserver()
+{
+ if ( !myIsObserverAdded ) {
+ vtkInteractorStyle* aIStyle = myRWInteractor->GetInteractorStyle();
+ aIStyle->AddObserver(SVTK::FocalPointChanged, myEventCallbackCommand.GetPointer(), myPriority);
+
+ vtkRenderer *aRenderer = myRWInteractor->getRenderer();
+ aRenderer->AddObserver(vtkCommand::EndEvent, myEventCallbackCommand.GetPointer(), myPriority);
+
+ myIsObserverAdded = true;
+ }
+}
+
+/*!
+ Processes events
+*/
+void SVTK_ViewParameterDlg::ProcessEvents(vtkObject* vtkNotUsed(theObject),
+ unsigned long theEvent,
+ void* theClientData,
+ void* theCallData)
+{
+ SVTK_ViewParameterDlg* self = reinterpret_cast<SVTK_ViewParameterDlg*>(theClientData);
+ vtkFloatingPointType* aCoord;
+ switch ( theEvent ) {
+ case SVTK::FocalPointChanged:
+ if ( theCallData )
+ {
+ aCoord = (vtkFloatingPointType*)theCallData;
+ self->myBusy = true;
+ self->myFocalX->setText( QString::number(aCoord[0]) );
+ self->myFocalY->setText( QString::number(aCoord[1]) );
+ self->myFocalZ->setText( QString::number(aCoord[2]) );
+ self->myBusy = false;
+ self->onFocalCoordChanged();
+ }
+ break;
+ case vtkCommand::EndEvent:
+ if ( self->myRWInteractor->getRenderer()->GetActiveCamera()->GetMTime() > self->myCameraMTime )
+ self->updateData();
+ break;
+ }
+}
+
+void SVTK_ViewParameterDlg::updateData()
+{
+ myBusy = true;
+ vtkCamera* aCamera = myRWInteractor->getRenderer()->GetActiveCamera();
+
+ int aParallel = aCamera->GetParallelProjection();
+ myProjectionMode->button(aParallel?0:1)->setChecked(true);
+ onProjectionModeChanged( myProjectionMode->checkedId() );
+
+ double focal[3], pos[3], vup[3], proj[3], dist, scale, angle;
+
+ aCamera->GetFocalPoint(focal);
+ myFocalX->setText(QString::number(focal[0]));
+ myFocalY->setText(QString::number(focal[1]));
+ myFocalZ->setText(QString::number(focal[2]));
+
+ aCamera->GetPosition(pos);
+ myCameraX->setText(QString::number(pos[0]));
+ myCameraY->setText(QString::number(pos[1]));
+ myCameraZ->setText(QString::number(pos[2]));
+
+ aCamera->GetDirectionOfProjection(proj);
+ myProjDirX->setText(QString::number(proj[0]));
+ myProjDirY->setText(QString::number(proj[1]));
+ myProjDirZ->setText(QString::number(proj[2]));
+
+ aCamera->GetViewUp(vup);
+ myViewDirX->setText(QString::number(vup[0]));
+ myViewDirY->setText(QString::number(vup[1]));
+ myViewDirZ->setText(QString::number(vup[2]));
+
+ dist = aCamera->GetDistance();
+ myDistance->setText(QString::number(dist));
+
+ scale = aCamera->GetParallelScale();
+ myScale->setText(QString::number(scale));
+
+ angle = aCamera->GetViewAngle();
+ myViewAngle->setText(QString::number(angle));
+
+ myCameraMTime.Modified();
+ myBusy = false;
+}
+
+void SVTK_ViewParameterDlg::setEnabled(QFrame* theWidget, const bool theState)
+{
+ QObjectList aChildren(theWidget->children());
+ QObject* anObj;
+ for(int i = 0; i < aChildren.size(); i++)
+ {
+ anObj = aChildren.at(i);
+ if (anObj !=0 && anObj->inherits("QLineEdit"))
+ ((QLineEdit*)anObj)->setReadOnly(!theState);
+ if (anObj !=0 && anObj->inherits("QPushButton"))
+ ((QLineEdit*)anObj)->setEnabled(theState);
+ }
+
+}
+
+void SVTK_ViewParameterDlg::onProjectionModeChanged(int mode)
+{
+ int aBtn = myProjectionMode->checkedId();
+
+ vtkCamera* aCamera = myRWInteractor->getRenderer()->GetActiveCamera();
+ aCamera->SetParallelProjection(aBtn == 0);
+
+ myMainWindow->activateProjectionMode(aBtn);
+
+ // update view
+ myRWInteractor->GetDevice()->CreateTimer(VTKI_TIMER_FIRST);
+
+ if ( aBtn == 0 ) {
+ myViewAngleBox->setVisible(false);
+ myScaleBox->setVisible(true);
+ }
+ else {
+ myScaleBox->setVisible(false);
+ myViewAngleBox->setVisible(true);
+ }
+}
+
+void SVTK_ViewParameterDlg::onPositionModeChanged(int mode)
+{
+ setEnabled(myCameraCoords, myCameraPositionMode->checkedId() == 0);
+}
+
+void SVTK_ViewParameterDlg::onToBBCenter()
+{
+ if ( mySelectPoint->isChecked() )
+ mySelectPoint->toggle();
+
+ myMainWindow->activateSetFocalPointGravity();
+}
+
+void SVTK_ViewParameterDlg::onToOrigin()
+{
+ if ( mySelectPoint->isChecked() )
+ mySelectPoint->toggle();
+
+ myBusy = true;
+ myFocalX->setText(QString::number(0.0));
+ myFocalY->setText(QString::number(0.0));
+ myFocalZ->setText(QString::number(0.0));
+ myBusy = false;
+
+ onFocalCoordChanged();
+}
+
+void SVTK_ViewParameterDlg::onSelectPoint()
+{
+ if ( mySelectPoint->isChecked() )
+ myMainWindow->activateStartFocalPointSelection();
+ else
+ mySelectPoint->toggle();
+}
+
+void SVTK_ViewParameterDlg::onFocalCoordChanged()
+{
+ if ( myBusy ) return;
+
+ if ( mySelectPoint->isChecked() )
+ mySelectPoint->toggle();
+
+ vtkCamera* aCamera = myRWInteractor->getRenderer()->GetActiveCamera();
+ aCamera->SetFocalPoint(myFocalX->text().toDouble(),
+ myFocalY->text().toDouble(),
+ myFocalZ->text().toDouble());
+
+ aCamera->OrthogonalizeViewUp();
+ myRWInteractor->getRenderer()->ResetCameraClippingRange();
+
+ // update view
+ myRWInteractor->GetDevice()->CreateTimer(VTKI_TIMER_FIRST);
+
+ myMainWindow->activateSetFocalPointSelected();
+
+ //updateProjection();
+}
+
+void SVTK_ViewParameterDlg::onCameraCoordChanged()
+{
+ if ( myBusy ) return;
+
+ vtkCamera* aCamera = myRWInteractor->getRenderer()->GetActiveCamera();
+ aCamera->SetPosition(myCameraX->text().toDouble(),
+ myCameraY->text().toDouble(),
+ myCameraZ->text().toDouble());
+
+ aCamera->OrthogonalizeViewUp();
+ myRWInteractor->getRenderer()->ResetCameraClippingRange();
+
+ // update view
+ myRWInteractor->GetDevice()->CreateTimer(VTKI_TIMER_FIRST);
+
+ //updateProjection();
+}
+
+void SVTK_ViewParameterDlg::onDirectionChanged()
+{
+ if ( myBusy ) return;
+
+ updateCoordinates();
+}
+
+void SVTK_ViewParameterDlg::onDistanceChanged()
+{
+ if ( myBusy ) return;
+
+ updateCoordinates();
+}
+
+void SVTK_ViewParameterDlg::onViewDirectionChanged()
+{
+ if ( myBusy ) return;
+
+ vtkCamera* aCamera = myRWInteractor->getRenderer()->GetActiveCamera();
+ aCamera->SetViewUp(myViewDirX->text().toDouble(),
+ myViewDirY->text().toDouble(),
+ myViewDirZ->text().toDouble());
+
+ // update view
+ myRWInteractor->GetDevice()->CreateTimer(VTKI_TIMER_FIRST);
+}
+
+void SVTK_ViewParameterDlg::onZoomChanged()
+{
+ if ( myBusy ) return;
+
+ vtkCamera* aCamera = myRWInteractor->getRenderer()->GetActiveCamera();
+
+ switch( myProjectionMode->checkedId() ) {
+ case 0:
+ aCamera->SetParallelScale(myScale->text().toDouble());
+ break;
+ case 1:
+ aCamera->SetViewAngle(myViewAngle->text().toDouble());
+ break;
+ }
+
+ // update view
+ myRWInteractor->GetDevice()->CreateTimer(VTKI_TIMER_FIRST);
+}
+
+void SVTK_ViewParameterDlg::onClickClose()
+{
+ reject();
+}
+
+void SVTK_ViewParameterDlg::updateProjection()
+{
+ double pnt[3], pos[3], dir[3], dist;
+
+ pnt[0] = myFocalX->text().toDouble();
+ pnt[1] = myFocalY->text().toDouble();
+ pnt[2] = myFocalZ->text().toDouble();
+
+ pos[0] = myCameraX->text().toDouble();
+ pos[1] = myCameraY->text().toDouble();
+ pos[2] = myCameraZ->text().toDouble();
+
+ dir[0] = pnt[0] - pos[0];
+ dir[1] = pnt[1] - pos[1];
+ dir[2] = pnt[2] - pos[2];
+
+ dist = sqrt( dir[0]*dir[0] + dir[1]*dir[1] + dir[2]*dir[2] );
+
+ if ( dist > 0.0002 ) {
+ dir[0] = dir[0] / dist;
+ dir[1] = dir[1] / dist;
+ dir[2] = dir[2] / dist;
+ }
+
+ myBusy = true;
+ myProjDirX->setText(QString::number(dir[0]));
+ myProjDirY->setText(QString::number(dir[1]));
+ myProjDirZ->setText(QString::number(dir[2]));
+
+ myDistance->setText(QString::number(dist));
+ myBusy = false;
+}
+
+void SVTK_ViewParameterDlg::updateCoordinates()
+{
+ double pnt[3], pos[3], dir[3], dist;
+
+ pnt[0] = myFocalX->text().toDouble();
+ pnt[1] = myFocalY->text().toDouble();
+ pnt[2] = myFocalZ->text().toDouble();
+
+ pos[0] = myCameraX->text().toDouble();
+ pos[1] = myCameraY->text().toDouble();
+ pos[2] = myCameraZ->text().toDouble();
+
+ dir[0] = myProjDirX->text().toDouble();
+ dir[1] = myProjDirY->text().toDouble();
+ dir[2] = myProjDirZ->text().toDouble();
+
+ dist = myDistance->text().toDouble();
+
+ if (myCameraPositionMode->checkedId() == 1) {
+ // recompute camera position
+ dir[0] = -dir[0]; dir[1] = -dir[1]; dir[2] = -dir[2];
+ if (computePoint(pnt, dir, dist, pos)) {
+ myBusy = true;
+ myCameraX->setText(QString::number(pos[0]));
+ myCameraY->setText(QString::number(pos[1]));
+ myCameraZ->setText(QString::number(pos[2]));
+ myBusy = false;
+ onCameraCoordChanged();
+ }
+ }
+ else {
+ // recompute focal point
+ if (computePoint(pos, dir, dist, pnt)) {
+ if (mySelectPoint->isChecked())
+ mySelectPoint->toggle();
+ myBusy = true;
+ myFocalX->setText(QString::number(pnt[0]));
+ myFocalY->setText(QString::number(pnt[1]));
+ myFocalZ->setText(QString::number(pnt[2]));
+ myBusy = false;
+ onFocalCoordChanged();
+ }
+ }
+}
+
+bool SVTK_ViewParameterDlg::computePoint(const double start[3],
+ const double dir[3],
+ const double dist,
+ double result[3])
+{
+ double d = sqrt(dir[0]*dir[0]+dir[1]*dir[1]+dir[2]*dir[2]);
+ if ( d < 0.0002 ) return false;
+
+ for (int i = 0; i < 3; i++)
+ result[i] = start[i] + dir[i] * dist / d;
+
+ return true;
+}
--- /dev/null
+// SALOME VTKViewer : build VTK viewer into Salome desktop
+//
+// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+//
+//
+// File :
+// Author :
+// Module : SALOME
+// $Header:
+
+#ifndef SVTK_VIEWPARAMETERDLG_H
+#define SVTK_VIEWPARAMETERDLG_H
+
+#include "SVTK.h"
+
+#include "SVTK_DialogBase.h"
+
+#include <vtkSmartPointer.h>
+#include <vtkTimeStamp.h>
+
+class SVTK_ViewWindow;
+class SVTK_RenderWindowInteractor;
+
+class QtxAction;
+
+class QLineEdit;
+class QPushButton;
+class QFrame;
+class QCheckBox;
+class QButtonGroup;
+
+class vtkCallbackCommand;
+class vtkObject;
+
+class SVTK_EXPORT SVTK_ViewParameterDlg : public SVTK_DialogBase
+{
+ Q_OBJECT;
+
+public:
+ SVTK_ViewParameterDlg(QtxAction* theAction,
+ SVTK_ViewWindow* theParent,
+ const char* theName);
+
+ ~SVTK_ViewParameterDlg();
+
+ void addObserver();
+
+protected:
+ SVTK_ViewWindow *myMainWindow;
+ SVTK_RenderWindowInteractor* myRWInteractor;
+ bool myIsObserverAdded;
+ bool myBusy;
+
+ QButtonGroup* myProjectionMode;
+
+ QPushButton* myToBBCenter;
+ QPushButton* myToOrigin;
+ QPushButton* mySelectPoint;
+
+ QFrame* myFocalCoords;
+ QLineEdit* myFocalX;
+ QLineEdit* myFocalY;
+ QLineEdit* myFocalZ;
+
+ QButtonGroup* myCameraPositionMode;
+
+ QFrame* myCameraCoords;
+ QLineEdit* myCameraX;
+ QLineEdit* myCameraY;
+ QLineEdit* myCameraZ;
+
+ QFrame* myProjDirection;
+ QLineEdit* myProjDirX;
+ QLineEdit* myProjDirY;
+ QLineEdit* myProjDirZ;
+
+ QLineEdit* myDistance;
+
+ QFrame* myViewDirection;
+ QLineEdit* myViewDirX;
+ QLineEdit* myViewDirY;
+ QLineEdit* myViewDirZ;
+
+ QFrame* myScaleBox;
+ QLineEdit* myScale;
+
+ QFrame* myViewAngleBox;
+ QLineEdit* myViewAngle;
+
+ void setEnabled(QFrame* theWidget, const bool theState);
+ bool computePoint(const double start[3], const double dir[3],
+ const double dist, double result[3]);
+ void updateProjection();
+ void updateCoordinates();
+
+ void updateData();
+
+ //----------------------------------------------------------------------------
+ // Priority at which events are processed
+ vtkFloatingPointType myPriority;
+
+ // Used to process events
+ vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
+
+ // Used to update camera
+ vtkTimeStamp myCameraMTime;
+
+ // Description:
+ // Main process event method
+ static void ProcessEvents(vtkObject* object,
+ unsigned long event,
+ void* clientdata,
+ void* calldata);
+
+protected slots:
+ void onProjectionModeChanged(int);
+ void onPositionModeChanged(int);
+
+ void onToBBCenter();
+ void onToOrigin();
+ void onSelectPoint();
+
+ void onFocalCoordChanged();
+ void onCameraCoordChanged();
+ void onDirectionChanged();
+ void onDistanceChanged();
+ void onViewDirectionChanged();
+
+ void onZoomChanged();
+
+ void onClickClose();
+
+};
+
+#endif // SVTK_VIEWPARAMETERDLG_H
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
+#include "SVTK_NonIsometricDlg.h"
+#include "SVTK_UpdateRateDlg.h"
+#include "SVTK_CubeAxesDlg.h"
+#include "SVTK_SetRotationPointDlg.h"
+#include "SVTK_ViewParameterDlg.h"
+
#include "SALOME_Actor.h"
#include <QToolBar>
#include <QEvent>
+#include <QXmlStreamWriter>
+#include <QXmlStreamReader>
+#include <QXmlStreamAttributes>
#include <vtkTextProperty.h>
#include <vtkActorCollection.h>
#include <vtkCellPicker.h>
#include <vtkAxisActor2D.h>
#include <vtkGL2PSExporter.h>
+#include <vtkInteractorStyle.h>
#include "QtxAction.h"
#include "SUIT_ResourceMgr.h"
#include "SUIT_Accel.h"
#include "SUIT_OverrideCursor.h"
+#include "QtxActionToolMgr.h"
+#include "QtxMultiAction.h"
#include "VTKViewer_Utilities.h"
#include "SVTK_View.h"
-#include "SVTK_MainWindow.h"
+//#include "SVTK_MainWindow.h"
#include "SVTK_Selector.h"
#include "SVTK_Event.h"
#include "SVTK_RenderWindowInteractor.h"
#include "SVTK_GenericRenderWindowInteractor.h"
#include "SVTK_CubeAxesActor2D.h"
+#include "SVTK_ComboAction.h"
+#include "SVTK_KeyFreeInteractorStyle.h"
+#include "SVTK_Selector.h"
+#include "SVTK_Recorder.h"
+#include "SVTK_RecorderDlg.h"
#include "SALOME_ListIteratorOfListIO.hxx"
/*!
Constructor
*/
-SVTK_ViewWindow
-::SVTK_ViewWindow(SUIT_Desktop* theDesktop):
+SVTK_ViewWindow::SVTK_ViewWindow(SUIT_Desktop* theDesktop):
SUIT_ViewWindow(theDesktop),
- myMainWindow(0),
+ //myMainWindow(0),
myView(NULL),
- myDumpImage(QImage())
-{}
+ myDumpImage(QImage()),
+ myKeyFreeInteractorStyle(SVTK_KeyFreeInteractorStyle::New())
+{
+ setWindowFlags( windowFlags() & ~Qt::Window );
+ // specific of vtkSmartPointer
+ myKeyFreeInteractorStyle->Delete();
+}
/*!
To initialize #SVTK_ViewWindow instance
*/
-void
-SVTK_ViewWindow
-::Initialize(SVTK_ViewModelBase* theModel)
+void SVTK_ViewWindow::Initialize(SVTK_ViewModelBase* theModel)
{
- if(SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr()){
- myMainWindow = new SVTK_MainWindow(this,"SVTK_MainWindow",aResourceMgr,this);
-
- SVTK_RenderWindowInteractor* anIteractor =
- new SVTK_RenderWindowInteractor(myMainWindow,"SVTK_RenderWindowInteractor");
-
- SVTK_Selector* aSelector = SVTK_Selector::New();
-
- SVTK_GenericRenderWindowInteractor* aDevice =
- SVTK_GenericRenderWindowInteractor::New();
- aDevice->SetRenderWidget(anIteractor);
- aDevice->SetSelector(aSelector);
+ // if(SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr()){
+ //myMainWindow = new SVTK_MainWindow(this,"SVTK_MainWindow",aResourceMgr,this);
- SVTK_Renderer* aRenderer = SVTK_Renderer::New();
- aRenderer->Initialize(aDevice,aSelector);
-
- anIteractor->Initialize(aDevice,aRenderer,aSelector);
-
- aDevice->Delete();
- aRenderer->Delete();
- aSelector->Delete();
-
- myMainWindow->Initialize(anIteractor);
-
- SVTK_InteractorStyle* aStyle = SVTK_InteractorStyle::New();
- anIteractor->PushInteractorStyle(aStyle);
- aStyle->Delete();
-
- setCentralWidget(myMainWindow);
-
- myView = new SVTK_View(myMainWindow);
- Initialize(myView,theModel);
-
- anIteractor->getRenderWindow()->Render();
- myMainWindow->onResetView();
- }
+ //SVTK_RenderWindowInteractor* anIteractor =
+ // new SVTK_RenderWindowInteractor(myMainWindow,"SVTK_RenderWindowInteractor");
+ myInteractor = new SVTK_RenderWindowInteractor(this,"SVTK_RenderWindowInteractor");
+
+ SVTK_Selector* aSelector = SVTK_Selector::New();
+
+ SVTK_GenericRenderWindowInteractor* aDevice = SVTK_GenericRenderWindowInteractor::New();
+ aDevice->SetRenderWidget(myInteractor);
+ aDevice->SetSelector(aSelector);
+
+ SVTK_Renderer* aRenderer = SVTK_Renderer::New();
+ aRenderer->Initialize(aDevice,aSelector);
+
+ myInteractor->Initialize(aDevice,aRenderer,aSelector);
+
+ aDevice->Delete();
+ aRenderer->Delete();
+ aSelector->Delete();
+
+ //myMainWindow->Initialize(anIteractor);
+ myToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_LABEL"), -1, this );
+ myRecordingToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_RECORD_LABEL"), -1, this );
+
+ createActions( SUIT_Session::session()->activeApplication()->resourceMgr() );
+ createToolBar();
+
+ SetEventDispatcher(myInteractor->GetDevice());
+ myInteractor->setBackgroundRole( QPalette::NoRole );//NoBackground
+ myInteractor->setFocusPolicy(Qt::StrongFocus);
+ myInteractor->setFocus();
+ setFocusProxy(myInteractor);
+
+ myUpdateRateDlg = new SVTK_UpdateRateDlg( getAction( UpdateRate ), this, "SVTK_UpdateRateDlg" );
+ myNonIsometricDlg = new SVTK_NonIsometricDlg( getAction( NonIsometric ), this, "SVTK_NonIsometricDlg" );
+ myCubeAxesDlg = new SVTK_CubeAxesDlg( getAction( GraduatedAxes ), this, "SVTK_CubeAxesDlg" );
+ mySetRotationPointDlg = new SVTK_SetRotationPointDlg
+ ( getAction( ChangeRotationPointId ), this, "SVTK_SetRotationPointDlg" );
+ myViewParameterDlg = new SVTK_ViewParameterDlg
+ ( getAction( ViewParametersId ), this, "SVTK_ViewParameterDlg" );
+
+ SVTK_InteractorStyle* aStyle = SVTK_InteractorStyle::New();
+ myInteractor->PushInteractorStyle(aStyle);
+ aStyle->Delete();
+
+ myRecorder = SVTK_Recorder::New();
+
+ myRecorder->SetNbFPS( 17.3 );
+ myRecorder->SetQuality( 100 );
+ myRecorder->SetProgressiveMode( true );
+ myRecorder->SetUseSkippedFrames( true );
+ myRecorder->SetRenderWindow( myInteractor->getRenderWindow() );
+
+ //setCentralWidget(myMainWindow);
+ setCentralWidget(myInteractor);
+
+ //myView = new SVTK_View(myMainWindow);
+ myView = new SVTK_View(this);
+ Initialize(myView,theModel);
+
+ myInteractor->getRenderWindow()->Render();
+ onResetView();
+ //}
}
/*!
To initialize #SVTK_ViewWindow instance
*/
-void
-SVTK_ViewWindow
-::Initialize(SVTK_View* theView,
- SVTK_ViewModelBase* theModel)
+void SVTK_ViewWindow::Initialize(SVTK_View* theView,
+ SVTK_ViewModelBase* theModel)
{
connect(theView,SIGNAL(KeyPressed(QKeyEvent*)),
this,SLOT(onKeyPressed(QKeyEvent*)) );
/*!
Destructor
*/
-SVTK_ViewWindow
-::~SVTK_ViewWindow()
+SVTK_ViewWindow::~SVTK_ViewWindow()
{}
/*!
\return corresponding view
*/
-SVTK_View*
-SVTK_ViewWindow
-::getView()
+SVTK_View* SVTK_ViewWindow::getView()
{
return myView;
}
/*!
\return corresponding vtk main window
*/
-SVTK_MainWindow*
-SVTK_ViewWindow
-::getMainWindow()
-{
- return myMainWindow;
-}
+// SVTK_MainWindow* SVTK_ViewWindow::getMainWindow()
+// {
+// return myMainWindow;
+// }
/*!
\return corresponding vtk render window
*/
-vtkRenderWindow*
-SVTK_ViewWindow
-::getRenderWindow()
+vtkRenderWindow* SVTK_ViewWindow::getRenderWindow()
+{
+ return GetInteractor()->getRenderWindow();
+}
+
+/*!
+ \return corresponding vtk render window interactor
+*/
+SVTK_RenderWindowInteractor* SVTK_ViewWindow::GetInteractor() const
{
- return getMainWindow()->getRenderWindow();
+ return myInteractor;
}
/*!
\return corresponding vtk render window interactor
*/
-vtkRenderWindowInteractor*
-SVTK_ViewWindow
-::getInteractor()
+vtkRenderWindowInteractor* SVTK_ViewWindow::getInteractor() const
{
- return getMainWindow()->getInteractor();
+ return myInteractor->GetDevice();
}
/*!
\return corresponding vtk renderer
*/
-vtkRenderer*
-SVTK_ViewWindow
-::getRenderer()
+vtkRenderer* SVTK_ViewWindow::getRenderer() const
+{
+ return GetInteractor()->getRenderer();
+}
+
+/*!
+ Redirect the request to SVTK_RenderWindowInteractor::GetRenderer
+*/
+SVTK_Renderer* SVTK_ViewWindow::GetRenderer() const
{
- return myMainWindow->getRenderer();
+ return GetInteractor()->GetRenderer();
}
/*!
\return corresponding vtk selector
*/
-SVTK_Selector*
-SVTK_ViewWindow
-::GetSelector()
+SVTK_Selector* SVTK_ViewWindow::GetSelector() const
{
- return myMainWindow->GetSelector();
+ return GetInteractor()->GetSelector();
}
/*!
Processes transformation "front view"
*/
-void
-SVTK_ViewWindow
-::onFrontView()
+void SVTK_ViewWindow::onFrontView()
{
- myMainWindow->onFrontView();
+ //myMainWindow->onFrontView();
+ GetRenderer()->OnFrontView();
+ Repaint();
}
/*!
Processes transformation "back view"
*/
-void
-SVTK_ViewWindow
-::onBackView()
+void SVTK_ViewWindow::onBackView()
{
- myMainWindow->onBackView();
+ //myMainWindow->onBackView();
+ GetRenderer()->OnBackView();
+ Repaint();
}
/*!
Processes transformation "top view"
*/
-void
-SVTK_ViewWindow
-::onTopView()
+void SVTK_ViewWindow::onTopView()
{
- myMainWindow->onTopView();
+ //myMainWindow->onTopView();
+ GetRenderer()->OnTopView();
+ Repaint();
}
/*!
Processes transformation "bottom view"
*/
-void
-SVTK_ViewWindow
-::onBottomView()
+void SVTK_ViewWindow::onBottomView()
{
- myMainWindow->onBottomView();
+ //myMainWindow->onBottomView();
+ GetRenderer()->OnBottomView();
+ Repaint();
}
/*!
Processes transformation "left view"
*/
-void
-SVTK_ViewWindow
-::onLeftView()
+void SVTK_ViewWindow::onLeftView()
{
- myMainWindow->onLeftView();
+ //myMainWindow->onLeftView();
+ GetRenderer()->OnLeftView();
+ Repaint();
}
/*!
Processes transformation "right view"
*/
-void
-SVTK_ViewWindow
-::onRightView()
+void SVTK_ViewWindow::onRightView()
{
- myMainWindow->onRightView();
+ //myMainWindow->onRightView();
+ GetRenderer()->OnRightView();
+ Repaint();
}
/*!
Processes transformation "reset view": sets default orientation of viewport camera
*/
-void
-SVTK_ViewWindow
-::onResetView()
+void SVTK_ViewWindow::onResetView()
{
- myMainWindow->onResetView();
+ //myMainWindow->onResetView();
+ GetRenderer()->OnResetView();
+ Repaint();
}
/*!
Processes transformation "fit all"
*/
-void
-SVTK_ViewWindow
-::onFitAll()
+void SVTK_ViewWindow::onFitAll()
{
- myMainWindow->onFitAll();
+ //myMainWindow->onFitAll();
+ GetRenderer()->OnFitAll();
+ Repaint();
}
/*!
SLOT: called if selection is changed
*/
-void
-SVTK_ViewWindow
-::onSelectionChanged()
+void SVTK_ViewWindow::onSelectionChanged()
{
myView->onSelectionChanged();
}
Change selection mode
\param theMode - new selection mode
*/
-void
-SVTK_ViewWindow
-::SetSelectionMode(Selection_Mode theMode)
+void SVTK_ViewWindow::SetSelectionMode(Selection_Mode theMode)
{
- myMainWindow->SetSelectionMode( theMode );
+ //myMainWindow->SetSelectionMode( theMode );
+ GetSelector()->SetSelectionMode(theMode);
}
/*!
\return selection mode
*/
-Selection_Mode
-SVTK_ViewWindow
-::SelectionMode() const
+Selection_Mode SVTK_ViewWindow::SelectionMode() const
{
- return myMainWindow->SelectionMode();
+ //return myMainWindow->SelectionMode();
+ return GetSelector()->SelectionMode();
}
/*!
Unhilights all objects in viewer
*/
-void
-SVTK_ViewWindow
-::unHighlightAll()
+void SVTK_ViewWindow::unHighlightAll()
{
myView->unHighlightAll();
}
\param theIsHighlight - if it is true, object will be hilighted, otherwise it will be unhilighted
\param theIsUpdate - update current viewer
*/
-void
-SVTK_ViewWindow
-::highlight(const Handle(SALOME_InteractiveObject)& theIO,
- bool theIsHighlight,
- bool theIsUpdate )
+void SVTK_ViewWindow::highlight(const Handle(SALOME_InteractiveObject)& theIO,
+ bool theIsHighlight,
+ bool theIsUpdate )
{
myView->highlight( theIO, theIsHighlight, theIsUpdate );
}
\return true if object is in viewer or in collector
\param theIO - object to be checked
*/
-bool
-SVTK_ViewWindow
-::isInViewer( const Handle(SALOME_InteractiveObject)& theIO )
+bool SVTK_ViewWindow::isInViewer( const Handle(SALOME_InteractiveObject)& theIO )
{
return myView->isInViewer( theIO );
}
\return true if object is displayed in viewer
\param theIO - object to be checked
*/
-bool
-SVTK_ViewWindow
-::isVisible( const Handle(SALOME_InteractiveObject)& theIO )
+bool SVTK_ViewWindow::isVisible( const Handle(SALOME_InteractiveObject)& theIO )
{
return myView->isVisible( theIO );
}
Display object
\param theEntry - entry that corresponds to intractive objects
*/
-Handle(SALOME_InteractiveObject)
-SVTK_ViewWindow
-::FindIObject(const char* theEntry)
+Handle(SALOME_InteractiveObject) SVTK_ViewWindow::FindIObject(const char* theEntry)
{
return myView->FindIObject(theEntry);
}
\param theIO - object
\param theImmediatly - update viewer
*/
-void
-SVTK_ViewWindow
-::Display(const Handle(SALOME_InteractiveObject)& theIO,
- bool theImmediatly)
+void SVTK_ViewWindow::Display(const Handle(SALOME_InteractiveObject)& theIO,
+ bool theImmediatly)
{
myView->Display(theIO,theImmediatly);
}
\param theIO - object
\param theImmediatly - update viewer
*/
-void
-SVTK_ViewWindow
-::Erase(const Handle(SALOME_InteractiveObject)& theIO,
- bool theImmediatly)
+void SVTK_ViewWindow::Erase(const Handle(SALOME_InteractiveObject)& theIO,
+ bool theImmediatly)
{
myView->Erase(theIO,theImmediatly);
}
Display only passed object
\param theIO - object
*/
-void
-SVTK_ViewWindow
-::DisplayOnly(const Handle(SALOME_InteractiveObject)& theIO)
+void SVTK_ViewWindow::DisplayOnly(const Handle(SALOME_InteractiveObject)& theIO)
{
myView->DisplayOnly(theIO);
}
/*!
Display all objects in view
*/
-void
-SVTK_ViewWindow
-::DisplayAll()
+void SVTK_ViewWindow::DisplayAll()
{
myView->DisplayAll();
}
/*!
Erase all objects in view
*/
-void
-SVTK_ViewWindow
-::EraseAll()
+void SVTK_ViewWindow::EraseAll()
{
myView->EraseAll();
}
Sets background color
\param color - new background color
*/
-void
-SVTK_ViewWindow
-::setBackgroundColor( const QColor& color )
+void SVTK_ViewWindow::setBackgroundColor( const QColor& theColor )
{
- myMainWindow->SetBackgroundColor( color );
+ //myMainWindow->SetBackgroundColor( color );
+ getRenderer()->SetBackground(theColor.red()/255.0,
+ theColor.green()/255.0,
+ theColor.blue()/255.0);
}
/*!
\return background color of viewer
*/
-QColor
-SVTK_ViewWindow
-::backgroundColor() const
+QColor SVTK_ViewWindow::backgroundColor() const
{
- return myMainWindow->BackgroundColor();
+ //return myMainWindow->BackgroundColor();
+ vtkFloatingPointType aBackgroundColor[3];
+ getRenderer()->GetBackground(aBackgroundColor);
+ return QColor(int(aBackgroundColor[0]*255),
+ int(aBackgroundColor[1]*255),
+ int(aBackgroundColor[2]*255));
+}
+
+
+/*!
+ Redirect the request to SVTK_RenderWindowInteractor::GetInteractorStyle
+*/
+vtkInteractorStyle* SVTK_ViewWindow::GetInteractorStyle() const
+{
+ return GetInteractor()->GetInteractorStyle();
+}
+
+/*!
+ Redirect the request to SVTK_RenderWindowInteractor::PushInteractorStyle
+*/
+void SVTK_ViewWindow::PushInteractorStyle(vtkInteractorStyle* theStyle)
+{
+ GetInteractor()->PushInteractorStyle(theStyle);
+}
+
+/*!
+ Redirect the request to SVTK_RenderWindowInteractor::PopInteractorStyle
+*/
+void SVTK_ViewWindow::PopInteractorStyle()
+{
+ GetInteractor()->PopInteractorStyle();
}
/*!
Updates current viewer
*/
-void
-SVTK_ViewWindow
-::Repaint(bool theUpdateTrihedron)
+void SVTK_ViewWindow::Repaint(bool theUpdateTrihedron)
{
- myMainWindow->Repaint( theUpdateTrihedron );
+ //myMainWindow->Repaint( theUpdateTrihedron );
+ if(theUpdateTrihedron)
+ GetRenderer()->OnAdjustTrihedron();
+
+ GetInteractor()->update();
+
+ SVTK_InteractorStyle* aStyle = (SVTK_InteractorStyle*)getInteractor()->GetInteractorStyle();
+ if ( aStyle )
+ aStyle->OnTimer();
}
/*!
Redirect the request to #SVTK_Renderer::GetScale
*/
-void
-SVTK_ViewWindow
-::GetScale( double theScale[3] )
+void SVTK_ViewWindow::GetScale( double theScale[3] )
{
- myMainWindow->GetScale( theScale );
+ //myMainWindow->GetScale( theScale );
+ GetRenderer()->GetScale( theScale );
}
/*!
Redirect the request to #SVTK_Renderer::SetScale
*/
-void
-SVTK_ViewWindow
-::SetScale( double theScale[3] )
+void SVTK_ViewWindow::SetScale( double theScale[3] )
{
- myMainWindow->SetScale( theScale );
+ //myMainWindow->SetScale( theScale );
+ GetRenderer()->SetScale( theScale );
+ Repaint();
}
/*!
Redirect the request to #SVTK_Renderer::IsTrihedronDisplayed
*/
-bool
-SVTK_ViewWindow
-::isTrihedronDisplayed()
+bool SVTK_ViewWindow::isTrihedronDisplayed()
{
- return myMainWindow->IsTrihedronDisplayed();
+ return GetRenderer()->IsTrihedronDisplayed();
+ // return myMainWindow->IsTrihedronDisplayed();
}
/*!
Redirect the request to #SVTK_Renderer::IsCubeAxesDisplayed
*/
-bool
-SVTK_ViewWindow
-::isCubeAxesDisplayed()
+bool SVTK_ViewWindow::isCubeAxesDisplayed()
{
- return myMainWindow->IsCubeAxesDisplayed();
+ //return myMainWindow->IsCubeAxesDisplayed();
+ return GetRenderer()->IsCubeAxesDisplayed();
}
/*!
Redirect the request to #SVTK_Renderer::OnViewTrihedron
*/
-void
-SVTK_ViewWindow
-::onViewTrihedron()
+void SVTK_ViewWindow::onViewTrihedron()
{
- myMainWindow->onViewTrihedron();
+ //myMainWindow->onViewTrihedron();
+ GetRenderer()->OnViewTrihedron();
+ Repaint();
}
/*!
Redirect the request to #SVTK_Renderer::OnViewCubeAxes
*/
-void
-SVTK_ViewWindow
-::onViewCubeAxes()
+void SVTK_ViewWindow::onViewCubeAxes()
{
- myMainWindow->onViewCubeAxes();
+ //myMainWindow->onViewCubeAxes();
+ GetRenderer()->OnViewCubeAxes();
+ Repaint();
}
/*!
Redirect the request to #SVTK_Renderer::GetTrihedron
*/
-VTKViewer_Trihedron*
-SVTK_ViewWindow::
-GetTrihedron()
+VTKViewer_Trihedron* SVTK_ViewWindow::GetTrihedron()
{
- return myMainWindow->GetTrihedron();
+ //return myMainWindow->GetTrihedron();
+ return GetRenderer()->GetTrihedron();
}
/*!
Redirect the request to #SVTK_Renderer::GetCubeAxes
*/
-SVTK_CubeAxesActor2D*
-SVTK_ViewWindow
-::GetCubeAxes()
+SVTK_CubeAxesActor2D* SVTK_ViewWindow::GetCubeAxes()
{
- return myMainWindow->GetCubeAxes();
+ //return myMainWindow->GetCubeAxes();
+ return GetRenderer()->GetCubeAxes();
}
/*!
\return trihedron size
*/
-vtkFloatingPointType
-SVTK_ViewWindow
-::GetTrihedronSize() const
+vtkFloatingPointType SVTK_ViewWindow::GetTrihedronSize() const
+{
+ //return myMainWindow->GetTrihedronSize();
+ return GetRenderer()->GetTrihedronSize();
+}
+
+/*!
+ Sets projection mode
+ \param theMode - projection mode ( 0 - orthogonal, 1 - perspective )
+*/
+void SVTK_ViewWindow::SetProjectionMode(const int theMode)
+{
+ activateProjectionMode( theMode );
+}
+
+
+/*!
+ Set the gravity center as a focal point
+*/
+void SVTK_ViewWindow::activateSetFocalPointGravity()
+{
+ myEventDispatcher->InvokeEvent(SVTK::SetFocalPointGravity, 0);
+}
+
+/*!
+ Set the selected point as a focal point
+*/
+void SVTK_ViewWindow::activateSetFocalPointSelected()
+{
+ myEventDispatcher->InvokeEvent(SVTK::SetFocalPointSelected, 0);
+}
+
+/*!
+ Set the point selected by user as a focal point
+*/
+void SVTK_ViewWindow::activateStartFocalPointSelection()
+{
+ myEventDispatcher->InvokeEvent(SVTK::StartFocalPointSelection,0);
+}
+
+void SVTK_ViewWindow::activateProjectionMode(int theMode)
+{
+ SVTK_ComboAction* a = ::qobject_cast<SVTK_ComboAction*>( toolMgr()->action( ProjectionModeId ) );
+ if ( a ) a->setCurrentIndex(theMode);
+}
+
+/*!
+ Sets actual interaction style
+ \param theStyle - type of interaction style ( 0 - standard, 1 - keyboard free )
+*/
+void SVTK_ViewWindow::SetInteractionStyle(const int theStyle)
+{
+ onSwitchInteractionStyle( theStyle==1 );
+}
+
+/*!
+ Switches "keyboard free" interaction style on/off
+*/
+void SVTK_ViewWindow::onSwitchInteractionStyle(bool theOn)
+{
+ if (theOn) {
+ // check if style is already set
+ if ( GetInteractorStyle() != myKeyFreeInteractorStyle.GetPointer() )
+ {
+ // keep the same style extensions
+ SVTK_InteractorStyle* aStyle = (SVTK_InteractorStyle*)GetInteractorStyle();
+ if ( aStyle ) {
+ myKeyFreeInteractorStyle->SetControllerIncrement(aStyle->ControllerIncrement());
+ myKeyFreeInteractorStyle->SetControllerOnKeyDown(aStyle->ControllerOnKeyDown());
+ }
+
+ PushInteractorStyle(myKeyFreeInteractorStyle.GetPointer());
+ }
+ }
+ else {
+ // pop only key free style
+ if ( GetInteractorStyle() == myKeyFreeInteractorStyle.GetPointer() )
+ PopInteractorStyle();
+ }
+
+ // update action state if method is called outside
+ QtxAction* a = getAction( SwitchInteractionStyleId );
+ if ( a->isChecked() != theOn ) a->setChecked( theOn );
+}
+
+/*!
+ Sets incremental speed
+ \param theValue - new incremental speed
+ \param theMode - modification mode
+*/
+void SVTK_ViewWindow::SetIncrementalSpeed(const int theValue, const int theMode)
{
- return myMainWindow->GetTrihedronSize();
+ //myMainWindow->SetIncrementalSpeed(theValue, theMode);
+ if ( (SVTK_InteractorStyle*)GetInteractorStyle() )
+ ((SVTK_InteractorStyle*)GetInteractorStyle())->SetIncrementSpeed(theValue, theMode);
+}
+
+/*!
+ Sets spacemouse buttons for the functions
+ \param theBtn1 - spacemouse button for the "decrease speed increment"
+ \param theBtn2 - spacemouse button for the "increase speed increment"
+ \param theBtn3 - spacemouse button for the "dominant combined switch"
+*/
+void SVTK_ViewWindow::SetSpacemouseButtons(const int theBtn1,
+ const int theBtn2,
+ const int theBtn3)
+{
+ //myMainWindow->SetSMButtons(theBtn1, theBtn2, theBtn3);
+ int val = theBtn1;
+ myEventDispatcher->InvokeEvent(SVTK::SetSMDecreaseSpeedEvent, &val);
+ val = theBtn2;
+ myEventDispatcher->InvokeEvent(SVTK::SetSMIncreaseSpeedEvent, &val);
+ val = theBtn3;
+ myEventDispatcher->InvokeEvent(SVTK::SetSMDominantCombinedSwitchEvent, &val);
}
/*!
\param theSize - new trihedron size
\param theRelative - trihedron relativeness
*/
-void
-SVTK_ViewWindow
-::SetTrihedronSize(const vtkFloatingPointType theSize, const bool theRelative)
+void SVTK_ViewWindow::SetTrihedronSize(const vtkFloatingPointType theSize, const bool theRelative)
{
- myMainWindow->SetTrihedronSize(theSize, theRelative);
+ //myMainWindow->SetTrihedronSize(theSize, theRelative);
+ GetRenderer()->SetTrihedronSize(theSize, theRelative);
+ Repaint();
}
/*! If parameter theIsForcedUpdate is true, recalculate parameters for
* trihedron and cube axes, even if trihedron and cube axes is invisible.
*/
-void
-SVTK_ViewWindow
-::AdjustTrihedrons(const bool theIsForcedUpdate)
+void SVTK_ViewWindow::AdjustTrihedrons(const bool theIsForcedUpdate)
{
- myMainWindow->AdjustActors();
+ //myMainWindow->AdjustActors();
+ GetRenderer()->AdjustActors();
+ Repaint();
}
/*!
Redirect the request to #SVTK_Renderer::OnAdjustTrihedron
*/
-void
-SVTK_ViewWindow
-::onAdjustTrihedron()
+void SVTK_ViewWindow::onAdjustTrihedron()
{
- myMainWindow->onAdjustTrihedron();
+ //myMainWindow->onAdjustTrihedron();
+ GetRenderer()->OnAdjustTrihedron();
}
/*!
Redirect the request to #SVTK_Renderer::OnAdjustCubeAxes
*/
-void
-SVTK_ViewWindow
-::onAdjustCubeAxes()
+void SVTK_ViewWindow::onAdjustCubeAxes()
{
- myMainWindow->onAdjustCubeAxes();
+ //myMainWindow->onAdjustCubeAxes();
+ GetRenderer()->OnAdjustCubeAxes();
}
/*!
Emits key pressed
*/
-void
-SVTK_ViewWindow
-::onKeyPressed(QKeyEvent* event)
+void SVTK_ViewWindow::onKeyPressed(QKeyEvent* event)
{
emit keyPressed( this, event );
}
/*!
Emits key released
*/
-void
-SVTK_ViewWindow
-::onKeyReleased(QKeyEvent* event)
+void SVTK_ViewWindow::onKeyReleased(QKeyEvent* event)
{
emit keyReleased( this, event );
}
/*!
Emits mouse pressed
*/
-void
-SVTK_ViewWindow
-::onMousePressed(QMouseEvent* event)
+void SVTK_ViewWindow::onMousePressed(QMouseEvent* event)
{
emit mousePressed(this, event);
}
/*!
Emits mouse released
*/
-void
-SVTK_ViewWindow
-::onMouseReleased(QMouseEvent* event)
+void SVTK_ViewWindow::onMouseReleased(QMouseEvent* event)
{
emit mouseReleased( this, event );
}
/*!
Emits mouse moving
*/
-void
-SVTK_ViewWindow
-::onMouseMoving(QMouseEvent* event)
+void SVTK_ViewWindow::onMouseMoving(QMouseEvent* event)
{
emit mouseMoving( this, event );
}
/*!
Emits mouse double clicked
*/
-void
-SVTK_ViewWindow
-::onMouseDoubleClicked( QMouseEvent* event )
+void SVTK_ViewWindow::onMouseDoubleClicked( QMouseEvent* event )
{
emit mouseDoubleClicked( this, event );
}
/*!
Redirect the request to #SVTK_Renderer::AddActor
*/
-void
-SVTK_ViewWindow
-::AddActor( VTKViewer_Actor* theActor,
- bool theUpdate )
+void SVTK_ViewWindow::AddActor( VTKViewer_Actor* theActor,
+ bool theUpdate )
{
- myMainWindow->AddActor( theActor, theUpdate );
+ //myMainWindow->AddActor( theActor, theUpdate );
+ GetRenderer()->AddActor(theActor);
+ if(theUpdate)
+ Repaint();
+ emit actorAdded(theActor);
}
/*!
Redirect the request to #SVTK_Renderer::RemoveActor
*/
-void
-SVTK_ViewWindow
-::RemoveActor( VTKViewer_Actor* theActor,
- bool theUpdate )
+void SVTK_ViewWindow::RemoveActor( VTKViewer_Actor* theActor,
+ bool theUpdate )
{
- myMainWindow->RemoveActor( theActor, theUpdate );
+ //myMainWindow->RemoveActor( theActor, theUpdate );
+ GetRenderer()->RemoveActor(theActor);
+ if(theUpdate)
+ Repaint();
+ emit actorRemoved(theActor);
}
/*!
\return QImage, containing all scene rendering in window
*/
-QImage
-SVTK_ViewWindow
-::dumpView()
+QImage SVTK_ViewWindow::dumpView()
{
- if ( myMainWindow->getToolBar()->testAttribute(Qt::WA_UnderMouse) || myDumpImage.isNull() )
- return myMainWindow->dumpView();
+// if ( myMainWindow->getToolBar()->testAttribute(Qt::WA_UnderMouse) || myDumpImage.isNull() )
+// return myMainWindow->dumpView();
- return myDumpImage;
+// return myDumpImage;
+ QPixmap px = QPixmap::grabWindow( GetInteractor()->winId() );
+ return px.toImage();
}
QString SVTK_ViewWindow::filter() const
*/
void SVTK_ViewWindow::RefreshDumpImage()
{
- myDumpImage = myMainWindow->dumpView();
+ //myDumpImage = myMainWindow->dumpView();
+ QPixmap px = QPixmap::grabWindow( GetInteractor()->winId() );
+ myDumpImage = px.toImage();
}
/*!
Redirect the request to #SVTK_Renderer::SetSelectionProp
*/
-void
-SVTK_ViewWindow
-::SetSelectionProp(const double& theRed,
- const double& theGreen,
- const double& theBlue,
- const int& theWidth)
+void SVTK_ViewWindow::SetSelectionProp(const double& theRed,
+ const double& theGreen,
+ const double& theBlue,
+ const int& theWidth)
{
myView->SetSelectionProp(theRed,theGreen,theBlue,theWidth);
}
/*!
Redirect the request to #SVTK_Renderer::SetSelectionProp
*/
-void
-SVTK_ViewWindow
-::SetPreselectionProp(const double& theRed,
- const double& theGreen,
- const double& theBlue,
- const int& theWidth)
+void SVTK_ViewWindow::SetPreselectionProp(const double& theRed,
+ const double& theGreen,
+ const double& theBlue,
+ const int& theWidth)
{
myView->SetPreselectionProp(theRed,theGreen,theBlue,theWidth);
}
/*!
Redirect the request to #SVTK_Renderer::SetSelectionTolerance
*/
-void
-SVTK_ViewWindow
-::SetSelectionTolerance(const double& theTolNodes,
- const double& theTolItems,
- const double& theTolObjects)
+void SVTK_ViewWindow::SetSelectionTolerance(const double& theTolNodes,
+ const double& theTolItems,
+ const double& theTolObjects)
{
myView->SetSelectionTolerance(theTolNodes, theTolItems, theTolObjects);
}
Performs action
\param accelAction - action
*/
-bool
-SVTK_ViewWindow
-::action( const int accelAction )
+bool SVTK_ViewWindow::action( const int accelAction )
{
- if ( !myMainWindow->hasFocus() )
- return false;
+ // if ( !myMainWindow->hasFocus() )
+ // return false;
if ( accelAction == SUIT_Accel::ZoomFit )
onFitAll();
else {
int anEvent = SVTK::convertAction( accelAction );
- myMainWindow->InvokeEvent( anEvent, 0 );
+ //myMainWindow->InvokeEvent( anEvent, 0 );
+ GetInteractor()->InvokeEvent(anEvent, 0);
}
return true;
}
+/*!
+ \return action by it's id
+*/
+QtxAction* SVTK_ViewWindow::getAction( int id ) const
+{
+ return dynamic_cast<QtxAction*>( toolMgr()->action( id ) );
+}
+
+
// old visual parameters had 13 values. New format added additional
// 76 values for graduated axes, so both numbers are processed.
const int nNormalParams = 13; // number of view windows parameters excluding graduated axes params
/*! The method returns visual parameters of a graduated axis actor (x,y,z axis of graduated axes)
*/
-QString getGradAxisVisualParams( vtkAxisActor2D* actor )
+void getGradAxisVisualParams( QXmlStreamWriter& writer, vtkAxisActor2D* actor, QString theAxis )
{
- QString params;
+ //QString params;
if ( !actor )
- return params;
+ return ;//params;
// Name
bool isVisible = actor->GetTitleVisibility();
italic = txtProp->GetItalic();
shadow = txtProp->GetShadow();
}
- params.sprintf( "* Graduated Axis: * Name *%u*%s*%.2f*%.2f*%.2f*%u*%u*%u*%u", isVisible,
- title.toLatin1().data(), color[0], color[1], color[2], font, bold, italic, shadow );
+ writer.writeStartElement("GraduatedAxis");
+ writer.writeAttribute("Axis", theAxis);
+
+ writer.writeStartElement("Title");
+ writer.writeAttribute("isVisible", QString("%1").arg(isVisible));
+ writer.writeAttribute("Text", title);
+ writer.writeAttribute("Font", QString("%1").arg(font));
+ writer.writeAttribute("Bold", QString("%1").arg(bold));
+ writer.writeAttribute("Italic", QString("%1").arg(italic));
+ writer.writeAttribute("Shadow", QString("%1").arg(shadow));
+
+ writer.writeStartElement("Color");
+ writer.writeAttribute("R", QString("%1").arg(color[0]));
+ writer.writeAttribute("G", QString("%1").arg(color[1]));
+ writer.writeAttribute("B", QString("%1").arg(color[2]));
+ writer.writeEndElement();
+ writer.writeEndElement();
+
+ //params.sprintf( "* Graduated Axis: * Name *%u*%s*%.2f*%.2f*%.2f*%u*%u*%u*%u", isVisible,
+ // title.toLatin1().data(), color[0], color[1], color[2], font, bold, italic, shadow );
// Labels
isVisible = actor->GetLabelVisibility();
italic = txtProp->GetItalic();
shadow = txtProp->GetShadow();
}
- params += QString().sprintf( "* Labels *%u*%u*%u*%.2f*%.2f*%.2f*%u*%u*%u*%u", isVisible, labels, offset,
- color[0], color[1], color[2], font, bold, italic, shadow );
+
+ writer.writeStartElement("Labels");
+ writer.writeAttribute("isVisible", QString("%1").arg(isVisible));
+ writer.writeAttribute("Number", QString("%1").arg(labels));
+ writer.writeAttribute("Offset", QString("%1").arg(offset));
+ writer.writeAttribute("Font", QString("%1").arg(font));
+ writer.writeAttribute("Bold", QString("%1").arg(bold));
+ writer.writeAttribute("Italic", QString("%1").arg(italic));
+ writer.writeAttribute("Shadow", QString("%1").arg(shadow));
+
+ writer.writeStartElement("Color");
+ writer.writeAttribute("R", QString("%1").arg(color[0]));
+ writer.writeAttribute("G", QString("%1").arg(color[1]));
+ writer.writeAttribute("B", QString("%1").arg(color[2]));
+ writer.writeEndElement();
+ writer.writeEndElement();
+ // params += QString().sprintf( "* Labels *%u*%u*%u*%.2f*%.2f*%.2f*%u*%u*%u*%u", isVisible, labels, offset,
+ // color[0], color[1], color[2], font, bold, italic, shadow );
// Tick marks
isVisible = actor->GetTickVisibility();
int length = actor->GetTickLength();
+ writer.writeStartElement("TickMarks");
+ writer.writeAttribute("isVisible", QString("%1").arg(isVisible));
+ writer.writeAttribute("Length", QString("%1").arg(length));
+ writer.writeEndElement();
+
+ //params += QString().sprintf( "* Tick marks *%u*%u", isVisible, length );
- params += QString().sprintf( "* Tick marks *%u*%u", isVisible, length );
+ writer.writeEndElement();
+ //return params;
+}
+
+void setGradAxisVisualParams(QXmlStreamReader& reader, vtkAxisActor2D* actor)
+{
+ if ( !actor )
+ return;
+
+ do {
+ reader.readNext();
+ } while (!reader.isStartElement());
+
+ // Read title params
+ QXmlStreamAttributes aAttr = reader.attributes();
+ bool isVisible = aAttr.value("isVisible").toString().toUShort();
+ QString title = aAttr.value("Text").toString();
+ int font = aAttr.value("Font").toString().toInt();
+ int bold = aAttr.value("Bold").toString().toInt();
+ int italic = aAttr.value("Italic").toString().toInt();
+ int shadow = aAttr.value("Shadow").toString().toInt();
+
+ //printf("#### TITLE: %i, %s, %i, %i, %i, %i\n", isVisible, qPrintable(title), font, bold, italic, shadow);
+
+ do {
+ reader.readNext();
+ } while (!reader.isStartElement());
+
+ // Read title color
+ aAttr = reader.attributes();
+
+ vtkFloatingPointType color[3];
+ color[0] = aAttr.value("R").toString().toDouble();
+ color[1] = aAttr.value("G").toString().toDouble();
+ color[2] = aAttr.value("B").toString().toDouble();
+ //printf("#### Color: %f, %f, %f\n", color[0], color[1], color[2]);
+
+ actor->SetTitleVisibility( isVisible );
+ actor->SetTitle( title.toLatin1() );
+ vtkTextProperty* txtProp = actor->GetTitleTextProperty();
+ if ( txtProp ) {
+ txtProp->SetColor( color );
+ txtProp->SetFontFamily( font );
+ txtProp->SetBold( bold );
+ txtProp->SetItalic( italic );
+ txtProp->SetShadow( shadow );
+ }
+
+ // Labels
+
+ do {
+ reader.readNext();
+ } while (!reader.isStartElement());
+ // Read labels
+ aAttr = reader.attributes();
+ isVisible = aAttr.value("isVisible").toString().toUShort();
+ int labels = aAttr.value("Number").toString().toInt();
+ int offset = aAttr.value("Offset").toString().toInt();
+ font = aAttr.value("Font").toString().toInt();
+ bold = aAttr.value("Bold").toString().toInt();
+ italic = aAttr.value("Italic").toString().toInt();
+ shadow = aAttr.value("Shadow").toString().toInt();
+
+ do {
+ reader.readNext();
+ } while (!reader.isStartElement());
+ // Read Color
+ aAttr = reader.attributes();
+
+ color[0] = aAttr.value("R").toString().toDouble();
+ color[1] = aAttr.value("G").toString().toDouble();
+ color[2] = aAttr.value("B").toString().toDouble();
+
+ actor->SetLabelVisibility( isVisible );
+ actor->SetNumberOfLabels( labels );
+ actor->SetTickOffset( offset );
+ txtProp = actor->GetLabelTextProperty();
+ if ( txtProp ) {
+ txtProp->SetColor( color );
+ txtProp->SetFontFamily( font );
+ txtProp->SetBold( bold );
+ txtProp->SetItalic( italic );
+ txtProp->SetShadow( shadow );
+ }
+
+ // Tick Marks
+ do {
+ reader.readNext();
+ } while (!reader.isStartElement());
+ aAttr = reader.attributes();
+
+ // retrieve and set tick marks properties
+ isVisible = aAttr.value("isVisible").toString().toUShort();
+ int length = aAttr.value("Length").toString().toInt();
- return params;
+ actor->SetTickVisibility( isVisible );
+ actor->SetTickLength( length );
}
/*! The method restores visual parameters of a graduated axis actor (x,y,z axis)
/*! The method returns the visual parameters of this view as a formated string
*/
-QString
-SVTK_ViewWindow
-::getVisualParameters()
+QString SVTK_ViewWindow::getVisualParameters()
{
double pos[3], focalPnt[3], viewUp[3], parScale, scale[3];
// view up values (3 digits), parallel scale (1 digit), scale (3 digits,
// Graduated axes parameters (X, Y, Z axes parameters)
QString retStr;
- retStr.sprintf( "%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e",
- pos[0], pos[1], pos[2], focalPnt[0], focalPnt[1], focalPnt[2],
- viewUp[0], viewUp[1], viewUp[2], parScale, scale[0], scale[1], scale[2] );
+ QXmlStreamWriter aWriter(&retStr);
+ aWriter.setAutoFormatting(true);
+
+ aWriter.writeStartDocument();
+ aWriter.writeStartElement("ViewState");
+
+ aWriter.writeStartElement("Position");
+ aWriter.writeAttribute("X", QString("%1").arg(pos[0]));
+ aWriter.writeAttribute("Y", QString("%1").arg(pos[1]));
+ aWriter.writeAttribute("Z", QString("%1").arg(pos[2]));
+ aWriter.writeEndElement();
+
+ aWriter.writeStartElement("FocalPoint");
+ aWriter.writeAttribute("X", QString::number(focalPnt[0]));
+ aWriter.writeAttribute("Y", QString::number(focalPnt[1]));
+ aWriter.writeAttribute("Z", QString::number(focalPnt[2]));
+ aWriter.writeEndElement();
+
+ aWriter.writeStartElement("ViewUp");
+ aWriter.writeAttribute("X", QString::number(viewUp[0]));
+ aWriter.writeAttribute("Y", QString::number(viewUp[1]));
+ aWriter.writeAttribute("Z", QString::number(viewUp[2]));
+ aWriter.writeEndElement();
+
+ aWriter.writeStartElement("ViewScale");
+ aWriter.writeAttribute("Parallel", QString::number(parScale));
+ aWriter.writeAttribute("X", QString::number(scale[0]));
+ aWriter.writeAttribute("Y", QString::number(scale[1]));
+ aWriter.writeAttribute("Z", QString::number(scale[2]));
+ aWriter.writeEndElement();
- // save graduated axes parameters
if ( SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes() ) {
- retStr += QString( "*%1" ).arg( getMainWindow()->IsCubeAxesDisplayed() );
- retStr += ::getGradAxisVisualParams( gradAxesActor->GetXAxisActor2D() );
- retStr += ::getGradAxisVisualParams( gradAxesActor->GetYAxisActor2D() );
- retStr += ::getGradAxisVisualParams( gradAxesActor->GetZAxisActor2D() );
+ aWriter.writeStartElement("DisplayCubeAxis");
+ aWriter.writeAttribute("Show", QString( "%1" ).arg( GetRenderer()->IsCubeAxesDisplayed()));
+ aWriter.writeEndElement();
+
+ getGradAxisVisualParams(aWriter, gradAxesActor->GetXAxisActor2D(), "X");
+ getGradAxisVisualParams(aWriter, gradAxesActor->GetYAxisActor2D(), "Y");
+ getGradAxisVisualParams(aWriter, gradAxesActor->GetZAxisActor2D(), "Z");
}
+ aWriter.writeEndElement();
+ aWriter.writeEndDocument();
+
+// retStr.sprintf( "%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e*%.12e",
+// pos[0], pos[1], pos[2], focalPnt[0], focalPnt[1], focalPnt[2],
+// viewUp[0], viewUp[1], viewUp[2], parScale, scale[0], scale[1], scale[2] );
+
+// // save graduated axes parameters
+// if ( SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes() ) {
+// retStr += QString( "*%1" ).arg( GetRenderer()->IsCubeAxesDisplayed() );
+// retStr += ::getGradAxisVisualParams( gradAxesActor->GetXAxisActor2D() );
+// retStr += ::getGradAxisVisualParams( gradAxesActor->GetYAxisActor2D() );
+// retStr += ::getGradAxisVisualParams( gradAxesActor->GetZAxisActor2D() );
+// }
+
return retStr;
}
/*!
The method restores visual parameters of this view or postpones it untill the view is shown
-*/
-void
-SVTK_ViewWindow
-::setVisualParameters( const QString& parameters )
+*/
+void SVTK_ViewWindow::setVisualParameters( const QString& parameters )
{
- SVTK_RenderWindowInteractor* anInteractor = getMainWindow()->GetInteractor();
+ //printf("#### %s\n", qPrintable(parameters));
+ SVTK_RenderWindowInteractor* anInteractor = GetInteractor();
if ( anInteractor->isVisible() ) {
doSetVisualParameters( parameters );
}
/*!
The method restores visual parameters of this view from a formated string
*/
-void
-SVTK_ViewWindow
-::doSetVisualParameters( const QString& parameters )
-{
- QStringList paramsLst = parameters.split( '*' );
- if ( paramsLst.size() >= nNormalParams ) {
- // 'reading' list of parameters
- double pos[3], focalPnt[3], viewUp[3], parScale, scale[3];
- pos[0] = paramsLst[0].toDouble();
- pos[1] = paramsLst[1].toDouble();
- pos[2] = paramsLst[2].toDouble();
- focalPnt[0] = paramsLst[3].toDouble();
- focalPnt[1] = paramsLst[4].toDouble();
- focalPnt[2] = paramsLst[5].toDouble();
- viewUp[0] = paramsLst[6].toDouble();
- viewUp[1] = paramsLst[7].toDouble();
- viewUp[2] = paramsLst[8].toDouble();
- parScale = paramsLst[9].toDouble();
- scale[0] = paramsLst[10].toDouble();
- scale[1] = paramsLst[11].toDouble();
- scale[2] = paramsLst[12].toDouble();
-
- // applying parameters
+void SVTK_ViewWindow::doSetVisualParameters( const QString& parameters )
+{
+ double pos[3], focalPnt[3], viewUp[3], parScale, scale[3];
+
+ QXmlStreamReader aReader(parameters);
+ SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes();
+
+ while(!aReader.atEnd()) {
+ aReader.readNext();
+ if (aReader.isStartElement()) {
+ QXmlStreamAttributes aAttr = aReader.attributes();
+ //printf("### Name = %s\n", qPrintable(aReader.name().toString()));
+ if (aReader.name() == "Position") {
+ pos[0] = aAttr.value("X").toString().toDouble();
+ pos[1] = aAttr.value("Y").toString().toDouble();
+ pos[2] = aAttr.value("Z").toString().toDouble();
+ //printf("#### Position %f; %f; %f\n", pos[0], pos[1], pos[2]);
+ } else if (aReader.name() == "FocalPoint") {
+ focalPnt[0] = aAttr.value("X").toString().toDouble();
+ focalPnt[1] = aAttr.value("Y").toString().toDouble();
+ focalPnt[2] = aAttr.value("Z").toString().toDouble();
+ //printf("#### FocalPoint %f; %f; %f\n", focalPnt[0], focalPnt[1], focalPnt[2]);
+ } else if (aReader.name() == "ViewUp") {
+ viewUp[0] = aAttr.value("X").toString().toDouble();
+ viewUp[1] = aAttr.value("Y").toString().toDouble();
+ viewUp[2] = aAttr.value("Z").toString().toDouble();
+ //printf("#### ViewUp %f; %f; %f\n", viewUp[0], viewUp[1], viewUp[2]);
+ } else if (aReader.name() == "ViewScale") {
+ parScale = aAttr.value("Parallel").toString().toDouble();
+ scale[0] = aAttr.value("X").toString().toDouble();
+ scale[1] = aAttr.value("Y").toString().toDouble();
+ scale[2] = aAttr.value("Z").toString().toDouble();
+ //printf("#### ViewScale %f; %f; %f\n", scale[0], scale[1], scale[2]);
+ } else if (aReader.name() == "DisplayCubeAxis") {
+ if (aAttr.value("Show") == "0")
+ gradAxesActor->VisibilityOff();
+ else
+ gradAxesActor->VisibilityOn();
+ } else if (aReader.name() == "GraduatedAxis") {
+ if(aAttr.value("Axis") == "X")
+ setGradAxisVisualParams(aReader, gradAxesActor->GetXAxisActor2D());
+ else if(aAttr.value("Axis") == "Y")
+ setGradAxisVisualParams(aReader, gradAxesActor->GetYAxisActor2D());
+ else if(aAttr.value("Axis") == "Z")
+ setGradAxisVisualParams(aReader, gradAxesActor->GetZAxisActor2D());
+ }
+ }
+ }
+ if (!aReader.hasError()) {
vtkCamera* camera = getRenderer()->GetActiveCamera();
camera->SetPosition( pos );
camera->SetFocalPoint( focalPnt );
camera->SetViewUp( viewUp );
camera->SetParallelScale( parScale );
SetScale( scale );
-
- // apply graduated axes parameters
- SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes();
- if ( gradAxesActor && paramsLst.size() == nAllParams ) {
+ } else {
+ QStringList paramsLst = parameters.split( '*' );
+ if ( paramsLst.size() >= nNormalParams ) {
+ // 'reading' list of parameters
+ pos[0] = paramsLst[0].toDouble();
+ pos[1] = paramsLst[1].toDouble();
+ pos[2] = paramsLst[2].toDouble();
+ focalPnt[0] = paramsLst[3].toDouble();
+ focalPnt[1] = paramsLst[4].toDouble();
+ focalPnt[2] = paramsLst[5].toDouble();
+ viewUp[0] = paramsLst[6].toDouble();
+ viewUp[1] = paramsLst[7].toDouble();
+ viewUp[2] = paramsLst[8].toDouble();
+ parScale = paramsLst[9].toDouble();
+ scale[0] = paramsLst[10].toDouble();
+ scale[1] = paramsLst[11].toDouble();
+ scale[2] = paramsLst[12].toDouble();
+
+ // applying parameters
+ vtkCamera* camera = getRenderer()->GetActiveCamera();
+ camera->SetPosition( pos );
+ camera->SetFocalPoint( focalPnt );
+ camera->SetViewUp( viewUp );
+ camera->SetParallelScale( parScale );
+ SetScale( scale );
- int i = nNormalParams+1, j = i + nGradAxisParams - 1;
- ::setGradAxisVisualParams( gradAxesActor->GetXAxisActor2D(), parameters.section( '*', i, j ) );
- i = j + 1; j += nGradAxisParams;
- ::setGradAxisVisualParams( gradAxesActor->GetYAxisActor2D(), parameters.section( '*', i, j ) );
- i = j + 1; j += nGradAxisParams;
- ::setGradAxisVisualParams( gradAxesActor->GetZAxisActor2D(), parameters.section( '*', i, j ) );
-
- if ( paramsLst[13].toUShort() )
- gradAxesActor->VisibilityOn();
- else
- gradAxesActor->VisibilityOff();
+ // apply graduated axes parameters
+ SVTK_CubeAxesActor2D* gradAxesActor = GetCubeAxes();
+ if ( gradAxesActor && paramsLst.size() == nAllParams ) {
+
+ int i = nNormalParams+1, j = i + nGradAxisParams - 1;
+ ::setGradAxisVisualParams( gradAxesActor->GetXAxisActor2D(), parameters.section( '*', i, j ) );
+ i = j + 1; j += nGradAxisParams;
+ ::setGradAxisVisualParams( gradAxesActor->GetYAxisActor2D(), parameters.section( '*', i, j ) );
+ i = j + 1; j += nGradAxisParams;
+ ::setGradAxisVisualParams( gradAxesActor->GetZAxisActor2D(), parameters.section( '*', i, j ) );
+
+ if ( paramsLst[13].toUShort() )
+ gradAxesActor->VisibilityOn();
+ else
+ gradAxesActor->VisibilityOff();
+ }
}
}
}
}
return SUIT_ViewWindow::eventFilter( theWatched, theEvent );
}
+
+
+/*!
+ Change rotation point
+*/
+void SVTK_ViewWindow::onChangeRotationPoint(bool theIsActivate)
+{
+ if(theIsActivate){
+ mySetRotationPointDlg->addObserver();
+ if ( mySetRotationPointDlg->IsFirstShown() )
+ activateSetRotationGravity();
+ mySetRotationPointDlg->show();
+ }else
+ mySetRotationPointDlg->hide();
+}
+
+/*!
+ Set the gravity center as a rotation point
+*/
+void SVTK_ViewWindow::activateSetRotationGravity()
+{
+ myEventDispatcher->InvokeEvent(SVTK::SetRotateGravity,0);
+}
+
+/*!
+ Set the selected point as a rotation point
+*/
+void SVTK_ViewWindow::activateSetRotationSelected(void* theData)
+{
+ myEventDispatcher->InvokeEvent(SVTK::ChangeRotationPoint,theData);
+}
+
+/*!
+ Set the point selected by user as a rotation point
+*/
+void SVTK_ViewWindow::activateStartPointSelection()
+{
+ myEventDispatcher->InvokeEvent(SVTK::StartPointSelection,0);
+}
+
+/*!
+ Set the view projection mode: orthogonal or perspective
+*/
+void SVTK_ViewWindow::onProjectionMode(int mode)
+{
+ vtkCamera* aCamera = getRenderer()->GetActiveCamera();
+ aCamera->SetParallelProjection(mode==0);
+ GetInteractor()->GetDevice()->CreateTimer(VTKI_TIMER_FIRST);
+}
+
+void SVTK_ViewWindow::SetEventDispatcher(vtkObject* theDispatcher)
+{
+ myEventDispatcher = theDispatcher;
+}
+
+/*!
+ Creates all actions of svtk main window
+*/
+void SVTK_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr)
+{
+ QtxAction* anAction;
+ QtxActionToolMgr* mgr = toolMgr();
+
+ // Dump view
+ anAction = new QtxAction(tr("MNU_DUMP_VIEW"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_DUMP" ) ),
+ tr( "MNU_DUMP_VIEW" ), 0, this);
+ anAction->setStatusTip(tr("DSC_DUMP_VIEW"));
+ connect(anAction, SIGNAL(activated()), this, SLOT(onDumpView()));
+ mgr->registerAction( anAction, DumpId );
+
+ // FitAll
+ anAction = new QtxAction(tr("MNU_FITALL"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITALL" ) ),
+ tr( "MNU_FITALL" ), 0, this);
+ anAction->setStatusTip(tr("DSC_FITALL"));
+ connect(anAction, SIGNAL(activated()), this, SLOT(onFitAll()));
+ mgr->registerAction( anAction, FitAllId );
+
+ // FitRect
+ anAction = new QtxAction(tr("MNU_FITRECT"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FITAREA" ) ),
+ tr( "MNU_FITRECT" ), 0, this);
+ anAction->setStatusTip(tr("DSC_FITRECT"));
+ connect(anAction, SIGNAL(activated()), this, SLOT(activateWindowFit()));
+ mgr->registerAction( anAction, FitRectId );
+
+ // Zoom
+ anAction = new QtxAction(tr("MNU_ZOOM_VIEW"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ZOOM" ) ),
+ tr( "MNU_ZOOM_VIEW" ), 0, this);
+ anAction->setStatusTip(tr("DSC_ZOOM_VIEW"));
+ connect(anAction, SIGNAL(activated()), this, SLOT(activateZoom()));
+ mgr->registerAction( anAction, ZoomId );
+
+ // Panning
+ anAction = new QtxAction(tr("MNU_PAN_VIEW"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_PAN" ) ),
+ tr( "MNU_PAN_VIEW" ), 0, this);
+ anAction->setStatusTip(tr("DSC_PAN_VIEW"));
+ connect(anAction, SIGNAL(activated()), this, SLOT(activatePanning()));
+ mgr->registerAction( anAction, PanId );
+
+ // Global Panning
+ anAction = new QtxAction(tr("MNU_GLOBALPAN_VIEW"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_GLOBALPAN" ) ),
+ tr( "MNU_GLOBALPAN_VIEW" ), 0, this);
+ anAction->setStatusTip(tr("DSC_GLOBALPAN_VIEW"));
+ connect(anAction, SIGNAL(activated()), this, SLOT(activateGlobalPanning()));
+ mgr->registerAction( anAction, GlobalPanId );
+
+ // Change rotation point
+ anAction = new QtxAction(tr("MNU_CHANGINGROTATIONPOINT_VIEW"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_ROTATION_POINT" ) ),
+ tr( "MNU_CHANGINGROTATIONPOINT_VIEW" ), 0, this);
+ anAction->setStatusTip(tr("DSC_CHANGINGROTATIONPOINT_VIEW"));
+ anAction->setCheckable(true);
+ connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onChangeRotationPoint(bool)));
+ mgr->registerAction( anAction, ChangeRotationPointId );
+
+ // Rotation
+ anAction = new QtxAction(tr("MNU_ROTATE_VIEW"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_ROTATE" ) ),
+ tr( "MNU_ROTATE_VIEW" ), 0, this);
+ anAction->setStatusTip(tr("DSC_ROTATE_VIEW"));
+ connect(anAction, SIGNAL(activated()), this, SLOT(activateRotation()));
+ mgr->registerAction( anAction, RotationId );
+
+ // Projections
+ anAction = new QtxAction(tr("MNU_FRONT_VIEW"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_FRONT" ) ),
+ tr( "MNU_FRONT_VIEW" ), 0, this);
+ anAction->setStatusTip(tr("DSC_FRONT_VIEW"));
+ connect(anAction, SIGNAL(activated()), this, SLOT(onFrontView()));
+ mgr->registerAction( anAction, FrontId );
+
+ anAction = new QtxAction(tr("MNU_BACK_VIEW"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BACK" ) ),
+ tr( "MNU_BACK_VIEW" ), 0, this);
+ anAction->setStatusTip(tr("DSC_BACK_VIEW"));
+ connect(anAction, SIGNAL(activated()), this, SLOT(onBackView()));
+ mgr->registerAction( anAction, BackId );
+
+ anAction = new QtxAction(tr("MNU_TOP_VIEW"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TOP" ) ),
+ tr( "MNU_TOP_VIEW" ), 0, this);
+ anAction->setStatusTip(tr("DSC_TOP_VIEW"));
+ connect(anAction, SIGNAL(activated()), this, SLOT(onTopView()));
+ mgr->registerAction( anAction, TopId );
+
+ anAction = new QtxAction(tr("MNU_BOTTOM_VIEW"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_BOTTOM" ) ),
+ tr( "MNU_BOTTOM_VIEW" ), 0, this);
+ anAction->setStatusTip(tr("DSC_BOTTOM_VIEW"));
+ connect(anAction, SIGNAL(activated()), this, SLOT(onBottomView()));
+ mgr->registerAction( anAction, BottomId );
+
+ anAction = new QtxAction(tr("MNU_LEFT_VIEW"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_LEFT" ) ),
+ tr( "MNU_LEFT_VIEW" ), 0, this);
+ anAction->setStatusTip(tr("DSC_LEFT_VIEW"));
+ connect(anAction, SIGNAL(activated()), this, SLOT(onLeftView()));
+ mgr->registerAction( anAction, LeftId );
+
+ anAction = new QtxAction(tr("MNU_RIGHT_VIEW"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RIGHT" ) ),
+ tr( "MNU_RIGHT_VIEW" ), 0, this);
+ anAction->setStatusTip(tr("DSC_RIGHT_VIEW"));
+ connect(anAction, SIGNAL(activated()), this, SLOT(onRightView()));
+ mgr->registerAction( anAction, RightId );
+
+ // Reset
+ anAction = new QtxAction(tr("MNU_RESET_VIEW"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_RESET" ) ),
+ tr( "MNU_RESET_VIEW" ), 0, this);
+ anAction->setStatusTip(tr("DSC_RESET_VIEW"));
+ connect(anAction, SIGNAL(activated()), this, SLOT(onResetView()));
+ mgr->registerAction( anAction, ResetId );
+
+ // onViewTrihedron: Shows - Hides Trihedron
+ anAction = new QtxAction(tr("MNU_SHOW_TRIHEDRON"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_VTKVIEWER_VIEW_TRIHEDRON" ) ),
+ tr( "MNU_SHOW_TRIHEDRON" ), 0, this);
+ anAction->setStatusTip(tr("DSC_SHOW_TRIHEDRON"));
+ connect(anAction, SIGNAL(activated()), this, SLOT(onViewTrihedron()));
+ mgr->registerAction( anAction, ViewTrihedronId );
+
+ // onNonIsometric: Manage non-isometric params
+ anAction = new QtxAction(tr("MNU_SVTK_SCALING"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_SCALING" ) ),
+ tr( "MNU_SVTK_SCALING" ), 0, this);
+ anAction->setStatusTip(tr("DSC_SVTK_SCALING"));
+ anAction->setCheckable(true);
+ connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onNonIsometric(bool)));
+ mgr->registerAction( anAction, NonIsometric );
+
+ // onGraduatedAxes: Manage graduated axes params
+ anAction = new QtxAction(tr("MNU_SVTK_GRADUATED_AXES"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_GRADUATED_AXES" ) ),
+ tr( "MNU_SVTK_GRADUATED_AXES" ), 0, this);
+ anAction->setStatusTip(tr("DSC_SVTK_GRADUATED_AXES"));
+ anAction->setCheckable(true);
+ connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onGraduatedAxes(bool)));
+ mgr->registerAction( anAction, GraduatedAxes );
+
+ // onGraduatedAxes: Manage graduated axes params
+ anAction = new QtxAction(tr("MNU_SVTK_UPDATE_RATE"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_UPDATE_RATE" ) ),
+ tr( "MNU_SVTK_UPDATE_RATE" ), 0, this);
+ anAction->setStatusTip(tr("DSC_SVTK_UPDATE_RATE"));
+ anAction->setCheckable(true);
+ connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onUpdateRate(bool)));
+ mgr->registerAction( anAction, UpdateRate );
+
+ // Set projection mode
+ SVTK_ComboAction* aModeAction = new SVTK_ComboAction(tr("MNU_SVTK_PROJECTION_MODE"), this);
+ aModeAction->setStatusTip(tr("DSC_SVTK_PROJECTION_MODE"));
+ aModeAction->insertItem(theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_PARALLEL" ) ) );
+ aModeAction->insertItem(theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_PERSPECTIVE" ) ) );
+ connect(aModeAction, SIGNAL(triggered(int)), this, SLOT(onProjectionMode(int)));
+ mgr->registerAction( aModeAction, ProjectionModeId );
+
+ // View Parameters
+ anAction = new QtxAction(tr("MNU_VIEWPARAMETERS_VIEW"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_VIEW_PARAMETERS" ) ),
+ tr( "MNU_VIEWPARAMETERS_VIEW" ), 0, this);
+ anAction->setStatusTip(tr("DSC_VIEWPARAMETERS_VIEW"));
+ anAction->setCheckable(true);
+ connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onViewParameters(bool)));
+ mgr->registerAction( anAction, ViewParametersId );
+
+ // Switch between interaction styles
+ anAction = new QtxAction(tr("MNU_SVTK_STYLE_SWITCH"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_STYLE_SWITCH" ) ),
+ tr( "MNU_SVTK_STYLE_SWITCH" ), 0, this);
+ anAction->setStatusTip(tr("DSC_SVTK_STYLE_SWITCH"));
+ anAction->setCheckable(true);
+ connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchInteractionStyle(bool)));
+ mgr->registerAction( anAction, SwitchInteractionStyleId );
+
+ // Start recording
+ myStartAction = new QtxAction(tr("MNU_SVTK_RECORDING_START"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_START" ) ),
+ tr( "MNU_SVTK_RECORDING_START" ), 0, this);
+ myStartAction->setStatusTip(tr("DSC_SVTK_RECORDING_START"));
+ connect( myStartAction, SIGNAL( triggered ( bool ) ), this, SLOT( onStartRecording() ) );
+ mgr->registerAction( myStartAction, StartRecordingId );
+
+ // Play recording
+ myPlayAction = new QtxAction(tr("MNU_SVTK_RECORDING_PLAY"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_PLAY" ) ),
+ tr( "MNU_SVTK_RECORDING_PLAY" ), 0, this);
+ myPlayAction->setStatusTip(tr("DSC_SVTK_RECORDING_PLAY"));
+ myPlayAction->setEnabled( false );
+ connect( myPlayAction, SIGNAL( triggered ( bool ) ), this, SLOT( onPlayRecording() ) );
+ mgr->registerAction( myPlayAction, PlayRecordingId );
+
+ // Pause recording
+ myPauseAction = new QtxAction(tr("MNU_SVTK_RECORDING_PAUSE"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_PAUSE" ) ),
+ tr( "MNU_SVTK_RECORDING_PAUSE" ), 0, this);
+ myPauseAction->setStatusTip(tr("DSC_SVTK_RECORDING_PAUSE"));
+ myPauseAction->setEnabled( false );
+ connect( myPauseAction, SIGNAL( triggered ( bool ) ), this, SLOT( onPauseRecording() ) );
+ mgr->registerAction( myPauseAction, PauseRecordingId );
+
+ // Stop recording
+ myStopAction = new QtxAction(tr("MNU_SVTK_RECORDING_STOP"),
+ theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_STOP" ) ),
+ tr( "MNU_SVTK_RECORDING_STOP" ), 0, this);
+ myStopAction->setStatusTip(tr("DSC_SVTK_RECORDING_STOP"));
+ myStopAction->setEnabled( false );
+ connect( myStopAction, SIGNAL( triggered ( bool ) ), this, SLOT( onStopRecording() ) );
+ mgr->registerAction( myStopAction, StopRecordingId );
+}
+
+/*!
+ Creates toolbar of svtk main window
+*/
+void SVTK_ViewWindow::createToolBar()
+{
+ QtxActionToolMgr* mgr = toolMgr();
+
+ mgr->append( DumpId, myToolBar );
+ mgr->append( SwitchInteractionStyleId, myToolBar );
+ mgr->append( ViewTrihedronId, myToolBar );
+
+ QtxMultiAction* aScaleAction = new QtxMultiAction( this );
+ aScaleAction->insertAction( getAction( FitAllId ) );
+ aScaleAction->insertAction( getAction( FitRectId ) );
+ aScaleAction->insertAction( getAction( ZoomId ) );
+ mgr->append( aScaleAction, myToolBar );
+
+ QtxMultiAction* aPanningAction = new QtxMultiAction( this );
+ aPanningAction->insertAction( getAction( PanId ) );
+ aPanningAction->insertAction( getAction( GlobalPanId ) );
+ mgr->append( aPanningAction, myToolBar );
+
+ mgr->append( ChangeRotationPointId, myToolBar );
+
+ mgr->append( RotationId, myToolBar );
+
+ QtxMultiAction* aViewsAction = new QtxMultiAction( this );
+ aViewsAction->insertAction( getAction( FrontId ) );
+ aViewsAction->insertAction( getAction( BackId ) );
+ aViewsAction->insertAction( getAction( TopId ) );
+ aViewsAction->insertAction( getAction( BottomId ) );
+ aViewsAction->insertAction( getAction( LeftId ) );
+ aViewsAction->insertAction( getAction( RightId ) );
+ mgr->append( aViewsAction, myToolBar );
+
+ mgr->append( ResetId, myToolBar );
+
+ mgr->append( UpdateRate, myToolBar );
+ mgr->append( NonIsometric, myToolBar );
+ mgr->append( GraduatedAxes, myToolBar );
+
+ mgr->append( ViewParametersId, myToolBar );
+ mgr->append( ProjectionModeId, myToolBar );
+
+ mgr->append( StartRecordingId, myRecordingToolBar );
+ mgr->append( PlayRecordingId, myRecordingToolBar );
+ mgr->append( PauseRecordingId, myRecordingToolBar );
+ mgr->append( StopRecordingId, myRecordingToolBar );
+}
+
+void SVTK_ViewWindow::onUpdateRate(bool theIsActivate)
+{
+ if(theIsActivate){
+ myUpdateRateDlg->Update();
+ myUpdateRateDlg->show();
+ }else
+ myUpdateRateDlg->hide();
+}
+
+void SVTK_ViewWindow::onNonIsometric(bool theIsActivate)
+{
+ if(theIsActivate){
+ myNonIsometricDlg->Update();
+ myNonIsometricDlg->show();
+ }else
+ myNonIsometricDlg->hide();
+}
+
+void SVTK_ViewWindow::onGraduatedAxes(bool theIsActivate)
+{
+ if(theIsActivate){
+ myCubeAxesDlg->Update();
+ myCubeAxesDlg->show();
+ }else
+ myCubeAxesDlg->hide();
+}
+
+/*!
+ Starts rotation transformation
+*/
+void SVTK_ViewWindow::activateRotation()
+{
+ myEventDispatcher->InvokeEvent(SVTK::StartRotate,0);
+}
+
+
+/*!
+ Starts panning transformation
+*/
+void SVTK_ViewWindow::activatePanning()
+{
+ myEventDispatcher->InvokeEvent(SVTK::StartPan,0);
+}
+
+/*!
+ Starts zoom transformation
+*/
+void SVTK_ViewWindow::activateZoom()
+{
+ myEventDispatcher->InvokeEvent(SVTK::StartZoom,0);
+}
+
+/*!
+ Starts window fit transformation
+*/
+void SVTK_ViewWindow::activateWindowFit()
+{
+ myEventDispatcher->InvokeEvent(SVTK::StartFitArea,0);
+}
+
+/*!
+ Starts global panning transformation
+*/
+void SVTK_ViewWindow::activateGlobalPanning()
+{
+ myEventDispatcher->InvokeEvent(SVTK::StartGlobalPan,0);
+}
+
+void SVTK_ViewWindow::onStartRecording()
+{
+ myRecorder->CheckExistAVIMaker();
+ if (myRecorder->ErrorStatus()) {
+ SUIT_MessageBox::warning(this, tr("ERROR"), tr("MSG_NO_AVI_MAKER") );
+ }
+ else {
+ SVTK_RecorderDlg* aRecorderDlg = new SVTK_RecorderDlg( this, myRecorder );
+
+ if( !aRecorderDlg->exec() )
+ return;
+
+ myStartAction->setEnabled( false );
+ myPlayAction->setEnabled( false );
+ myPauseAction->setEnabled( true );
+ myStopAction->setEnabled( true );
+
+ // to prevent resizing the window while recording
+ myPreRecordingMinSize = minimumSize();
+ myPreRecordingMaxSize = maximumSize();
+ setFixedSize( size() );
+
+ myRecorder->Record();
+ }
+}
+
+void SVTK_ViewWindow::onPlayRecording()
+{
+ myStartAction->setEnabled( false );
+ myPlayAction->setEnabled( false );
+ myPauseAction->setEnabled( true );
+ myStopAction->setEnabled( true );
+
+ myRecorder->Pause();
+}
+
+void SVTK_ViewWindow::onPauseRecording()
+{
+ myStartAction->setEnabled( false );
+ myPlayAction->setEnabled( true );
+ myPauseAction->setEnabled( false );
+ myStopAction->setEnabled( true );
+
+ myRecorder->Pause();
+}
+
+void SVTK_ViewWindow::onStopRecording()
+{
+ myStartAction->setEnabled( true );
+ myPlayAction->setEnabled( false );
+ myPauseAction->setEnabled( false );
+ myStopAction->setEnabled( false );
+
+ myRecorder->Stop();
+
+ setMinimumSize( myPreRecordingMinSize );
+ setMaximumSize( myPreRecordingMaxSize );
+}
+
+/*!
+ To invoke a VTK event on SVTK_RenderWindowInteractor instance
+*/
+void SVTK_ViewWindow::InvokeEvent(unsigned long theEvent, void* theCallData)
+{
+ GetInteractor()->InvokeEvent(theEvent,theCallData);
+}
+
+/*!
+ Modify view parameters
+*/
+void SVTK_ViewWindow::onViewParameters(bool theIsActivate)
+{
+ if(theIsActivate){
+ myViewParameterDlg->addObserver();
+ myViewParameterDlg->show();
+ }else
+ myViewParameterDlg->hide();
+}
+
+/*!
+ Custom show event handler
+*/
+void SVTK_ViewWindow::showEvent( QShowEvent * theEvent )
+{
+ emit Show( theEvent );
+}
+
+/*!
+ Custom hide event handler
+*/
+void SVTK_ViewWindow::hideEvent( QHideEvent * theEvent )
+{
+ emit Hide( theEvent );
+}
+
#include "SALOME_InteractiveObject.hxx"
#include <QImage>
+#include <vtkSmartPointer.h>
class SUIT_Desktop;
+class SUIT_ResourceMgr;
class VTKViewer_Actor;
class VTKViewer_Trihedron;
class SVTK_ViewModelBase;
-class SVTK_MainWindow;
+//class SVTK_MainWindow;
class SVTK_Selector;
class SVTK_View;
class vtkRenderer;
class vtkRenderWindow;
class vtkRenderWindowInteractor;
+class vtkInteractorStyle;
+class SVTK_RenderWindowInteractor;
+class SVTK_Renderer;
+class SVTK_NonIsometricDlg;
+class SVTK_UpdateRateDlg;
+class SVTK_CubeAxesDlg;
+class SVTK_SetRotationPointDlg;
+class SVTK_KeyFreeInteractorStyle;
+class SVTK_ViewParameterDlg;
+class SVTK_Recorder;
+
+class vtkObject;
+class QtxAction;
namespace SVTK
{
//! To construct #SVTK_ViewWindow instance
SVTK_ViewWindow(SUIT_Desktop* theDesktop);
- virtual
- ~SVTK_ViewWindow();
+ virtual ~SVTK_ViewWindow();
virtual QImage dumpView();
//! To initialize #SVTK_ViewWindow instance
- virtual
- void
- Initialize(SVTK_ViewModelBase* theModel);
+ virtual void Initialize(SVTK_ViewModelBase* theModel);
//! Get #SVTK_View
- SVTK_View*
- getView();
+ SVTK_View* getView();
//! Get #SVTK_MainWindow
- SVTK_MainWindow*
- getMainWindow();
+ //SVTK_MainWindow* getMainWindow();
//! Redirect the request to #SVTK_MainWindow::getRenderWindow
- vtkRenderWindow*
- getRenderWindow();
+ vtkRenderWindow* getRenderWindow();
//! Redirect the request to #SVTK_MainWindow::getInteractor
- vtkRenderWindowInteractor*
- getInteractor();
+ vtkRenderWindowInteractor* getInteractor() const;
+
+ //! Redirect the request to #SVTK_MainWindow::getInteractor
+ SVTK_RenderWindowInteractor* GetInteractor() const;
+
+ vtkInteractorStyle* GetInteractorStyle() const;
+
+ //! Redirect the request to #SVTK_RenderWindowInteractor::PushInteractorStyle
+ void PushInteractorStyle(vtkInteractorStyle* theStyle);
+
+ //! Redirect the request to #SVTK_RenderWindowInteractor::PopInteractorStyle
+ void PopInteractorStyle();
//! Redirect the request to #SVTK_MainWindow::getRenderer
- vtkRenderer*
- getRenderer();
+ vtkRenderer* getRenderer() const;
+
+ SVTK_Renderer* GetRenderer() const;
//! Redirect the request to #SVTK_MainWindow::GetSelector
- SVTK_Selector*
- GetSelector();
+ SVTK_Selector* GetSelector() const;
//! Redirect the request to #SVTK_Selector::SelectionMode
- Selection_Mode
- SelectionMode() const;
+ Selection_Mode SelectionMode() const;
//! Change selection mode
- virtual
- void
- SetSelectionMode(Selection_Mode theMode);
+ virtual void SetSelectionMode(Selection_Mode theMode);
//! Redirect the request to #SVTK_MainWindow::SetBackgroundColor
- virtual
- void
- setBackgroundColor( const QColor& );
+ virtual void setBackgroundColor( const QColor& );
//! Redirect the request to #SVTK_MainWindow::SetBackgroundColor
- QColor
- backgroundColor() const;
+ QColor backgroundColor() const;
//! Redirect the request to #SVTK_Renderer::IsTrihedronDisplayed
- bool
- isTrihedronDisplayed();
+ bool isTrihedronDisplayed();
//! Redirect the request to #SVTK_Renderer::IsCubeAxesDisplayed
- bool
- isCubeAxesDisplayed();
+ bool isCubeAxesDisplayed();
/* interactive object management */
//! Redirect the request to #SVTK_View::highlight (to support old code)
- virtual
- void
- highlight(const Handle(SALOME_InteractiveObject)& theIO,
- bool theIsHighlight = true,
- bool theIsUpdate = true);
+ virtual void highlight(const Handle(SALOME_InteractiveObject)& theIO,
+ bool theIsHighlight = true,
+ bool theIsUpdate = true);
//! Redirect the request to #SVTK_View::unHighlightAll (to support old code)
- virtual
- void
- unHighlightAll();
+ virtual void unHighlightAll();
//! Redirect the request to #SVTK_View::isInViewer (to support old code)
- bool
- isInViewer(const Handle(SALOME_InteractiveObject)& theIObject);
+ bool isInViewer(const Handle(SALOME_InteractiveObject)& theIObject);
//! Redirect the request to #SVTK_View::isVisible (to support old code)
- bool
- isVisible(const Handle(SALOME_InteractiveObject)& theIObject);
+ bool isVisible(const Handle(SALOME_InteractiveObject)& theIObject);
//! Redirect the request to #SVTK_View::FindIObject (to support old code)
//----------------------------------------------------------------------------
- Handle(SALOME_InteractiveObject)
- FindIObject(const char* theEntry);
+ Handle(SALOME_InteractiveObject) FindIObject(const char* theEntry);
/* display */
//----------------------------------------------------------------------------
//! Redirect the request to #SVTK_View::Display (to support old code)
- virtual
- void
- Display(const Handle(SALOME_InteractiveObject)& theIObject,
- bool theImmediatly = true);
+ virtual void Display(const Handle(SALOME_InteractiveObject)& theIObject,
+ bool theImmediatly = true);
//! Redirect the request to #SVTK_View::DisplayOnly (to support old code)
- virtual
- void
- DisplayOnly(const Handle(SALOME_InteractiveObject)& theIObject);
+ virtual void DisplayOnly(const Handle(SALOME_InteractiveObject)& theIObject);
//! Redirect the request to #SVTK_View::Erase (to support old code)
- virtual
- void
- Erase(const Handle(SALOME_InteractiveObject)& theIObject,
- bool theImmediatly = true);
+ virtual void Erase(const Handle(SALOME_InteractiveObject)& theIObject,
+ bool theImmediatly = true);
//! Redirect the request to #SVTK_View::DisplayAll (to support old code)
- virtual
- void
- DisplayAll();
+ virtual void DisplayAll();
//! Redirect the request to #SVTK_View::EraseAll (to support old code)
- virtual
- void
- EraseAll();
+ virtual void EraseAll();
//! To repaint the viewer
- virtual
- void
- Repaint(bool theUpdateTrihedron = true);
+ virtual void Repaint(bool theUpdateTrihedron = true);
//----------------------------------------------------------------------------
//! Redirect the request to #SVTK_Renderer::SetScale
- virtual
- void
- SetScale( double theScale[3] );
+ virtual void SetScale( double theScale[3] );
//! Redirect the request to #SVTK_Renderer::GetScale
- virtual
- void
- GetScale( double theScale[3] );
+ virtual void GetScale( double theScale[3] );
//! Redirect the request to #SVTK_Renderer::AddActor
- virtual
- void
- AddActor(VTKViewer_Actor* theActor,
- bool theIsUpdate = false);
+ virtual void AddActor(VTKViewer_Actor* theActor,
+ bool theIsUpdate = false);
//! Redirect the request to #SVTK_Renderer::RemoveActor
- virtual
- void
- RemoveActor(VTKViewer_Actor* theActor,
- bool theIsUpdate = false);
+ virtual void RemoveActor(VTKViewer_Actor* theActor,
+ bool theIsUpdate = false);
//----------------------------------------------------------------------------
//! Redirect the request to #SVTK_Renderer::AdjustActors
- virtual
- void
- AdjustTrihedrons(const bool theIsForced);
+ virtual void AdjustTrihedrons(const bool theIsForced);
//! Redirect the request to #SVTK_Renderer::GetTrihedron
- VTKViewer_Trihedron*
- GetTrihedron();
+ VTKViewer_Trihedron* GetTrihedron();
//! Redirect the request to #SVTK_Renderer::GetCubeAxes
- SVTK_CubeAxesActor2D*
- GetCubeAxes();
+ SVTK_CubeAxesActor2D* GetCubeAxes();
//! Redirect the request to #SVTK_Renderer::GetTrihedronSize
- vtkFloatingPointType
- GetTrihedronSize() const;
+ vtkFloatingPointType GetTrihedronSize() const;
//! Redirect the request to #SVTK_Renderer::SetTrihedronSize
- virtual
- void
- SetTrihedronSize( const vtkFloatingPointType, const bool = true );
+ virtual void SetTrihedronSize( const vtkFloatingPointType, const bool = true );
+
+ //! Redirect the request to #SVTK_MainWindow::SetIncrementalSpeed
+ virtual void SetIncrementalSpeed( const int, const int = 0 );
+
+ //! Redirect the request to #SVTK_MainWindow::SetProjectionMode
+ virtual void SetProjectionMode( const int );
+
+ //! Redirect the request to #SVTK_MainWindow::SetInteractionStyle
+ virtual void SetInteractionStyle( const int );
+
+ //! Redirect the request to #SVTK_MainWindow::SetSpacemouseButtons
+ virtual void SetSpacemouseButtons( const int, const int, const int );
//! Redirect the request to #SVTK_Renderer::SetSelectionProp
- virtual
- void
- SetSelectionProp(const double& theRed = 1,
- const double& theGreen = 1,
- const double& theBlue = 0,
- const int& theWidth = 5);
+ virtual void SetSelectionProp(const double& theRed = 1,
+ const double& theGreen = 1,
+ const double& theBlue = 0,
+ const int& theWidth = 5);
//! Redirect the request to #SVTK_Renderer::SetPreselectionProp
- virtual
- void
- SetPreselectionProp(const double& theRed = 0,
- const double& theGreen = 1,
- const double& theBlue = 1,
- const int& theWidth = 5);
+ virtual void SetPreselectionProp(const double& theRed = 0,
+ const double& theGreen = 1,
+ const double& theBlue = 1,
+ const int& theWidth = 5);
//! Redirect the request to #SVTK_Renderer::SetSelectionTolerance
- virtual
- void
- SetSelectionTolerance(const double& theTolNodes = 0.025,
- const double& theTolCell = 0.001,
- const double& theTolObjects = 0.025);
+ virtual void SetSelectionTolerance(const double& theTolNodes = 0.025,
+ const double& theTolCell = 0.001,
+ const double& theTolObjects = 0.025);
//! Methods to save/restore visual parameters of a view (pan, zoom, etc.)
- virtual
- QString
- getVisualParameters();
+ virtual QString getVisualParameters();
- virtual
- void
- setVisualParameters( const QString& parameters );
+ virtual void setVisualParameters( const QString& parameters );
- virtual
- bool
- eventFilter( QObject*, QEvent* );
+ virtual bool eventFilter( QObject*, QEvent* );
- virtual
- void RefreshDumpImage();
+ virtual void RefreshDumpImage();
+
+ //! To invoke a VTK event on #SVTK_RenderWindowInteractor instance
+ void InvokeEvent(unsigned long theEvent, void* theCallData);
+ signals:
+ void Show( QShowEvent * );
+ void Hide( QHideEvent * );
+
public slots:
- virtual
- void
- onSelectionChanged();
+ virtual void showEvent( QShowEvent * );
+ virtual void hideEvent( QHideEvent * );
+ virtual void onSelectionChanged();
+
+ void onChangeRotationPoint(bool theIsActivate);
+
+ void activateSetRotationGravity();
+ void activateSetRotationSelected(void* theData);
+ void activateStartPointSelection();
+
+ void onUpdateRate(bool theIsActivate);
+ void onNonIsometric(bool theIsActivate);
+ void onGraduatedAxes(bool theIsActivate);
+
+ void activateZoom();
+ void activateWindowFit();
+ void activateRotation();
+ void activatePanning();
+ void activateGlobalPanning();
+
+ void onProjectionMode(int mode);
+
+ void activateProjectionMode(int);
+
+ void activateSetFocalPointGravity();
+ void activateSetFocalPointSelected();
+ void activateStartFocalPointSelection();
+
+ void onViewParameters(bool theIsActivate);
+
+ void onSwitchInteractionStyle(bool theOn);
+
+ void onStartRecording();
+ void onPlayRecording();
+ void onPauseRecording();
+ void onStopRecording();
signals:
void selectionChanged();
+ void actorAdded(VTKViewer_Actor*);
+ void actorRemoved(VTKViewer_Actor*);
public slots:
//! Redirect the request to #SVTK_Renderer::OnFrontView
- virtual
- void
- onFrontView();
+ virtual void onFrontView();
//! Redirect the request to #SVTK_Renderer::OnBackView
- virtual
- void
- onBackView();
+ virtual void onBackView();
//! Redirect the request to #SVTK_Renderer::OnTopView
- virtual
- void
- onTopView();
+ virtual void onTopView();
//! Redirect the request to #SVTK_Renderer::OnBottomView
- virtual
- void
- onBottomView();
+ virtual void onBottomView();
//! Redirect the request to #SVTK_Renderer::OnRightView
- virtual
- void
- onRightView();
+ virtual void onRightView();
//! Redirect the request to #SVTK_Renderer::OnLeftView
- virtual
- void
- onLeftView();
+ virtual void onLeftView();
//! Redirect the request to #SVTK_Renderer::OnResetView
- virtual
- void
- onResetView();
+ virtual void onResetView();
//! Redirect the request to #SVTK_Renderer::OnFitAll
- virtual
- void
- onFitAll();
+ virtual void onFitAll();
//! Redirect the request to #SVTK_Renderer::OnViewTrihedron
- virtual
- void
- onViewTrihedron();
+ virtual void onViewTrihedron();
//! Redirect the request to #SVTK_Renderer::OnViewCubeAxes
- virtual
- void
- onViewCubeAxes();
+ virtual void onViewCubeAxes();
//! Redirect the request to #SVTK_Renderer::OnAdjustTrihedron
- virtual
- void
- onAdjustTrihedron();
+ virtual void onAdjustTrihedron();
//! Redirect the request to #SVTK_Renderer::OnAdjustCubeAxes
- virtual
- void
- onAdjustCubeAxes();
+ virtual void onAdjustCubeAxes();
protected slots:
void onKeyPressed(QKeyEvent* event);
void onMouseMoving(QMouseEvent* event);
protected:
- virtual
- void
- Initialize(SVTK_View* theView,
- SVTK_ViewModelBase* theModel);
+ virtual void Initialize(SVTK_View* theView,
+ SVTK_ViewModelBase* theModel);
- void
- doSetVisualParameters( const QString& );
+ void doSetVisualParameters( const QString& );
+ void SetEventDispatcher(vtkObject* theDispatcher);
virtual QString filter() const;
virtual bool dumpViewToFormat( const QImage& img, const QString& fileName, const QString& format );
virtual bool action( const int );
+ QtxAction* getAction( int ) const;
+ void createToolBar();
+ void createActions(SUIT_ResourceMgr* theResourceMgr);
+
+ enum { DumpId, FitAllId, FitRectId, ZoomId, PanId, GlobalPanId,
+ ChangeRotationPointId, RotationId,
+ FrontId, BackId, TopId, BottomId, LeftId, RightId, ResetId,
+ ViewTrihedronId, NonIsometric, GraduatedAxes, UpdateRate,
+ ProjectionModeId, ViewParametersId, SwitchInteractionStyleId,
+ StartRecordingId, PlayRecordingId, PauseRecordingId, StopRecordingId };
+
+
SVTK_View* myView;
- SVTK_MainWindow* myMainWindow;
+ //SVTK_MainWindow* myMainWindow;
SVTK_ViewModelBase* myModel;
+ SVTK_RenderWindowInteractor* myInteractor;
+ vtkSmartPointer<SVTK_KeyFreeInteractorStyle> myKeyFreeInteractorStyle;
+
QString myVisualParams; // used for delayed setting of view parameters
+ vtkSmartPointer<vtkObject> myEventDispatcher;
+
+ SVTK_NonIsometricDlg* myNonIsometricDlg;
+ SVTK_UpdateRateDlg* myUpdateRateDlg;
+ SVTK_CubeAxesDlg* myCubeAxesDlg;
+ SVTK_SetRotationPointDlg* mySetRotationPointDlg;
+ SVTK_ViewParameterDlg* myViewParameterDlg;
+
+ QSize myPreRecordingMinSize;
+ QSize myPreRecordingMaxSize;
+
+ SVTK_Recorder* myRecorder;
+ QtxAction* myStartAction;
+ QtxAction* myPlayAction;
+ QtxAction* myPauseAction;
+ QtxAction* myStopAction;
+
+ int myToolBar;
+ int myRecordingToolBar;
+
private:
QImage myDumpImage;
};
<source>ICON_SVTK_UPDATE_RATE</source>
<translation>vtk_view_update_rate.png</translation>
</message>
+ <message>
+ <source>ICON_SVTK_VIEW_PARAMETERS</source>
+ <translation>vtk_view_parameters.png</translation>
+ </message>
+ <message>
+ <source>ICON_SVTK_VIEW_PARALLEL</source>
+ <translation>vtk_view_parallel.png</translation>
+ </message>
+ <message>
+ <source>ICON_SVTK_VIEW_PERSPECTIVE</source>
+ <translation>vtk_view_perspective.png</translation>
+ </message>
+ <message>
+ <source>ICON_SVTK_STYLE_SWITCH</source>
+ <translation>vtk_view_style_switch.png</translation>
+ </message>
+ <message>
+ <source>ICON_SVTK_RECORDING_START</source>
+ <translation>vtk_view_recording_start.png</translation>
+ </message>
+ <message>
+ <source>ICON_SVTK_RECORDING_PLAY</source>
+ <translation>vtk_view_recording_play.png</translation>
+ </message>
+ <message>
+ <source>ICON_SVTK_RECORDING_PAUSE</source>
+ <translation>vtk_view_recording_pause.png</translation>
+ </message>
+ <message>
+ <source>ICON_SVTK_RECORDING_STOP</source>
+ <translation>vtk_view_recording_stop.png</translation>
+ </message>
</context>
</TS>
<source>SVTK_IMAGE_FILES</source>
<translation>Images Files (*.bmp *.png *.jpg *.jpeg *.pdf *.ps *.eps)</translation>
</message>
+ <message>
+ <source>MNU_VIEWPARAMETERS_VIEW</source>
+ <translation>Change View Parameters</translation>
+ </message>
+ <message>
+ <source>DSC_VIEWPARAMETERS_VIEW</source>
+ <translation>Change the parameters of the view</translation>
+ </message>
+ <message>
+ <source>MNU_SVTK_PROJECTION_MODE</source>
+ <translation>Projection Mode</translation>
+ </message>
+ <message>
+ <source>DSC_SVTK_PROJECTION_MODE</source>
+ <translation>Set orthogonal or perspective projection of the view</translation>
+ </message>
+ <message>
+ <source>DSC_SVTK_STYLE_SWITCH</source>
+ <translation>Interactiion style switch</translation>
+ </message>
+ <message>
+ <source>MNU_SVTK_STYLE_SWITCH</source>
+ <translation>Interaction Style Switch</translation>
+ </message>
</context>
<context>
<name>SVTK_CubeAxesDlg</name>
</message>
</context>
<context>
- <name>SVTK_MainWindow</name>
+ <name>SVTK_ViewWindow</name>
<message>
<source>DSC_SVTK_UPDATE_RATE</source>
<translation>Update rate</translation>
<source>MNU_SVTK_UPDATE_RATE</source>
<translation>Update rate</translation>
</message>
+ <message>
+ <source>DSC_SVTK_RECORDING_START</source>
+ <translation>Start recording</translation>
+ </message>
+ <message>
+ <source>MNU_SVTK_RECORDING_START</source>
+ <translation>Start recording</translation>
+ </message>
+ <message>
+ <source>DSC_SVTK_RECORDING_PLAY</source>
+ <translation>Play recording</translation>
+ </message>
+ <message>
+ <source>MNU_SVTK_RECORDING_PLAY</source>
+ <translation>Play recording</translation>
+ </message>
+ <message>
+ <source>DSC_SVTK_RECORDING_PAUSE</source>
+ <translation>Pause recording</translation>
+ </message>
+ <message>
+ <source>MNU_SVTK_RECORDING_PAUSE</source>
+ <translation>Pause recording</translation>
+ </message>
+ <message>
+ <source>DSC_SVTK_RECORDING_STOP</source>
+ <translation>Stop recording</translation>
+ </message>
+ <message>
+ <source>MNU_SVTK_RECORDING_STOP</source>
+ <translation>Stop recording</translation>
+ </message>
+ <message>
+ <source>LBL_TOOLBAR_RECORD_LABEL</source>
+ <translation>Recording Operations</translation>
+ </message>
+ <message>
+ <source>MSG_NO_AVI_MAKER</source>
+ <translation>Tool jpeg2yuv, necessary for AVI recording, is not available.
+Please, refer to the documentation.</translation>
+ </message>
</context>
<context>
<name>SVTK_NonIsometricDlg</name>
<translation>Scaling</translation>
</message>
</context>
+<context>
+ <name>SVTK_RecorderDlg</name>
+ <message>
+ <source>ALL_DISLPAYED_FRAMES</source>
+ <translation>Recording all displayed frames</translation>
+ </message>
+ <message>
+ <source>CLOSE</source>
+ <translation>Close</translation>
+ </message>
+ <message>
+ <source>DLG_RECORDER_TITLE</source>
+ <translation>Recorder</translation>
+ </message>
+ <message>
+ <source>FILE_NAME</source>
+ <translation>Save to file : </translation>
+ </message>
+ <message>
+ <source>FLT_ALL_FILES</source>
+ <translation>All Files (*.*)</translation>
+ </message>
+ <message>
+ <source>FLT_AVI_FILES</source>
+ <translation>AVI Files (*.avi)</translation>
+ </message>
+ <message>
+ <source>FPS</source>
+ <translation>FPS : </translation>
+ </message>
+ <message>
+ <source>HELP</source>
+ <translation>Help</translation>
+ </message>
+ <message>
+ <source>PROGRESSIVE</source>
+ <translation>Progressive</translation>
+ </message>
+ <message>
+ <source>QUALITY</source>
+ <translation>Quality : </translation>
+ </message>
+ <message>
+ <source>RECORDING_MODE</source>
+ <translation>Mode : </translation>
+ </message>
+ <message>
+ <source>SETTINGS</source>
+ <translation>Settings</translation>
+ </message>
+ <message>
+ <source>SKIPPED_FRAMES</source>
+ <translation>Recording at a given FPS</translation>
+ </message>
+ <message>
+ <source>START</source>
+ <translation>Start</translation>
+ </message>
+</context>
<context>
<name>SVTK_SetRotationPointDlg</name>
<message>
<translation>Set Rotation Point</translation>
</message>
</context>
+<context>
+ <name>SVTK_ViewParameterDlg</name>
+ <message>
+ <source>LBL_X</source>
+ <translation>X :</translation>
+ </message>
+ <message>
+ <source>LBL_Y</source>
+ <translation>Y :</translation>
+ </message>
+ <message>
+ <source>LBL_Z</source>
+ <translation>Z :</translation>
+ </message>
+ <message>
+ <source>LBL_DX</source>
+ <translation>DX :</translation>
+ </message>
+ <message>
+ <source>LBL_DY</source>
+ <translation>DY :</translation>
+ </message>
+ <message>
+ <source>LBL_DZ</source>
+ <translation>DZ :</translation>
+ </message>
+ <message>
+ <source>PROJECTION_MODE</source>
+ <translation>Projection Mode</translation>
+ </message>
+ <message>
+ <source>ORTHOGONAL_MODE</source>
+ <translation>Orthogonal</translation>
+ </message>
+ <message>
+ <source>PERSPECTIVE_MODE</source>
+ <translation>Perspective</translation>
+ </message>
+ <message>
+ <source>USE_BBCENTER</source>
+ <translation>Use Bounding Box Center</translation>
+ </message>
+ <message>
+ <source>LBL_TOBBCENTER</source>
+ <translation>Set to Bounding Box Center</translation>
+ </message>
+ <message>
+ <source>LBL_TOORIGIN</source>
+ <translation>Set to Origin</translation>
+ </message>
+ <message>
+ <source>LBL_SELECTPOINT</source>
+ <translation>Select Point from View</translation>
+ </message>
+ <message>
+ <source>FOCAL_POINT</source>
+ <translation>Focal Point</translation>
+ </message>
+ <message>
+ <source>CAMERA_POSITION</source>
+ <translation>Camera Position</translation>
+ </message>
+ <message>
+ <source>WORLD_COORDINATES</source>
+ <translation>World Coordinates</translation>
+ </message>
+ <message>
+ <source>FOCAL_RELATIVE</source>
+ <translation>Relative to Focal Point</translation>
+ </message>
+ <message>
+ <source>PROJECTION_DIRECTION</source>
+ <translation>Projection Direction :</translation>
+ </message>
+ <message>
+ <source>FOCAL_DISTANCE</source>
+ <translation>Focal Distance :</translation>
+ </message>
+ <message>
+ <source>VIEW_UP_DIRECTION</source>
+ <translation>View Up Direction :</translation>
+ </message>
+ <message>
+ <source>ZOOMING</source>
+ <translation>Zooming</translation>
+ </message>
+ <message>
+ <source>LBL_SCALE</source>
+ <translation>Scale</translation>
+ </message>
+ <message>
+ <source>LBL_VIEW_ANGLE</source>
+ <translation>View Angle</translation>
+ </message>
+ <message>
+ <source>DLG_TITLE</source>
+ <translation>View Parameters</translation>
+ </message>
+</context>
<context>
<name>SVTK_UpdateRateDlg</name>
<message>
<parameter name="trihedron_size" value="105" />
<parameter name="relative_size" value="true" />
<parameter name="use_advanced_selection_algorithm" value="true" />
+ <parameter name="recorder_mode" value="1" />
+ <parameter name="recorder_fps" value="17.3" />
+ <parameter name="recorder_quality" value="100" />
+ <parameter name="recorder_progressive" value="true" />
</section>
<section name="Plot2d" >
<!-- Plot2d viewer preferences -->
// File : VTKViewer_GeometryFilter.cxx
// Author : Michael ZORIN
// Module : SALOME
-// $Header$
+// $Header$
#include "VTKViewer_GeometryFilter.h"
#include "VTKViewer_ConvexTool.h"