return mySelector->viewer()->getAISContext();
}
-Handle(V3d_Viewer) NewGeom_SalomeViewer::V3dViewer() const
+Handle(V3d_Viewer) NewGeom_SalomeViewer::v3dViewer() const
{
return mySelector->viewer()->getViewer3d();
}
virtual Handle(AIS_InteractiveContext) AISContext() const;
//! Retrurns V3d_Vioewer from current viewer
- virtual Handle(V3d_Viewer) V3dViewer() const;
+ virtual Handle(V3d_Viewer) v3dViewer() const;
//! Returns Vsd_View object from currently active view window
virtual Handle(V3d_View) activeView() const;
XGUI_ActionsMgr.h
XGUI_ErrorDialog.h
XGUI_SalomeViewer.h
+ XGUI_ViewerProxy.h
)
SET(PROJECT_AUTOMOC
XGUI_SelectionMgr.cpp
XGUI_ActionsMgr.cpp
XGUI_ErrorDialog.cpp
+ XGUI_ViewerProxy.cpp
)
SET(PROJECT_RESOURCES
#include "XGUI_Displayer.h"
#include "XGUI_Viewer.h"
+#include "XGUI_Workshop.h"
+#include "XGUI_ViewerProxy.h"
#include <ModelAPI_Document.h>
#include <AIS_Shape.hxx>
-XGUI_Displayer::XGUI_Displayer(const Handle(AIS_InteractiveContext)& theAIS)
+XGUI_Displayer::XGUI_Displayer(XGUI_Workshop* theWorkshop)
{
- myAISContext = theAIS;
+ myWorkshop = theWorkshop;
}
XGUI_Displayer::~XGUI_Displayer()
ic->UpdateCurrentViewer();
}
}
+
+Handle(AIS_InteractiveContext) XGUI_Displayer::AISContext() const
+{
+ return myWorkshop->viewer()->AISContext();
+}
class XGUI_Viewer;
class ModelAPI_Feature;
-
+class XGUI_Workshop;
/**\class XGUI_Displayer
* \ingroup GUI
public:
/// Constructor
/// \param theViewer the viewer
- XGUI_Displayer(const Handle(AIS_InteractiveContext)& theAIS);
+ XGUI_Displayer(XGUI_Workshop* theWorkshop);
/// Destructor
virtual ~XGUI_Displayer();
void closeAllContexts(const bool isUpdateViewer);
/// Returns currently installed AIS_InteractiveContext
- Handle(AIS_InteractiveContext) AISContext() const { return myAISContext; }
+ Handle(AIS_InteractiveContext) AISContext() const;
protected:
- ///< the viewer where the objects should be visualized
- Handle(AIS_InteractiveContext) myAISContext;
+ XGUI_Workshop* myWorkshop;
std::map<boost::shared_ptr<ModelAPI_Feature>, std::vector<Handle(AIS_InteractiveObject)> > myFeature2AISObjectMap;
};
virtual Handle(AIS_InteractiveContext) AISContext() const = 0;
//! Retrurns V3d_Vioewer from current viewer
- virtual Handle(V3d_Viewer) V3dViewer() const = 0;
+ virtual Handle(V3d_Viewer) v3dViewer() const = 0;
//! Returns Vsd_View object from currently active view window
virtual Handle(V3d_View) activeView() const = 0;
#include "XGUI_ObjectsBrowser.h"
#include "XGUI_Viewer.h"
#include "XGUI_SalomeConnector.h"
-#include "XGUI_SalomeViewer.h"
+#include "XGUI_ViewerProxy.h"
#include <ModelAPI_Feature.h>
#include <ModelAPI_PluginManager.h>
//**************************************************************
void XGUI_SelectionMgr::selectedAISObjects(AIS_ListOfInteractive& theList) const
{
- if (myWorkshop->isSalomeMode()) {
- Handle(AIS_InteractiveContext) aContext = myWorkshop->salomeViewer()->AISContext();
- theList.Clear();
- for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
- theList.Append(aContext->SelectedInteractive());
- } else {
- XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
- aViewer->getSelectedObjects(theList);
- }
+ Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
+ theList.Clear();
+ for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
+ theList.Append(aContext->SelectedInteractive());
}
//**************************************************************
void XGUI_SelectionMgr::selectedShapes(NCollection_List<TopoDS_Shape>& theList) const
{
- if (myWorkshop->isSalomeMode()) {
- theList.Clear();
- Handle(AIS_InteractiveContext) aContext = myWorkshop->salomeViewer()->AISContext();
- for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
- TopoDS_Shape aShape = aContext->SelectedShape();
- if (!aShape.IsNull())
- theList.Append(aShape);
- }
- } else {
- XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
- aViewer->getSelectedShapes(theList);
+ theList.Clear();
+ Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
+ for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
+ TopoDS_Shape aShape = aContext->SelectedShape();
+ if (!aShape.IsNull())
+ theList.Append(aShape);
}
}
--- /dev/null
+#include "XGUI_ViewerProxy.h"
+#include "XGUI_Workshop.h"
+#include "XGUI_MainWindow.h"
+#include "XGUI_ViewPort.h"
+#include "XGUI_ViewWindow.h"
+#include "XGUI_Viewer.h"
+#include "XGUI_SalomeConnector.h"
+
+
+XGUI_ViewerProxy::XGUI_ViewerProxy(XGUI_Workshop* theParent)
+: XGUI_SalomeViewer(theParent), myWorkshop(theParent)
+{
+}
+
+
+Handle(AIS_InteractiveContext) XGUI_ViewerProxy::AISContext() const
+{
+ if (myWorkshop->isSalomeMode()) {
+ return myWorkshop->salomeConnector()->viewer()->AISContext();
+ } else {
+ return myWorkshop->mainWindow()->viewer()->AISContext();
+ }
+}
+
+Handle(V3d_Viewer) XGUI_ViewerProxy::v3dViewer() const
+{
+ if (myWorkshop->isSalomeMode()) {
+ return myWorkshop->salomeConnector()->viewer()->v3dViewer();
+ } else {
+ return myWorkshop->mainWindow()->viewer()->v3dViewer();
+ }
+}
+
+Handle(V3d_View) XGUI_ViewerProxy::activeView() const
+{
+ if (myWorkshop->isSalomeMode()) {
+ return myWorkshop->salomeConnector()->viewer()->activeView();
+ } else {
+ XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
+ return aViewer->activeViewWindow()->viewPort()->getView();
+ }
+}
+
+void XGUI_ViewerProxy::connectToViewer()
+{
+ if (myWorkshop->isSalomeMode()) {
+ XGUI_SalomeViewer* aViewer = myWorkshop->salomeConnector()->viewer();
+
+ connect(aViewer, SIGNAL(lastViewClosed()),
+ this, SIGNAL(lastViewClosed()));
+ connect(aViewer, SIGNAL(tryCloseView()),
+ this, SIGNAL(tryCloseView()));
+ connect(aViewer, SIGNAL(deleteView()),
+ this, SIGNAL(deleteView()));
+ connect(aViewer, SIGNAL(viewCreated()),
+ this, SIGNAL(viewCreated()));
+ 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)));
+ } else {
+ XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
+
+ connect(aViewer, SIGNAL(lastViewClosed()),
+ this, SIGNAL(lastViewClosed()));
+ connect(aViewer, SIGNAL(tryCloseView(XGUI_ViewWindow*)),
+ this, SIGNAL(tryCloseView()));
+ connect(aViewer, SIGNAL(deleteView(XGUI_ViewWindow*)),
+ this, SIGNAL(deleteView()));
+ connect(aViewer, SIGNAL(viewCreated(XGUI_ViewWindow*)),
+ this, SIGNAL(viewCreated()));
+ connect(aViewer, SIGNAL(activated(XGUI_ViewWindow*)),
+ this, SIGNAL(activated()));
+
+ connect(aViewer, SIGNAL(mousePress(XGUI_ViewWindow*, QMouseEvent*)),
+ this, SLOT(onMousePress(XGUI_ViewWindow*, QMouseEvent*)));
+ connect(aViewer, SIGNAL(mouseRelease(XGUI_ViewWindow*, QMouseEvent*)),
+ this, SLOT(onMouseRelease(XGUI_ViewWindow*, QMouseEvent*)));
+ connect(aViewer, SIGNAL(mouseDoubleClick(XGUI_ViewWindow*, QMouseEvent*)),
+ this, SLOT(onMouseDoubleClick(XGUI_ViewWindow*, QMouseEvent*)));
+ connect(aViewer, SIGNAL(mouseMove(XGUI_ViewWindow*, QMouseEvent*)),
+ this, SLOT(onMouseMove(XGUI_ViewWindow*, QMouseEvent*)));
+ connect(aViewer, SIGNAL(keyPress(XGUI_ViewWindow*, QKeyEvent*)),
+ this, SLOT(onKeyPress(XGUI_ViewWindow*, QKeyEvent*)));
+ connect(aViewer, SIGNAL(keyRelease(XGUI_ViewWindow*, QKeyEvent*)),
+ this, SLOT(onKeyRelease(XGUI_ViewWindow*, QKeyEvent*)));
+ }
+}
+
+void XGUI_ViewerProxy::onMousePress(XGUI_ViewWindow*, QMouseEvent* theEvent)
+{
+ emit mousePress(theEvent);
+}
+
+void XGUI_ViewerProxy::onMouseRelease(XGUI_ViewWindow*, QMouseEvent* theEvent)
+{
+ emit mouseRelease(theEvent);
+}
+
+void XGUI_ViewerProxy::onMouseDoubleClick(XGUI_ViewWindow*, QMouseEvent* theEvent)
+{
+ emit mouseDoubleClick(theEvent);
+}
+
+void XGUI_ViewerProxy::onMouseMove(XGUI_ViewWindow*, QMouseEvent* theEvent)
+{
+ emit mouseMove(theEvent);
+}
+
+void XGUI_ViewerProxy::onKeyPress(XGUI_ViewWindow*, QKeyEvent* theEvent)
+{
+ emit keyPress(theEvent);
+}
+
+void XGUI_ViewerProxy::onKeyRelease(XGUI_ViewWindow*, QKeyEvent* theEvent)
+{
+ emit keyRelease(theEvent);
+}
--- /dev/null
+#ifndef XGUI_VIEWERPROXY_H
+#define XGUI_VIEWERPROXY_H
+
+#include "XGUI.h"
+#include "XGUI_SalomeViewer.h"
+
+class XGUI_Workshop;
+class XGUI_ViewWindow;
+
+/**
+* Proxy class which repersents or XGUI_Viewer or Salome Viewer
+* dependently on current launching environment.
+* 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
+{
+ Q_OBJECT
+public:
+ XGUI_ViewerProxy(XGUI_Workshop* theParent);
+
+ //! Returns AIS_InteractiveContext from current OCCViewer
+ virtual Handle(AIS_InteractiveContext) AISContext() const;
+
+ //! Retrurns V3d_Vioewer from current viewer
+ virtual Handle(V3d_Viewer) v3dViewer() const;
+
+ //! Returns Vsd_View object from currently active view window
+ virtual Handle(V3d_View) activeView() const;
+
+ void connectToViewer();
+
+private slots:
+ void onMousePress(XGUI_ViewWindow*, QMouseEvent*);
+ void onMouseRelease(XGUI_ViewWindow*, QMouseEvent*);
+ void onMouseDoubleClick(XGUI_ViewWindow*, QMouseEvent*);
+ void onMouseMove(XGUI_ViewWindow*, QMouseEvent*);
+ void onKeyPress(XGUI_ViewWindow*, QKeyEvent*);
+ void onKeyRelease(XGUI_ViewWindow*, QKeyEvent*);
+
+private:
+ XGUI_Workshop* myWorkshop;
+};
+
+#endif
\ No newline at end of file
#include "XGUI_SalomeViewer.h"
#include "XGUI_ActionsMgr.h"
#include "XGUI_ErrorDialog.h"
+#include "XGUI_ViewerProxy.h"
#include <ModelAPI_PluginManager.h>
#include <ModelAPI_Feature.h>
{
myMainWindow = mySalomeConnector? 0 : new XGUI_MainWindow();
- // In SALOME viewer is accessible only when module is initialized
- // and in SALOME mode myDisplayer object has to be created later
- // So, displayer will be created on demand.
+ myDisplayer = new XGUI_Displayer(this);
mySelector = new XGUI_SelectionMgr(this);
connect(mySelector, SIGNAL(selectionChanged()), this, SLOT(changeCurrentDocument()));
+
myOperationMgr = new XGUI_OperationMgr(this);
myActionsMgr = new XGUI_ActionsMgr(this);
myErrorDlg = new XGUI_ErrorDialog(myMainWindow);
+ myViewerProxy = new XGUI_ViewerProxy(this);
+
connect(myOperationMgr, SIGNAL(operationStarted()), this, SLOT(onOperationStarted()));
connect(myOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
this, SLOT(onOperationStopped(ModuleBase_Operation*)));
createDockWidgets();
mySelector->connectViewers();
}
+ myViewerProxy->connectToViewer();
showObjectBrowser();
if (!isSalomeMode()) {
myMainWindow->showPythonConsole();
}
}
-//******************************************************
-XGUI_Displayer* XGUI_Workshop::displayer() const
-{
- // In SALOME viewer is accessible only when module is initialized
- // and in SALOME mode myDisplayer object has to be created later (on demand)
- if (!myDisplayer) {
- XGUI_Workshop* that = (XGUI_Workshop*)this;
- that->myDisplayer = isSalomeMode() ?
- new XGUI_Displayer(salomeViewer()->AISContext()):
- new XGUI_Displayer(myMainWindow->viewer()->AISContext());
- }
- return myDisplayer;
-}
-
//******************************************************
void XGUI_Workshop::changeCurrentDocument()
{
class XGUI_ActionsMgr;
class XGUI_ErrorDialog;
class XGUI_SalomeViewer;
+class XGUI_ViewerProxy;
class ModuleBase_Operation;
class ModuleBase_PropPanelOperation;
XGUI_SelectionMgr* selector() const { return mySelector; }
//! Returns displayer
- XGUI_Displayer* displayer() const;
+ XGUI_Displayer* displayer() const { return myDisplayer; }
//! ! Returns operation manager.
XGUI_OperationMgr* operationMgr() const { return myOperationMgr; }
void salomeViewerSelectionChanged();
+ XGUI_ViewerProxy* viewer() const { return myViewerProxy; }
+
signals:
void salomeViewerSelection();
XGUI_ActionsMgr* myActionsMgr;
XGUI_SalomeConnector* mySalomeConnector;
XGUI_ErrorDialog* myErrorDlg;
+ XGUI_ViewerProxy* myViewerProxy;
};
#endif