NewGeom_Module.h
NewGeom_DataModel.h
NewGeom_OCCSelector.h
+ NewGeom_SalomeViewer.h
)
SET(PROJECT_AUTOMOC
NewGeom_Module.cpp
NewGeom_DataModel.cpp
NewGeom_OCCSelector.cpp
+ NewGeom_SalomeViewer.cpp
)
SET(PROJECT_RESOURCES
: LightApp_Module( "NewGeom" ), mySelector(0)
{
myWorkshop = new XGUI_Workshop(this);
+ myProxyViewer = new NewGeom_SalomeViewer(this);
}
//******************************************************
foreach(SUIT_Selector* aSel, aList) {
aSel->setEnabled(aSel == aSelector);
}
+ myProxyViewer->setSelector(aSelector);
return aSelector;
}
return 0;
return QStringList();
}
-//******************************************************
-Handle(AIS_InteractiveContext) NewGeom_Module::AISContext() const
-{
- Handle(AIS_InteractiveContext) aContext;
- OCCViewer_Viewer* aViewer = mySelector->viewer();
- if (aViewer) {
- aContext = aViewer->getAISContext();
- }
- return aContext;
-}
-
//******************************************************
void NewGeom_Module::selectionChanged()
{
#define NewGeom_Module_H
#include "NewGeom.h"
+#include "NewGeom_SalomeViewer.h"
#include <LightApp_Module.h>
#include <XGUI_SalomeConnector.h>
class XGUI_Workshop;
class NewGeom_OCCSelector;
class OCCViewer_Viewer;
+
/**
* An implementation of SALOME connector class for implementation of
* XGUI functionality as a module of SALOME
//! Returns list of nested actions according to the given command ID
virtual QStringList nestedActions(const QString& theId) const;
- //! Returns AIS_InteractiveContext from current OCCViewer
- virtual Handle(AIS_InteractiveContext) AISContext() const;
+ //! Returns interface to Salome viewer
+ virtual XGUI_SalomeViewer* viewer() const { return myProxyViewer; }
public slots:
virtual bool activateModule( SUIT_Study* theStudy);
NewGeom_OCCSelector* mySelector;
+ NewGeom_SalomeViewer* myProxyViewer;
+
QMap<QString, QStringList> myNestedActions;
};
--- /dev/null
+
+#include "NewGeom_SalomeViewer.h"
+#include "NewGeom_OCCSelector.h"
+
+#include <OCCViewer_ViewWindow.h>
+#include <OCCViewer_ViewPort3d.h>
+
+#include <SUIT_ViewManager.h>
+
+NewGeom_SalomeViewer::NewGeom_SalomeViewer(QObject* theParent)
+: XGUI_SalomeViewer(theParent), mySelector(0)
+{
+}
+
+
+Handle(AIS_InteractiveContext) NewGeom_SalomeViewer::AISContext() const
+{
+ return mySelector->viewer()->getAISContext();
+}
+
+Handle(V3d_Viewer) NewGeom_SalomeViewer::V3dViewer() const
+{
+ return mySelector->viewer()->getViewer3d();
+}
+
+Handle(V3d_View) NewGeom_SalomeViewer::activeView() const
+{
+ OCCViewer_Viewer* aViewer = mySelector->viewer();
+ SUIT_ViewManager* aMgr = aViewer->getViewManager();
+ OCCViewer_ViewWindow* aWnd = static_cast<OCCViewer_ViewWindow*>(aMgr->getActiveView());
+ return aWnd->getViewPort()->getView();
+}
+
+void NewGeom_SalomeViewer::setSelector(NewGeom_OCCSelector* theSel)
+{
+ if (mySelector) {
+ if (mySelector == theSel)
+ return;
+ else {
+ mySelector->viewer()->getViewManager()->disconnect(this);
+ }
+ }
+ mySelector = theSel;
+ OCCViewer_Viewer* aViewer = mySelector->viewer();
+ SUIT_ViewManager* aMgr = aViewer->getViewManager();
+
+ connect(aMgr, SIGNAL(lastViewClosed(SUIT_ViewManager*)),
+ this, SIGNAL(lastViewClosed()));
+ connect(aMgr, SIGNAL(tryCloseView(SUIT_ViewManager*)),
+ this, SIGNAL(tryCloseView()));
+ connect(aMgr, SIGNAL(deleteView(SUIT_ViewManager*)),
+ this, SIGNAL(deleteView()));
+ connect(aMgr, SIGNAL(viewCreated(SUIT_ViewManager*)),
+ this, SIGNAL(viewCreated()));
+ connect(aMgr, SIGNAL(activated(SUIT_ViewManager*)),
+ this, SIGNAL(activated()));
+
+ connect(aMgr, SIGNAL(mousePress(SUIT_ViewWindow*, QMouseEvent*)),
+ this, SLOT(onMousePress(SUIT_ViewWindow*, QMouseEvent*)));
+ connect(aMgr, SIGNAL(mouseRelease(SUIT_ViewWindow*, QMouseEvent*)),
+ this, SLOT(onMouseRelease(SUIT_ViewWindow*, QMouseEvent*)));
+ connect(aMgr, SIGNAL(mouseDoubleClick(SUIT_ViewWindow*, QMouseEvent*)),
+ this, SLOT(onMouseDoubleClick(SUIT_ViewWindow*, QMouseEvent*)));
+ connect(aMgr, SIGNAL(mouseMove(SUIT_ViewWindow*, QMouseEvent*)),
+ this, SLOT(onMouseMove(SUIT_ViewWindow*, QMouseEvent*)));
+ connect(aMgr, SIGNAL(keyPress(SUIT_ViewWindow*, QKeyEvent*)),
+ this, SLOT(onKeyPress(SUIT_ViewWindow*, QKeyEvent*)));
+ connect(aMgr, SIGNAL(keyRelease(SUIT_ViewWindow*, QKeyEvent*)),
+ this, SLOT(onKeyRelease(SUIT_ViewWindow*, QKeyEvent*)));
+}
+
+
+void NewGeom_SalomeViewer::onMousePress(SUIT_ViewWindow*, QMouseEvent* theEvent)
+{
+ emit mousePress(theEvent);
+}
+
+void NewGeom_SalomeViewer::onMouseRelease(SUIT_ViewWindow*, QMouseEvent* theEvent)
+{
+ emit mouseRelease(theEvent);
+}
+
+void NewGeom_SalomeViewer::onMouseDoubleClick(SUIT_ViewWindow*, QMouseEvent* theEvent)
+{
+ emit mouseDoubleClick(theEvent);
+}
+
+void NewGeom_SalomeViewer::onMouseMove(SUIT_ViewWindow*, QMouseEvent* theEvent)
+{
+ emit mouseMove(theEvent);
+}
+
+void NewGeom_SalomeViewer::onKeyPress(SUIT_ViewWindow*, QKeyEvent* theEvent)
+{
+ emit keyPress(theEvent);
+}
+
+void NewGeom_SalomeViewer::onKeyRelease(SUIT_ViewWindow*, QKeyEvent* theEvent)
+{
+ emit keyRelease(theEvent);
+}
--- /dev/null
+
+
+#ifndef NewGeom_SalomeViewer_H
+#define NewGeom_SalomeViewer_H
+
+#include "NewGeom.h"
+
+#include <XGUI_SalomeViewer.h>
+
+class SUIT_ViewWindow;
+class QMouseEvent;
+class QKeyEvent;
+
+class NewGeom_OCCSelector;
+
+class NewGeom_SalomeViewer: public XGUI_SalomeViewer
+{
+ Q_OBJECT
+public:
+ NewGeom_SalomeViewer(QObject* 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 setSelector(NewGeom_OCCSelector* theSel);
+
+ NewGeom_OCCSelector* selector() const { return mySelector; }
+
+private slots:
+ void onMousePress(SUIT_ViewWindow*, QMouseEvent*);
+ void onMouseRelease(SUIT_ViewWindow*, QMouseEvent*);
+ void onMouseDoubleClick(SUIT_ViewWindow*, QMouseEvent*);
+ void onMouseMove(SUIT_ViewWindow*, QMouseEvent*);
+ void onKeyPress(SUIT_ViewWindow*, QKeyEvent*);
+ void onKeyRelease(SUIT_ViewWindow*, QKeyEvent*);
+
+
+private:
+ NewGeom_OCCSelector* mySelector;
+
+};
+
+#endif
XGUI_SalomeConnector.h
XGUI_ActionsMgr.h
XGUI_ErrorDialog.h
+ XGUI_SalomeViewer.h
)
SET(PROJECT_AUTOMOC
#include "XGUI.h"
-#include <AIS_InteractiveContext.hxx>
#include <QString>
#include <QStringList>
class QMainWindow;
+class XGUI_SalomeViewer;
/**
* An interface which provides a connection of XGUI functionality
//! Returns list of nested actions according to the given command ID
virtual QStringList nestedActions(const QString& theId) const = 0;
-
- //! Returns AIS_InteractiveContext from current OCCViewer
- virtual Handle(AIS_InteractiveContext) AISContext() const = 0;
+
+ //! Returns interface to Salome viewer
+ virtual XGUI_SalomeViewer* viewer() const = 0;
};
#endif
\ No newline at end of file
--- /dev/null
+#ifndef XGUI_SALOMEVIEWER_H
+#define XGUI_SALOMEVIEWER_H
+
+#include "XGUI.h"
+
+#include <QObject>
+#include <AIS_InteractiveContext.hxx>
+#include <V3d_View.hxx>
+
+class QMouseEvent;
+class QKeyEvent;
+
+/**
+* A Base object for definition of connector object to
+* Salome Viewer. Reimplemented in NewGeom_SalomeViewer class
+*/
+class XGUI_EXPORT XGUI_SalomeViewer: public QObject
+{
+ Q_OBJECT
+public:
+ XGUI_SalomeViewer(QObject* theParent):QObject(theParent) {}
+
+ //! Returns AIS_InteractiveContext from current OCCViewer
+ virtual Handle(AIS_InteractiveContext) AISContext() const = 0;
+
+ //! Retrurns V3d_Vioewer from current viewer
+ virtual Handle(V3d_Viewer) V3dViewer() const = 0;
+
+ //! Returns Vsd_View object from currently active view window
+ virtual Handle(V3d_View) activeView() const = 0;
+
+signals:
+ void lastViewClosed();
+ void tryCloseView();
+ void deleteView();
+ void viewCreated();
+ void mousePress(QMouseEvent* theEvent);
+ void mouseRelease(QMouseEvent* theEvent);
+ void mouseDoubleClick(QMouseEvent* theEvent);
+ void mouseMove(QMouseEvent* theEvent);
+ void keyPress(QKeyEvent* theEvent);
+ void keyRelease(QKeyEvent* theEvent);
+ void activated();
+
+};
+
+#endif
\ No newline at end of file
#include "XGUI_ObjectsBrowser.h"
#include "XGUI_Viewer.h"
#include "XGUI_SalomeConnector.h"
+#include "XGUI_SalomeViewer.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->salomeConnector()->AISContext();
+ Handle(AIS_InteractiveContext) aContext = myWorkshop->salomeViewer()->AISContext();
theList.Clear();
for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected())
theList.Append(aContext->SelectedInteractive());
{
if (myWorkshop->isSalomeMode()) {
theList.Clear();
- Handle(AIS_InteractiveContext) aContext = myWorkshop->salomeConnector()->AISContext();
+ Handle(AIS_InteractiveContext) aContext = myWorkshop->salomeViewer()->AISContext();
for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) {
TopoDS_Shape aShape = aContext->SelectedShape();
if (!aShape.IsNull())
XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
aViewer->getSelectedShapes(theList);
}
-}
\ No newline at end of file
+}
#include "XGUI_Displayer.h"
#include "XGUI_OperationMgr.h"
#include "XGUI_SalomeConnector.h"
+#include "XGUI_SalomeViewer.h"
#include "XGUI_ActionsMgr.h"
#include "XGUI_ErrorDialog.h"
if (!myDisplayer) {
XGUI_Workshop* that = (XGUI_Workshop*)this;
that->myDisplayer = isSalomeMode() ?
- new XGUI_Displayer(salomeConnector()->AISContext()):
+ new XGUI_Displayer(salomeViewer()->AISContext()):
new XGUI_Displayer(myMainWindow->viewer()->AISContext());
}
return myDisplayer;
{
emit salomeViewerSelection();
}
+
+
+//**************************************************************
+XGUI_SalomeViewer* XGUI_Workshop::salomeViewer() const
+{
+ return mySalomeConnector->viewer();
+}
class XGUI_ObjectsBrowser;
class XGUI_ActionsMgr;
class XGUI_ErrorDialog;
+class XGUI_SalomeViewer;
+
class ModuleBase_Operation;
class ModuleBase_PropPanelOperation;
//! Redefinition of Events_Listener method
virtual void processEvent(const Events_Message* theMessage);
+ //! Returns an object which provides interface to Salome Module (LightApp_Module)
XGUI_SalomeConnector* salomeConnector() const { return mySalomeConnector; }
+ //! Provides an object which provides interface to Salome Viewer
+ XGUI_SalomeViewer* salomeViewer() const;
+
//! Returns true if the application works as SALOME module
bool isSalomeMode() const { return mySalomeConnector != 0; }