#include <XGUI_ViewWindow.h>
#include <XGUI_SelectionMgr.h>
#include <XGUI_ViewPort.h>
+#include <XGUI_ActionsMgr.h>
#include <Config_PointerMessage.h>
#include <Config_ModuleReader.h>
#include <AIS_ListOfInteractive.hxx>
#include <QObject>
+#include <QMouseEvent>
#include <QString>
#ifdef _DEBUG
connect(anOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
this, SLOT(onOperationStopped(ModuleBase_Operation*)));
if (!myWorkshop->isSalomeMode()) {
- connect(myWorkshop->mainWindow()->viewer(), SIGNAL(mouseReleased(QPoint)),
- this, SLOT(onMouseReleased(QPoint)));
- connect(myWorkshop->mainWindow()->viewer(), SIGNAL(mouseMoved(QPoint)),
- this, SLOT(onMouseMoved(QPoint)));
+ XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
+ connect(aViewer, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged()));
+ connect(aViewer, SIGNAL(mouseRelease(XGUI_ViewWindow*, QMouseEvent*)),
+ this, SLOT(onMouseReleased(XGUI_ViewWindow*, QMouseEvent*)));
+ connect(aViewer, SIGNAL(mouseMove(XGUI_ViewWindow*, QMouseEvent*)),
+ this, SLOT(onMouseMoved(XGUI_ViewWindow*, QMouseEvent*)));
}
}
PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
if (aPreviewOp) {
visualizePreview(true);
- connect(aPreviewOp, SIGNAL(viewerProjectionChange(double, double, double)),
- this, SLOT(onViewerProjectionChange(double, double, double)));
+
+ PartSet_OperationSketch* aSketchOp = dynamic_cast<PartSet_OperationSketch*>(aPreviewOp);
+ if (aSketchOp) {
+ connect(aSketchOp, SIGNAL(planeSelected(double, double, double)),
+ this, SLOT(onPlaneSelected(double, double, double)));
+ }
}
}
visualizePreview(false);
}
-void PartSet_Module::onMouseReleased(QPoint thePoint)
+void PartSet_Module::onSelectionChanged()
{
ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
if (aSelector) {
NCollection_List<TopoDS_Shape> aList;
aSelector->selectedShapes(aList);
+ aPreviewOp->setSelectedShapes(aList);
+ }
+ }
+}
+
+void PartSet_Module::onMouseReleased(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent)
+{
+ QPoint aPoint = theEvent->pos();
+ ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
+ PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
+ if (aPreviewOp) {
+ XGUI_SelectionMgr* aSelector = myWorkshop->selector();
+ if (aSelector) {
XGUI_ViewWindow* aWindow = myWorkshop->mainWindow()->viewer()->activeViewWindow();
if (aWindow) {
Handle(V3d_View) aView3d = aWindow->viewPort()->getView();
if ( !aView3d.IsNull() ) {
- gp_Pnt aPoint = PartSet_Tools::ConvertClickToPoint(thePoint, aView3d);
- aPreviewOp->setSelectedShapes(aList, aPoint);
+ gp_Pnt aPnt = PartSet_Tools::ConvertClickToPoint(aPoint, aView3d);
+ aPreviewOp->mouseReleased(aPnt);
}
}
}
}
}
-void PartSet_Module::onMouseMoved(QPoint thePoint)
+void PartSet_Module::onMouseMoved(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent)
{
+ QPoint aPoint = theEvent->pos();
ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
if (aPreviewOp) {
if (aWindow) {
Handle(V3d_View) aView3d = aWindow->viewPort()->getView();
if ( !aView3d.IsNull() ) {
- gp_Pnt aPoint = PartSet_Tools::ConvertClickToPoint(thePoint, aView3d);
- aPreviewOp->setMouseMovePoint(aPoint);
+ gp_Pnt aPnt = PartSet_Tools::ConvertClickToPoint(aPoint, aView3d);
+ aPreviewOp->mouseMoved(aPnt);
}
}
}
}
}
-void PartSet_Module::onViewerProjectionChange(double theX, double theY, double theZ)
+void PartSet_Module::onPlaneSelected(double theX, double theY, double theZ)
{
XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
if (aViewer) {
aViewer->setViewProjection(theX, theY, theZ);
}
+ myWorkshop->actionsMgr()->setNestedActionsEnabled(true);
}
void PartSet_Module::visualizePreview(bool isDisplay)
#include <string>
+class XGUI_ViewWindow;
+class QMouseEvent;
class PartSet_Listener;
class PARTSET_EXPORT PartSet_Module: public QObject, public XGUI_Module
/// SLOT, that is called after the operation is stopped. Disconnect the sketch feature
/// from the viewer selection and show the sketch preview.
void onOperationStopped(ModuleBase_Operation* theOperation);
+
/// 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 onMouseReleased(QPoint thePoint);
+ /// The selection is sent to the current operation if it listens selection.
+ void onSelectionChanged();
+ /// SLOT, that is called by mouse click in the viewer.
+ /// The mouse released point is sent to the current operation to be processed.
+ /// \param theWindow the window where the signal appears
+ /// \param theEvent the mouse event
+ void onMouseReleased(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
/// 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.
- /// \thePoint the mouse point
- void onMouseMoved(QPoint thePoint);
+ /// The mouse moved point is sent to the current operation to be processed.
+ /// \param theWindow the window where the signal appears
+ /// \param theEvent the mouse event
+ void onMouseMoved(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent);
/// 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);
+ void onPlaneSelected(double theX, double theY, double theZ);
private:
XGUI_Workshop* myWorkshop;
return TopAbs_FACE;
}
-void PartSet_OperationSketch::setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList,
- const gp_Pnt& theSelectedPoint)
+void PartSet_OperationSketch::setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList)
{
if (theList.IsEmpty())
return;
aDirY->setValue(aC, anA, aB);
boost::shared_ptr<GeomAPI_Dir> aDir = aPlane->direction();
- emit viewerProjectionChange(aDir->x(), aDir->y(), aDir->z());
+ emit planeSelected(aDir->x(), aDir->y(), aDir->z());
//commit();
//SketchPlugin_Sketch::setActive(myFeature);
/// Gives the current selected objects to be processed by the operation
/// \param theList a list of interactive selected shapes
/// \param theSelectedPoint a point clidked in the viewer
- virtual void setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList,
- const gp_Pnt& theSelectedPoint);
+ virtual void setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList);
+
+signals:
+ /// signal about the sketch plane is selected
+ /// \param theX the value in the X direction of the plane
+ /// \param theX the value in the Y direction value of the plane
+ /// \param theX the value in the Z direction of the plane
+ void planeSelected(double theX, double theY, double theZ);
};
#endif
/// Gives the current selected objects to be processed by the operation
/// \param theList a list of interactive selected shapes
- /// \param theSelectedPoint a 3D selected point
- virtual void setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList,
- const gp_Pnt& thePoint) = 0;
- /// Gives the current mouse point in the viewer
- /// \param thePoint a point clidked in the viewer
- virtual void setMouseMovePoint(const gp_Pnt& thePoint) {};
-
-signals:
- void viewerProjectionChange(double theX, double theY, double theZ);
+ virtual void setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList) {};
+
+ /// Processes the mouse release in the point
+ /// \param thePoint a point clicked in the viewer
+ virtual void mouseReleased(const gp_Pnt& thePoint) {};
+
+ /// Processes the mouse move in the point
+ /// \param thePoint a 3D point clicked in the viewer
+ virtual void mouseMoved(const gp_Pnt& thePoint) {};
};
#endif
return 0;//TopAbs_FACE;
}
-void PartSet_OperationSketchLine::setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList,
- const gp_Pnt& thePoint)
+void PartSet_OperationSketchLine::mouseReleased(const gp_Pnt& thePoint)
{
- if (theList.IsEmpty())
- return;
-
switch (myPointSelectionMode)
{
case SM_FirstPoint: {
}
}
-void PartSet_OperationSketchLine::setMouseMovePoint(const gp_Pnt& thePoint)
+void PartSet_OperationSketchLine::mouseMoved(const gp_Pnt& thePoint)
{
if (myPointSelectionMode == SM_SecondPoint)
setLinePoint(thePoint, LINE_ATTR_END);
virtual int getSelectionMode() const;
/// Gives the current selected objects to be processed by the operation
- /// \param theList a list of interactive selected shapes
- /// \param theSelectedPoint a point clidked in the viewer
- virtual void setSelectedShapes(const NCollection_List<TopoDS_Shape>& theList,
- const gp_Pnt& thePoint);
+ /// \param thePoint a point clicked in the viewer
+ virtual void mouseReleased(const gp_Pnt& thePoint);
/// Gives the current mouse point in the viewer
- /// \param thePoint a point clidked in the viewer
- virtual void setMouseMovePoint(const gp_Pnt& thePoint);
+ /// \param thePoint a point clicked in the viewer
+ virtual void mouseMoved(const gp_Pnt& thePoint);
protected:
/// \brief Virtual method called when operation is started
#ifndef XGUI_ACTIONSMGR_H_
#define XGUI_ACTIONSMGR_H_
+#include "XGUI.h"
+
#include <QObject>
#include <QMap>
#include <QStringList>
class XGUI_Command;
class QAction;
-class XGUI_ActionsMgr: public QObject
+class XGUI_EXPORT XGUI_ActionsMgr: public QObject
{
Q_OBJECT
void keyRelease(XGUI_ViewWindow* theWindow, QKeyEvent* theEvent);
void activated(XGUI_ViewWindow* theWindow);
void selectionChanged();
- //void mouseReleased(QPoint thePoint);
- //void mouseMoved(QPoint thePoint);
public slots:
void onWindowMinimized(QMdiSubWindow*);
//! ! Returns operation manager.
XGUI_OperationMgr* operationMgr() const { return myOperationMgr; }
+ //! ! Returns an actions manager
+ XGUI_ActionsMgr* actionsMgr() const { return myActionsMgr; };
+
//! Creates and adds a new workbench (menu group) with the given name and returns it
XGUI_Workbench* addWorkbench(const QString& theName);