#include <vtkPolyDataMapper.h>
#include <vtkProperty.h>
#include <vtkOutlineSource.h>
+
#include <vtkInteractorStyle.h>
+#include <vtkRenderWindowInteractor.h>
#include <TColStd_MapOfInteger.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
//----------------------------------------------------------------------------
SALOME_Actor
-::SALOME_Actor()
+::SALOME_Actor():
+ myRenderer(NULL),
+ myInteractor(NULL),
+ mySelectionMode(ActorSelection),
+ myIsHighlighted(false),
+ myIsPreselected(false),
+ myRepresentation(VTK_WIREFRAME),
+ myDisplayMode(0),
+ myProperty(vtkProperty::New()),
+ PreviewProperty(NULL),
+ myIsInfinite(false),
+ myIsResolveCoincidentTopology(true),
+ myStoreMapping(false),
+ myGeomFilter(VTKViewer_GeometryFilter::New()),
+ myTransformFilter(VTKViewer_TransformFilter::New())
{
- mySelectionMode = ActorSelection;
- myIsHighlighted = myIsPreselected = false;
-
- myRepresentation = 1;
- myDisplayMode = myRepresentation - 1;
-
- myProperty = vtkProperty::New();
- PreviewProperty = NULL;
-
- myIsInfinite = false;
-
- myIsResolveCoincidentTopology = true;
-
vtkMapper::GetResolveCoincidentTopologyPolygonOffsetParameters(myPolygonOffsetFactor,
myPolygonOffsetUnits);
- myStoreMapping = false;
- myGeomFilter = VTKViewer_GeometryFilter::New();
-
- myTransformFilter = VTKViewer_TransformFilter::New();
for(int i = 0; i < 6; i++)
myPassFilter.push_back(VTKViewer_PassThroughFilter::New());
SALOME_Actor
::AddToRender(vtkRenderer* theRenderer)
{
+ myRenderer = theRenderer;
+
theRenderer->AddActor(this);
- // from VISU
theRenderer->AddActor( myPreHighlightActor );
theRenderer->AddActor( myHighlightActor );
theRenderer->AddActor( myOutlineActor );
{
theRenderer->RemoveActor(this);
- // from VISU
theRenderer->RemoveActor( myPreHighlightActor );
theRenderer->RemoveActor( myHighlightActor );
theRenderer->RemoveActor( myOutlineActor );
}
+vtkRenderer*
+SALOME_Actor
+::GetRenderer()
+{
+ return myRenderer;
+}
+
+
+//----------------------------------------------------------------------------
void
SALOME_Actor
-::AddToInteractor(vtkRenderWindowInteractor* theInteractor)
-{}
+::SetInteractor(vtkRenderWindowInteractor* theInteractor)
+{
+ myInteractor = theInteractor;
+}
void
SALOME_Actor
-::RemoveFromInteractor(vtkRenderWindowInteractor* theInteractor)
-{}
+::Update()
+{
+ myInteractor->CreateTimer(VTKI_TIMER_UPDATE);
+}
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
virtual
void
- AddToRender( vtkRenderer* );
+ AddToRender(vtkRenderer* theRendere);
virtual
void
- RemoveFromRender( vtkRenderer* );
+ RemoveFromRender(vtkRenderer* theRendere);
+ vtkRenderer*
+ GetRenderer();
+
+ //----------------------------------------------------------------------------
virtual
void
- AddToInteractor(vtkRenderWindowInteractor* theInteractor);
+ SetInteractor(vtkRenderWindowInteractor* theInteractor);
virtual
void
- RemoveFromInteractor(vtkRenderWindowInteractor* theInteractor);
+ Update();
//----------------------------------------------------------------------------
virtual
}
protected:
+ vtkRenderWindowInteractor* myInteractor;
+ vtkRenderer* myRenderer;
+
bool myIsResolveCoincidentTopology;
float myPolygonOffsetFactor;
float myPolygonOffsetUnits;
vtkProperty *PreviewProperty;
bool myIsPreselected;
bool myIsHighlighted;
- int mySelectionMode;
+ Selection_Mode mySelectionMode;
float myOpacity;
int myDisplayMode;
// Module :
// $Header$
+#include "SVTK.h"
+#include "SVTK_Prs.h"
+#include "SVTK_Actor.h"
+#include "SALOME_Actor.h"
+#include "SVTK_CubeAxesActor2D.h"
+#include "SVTK_Functor.h"
+#include "SVTK_View.h"
+#include "SVTK_ViewManager.h"
+#include "SVTK_ViewModel.h"
+#include "SVTK_ViewWindow.h"
+#include "SVTK_Renderer.h"
+#include "SVTK_InteractorStyle.h"
+#include "SVTK_RenderWindowInteractor.h"
+#include "SVTK_GenericRenderWindowInteractor.h"
+#include "SVTK_Selector.h"
+#include "SVTK_Selection.h"
+#include "SVTK_SelectionEvent.h"
+#include "SVTK_SpaceMouse.h"
+#include "SVTK_Event.h"
+#include "SVTK_ViewModelBase.h"
+
int
main(int argc, char** argv)
{
::AddActor(VTKViewer_Actor* theActor)
{
if(SALOME_Actor* anActor = dynamic_cast<SALOME_Actor*>(theActor))
- anActor->AddToInteractor(myInteractor);
+ anActor->SetInteractor(myInteractor);
theActor->SetTransform(GetTransform());
theActor->AddToRender(GetDevice());
AdjustActors();
SVTK_Renderer
::RemoveActor(VTKViewer_Actor* theActor)
{
- if(SALOME_Actor* anActor = dynamic_cast<SALOME_Actor*>(theActor))
- anActor->RemoveFromInteractor(myInteractor);
theActor->SetTransform(NULL);
theActor->RemoveFromRender(GetDevice());
AdjustActors();
::Display(SALOME_Actor* theActor,
bool theIsUpdate)
{
- GetRenderer()->AddActor(theActor);
+ if(!isInViewer(theActor->getIO()))
+ GetRenderer()->AddActor(theActor);
+
theActor->SetVisibility(true);
if(theIsUpdate)
Repaint();
}
-
void
SVTK_View
::Display(const Handle(SALOME_InteractiveObject)& theIObject,
Repaint();
}
+void
+SVTK_View
+::DisplayOnly(const Handle(SALOME_InteractiveObject)& theIObject)
+{
+ EraseAll();
+ Display(theIObject);
+}
+
+
//----------------------------------------------------------------------------
struct TRemoveAction
{
//----------------------------------------------------------------
void
SVTK_ViewWindow
-::highlight( const Handle(SALOME_InteractiveObject)& theIO,
- bool theIsHighlight,
- bool theIsUpdate )
+::highlight(const Handle(SALOME_InteractiveObject)& theIO,
+ bool theIsHighlight,
+ bool theIsUpdate )
{
myView->highlight( theIO, theIsHighlight, theIsUpdate );
}
}
//----------------------------------------------------------------
-bool
+void
+SVTK_ViewWindow
+::Display(const Handle(SALOME_InteractiveObject)& theIO,
+ bool theImmediatly)
+{
+ myView->Display(theIO,theImmediatly);
+}
+
+void
+SVTK_ViewWindow
+::Erase(const Handle(SALOME_InteractiveObject)& theIO,
+ bool theImmediatly)
+{
+ myView->Erase(theIO,theImmediatly);
+}
+
+void
+SVTK_ViewWindow
+::DisplayOnly(const Handle(SALOME_InteractiveObject)& theIO)
+{
+ myView->DisplayOnly(theIO);
+}
+
+void
+SVTK_ViewWindow
+::DisplayAll()
+{
+ myView->DisplayAll();
+}
+
+void
SVTK_ViewWindow
-::isVisible( const Handle(SALOME_InteractiveObject)& theIO )
+::EraseAll()
{
- return myView->isVisible( theIO );
+ myView->EraseAll();
}
//----------------------------------------------------------------------------
Selection_Mode
SelectionMode() const;
+ virtual
void
SetSelectionMode(Selection_Mode theMode);
- void setBackgroundColor( const QColor& );
- QColor backgroundColor() const;
+ virtual
+ void
+ setBackgroundColor( const QColor& );
+
+ QColor
+ backgroundColor() const;
+
+ bool
+ isTrihedronDisplayed();
- bool isTrihedronDisplayed();
- bool isCubeAxesDisplayed();
+ bool
+ isCubeAxesDisplayed();
/* interactive object management */
- void highlight( const Handle(SALOME_InteractiveObject)& IObject,
- bool highlight, bool immediatly = true );
- void unHighlightAll();
- bool isInViewer( const Handle(SALOME_InteractiveObject)& IObject );
- bool isVisible( const Handle(SALOME_InteractiveObject)& IObject );
+ virtual
+ void
+ highlight(const Handle(SALOME_InteractiveObject)& theIO,
+ bool theIsHighlight = true,
+ bool theIsUpdate = true);
+ virtual
+ void
+ unHighlightAll();
+
+ bool
+ isInViewer(const Handle(SALOME_InteractiveObject)& theIObject);
+
+ bool
+ isVisible(const Handle(SALOME_InteractiveObject)& theIObject);
/* selection */
- Handle(SALOME_InteractiveObject) FindIObject(const char* Entry);
+ //----------------------------------------------------------------------------
+ Handle(SALOME_InteractiveObject)
+ FindIObject(const char* theEntry);
/* display */
- void Display( const Handle(SALOME_InteractiveObject)& IObject,
- bool immediatly = true );
- void DisplayOnly( const Handle(SALOME_InteractiveObject)& IObject );
- void Erase( const Handle(SALOME_InteractiveObject)& IObject,
- bool immediatly = true );
- void DisplayAll();
- void EraseAll();
- void Repaint( bool theUpdateTrihedron );
- void Repaint() { Repaint(true); }
-
- //apply existing transformation on adding SALOME_Actor
+ //----------------------------------------------------------------------------
+ virtual
+ void
+ Display(const Handle(SALOME_InteractiveObject)& theIObject,
+ bool theImmediatly = true);
+
+ virtual
+ void
+ DisplayOnly(const Handle(SALOME_InteractiveObject)& theIObject);
+
+ virtual
+ void
+ Erase(const Handle(SALOME_InteractiveObject)& theIObject,
+ bool theImmediatly = true);
+
+ virtual
+ void
+ DisplayAll();
+
+ virtual
+ void
+ EraseAll();
+
+ virtual
+ void
+ Repaint(bool theUpdateTrihedron = true);
+
+ //----------------------------------------------------------------------------
virtual
void
SetScale( double theScale[3] );
RemoveActor(VTKViewer_Actor* theActor,
bool theIsUpdate = false);
- void AdjustTrihedrons( const bool forced );
+ //----------------------------------------------------------------------------
+ virtual
+ void
+ AdjustTrihedrons(const bool theIsForced);
VTKViewer_Trihedron*
GetTrihedron();
int
GetTrihedronSize() const;
+ virtual
void
SetTrihedronSize( const int );
- void SetSelectionProp(const double& theRed = 1,
- const double& theGreen = 1,
- const double& theBlue = 0,
- const int& theWidth = 5);
- void SetSelectionTolerance(const double& theTolNodes = 0.025,
- const double& theTolCell = 0.001);
+ virtual
+ void
+ SetSelectionProp(const double& theRed = 1,
+ const double& theGreen = 1,
+ const double& theBlue = 0,
+ const int& theWidth = 5);
+ virtual
+ void
+ SetSelectionTolerance(const double& theTolNodes = 0.025,
+ const double& theTolCell = 0.001);
+
public slots:
- void onSelectionChanged();
+ virtual
+ void
+ onSelectionChanged();
signals:
void selectionChanged();
public slots:
- void onFrontView();
- void onBackView();
- void onTopView();
- void onBottomView();
- void onRightView();
- void onLeftView();
+ virtual
+ void
+ onFrontView();
+
+ virtual
+ void
+ onBackView();
+
+ virtual
+ void
+ onTopView();
+
+ virtual
+ void
+ onBottomView();
+
+ virtual
+ void
+ onRightView();
+
+ virtual
+ void
+ onLeftView();
virtual
void
void
onFitAll();
- void onViewTrihedron();
- void onViewCubeAxes();
+ virtual
+ void
+ onViewTrihedron();
+
+ virtual
+ void
+ onViewCubeAxes();
+
+ virtual
+ void
+ onAdjustTrihedron();
- void onAdjustTrihedron();
- void onAdjustCubeAxes();
+ virtual
+ void
+ onAdjustCubeAxes();
protected slots:
void onKeyPressed(QKeyEvent* event);