#include <XGUI_Viewer.h>
#include <XGUI_Workshop.h>
#include <XGUI_OperationMgr.h>
-#include <XGUI_ViewWindow.h>
#include <XGUI_SelectionMgr.h>
#include <XGUI_ViewPort.h>
#include <XGUI_ActionsMgr.h>
+#include <XGUI_ViewerProxy.h>
#include <Config_PointerMessage.h>
#include <Config_ModuleReader.h>
connect(anOperationMgr, SIGNAL(operationStarted()), this, SLOT(onOperationStarted()));
connect(anOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
this, SLOT(onOperationStopped(ModuleBase_Operation*)));
- if (!myWorkshop->isSalomeMode()) {
- 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*)));
- connect(aViewer, SIGNAL(keyRelease(XGUI_ViewWindow*, QKeyEvent*)),
- this, SLOT(onKeyRelease(XGUI_ViewWindow*, QKeyEvent*)));
- }
+
+ connect(myWorkshop->selector(), SIGNAL(selectionChanged()),
+ this, SLOT(onSelectionChanged()));
+ connect(myWorkshop->viewer(), SIGNAL(mouseRelease(QMouseEvent*)),
+ this, SLOT(onMouseReleased(QMouseEvent*)));
+ connect(myWorkshop->viewer(), SIGNAL(mouseMove(QMouseEvent*)),
+ this, SLOT(onMouseMoved(QMouseEvent*)));
+ connect(myWorkshop->viewer(), SIGNAL(keyRelease(QKeyEvent*)),
+ this, SLOT(onKeyRelease(QKeyEvent*)));
}
PartSet_Module::~PartSet_Module()
}
}
-void PartSet_Module::onMouseReleased(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent)
+void PartSet_Module::onMouseReleased(QMouseEvent* theEvent)
{
QPoint aPoint = theEvent->pos();
ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
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 aPnt = PartSet_Tools::ConvertClickToPoint(aPoint, aView3d);
- aPreviewOp->mouseReleased(aPnt);
- }
+ Handle(V3d_View) aView3d = myWorkshop->viewer()->activeView();
+ if ( !aView3d.IsNull() ) {
+ gp_Pnt aPnt = PartSet_Tools::ConvertClickToPoint(aPoint, aView3d);
+ aPreviewOp->mouseReleased(aPnt);
}
}
}
}
-void PartSet_Module::onMouseMoved(XGUI_ViewWindow* theWindow, QMouseEvent* theEvent)
+void PartSet_Module::onMouseMoved(QMouseEvent* theEvent)
{
QPoint aPoint = theEvent->pos();
ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
if (aPreviewOp) {
- XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
- if (aViewer) {
- XGUI_ViewWindow* aWindow = aViewer->activeViewWindow();
- if (aWindow) {
- Handle(V3d_View) aView3d = aWindow->viewPort()->getView();
- if ( !aView3d.IsNull() ) {
- gp_Pnt aPnt = PartSet_Tools::ConvertClickToPoint(aPoint, aView3d);
- aPreviewOp->mouseMoved(aPnt);
- }
- }
+ Handle(V3d_View) aView3d = myWorkshop->viewer()->activeView();
+ if ( !aView3d.IsNull() ) {
+ gp_Pnt aPnt = PartSet_Tools::ConvertClickToPoint(aPoint, aView3d);
+ aPreviewOp->mouseMoved(aPnt);
}
}
}
-void PartSet_Module::onKeyRelease(XGUI_ViewWindow* theWindow, QKeyEvent* theEvent)
+void PartSet_Module::onKeyRelease(QKeyEvent* theEvent)
{
ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
void PartSet_Module::onPlaneSelected(double theX, double theY, double theZ)
{
- XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
- if (aViewer) {
- aViewer->setViewProjection(theX, theY, theZ);
- }
+ myWorkshop->viewer()->setViewProjection(theX, theY, theZ);
ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
if (anOperation) {
#include <boost/shared_ptr.hpp>
-class XGUI_ViewWindow;
class QMouseEvent;
class QKeyEvent;
class PartSet_Listener;
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);
+ void onMouseReleased(QMouseEvent* theEvent);
/// SLOT, that is called by the selection in the viewer is changed.
/// 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);
+ void onMouseMoved(QMouseEvent* theEvent);
/// SLOT, that is called by the key in the viewer is clicked.
- /// \param theWindow the window where the signal appears
/// \param theEvent the mouse event
- void onKeyRelease(XGUI_ViewWindow*, QKeyEvent*);
+ void onKeyRelease(QKeyEvent*);
/// SLOT, to apply to the current viewer the operation
/// \param theX the X projection value
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;
}
}
+void XGUI_ViewerProxy::setViewProjection(double theX, double theY, double theZ)
+{
+ Handle(V3d_View) aView3d = activeView();
+ if ( !aView3d.IsNull() ) {
+ aView3d->SetProj(theX, theY, theZ);
+ aView3d->FitAll( 0.01, true, true );
+ aView3d->SetZSize(0.);
+ }
+}
+
+
void XGUI_ViewerProxy::connectToViewer()
{
if (myWorkshop->isSalomeMode()) {
connect(aViewer, SIGNAL(activated()),
this, SIGNAL(activated()));
- connect(aViewer, SIGNAL(mousePress(QMouseEvent* theEvent)),
- this, SIGNAL(mousePress(QMouseEvent* theEvent)));
- connect(aViewer, SIGNAL(mouseRelease(QMouseEvent* theEvent)),
- this, SIGNAL(mouseRelease(QMouseEvent* theEvent)));
- connect(aViewer, SIGNAL(mouseDoubleClick(QMouseEvent* theEvent)),
- this, SIGNAL(mouseDoubleClick(QMouseEvent* theEvent)));
- connect(aViewer, SIGNAL(mouseMove(QMouseEvent* theEvent)),
- this, SIGNAL(mouseMove(QMouseEvent* theEvent)));
- connect(aViewer, SIGNAL(keyPress(QKeyEvent* theEvent)),
- this, SIGNAL(keyPress(QKeyEvent* theEvent)));
- connect(aViewer, SIGNAL(keyRelease(QKeyEvent* theEvent)),
- this, SIGNAL(keyRelease(QKeyEvent* theEvent)));
+ connect(aViewer, SIGNAL(mousePress(QMouseEvent*)),
+ this, SIGNAL(mousePress(QMouseEvent*)));
+
+ connect(aViewer, SIGNAL(mouseRelease(QMouseEvent*)),
+ this, SIGNAL(mouseRelease(QMouseEvent*)));
+
+ connect(aViewer, SIGNAL(mouseDoubleClick(QMouseEvent*)),
+ this, SIGNAL(mouseDoubleClick(QMouseEvent*)));
+
+ connect(aViewer, SIGNAL(mouseMove(QMouseEvent*)),
+ this, SIGNAL(mouseMove(QMouseEvent*)));
+
+ connect(aViewer, SIGNAL(keyPress(QKeyEvent*)),
+ this, SIGNAL(keyPress(QKeyEvent*)));
+
+ connect(aViewer, SIGNAL(keyRelease(QKeyEvent*)),
+ this, SIGNAL(keyRelease(QKeyEvent*)));
} else {
XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
* It is reccomennded to use this class in operation for accessing to viewer
* functionality instead of direct access to a viewer
*/
-class XGUI_ViewerProxy: public XGUI_SalomeViewer
+class XGUI_EXPORT XGUI_ViewerProxy: public XGUI_SalomeViewer
{
Q_OBJECT
public:
//! Returns Vsd_View object from currently active view window
virtual Handle(V3d_View) activeView() const;
+ //! 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);
+
+ /// Connects to a viewer according to current environment
void connectToViewer();
private slots: