SVTK_InteractorStyle
::GetSelector()
{
- return myViewWindow->GetSelector();
+ return mySelector.GetPointer();
}
//----------------------------------------------------------------------------
aSelectionEvent.myY = h - y - 1;
aSelectionEvent.myIsCtrl = Interactor->GetControlKey();
aSelectionEvent.myIsShift = Interactor->GetShiftKey();
+ aSelectionEvent.mySelectionMode = GetSelector()->SelectionMode();
return aSelectionEvent;
}
myViewWindow = theViewWindow;
}
+//----------------------------------------------------------------------------
+void
+SVTK_InteractorStyle
+::SetSelector( SVTK_Selector* theSelector )
+{
+ mySelector = theSelector;
+}
+
//----------------------------------------------------------------------------
void
SVTK_InteractorStyle
cam->Elevation(ryf);
cam->OrthogonalizeViewUp();
::ResetCameraClippingRange(this->CurrentRenderer);
- this->Interactor->CreateTimer(VTKI_TIMER_FIRST);
+ this->Render();
}
//----------------------------------------------------------------------------
::PanXY(int x, int y, int oldX, int oldY)
{
TranslateView(x, y, oldX, oldY);
- this->Interactor->CreateTimer(VTKI_TIMER_FIRST);
+ this->Render();
}
::ResetCameraClippingRange(this->CurrentRenderer);
}
- this->Interactor->CreateTimer(VTKI_TIMER_FIRST);
+ this->Render();
}
//----------------------------------------------------------------------------
cam->Roll(newAngle - oldAngle);
cam->OrthogonalizeViewUp();
- this->Interactor->CreateTimer(VTKI_TIMER_FIRST);
+ this->Render();
}
if (myViewWindow) myViewWindow->onFitAll();
- this->Interactor->CreateTimer(VTKI_TIMER_FIRST);
+ this->Render();
qApp->installEventFilter(this);
}
::ResetCameraClippingRange(this->CurrentRenderer);
}
- this->Interactor->CreateTimer(VTKI_TIMER_FIRST);
+ this->Render();
}
// VSV: LOD actor activisation
// rwi->GetRenderWindow()->SetDesiredUpdateRate(rwi->GetStillUpdateRate());
- Selection_Mode aSelectionMode = myViewWindow->SelectionMode();
+ Selection_Mode aSelectionMode = GetSelector()->SelectionMode();
switch (State) {
case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
} else {
//processing rectangle selection
Interactor->StartPickCallback();
+ GetSelector()->StartPickCallback();
if (!myShiftState) {
this->PropPicked = 0;
}
}
Interactor->EndPickCallback();
- myViewWindow->onSelectionChanged();
+ GetSelector()->EndPickCallback();
}
}
break;
break;
}
- this->Interactor->CreateTimer(VTKI_TIMER_FIRST);
+ this->Render();
}
this->FindPokedRenderer(x,y);
Interactor->StartPickCallback();
+ GetSelector()->StartPickCallback();
SVTK_SelectionEvent aSelectionEvent = GetSelectionEvent();
- aSelectionEvent.mySelectionMode = myViewWindow->SelectionMode();
aSelectionEvent.myX = x;
aSelectionEvent.myY = y;
}
Interactor->EndPickCallback();
+ GetSelector()->EndPickCallback();
if(anIsChanged)
- this->Interactor->CreateTimer(VTKI_TIMER_FIRST);
+ this->Render();
}
// called on finsh GlobalPan operation
cam->SetParallelScale(myScale);
::ResetCameraClippingRange(this->CurrentRenderer);
- this->Interactor->CreateTimer(VTKI_TIMER_FIRST);
+ this->Render();
}
this->Interactor->Render();
}
+//----------------------------------------------------------------------------
+void
+SVTK_InteractorStyle
+::Render()
+{
+ this->Interactor->CreateTimer(VTKI_TIMER_FIRST);
+}
+
//----------------------------------------------------------------------------
void
SVTK_InteractorStyle
}
}
}
-
vtkTypeMacro(SVTK_InteractorStyle, vtkInteractorStyle);
void setViewWindow(SVTK_ViewWindow* theViewWindow);
+
+ void SetSelector( SVTK_Selector* theSelector );
+ SVTK_Selector* GetSelector();
+
void SetRenderWidget(QWidget* theRenderWidget);
virtual int GetState();
// redefined in order to add an observer (callback) for custorm event (space mouse event)
virtual void SetInteractor( vtkRenderWindowInteractor* );
+ virtual void Render();
+
// redefined in order to cach rendering
virtual void OnTimer();
SVTK_InteractorStyle(const SVTK_InteractorStyle&) {};
void operator=(const SVTK_InteractorStyle&) {};
- SVTK_Selector* GetSelector();
-
void RotateXY(int dx, int dy);
void PanXY(int x, int y, int oldX, int oldY);
void DollyXY(int dx, int dy);
bool myShiftState;
int ForcedState;
+ vtkSmartPointer<SVTK_Selector> mySelector;
SVTK_ViewWindow* myViewWindow;
QWidget* myRenderWidget;
#include <TColStd_MapIteratorOfMapOfInteger.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
-
#include "SALOME_Actor.h"
#include "SVTK_ViewModel.h"
#include "SVTK_ViewWindow.h"
#include "SVTK_SelectorDef.h"
+
#include "utilities.h"
+#include <vtkCallbackCommand.h>
+
+SVTK_Selector*
+SVTK_Selector
+::New()
+{
+ return new SVTK_SelectorDef();
+}
+
+//----------------------------------------------------------------------------
SVTK_SelectorDef
::SVTK_SelectorDef()
{
+ mySelectionMode = ActorSelection;
}
SVTK_SelectorDef
{
}
+//----------------------------------------------------------------------------
+void
+SVTK_SelectorDef
+::StartPickCallback()
+{
+ this->InvokeEvent(vtkCommand::StartPickEvent,NULL);
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_SelectorDef
+::EndPickCallback()
+{
+ this->InvokeEvent(vtkCommand::EndPickEvent,NULL);
+}
+
+//----------------------------------------------------------------------------
void
SVTK_SelectorDef
::SetSelectionMode(Selection_Mode theMode)
#ifndef SVTK_SELECTOR_H
#define SVTK_SELECTOR_H
+#include <vtkObject.h>
+
#include <TColStd_MapOfInteger.hxx>
#include <TColStd_IndexedMapOfInteger.hxx>
class SALOME_Actor;
-class SVTK_Selector
+class SVTK_Selector: public vtkObject
{
public:
- virtual ~SVTK_Selector() {};
+ static SVTK_Selector* New();
+
+ vtkTypeMacro(SVTK_Selector,vtkObject);
virtual
void
virtual
void
ClearIndex() = 0;
+
+ virtual
+ void
+ StartPickCallback() = 0;
+
+ virtual
+ void
+ EndPickCallback() = 0;
};
void
ClearIndex();
+ virtual
+ void
+ StartPickCallback();
+
+ virtual
+ void
+ EndPickCallback();
+
private:
Selection_Mode mySelectionMode;
#include <qapplication.h>
+#include <vtkCallbackCommand.h>
#include <vtkTextProperty.h>
#include <vtkActorCollection.h>
#include <vtkRenderer.h>
::SVTK_View( QWidget* parent, const char* name ) :
SVTK_RenderWindowInteractor( parent, name )
{
+ mySelector = SVTK_Selector::New();
+ mySelector->Delete();
+
+ myEventCallbackCommand = vtkCallbackCommand::New();
+ myEventCallbackCommand->Delete();
+
+ myEventCallbackCommand->SetClientData(this);
+ myPriority = 0.0;
+
+ myEventCallbackCommand->SetCallback(SVTK_View::ProcessEvents);
}
//----------------------------------------------------------------------------
}
//----------------------------------------------------------------------------
+SVTK_InteractorStyle*
+SVTK_View
+::GetInteractorStyle()
+{
+ return myInteractorStyle;
+}
+
void
SVTK_View
::SetInteractorStyle( SVTK_InteractorStyle* theStyle )
getInteractor()->SetInteractorStyle( theStyle );
}
+//----------------------------------------------------------------------------
+SVTK_Selector*
+SVTK_View
+::GetSelector()
+{
+ return mySelector.GetPointer();
+}
+
+void
+SVTK_View
+::SetSelector( SVTK_Selector* theSelector )
+{
+ if(mySelector.GetPointer())
+ mySelector->RemoveObserver(myEventCallbackCommand.GetPointer());
+
+ mySelector = theSelector;
+
+ if(mySelector.GetPointer())
+ mySelector->AddObserver(vtkCommand::EndPickEvent,
+ myEventCallbackCommand.GetPointer(),
+ myPriority);
+}
+
+//----------------------------------------------------------------------------
+void
+SVTK_View
+::ProcessEvents(vtkObject* vtkNotUsed(theObject),
+ unsigned long theEvent,
+ void* theClientData,
+ void* vtkNotUsed(theCallData))
+{
+ SVTK_View* self = reinterpret_cast<SVTK_View*>(theClientData);
+
+ switch(theEvent){
+ case vtkCommand::EndPickEvent:
+ self->onEmitSelectionChanged();
+ break;
+ }
+}
+
//----------------------------------------------------------------------------
void
SVTK_View
for(; anIter.More(); anIter.Next()){
highlight(anIter.Value(),true,!anIter.More());
}
+}
+//----------------------------------------------------------------
+void
+SVTK_View
+::onEmitSelectionChanged()
+{
emit selectionChanged();
}
::SetSelectionMode(Selection_Mode theMode)
{
mySelector->SetSelectionMode(theMode);
-
- //myRWInteractor->SetSelectionMode(theMode);
}
//----------------------------------------------------------------
#include "SALOME_InteractiveObject.hxx"
+#include <vtkSmartPointer.h>
+
+class vtkCallbackCommand;
class VTKViewer_Actor;
class SVTK_Viewer;
class SVTK_EXPORT SVTK_View : public SVTK_RenderWindowInteractor
{
- Q_OBJECT
+ Q_OBJECT;
public:
SVTK_View( QWidget*, const char* );
virtual ~SVTK_View();
- SVTK_Selector* GetSelector() { return mySelector; }
- void SetSelector( SVTK_Selector* theSelector ) { mySelector = theSelector; }
-
- SVTK_InteractorStyle* GetInteractorStyle() { return myInteractorStyle; }
+ SVTK_InteractorStyle* GetInteractorStyle();
void SetInteractorStyle( SVTK_InteractorStyle* );
+ SVTK_Selector* GetSelector();
+ void SetSelector( SVTK_Selector* theSelector );
+
+ // Main process VTK event method
+ static
+ void
+ ProcessEvents(vtkObject* theObject,
+ unsigned long theEvent,
+ void* theClientData,
+ void* theCallData);
+
Selection_Mode SelectionMode() const;
void SetSelectionMode( Selection_Mode );
public slots:
void onSelectionChanged();
+ void onEmitSelectionChanged();
signals:
void selectionChanged();
private:
SVTK_Viewer* myModel;
- SVTK_Selector* mySelector;
+ // Used to process VTK events
+ vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
+ // Priority at which events are processed
+ float myPriority;
+
+ vtkSmartPointer<SVTK_Selector> mySelector;
SVTK_InteractorStyle* myInteractorStyle;
double myCurScale;
-
- friend class SVTK_RenderWindowInteractor;
};
#ifdef WIN32
#include "SALOME_ListIteratorOfListIO.hxx"
-#include "SVTK_SelectorDef.h"
+#include "SVTK_Selector.h"
#include "VTKViewer_Algorithm.h"
#include "SVTK_Functor.h"
SVTK_ViewModelBase* theModel)
: SUIT_ViewWindow( theDesktop )
{
- mySelector = new SVTK_SelectorDef();
- connect(this,SIGNAL(selectionChanged()),theModel,SLOT(onSelectionChanged()));
-
QWidget* aCentralWidget = new QWidget( this );
setCentralWidget( aCentralWidget );
QBoxLayout* aLayout = new QVBoxLayout( aCentralWidget );
bottomView->getInteractor()->SetInteractorStyle( myInteractorStyle );
bottomView->Initialize();
*/
+
myInteractorStyle = SVTK_InteractorStyle::New();
myInteractorStyle->SetRenderWidget( myView );
myInteractorStyle->setViewWindow( this );
+ myInteractorStyle->SetSelector( myView->GetSelector() );
myView->SetInteractorStyle( myInteractorStyle );
- myView->SetSelector( mySelector );
myView->Initialize();
+ connect(myView,SIGNAL(selectionChanged()),theModel,SLOT(onSelectionChanged()));
+
//merge with V2_2_0_VISU_improvements:myInteractorStyle->setTriedron( myTrihedron );
myInteractorStyle->FindPokedRenderer( 0, 0 );
return myView->getRenderer();
}
+//----------------------------------------------------------------------------
+SVTK_Selector*
+SVTK_ViewWindow
+::GetSelector() {
+ return myView->GetSelector();
+}
+
//----------------------------------------------------------------------------
void
SVTK_ViewWindow
SVTK_ViewWindow
::onSelectionChanged()
{
- //cout << "SVTK_ViewWindow::onSelectionChanged" << endl;
- myView->onSelectionChanged();
emit selectionChanged();
}
#include "SALOME_InteractiveObject.hxx"
+#include <vtkSmartPointer.h>
+
class SUIT_Desktop;
class VTKViewer_Actor;
QColor backgroundColor() const;
vtkRenderer* getRenderer();
- SVTK_Selector* GetSelector() {return mySelector;}
+ SVTK_Selector* GetSelector();
SVTK_View* getView() { return myView; }
SVTK_View* getRenderWindow() { return myView; }
void onRotateUp();
void onRotateDown();
-protected:
- QImage dumpView();
-
protected slots:
void onKeyPressed(QKeyEvent* event);
void onKeyReleased(QKeyEvent* event);
void onMouseReleased(QMouseEvent* event);
void onMouseMoving(QMouseEvent* event);
-private:
- void InitialSetup();
- //void InsertActor( VTKViewer_Actor* theActor,
- // bool theMoveInternalActors = false );
- //void MoveActor( VTKViewer_Actor* theActor );
-
-private:
- SVTK_Selector* mySelector;
+protected:
+ QImage dumpView();
SVTK_View* myView;
SVTK_InteractorStyle* myInteractorStyle;
-
- double myCurScale;
-
- friend class SVTK_RenderWindowInteractor;
};
#ifdef WIN32