SVTK_Renderer.h \
SVTK_InteractorStyle.h \
SVTK_RenderWindowInteractor.h \
+ SVTK_GenericRenderWindowInteractor.h \
SVTK_Selector.h \
SVTK_Selection.h \
SVTK_SelectionEvent.h \
SVTK_ViewWindow.cxx \
SVTK_InteractorStyle.cxx \
SVTK_RenderWindowInteractor.cxx \
+ SVTK_GenericRenderWindowInteractor.cxx \
SVTK_SpaceMouse.cxx \
SVTK_Selector.cxx
-LIB_MOC = SVTK_RenderWindowInteractor.h \
- SVTK_InteractorStyle.h \
- SVTK_View.h \
+LIB_MOC = SVTK_GenericRenderWindowInteractor.h \
+ SVTK_RenderWindowInteractor.h \
+ SVTK_ViewModelBase.h \
+ SVTK_ViewManager.h \
SVTK_ViewWindow.h \
SVTK_ViewModel.h \
- SVTK_ViewManager.h \
- SVTK_ViewModelBase.h
+ SVTK_View.h
LIB_CLIENT_IDL = SALOMEDS.idl \
+ SALOMEDS_Attributes.idl \
SALOME_Exception.idl \
SALOME_ModuleCatalog.idl \
SALOME_GenericObj.idl
+BIN = SVTK
+
CPPFLAGS+=$(QT_INCLUDES) $(OCC_INCLUDES) $(VTK_INCLUDES) $(BOOST_CPPFLAGS) -I$(KERNEL_ROOT_DIR)/include/salome
LDFLAGS+=$(QT_MT_LIBS) $(OCC_LIBS) $(VTK_LIBS) -L$(KERNEL_ROOT_DIR)/lib/salome
-LIBS+= -lsuit -lCAM -lSalomeObject -lSalomePrs -lVTKViewer -lOpUtil
+LIBS+= -lsuit -lCAM -lSalomeObject -lSalomePrs -lVTKViewer -lOpUtil -lToolsGUI -lSalomeDS
@CONCLUDE@
theRenderer->RemoveActor( myOutlineActor );
}
+void
+SALOME_Actor
+::AddToInteractor(vtkRenderWindowInteractor* theInteractor)
+{}
+
+void
+SALOME_Actor
+::RemoveFromInteractor(vtkRenderWindowInteractor* theInteractor)
+{}
+
//----------------------------------------------------------------------------
void
class vtkOutlineSource;
class vtkRenderer;
class vtkInteractorStyle;
+class vtkRenderWindowInteractor;
+
class VTKViewer_Transform;
class VTKViewer_GeometryFilter;
class VTKViewer_TransformFilter;
void
SetVisibility( int );
+ //----------------------------------------------------------------------------
virtual
void
AddToRender( vtkRenderer* );
void
RemoveFromRender( vtkRenderer* );
-
+ virtual
+ void
+ AddToInteractor(vtkRenderWindowInteractor* theInteractor);
+
+ virtual
+ void
+ RemoveFromInteractor(vtkRenderWindowInteractor* theInteractor);
+
+ //----------------------------------------------------------------------------
virtual
bool
PreHighlight( SVTK_Selector*,
--- /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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File :
+// Author :
+// Module :
+// $Header$
+
+int
+main(int argc, char** argv)
+{
+ return 0;
+}
#include <vtkPolyData.h>
#include <vtkShrinkFilter.h>
-//#include "utilities.h"
+#include "utilities.h"
using namespace std;
SVTK_Actor::SVTK_Actor()
{
+ if(MYDEBUG) INFOS("SVTK_Actor - "<<this);
+
myRenderer = NULL;
myIsInfinite = true;
//----------------------------------------------------------------------------
SVTK_Actor::~SVTK_Actor()
{
- //if(MYDEBUG) INFOS("VTKViewer_Actor::~VTKViewer_Actor()");
+ if(MYDEBUG) INFOS("~SVTK_Actor()");
myMapper->RemoveAllInputs();
myMapper->Delete();
--- /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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File :
+// Author :
+// Module : SALOME
+// $Header$
+
+#include "SVTK_GenericRenderWindowInteractor.h"
+#include "SVTK_Selector.h"
+
+#include "utilities.h"
+
+#include <vtkObjectFactory.h>
+#include <vtkCommand.h>
+
+#include <qtimer.h>
+
+using namespace std;
+
+#ifdef _DEBUG_
+static int MYDEBUG = 1;
+#else
+static int MYDEBUG = 0;
+#endif
+
+//----------------------------------------------------------------------------
+vtkStandardNewMacro(QVTK_GenericRenderWindowInteractor);
+
+QVTK_GenericRenderWindowInteractor
+::QVTK_GenericRenderWindowInteractor()
+{
+ if(MYDEBUG) INFOS("QVTK_GenericRenderWindowInteractor() - "<<this);
+ myTimer = new QTimer( ) ;
+ connect(myTimer, SIGNAL(timeout()), this, SLOT(OnTimeOut())) ;
+}
+
+QVTK_GenericRenderWindowInteractor
+::~QVTK_GenericRenderWindowInteractor()
+{
+ if(MYDEBUG) INFOS("~QVTK_GenericRenderWindowInteractor() - "<<this);
+ delete myTimer;
+}
+
+
+//----------------------------------------------------------------------------
+void
+QVTK_GenericRenderWindowInteractor
+::OnTimeOut()
+{
+ if( GetEnabled() ) {
+ this->InvokeEvent(vtkCommand::TimerEvent,NULL);
+ }
+}
+
+int
+QVTK_GenericRenderWindowInteractor
+::CreateTimer(int vtkNotUsed(timertype))
+{
+ //
+ // Start a one-shot timer for <DELAY> ms.
+ //
+ static int DELAY = 1;
+ myTimer->start(DELAY,TRUE);
+ return 1;
+}
+
+int
+QVTK_GenericRenderWindowInteractor
+::DestroyTimer(void)
+{
+ //
+ // :TRICKY: Tue May 2 00:17:32 2000 Pagey
+ //
+ // QTimer will automatically expire after 10ms. So
+ // we do not need to do anything here. In fact, we
+ // should not even Stop() the QTimer here because doing
+ // this will skip some of the processing that the TimerFunc()
+ // does and will result in undesirable effects. For
+ // example, this will result in vtkLODActor to leave
+ // the models in low-res mode after the mouse stops
+ // moving.
+ //
+ return 1;
+}
+
+
+//----------------------------------------------------------------------------
+vtkStandardNewMacro(SVTK_GenericRenderWindowInteractor);
+
+SVTK_GenericRenderWindowInteractor
+::SVTK_GenericRenderWindowInteractor():
+ myRenderWidget(NULL)
+{
+ if(MYDEBUG) INFOS("SVTK_GenericRenderWindowInteractor() - "<<this);
+}
+
+SVTK_GenericRenderWindowInteractor
+::~SVTK_GenericRenderWindowInteractor()
+{
+ if(MYDEBUG) INFOS("~SVTK_GenericRenderWindowInteractor() - "<<this);
+}
+
+SVTK_Selector*
+SVTK_GenericRenderWindowInteractor
+::GetSelector()
+{
+ return mySelector.GetPointer();
+}
+
+void
+SVTK_GenericRenderWindowInteractor
+::SetSelector(SVTK_Selector* theSelector)
+{
+ mySelector = theSelector;
+}
+
+QWidget*
+SVTK_GenericRenderWindowInteractor
+::GetRenderWidget()
+{
+ return myRenderWidget;
+}
+
+void
+SVTK_GenericRenderWindowInteractor
+::SetRenderWidget(QWidget* theRenderWidget)
+{
+ myRenderWidget = theRenderWidget;
+}
--- /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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File :
+// Author :
+// Module : SALOME
+// $Header$
+
+#ifndef SVTK_GenericRenderWindowInteractor_h
+#define SVTK_GenericRenderWindowInteractor_h
+
+#include "SVTK.h"
+
+#include <qobject.h>
+#include <vtkGenericRenderWindowInteractor.h>
+#include <vtkSmartPointer.h>
+
+class QTimer;
+class QWidget;
+
+class SVTK_Selector;
+class SVTK_Renderer;
+
+// ------------------------------------------------------------
+// :TRICKY: Fri Apr 21 22:19:27 2000 Pagey
+// The Signal/Slot mechanism used by Qt requires that QObject
+// appear as the first class when using multiple inheritance.
+// Hence the order of the two classes QObject and vtkRenderWindowInteractor
+// matters here. Be careful not to change it by accident.
+// ------------------------------------------------------------
+class SVTK_EXPORT QVTK_GenericRenderWindowInteractor:
+ public QObject,
+ public vtkGenericRenderWindowInteractor
+{
+ Q_OBJECT;
+
+ public:
+ static QVTK_GenericRenderWindowInteractor* New();
+ vtkTypeMacro(QVTK_GenericRenderWindowInteractor,vtkGenericRenderWindowInteractor);
+
+ virtual
+ int
+ CreateTimer( int ) ;
+
+ virtual
+ int
+ DestroyTimer() ;
+
+ protected slots:
+ void
+ OnTimeOut();
+
+ protected:
+ QVTK_GenericRenderWindowInteractor();
+ ~QVTK_GenericRenderWindowInteractor();
+
+ QTimer* myTimer ;
+};
+
+
+// ------------------------------------------------------------
+class SVTK_EXPORT SVTK_GenericRenderWindowInteractor: public QVTK_GenericRenderWindowInteractor
+{
+ public:
+ static SVTK_GenericRenderWindowInteractor* New();
+ vtkTypeMacro(SVTK_GenericRenderWindowInteractor,QVTK_GenericRenderWindowInteractor);
+
+ SVTK_Selector*
+ GetSelector();
+
+ void
+ SetSelector(SVTK_Selector* theSelector);
+
+ QWidget*
+ GetRenderWidget();
+
+ void
+ SetRenderWidget(QWidget* theRenderWidget);
+
+ protected:
+ SVTK_GenericRenderWindowInteractor();
+ ~SVTK_GenericRenderWindowInteractor();
+
+ vtkSmartPointer<SVTK_Selector> mySelector;
+ QWidget* myRenderWidget;
+};
+
+#endif
//
//
//
-// File : SVTK_InteractorStyle.cxx
-// Author : Christophe ATTANASIO
+// File :
+// Author :
// Module : SALOME
// $Header$
#include "VTKViewer_Utilities.h"
#include "VTKViewer_RectPicker.h"
+#include "SVTK_GenericRenderWindowInteractor.h"
#include "SVTK_Selection.h"
#include "SVTK_Event.h"
using namespace std;
#ifdef _DEBUG_
-static int MYDEBUG = 0;
+static int MYDEBUG = 1;
#else
static int MYDEBUG = 0;
#endif
namespace
{
- bool CheckDimensionId(Selection_Mode theMode, SALOME_Actor *theActor, vtkIdType theObjId){
- switch(theMode){
- case CellSelection:
- return true;
- case EdgeSelection:
- return ( theActor->GetObjDimension( theObjId ) == 1 );
- case FaceSelection:
- return ( theActor->GetObjDimension( theObjId ) == 2 );
- case VolumeSelection:
- return ( theActor->GetObjDimension( theObjId ) == 3 );
- };
- return false;
+ inline
+ void
+ GetEventPosition(vtkRenderWindowInteractor* theInteractor,
+ int& theX,
+ int& theY)
+ {
+ theInteractor->GetEventPosition(theX,theY);
+ theY = theInteractor->GetSize()[1] - theY - 1;
}
}
SVTK_InteractorStyle
::SVTK_InteractorStyle()
{
+ if(MYDEBUG) INFOS("SVTK_InteractorStyle() - "<<this);
+
this->MotionFactor = 10.0;
this->State = VTK_INTERACTOR_STYLE_CAMERA_NONE;
this->RadianToDegree = 180.0 / vtkMath::Pi();
SVTK_InteractorStyle
::~SVTK_InteractorStyle()
{
- if(MYDEBUG) INFOS("SVTK_InteractorStyle::~SVTK_InteractorStyle()");
+ if(MYDEBUG) INFOS("~SVTK_InteractorStyle() - "<<this);
}
//----------------------------------------------------------------------------
+QWidget*
+SVTK_InteractorStyle
+::GetRenderWidget()
+{
+ return myInteractor->GetRenderWidget();
+}
+
SVTK_Selector*
SVTK_InteractorStyle
::GetSelector()
{
- return mySelector.GetPointer();
+ return myInteractor->GetSelector();
}
//----------------------------------------------------------------------------
{
SVTK_SelectionEvent aSelectionEvent;
- int x, y, w, h;
- Interactor->GetEventPosition( x, y );
- Interactor->GetSize( w, h );
+ int x, y;
+ GetEventPosition( this->Interactor, x, y );
aSelectionEvent.myX = x;
- aSelectionEvent.myY = h - y - 1;
+ aSelectionEvent.myY = y;
aSelectionEvent.myIsCtrl = Interactor->GetControlKey();
aSelectionEvent.myIsShift = Interactor->GetShiftKey();
aSelectionEvent.mySelectionMode = GetSelector()->SelectionMode();
return aSelectionEvent;
}
-//----------------------------------------------------------------------------
-void
-SVTK_InteractorStyle
-::SetSelector( SVTK_Selector* theSelector )
-{
- mySelector = theSelector;
-}
-
-//----------------------------------------------------------------------------
-void
-SVTK_InteractorStyle
-::SetRenderWidget(QWidget* theWidget)
-{
- myRenderWidget = theWidget;
-}
-
//----------------------------------------------------------------------------
void
SVTK_InteractorStyle
::OnMouseMove()
{
int x, y;
- this->Interactor->GetEventPosition( x, y );
+ GetEventPosition( this->Interactor, x, y );
this->OnMouseMove( this->Interactor->GetControlKey(),
this->Interactor->GetShiftKey(),
x, y );
::OnLeftButtonDown()
{
int x, y;
- this->Interactor->GetEventPosition( x, y );
+ GetEventPosition( this->Interactor, x, y );
this->OnLeftButtonDown( this->Interactor->GetControlKey(),
this->Interactor->GetShiftKey(),
x, y );
::OnLeftButtonUp()
{
int x, y;
- this->Interactor->GetEventPosition( x, y );
+ GetEventPosition( this->Interactor, x, y );
this->OnLeftButtonUp( this->Interactor->GetControlKey(),
this->Interactor->GetShiftKey(),
x, y );
::OnMiddleButtonDown()
{
int x, y;
- this->Interactor->GetEventPosition( x, y );
+ GetEventPosition( this->Interactor, x, y );
this->OnMiddleButtonDown( this->Interactor->GetControlKey(),
this->Interactor->GetShiftKey(),
x, y );
::OnMiddleButtonUp()
{
int x, y;
- this->Interactor->GetEventPosition( x, y );
+ GetEventPosition( this->Interactor, x, y );
this->OnMiddleButtonUp( this->Interactor->GetControlKey(),
this->Interactor->GetShiftKey(),
x, y );
::OnRightButtonDown()
{
int x, y;
- this->Interactor->GetEventPosition( x, y );
+ GetEventPosition( this->Interactor, x, y );
this->OnRightButtonDown( this->Interactor->GetControlKey(),
this->Interactor->GetShiftKey(),
x, y );
::OnRightButtonUp()
{
int x, y;
- this->Interactor->GetEventPosition( x, y );
+ GetEventPosition( this->Interactor, x, y );
this->OnRightButtonUp( this->Interactor->GetControlKey(),
this->Interactor->GetShiftKey(),
x, y );
SVTK_InteractorStyle
::loadCursors()
{
- myDefCursor = QCursor(ArrowCursor);
- myHandCursor = QCursor(PointingHandCursor);
- myPanCursor = QCursor(SizeAllCursor);
+ myDefCursor = QCursor(Qt::ArrowCursor);
+ myHandCursor = QCursor(Qt::PointingHandCursor);
+ myPanCursor = QCursor(Qt::SizeAllCursor);
myZoomCursor = QCursor(QPixmap(imageZoomCursor));
myRotateCursor = QCursor(QPixmap(imageRotateCursor));
mySpinCursor = QCursor(QPixmap(imageRotateCursor)); // temporarly !!!!!!
- myGlobalPanCursor = QCursor(CrossCursor);
+ myGlobalPanCursor = QCursor(Qt::CrossCursor);
myCursorState = false;
}
-//----------------------------------------------------------------------------
-// event filter - controls mouse and keyboard events during viewer operations
-bool
-SVTK_InteractorStyle
-::eventFilter(QObject* object, QEvent* event)
-{
- if (!myRenderWidget) return false;
- if ( (event->type() == QEvent::MouseButtonPress ||
- event->type() == QEvent::KeyPress) &&
- object != myRenderWidget)
- {
- qApp->removeEventFilter(this);
- startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
- }
- return QObject::eventFilter(object, event);
-}
-
-
//----------------------------------------------------------------------------
// starts Zoom operation (e.g. through menu command)
void
}
setCursor(VTK_INTERACTOR_STYLE_CAMERA_ZOOM);
ForcedState = VTK_INTERACTOR_STYLE_CAMERA_ZOOM;
- qApp->installEventFilter(this);
}
}
setCursor(VTK_INTERACTOR_STYLE_CAMERA_PAN);
ForcedState = VTK_INTERACTOR_STYLE_CAMERA_PAN;
- qApp->installEventFilter(this);
}
//----------------------------------------------------------------------------
}
setCursor(VTK_INTERACTOR_STYLE_CAMERA_ROTATE);
ForcedState = VTK_INTERACTOR_STYLE_CAMERA_ROTATE;
- qApp->installEventFilter(this);
}
}
setCursor(VTK_INTERACTOR_STYLE_CAMERA_SPIN);
ForcedState = VTK_INTERACTOR_STYLE_CAMERA_SPIN;
- qApp->installEventFilter(this);
}
}
setCursor(VTK_INTERACTOR_STYLE_CAMERA_FIT);
ForcedState = VTK_INTERACTOR_STYLE_CAMERA_FIT;
- qApp->installEventFilter(this);
}
ForcedState = VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN;
// store current zoom scale
- vtkCamera *cam = GetCurrentRenderer()->GetActiveCamera();
- myScale = cam->GetParallelScale();
+ myScale = GetCurrentRenderer()->GetActiveCamera()->GetParallelScale();
GetCurrentRenderer()->ResetCamera();
this->Render();
-
- qApp->installEventFilter(this);
}
SVTK_InteractorStyle
::setCursor(const int operation)
{
- if (!myRenderWidget) return;
+ if (!GetRenderWidget()) return;
switch (operation)
{
case VTK_INTERACTOR_STYLE_CAMERA_ZOOM:
- myRenderWidget->setCursor(myZoomCursor);
+ GetRenderWidget()->setCursor(myZoomCursor);
myCursorState = true;
break;
case VTK_INTERACTOR_STYLE_CAMERA_PAN:
- myRenderWidget->setCursor(myPanCursor);
+ GetRenderWidget()->setCursor(myPanCursor);
myCursorState = true;
break;
case VTK_INTERACTOR_STYLE_CAMERA_ROTATE:
- myRenderWidget->setCursor(myRotateCursor);
+ GetRenderWidget()->setCursor(myRotateCursor);
myCursorState = true;
break;
case VTK_INTERACTOR_STYLE_CAMERA_SPIN:
- myRenderWidget->setCursor(mySpinCursor);
+ GetRenderWidget()->setCursor(mySpinCursor);
myCursorState = true;
break;
case VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN:
- myRenderWidget->setCursor(myGlobalPanCursor);
+ GetRenderWidget()->setCursor(myGlobalPanCursor);
myCursorState = true;
break;
case VTK_INTERACTOR_STYLE_CAMERA_FIT:
case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
- myRenderWidget->setCursor(myHandCursor);
+ GetRenderWidget()->setCursor(myHandCursor);
myCursorState = true;
break;
case VTK_INTERACTOR_STYLE_CAMERA_NONE:
default:
- myRenderWidget->setCursor(myDefCursor);
+ GetRenderWidget()->setCursor(myDefCursor);
myCursorState = false;
break;
}
SVTK_InteractorStyle
::onStartOperation()
{
- if (!myRenderWidget) return;
+ if (!GetRenderWidget()) return;
// VSV: LOD actor activisation
// this->Interactor->GetRenderWindow()->SetDesiredUpdateRate(this->Interactor->GetDesiredUpdateRate());
switch (State) {
case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
case VTK_INTERACTOR_STYLE_CAMERA_FIT:
{
- QPainter p(myRenderWidget);
+ QPainter p(GetRenderWidget());
p.setPen(Qt::lightGray);
p.setRasterOp(Qt::XorROP);
p.drawRect(QRect(myPoint, myOtherPoint));
SVTK_InteractorStyle
::onFinishOperation()
{
- if (!myRenderWidget)
+ if (!GetRenderWidget())
return;
// VSV: LOD actor activisation
case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
case VTK_INTERACTOR_STYLE_CAMERA_FIT:
{
- QPainter p(myRenderWidget);
+ QPainter p(GetRenderWidget());
p.setPen(Qt::lightGray);
p.setRasterOp(Qt::XorROP);
QRect rect(myPoint, myOtherPoint);
SVTK_InteractorStyle
::onOperation(QPoint mousePos)
{
- if (!myRenderWidget)
+ if (!GetRenderWidget())
return;
switch (State) {
}
case VTK_INTERACTOR_STYLE_CAMERA_FIT:
{
- QPainter p(myRenderWidget);
+ QPainter p(GetRenderWidget());
p.setPen(Qt::lightGray);
p.setRasterOp(Qt::XorROP);
p.drawRect(QRect(myPoint, myOtherPoint));
//----------------------------------------------------------------------------
void
SVTK_InteractorStyle
-::SetInteractor( vtkRenderWindowInteractor* interactor )
+::SetInteractor( vtkRenderWindowInteractor* theInteractor )
{
// register EventCallbackCommand as observer of standard events (keypress, mousemove, etc)
- vtkInteractorStyle::SetInteractor( interactor );
+ vtkInteractorStyle::SetInteractor( theInteractor );
- if ( interactor ) {
+ myInteractor = dynamic_cast<SVTK_GenericRenderWindowInteractor*>(theInteractor);
+
+ if ( myInteractor.GetPointer() ) {
// register EventCallbackCommand as observer of custorm event (3d space mouse event)
- interactor->AddObserver( SVTK::SpaceMouseMoveEvent, EventCallbackCommand, Priority );
- interactor->AddObserver( SVTK::SpaceMouseButtonEvent, EventCallbackCommand, Priority );
- interactor->AddObserver( SVTK::PanLeftEvent, EventCallbackCommand, Priority );
- interactor->AddObserver( SVTK::PanRightEvent, EventCallbackCommand, Priority );
- interactor->AddObserver( SVTK::PanUpEvent, EventCallbackCommand, Priority );
- interactor->AddObserver( SVTK::PanDownEvent, EventCallbackCommand, Priority );
- interactor->AddObserver( SVTK::ZoomInEvent, EventCallbackCommand, Priority );
- interactor->AddObserver( SVTK::ZoomOutEvent, EventCallbackCommand, Priority );
- interactor->AddObserver( SVTK::RotateLeftEvent, EventCallbackCommand, Priority );
- interactor->AddObserver( SVTK::RotateRightEvent, EventCallbackCommand, Priority );
- interactor->AddObserver( SVTK::RotateUpEvent, EventCallbackCommand, Priority );
- interactor->AddObserver( SVTK::RotateDownEvent, EventCallbackCommand, Priority );
- interactor->AddObserver( SVTK::PlusSpeedIncrementEvent, EventCallbackCommand, Priority );
- interactor->AddObserver( SVTK::MinusSpeedIncrementEvent, EventCallbackCommand, Priority );
- interactor->AddObserver( SVTK::SetSpeedIncrementEvent, EventCallbackCommand, Priority );
-
- interactor->AddObserver( SVTK::SetSpaceMouseF1Event, EventCallbackCommand, Priority );
- interactor->AddObserver( SVTK::SetSpaceMouseF2Event, EventCallbackCommand, Priority );
- interactor->AddObserver( SVTK::SetSpaceMouseF3Event, EventCallbackCommand, Priority );
- interactor->AddObserver( SVTK::SetSpaceMouseF4Event, EventCallbackCommand, Priority );
- interactor->AddObserver( SVTK::SetSpaceMouseF5Event, EventCallbackCommand, Priority );
-
- interactor->AddObserver( SVTK::StartZoom, EventCallbackCommand, Priority );
- interactor->AddObserver( SVTK::StartPan, EventCallbackCommand, Priority );
- interactor->AddObserver( SVTK::StartRotate, EventCallbackCommand, Priority );
- interactor->AddObserver( SVTK::StartGlobalPan, EventCallbackCommand, Priority );
- interactor->AddObserver( SVTK::StartFitArea, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::SpaceMouseMoveEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::SpaceMouseButtonEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::PanLeftEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::PanRightEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::PanUpEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::PanDownEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::ZoomInEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::ZoomOutEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::RotateLeftEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::RotateRightEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::RotateUpEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::RotateDownEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::PlusSpeedIncrementEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::MinusSpeedIncrementEvent, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::SetSpeedIncrementEvent, EventCallbackCommand, Priority );
+
+ theInteractor->AddObserver( SVTK::SetSpaceMouseF1Event, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::SetSpaceMouseF2Event, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::SetSpaceMouseF3Event, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::SetSpaceMouseF4Event, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::SetSpaceMouseF5Event, EventCallbackCommand, Priority );
+
+ theInteractor->AddObserver( SVTK::StartZoom, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::StartPan, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::StartRotate, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::StartGlobalPan, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::StartFitArea, EventCallbackCommand, Priority );
}
}
// general things, do SetCurrentRenderer() within FindPokedRenderer()
int x, y;
- Interactor->GetEventPosition( x, y ); // current mouse position (from last mouse move event or any other event)
+ GetEventPosition( this->Interactor, x, y ); // current mouse position (from last mouse move event or any other event)
FindPokedRenderer( x, y ); // calls SetCurrentRenderer
IncrementalZoom( (int)data[2] ); // 1. push toward / pull backward = zoom out / zoom in
#include "SVTK.h"
+#include "SVTK_SelectionEvent.h"
+
#include <vtkInteractorStyle.h>
#include <vtkSmartPointer.h>
-class vtkCell;
-class vtkRenderWindowInteractor;
-
-#include <qobject.h>
#include <qcursor.h>
#include <qevent.h>
#include <map>
-#include "SVTK_SelectionEvent.h"
-
+class vtkCell;
class vtkPicker;
class VTKViewer_RectPicker;
-class SALOME_Actor;
-class SVTK_Viewer;
class SVTK_Selector;
-class SVTK_ViewWindow;
+class SVTK_GenericRenderWindowInteractor;
#define VTK_INTERACTOR_STYLE_CAMERA_NONE 0
#define VTK_INTERACTOR_STYLE_CAMERA_ROTATE 1
#define VTK_INTERACTOR_STYLE_CAMERA_SELECT 6
#define VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN 7
-class SVTK_EXPORT SVTK_InteractorStyle :
- public QObject,
- public vtkInteractorStyle
+class SVTK_EXPORT SVTK_InteractorStyle: public vtkInteractorStyle
{
- Q_OBJECT;
-
public:
// Description:
// This class must be supplied with a vtkRenderWindowInteractor wrapper or
static SVTK_InteractorStyle *New();
vtkTypeMacro(SVTK_InteractorStyle, vtkInteractorStyle);
- void SetSelector( SVTK_Selector* theSelector );
- SVTK_Selector* GetSelector();
-
- void SetRenderWidget(QWidget* theRenderWidget);
-
virtual int GetState();
SVTK_SelectionEvent GetSelectionEvent();
virtual void OnRightButtonDown();
virtual void OnRightButtonUp();
- void
- IncrementalPan( const int incrX, const int incrY );
-
- void
- IncrementalZoom( const int incr );
-
- void
- IncrementalRotate( const int incrX, const int incrY );
-
protected:
SVTK_InteractorStyle();
~SVTK_InteractorStyle();
- SVTK_InteractorStyle(const SVTK_InteractorStyle&) {};
- void operator=(const SVTK_InteractorStyle&) {};
+
+ QWidget*
+ GetRenderWidget();
+
+ SVTK_Selector*
+ GetSelector();
// Generic event bindings must be overridden in subclasses
virtual void OnMouseMove (int ctrl, int shift, int x, int y);
void Place(const int theX, const int theY);
void TranslateView(int toX, int toY, int fromX, int fromY);
+ void
+ IncrementalPan( const int incrX, const int incrY );
+
+ void
+ IncrementalZoom( const int incr );
+
+ void
+ IncrementalRotate( const int incrX, const int incrY );
+
// custom event handling function (to handle 3d space mouse events)
static void ProcessEvents( vtkObject* object, unsigned long event,
void* clientData, void* callData );
double myScale;
public:
- bool eventFilter(QObject* object, QEvent* event);
void startZoom();
void startPan();
void startGlobalPan();
QWidget* myRenderWidget;
vtkSmartPointer<SVTK_Selector> mySelector;
+ vtkSmartPointer<SVTK_GenericRenderWindowInteractor> myInteractor;
vtkSmartPointer<vtkPicker> myPicker;
vtkSmartPointer<VTKViewer_RectPicker> myRectPicker;
// $Header$
#include "SVTK_RenderWindowInteractor.h"
+#include "SVTK_GenericRenderWindowInteractor.h"
#include "SVTK_InteractorStyle.h"
#include "SVTK_Renderer.h"
using namespace std;
#ifdef _DEBUG_
-static int MYDEBUG = 0;
+static int MYDEBUG = 1;
#else
static int MYDEBUG = 0;
#endif
//#define GENERATE_SUIT_EVENTS
-//----------------------------------------------------------------------------
-vtkStandardNewMacro(QtRenderWindowInteractor);
-
-QtRenderWindowInteractor
-::QtRenderWindowInteractor()
-{
- myTimer = new QTimer( ) ;
- connect(myTimer, SIGNAL(timeout()), this, SLOT(OnTimeOut())) ;
-}
-
-QtRenderWindowInteractor
-::~QtRenderWindowInteractor()
-{
- delete myTimer;
-}
-
-
-//----------------------------------------------------------------------------
-void
-QtRenderWindowInteractor
-::OnTimeOut()
-{
- if( GetEnabled() ) {
- this->InvokeEvent(vtkCommand::TimerEvent,NULL);
- }
-}
-
-int
-QtRenderWindowInteractor
-::CreateTimer(int vtkNotUsed(timertype))
-{
- //
- // Start a one-shot timer for 10ms.
- //
- myTimer->start(1,TRUE);
- return 1;
-}
-
-int
-QtRenderWindowInteractor
-::DestroyTimer(void)
-{
- //
- // :TRICKY: Tue May 2 00:17:32 2000 Pagey
- //
- // QTimer will automatically expire after 10ms. So
- // we do not need to do anything here. In fact, we
- // should not even Stop() the QTimer here because doing
- // this will skip some of the processing that the TimerFunc()
- // does and will result in undesirable effects. For
- // example, this will result in vtkLODActor to leave
- // the models in low-res mode after the mouse stops
- // moving.
- //
- return 1;
-}
-
//----------------------------------------------------------------------------
QVTK_RenderWindowInteractor
::QVTK_RenderWindowInteractor(QWidget* theParent,
const char* theName):
- QWidget(theParent,theName),
- myInteractor(QtRenderWindowInteractor::New())
+ QWidget(theParent,theName)
{
- myInteractor->Delete();
-
+ if(MYDEBUG) INFOS("QVTK_RenderWindowInteractor() - "<<this);
setMouseTracking(true);
}
QVTK_RenderWindowInteractor
::~QVTK_RenderWindowInteractor()
{
+ if(MYDEBUG) INFOS("~QVTK_RenderWindowInteractor() - "<<this);
+
if(SVTK_SpaceMouse* aSpaceMouse = SVTK_SpaceMouse::getInstance())
if(aSpaceMouse->isSpaceMouseOn())
aSpaceMouse->close(x11Display());
}
//----------------------------------------------------------------------------
-vtkRenderWindowInteractor*
+vtkGenericRenderWindowInteractor*
QVTK_RenderWindowInteractor
::GetDevice()
{
- return myInteractor.GetPointer();
+ return myDevice.GetPointer();
+}
+
+void
+QVTK_RenderWindowInteractor
+::SetDevice(vtkGenericRenderWindowInteractor* theDevice)
+{
+ myDevice = theDevice;
}
//----------------------------------------------------------------------------
QVTK_RenderWindowInteractor
::SetRenderWindow(vtkRenderWindow *theRenderWindow)
{
- myInteractor->SetRenderWindow(theRenderWindow);
+ GetDevice()->SetRenderWindow(theRenderWindow);
theRenderWindow->DoubleBufferOn();
}
QVTK_RenderWindowInteractor
::GetRenderWindow()
{
- return myInteractor->GetRenderWindow();
+ return GetDevice()->GetRenderWindow();
}
//----------------------------------------------------------------------------
QVTK_RenderWindowInteractor
::InvokeEvent(unsigned long theEvent, void* theCallData)
{
- myInteractor->InvokeEvent(theEvent,theCallData);
+ GetDevice()->InvokeEvent(theEvent,theCallData);
}
//----------------------------------------------------------------------------
QVTK_RenderWindowInteractor
::polish()
{
- // Final initialization just before the widget is displayed.
- myInteractor->SetSize(width(),height());
+ // Final initialization just before the widget is displayed
+ GetDevice()->SetSize(width(),height());
#ifndef WNT
GetRenderWindow()->SetDisplayId((void*)x11Display());
#endif
GetRenderWindow()->SetWindowId((void*)winId());
- myInteractor->Enable();
+ GetDevice()->Enable();
}
//----------------------------------------------------------------------------
QVTK_RenderWindowInteractor
::resize(int w, int h)
{
- myInteractor->UpdateSize(w,h);
+ GetDevice()->UpdateSize(w,h);
}
//----------------------------------------------------------------------------
QVTK_RenderWindowInteractor
::paintEvent( QPaintEvent* theEvent )
{
- if(myInteractor->GetEnabled()){
- if(!myInteractor->GetInitialized()){
- myInteractor->Initialize();
- myInteractor->ConfigureEvent();
+ if(GetDevice()->GetEnabled()){
+ if(!GetDevice()->GetInitialized()){
+ GetDevice()->Initialize();
+ GetDevice()->ConfigureEvent();
}
- myInteractor->Render();
+ GetDevice()->Render();
}
}
int aWidth = aSize[0];
int aHeight = aSize[1];
- myInteractor->UpdateSize(width(),height());
+ GetDevice()->UpdateSize(width(),height());
- if(aWidth && aHeight){
+ if(isVisible() && aWidth && aHeight){
if( aWidth != width() || aHeight != height() ) {
vtkRendererCollection * aRenderers = GetRenderWindow()->GetRenderers();
aRenderers->InitTraversal();
QVTK_RenderWindowInteractor
::mouseMoveEvent( QMouseEvent* event )
{
- myInteractor->SetEventInformation( event->x(), event->y(),
- ( event->state() & ControlButton ),
- ( event->state() & ShiftButton ) );
- myInteractor->MouseMoveEvent();
+ GetDevice()->SetEventInformationFlipY(event->x(),
+ event->y(),
+ event->state() & ControlButton,
+ event->state() & ShiftButton);
+ GetDevice()->MouseMoveEvent();
}
QVTK_RenderWindowInteractor
::mousePressEvent( QMouseEvent* event )
{
- myInteractor->SetEventInformation( event->x(), event->y(),
- ( event->state() & ControlButton ),
- ( event->state() & ShiftButton ) );
+ GetDevice()->SetEventInformationFlipY(event->x(),
+ event->y(),
+ event->state() & ControlButton,
+ event->state() & ShiftButton);
if( event->button() & LeftButton )
- myInteractor->LeftButtonPressEvent();
+ GetDevice()->LeftButtonPressEvent();
else if( event->button() & MidButton )
- myInteractor->MiddleButtonPressEvent();
+ GetDevice()->MiddleButtonPressEvent();
else if( event->button() & RightButton )
- myInteractor->RightButtonPressEvent();
+ GetDevice()->RightButtonPressEvent();
}
QVTK_RenderWindowInteractor
::mouseReleaseEvent( QMouseEvent *event )
{
- myInteractor->SetEventInformation( event->x(), event->y(),
- ( event->state() & ControlButton ),
- ( event->state() & ShiftButton ) );
+ GetDevice()->SetEventInformationFlipY(event->x(),
+ event->y(),
+ event->state() & ControlButton,
+ event->state() & ShiftButton);
if( event->button() & LeftButton )
- myInteractor->LeftButtonReleaseEvent();
+ GetDevice()->LeftButtonReleaseEvent();
else if( event->button() & MidButton )
- myInteractor->MiddleButtonReleaseEvent();
+ GetDevice()->MiddleButtonReleaseEvent();
else if( event->button() & RightButton )
- myInteractor->RightButtonReleaseEvent();
+ GetDevice()->RightButtonReleaseEvent();
}
QVTK_RenderWindowInteractor
::keyPressEvent( QKeyEvent* event )
{
- myInteractor->SetKeyEventInformation( ( event->state() & ControlButton ),
- ( event->state() & ShiftButton ),
- event->key() );
- myInteractor->KeyPressEvent();
+ GetDevice()->SetKeyEventInformation(event->state() & ControlButton,
+ event->state() & ShiftButton,
+ event->key());
+ GetDevice()->KeyPressEvent();
+ GetDevice()->CharEvent();
}
//----------------------------------------------------------------------------
QVTK_RenderWindowInteractor
::keyReleaseEvent( QKeyEvent * event )
{
- myInteractor->SetKeyEventInformation( ( event->state() & ControlButton ),
- ( event->state() & ShiftButton ),
- event->key() );
- myInteractor->KeyReleaseEvent();
+ GetDevice()->SetKeyEventInformation(event->state() & ControlButton,
+ event->state() & ShiftButton,
+ event->key());
+ GetDevice()->KeyReleaseEvent();
}
}
}
- myInteractor->EnterEvent();
+ GetDevice()->EnterEvent();
}
//----------------------------------------------------------------------------
aSpaceMouse->setWindow(x11Display(),0);
}
- myInteractor->LeaveEvent();
+ GetDevice()->LeaveEvent();
}
int type = aSpaceMouse->translateEvent( x11Display(), xEvent, &anEvent, 1.0, 1.0 );
switch( type ){
case SVTK_SpaceMouse::SpaceMouseMove :
- myInteractor->InvokeEvent(SVTK::SpaceMouseMoveEvent, anEvent.data );
+ GetDevice()->InvokeEvent(SVTK::SpaceMouseMoveEvent, anEvent.data );
break;
case SVTK_SpaceMouse::SpaceButtonPress :
- myInteractor->InvokeEvent( SVTK::SpaceMouseButtonEvent, &anEvent.button );
+ GetDevice()->InvokeEvent( SVTK::SpaceMouseButtonEvent, &anEvent.button );
break;
case SVTK_SpaceMouse::SpaceButtonRelease :
break;
myEventCallbackCommand(vtkCallbackCommand::New()),
myRenderWindow(vtkRenderWindow::New())
{
+ if(MYDEBUG) INFOS("SVTK_RenderWindowInteractor() - "<<this);
+
myEventCallbackCommand->Delete();
myEventCallbackCommand->SetClientData(this);
myEventCallbackCommand->SetCallback(SVTK_RenderWindowInteractor::ProcessEvents);
- myRenderWindow->Delete();
- GetDevice()->SetRenderWindow(getRenderWindow());
+ SVTK_GenericRenderWindowInteractor* aDevice = SVTK_GenericRenderWindowInteractor::New();
+ SetDevice(aDevice);
+ aDevice->Delete();
+
+ aDevice->SetRenderWidget(this);
SetSelector(SVTK_Selector::New());
mySelector->Delete();
+
+ aDevice->SetSelector(GetSelector());
+
+ GetDevice()->SetRenderWindow(getRenderWindow());
+ myRenderWindow->Delete();
}
SVTK_RenderWindowInteractor
::~SVTK_RenderWindowInteractor()
-{}
+{
+ if(MYDEBUG) INFOS("~SVTK_RenderWindowInteractor() - "<<this);
+}
vtkRenderWindow*
SVTK_RenderWindowInteractor
SVTK_RenderWindowInteractor
::getRenderer()
{
- return GetRenderer();
+ return GetRenderer()->GetDevice();
}
void
SVTK_RenderWindowInteractor
::SetRenderer(SVTK_Renderer* theRenderer)
{
- myRenderWindow->RemoveRenderer(GetRenderer());
+ if(theRenderer == myRenderer.GetPointer())
+ return;
+
+ if(GetRenderer()){
+ myRenderWindow->RemoveRenderer(getRenderer());
+ theRenderer->SetInteractor(NULL);
+ }
+
myRenderer = theRenderer;
- myRenderWindow->AddRenderer(GetRenderer());
+
+ if(GetRenderer()){
+ myRenderWindow->AddRenderer(getRenderer());
+ theRenderer->SetInteractor(GetDevice());
+ }
}
//----------------------------------------------------------------------------
void
SVTK_RenderWindowInteractor
-::InitInteractorStyle(SVTK_InteractorStyle* theStyle)
+::InitInteractorStyle(vtkInteractorStyle* theStyle)
{
GetDevice()->SetInteractorStyle(theStyle);
-
- theStyle->SetSelector(GetSelector());
- theStyle->SetRenderWidget(this);
}
//----------------------------------------------------------------------------
void
SVTK_RenderWindowInteractor
-::PushInteractorStyle(SVTK_InteractorStyle* theStyle)
+::PushInteractorStyle(vtkInteractorStyle* theStyle)
{
myInteractorStyles.push(PInteractorStyle(theStyle));
InitInteractorStyle(theStyle);
//----------------------------------------------------------------------------
-SVTK_InteractorStyle*
+vtkInteractorStyle*
SVTK_RenderWindowInteractor
::GetInteractorStyle()
{
//
//
//
-// File : SVTK_RenderWindowInteractor.h
-// Author : Nicolas REJNERI
+// File :
+// Author :
// Module : SALOME
// $Header$
#include "SVTK.h"
#include "SVTK_Selection.h"
-#include "SALOME_InteractiveObject.hxx"
-
-#include <vtkSmartPointer.h>
-#include <vtkGenericRenderWindowInteractor.h>
-
-#include <qvaluestack.h>
#include <qwidget.h>
+#include <qvaluestack.h>
-class QTimer;
+#include <vtkSmartPointer.h>
-class vtkCallbackCommand;
-class vtkActorCollection;
class vtkGenericRenderWindowInteractor;
+class vtkInteractorStyle;
+class vtkCallbackCommand;
+class vtkRenderWindow;
+class vtkRenderer;
+class vtkObject;
-class SALOME_Actor;
class SVTK_Selector;
class SVTK_Renderer;
-class SVTK_InteractorStyle;
-
-// ------------------------------------------------------------
-// :TRICKY: Fri Apr 21 22:19:27 2000 Pagey
-// The Signal/Slot mechanism used by Qt requires that QObject
-// appear as the first class when using multiple inheritance.
-// Hence the order of the two classes QObject and vtkRenderWindowInteractor
-// matters here. Be careful not to change it by accident.
-// ------------------------------------------------------------
-class SVTK_EXPORT QtRenderWindowInteractor:
- public QObject,
- public vtkGenericRenderWindowInteractor
-{
- Q_OBJECT;
-
- public:
- static QtRenderWindowInteractor* New();
- vtkTypeMacro(QtRenderWindowInteractor,vtkGenericRenderWindowInteractor);
-
- virtual
- int
- CreateTimer( int ) ;
-
- virtual
- int
- DestroyTimer() ;
-
- protected slots:
- virtual
- void
- OnTimeOut();
-
- protected:
- QtRenderWindowInteractor();
- ~QtRenderWindowInteractor();
-
- QTimer* myTimer ;
-};
-
// ------------------------------------------------------------
class SVTK_EXPORT QVTK_RenderWindowInteractor: public QWidget
~QVTK_RenderWindowInteractor();
- vtkRenderWindowInteractor*
+ vtkGenericRenderWindowInteractor*
GetDevice();
+ void
+ SetDevice(vtkGenericRenderWindowInteractor* theDevice);
+
void
SetRenderWindow(vtkRenderWindow *theRenderWindow);
virtual bool x11Event( XEvent *e );
- vtkSmartPointer<vtkGenericRenderWindowInteractor> myInteractor;
+ vtkSmartPointer<vtkGenericRenderWindowInteractor> myDevice;
};
getRenderer();
//----------------------------------------------------------------------------
- SVTK_InteractorStyle*
+ vtkInteractorStyle*
GetInteractorStyle();
void
- PushInteractorStyle(SVTK_InteractorStyle* theStyle);
+ PushInteractorStyle(vtkInteractorStyle* theStyle);
void
PopInteractorStyle();
virtual void contextMenuEvent( QContextMenuEvent * e );
void
- InitInteractorStyle(SVTK_InteractorStyle* theStyle);
+ InitInteractorStyle(vtkInteractorStyle* theStyle);
// Main process VTK event method
static
vtkSmartPointer<SVTK_Renderer> myRenderer;
vtkSmartPointer<vtkRenderWindow> myRenderWindow;
- typedef vtkSmartPointer<SVTK_InteractorStyle> PInteractorStyle;
+ typedef vtkSmartPointer<vtkInteractorStyle> PInteractorStyle;
QValueStack<PInteractorStyle> myInteractorStyles;
};
#include "SVTK_Trihedron.h"
#include "SVTK_CubeAxesActor2D.h"
-#include "VTKViewer_Actor.h"
#include "SALOME_Actor.h"
-
+#include "VTKViewer_Actor.h"
#include "VTKViewer_Transform.h"
#include "VTKViewer_Utilities.h"
-#include "SUIT_Session.h"
-#include "SUIT_ResourceMgr.h"
-
#include <vtkCamera.h>
+#include <vtkRenderer.h>
#include <vtkTextProperty.h>
#include <vtkObjectFactory.h>
#include <vtkCallbackCommand.h>
+#include "utilities.h"
+
+#ifdef _DEBUG_
+static int MYDEBUG = 1;
+#else
+static int MYDEBUG = 0;
+#endif
+
//----------------------------------------------------------------------------
vtkStandardNewMacro(SVTK_Renderer);
//----------------------------------------------------------------------------
SVTK_Renderer
::SVTK_Renderer():
+ myDevice(vtkRenderer::New()),
+ myInteractor(NULL),
myTransform(VTKViewer_Transform::New()),
myCubeAxes(SVTK_CubeAxesActor2D::New()),
myTrihedron(SVTK_Trihedron::New()),
myPriority(0.0),
myEventCallbackCommand(vtkCallbackCommand::New())
{
+ if(MYDEBUG) INFOS("SVTK_Renderer() - "<<this);
+
myTransform->Delete();
myTrihedron->Delete();
myCubeAxes->Delete();
myEventCallbackCommand->Delete();
- myTrihedron->AddToRender(this);
- this->AddProp(GetCubeAxes());
+ myTrihedron->AddToRender(GetDevice());
+ GetDevice()->AddProp(GetCubeAxes());
- vtkTextProperty* aTextProp = vtkTextProperty::New();
- aTextProp->SetColor(1, 1, 1);
- aTextProp->ShadowOn();
-
- float aBndBox[6];
- aBndBox[0] = aBndBox[2] = aBndBox[4] = 0;
- aBndBox[1] = aBndBox[3] = aBndBox[5] = myTrihedron->GetSize();
- myCubeAxes->SetBounds(aBndBox);
- myCubeAxes->SetCamera(this->GetActiveCamera());
+ myBndBox[0] = myBndBox[2] = myBndBox[4] = 0;
+ myBndBox[1] = myBndBox[3] = myBndBox[5] = myTrihedron->GetSize();
+
+ myCubeAxes->SetBounds(myBndBox);
+ myCubeAxes->SetCamera(GetDevice()->GetActiveCamera());
myCubeAxes->SetLabelFormat("%6.4g");
myCubeAxes->SetFlyModeToOuterEdges(); // ENK remarks: it must bee
myCubeAxes->SetFontFactor(0.8);
- myCubeAxes->SetAxisTitleTextProperty(aTextProp);
- myCubeAxes->SetAxisLabelTextProperty(aTextProp);
myCubeAxes->SetCornerOffset(0);
myCubeAxes->SetScaling(0);
myCubeAxes->SetNumberOfLabels(5);
myCubeAxes->VisibilityOff();
myCubeAxes->SetTransform(GetTransform());
- aTextProp->Delete();
- SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
- QColor aColor = aResMgr->colorValue("VTKViewer","background",QColor());
- this->SetBackground(aColor.red()/255.0,
- aColor.green()/255.0,
- aColor.blue()/255.0);
+ vtkTextProperty* aTextProp = vtkTextProperty::New();
+ aTextProp->SetColor(1, 1, 1);
+ aTextProp->ShadowOn();
+ myCubeAxes->SetAxisTitleTextProperty(aTextProp);
+ myCubeAxes->SetAxisLabelTextProperty(aTextProp);
+ aTextProp->Delete();
- this->GetActiveCamera()->ParallelProjectionOn();
- this->LightFollowCameraOn();
- this->TwoSidedLightingOn();
+ GetDevice()->GetActiveCamera()->ParallelProjectionOn();
+ GetDevice()->LightFollowCameraOn();
+ GetDevice()->TwoSidedLightingOn();
myEventCallbackCommand->SetClientData(this);
myEventCallbackCommand->SetCallback(SVTK_Renderer::ProcessEvents);
- this->AddObserver(vtkCommand::ConfigureEvent,
- myEventCallbackCommand.GetPointer(),
- myPriority);
- this->AddObserver(vtkCommand::ResetCameraEvent,
- myEventCallbackCommand.GetPointer(),
- myPriority);
- this->AddObserver(vtkCommand::ResetCameraClippingRangeEvent,
- myEventCallbackCommand.GetPointer(),
- myPriority);
+ GetDevice()->AddObserver(vtkCommand::ConfigureEvent,
+ myEventCallbackCommand.GetPointer(),
+ myPriority);
+ GetDevice()->AddObserver(vtkCommand::ResetCameraEvent,
+ myEventCallbackCommand.GetPointer(),
+ myPriority);
+ GetDevice()->AddObserver(vtkCommand::ResetCameraClippingRangeEvent,
+ myEventCallbackCommand.GetPointer(),
+ myPriority);
}
SVTK_Renderer
::~SVTK_Renderer()
-{}
+{
+ if(MYDEBUG) INFOS("~SVTK_Renderer() - "<<this);
+}
void
switch(theEvent){
case vtkCommand::ConfigureEvent:
- self->onResetView();
+ self->OnResetView();
break;
case vtkCommand::ResetCameraEvent:
- self->onFitAll();
+ self->OnFitAll();
break;
case vtkCommand::ResetCameraClippingRangeEvent:
- self->onResetClippingRange();
+ self->OnResetClippingRange();
break;
}
}
+
//----------------------------------------------------------------------------
-SVTK_CubeAxesActor2D*
+vtkRenderer*
SVTK_Renderer
-::GetCubeAxes()
+::GetDevice()
{
- return myCubeAxes.GetPointer();
+ return myDevice.GetPointer();
}
-bool
+void
SVTK_Renderer
-::isCubeAxesDisplayed()
+::SetInteractor(vtkRenderWindowInteractor* theInteractor)
{
- return myCubeAxes->GetVisibility() == 1;
+ myInteractor = theInteractor;
}
-VTKViewer_Trihedron*
+//----------------------------------------------------------------------------
+void
SVTK_Renderer
-::GetTrihedron()
+::AddActor(VTKViewer_Actor* theActor)
{
- return myTrihedron.GetPointer();
+ if(SALOME_Actor* anActor = dynamic_cast<SALOME_Actor*>(theActor))
+ anActor->AddToInteractor(myInteractor);
+ theActor->SetTransform(GetTransform());
+ theActor->AddToRender(GetDevice());
+ AdjustActors();
}
-bool
+void
SVTK_Renderer
-::isTrihedronDisplayed()
+::RemoveActor(VTKViewer_Actor* theActor)
{
- return myTrihedron->GetVisibility() == VTKViewer_Trihedron::eOn;
+ if(SALOME_Actor* anActor = dynamic_cast<SALOME_Actor*>(theActor))
+ anActor->RemoveFromInteractor(myInteractor);
+ theActor->SetTransform(NULL);
+ theActor->RemoveFromRender(GetDevice());
+ AdjustActors();
}
-int
+VTKViewer_Transform*
SVTK_Renderer
-::GetTrihedronSize() const
+::GetTransform()
{
- return myTrihedronSize;
+ return myTransform.GetPointer();
}
void
SVTK_Renderer
-::SetTrihedronSize(int theSize)
+::GetScale( double theScale[3] )
{
- if(myTrihedronSize != theSize){
- myTrihedronSize = theSize;
- AdjustTrihedrons(true);
- }
+ myTransform->GetMatrixScale( theScale );
+}
+
+void
+SVTK_Renderer
+::SetScale( double theScale[3] )
+{
+ myTransform->SetMatrixScale( theScale[0], theScale[1], theScale[2] );
+ AdjustActors();
}
return false;
}
-void
+bool
SVTK_Renderer
-::AdjustTrihedrons(const bool theIsForced)
+::OnAdjustActors()
{
- bool aTDisplayed = isTrihedronDisplayed();
- bool aCDisplayed = isCubeAxesDisplayed();
-
- if(!aCDisplayed && !aTDisplayed && !theIsForced)
- return;
-
- float aBndBox[ 6 ];
- myCubeAxes->GetBounds(aBndBox);
+ bool aTDisplayed = IsTrihedronDisplayed();
+ bool aCDisplayed = IsCubeAxesDisplayed();
float aNewBndBox[6];
aNewBndBox[ 0 ] = aNewBndBox[ 2 ] = aNewBndBox[ 4 ] = VTK_LARGE_FLOAT;
aNewBndBox[ 1 ] = aNewBndBox[ 3 ] = aNewBndBox[ 5 ] = -VTK_LARGE_FLOAT;
- int aVisibleNum = myTrihedron->GetVisibleActorCount(this);
+ int aVisibleNum = myTrihedron->GetVisibleActorCount(GetDevice());
if(aVisibleNum){
- // if the new trihedron size have sufficient difference, then apply the value
- double aNewSize = 100;
- double anOldSize = myTrihedron->GetSize();
-
if(aTDisplayed)
myTrihedron->VisibilityOff();
if(aCDisplayed)
myCubeAxes->VisibilityOff();
- static SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
- float aSizeInPercents = aResMgr->doubleValue("VTKViewer","trihedron_size", 105);
-
- ComputeTrihedronSize(this,aNewSize,anOldSize,aSizeInPercents);
-
- myTrihedron->SetSize(aNewSize);
+ // if the new trihedron size have sufficient difference, then apply the value
+ double aSize = myTrihedron->GetSize();
+ ComputeTrihedronSize(GetDevice(),aSize,aSize,myTrihedronSize);
+ myTrihedron->SetSize(aSize);
// iterate through displayed objects and set size if necessary
- vtkActorCollection* anActors = this->GetActors();
+ vtkActorCollection* anActors = GetDevice()->GetActors();
anActors->InitTraversal();
- while(vtkActor* anActor = anActors->GetNextActor()){
- if(SALOME_Actor* aSActor = SALOME_Actor::SafeDownCast( anActor )){
- if(aSActor->IsResizable())
- aSActor->SetSize(0.5 * aNewSize);
- if(aSActor->GetVisibility() && !aSActor->IsInfinitive()){
- float *aBounds = aSActor->GetBounds();
+ while(vtkActor* anAct = anActors->GetNextActor()){
+ if(SALOME_Actor* anActor = dynamic_cast<SALOME_Actor*>(anAct)){
+ if(anActor->IsResizable())
+ anActor->SetSize(0.5*aSize);
+ if(anActor->GetVisibility() && !anActor->IsInfinitive()){
+ float *aBounds = anActor->GetBounds();
if(CheckBndBox(aBounds))
for(int i = 0; i < 5; i = i + 2){
if(aBounds[i] < aNewBndBox[i])
aNewBndBox[1] = aNewBndBox[3] = aNewBndBox[5] = aSize;
}
- if(CheckBndBox(aNewBndBox))
- myCubeAxes->SetBounds(aNewBndBox);
+ if(CheckBndBox(aNewBndBox)){
+ for(int i = 0; i < 6; i++)
+ myBndBox[i] = aNewBndBox[i];
+ myCubeAxes->SetBounds(myBndBox);
+ return true;
+ }
- ::ResetCameraClippingRange(this);
+ return false;
}
-
-//----------------------------------------------------------------------------
-void
+void
SVTK_Renderer
-::onViewTrihedron()
+::AdjustActors()
{
- if(isTrihedronDisplayed())
- myTrihedron->VisibilityOff();
- else
- myTrihedron->VisibilityOn();
+ if(OnAdjustActors())
+ ::ResetCameraClippingRange(GetDevice());
}
void
SVTK_Renderer
-::onViewCubeAxes()
+::SetTrihedronSize(int theSize)
{
- if(isCubeAxesDisplayed())
- myCubeAxes->VisibilityOff();
- else
- myCubeAxes->VisibilityOn();
+ if(myTrihedronSize != theSize){
+ myTrihedronSize = theSize;
+ AdjustActors();
+ }
+}
+
+int
+SVTK_Renderer
+::GetTrihedronSize() const
+{
+ return myTrihedronSize;
}
//----------------------------------------------------------------------------
-void
+VTKViewer_Trihedron*
SVTK_Renderer
-::onAdjustTrihedron()
-{
- AdjustTrihedrons(false);
+::GetTrihedron()
+{
+ return myTrihedron.GetPointer();
}
-void
+bool
SVTK_Renderer
-::onAdjustCubeAxes()
-{
- AdjustTrihedrons(false);
+::IsTrihedronDisplayed()
+{
+ return myTrihedron->GetVisibility() == VTKViewer_Trihedron::eOn;
}
-
-//----------------------------------------------------------------------------
-VTKViewer_Transform*
+void
SVTK_Renderer
-::GetTransform()
+::OnViewTrihedron()
{
- return myTransform.GetPointer();
+ if(IsTrihedronDisplayed())
+ myTrihedron->VisibilityOff();
+ else
+ myTrihedron->VisibilityOn();
}
void
SVTK_Renderer
-::GetScale( double theScale[3] )
-{
- myTransform->GetMatrixScale( theScale );
+::OnAdjustTrihedron()
+{
+ AdjustActors();
}
-void
+
+//----------------------------------------------------------------------------
+SVTK_CubeAxesActor2D*
SVTK_Renderer
-::SetScale( double theScale[3] )
+::GetCubeAxes()
{
- myTransform->SetMatrixScale( theScale[0], theScale[1], theScale[2] );
+ return myCubeAxes.GetPointer();
}
+bool
+SVTK_Renderer
+::IsCubeAxesDisplayed()
+{
+ return myCubeAxes->GetVisibility() == 1;
+}
-//----------------------------------------------------------------------------
void
SVTK_Renderer
-::AddActor(VTKViewer_Actor* theActor)
+::OnViewCubeAxes()
{
- theActor->SetTransform(GetTransform());
- theActor->AddToRender(this);
+ if(IsCubeAxesDisplayed())
+ myCubeAxes->VisibilityOff();
+ else
+ myCubeAxes->VisibilityOn();
}
void
SVTK_Renderer
-::RemoveActor(VTKViewer_Actor* theActor)
-{
- theActor->RemoveFromRender(this);
+::OnAdjustCubeAxes()
+{
+ AdjustActors();
}
//----------------------------------------------------------------------------
void
SVTK_Renderer
-::onResetView()
+::OnResetView()
{
- int aTrihedronIsVisible = isTrihedronDisplayed();
- int aCubeAxesIsVisible = isCubeAxesDisplayed();
+ int aTrihedronIsVisible = IsTrihedronDisplayed();
+ int aCubeAxesIsVisible = IsCubeAxesDisplayed();
myTrihedron->SetVisibility( VTKViewer_Trihedron::eOnlyLineOn );
myCubeAxes->SetVisibility(0);
- ::ResetCamera(this,true);
- vtkCamera* aCamera = this->GetActiveCamera();
+ ::ResetCamera(GetDevice(),true);
+ vtkCamera* aCamera = GetDevice()->GetActiveCamera();
aCamera->SetPosition(1,-1,1);
aCamera->SetViewUp(0,0,1);
- ::ResetCamera(this,true);
+ ::ResetCamera(GetDevice(),true);
if(aTrihedronIsVisible)
myTrihedron->VisibilityOn();
//----------------------------------------------------------------------------
void
SVTK_Renderer
-::onFitAll()
+::OnFitAll()
{
int aTrihedronWasVisible = false;
int aCubeAxesWasVisible = false;
- aTrihedronWasVisible = isTrihedronDisplayed();
+ aTrihedronWasVisible = IsTrihedronDisplayed();
if(aTrihedronWasVisible)
myTrihedron->VisibilityOff();
- aCubeAxesWasVisible = isCubeAxesDisplayed();
+ aCubeAxesWasVisible = IsCubeAxesDisplayed();
if(aCubeAxesWasVisible)
myCubeAxes->VisibilityOff();
- if(myTrihedron->GetVisibleActorCount(this)){
+ if(myTrihedron->GetVisibleActorCount(GetDevice())){
myTrihedron->VisibilityOff();
myCubeAxes->VisibilityOff();
- ::ResetCamera(this);
+ ::ResetCamera(GetDevice());
}else{
myTrihedron->SetVisibility(VTKViewer_Trihedron::eOnlyLineOn);
myCubeAxes->SetVisibility(2);
- ::ResetCamera(this,true);
+ ::ResetCamera(GetDevice(),true);
}
if(aTrihedronWasVisible)
else
myCubeAxes->VisibilityOff();
- ::ResetCameraClippingRange(this);
+ ::ResetCameraClippingRange(GetDevice());
}
//----------------------------------------------------------------------------
void
SVTK_Renderer
-::onResetClippingRange()
+::OnResetClippingRange()
{
return;
- ::ResetCameraClippingRange(this);
+ ::ResetCameraClippingRange(GetDevice());
}
//----------------------------------------------------------------------------
void
SVTK_Renderer
-::onFrontView()
+::OnFrontView()
{
- vtkCamera* aCamera = this->GetActiveCamera();
+ vtkCamera* aCamera = GetDevice()->GetActiveCamera();
aCamera->SetPosition(1,0,0);
aCamera->SetViewUp(0,0,1);
aCamera->SetFocalPoint(0,0,0);
- this->onFitAll();
+ this->OnFitAll();
}
//----------------------------------------------------------------------------
void
SVTK_Renderer
-::onBackView()
+::OnBackView()
{
- vtkCamera* aCamera = this->GetActiveCamera();
+ vtkCamera* aCamera = GetDevice()->GetActiveCamera();
aCamera->SetPosition(-1,0,0);
aCamera->SetViewUp(0,0,1);
aCamera->SetFocalPoint(0,0,0);
- this->onFitAll();
+ this->OnFitAll();
}
//----------------------------------------------------------------------------
void
SVTK_Renderer
-::onTopView()
+::OnTopView()
{
- vtkCamera* aCamera = this->GetActiveCamera();
+ vtkCamera* aCamera = GetDevice()->GetActiveCamera();
aCamera->SetPosition(0,0,1);
aCamera->SetViewUp(0,1,0);
aCamera->SetFocalPoint(0,0,0);
- this->onFitAll();
+ this->OnFitAll();
}
//----------------------------------------------------------------------------
void
SVTK_Renderer
-::onBottomView()
+::OnBottomView()
{
- vtkCamera* aCamera = this->GetActiveCamera();
+ vtkCamera* aCamera = GetDevice()->GetActiveCamera();
aCamera->SetPosition(0,0,-1);
aCamera->SetViewUp(0,1,0);
aCamera->SetFocalPoint(0,0,0);
- this->onFitAll();
+ this->OnFitAll();
}
//----------------------------------------------------------------------------
void
SVTK_Renderer
-::onLeftView()
+::OnLeftView()
{
- vtkCamera* aCamera = this->GetActiveCamera();
+ vtkCamera* aCamera = GetDevice()->GetActiveCamera();
aCamera->SetPosition(0,-1,0);
aCamera->SetViewUp(0,0,1);
aCamera->SetFocalPoint(0,0,0);
- this->onFitAll();
+ this->OnFitAll();
}
//----------------------------------------------------------------------------
void
SVTK_Renderer
-::onRightView()
+::OnRightView()
{
- vtkCamera* aCamera = this->GetActiveCamera();
+ vtkCamera* aCamera = GetDevice()->GetActiveCamera();
aCamera->SetPosition(0,1,0);
aCamera->SetViewUp(0,0,1);
aCamera->SetFocalPoint(0,0,0);
- this->onFitAll();
+ this->OnFitAll();
}
//
//
//
-// File : VTKViewer_RenderWindow.h
-// Author : Nicolas REJNERI
+// File :
+// Author :
// Module : SALOME
// $Header$
#include "SVTK.h"
+#include <vtkObject.h>
#include <vtkSmartPointer.h>
-#ifndef VTK_IMPLEMENT_MESA_CXX
-#include <vtkOpenGLRenderer.h>
-#define SVTK_RENDERER_SUPERCLASS vtkOpenGLRenderer
-#else
-#include <vtkMesaRenderer.h>
-#define SVTK_RENDERER_SUPERCLASS vtkMesaRenderer
-#endif
-
+class vtkRenderer;
class vtkCallbackCommand;
+class vtkRenderWindowInteractor;
class VTKViewer_Trihedron;
class VTKViewer_Transform;
class SVTK_CubeAxesActor2D;
class VTKViewer_Actor;
-class SVTK_EXPORT SVTK_Renderer : public SVTK_RENDERER_SUPERCLASS
+class SVTK_EXPORT SVTK_Renderer : public vtkObject
{
+ public:
+ vtkTypeMacro(SVTK_Renderer,vtkObject);
+ static SVTK_Renderer* New();
+
+ //----------------------------------------------------------------------------
+ vtkRenderer*
+ GetDevice();
+
+ virtual
+ void
+ SetInteractor(vtkRenderWindowInteractor* theInteractor);
+
+ //----------------------------------------------------------------------------
+ virtual
+ void
+ AddActor(VTKViewer_Actor* theActor);
+
+ virtual
+ void
+ RemoveActor(VTKViewer_Actor* theActor);
+
+ VTKViewer_Transform*
+ GetTransform();
+
+ virtual
+ void
+ SetScale( double theScale[3] );
+
+ void
+ GetScale( double theScale[3] );
+
+ //----------------------------------------------------------------------------
+ void
+ AdjustActors();
+
+ void
+ SetTrihedronSize(int theSize);
+
+ int
+ GetTrihedronSize() const;
+
+ //----------------------------------------------------------------------------
+ VTKViewer_Trihedron*
+ GetTrihedron();
+
+ bool
+ IsTrihedronDisplayed();
+
+ void
+ OnViewTrihedron();
+
+ void
+ OnAdjustTrihedron();
+
+ //----------------------------------------------------------------------------
+ SVTK_CubeAxesActor2D*
+ GetCubeAxes();
+
+ bool
+ IsCubeAxesDisplayed();
+
+ void
+ OnViewCubeAxes();
+
+ void
+ OnAdjustCubeAxes();
+
+ //----------------------------------------------------------------------------
+ void OnFitAll();
+ void OnResetView();
+ void OnResetClippingRange();
+
+ void OnFrontView();
+ void OnBackView();
+ void OnTopView();
+ void OnBottomView();
+ void OnRightView();
+ void OnLeftView();
+
protected:
SVTK_Renderer();
~SVTK_Renderer();
- vtkSmartPointer<VTKViewer_Transform> myTransform;
- vtkSmartPointer<SVTK_CubeAxesActor2D> myCubeAxes;
- vtkSmartPointer<VTKViewer_Trihedron> myTrihedron;
- int myTrihedronSize;
+ virtual
+ bool
+ OnAdjustActors();
// Priority at which events are processed
float myPriority;
void* clientdata,
void* calldata);
- public:
- vtkTypeMacro(SVTK_Renderer,SVTK_RENDERER_SUPERCLASS);
- static SVTK_Renderer* New();
-
- VTKViewer_Trihedron* GetTrihedron();
- SVTK_CubeAxesActor2D* GetCubeAxes();
-
- bool isTrihedronDisplayed();
- bool isCubeAxesDisplayed();
+ vtkSmartPointer<vtkRenderer> myDevice;
+ vtkRenderWindowInteractor* myInteractor;
- int GetTrihedronSize() const;
- void SetTrihedronSize(int theSize);
- void AdjustTrihedrons(bool theIsForced);
-
- void onViewTrihedron();
- void onViewCubeAxes();
-
- void onAdjustTrihedron();
- void onAdjustCubeAxes();
-
- VTKViewer_Transform* GetTransform();
- void SetScale( double theScale[3] );
- void GetScale( double theScale[3] );
-
- void AddActor(VTKViewer_Actor* theActor);
- void RemoveActor(VTKViewer_Actor* theActor);
-
- void onFitAll();
- void onResetView();
- void onResetClippingRange();
-
- void onFrontView();
- void onBackView();
- void onTopView();
- void onBottomView();
- void onRightView();
- void onLeftView();
+ vtkSmartPointer<VTKViewer_Transform> myTransform;
+ vtkSmartPointer<SVTK_CubeAxesActor2D> myCubeAxes;
+ vtkSmartPointer<VTKViewer_Trihedron> myTrihedron;
+ int myTrihedronSize;
+ float myBndBox[6];
};
#endif
+// 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
+//
+//
+//
+// File :
+// Author :
+// Module : SALOME
+// $Header$
+
#include "SALOME_Actor.h"
#include <qapplication.h>
#include <qpushbutton.h>
+#include <vtkGenericRenderWindowInteractor.h>
#include <vtkCallbackCommand.h>
#include <vtkTextProperty.h>
#include <vtkActorCollection.h>
#include "VTKViewer_Algorithm.h"
#include "SVTK_Functor.h"
+#include "utilities.h"
+
+#ifdef _DEBUG_
+static int MYDEBUG = 1;
+#else
+static int MYDEBUG = 0;
+#endif
+
//----------------------------------------------------------------------------
SVTK_MainWindow
SUIT_ResourceMgr* theResourceMgr) :
QMainWindow(theParent,theName,0)
{
+ if(MYDEBUG) INFOS("SVTK_MainWindow() - "<<this);
+
myToolBar = new QToolBar(this);
myToolBar->setCloseMode(QDockWindow::Undocked);
myToolBar->setLabel(tr("LBL_TOOLBAR_LABEL"));
void
SVTK_MainWindow
-::Initialize()
+::Initialize(SVTK_Renderer *theRenderer)
{
SetInteractor(new SVTK_RenderWindowInteractor(this,"SVTK_RenderWindowInteractor"));
- SVTK_Renderer* aRenderer = SVTK_Renderer::New();
- GetInteractor()->SetRenderer(aRenderer);
- aRenderer->Delete();
-
SVTK_InteractorStyle* aStyle = SVTK_InteractorStyle::New();
GetInteractor()->PushInteractorStyle(aStyle);
aStyle->Delete();
+
+ GetInteractor()->SetRenderer(theRenderer);
+}
+
+void
+SVTK_MainWindow
+::Initialize()
+{
+ SVTK_Renderer* aRenderer = SVTK_Renderer::New();
+ Initialize(aRenderer);
+ aRenderer->Delete();
}
//----------------------------------------------------------------------------
SVTK_MainWindow
::~SVTK_MainWindow()
-{}
+{
+ if(MYDEBUG) INFOS("~SVTK_MainWindow() - "<<this);
+}
//----------------------------------------------------------------------------
::Repaint(bool theUpdateTrihedron)
{
if(theUpdateTrihedron)
- GetRenderer()->onAdjustTrihedron();
+ GetRenderer()->OnAdjustTrihedron();
GetInteractor()->update();
}
}
//----------------------------------------------------------------------------
-SVTK_InteractorStyle*
+vtkInteractorStyle*
SVTK_MainWindow
::GetInteractorStyle()
{
void
SVTK_MainWindow
-::PushInteractorStyle(SVTK_InteractorStyle* theStyle)
+::PushInteractorStyle(vtkInteractorStyle* theStyle)
{
GetInteractor()->PushInteractorStyle(theStyle);
}
SVTK_MainWindow
::SetBackgroundColor(const QColor& theColor)
{
- GetRenderer()->SetBackground(theColor.red()/255.0,
+ getRenderer()->SetBackground(theColor.red()/255.0,
theColor.green()/255.0,
theColor.blue()/255.0);
}
::BackgroundColor()
{
float aBackgroundColor[3];
- GetRenderer()->GetBackground(aBackgroundColor);
+ getRenderer()->GetBackground(aBackgroundColor);
return QColor(int(aBackgroundColor[0]*255),
int(aBackgroundColor[1]*255),
int(aBackgroundColor[2]*255));
*/
void
SVTK_MainWindow
-::AdjustTrihedrons(const bool theIsForced)
+::AdjustActors()
{
- GetRenderer()->AdjustTrihedrons(theIsForced);
+ GetRenderer()->AdjustActors();
Repaint();
}
SVTK_MainWindow
::IsTrihedronDisplayed()
{
- return GetRenderer()->isTrihedronDisplayed();
+ return GetRenderer()->IsTrihedronDisplayed();
}
//----------------------------------------------------------------------------
SVTK_MainWindow
::IsCubeAxesDisplayed()
{
- return GetRenderer()->isCubeAxesDisplayed();
+ return GetRenderer()->IsCubeAxesDisplayed();
}
//----------------------------------------------------------------------------
SVTK_MainWindow
::onFrontView()
{
- GetRenderer()->onFrontView();
+ GetRenderer()->OnFrontView();
}
//----------------------------------------------------------------------------
SVTK_MainWindow
::onBackView()
{
- GetRenderer()->onBackView();
+ GetRenderer()->OnBackView();
}
//----------------------------------------------------------------------------
SVTK_MainWindow
::onTopView()
{
- GetRenderer()->onTopView();
+ GetRenderer()->OnTopView();
}
//----------------------------------------------------------------------------
SVTK_MainWindow
::onBottomView()
{
- GetRenderer()->onBottomView();
+ GetRenderer()->OnBottomView();
}
//----------------------------------------------------------------------------
SVTK_MainWindow
::onLeftView()
{
- GetRenderer()->onLeftView();
+ GetRenderer()->OnLeftView();
}
//----------------------------------------------------------------------------
SVTK_MainWindow
::onRightView()
{
- GetRenderer()->onRightView();
+ GetRenderer()->OnRightView();
}
//----------------------------------------------------------------------------
SVTK_MainWindow
::onResetView()
{
- GetRenderer()->onResetView();
+ GetRenderer()->OnResetView();
Repaint();
}
SVTK_MainWindow
::onFitAll()
{
- GetRenderer()->onFitAll();
+ GetRenderer()->OnFitAll();
Repaint();
}
SVTK_MainWindow
::onViewTrihedron()
{
- GetRenderer()->onViewTrihedron();
+ GetRenderer()->OnViewTrihedron();
Repaint();
}
SVTK_MainWindow
::onViewCubeAxes()
{
- GetRenderer()->onViewCubeAxes();
+ GetRenderer()->OnViewCubeAxes();
Repaint();
}
SVTK_MainWindow
::onAdjustTrihedron()
{
- GetRenderer()->onAdjustTrihedron();
+ GetRenderer()->OnAdjustTrihedron();
}
//----------------------------------------------------------------------------
SVTK_MainWindow
::onAdjustCubeAxes()
{
- GetRenderer()->onAdjustCubeAxes();
+ GetRenderer()->OnAdjustCubeAxes();
}
//----------------------------------------------------------------------------
QObject(theMainWindow),
myMainWindow(theMainWindow)
{
+ if(MYDEBUG) INFOS("SVTK_SignalHandler() - "<<this);
+
SVTK_RenderWindowInteractor* anInteractor = theMainWindow->GetInteractor();
connect(anInteractor,SIGNAL(KeyPressed(QKeyEvent*)),
SVTK_SignalHandler
::~SVTK_SignalHandler()
-{}
+{
+ if(MYDEBUG) INFOS("~SVTK_SignalHandler() - "<<this);
+}
SVTK_MainWindow*
SVTK_SignalHandler
SVTK_SignalHandler
::getRenderer()
{
- return myMainWindow->GetRenderer();
+ return myMainWindow->getRenderer();
}
//----------------------------------------------------------------
SVTK_SignalHandler
::onSelectionChanged()
{
- vtkActorCollection* anActors = myMainWindow->GetRenderer()->GetActors();
+ vtkActorCollection* anActors = myMainWindow->getRenderer()->GetActors();
using namespace VTK;
ForEach<SALOME_Actor>(anActors,
SVTK_View
::SVTK_View(SVTK_MainWindow* theMainWindow) :
SVTK_SignalHandler(theMainWindow)
-{}
+{
+ if(MYDEBUG) INFOS("SVTK_View() - "<<this);
+}
//----------------------------------------------------------------------------
SVTK_View
::~SVTK_View()
-{}
+{
+ if(MYDEBUG) INFOS("~SVTK_View() - "<<this);
+}
//----------------------------------------------------------------
void
::unHighlightAll()
{
using namespace VTK;
- ForEach<SALOME_Actor>(GetRenderer()->GetActors(),
+ ForEach<SALOME_Actor>(getRenderer()->GetActors(),
THighlightAction( false ));
Repaint();
{
using namespace VTK;
SVTK_Selector* aSelector = myMainWindow->GetSelector();
- ForEachIf<SALOME_Actor>(GetRenderer()->GetActors(),
+ ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
TIsSameIObject<SALOME_Actor>( theIO ),
THighlightAction( theIsHighlight, aSelector->SelectionMode() ));
const double& theBlue,
const int& theWidth)
{
- vtkActorCollection* anActors = GetRenderer()->GetActors();
+ vtkActorCollection* anActors = getRenderer()->GetActors();
anActors->InitTraversal();
while( vtkActor* anActor = anActors->GetNextActor() )
{
::SetSelectionTolerance(const double& theTolNodes,
const double& theTolItems)
{
- vtkActorCollection* anActors = GetRenderer()->GetActors();
+ vtkActorCollection* anActors = getRenderer()->GetActors();
anActors->InitTraversal();
while( vtkActor* anActor = anActors->GetNextActor() )
{
{
using namespace VTK;
SALOME_Actor* anActor =
- Find<SALOME_Actor>(GetRenderer()->GetActors(),
+ Find<SALOME_Actor>(getRenderer()->GetActors(),
TIsSameIObject<SALOME_Actor>(theIObject));
return anActor != NULL;
}
{
using namespace VTK;
SALOME_Actor* anActor =
- Find<SALOME_Actor>(GetRenderer()->GetActors(),
+ Find<SALOME_Actor>(getRenderer()->GetActors(),
TIsSameIObject<SALOME_Actor>(theIObject));
return anActor != NULL && anActor->GetVisibility();
}
const QString& theName)
{
using namespace VTK;
- ForEachIf<SALOME_Actor>(GetRenderer()->GetActors(),
+ ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
TIsSameIObject<SALOME_Actor>(theIObject),
TSetFunction<SALOME_Actor,const char*,QString>
(&SALOME_Actor::setName,theName.latin1()));
int theMode)
{
using namespace VTK;
- ForEachIf<SALOME_Actor>(GetRenderer()->GetActors(),
+ ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
TIsSameIObject<SALOME_Actor>(theIObject),
TSetFunction<SALOME_Actor,int>
(&SALOME_Actor::setDisplayMode,theMode));
SVTK_View
::ChangeRepresentationToWireframe()
{
- ChangeRepresentationToWireframe(GetRenderer()->GetActors());
+ ChangeRepresentationToWireframe(getRenderer()->GetActors());
}
void
SVTK_View
::ChangeRepresentationToSurface()
{
- ChangeRepresentationToSurface(GetRenderer()->GetActors());
+ ChangeRepresentationToSurface(getRenderer()->GetActors());
}
::EraseAll()
{
using namespace VTK;
- ForEach<SALOME_Actor>(GetRenderer()->GetActors(),
+ ForEach<SALOME_Actor>(getRenderer()->GetActors(),
TErase());
Repaint();
}
::DisplayAll()
{
using namespace VTK;
- ForEach<SALOME_Actor>(GetRenderer()->GetActors(),
+ ForEach<SALOME_Actor>(getRenderer()->GetActors(),
TSetVisibility<SALOME_Actor>(true));
Repaint();
}
bool theIsUpdate)
{
using namespace VTK;
- ForEachIf<SALOME_Actor>(GetRenderer()->GetActors(),
+ ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
TIsSameIObject<SALOME_Actor>(theIObject),
TErase());
if(theIsUpdate)
bool theIsUpdate)
{
using namespace VTK;
- ForEachIf<SALOME_Actor>(GetRenderer()->GetActors(),
+ ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
TIsSameIObject<SALOME_Actor>(theIObject),
TSetVisibility<SALOME_Actor>(true));
//----------------------------------------------------------------------------
struct TRemoveAction
{
- vtkRenderer* myRen;
- TRemoveAction(vtkRenderer* theRen): myRen(theRen){}
- void operator()(SALOME_Actor* theActor){
- myRen->RemoveActor(theActor);
+ SVTK_Renderer* myRenderer;
+ TRemoveAction(SVTK_Renderer* theRenderer):
+ myRenderer(theRenderer)
+ {}
+ void
+ operator()(SALOME_Actor* theActor)
+ {
+ myRenderer->RemoveActor(theActor);
}
};
bool theIsUpdate)
{
using namespace VTK;
- ForEachIf<SALOME_Actor>(GetRenderer()->GetActors(),
+ ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
TIsSameIObject<SALOME_Actor>(theIObject),
TRemoveAction(GetRenderer()));
if(theIsUpdate)
::Remove(SALOME_Actor* theActor,
bool theIsUpdate)
{
- GetRenderer()->RemoveProp(theActor);
+ GetRenderer()->RemoveActor(theActor);
if(theIsUpdate)
Repaint();
}
SVTK_View
::RemoveAll(bool theIsUpdate)
{
- vtkRenderer* aRenderer = GetRenderer();
+ vtkRenderer* aRenderer = getRenderer();
if(vtkActorCollection* anActors = aRenderer->GetActors()){
anActors->InitTraversal();
while(vtkActor *anAct = anActors->GetNextActor()){
{
using namespace VTK;
SALOME_Actor* anActor =
- Find<SALOME_Actor>(GetRenderer()->GetActors(),
+ Find<SALOME_Actor>(getRenderer()->GetActors(),
TIsSameIObject<SALOME_Actor>(theIObject));
if(anActor)
return 1.0 - anActor->GetOpacity();
{
float anOpacity = 1.0 - theTrans;
using namespace VTK;
- ForEachIf<SALOME_Actor>(GetRenderer()->GetActors(),
+ ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
TIsSameIObject<SALOME_Actor>(theIObject),
TSetFunction<SALOME_Actor,float>
(&SALOME_Actor::SetOpacity,anOpacity));
float aColor[3] = {theColor.red()/255., theColor.green()/255., theColor.blue()/255.};
using namespace VTK;
- ForEachIf<SALOME_Actor>(GetRenderer()->GetActors(),
+ ForEachIf<SALOME_Actor>(getRenderer()->GetActors(),
TIsSameIObject<SALOME_Actor>(theIObject),
TSetFunction<SALOME_Actor,const float*>
(&SALOME_Actor::SetColor,aColor));
{
using namespace VTK;
SALOME_Actor* anActor =
- Find<SALOME_Actor>(GetRenderer()->GetActors(),
+ Find<SALOME_Actor>(getRenderer()->GetActors(),
TIsSameIObject<SALOME_Actor>(theIObject));
if(anActor){
float r,g,b;
class vtkRenderer;
class vtkRenderWindow;
+class vtkInteractorStyle;
class vtkRenderWindowInteractor;
class vtkObject;
class SVTK_Renderer;
class SVTK_RenderWindow;
-class SVTK_InteractorStyle;
class SVTK_RenderWindowInteractor;
class SALOME_Actor;
const char* theName,
SUIT_ResourceMgr* theResourceMgr);
+ virtual
+ void
+ Initialize(SVTK_Renderer *theRenderer);
+
virtual
void
Initialize();
InvokeEvent(unsigned long theEvent, void* theCallData);
//----------------------------------------------------------------------------
- SVTK_InteractorStyle*
+ vtkInteractorStyle*
GetInteractorStyle();
void
- PushInteractorStyle(SVTK_InteractorStyle* theStyle);
+ PushInteractorStyle(vtkInteractorStyle* theStyle);
void
PopInteractorStyle();
void
AddActor(VTKViewer_Actor* theActor,
bool theIsUpdate = false);
+
void
RemoveActor(VTKViewer_Actor* theActor,
bool theIsUpdate = false);
SetTrihedronSize(const int theSize);
void
- AdjustTrihedrons(const bool theIsForced);
+ AdjustActors();
bool
IsTrihedronDisplayed();
//----------------------------------------------------------------------------
SVTK_ViewWindow
::SVTK_ViewWindow(SUIT_Desktop* theDesktop):
- SUIT_ViewWindow(theDesktop)
+ SUIT_ViewWindow(theDesktop),
+ myMainWindow(NULL),
+ myView(NULL)
{}
void
SVTK_ViewWindow
::AdjustTrihedrons(const bool theIsForcedUpdate)
{
- myMainWindow->AdjustTrihedrons( theIsForcedUpdate );
+ myMainWindow->AdjustActors();
}
//----------------------------------------------------------------------------
void Repaint() { Repaint(true); }
//apply existing transformation on adding SALOME_Actor
- void SetScale( double theScale[3] );
- void GetScale( double theScale[3] );
- void AddActor( VTKViewer_Actor*, bool update = false );
- void RemoveActor(VTKViewer_Actor*, bool update = false);
+ virtual
+ void
+ SetScale( double theScale[3] );
+
+ virtual
+ void
+ GetScale( double theScale[3] );
+
+ virtual
+ void
+ AddActor(VTKViewer_Actor* theActor,
+ bool theIsUpdate = false);
+
+ virtual
+ void
+ RemoveActor(VTKViewer_Actor* theActor,
+ bool theIsUpdate = false);
void AdjustTrihedrons( const bool forced );
- VTKViewer_Trihedron* GetTrihedron();
- SVTK_CubeAxesActor2D* GetCubeAxes();
+ VTKViewer_Trihedron*
+ GetTrihedron();
+
+ SVTK_CubeAxesActor2D*
+ GetCubeAxes();
- int GetTrihedronSize() const;
- void SetTrihedronSize( const int );
+ int
+ GetTrihedronSize() const;
+
+ void
+ SetTrihedronSize( const int );
void SetSelectionProp(const double& theRed = 1,
const double& theGreen = 1,
void onBottomView();
void onRightView();
void onLeftView();
- void onResetView();
- void onFitAll();
+
+ virtual
+ void
+ onResetView();
+
+ virtual
+ void
+ onFitAll();
void onViewTrihedron();
void onViewCubeAxes();