ModuleBase_WidgetFileSelector.h
ModuleBase_DoubleSpinBox.h
ModuleBase_IPropertyPanel.h
+ ModuleBase_IViewer.h
)
SET(PROJECT_SOURCES
ModuleBase_Tools.cpp
+ ModuleBase_IModule.cpp
ModuleBase_Operation.cpp
ModuleBase_OperationDescription.cpp
ModuleBase_ModelWidget.cpp
--- /dev/null
+
+#include "ModuleBase_IModule.h"
+#include "ModuleBase_ViewerPrs.h"
+#include "ModuleBase_Operation.h"
+#include "ModuleBase_ISelection.h"
+
+#include <Events_Loop.h>
+
+#include <ModelAPI_Events.h>
+
+#include <Config_PointerMessage.h>
+
+
+void ModuleBase_IModule::launchOperation(const QString& theCmdId)
+{
+ ModuleBase_Operation* anOperation = createOperation(theCmdId.toStdString());
+ ModuleBase_ISelection* aSelection = myWorkshop->selection();
+ // Initialise operation with preliminary selection
+ std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
+ std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
+ anOperation->initSelection(aSelected, aHighlighted);
+ sendOperation(anOperation);
+}
+
+
+void ModuleBase_IModule::sendOperation(ModuleBase_Operation* theOperation)
+{
+ static Events_ID aModuleEvent = Events_Loop::eventByName(EVENT_OPERATION_LAUNCHED);
+ boost::shared_ptr<Config_PointerMessage> aMessage =
+ boost::shared_ptr<Config_PointerMessage>(new Config_PointerMessage(aModuleEvent, this));
+ aMessage->setPointer(theOperation);
+ Events_Loop::loop()->send(aMessage);
+}
#ifndef ModuleBase_IModule_H\r
#define ModuleBase_IModule_H\r
\r
+#include "ModuleBase.h"
+#include "ModuleBase_IWorkshop.h"\r
+\r
#include <QString>\r
#include <QObject>\r
\r
+\r
class QAction;\r
-class XGUI_Workshop;\r
class Config_WidgetAPI;\r
class ModuleBase_ModelWidget;\r
+class ModuleBase_Operation;\r
+class ModuleBase_IWorkshop;\r
\r
/**\r
* Interface to a module\r
*/\r
-class ModuleBase_IModule : public QObject\r
+class MODULEBASE_EXPORT ModuleBase_IModule : public QObject\r
{\r
public:\r
+\r
+ ModuleBase_IModule(ModuleBase_IWorkshop* theParent): QObject(theParent), myWorkshop(theParent) {}\r
+\r
+ virtual ~ModuleBase_IModule() {}\r
+\r
/// Reads description of features from XML file \r
virtual void createFeatures() = 0;\r
\r
\r
/// Creates an operation and send it to loop\r
/// \param theCmdId the operation name\r
- virtual void launchOperation(const QString& theCmdId) = 0;\r
+ virtual void launchOperation(const QString& theCmdId);\r
\r
/// Called when it is necessary to update a command state (enable or disable it)\r
//virtual bool isFeatureEnabled(const QString& theCmdId) const = 0;\r
return 0;\r
}\r
\r
- virtual ~ModuleBase_IModule()\r
- {\r
- }\r
- ;\r
+ ModuleBase_IWorkshop* workshop() const { return myWorkshop; }\r
+\r
+ protected:\r
+ /// Sends the operation for launching\r
+ /// \param theOperation the operation\r
+ void sendOperation(ModuleBase_Operation* theOperation);\r
+\r
+ /// Creates a new operation\r
+ /// \param theCmdId the operation name\r
+ /// \param theFeatureKind a kind of feature to get the feature xml description\r
+ virtual ModuleBase_Operation* createOperation(const std::string& theCmdId,\r
+ const std::string& theFeatureKind = "") = 0;\r
+\r
+\r
+protected:\r
+\r
+ ModuleBase_IWorkshop* myWorkshop;\r
+\r
};\r
\r
//! This function must return a new module instance.\r
extern "C" {\r
-typedef ModuleBase_IModule* (*CREATE_FUNC)(XGUI_Workshop*);\r
+typedef ModuleBase_IModule* (*CREATE_FUNC)(ModuleBase_IWorkshop*);\r
}\r
\r
#define CREATE_MODULE "createModule"\r
--- /dev/null
+#ifndef ModuleBase_IViewer_H
+#define ModuleBase_IViewer_H
+
+#include "ModuleBase.h"
+#include <QObject>
+#include <AIS_InteractiveContext.hxx>
+#include <V3d_View.hxx>
+
+class QMouseEvent;
+class QKeyEvent;
+class QContextMenuEvent;
+
+/**
+ * A Base object for definition of connector object to
+ * Salome Viewer. Reimplemented in NewGeom_SalomeViewer class
+ */
+class MODULEBASE_EXPORT ModuleBase_IViewer : public QObject
+{
+Q_OBJECT
+ public:
+ ModuleBase_IViewer(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;
+
+ //! Enable or disable selection in the viewer
+ virtual void enableSelection(bool isEnabled) = 0;
+
+ //! Returns true if selection is enabled
+ virtual bool isSelectionEnabled() const = 0;
+
+ //! Enable or disable multiselection in the viewer
+ virtual void enableMultiselection(bool isEnable) = 0;
+
+ //! Returns true if multiselection is enabled
+ virtual bool isMultiSelectionEnabled() const = 0;
+
+ //! Perfroms the fit all for the active view
+ virtual void fitAll() = 0;
+
+ //! Sets the view projection
+ /// \param theX the X projection value
+ /// \param theY the Y projection value
+ /// \param theZ the Z projection value
+ virtual void setViewProjection(double theX, double theY, double theZ) = 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();
+
+ void selectionChanged();
+ void contextMenuRequested(QContextMenuEvent*);
+};
+
+#endif
#include <ModelAPI_Object.h>
-#include <AIS_InteractiveContext.hxx>
-
#include <QObject>
class ModuleBase_IModule;
+class ModuleBase_ISelection;
+class ModuleBase_IViewer;
+class ModuleBase_Operation;
/**
* Class which provides access to Workshop object serveces
public:
ModuleBase_IWorkshop(QObject* theParent)
: QObject(theParent)
- {
- }
+ {}
virtual ~ModuleBase_IWorkshop()
- {
- }
- ;
-
- //! Returns AIS_InteractiveContext from current OCCViewer
- virtual Handle(AIS_InteractiveContext) AISContext() const = 0;
+ {}
- //! Returns list of currently selected data objects
- virtual QList<ObjectPtr> selectedObjects() const = 0;
+ virtual ModuleBase_ISelection* selection() const = 0;
//! Returns instance of loaded module
virtual ModuleBase_IModule* module() const = 0;
+ //! Returns current viewer
+ virtual ModuleBase_IViewer* viewer() const = 0;
+
+ //! Returns currently active operation
+ virtual ModuleBase_Operation* currentOperation() const = 0;
+
signals:
void selectionChanged();
+
+ void operationStarted(ModuleBase_Operation*);
+ void operationStopped(ModuleBase_Operation*);
};
#endif
#include "ModuleBase_WidgetShapeSelector.h"
#include <ModuleBase_IWorkshop.h>
+#include <ModuleBase_ISelection.h>
#include "ModuleBase_WidgetValue.h"
#include <ModuleBase_Tools.h>
#include "ModuleBase_WidgetValueFeature.h"
//********************************************************************
void ModuleBase_WidgetShapeSelector::onSelectionChanged()
{
- QList<ObjectPtr> aObjects = myWorkshop->selectedObjects();
+ QList<ObjectPtr> aObjects = myWorkshop->selection()->selectedObjects();
if (aObjects.size() > 0) {
ObjectPtr aObject = aObjects.first();
if ((!mySelectedObject) && (!aObject))
Events
Config
XGUI
+ ModuleBase
${QT_LIBRARIES}
${suit}
${std}
virtual QStringList nestedActions(const QString& theId) const;
//! Returns interface to Salome viewer
- virtual XGUI_SalomeViewer* viewer() const
+ virtual ModuleBase_IViewer* viewer() const
{
return myProxyViewer;
}
#include <QContextMenuEvent>
NewGeom_SalomeViewer::NewGeom_SalomeViewer(QObject* theParent)
- : XGUI_SalomeViewer(theParent),
+ : ModuleBase_IViewer(theParent),
mySelector(0)
{
}
aVFrame->onFitAll();
}
}
+
+//**********************************************
+void NewGeom_SalomeViewer::setViewProjection(double theX, double theY, double theZ)
+{
+ SUIT_ViewManager* aMgr = mySelector->viewer()->getViewManager();
+ OCCViewer_ViewFrame* aVFrame = dynamic_cast<OCCViewer_ViewFrame*>(aMgr->getActiveView());
+ if (aVFrame) {
+ Handle(V3d_View) aView3d = aVFrame->getViewPort()->getView();
+ if (!aView3d.IsNull()) {
+ aView3d->SetProj(theX, theY, theZ);
+ aView3d->FitAll(0.01, true, true);
+ aView3d->SetZSize(0.);
+ }
+ }
+}
\ No newline at end of file
#include "NewGeom.h"
-#include <XGUI_SalomeViewer.h>
+#include <ModuleBase_IViewer.h>
class SUIT_ViewWindow;
class QMouseEvent;
class NewGeom_OCCSelector;
-class NewGeom_SalomeViewer : public XGUI_SalomeViewer
+class NewGeom_SalomeViewer : public ModuleBase_IViewer
{
Q_OBJECT
public:
//! Perfroms the fit all for the active view
virtual void fitAll();
+ //! Sets the view projection
+ /// \param theX the X projection value
+ /// \param theY the Y projection value
+ /// \param theZ the Z projection value
+ virtual void setViewProjection(double theX, double theY, double theZ);
+
void setSelector(NewGeom_OCCSelector* theSel);
NewGeom_OCCSelector* selector() const
//******************************************************
void PartSet_Listener::processEvent(const boost::shared_ptr<Events_Message>& theMessage)
{
- ModuleBase_Operation* anOperation = myModule->workshop()->operationMgr()->currentOperation();
+ ModuleBase_Operation* anOperation = myModule->xWorkshop()->operationMgr()->currentOperation();
PartSet_OperationSketchBase* aSketchOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
if (!aSketchOp)
return;
- XGUI_Displayer* aDisplayer = myModule->workshop()->displayer();
+ XGUI_Displayer* aDisplayer = myModule->xWorkshop()->displayer();
QString aType = QString(theMessage->eventID().eventText());
if (aType == EVENT_OBJECT_CREATED) {
boost::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
std::set<ObjectPtr> aFeatures = aUpdMsg->objects();
PartSet_OperationSketch* aSketchOp =
- dynamic_cast<PartSet_OperationSketch*>(myModule->workshop()->operationMgr()->currentOperation());
+ dynamic_cast<PartSet_OperationSketch*>(myModule->xWorkshop()->operationMgr()->currentOperation());
std::set<ObjectPtr>::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
for (; anIt != aLast; anIt++) {
// If current operation is Sketch then there is no active sketching operation
// and possible the object was created by Redo operatgion
else if (aSketchOp) {
- XGUI_Displayer* aDisplayer = myModule->workshop()->displayer();
+ XGUI_Displayer* aDisplayer = myModule->xWorkshop()->displayer();
// Very possible it is not displayed
aDisplayer->display(aObj, false);
std::list<int> aModes = aSketchOp->getSelectionModes(aObj);
for (; anIt != aLast; anIt++) {
std::string aGroup = *anIt;
if (aGroup.compare(SketchPlugin_Sketch::ID()) == 0) { // Update only Sketch group
- myModule->workshop()->displayer()->eraseDeletedResults();
+ myModule->xWorkshop()->displayer()->eraseDeletedResults();
myModule->updateCurrentPreview(aGroup);
}
}
#include <XGUI_Viewer.h>
#include <XGUI_Workshop.h>
#include <XGUI_OperationMgr.h>
-#include <XGUI_SelectionMgr.h>
-#include <XGUI_Selection.h>
#include <XGUI_ViewPort.h>
#include <XGUI_ActionsMgr.h>
#include <XGUI_ViewerProxy.h>
#include <Config_ModuleReader.h>
#include <Config_WidgetReader.h>
#include <Events_Loop.h>
-#include <Events_Message.h>
-#include <Events_Error.h>
+//#include <Events_Message.h>
+//#include <Events_Error.h>
#include <GeomAPI_Shape.h>
#include <GeomAPI_AISObject.h>
#endif
/*!Create and return new instance of XGUI_Module*/
-extern "C" PARTSET_EXPORT ModuleBase_IModule* createModule(XGUI_Workshop* theWshop)
+extern "C" PARTSET_EXPORT ModuleBase_IModule* createModule(ModuleBase_IWorkshop* theWshop)
{
return new PartSet_Module(theWshop);
}
-PartSet_Module::PartSet_Module(XGUI_Workshop* theWshop)
+PartSet_Module::PartSet_Module(ModuleBase_IWorkshop* theWshop)
+ : ModuleBase_IModule(theWshop)
{
- myWorkshop = theWshop;
+ //myWorkshop = theWshop;
myListener = new PartSet_Listener(this);
- XGUI_OperationMgr* anOperationMgr = myWorkshop->operationMgr();
+ connect(myWorkshop, SIGNAL(operationStarted(ModuleBase_Operation*)),
+ this, SLOT(onOperationStarted(ModuleBase_Operation*)));
- connect(anOperationMgr, SIGNAL(operationStarted()), this, SLOT(onOperationStarted()));
-
- connect(anOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)), this,
+ connect(myWorkshop, SIGNAL(operationStopped(ModuleBase_Operation*)), this,
SLOT(onOperationStopped(ModuleBase_Operation*)));
- XGUI_ContextMenuMgr* aContextMenuMgr = myWorkshop->contextMenuMgr();
+ XGUI_ContextMenuMgr* aContextMenuMgr = xWorkshop()->contextMenuMgr();
connect(aContextMenuMgr, SIGNAL(actionTriggered(const QString&, bool)), this,
SLOT(onContextMenuCommand(const QString&, bool)));
{
}
-XGUI_Workshop* PartSet_Module::workshop() const
-{
- return myWorkshop;
-}
-
void PartSet_Module::createFeatures()
{
//Registering of validators
launchOperation(aCmd->data().toString());
}
-void PartSet_Module::launchOperation(const QString& theCmdId)
-{
- ModuleBase_Operation* anOperation = createOperation(theCmdId.toStdString());
- //PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
- //if (aPreviewOp) {
- XGUI_Selection* aSelection = myWorkshop->selector()->selection();
- // Initialise operation with preliminary selection
- std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
- std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
- anOperation->initSelection(aSelected, aHighlighted);
- //}
- sendOperation(anOperation);
-}
+//void PartSet_Module::launchOperation(const QString& theCmdId)
+//{
+// ModuleBase_Operation* anOperation = createOperation(theCmdId.toStdString());
+// //PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
+// //if (aPreviewOp) {
+// XGUI_Selection* aSelection = myWorkshop->selector()->selection();
+// // Initialise operation with preliminary selection
+// std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
+// std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
+// anOperation->initSelection(aSelected, aHighlighted);
+// //}
+// sendOperation(anOperation);
+//}
-void PartSet_Module::onOperationStarted()
+void PartSet_Module::onOperationStarted(ModuleBase_Operation* theOperation)
{
- ModuleBase_Operation* aOperation = myWorkshop->operationMgr()->currentOperation();
-
- PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(aOperation);
+ PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(theOperation);
if (aPreviewOp) {
- XGUI_PropertyPanel* aPropPanel = myWorkshop->propertyPanel();
+ XGUI_Workshop* aXWshp = xWorkshop();
+ XGUI_PropertyPanel* aPropPanel = aXWshp->propertyPanel();
connect(aPropPanel, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)), this,
SLOT(onStorePoint2D(ObjectPtr, const std::string&)), Qt::UniqueConnection);
- XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+ XGUI_Displayer* aDisplayer = aXWshp->displayer();
aDisplayer->openLocalContext();
aDisplayer->deactivateObjectsOutOfContext();
}
{
if (!theOperation)
return;
+ XGUI_Workshop* aXWshp = xWorkshop();
PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(theOperation);
if (aPreviewOp) {
- XGUI_PropertyPanel* aPropPanel = myWorkshop->propertyPanel();
+ XGUI_PropertyPanel* aPropPanel = aXWshp->propertyPanel();
//disconnect(aPropPanel, SIGNAL(storedPoint2D(ObjectPtr, const std::string&)),
// this, SLOT(onStorePoint2D(ObjectPtr, const std::string&)));
} else {
// Activate results of current feature for selection
FeaturePtr aFeature = theOperation->feature();
- XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+ XGUI_Displayer* aDisplayer = aXWshp->displayer();
std::list<ResultPtr> aResults = aFeature->results();
std::list<ResultPtr>::const_iterator aIt;
for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
void PartSet_Module::onContextMenuCommand(const QString& theId, bool isChecked)
{
- QList<ObjectPtr> aFeatures = myWorkshop->selector()->selection()->selectedObjects();
+ QList<ObjectPtr> aFeatures = workshop()->selection()->selectedObjects();
if (theId == "EDIT_CMD" && (aFeatures.size() > 0)) {
FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(aFeatures.first());
if (aFeature)
void PartSet_Module::onMousePressed(QMouseEvent* theEvent)
{
-
- PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop
- ->operationMgr()->currentOperation());
+ XGUI_Workshop* aXWshp = xWorkshop();
+ PartSet_OperationSketchBase* aPreviewOp =
+ dynamic_cast<PartSet_OperationSketchBase*>(workshop()->currentOperation());
Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
if (aPreviewOp && (!aView.IsNull())) {
- XGUI_Selection* aSelection = myWorkshop->selector()->selection();
+ ModuleBase_ISelection* aSelection = workshop()->selection();
// Initialise operation with preliminary selection
std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
void PartSet_Module::onMouseReleased(QMouseEvent* theEvent)
{
- PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop
- ->operationMgr()->currentOperation());
+ PartSet_OperationSketchBase* aPreviewOp =
+ dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop->currentOperation());
Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
if (aPreviewOp && (!aView.IsNull())) {
- XGUI_Selection* aSelection = myWorkshop->selector()->selection();
+ ModuleBase_ISelection* aSelection = workshop()->selection();
// Initialise operation with preliminary selection
std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
void PartSet_Module::onMouseMoved(QMouseEvent* theEvent)
{
- PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop
- ->operationMgr()->currentOperation());
+ PartSet_OperationSketchBase* aPreviewOp =
+ dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop->currentOperation());
Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
if (aPreviewOp && (!aView.IsNull()))
aPreviewOp->mouseMoved(theEvent, aView);
void PartSet_Module::onKeyRelease(QKeyEvent* theEvent)
{
- ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
+ ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
if (aPreviewOp) {
aPreviewOp->keyReleased(theEvent->key());
void PartSet_Module::onMouseDoubleClick(QMouseEvent* theEvent)
{
- PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop
- ->operationMgr()->currentOperation());
+ PartSet_OperationSketchBase* aPreviewOp =
+ dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop->currentOperation());
Handle(V3d_View) aView = myWorkshop->viewer()->activeView();
if (aPreviewOp && (!aView.IsNull())) {
- XGUI_Selection* aSelection = myWorkshop->selector()->selection();
+ ModuleBase_ISelection* aSelection = workshop()->selection();
// Initialise operation with preliminary selection
std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
{
//erasePlanes();
myWorkshop->viewer()->setViewProjection(theX, theY, theZ);
- myWorkshop->actionsMgr()->update();
+ xWorkshop()->actionsMgr()->update();
//PartSet_TestOCC::testSelection(myWorkshop);
}
else {
anOperation->setFeature(aFeature);
}
- XGUI_Selection* aSelection = myWorkshop->selector()->selection();
+ ModuleBase_ISelection* aSelection = workshop()->selection();
// Initialise operation with preliminary selection
std::list<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
std::list<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
} else if (aFeature) {
anOperation->setFeature(aFeature);
//Deactivate result of current feature in order to avoid its selection
- XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+ XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
std::list<ResultPtr> aResults = aFeature->results();
std::list<ResultPtr>::const_iterator aIt;
for (aIt = aResults.cbegin(); aIt != aResults.cend(); ++aIt) {
}
}
sendOperation(anOperation);
- myWorkshop->actionsMgr()->updateCheckState();
+ xWorkshop()->actionsMgr()->updateCheckState();
}
void PartSet_Module::onMultiSelectionEnabled(bool theEnabled)
{
- XGUI_ViewerProxy* aViewer = myWorkshop->viewer();
+ ModuleBase_IViewer* aViewer = myWorkshop->viewer();
aViewer->enableMultiselection(theEnabled);
}
void PartSet_Module::onStopSelection(const QList<ObjectPtr>& theFeatures, const bool isStop)
{
- XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+ XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
if (!isStop) {
foreach(ObjectPtr aObject, theFeatures)
{
}
aDisplayer->stopSelection(theFeatures, isStop, false);
- XGUI_ViewerProxy* aViewer = myWorkshop->viewer();
+ ModuleBase_IViewer* aViewer = myWorkshop->viewer();
aViewer->enableSelection(!isStop);
aDisplayer->updateViewer();
void PartSet_Module::onSetSelection(const QList<ObjectPtr>& theFeatures)
{
- XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+ XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
aDisplayer->setSelected(theFeatures, false);
aDisplayer->updateViewer();
}
void PartSet_Module::onCloseLocalContext()
{
- XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+ XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
aDisplayer->deactivateObjectsOutOfContext();
aDisplayer->closeLocalContexts();
}
void PartSet_Module::onFeatureConstructed(ObjectPtr theFeature, int theMode)
{
bool isDisplay = theMode != PartSet_OperationSketchBase::FM_Hide;
- ModuleBase_Operation* aCurOperation = myWorkshop->operationMgr()->currentOperation();
+ ModuleBase_Operation* aCurOperation = myWorkshop->currentOperation();
PartSet_OperationSketchBase* aPrevOp = dynamic_cast<PartSet_OperationSketchBase*>(aCurOperation);
if (aPrevOp) {
std::list<FeaturePtr> aList = aPrevOp->subFeatures();
- XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+ XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
std::list<int> aModes = aPrevOp->getSelectionModes(aPrevOp->feature());
std::list<FeaturePtr>::iterator aSFIt;
for (aSFIt = aList.begin(); aSFIt != aList.end(); ++aSFIt) {
if (theCmdId == PartSet_OperationSketch::Type()) {
anOperation = new PartSet_OperationSketch(theCmdId.c_str(), this);
} else {
- ModuleBase_Operation* aCurOperation = myWorkshop->operationMgr()->currentOperation();
+ ModuleBase_Operation* aCurOperation = myWorkshop->currentOperation();
FeaturePtr aSketch;
PartSet_OperationSketchBase* aPrevOp = dynamic_cast<PartSet_OperationSketchBase*>(aCurOperation);
if (aPrevOp) {
std::string aXmlCfg = aWdgReader.featureWidgetCfg(aFeatureKind);
std::string aDescription = aWdgReader.featureDescription(aFeatureKind);
- //QString aXmlRepr = QString::fromStdString(aXmlCfg);
- //ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aXmlRepr.toStdString(),
- // myWorkshop->moduleConnector());
- //QWidget* aContent = myWorkshop->propertyPanel()->contentWidget();
- //qDeleteAll(aContent->children());
- //aFactory.createWidget(aContent);
-
anOperation->getDescription()->setDescription(QString::fromStdString(aDescription));
anOperation->getDescription()->setXmlRepresentation(QString::fromStdString(aXmlCfg));
- //anOperation->setModelWidgets(aXmlRepr.toStdString(), aFactory.getModelWidgets());
-
// connect the operation
PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
if (aPreviewOp) {
return anOperation;
}
-void PartSet_Module::sendOperation(ModuleBase_Operation* theOperation)
-{
- static Events_ID aModuleEvent = Events_Loop::eventByName(EVENT_OPERATION_LAUNCHED);
- boost::shared_ptr<Config_PointerMessage> aMessage =
- boost::shared_ptr<Config_PointerMessage>(new Config_PointerMessage(aModuleEvent, this));
- aMessage->setPointer(theOperation);
- Events_Loop::loop()->send(aMessage);
-}
+//void PartSet_Module::sendOperation(ModuleBase_Operation* theOperation)
+//{
+// static Events_ID aModuleEvent = Events_Loop::eventByName(EVENT_OPERATION_LAUNCHED);
+// boost::shared_ptr<Config_PointerMessage> aMessage =
+// boost::shared_ptr<Config_PointerMessage>(new Config_PointerMessage(aModuleEvent, this));
+// aMessage->setPointer(theOperation);
+// Events_Loop::loop()->send(aMessage);
+//}
void PartSet_Module::activateFeature(ObjectPtr theFeature, const bool isUpdateViewer)
{
- ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
+ ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
if (aPreviewOp) {
- XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+ XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
std::list<int> aModes = aPreviewOp->getSelectionModes(theFeature);
aDisplayer->activateInLocalContext(theFeature, aModes, isUpdateViewer);
void PartSet_Module::updateCurrentPreview(const std::string& theCmdId)
{
- ModuleBase_Operation* anOperation = myWorkshop->operationMgr()->currentOperation();
+ ModuleBase_Operation* anOperation = myWorkshop->currentOperation();
if (!anOperation)
return;
if (!aFeature || aFeature->getKind() != theCmdId)
return;
- XGUI_Displayer* aDisplayer = myWorkshop->displayer();
+ XGUI_Displayer* aDisplayer = xWorkshop()->displayer();
// Hide result of sketch
std::list<ResultPtr> aResults = aFeature->results();
std::list<ResultPtr>::const_iterator aIt;
{
FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theFeature);
- PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop
- ->operationMgr()->currentOperation());
+ PartSet_OperationSketchBase* aPreviewOp =
+ dynamic_cast<PartSet_OperationSketchBase*>(myWorkshop->currentOperation());
if (!aPreviewOp)
return;
{
if (theType == "sketch-start-label") {
PartSet_WidgetSketchLabel* aWgt = new PartSet_WidgetSketchLabel(theParent, theWidgetApi, "");
- aWgt->setOperationsMgr(myWorkshop->operationMgr());
+ aWgt->setOperationsMgr(xWorkshop()->operationMgr());
theModelWidgets.append(aWgt);
return aWgt->getControl();
} else
return 0;
}
+
+
+XGUI_Workshop* PartSet_Module::xWorkshop() const
+{
+ XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(workshop());
+ if (aConnector) {
+ return aConnector->workshop();
+ }
+ return 0;
+}
\ No newline at end of file
class PartSet_Listener;
class ModelAPI_Feature;
class XGUI_ViewerPrs;
+class XGUI_Workshop;
class ModuleBase_Operation;
class GeomAPI_AISObject;
Q_OBJECT
public:
- PartSet_Module(XGUI_Workshop* theWshop);
+ PartSet_Module(ModuleBase_IWorkshop* theWshop);
virtual ~PartSet_Module();
- /// Returns the module workshop
- /// \returns a workshop instance
- XGUI_Workshop* workshop() const;
-
/// Reads description of features from XML file
virtual void createFeatures();
/// Creates an operation and send it to loop
/// \param theCmdId the operation name
- virtual void launchOperation(const QString& theCmdId);
-
- /// Called when it is necessary to update a command state (enable or disable it)
- //virtual bool isFeatureEnabled(const QString& theCmdId) const;
-
- /// Displays or erase the current operation preview, if it has it.
- /// \param theFeature the feature instance to be displayed
- /// \param isDisplay the state whether the presentation should be displayed or erased
- /// \param isUpdateViewer the flag whether the viewer should be updated
- //void visualizePreview(FeaturePtr theFeature, bool isDisplay,
- // const bool isUpdateViewer = true);
+ //virtual void launchOperation(const QString& theCmdId);
/// Activates the feature in the displayer
/// \param theFeature the feature instance to be displayed
Config_WidgetAPI* theWidgetApi,
QList<ModuleBase_ModelWidget*>& theModelWidgets);
+ XGUI_Workshop* xWorkshop() const;
+
public slots:
void onFeatureTriggered();
/// SLOT, that is called after the operation is started. Connect on the focus activated signal
- void onOperationStarted();
+ void onOperationStarted(ModuleBase_Operation* theOperation);
/// SLOT, that is called after the operation is stopped. Switched off the modfications performed
/// by the operation start
void onOperationStopped(ModuleBase_Operation* theOperation);
ModuleBase_Operation* createOperation(const std::string& theCmdId,
const std::string& theFeatureKind = "");
- /// Sends the operation
- /// \param theOperation the operation
- void sendOperation(ModuleBase_Operation* theOperation);
protected:
//! Edits the feature
void editFeature(FeaturePtr theFeature);
private:
- XGUI_Workshop* myWorkshop;
+ //XGUI_Workshop* myWorkshop;
PartSet_Listener* myListener;
std::map<std::string, std::string> myFeaturesInFiles;
XGUI_SalomeConnector.h
XGUI_ActionsMgr.h
XGUI_ErrorDialog.h
- XGUI_SalomeViewer.h
XGUI_ViewerProxy.h
XGUI_PropertyPanel.h
XGUI_ContextMenuMgr.h
#include "XGUI_ViewerProxy.h"
#include "XGUI_SelectionMgr.h"
#include "XGUI_Selection.h"
+#include "XGUI_OperationMgr.h"
XGUI_ModuleConnector::XGUI_ModuleConnector(XGUI_Workshop* theWorkshop)
: ModuleBase_IWorkshop(theWorkshop),
{
XGUI_SelectionMgr* aSelector = myWorkshop->selector();
connect(aSelector, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged()));
+
+ XGUI_OperationMgr* anOperationMgr = myWorkshop->operationMgr();
+
+ connect(anOperationMgr, SIGNAL(operationStarted(ModuleBase_Operation*)),
+ this, SIGNAL(operationStarted(ModuleBase_Operation*)));
+ connect(anOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
+ this, SIGNAL(operationStopped(ModuleBase_Operation*)));
}
XGUI_ModuleConnector::~XGUI_ModuleConnector()
{
}
-Handle(AIS_InteractiveContext) XGUI_ModuleConnector::AISContext() const
+ModuleBase_ISelection* XGUI_ModuleConnector::selection() const
{
- return myWorkshop->viewer()->AISContext();
+ return myWorkshop->selector()->selection();
}
-QList<ObjectPtr> XGUI_ModuleConnector::selectedObjects() const
+ModuleBase_IModule* XGUI_ModuleConnector::module() const
{
- return myWorkshop->selector()->selection()->selectedObjects();
+ return myWorkshop->module();
}
-ModuleBase_IModule* XGUI_ModuleConnector::module() const
+ModuleBase_IViewer* XGUI_ModuleConnector::viewer() const
{
- return myWorkshop->module();
+ return myWorkshop->viewer();
+}
+
+ModuleBase_Operation* XGUI_ModuleConnector::currentOperation() const
+{
+ return myWorkshop->operationMgr()->currentOperation();
}
virtual ~XGUI_ModuleConnector();
- //! Returns AIS_InteractiveContext from current OCCViewer
- virtual Handle(AIS_InteractiveContext) AISContext() const;
-
//! Returns list of currently selected data objects
- virtual QList<ObjectPtr> selectedObjects() const;
+ virtual ModuleBase_ISelection* selection() const;
//! Returns instance of loaded module
virtual ModuleBase_IModule* module() const;
+ //! Returns current viewer
+ virtual ModuleBase_IViewer* viewer() const;
+
+ //! Returns currently active operation
+ virtual ModuleBase_Operation* currentOperation() const;
+
+ XGUI_Workshop* workshop() const { return myWorkshop; }
+
private:
XGUI_Workshop* myWorkshop;
};
myOperations.append(theOperation);
connect(theOperation, SIGNAL(stopped()), this, SLOT(onOperationStopped()));
- connect(theOperation, SIGNAL(started()), this, SIGNAL(operationStarted()));
+ connect(theOperation, SIGNAL(started()), this, SLOT(onOperationStarted()));
connect(theOperation, SIGNAL(resumed()), this, SIGNAL(operationResumed()));
theOperation->start();
return true;
}
+void XGUI_OperationMgr::onOperationStarted()
+{
+ ModuleBase_Operation* aSenderOperation = dynamic_cast<ModuleBase_Operation*>(sender());
+ emit operationStarted(aSenderOperation);
+}
+
void XGUI_OperationMgr::onOperationStopped()
{
ModuleBase_Operation* aSenderOperation = dynamic_cast<ModuleBase_Operation*>(sender());
signals:
/// Signal about an operation is started. It is emitted after the start() of operation is done.
- void operationStarted();
+ void operationStarted(ModuleBase_Operation* theOperation);
/// Signal about an operation is stopped. It is emitted after the stop() of operation is done.
/// \param theOperation a stopped operation
void operationStopped(ModuleBase_Operation* theOperation);
/// Slot that is called by an operation stop. Removes the stopped operation form the stack.
/// If there is a suspended operation, restart it.
void onOperationStopped();
+ void onOperationStarted();
private:
typedef QList<ModuleBase_Operation*> Operations; ///< definition for a list of operations
#include <QStringList>
class QMainWindow;
-class XGUI_SalomeViewer;
+class ModuleBase_IViewer;
/**
* An interface which provides a connection of XGUI functionality
virtual QStringList nestedActions(const QString& theId) const = 0;
//! Returns interface to Salome viewer
- virtual XGUI_SalomeViewer* viewer() const = 0;
+ virtual ModuleBase_IViewer* viewer() const = 0;
virtual void createPreferences() = 0;
};
+++ /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;
-class QContextMenuEvent;
-
-/**
- * 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;
-
- //! Enable or disable selection in the viewer
- virtual void enableSelection(bool isEnabled) = 0;
-
- //! Returns true if selection is enabled
- virtual bool isSelectionEnabled() const = 0;
-
- //! Enable or disable multiselection in the viewer
- virtual void enableMultiselection(bool isEnable) = 0;
-
- //! Returns true if multiselection is enabled
- virtual bool isMultiSelectionEnabled() const = 0;
-
- //! Perfroms the fit all for the active view
- virtual void fitAll() = 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();
-
- void selectionChanged();
- void contextMenuRequested(QContextMenuEvent*);
-};
-
-#endif
#include "XGUI_SalomeConnector.h"
XGUI_ViewerProxy::XGUI_ViewerProxy(XGUI_Workshop* theParent)
- : XGUI_SalomeViewer(theParent),
+ : ModuleBase_IViewer(theParent),
myWorkshop(theParent)
{
}
void XGUI_ViewerProxy::connectToViewer()
{
if (myWorkshop->isSalomeMode()) {
- XGUI_SalomeViewer* aViewer = myWorkshop->salomeConnector()->viewer();
+ ModuleBase_IViewer* aViewer = myWorkshop->salomeConnector()->viewer();
connect(aViewer, SIGNAL(lastViewClosed()), this, SIGNAL(lastViewClosed()));
connect(aViewer, SIGNAL(tryCloseView()), this, SIGNAL(tryCloseView()));
#define XGUI_VIEWERPROXY_H
#include "XGUI.h"
-#include "XGUI_SalomeViewer.h"
+#include <ModuleBase_IViewer.h>
class XGUI_Workshop;
class XGUI_ViewWindow;
* It is reccomennded to use this class in operation for accessing to viewer
* functionality instead of direct access to a viewer
*/
-class XGUI_EXPORT XGUI_ViewerProxy : public XGUI_SalomeViewer
+class XGUI_EXPORT XGUI_ViewerProxy : public ModuleBase_IViewer
{
Q_OBJECT
public:
/// \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);
+ virtual void setViewProjection(double theX, double theY, double theZ);
//! Sets the view fitted all
- void fitAll();
+ virtual void fitAll();
/// Connects to a viewer according to current environment
void connectToViewer();
#include "XGUI_Displayer.h"
#include "XGUI_OperationMgr.h"
#include "XGUI_SalomeConnector.h"
-#include "XGUI_SalomeViewer.h"
#include "XGUI_ActionsMgr.h"
#include "XGUI_ErrorDialog.h"
#include "XGUI_ViewerProxy.h"
#include <ModuleBase_SelectionValidator.h>
#include <ModuleBase_WidgetFactory.h>
#include <ModuleBase_Tools.h>
+#include <ModuleBase_IViewer.h>
#include <Config_Common.h>
#include <Config_FeatureMessage.h>
myModuleConnector = new XGUI_ModuleConnector(this);
- connect(myOperationMgr, SIGNAL(operationStarted()), SLOT(onOperationStarted()));
+ connect(myOperationMgr, SIGNAL(operationStarted(ModuleBase_Operation*)),
+ SLOT(onOperationStarted()));
connect(myOperationMgr, SIGNAL(operationResumed()), SLOT(onOperationStarted()));
connect(myOperationMgr, SIGNAL(operationStopped(ModuleBase_Operation*)),
SLOT(onOperationStopped(ModuleBase_Operation*)));
}
#endif
- ModuleBase_IModule* aModule = crtInst ? crtInst(this) : 0;
+ ModuleBase_IModule* aModule = crtInst ? crtInst(myModuleConnector) : 0;
if (!err.isEmpty()) {
if (mainWindow()) {
}
//**************************************************************
-XGUI_SalomeViewer* XGUI_Workshop::salomeViewer() const
+ModuleBase_IViewer* XGUI_Workshop::salomeViewer() const
{
return mySalomeConnector->viewer();
}
class ModuleBase_Operation;
class ModuleBase_IModule;
+class ModuleBase_IViewer;
class Config_FeatureMessage;
class Config_PointerMessage;
}
//! Provides an object which provides interface to Salome Viewer
- XGUI_SalomeViewer* salomeViewer() const;
+ ModuleBase_IViewer* salomeViewer() const;
//! Returns true if the application works as SALOME module
bool isSalomeMode() const