myRectBand(0),
myPolygonBand(0),
myPoligonState(Disable),
- myIsAdvancedZoomingEnabled(false)
+ myIsAdvancedZoomingEnabled(false),
+ myInteractivePoint{0.0, 0.0, 0.0}
{
myPointPicker->Delete();
// finishing current viewer operation
if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
onFinishOperation();
+ int lastOperation = State;
startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
+ if (lastOperation == VTK_INTERACTOR_STYLE_CAMERA_INTERACTIVE_SELECTION) {
+ InvokeEvent(SVTK::InteractiveSelectionFinished, nullptr);
+ }
}
}
startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
}
myOtherPoint = myPoint = QPoint(x, y);
- if (ForcedState != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
+ if (ForcedState != VTK_INTERACTOR_STYLE_CAMERA_NONE &&
+ ForcedState != VTK_INTERACTOR_STYLE_CAMERA_INTERACTIVE_SELECTION) {
startOperation(ForcedState);
}
else {
startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
}
myOtherPoint = myPoint = QPoint(x, y);
- if (ForcedState != VTK_INTERACTOR_STYLE_CAMERA_NONE) {
+ if (ForcedState != VTK_INTERACTOR_STYLE_CAMERA_NONE &&
+ ForcedState != VTK_INTERACTOR_STYLE_CAMERA_INTERACTIVE_SELECTION) {
startOperation(ForcedState);
}
else {
ForcedState = VTK_INTERACTOR_STYLE_CAMERA_ROTATE;
}
+/*!
+ Starts Interactive Selection operation
+*/
+void SVTK_InteractorStyle::startInteractiveSelection()
+{
+ if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
+ {
+ onFinishOperation();
+ startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
+ }
+ ForcedState = VTK_INTERACTOR_STYLE_CAMERA_INTERACTIVE_SELECTION;
+}
+
+
/*!
Set rotation point selected by user
*/
case VTK_INTERACTOR_STYLE_CAMERA_SPIN:
case VTK_INTERACTOR_STYLE_CAMERA_FIT:
case VTK_INTERACTOR_STYLE_CAMERA_SELECT:
+ case VTK_INTERACTOR_STYLE_CAMERA_INTERACTIVE_SELECTION:
if (State != VTK_INTERACTOR_STYLE_CAMERA_NONE)
startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
State = operation;
drawRect();
break;
}
+ case VTK_INTERACTOR_STYLE_CAMERA_INTERACTIVE_SELECTION:
+ {
+ InteractiveSelection();
+ break;
+ }
case VTK_INTERACTOR_STYLE_CAMERA_ZOOM:
case VTK_INTERACTOR_STYLE_CAMERA_PAN:
case VTK_INTERACTOR_STYLE_CAMERA_ROTATE:
drawRect();
break;
}
+ case VTK_INTERACTOR_STYLE_CAMERA_INTERACTIVE_SELECTION:
+ this->InteractiveSelection();
}
}
this->RotateXY( incrX, -incrY );
}
+void SVTK_InteractorStyle::InteractiveSelection()
+{
+ if (vtkCamera *cam = GetCurrentRenderer()->GetActiveCamera()) {
+ int posX, posY;
+ this->Interactor->GetEventPosition(posX, posY);
+ double viewFocus[3], z;
+ double* focalPointWorld = cam->GetFocalPoint();
+ this->ComputeWorldToDisplay(focalPointWorld[0], focalPointWorld[1],
+ focalPointWorld[2], viewFocus);
+ z = viewFocus[2];
+
+ this->ComputeDisplayToWorld(double(posX), double(posY),
+ z, this->myInteractivePoint);
+ InvokeEvent(SVTK::InteractiveSelectionChanged, (void*)this->myInteractivePoint);
+ }
+}
+
/*!
Redefined in order to add an observer (callback) for custorm event (space mouse event)
*/
theInteractor->AddObserver( SVTK::SetFocalPointGravity, EventCallbackCommand, Priority );
theInteractor->AddObserver( SVTK::StartFocalPointSelection, EventCallbackCommand, Priority );
theInteractor->AddObserver( SVTK::SetFocalPointSelected, EventCallbackCommand, Priority );
+ theInteractor->AddObserver( SVTK::StartInteractiveSelection, EventCallbackCommand, Priority);
+ theInteractor->AddObserver( SVTK::StopCurrentOperation, EventCallbackCommand, Priority);
}
}
case SVTK::StartFocalPointSelection:
self->startFocalPointSelection();
return;
-
+ case SVTK::StartInteractiveSelection:
+ self->startInteractiveSelection();
+ return;
case SVTK::SetFocalPointSelected:
if ( self->myCurrFocalPointType == SVTK::StartFocalPointSelection )
{
self->myPrevFocalPointType = self->myCurrFocalPointType;
self->myCurrFocalPointType = SVTK::SetFocalPointSelected;
return;
+ case SVTK::StopCurrentOperation:
+ self->onFinishOperation();
+ self->startOperation(VTK_INTERACTOR_STYLE_CAMERA_NONE);
}
}
}
#define VTK_INTERACTOR_STYLE_CAMERA_SELECT 6
#define VTK_INTERACTOR_STYLE_CAMERA_GLOBAL_PAN 7
#define VTK_INTERACTOR_STYLE_CAMERA_SELECT_ROTATION_POINT 8
+#define VTK_INTERACTOR_STYLE_CAMERA_INTERACTIVE_SELECTION 9
enum PolygonState { Disable, Start, InProcess, Finished, Closed, NotValid };
void
IncrementalRotate( const int incrX, const int incrY );
+ void
+ InteractiveSelection();
+
// Main process event method (reimplemented from #vtkInteractorStyle)
static
void
void startPointSelection();
void startFocalPointSelection();
+ void startInteractiveSelection();
protected:
void loadCursors();
vtkSmartPointer<vtkPointPicker> myPointPicker;
double myBBCenter[3];
+ double myInteractivePoint[3];
bool myBBFirstCheck;
QtxRectRubberBand* myRectBand; //!< selection rectangle rubber band