INCLUDE(FindPython)
INCLUDE(FindSalome)
INCLUDE(FindSolveSpace)
+INCLUDE(FindCAS)
IF(UNIX)
IF(CMAKE_COMPILER_IS_GNUCC)
INCLUDE_DIRECTORIES (${PROJECT_SOURCE_DIR}/src/Events)
SET(PROJECT_HEADERS
- Config.h
+ Config_def.h
Config_FeatureMessage.h
Config_XMLReader.h
Config_ModuleReader.h
+++ /dev/null
-#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
#ifndef Config_Common_H_
#define Config_Common_H_
-#include "Config.h"
+#include "Config_def.h"
#include <string>
#include <stdarg.h>
#ifndef CONFIG_MESSAGE_H\r
#define CONFIG_MESSAGE_H\r
\r
-#include <Config.h>\r
+#include <Config_def.h>\r
#include <Events_Message.h>\r
\r
#include <string>\r
#ifndef CONFIG_FEATUREREADER_H_
#define CONFIG_FEATUREREADER_H_
-#include <Config.h>
+#include <Config_def.h>
#include <Config_XMLReader.h>
#include <string>
#ifndef CONFIG_MODULEREADER_H_
#define CONFIG_MODULEREADER_H_
-#include <Config.h>
+#include <Config_def.h>
#include <Config_XMLReader.h>
#include <map>
#ifndef PARTSET_MESSAGE_H_
#define PARTSET_MESSAGE_H_
-#include <Config.h>
+#include <Config_def.h>
#include <Events_Message.h>
/*
return myCurrentNode != NULL;
}
-std::string Config_WidgetAPI::widgetType()
+std::string Config_WidgetAPI::widgetType() const
{
std::string result = "";
if(myCurrentNode) {
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);
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");
}
#ifndef CONFIG_WIDGETAPI_H_
#define CONFIG_WIDGETAPI_H_
-#include <Config.h>
+#include <Config_def.h>
#include <cstdarg>
#include <string>
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;
#ifndef CONFIG_WIDGETREADER_H_
#define CONFIG_WIDGETREADER_H_
-#include <Config.h>
+#include <Config_def.h>
#include <Config_XMLReader.h>
#include <map>
#ifndef CONFIG_XMLREADER_H_
#define CONFIG_XMLREADER_H_
-#include <Config.h>
+#include <Config_def.h>
#include <cstdarg>
#include <string>
--- /dev/null
+#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
FIND_PACKAGE(SWIG REQUIRED)
-INCLUDE(FindCAS)
INCLUDE(${SWIG_USE_FILE})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
FIND_PACKAGE(SWIG REQUIRED)
-INCLUDE(FindCAS)
INCLUDE(${SWIG_USE_FILE})
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
INCLUDE(Common)
-INCLUDE(FindCAS)
SET(PROJECT_HEADERS
GeomData.h
INCLUDE(Common)
-INCLUDE(FindCAS)
SET(PROJECT_HEADERS
Model.h
ModuleBase_WidgetPoint2D.h
ModuleBase_WidgetSwitch.h
ModuleBase_MetaWidget.h
+ ModuleBase_SelectorWidget.h
+ ModuleBase_IWorkshop.h
)
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
#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})
--- /dev/null
+// File: ModuleBase_IWorkshop.h
+// Created: 2 June 2014
+// Author: Vitaly Smetannikov
+
+#ifndef ModuleBase_IWorkshop_H
+#define ModuleBase_IWorkshop_H
+
+#include "ModuleBase.h"
+
+#include <ModelAPI_Feature.h>
+
+#include <AIS_InteractiveContext.hxx>
+
+#include <QObject>
+
+/**
+* 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<FeaturePtr> selectedFeatures() const = 0;
+
+signals:
+ void selectionChanged();
+};
+
+#endif
\ No newline at end of file
--- /dev/null
+// File: ModuleBase_SelectorWidget.h
+// Created: 2 June 2014
+// Author: Vitaly Smetannikov
+
+
+#include "ModuleBase_SelectorWidget.h"
+#include "ModuleBase_IWorkshop.h"
+
+#include <ModelAPI_Data.h>
+#include <ModelAPI_AttributeReference.h>
+#include <Config_WidgetAPI.h>
+
+#include <QWidget>
+#include <QLayout>
+#include <QLabel>
+#include <QLineEdit>
+#include <QToolButton>
+
+
+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<ModelAPI_AttributeReference> aRef =
+ boost::dynamic_pointer_cast<ModelAPI_AttributeReference>(aData->attribute(myFeatureAttributeID));
+
+ return true;
+}
+
+//********************************************************************
+bool ModuleBase_SelectorWidget::restoreValue(FeaturePtr theFeature)
+{
+ DataPtr aData = theFeature->data();
+ boost::shared_ptr<ModelAPI_AttributeReference> aRef =
+ boost::dynamic_pointer_cast<ModelAPI_AttributeReference>(aData->attribute(myFeatureAttributeID));
+
+ return true;
+}
+
+//********************************************************************
+bool ModuleBase_SelectorWidget::canFocusTo(const std::string& theAttributeName)
+{
+ return false;
+}
+
+//********************************************************************
+void ModuleBase_SelectorWidget::focusTo()
+{
+}
+
+//********************************************************************
+QList<QWidget*> ModuleBase_SelectorWidget::getControls() const
+{
+ QList<QWidget*> aControls;
+ aControls.append(myLabel);
+ aControls.append(myTextLine);
+ aControls.append(myActivateBtn);
+ return aControls;
+}
+
+//********************************************************************
+void ModuleBase_SelectorWidget::onSelectionChanged()
+{
+ QList<FeaturePtr> aFeatures = myWorkshop->selectedFeatures();
+ int aCount = aFeatures.size();
+}
\ No newline at end of file
--- /dev/null
+// 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 <ModelAPI_Feature.h>
+
+
+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<QWidget*> 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
#include <ModuleBase_OperationDescription.h>
#include <ModuleBase_WidgetPoint2D.h>
#include <ModuleBase_WidgetSwitch.h>
+#include <ModuleBase_SelectorWidget.h>
#include <Config_Keywords.h>
#include <Config_WidgetAPI.h>
#include <QPixmap>
#include <QGroupBox>
#include <QToolBox>
-#include <QLineEdit>
-#include <QToolButton>
#include <QCheckBox>
#ifdef _DEBUG
#include <cfloat>
#include <climits>
-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());
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();
}
#ifndef ModuleBase_WidgetFactory_H_
#define ModuleBase_WidgetFactory_H_
-#include <ModuleBase.h>
-#include <ModuleBase_ModelWidget.h>
+#include "ModuleBase.h"
+#include "ModuleBase_ModelWidget.h"
#include <QString>
#include <QList>
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);
private:
Config_WidgetAPI* myWidgetApi;
ModuleBase_Operation* myOperation;
+ ModuleBase_IWorkshop* myWorkshop;
QList<ModuleBase_ModelWidget*> myModelWidgets;
};
-INCLUDE(FindCAS)
-
SET(CMAKE_AUTOMOC ON)
SET(PROJECT_HEADERS
INCLUDE(Common)
-INCLUDE(FindCAS)
SET(CMAKE_AUTOMOC ON)
-INCLUDE(FindCAS)
SET(CMAKE_AUTOMOC ON)
XGUI_ViewerPrs.h
XGUI_PropertyPanel.h
XGUI_ContextMenuMgr.h
+ XGUI_ModuleConnector.h
)
SET(PROJECT_AUTOMOC
XGUI_ViewerPrs.cpp
XGUI_PropertyPanel.cpp
XGUI_ContextMenuMgr.cpp
+ XGUI_ModuleConnector.cpp
)
SET(PROJECT_RESOURCES
--- /dev/null
+// 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
--- /dev/null
+// 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 <ModuleBase_IWorkshop.h>
+
+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
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)));
myActiveDocLbl->setProperty("OldText", myActiveDocLbl->text());
}
}
+}
+
+//***************************************************
+void XGUI_ObjectsBrowser::onSelectionChanged()
+{
+ myFeaturesList = myTreeView->selectedFeatures();
+ emit selectionChanged();
}
\ No newline at end of file
//! Called on Edit command request
void onEditItem();
+ void onSelectionChanged();
+
private:
void closeDocNameEditing(bool toSave);
#include "XGUI_ViewerProxy.h"
#include "XGUI_PropertyPanel.h"
#include "XGUI_ContextMenuMgr.h"
+#include "XGUI_ModuleConnector.h"
#include <Model_Events.h>
#include <ModelAPI_PluginManager.h>
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()));
showPropertyPanel();
- ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aOperation);
+ ModuleBase_WidgetFactory aFactory = ModuleBase_WidgetFactory(aOperation, myModuleConnector);
QWidget* aContent = myPropertyPanel->contentWidget();
qDeleteAll(aContent->children());
aFactory.createWidget(aContent);
class XGUI_ViewerProxy;
class XGUI_PropertyPanel;
class XGUI_ContextMenuMgr;
+class XGUI_ModuleConnector;
class ModuleBase_Operation;
XGUI_ErrorDialog* myErrorDlg;
XGUI_ViewerProxy* myViewerProxy;
XGUI_ContextMenuMgr* myContextMenuMgr;
+ XGUI_ModuleConnector* myModuleConnector;
QString myCurrentDir;
static QMap<QString, QString> myIcons;