Set plane for sketch and erase the sketch preview. Set view projection.
ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
- if (aPreviewOp)
+ if (aPreviewOp) {
visualizePreview(true);
+ connect(aPreviewOp, SIGNAL(viewerProjectionChange(double, double, double)),
+ this, SLOT(onViewerProjectionChange(double, double, double)));
+ }
}
void PartSet_Module::onOperationStopped(ModuleBase_Operation* theOperation)
}
}
+void PartSet_Module::onViewerProjectionChange(double theX, double theY, double theZ)
+{
+ XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
+ if (aViewer) {
+ aViewer->setViewProjection(theX, theY, theZ);
+ }
+}
+
void PartSet_Module::visualizePreview(bool isDisplay)
{
ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
/// SLOT, that is called by the selection in the viewer is changed.
/// The selection is sent to the current operation if it listen the selection.
void onViewSelectionChanged();
+ /// SLOT, to apply to the current viewer the operation
+ /// \param theX the X projection value
+ /// \param theY the Y projection value
+ /// \param theZ the Z projection value
+ void onViewerProjectionChange(double theX, double theY, double theZ);
private:
/// Displays or erase the current operation preview, if it has it.
aData->real(SKETCH_ATTR_PLANE_C)->setValue(aC);
aData->real(SKETCH_ATTR_PLANE_D)->setValue(aD);
- //emit viewPlaneChanged();
+ boost::shared_ptr<GeomAPI_Dir> aDir = aPlane->direction();
+ emit viewerProjectionChange(aDir->x(), aDir->y(), aDir->z());
commit();
}
/// Gives the current selected objects to be processed by the operation
/// \param a list of interactive selected objects
virtual void setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList) = 0;
+
+signals:
+ void viewerProjectionChange(double theX, double theY, double theZ);
};
#endif
theButton = myButtonMap[theInteractionStyle][theOper];
}
+void XGUI_Viewer::setViewProjection(double theX, double theY, double theZ)
+{
+ XGUI_ViewWindow* aWindow = dynamic_cast<XGUI_ViewWindow*>(myActiveView->widget());
+ if (aWindow) {
+ Handle(V3d_View) aView3d = aWindow->viewPort()->getView();
+ if ( !aView3d.IsNull() )
+ aView3d->SetProj(theX, theY, theZ);
+ aWindow->viewPort()->fitAll();
+ }
+}
+
/*!
Changes visibility of trihedron to opposite
*/
static void getHotButton(XGUI::InteractionStyle theInteractionStyle, XGUI::HotOperation theOper,
Qt::KeyboardModifiers& theState, Qt::MouseButtons& theButton);
+ //! Sets the view projection
+ /// \param theX the X projection value
+ /// \param theY the Y projection value
+ /// \param theZ the Z projection value
+ void setViewProjection(double theX, double theY, double theZ);
+
typedef QMap<XGUI::HotOperation, Qt::KeyboardModifiers> StatesMap;
typedef QMap<XGUI::HotOperation, Qt::MouseButtons> ButtonsMap;