From: vsv Date: Tue, 3 Jun 2014 08:17:50 +0000 (+0400) Subject: IWorkshop interface for Module is created X-Git-Tag: V_0.4.4~335 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=dc4b9ee9f5445b39bcaeb3b7f05627774e343ffa;p=modules%2Fshaper.git IWorkshop interface for Module is created --- diff --git a/CMakeLists.txt b/CMakeLists.txt index bef4cdee8..4f70d821c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,7 @@ INCLUDE(FindBoost) INCLUDE(FindPython) INCLUDE(FindSalome) INCLUDE(FindSolveSpace) +INCLUDE(FindCAS) IF(UNIX) IF(CMAKE_COMPILER_IS_GNUCC) diff --git a/src/Config/CMakeLists.txt b/src/Config/CMakeLists.txt index 2e954c8a8..ebb5efb69 100644 --- a/src/Config/CMakeLists.txt +++ b/src/Config/CMakeLists.txt @@ -4,7 +4,7 @@ INCLUDE(XMLProcessing) INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/src/Events) SET(PROJECT_HEADERS - Config.h + Config_def.h Config_FeatureMessage.h Config_XMLReader.h Config_ModuleReader.h diff --git a/src/Config/Config.h b/src/Config/Config.h deleted file mode 100644 index 587ac534d..000000000 --- a/src/Config/Config.h +++ /dev/null @@ -1,18 +0,0 @@ -#ifndef CONFIG_H -#define CONFIG_H - -#if defined CONFIG_EXPORTS -#if defined WIN32 -#define CONFIG_EXPORT __declspec( dllexport ) -#else -#define CONFIG_EXPORT -#endif -#else -#if defined WIN32 -#define CONFIG_EXPORT __declspec( dllimport ) -#else -#define CONFIG_EXPORT -#endif -#endif - -#endif //CONFIG_H diff --git a/src/Config/Config_Common.h b/src/Config/Config_Common.h index 40051dc2a..2a579b91e 100644 --- a/src/Config/Config_Common.h +++ b/src/Config/Config_Common.h @@ -8,7 +8,7 @@ #ifndef Config_Common_H_ #define Config_Common_H_ -#include "Config.h" +#include "Config_def.h" #include #include diff --git a/src/Config/Config_FeatureMessage.h b/src/Config/Config_FeatureMessage.h index 9328e0690..2613c9926 100644 --- a/src/Config/Config_FeatureMessage.h +++ b/src/Config/Config_FeatureMessage.h @@ -1,7 +1,7 @@ #ifndef CONFIG_MESSAGE_H #define CONFIG_MESSAGE_H -#include +#include #include #include diff --git a/src/Config/Config_FeatureReader.h b/src/Config/Config_FeatureReader.h index 1add8438d..468cb9911 100644 --- a/src/Config/Config_FeatureReader.h +++ b/src/Config/Config_FeatureReader.h @@ -8,7 +8,7 @@ #ifndef CONFIG_FEATUREREADER_H_ #define CONFIG_FEATUREREADER_H_ -#include +#include #include #include diff --git a/src/Config/Config_ModuleReader.h b/src/Config/Config_ModuleReader.h index a4afba3c2..3bd5d39f3 100644 --- a/src/Config/Config_ModuleReader.h +++ b/src/Config/Config_ModuleReader.h @@ -8,7 +8,7 @@ #ifndef CONFIG_MODULEREADER_H_ #define CONFIG_MODULEREADER_H_ -#include +#include #include #include diff --git a/src/Config/Config_PointerMessage.h b/src/Config/Config_PointerMessage.h index f108d3ede..0e3c726ca 100644 --- a/src/Config/Config_PointerMessage.h +++ b/src/Config/Config_PointerMessage.h @@ -8,7 +8,7 @@ #ifndef PARTSET_MESSAGE_H_ #define PARTSET_MESSAGE_H_ -#include +#include #include /* diff --git a/src/Config/Config_WidgetAPI.cpp b/src/Config/Config_WidgetAPI.cpp index 9a77d778a..2fdad6735 100644 --- a/src/Config/Config_WidgetAPI.cpp +++ b/src/Config/Config_WidgetAPI.cpp @@ -61,7 +61,7 @@ bool Config_WidgetAPI::toParentWidget() return myCurrentNode != NULL; } -std::string Config_WidgetAPI::widgetType() +std::string Config_WidgetAPI::widgetType() const { std::string result = ""; if(myCurrentNode) { @@ -70,19 +70,19 @@ std::string Config_WidgetAPI::widgetType() return result; } -bool Config_WidgetAPI::isContainerWidget() +bool Config_WidgetAPI::isContainerWidget() const { return isNode(myCurrentNode, WDG_GROUP, WDG_CHECK_GROUP, NULL); } -bool Config_WidgetAPI::isPagedWidget() +bool Config_WidgetAPI::isPagedWidget() const { return isNode(myCurrentNode, WDG_TOOLBOX, WDG_SWITCH, NULL); } -std::string Config_WidgetAPI::getProperty(const char* thePropName) +std::string Config_WidgetAPI::getProperty(const char* thePropName) const { std::string result = ""; char* aPropChars = (char*) xmlGetProp(myCurrentNode, BAD_CAST thePropName); @@ -92,22 +92,22 @@ std::string Config_WidgetAPI::getProperty(const char* thePropName) return result; } -std::string Config_WidgetAPI::widgetId() +std::string Config_WidgetAPI::widgetId() const { return getProperty("id"); } -std::string Config_WidgetAPI::widgetTooltip() +std::string Config_WidgetAPI::widgetTooltip() const { return getProperty("tooltip"); } -std::string Config_WidgetAPI::widgetIcon() +std::string Config_WidgetAPI::widgetIcon() const { return getProperty("icon"); } -std::string Config_WidgetAPI::widgetLabel() +std::string Config_WidgetAPI::widgetLabel() const { return getProperty("label"); } diff --git a/src/Config/Config_WidgetAPI.h b/src/Config/Config_WidgetAPI.h index 4030ff257..190ccfc7f 100644 --- a/src/Config/Config_WidgetAPI.h +++ b/src/Config/Config_WidgetAPI.h @@ -8,7 +8,7 @@ #ifndef CONFIG_WIDGETAPI_H_ #define CONFIG_WIDGETAPI_H_ -#include +#include #include #include @@ -36,16 +36,16 @@ public: bool toChildWidget(); bool toParentWidget(); - std::string widgetType(); - bool isContainerWidget(); - bool isPagedWidget(); + std::string widgetType() const; + bool isContainerWidget() const; + bool isPagedWidget() const; - std::string widgetId(); - std::string widgetIcon(); - std::string widgetLabel(); - std::string widgetTooltip(); + std::string widgetId() const; + std::string widgetIcon() const; + std::string widgetLabel() const; + std::string widgetTooltip() const; - std::string getProperty(const char* thePropName); + std::string getProperty(const char* thePropName) const; private: xmlDocPtr myDoc; diff --git a/src/Config/Config_WidgetReader.h b/src/Config/Config_WidgetReader.h index cfc1519a5..96f35ac19 100644 --- a/src/Config/Config_WidgetReader.h +++ b/src/Config/Config_WidgetReader.h @@ -8,7 +8,7 @@ #ifndef CONFIG_WIDGETREADER_H_ #define CONFIG_WIDGETREADER_H_ -#include +#include #include #include diff --git a/src/Config/Config_XMLReader.h b/src/Config/Config_XMLReader.h index bcd8ddfdf..8915147e9 100644 --- a/src/Config/Config_XMLReader.h +++ b/src/Config/Config_XMLReader.h @@ -8,7 +8,7 @@ #ifndef CONFIG_XMLREADER_H_ #define CONFIG_XMLREADER_H_ -#include +#include #include #include diff --git a/src/Config/Config_def.h b/src/Config/Config_def.h new file mode 100644 index 000000000..587ac534d --- /dev/null +++ b/src/Config/Config_def.h @@ -0,0 +1,18 @@ +#ifndef CONFIG_H +#define CONFIG_H + +#if defined CONFIG_EXPORTS +#if defined WIN32 +#define CONFIG_EXPORT __declspec( dllexport ) +#else +#define CONFIG_EXPORT +#endif +#else +#if defined WIN32 +#define CONFIG_EXPORT __declspec( dllimport ) +#else +#define CONFIG_EXPORT +#endif +#endif + +#endif //CONFIG_H diff --git a/src/GeomAPI/CMakeLists.txt b/src/GeomAPI/CMakeLists.txt index ad741d302..2a2f3ed40 100644 --- a/src/GeomAPI/CMakeLists.txt +++ b/src/GeomAPI/CMakeLists.txt @@ -1,5 +1,4 @@ FIND_PACKAGE(SWIG REQUIRED) -INCLUDE(FindCAS) INCLUDE(${SWIG_USE_FILE}) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/src/GeomAlgoAPI/CMakeLists.txt b/src/GeomAlgoAPI/CMakeLists.txt index 509c7fd9e..0ce88abde 100644 --- a/src/GeomAlgoAPI/CMakeLists.txt +++ b/src/GeomAlgoAPI/CMakeLists.txt @@ -1,5 +1,4 @@ FIND_PACKAGE(SWIG REQUIRED) -INCLUDE(FindCAS) INCLUDE(${SWIG_USE_FILE}) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/src/GeomData/CMakeLists.txt b/src/GeomData/CMakeLists.txt index b69c280d0..a1e450c6e 100644 --- a/src/GeomData/CMakeLists.txt +++ b/src/GeomData/CMakeLists.txt @@ -1,5 +1,4 @@ INCLUDE(Common) -INCLUDE(FindCAS) SET(PROJECT_HEADERS GeomData.h diff --git a/src/Model/CMakeLists.txt b/src/Model/CMakeLists.txt index 9da38b914..3743fabf3 100644 --- a/src/Model/CMakeLists.txt +++ b/src/Model/CMakeLists.txt @@ -1,5 +1,4 @@ INCLUDE(Common) -INCLUDE(FindCAS) SET(PROJECT_HEADERS Model.h diff --git a/src/ModuleBase/CMakeLists.txt b/src/ModuleBase/CMakeLists.txt index 82f7214d8..6b1f3d677 100644 --- a/src/ModuleBase/CMakeLists.txt +++ b/src/ModuleBase/CMakeLists.txt @@ -11,6 +11,8 @@ SET(PROJECT_HEADERS ModuleBase_WidgetPoint2D.h ModuleBase_WidgetSwitch.h ModuleBase_MetaWidget.h + ModuleBase_SelectorWidget.h + ModuleBase_IWorkshop.h ) SET(PROJECT_SOURCES @@ -21,12 +23,15 @@ SET(PROJECT_SOURCES ModuleBase_WidgetPoint2D.cpp ModuleBase_WidgetSwitch.cpp ModuleBase_MetaWidget.cpp + ModuleBase_SelectorWidget.cpp ) SET(PROJECT_LIBRARIES Config ModelAPI ${QT_LIBRARIES} + ${CAS_VIEWER} + ${CAS_KERNEL} ) SET(PROJECT_AUTOMOC @@ -40,14 +45,15 @@ SOURCE_GROUP ("Generated Files" FILES ${PROJECT_AUTOMOC} ${PROJECT_COMPILED_RESO #SOURCE_GROUP ("Resource Files" FILES ${TEXT_RESOURCES} ${PROJECT_RESOURCES}) INCLUDE_DIRECTORIES( - ${PROJECT_SOURCE_DIR}/src/Config + ${CAS_INCLUDE_DIRS} + ${CMAKE_SOURCE_DIR}/src/Config ${CMAKE_SOURCE_DIR}/src/Events ${CMAKE_SOURCE_DIR}/src/Model ${CMAKE_SOURCE_DIR}/src/ModelAPI ${CMAKE_SOURCE_DIR}/src/GeomDataAPI ) -ADD_DEFINITIONS(-DMODULEBASE_EXPORTS) +ADD_DEFINITIONS(-DMODULEBASE_EXPORTS ${CAS_DEFINITIONS}) ADD_LIBRARY(ModuleBase SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS}) TARGET_LINK_LIBRARIES(ModuleBase ${PROJECT_LIBRARIES}) diff --git a/src/ModuleBase/ModuleBase_IWorkshop.h b/src/ModuleBase/ModuleBase_IWorkshop.h new file mode 100644 index 000000000..d9dcf5405 --- /dev/null +++ b/src/ModuleBase/ModuleBase_IWorkshop.h @@ -0,0 +1,37 @@ +// File: ModuleBase_IWorkshop.h +// Created: 2 June 2014 +// Author: Vitaly Smetannikov + +#ifndef ModuleBase_IWorkshop_H +#define ModuleBase_IWorkshop_H + +#include "ModuleBase.h" + +#include + +#include + +#include + +/** +* Class which provides access to Workshop object serveces +*/ +class MODULEBASE_EXPORT ModuleBase_IWorkshop: public QObject +{ +Q_OBJECT +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 selectedFeatures() const = 0; + +signals: + void selectionChanged(); +}; + +#endif \ No newline at end of file diff --git a/src/ModuleBase/ModuleBase_SelectorWidget.cpp b/src/ModuleBase/ModuleBase_SelectorWidget.cpp new file mode 100644 index 000000000..931c3be6c --- /dev/null +++ b/src/ModuleBase/ModuleBase_SelectorWidget.cpp @@ -0,0 +1,106 @@ +// File: ModuleBase_SelectorWidget.h +// Created: 2 June 2014 +// Author: Vitaly Smetannikov + + +#include "ModuleBase_SelectorWidget.h" +#include "ModuleBase_IWorkshop.h" + +#include +#include +#include + +#include +#include +#include +#include +#include + + +ModuleBase_SelectorWidget::ModuleBase_SelectorWidget(QWidget* theParent, + ModuleBase_IWorkshop* theWorkshop, + const Config_WidgetAPI* theData) +: ModuleBase_ModelWidget(theParent), myWorkshop(theWorkshop) +{ + myFeatureAttributeID = theData->widgetId(); + + myContainer = new QWidget(theParent); + QHBoxLayout* aLayout = new QHBoxLayout(myContainer); + + aLayout->setContentsMargins(0, 0, 0, 0); + QString aLabelText = QString::fromStdString(theData->widgetLabel()); + QString aLabelIcon = QString::fromStdString(theData->widgetIcon()); + myLabel = new QLabel(aLabelText, myContainer); + myLabel->setPixmap(QPixmap(aLabelIcon)); + + aLayout->addWidget(myLabel); + + QString aToolTip = QString::fromStdString(theData->widgetTooltip()); + myTextLine = new QLineEdit(myContainer); + myTextLine->setReadOnly(true); + myTextLine->setToolTip(aToolTip); + + aLayout->addWidget(myTextLine); + + myActivateBtn = new QToolButton(myContainer); + myActivateBtn->setIcon(QIcon(":icons/hand_point.png")); + myActivateBtn->setCheckable(true); + myActivateBtn->setToolTip(tr("Activate/Deactivate selection")); + + aLayout->addWidget(myActivateBtn); + + connect(myWorkshop, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged())); +} + +//******************************************************************** +ModuleBase_SelectorWidget::~ModuleBase_SelectorWidget() +{ +} + +//******************************************************************** +bool ModuleBase_SelectorWidget::storeValue(FeaturePtr theFeature) +{ + DataPtr aData = theFeature->data(); + boost::shared_ptr aRef = + boost::dynamic_pointer_cast(aData->attribute(myFeatureAttributeID)); + + return true; +} + +//******************************************************************** +bool ModuleBase_SelectorWidget::restoreValue(FeaturePtr theFeature) +{ + DataPtr aData = theFeature->data(); + boost::shared_ptr aRef = + boost::dynamic_pointer_cast(aData->attribute(myFeatureAttributeID)); + + return true; +} + +//******************************************************************** +bool ModuleBase_SelectorWidget::canFocusTo(const std::string& theAttributeName) +{ + return false; +} + +//******************************************************************** +void ModuleBase_SelectorWidget::focusTo() +{ +} + +//******************************************************************** +QList ModuleBase_SelectorWidget::getControls() const +{ + QList aControls; + aControls.append(myLabel); + aControls.append(myTextLine); + aControls.append(myActivateBtn); + return aControls; +} + +//******************************************************************** +void ModuleBase_SelectorWidget::onSelectionChanged() +{ + QList aFeatures = myWorkshop->selectedFeatures(); + int aCount = aFeatures.size(); +} \ No newline at end of file diff --git a/src/ModuleBase/ModuleBase_SelectorWidget.h b/src/ModuleBase/ModuleBase_SelectorWidget.h new file mode 100644 index 000000000..cf3468a3f --- /dev/null +++ b/src/ModuleBase/ModuleBase_SelectorWidget.h @@ -0,0 +1,66 @@ +// File: ModuleBase_SelectorWidget.h +// Created: 2 June 2014 +// Author: Vitaly Smetannikov + +#ifndef ModuleBase_SelectorWidget_H +#define ModuleBase_SelectorWidget_H + +#include "ModuleBase.h" +#include "ModuleBase_ModelWidget.h" + +#include + + +class Config_WidgetAPI; +class QWidget; +class QLabel; +class QLineEdit; +class QToolButton; +class ModuleBase_IWorkshop; + +class MODULEBASE_EXPORT ModuleBase_SelectorWidget: public ModuleBase_ModelWidget +{ + Q_OBJECT +public: + ModuleBase_SelectorWidget(QWidget* theParent, + ModuleBase_IWorkshop* theWorkshop, + const Config_WidgetAPI* theData); + + virtual ~ModuleBase_SelectorWidget(); + + /// Saves the internal parameters to the given feature + /// \param theFeature a model feature to be changed + virtual bool storeValue(FeaturePtr theFeature); + + virtual bool restoreValue(FeaturePtr theFeature); + + /// Returns whether the widget can accept focus, or if it corresponds to the given attribute + /// \param theAttribute name + virtual bool canFocusTo(const std::string& theAttributeName); + + /// Set focus to the current widget if it corresponds to the given attribute + virtual void focusTo(); + + /// Returns the internal parent wiget control, that can be shown anywhere + /// \returns the widget + QWidget* getControl() const { return myContainer; } + + /// Returns list of widget controls + /// \return a control list + virtual QList getControls() const; + +private slots: + void onSelectionChanged(); + +private: + std::string myFeatureAttributeID; + + QWidget* myContainer; + QLabel* myLabel; + QLineEdit* myTextLine; + QToolButton* myActivateBtn; + + ModuleBase_IWorkshop* myWorkshop; +}; + +#endif \ No newline at end of file diff --git a/src/ModuleBase/ModuleBase_WidgetFactory.cpp b/src/ModuleBase/ModuleBase_WidgetFactory.cpp index 1ef8c83d8..ecfe258e6 100644 --- a/src/ModuleBase/ModuleBase_WidgetFactory.cpp +++ b/src/ModuleBase/ModuleBase_WidgetFactory.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -25,8 +26,6 @@ #include #include #include -#include -#include #include #ifdef _DEBUG @@ -36,8 +35,8 @@ #include #include -ModuleBase_WidgetFactory::ModuleBase_WidgetFactory(ModuleBase_Operation* theOperation) - : myOperation(theOperation) +ModuleBase_WidgetFactory::ModuleBase_WidgetFactory(ModuleBase_Operation* theOperation, ModuleBase_IWorkshop* theWorkshop) + : myOperation(theOperation), myWorkshop(theWorkshop) { QString aXml = myOperation->getDescription()->xmlRepresentation(); myWidgetApi = new Config_WidgetAPI(aXml.toStdString()); @@ -229,29 +228,12 @@ QString ModuleBase_WidgetFactory::qs(const std::string& theStdString) const QWidget* ModuleBase_WidgetFactory::selectorControl(QWidget* theParent) { - QWidget* aRes = new QWidget(); - QHBoxLayout* aLayout = new QHBoxLayout(aRes); + ModuleBase_SelectorWidget* aSelector = new ModuleBase_SelectorWidget(theParent, myWorkshop, myWidgetApi); + + QObject::connect(aSelector, SIGNAL(valuesChanged()), myOperation, SLOT(storeCustomValue())); - aLayout->setContentsMargins(0, 0, 0, 0); - QString aLabelText = qs(myWidgetApi->widgetLabel()); - QString aLabelIcon = qs(myWidgetApi->widgetIcon()); - QLabel* aLabel = new QLabel(aLabelText, aRes); - aLabel->setPixmap(QPixmap(aLabelIcon)); - - aLayout->addWidget(aLabel); - - QLineEdit* aTextLine = new QLineEdit(aRes); - aTextLine->setReadOnly(true); - - aLayout->addWidget(aTextLine); - - QToolButton* aActivateBtn = new QToolButton(aRes); - aActivateBtn->setIcon(QIcon(":icons/hand_point.png")); - aActivateBtn->setCheckable(true); - - aLayout->addWidget(aActivateBtn); - - return aRes; + myModelWidgets.append(aSelector); + return aSelector->getControl(); } diff --git a/src/ModuleBase/ModuleBase_WidgetFactory.h b/src/ModuleBase/ModuleBase_WidgetFactory.h index f0303cdae..5dd799d62 100644 --- a/src/ModuleBase/ModuleBase_WidgetFactory.h +++ b/src/ModuleBase/ModuleBase_WidgetFactory.h @@ -8,8 +8,8 @@ #ifndef ModuleBase_WidgetFactory_H_ #define ModuleBase_WidgetFactory_H_ -#include -#include +#include "ModuleBase.h" +#include "ModuleBase_ModelWidget.h" #include #include @@ -18,11 +18,12 @@ class QObject; class QWidget; class Config_WidgetAPI; class ModuleBase_Operation; +class ModuleBase_IWorkshop; class MODULEBASE_EXPORT ModuleBase_WidgetFactory { public: - ModuleBase_WidgetFactory(ModuleBase_Operation*); + ModuleBase_WidgetFactory(ModuleBase_Operation* theOperation, ModuleBase_IWorkshop* theWorkshop); virtual ~ModuleBase_WidgetFactory(); void createWidget(QWidget* theParent); @@ -48,6 +49,7 @@ protected: private: Config_WidgetAPI* myWidgetApi; ModuleBase_Operation* myOperation; + ModuleBase_IWorkshop* myWorkshop; QList myModelWidgets; }; diff --git a/src/NewGeom/CMakeLists.txt b/src/NewGeom/CMakeLists.txt index 4eee4a294..27b7c58f4 100644 --- a/src/NewGeom/CMakeLists.txt +++ b/src/NewGeom/CMakeLists.txt @@ -1,6 +1,4 @@ -INCLUDE(FindCAS) - SET(CMAKE_AUTOMOC ON) SET(PROJECT_HEADERS diff --git a/src/PartSet/CMakeLists.txt b/src/PartSet/CMakeLists.txt index 9ccf4e46b..4dc7d82ae 100644 --- a/src/PartSet/CMakeLists.txt +++ b/src/PartSet/CMakeLists.txt @@ -1,5 +1,4 @@ INCLUDE(Common) -INCLUDE(FindCAS) SET(CMAKE_AUTOMOC ON) diff --git a/src/XGUI/CMakeLists.txt b/src/XGUI/CMakeLists.txt index ea9af50b6..c23054513 100644 --- a/src/XGUI/CMakeLists.txt +++ b/src/XGUI/CMakeLists.txt @@ -1,4 +1,3 @@ -INCLUDE(FindCAS) SET(CMAKE_AUTOMOC ON) @@ -33,6 +32,7 @@ SET(PROJECT_HEADERS XGUI_ViewerPrs.h XGUI_PropertyPanel.h XGUI_ContextMenuMgr.h + XGUI_ModuleConnector.h ) SET(PROJECT_AUTOMOC @@ -64,6 +64,7 @@ SET(PROJECT_SOURCES XGUI_ViewerPrs.cpp XGUI_PropertyPanel.cpp XGUI_ContextMenuMgr.cpp + XGUI_ModuleConnector.cpp ) SET(PROJECT_RESOURCES diff --git a/src/XGUI/XGUI_ModuleConnector.cpp b/src/XGUI/XGUI_ModuleConnector.cpp new file mode 100644 index 000000000..542eca0cf --- /dev/null +++ b/src/XGUI/XGUI_ModuleConnector.cpp @@ -0,0 +1,33 @@ +// File: XGUI_ModuleConnector.cpp +// Created: 3 June 2014 +// Author: Vitaly Smetannikov + + +#include "XGUI_ModuleConnector.h" +#include "XGUI_Workshop.h" +#include "XGUI_ViewerProxy.h" +#include "XGUI_SelectionMgr.h" + + + +XGUI_ModuleConnector::XGUI_ModuleConnector(XGUI_Workshop* theWorkshop) +: ModuleBase_IWorkshop(theWorkshop), myWorkshop(theWorkshop) +{ + XGUI_SelectionMgr* aSelector = myWorkshop->selector(); + connect(aSelector, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged())); +} + +XGUI_ModuleConnector::~XGUI_ModuleConnector() +{ +} + +Handle(AIS_InteractiveContext) XGUI_ModuleConnector::AISContext() const +{ + return myWorkshop->viewer()->AISContext(); +} + + +QFeatureList XGUI_ModuleConnector::selectedFeatures() const +{ + return myWorkshop->selector()->selectedFeatures(); +} \ No newline at end of file diff --git a/src/XGUI/XGUI_ModuleConnector.h b/src/XGUI/XGUI_ModuleConnector.h new file mode 100644 index 000000000..04d7b3ef1 --- /dev/null +++ b/src/XGUI/XGUI_ModuleConnector.h @@ -0,0 +1,38 @@ +// File: XGUI_ModuleConnector.h +// Created: 3 June 2014 +// Author: Vitaly Smetannikov + +#ifndef XGUI_ModuleConnector_H +#define XGUI_ModuleConnector_H + + +#include "XGUI.h" +#include "XGUI_Constants.h" + +#include + +class Handle_AIS_InteractiveContext; +class XGUI_Workshop; + +/** +* Implementation of IWorkshop interface which provides access to Workshop sevices at module level +*/ +class XGUI_EXPORT XGUI_ModuleConnector: public ModuleBase_IWorkshop +{ + Q_OBJECT +public: + XGUI_ModuleConnector(XGUI_Workshop* theWorkshop); + + virtual ~XGUI_ModuleConnector(); + + //! Returns AIS_InteractiveContext from current OCCViewer + virtual Handle(AIS_InteractiveContext) AISContext() const; + + //! Returns list of currently selected data objects + QFeatureList selectedFeatures() const; + +private: + XGUI_Workshop* myWorkshop; +}; + +#endif \ No newline at end of file diff --git a/src/XGUI/XGUI_ObjectsBrowser.cpp b/src/XGUI/XGUI_ObjectsBrowser.cpp index 125e1aaf4..818e72210 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.cpp +++ b/src/XGUI/XGUI_ObjectsBrowser.cpp @@ -146,7 +146,7 @@ XGUI_ObjectsBrowser::XGUI_ObjectsBrowser(QWidget* theParent) aLabelWgt->setFrameShape(myTreeView->frameShape()); aLabelWgt->setFrameShadow(myTreeView->frameShadow()); - connect(myTreeView, SIGNAL(selectionChanged()), this, SIGNAL(selectionChanged())); + connect(myTreeView, SIGNAL(selectionChanged()), this, SLOT(onSelectionChanged())); connect(myTreeView, SIGNAL(activePartChanged(FeaturePtr)), this, SLOT(onActivePartChanged(FeaturePtr))); connect(myTreeView, SIGNAL(activePartChanged(FeaturePtr)), this, SIGNAL(activePartChanged(FeaturePtr))); @@ -315,4 +315,11 @@ void XGUI_ObjectsBrowser::onEditItem() myActiveDocLbl->setProperty("OldText", myActiveDocLbl->text()); } } +} + +//*************************************************** +void XGUI_ObjectsBrowser::onSelectionChanged() +{ + myFeaturesList = myTreeView->selectedFeatures(); + emit selectionChanged(); } \ No newline at end of file diff --git a/src/XGUI/XGUI_ObjectsBrowser.h b/src/XGUI/XGUI_ObjectsBrowser.h index b8e275ae6..8e4842df5 100644 --- a/src/XGUI/XGUI_ObjectsBrowser.h +++ b/src/XGUI/XGUI_ObjectsBrowser.h @@ -96,6 +96,8 @@ private slots: //! Called on Edit command request void onEditItem(); + void onSelectionChanged(); + private: void closeDocNameEditing(bool toSave); diff --git a/src/XGUI/XGUI_Workshop.cpp b/src/XGUI/XGUI_Workshop.cpp index 980b8c8e0..dfe77c6f8 100644 --- a/src/XGUI/XGUI_Workshop.cpp +++ b/src/XGUI/XGUI_Workshop.cpp @@ -20,6 +20,7 @@ #include "XGUI_ViewerProxy.h" #include "XGUI_PropertyPanel.h" #include "XGUI_ContextMenuMgr.h" +#include "XGUI_ModuleConnector.h" #include #include @@ -91,6 +92,8 @@ XGUI_Workshop::XGUI_Workshop(XGUI_SalomeConnector* theConnector) this, SLOT(onContextMenuCommand(const QString&, bool))); myViewerProxy = new XGUI_ViewerProxy(this); + + myModuleConnector = new XGUI_ModuleConnector(this); connect(myOperationMgr, SIGNAL(operationStarted()), SLOT(onOperationStarted())); connect(myOperationMgr, SIGNAL(operationResumed()), SLOT(onOperationStarted())); @@ -289,7 +292,7 @@ void XGUI_Workshop::onOperationStarted() showPropertyPanel(); - ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aOperation); + ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aOperation, myModuleConnector); QWidget* aContent = myPropertyPanel->contentWidget(); qDeleteAll(aContent->children()); aFactory.createWidget(aContent); diff --git a/src/XGUI/XGUI_Workshop.h b/src/XGUI/XGUI_Workshop.h index d7ace358b..dad085707 100644 --- a/src/XGUI/XGUI_Workshop.h +++ b/src/XGUI/XGUI_Workshop.h @@ -25,6 +25,7 @@ class XGUI_SalomeViewer; class XGUI_ViewerProxy; class XGUI_PropertyPanel; class XGUI_ContextMenuMgr; +class XGUI_ModuleConnector; class ModuleBase_Operation; @@ -174,6 +175,7 @@ private: XGUI_ErrorDialog* myErrorDlg; XGUI_ViewerProxy* myViewerProxy; XGUI_ContextMenuMgr* myContextMenuMgr; + XGUI_ModuleConnector* myModuleConnector; QString myCurrentDir; static QMap myIcons;