#include "SVTK_Actor.h"
+#include <vtkCamera.h>
#include <vtkRenderer.h>
#include <vtkPointPicker.h>
#include <vtkScalarBarWidget.h>
#include <vtkPolyData.h>
#include <vtkActor.h>
+#include <vtkCommand.h>
#include <vtkObjectFactory.h>
+#include <vtkCallbackCommand.h>
#include <vtkInteractorStyle.h>
+#include <vtkInteractorObserver.h>
#include <vtkRenderWindowInteractor.h>
-#include <vtkCamera.h>
#include <sstream>
+#include <boost/bind.hpp>
#include <vtkUnstructuredGrid.h>
#include <vtkDataSetMapper.h>
VISU_GaussPtsAct
::VISU_GaussPtsAct():
+ myInteractorObserver(vtkInteractorObserver::New()),
+ myEventCallbackCommand(vtkCallbackCommand::New()),
myPSMapper(VISU_OpenGLPointSpriteMapper::New()),
myGaussPointsPL(NULL),
myTextMapper(vtkTextMapper::New()),
mySphereActor(vtkActor::New()),
myCursorPyramid(VISU_CursorPyramid::New())
{
+ myInteractorObserver->Delete();
+ myEventCallbackCommand->Delete();
+
+ myEventCallbackCommand->SetClientData(this);
+ myEventCallbackCommand->SetCallback(VISU_GaussPtsAct::ProcessEvents);
+
myTextMapper->Delete();
myTextActor->Delete();
myPSMapper->Delete();
Superclass::SetPipeLine(thePipeLine);
}
+void
+VISU_GaussPtsAct
+::SetFactory(VISU::TActorFactory* theActorFactory)
+{
+ VISU_Actor::SetFactory(theActorFactory);
+ myUpdatePrs3dSignal.connect(boost::bind(&VISU::TActorFactory::UpdateFromActor,
+ theActorFactory,
+ _1));
+}
+
VISU_GaussPointsPL*
VISU_GaussPtsAct
::GetGaussPointsPL()
return myGaussPointsPL.GetPointer();
}
+bool
+VISU_GaussPtsAct
+::ChangeMagnification()
+{
+ return myChangeMagnification;
+}
+
+
+//----------------------------------------------------------------------------
+void
+VISU_GaussPtsAct
+::SetInteractor(vtkRenderWindowInteractor* theInteractor)
+{
+ if(theInteractor == myInteractor)
+ return;
+
+ if(myInteractor)
+ myInteractor->RemoveObserver(myEventCallbackCommand.GetPointer());
+
+
+ if(theInteractor)
+ theInteractor->AddObserver(vtkCommand::CharEvent,
+ myEventCallbackCommand.GetPointer(),
+ 0.0);
+
+
+ Superclass::SetInteractor(theInteractor);
+
+ Modified();
+}
+
+void
+VISU_GaussPtsAct
+::ProcessEvents(vtkObject* vtkNotUsed(theObject),
+ unsigned long theEvent,
+ void* theClientData,
+ void* vtkNotUsed(theCallData))
+{
+ if(vtkObject* anObject = reinterpret_cast<vtkObject*>(theClientData))
+ if(VISU_GaussPtsAct* self = dynamic_cast<VISU_GaussPtsAct*>(anObject))
+ self->OnInteractorEvent(theEvent);
+}
+
+void
+VISU_GaussPtsAct
+::OnInteractorEvent(unsigned long theEvent)
+{
+ switch(theEvent){
+ case vtkCommand::CharEvent: {
+ switch(myInteractor->GetKeyCode()) {
+ case 'm' :
+ case 'M' :
+ myChangeMagnification = true;
+ break;
+ case 'n' :
+ case 'N' :
+ myChangeMagnification = false;
+ break;
+ default:
+ return;
+ }
+ myUpdatePrs3dSignal(this);
+ return;
+ }
+ break;
+ }
+}
+
+
//----------------------------------------------------------------
bool
VISU_GaussPtsAct
Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode;
mySelectionMode = aSelectionMode;
//
- if(aSelectionMode==ActorSelection ){ //|| !theIsHighlight) {
+ if(aSelectionMode == ActorSelection ){
myTextActor->SetVisibility(aTextVisibility);
mySphereActor->SetVisibility(aSphereVisibility);
mySphereActorSelected->SetVisibility(aSphereVisibilitySelected);
class VISU_CursorPyramid;
class VISU_GPTextActor;
-//xxx
+
class vtkUnstructuredGrid;
class vtkDataSetMapper;
-//xxx
+
+class vtkInteractorObserver;
+class vtkCallbackCommand;
+
+
+//----------------------------------------------------------------------------
class VTKOCC_EXPORT VISU_GaussPtsAct : public VISU_ScalarMapAct
{
public:
VISU_GaussPtsAct*
New();
+ //----------------------------------------------------------------------------
virtual
void
SetPipeLine(VISU_PipeLine* thePipeLine) ;
+ virtual
+ void
+ SetFactory(VISU::TActorFactory* theActorFactory);
+
VISU_GaussPointsPL*
GetGaussPointsPL();
+ bool
+ ChangeMagnification();
+
+ //----------------------------------------------------------------------------
virtual
void
AddToRender(vtkRenderer* theRenderer);
void
RemoveFromRender(vtkRenderer* theRenderer);
+ virtual
+ void
+ SetInteractor(vtkRenderWindowInteractor* theInteractor);
+
+ //----------------------------------------------------------------------------
virtual
bool
PreHighlight(SVTK_Selector* theSelector,
SVTK_SelectionEvent* theSelectionEvent,
bool theIsHighlight);
+ //----------------------------------------------------------------------------
protected:
VISU_GaussPtsAct();
void
SetMapperInput(vtkDataSet* theDataSet);
- vtkSmartPointer<VISU_OpenGLPointSpriteMapper> myPSMapper;
+ //----------------------------------------------------------------------------
+ vtkSmartPointer<vtkInteractorObserver> myInteractorObserver;
+ vtkSmartPointer<vtkCallbackCommand> myEventCallbackCommand;
+ // Main process VTK event method
+ static
+ void
+ ProcessEvents(vtkObject* theObject,
+ unsigned long theEvent,
+ void* theClientData,
+ void* theCallData);
+ void
+ OnInteractorEvent(unsigned long theEvent);
+
+ boost::signal1<void,VISU_Actor*> myUpdatePrs3dSignal;
+ bool myChangeMagnification;
+
+ //----------------------------------------------------------------------------
+ vtkSmartPointer<VISU_OpenGLPointSpriteMapper> myPSMapper;
vtkSmartPointer<VISU_GaussPointsPL> myGaussPointsPL;
vtkSmartPointer<vtkTextMapper> myTextMapper;