//Widgets
const static char* WDG_DOUBLEVALUE = "doublevalue";
const static char* WDG_BOOLVALUE = "boolvalue";
+const static char* WDG_STRINGVALUE = "stringvalue";
+const static char* WDG_MULTISELECTOR = "multi_selector";
//Widget containers
const static char* WDG_INFO = "label";
const static char* WDG_GROUP = "groupbox";
FeaturesPlugin_Plugin.h
FeaturesPlugin_Extrusion.h
FeaturesPlugin_Boolean.h
+ FeaturesPlugin_Group.h
)
SET(PROJECT_SOURCES
FeaturesPlugin_Plugin.cpp
FeaturesPlugin_Extrusion.cpp
FeaturesPlugin_Boolean.cpp
+ FeaturesPlugin_Group.cpp
)
SET(XML_RESOURCES
plugin-Features.xml
extrusion_widget.xml
boolean_widget.xml
+ group_widget.xml
)
INCLUDE_DIRECTORIES(
--- /dev/null
+// File: FeaturesPlugin_Group.cpp
+// Created: 08 Oct 2014
+// Author: Sergey BELASH
+
+#include "FeaturesPlugin_Group.h"
+
+#include <ModelAPI_Data.h>
+#include <ModelAPI_Document.h>
+#include <ModelAPI_AttributeInteger.h>
+#include <ModelAPI_AttributeString.h>
+
+using namespace std;
+
+FeaturesPlugin_Group::FeaturesPlugin_Group()
+{
+}
+
+void FeaturesPlugin_Group::initAttributes()
+{
+ data()->addAttribute(FeaturesPlugin_Group::NAME_ID(), ModelAPI_AttributeString::type());
+ data()->addAttribute(FeaturesPlugin_Group::TYPE_ID(), ModelAPI_AttributeInteger::type());
+ data()->addAttribute(FeaturesPlugin_Group::LIST_ID(), ModelAPI_AttributeString::type());
+}
+
+void FeaturesPlugin_Group::execute()
+{
+ AttributeIntegerPtr aTypeAttr = boost::dynamic_pointer_cast<ModelAPI_AttributeInteger>(
+ data()->attribute(FeaturesPlugin_Group::TYPE_ID()));
+ if (!aTypeAttr)
+ return;
+ int aType = aTypeAttr->value();
+}
--- /dev/null
+// File: FeaturesPlugin_Group.h
+// Created: 08 Oct 2014
+// Author: Sergey BELASH
+
+#ifndef FEATURESPLUGIN_GROUP_H_
+#define FEATURESPLUGIN_GROUP_H_
+
+#include "FeaturesPlugin.h"
+#include <ModelAPI_Feature.h>
+#include <GeomAPI_Shape.h>
+
+class FeaturesPlugin_Group : public ModelAPI_Feature
+{
+ public:
+ /// Extrusion kind
+ inline static const std::string& ID()
+ {
+ static const std::string MY_GROUP_ID("Group");
+ return MY_GROUP_ID;
+ }
+ /// attribute name of group type
+ inline static const std::string& NAME_ID()
+ {
+ static const std::string MY_GROUP_NAME_ID("group_name");
+ return MY_GROUP_NAME_ID;
+ }
+ /// attribute name of group type
+ inline static const std::string& TYPE_ID()
+ {
+ static const std::string MY_GROUP_TYPE_ID("group_type");
+ return MY_GROUP_TYPE_ID;
+ }
+ /// attribute name of selected entities list
+ inline static const std::string& LIST_ID()
+ {
+ static const std::string MY_GROUP_LIST_ID("group_list");
+ return MY_GROUP_LIST_ID;
+ }
+
+ /// Returns the kind of a feature
+ FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
+ {
+ static std::string MY_KIND = FeaturesPlugin_Group::ID();
+ return MY_KIND;
+ }
+
+ /// Creates a new part document if needed
+ FEATURESPLUGIN_EXPORT virtual void execute();
+
+ /// Request for initialization of data model of the feature: adding all attributes
+ FEATURESPLUGIN_EXPORT virtual void initAttributes();
+
+ /// Use plugin manager for features creation
+ FeaturesPlugin_Group();
+
+};
+
+#endif
-#include "FeaturesPlugin_Plugin.h"
-#include "FeaturesPlugin_Extrusion.h"
-#include "FeaturesPlugin_Boolean.h"
+#include <FeaturesPlugin_Plugin.h>
+
+#include <FeaturesPlugin_Boolean.h>
+#include <FeaturesPlugin_Extrusion.h>
+#include <FeaturesPlugin_Group.h>
#include <ModelAPI_Session.h>
-#include <ModelAPI_Document.h>
+
+#include <string>
+
+#include <boost/smart_ptr/shared_ptr.hpp>
using namespace std;
{
if (theFeatureID == FeaturesPlugin_Extrusion::ID()) {
return FeaturePtr(new FeaturesPlugin_Extrusion);
- } else
- if (theFeatureID == FeaturesPlugin_Boolean::ID()) {
+ } else if (theFeatureID == FeaturesPlugin_Boolean::ID()) {
return FeaturePtr(new FeaturesPlugin_Boolean);
+ } else if (theFeatureID == FeaturesPlugin_Group::ID()) {
+ return FeaturePtr(new FeaturesPlugin_Group);
}
// feature of such kind is not found
return FeaturePtr();
--- /dev/null
+<source>
+ <stringvalue
+ id="group_name"
+ label="Name"
+ tooltip="Name of the group"
+ string_list="Vertices Edges Faces Solids" />
+ <choice
+ id="group_type"
+ label="Type"
+ tooltip="Type of geometry entities"
+ string_list="Vertices Edges Faces Solids" />
+ <multi_selector id="group_list"
+ label="Selected objects:"
+ tooltip="List of selected objects" />
+</source>
\ No newline at end of file
<source path="boolean_widget.xml"/>
</feature>
</group>
+ <group id="Collections">
+ <feature id="Group"
+ title="Group"
+ tooltip="Create a new named collection of geometry entities"
+ icon=":icons/group.png">
+ <source path="group_widget.xml"/>
+ </feature>
+ </group>
</workbench>
</plugin>
ModuleBase_DoubleSpinBox.h
ModuleBase_IPropertyPanel.h
ModuleBase_IViewer.h
+ ModuleBase_WidgetLineEdit.h
+ ModuleBase_WidgetMultiSelector.h
)
SET(PROJECT_SOURCES
ModuleBase_WidgetChoice.cpp
ModuleBase_WidgetFileSelector.cpp
ModuleBase_DoubleSpinBox.cpp
+ ModuleBase_WidgetLineEdit.cpp
+ ModuleBase_WidgetMultiSelector.cpp
)
SET(PROJECT_LIBRARIES
#include <ModuleBase_IWorkshop.h>
#include <ModuleBase_IModule.h>
#include <ModuleBase_Tools.h>
+#include <ModuleBase_WidgetLineEdit.h>
+#include <ModuleBase_WidgetMultiSelector.h>
#include <ModelAPI_Validator.h>
} else if (theType == WDG_CHOICE) {
result = choiceControl(theParent);
+ } else if (theType == WDG_STRINGVALUE) {
+ result = lineEditControl(theParent);
+
+ } else if (theType == WDG_MULTISELECTOR) {
+ result = multiSelectorControl(theParent);
+
} else if (myWidgetApi->isContainerWidget() || myWidgetApi->isPagedWidget()) {
result = createContainer(theType, theParent);
} else {
return aChoiceWgt->getControl();
}
+QWidget* ModuleBase_WidgetFactory::lineEditControl(QWidget* theParent)
+{
+ ModuleBase_WidgetLineEdit* aLineEditWgt =
+ new ModuleBase_WidgetLineEdit(theParent, myWidgetApi,myParentId);
+ myModelWidgets.append(aLineEditWgt);
+ return aLineEditWgt->getControl();
+}
+
+QWidget* ModuleBase_WidgetFactory::multiSelectorControl(QWidget* theParent)
+{
+ ModuleBase_WidgetMultiSelector* aMultiselectorWgt =
+ new ModuleBase_WidgetMultiSelector(theParent, myWidgetApi,myParentId);
+ myModelWidgets.append(aMultiselectorWgt);
+ return aMultiselectorWgt->getControl();
+}
+
QString ModuleBase_WidgetFactory::qs(const std::string& theStdString) const
{
return QString::fromStdString(theStdString);
QWidget* point2dDistanceControl(QWidget* theParent);
QWidget* fileSelectorControl(QWidget* theParent);
QWidget* choiceControl(QWidget* theParent);
+ QWidget* lineEditControl(QWidget* theParent);
+ QWidget* multiSelectorControl(QWidget* theParent);
+
QString qs(const std::string& theStdString) const;
--- /dev/null
+/*
+ * ModuleBase_WidgetLineEdit.cpp
+ *
+ * Created on: Aug 28, 2014
+ * Author: sbh
+ */
+
+#include <ModuleBase_WidgetLineEdit.h>
+#include <ModuleBase_Tools.h>
+
+#include <ModelAPI_AttributeString.h>
+#include <ModelAPI_Data.h>
+#include <ModelAPI_Object.h>
+#include <ModelAPI_Validator.h>
+
+#include <Config_WidgetAPI.h>
+
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QLineEdit>
+#include <QObject>
+#include <QString>
+
+#include <boost/smart_ptr/shared_ptr.hpp>
+#include <string>
+
+ModuleBase_WidgetLineEdit::ModuleBase_WidgetLineEdit(QWidget* theParent,
+ const Config_WidgetAPI* theData,
+ const std::string& theParentId)
+ : ModuleBase_ModelWidget(theParent, theData, theParentId)
+{
+ myMainWidget = new QWidget(theParent);
+ QHBoxLayout* aMainLay = new QHBoxLayout(myMainWidget);
+ ModuleBase_Tools::adjustMargins(aMainLay);
+ QString aTitle = QString::fromStdString(theData->widgetLabel());
+ QLabel* aTitleLabel = new QLabel(aTitle, myMainWidget);
+ aMainLay->addWidget(aTitleLabel);
+ myLineEdit = new QLineEdit(myMainWidget);
+ aMainLay->addWidget(myLineEdit);
+ myLineEdit->setMinimumHeight(20);
+ myMainWidget->setLayout(aMainLay);
+
+ connect(myLineEdit, SIGNAL(textChanged(const QString&)), this, SLOT(onTextChanged()));
+}
+
+ModuleBase_WidgetLineEdit::~ModuleBase_WidgetLineEdit()
+{
+}
+
+bool ModuleBase_WidgetLineEdit::storeValue() const
+{
+ // A rare case when plugin was not loaded.
+ if(!myFeature)
+ return false;
+ DataPtr aData = myFeature->data();
+ AttributeStringPtr aStringAttr = aData->string(attributeID());
+ QString aWidgetValue = myLineEdit->text();
+ aStringAttr->setValue(aWidgetValue.toStdString());
+ updateObject(myFeature);
+ return true;
+}
+
+bool ModuleBase_WidgetLineEdit::restoreValue()
+{
+ // A rare case when plugin was not loaded.
+ if(!myFeature)
+ return false;
+ DataPtr aData = myFeature->data();
+ AttributeStringPtr aStringAttr = aData->string(attributeID());
+
+ bool isBlocked = myLineEdit->blockSignals(true);
+ myLineEdit->setText(QString::fromStdString(aStringAttr->value()));
+ myLineEdit->blockSignals(isBlocked);
+
+ return true;
+}
+
+QWidget* ModuleBase_WidgetLineEdit::getControl() const
+{
+ return myMainWidget;
+}
+
+QList<QWidget*> ModuleBase_WidgetLineEdit::getControls() const
+{
+ QList<QWidget*> result;
+ result << myLineEdit;
+ return result;
+}
+
+void ModuleBase_WidgetLineEdit::onTextChanged()
+{
+ storeValue();
+}
--- /dev/null
+/*
+ * ModuleBase_WidgetLineEdit.h
+ *
+ * Created on: Oct 8, 2014
+ * Author: sbh
+ */
+
+#ifndef MODULEBASE_WIDGETLINEEDIT_H_
+#define MODULEBASE_WIDGETLINEEDIT_H_
+
+#include <ModuleBase.h>
+#include <ModuleBase_ModelWidget.h>
+
+#include <QList>
+#include <QString>
+#include <QStringList>
+
+class QWidget;
+class QLineEdit;
+
+class MODULEBASE_EXPORT ModuleBase_WidgetLineEdit : public ModuleBase_ModelWidget
+{
+ Q_OBJECT
+ public:
+ ModuleBase_WidgetLineEdit(QWidget* theParent,
+ const Config_WidgetAPI* theData,
+ const std::string& theParentId);
+ virtual ~ModuleBase_WidgetLineEdit();
+
+ /// Saves the internal parameters to the given feature
+ /// \param theObject a model feature to be changed
+ virtual bool storeValue() const;
+
+ virtual bool restoreValue();
+
+ /// Returns the internal parent wiget control, that can be shown anywhere
+ /// \returns the widget
+ QWidget* getControl() const;
+
+ /// Returns list of widget controls
+ /// \return a control list
+ virtual QList<QWidget*> getControls() const;
+
+ public slots:
+ void onTextChanged();
+
+ private:
+ QLineEdit* myLineEdit;
+ QWidget* myMainWidget;
+};
+
+#endif /* MODULEBASE_WIDGETFILESELECTOR_H_ */
--- /dev/null
+/*
+ * ModuleBase_WidgetMultiSelector.cpp
+ *
+ * Created on: Aug 28, 2014
+ * Author: sbh
+ */
+
+#include <ModuleBase_WidgetMultiSelector.h>
+#include <ModuleBase_Tools.h>
+
+#include <ModelAPI_AttributeString.h>
+#include <ModelAPI_Data.h>
+#include <ModelAPI_Object.h>
+#include <ModelAPI_Validator.h>
+
+#include <Config_WidgetAPI.h>
+
+#include <QVBoxLayout>
+#include <QLabel>
+#include <QTextEdit>
+#include <QObject>
+#include <QString>
+
+#include <boost/smart_ptr/shared_ptr.hpp>
+#include <string>
+
+ModuleBase_WidgetMultiSelector::ModuleBase_WidgetMultiSelector(QWidget* theParent,
+ const Config_WidgetAPI* theData,
+ const std::string& theParentId)
+ : ModuleBase_ModelWidget(theParent, theData, theParentId)
+{
+ myMainWidget = new QWidget(theParent);
+ QVBoxLayout* aMainLay = new QVBoxLayout(myMainWidget);
+ ModuleBase_Tools::adjustMargins(aMainLay);
+ QString aTitle = QString::fromStdString(theData->widgetLabel());
+ QLabel* aTitleLabel = new QLabel(aTitle, myMainWidget);
+ aMainLay->addWidget(aTitleLabel);
+ myListControl = new QTextEdit(myMainWidget);
+ myListControl->setReadOnly(true);
+ aMainLay->addWidget(myListControl);
+ myListControl->setMinimumHeight(20);
+ myMainWidget->setLayout(aMainLay);
+
+ connect(myListControl, SIGNAL(textChanged(const QString&)), this, SLOT(onTextChanged()));
+}
+
+ModuleBase_WidgetMultiSelector::~ModuleBase_WidgetMultiSelector()
+{
+}
+
+bool ModuleBase_WidgetMultiSelector::storeValue() const
+{
+ // A rare case when plugin was not loaded.
+ if(!myFeature)
+ return false;
+ DataPtr aData = myFeature->data();
+ AttributeStringPtr aStringAttr = aData->string(attributeID());
+ QString aWidgetValue = myListControl->toPlainText();
+ aStringAttr->setValue(aWidgetValue.toStdString());
+ updateObject(myFeature);
+ return true;
+}
+
+bool ModuleBase_WidgetMultiSelector::restoreValue()
+{
+ // A rare case when plugin was not loaded.
+ if(!myFeature)
+ return false;
+ DataPtr aData = myFeature->data();
+ AttributeStringPtr aStringAttr = aData->string(attributeID());
+
+ bool isBlocked = myListControl->blockSignals(true);
+ myListControl->setText(QString::fromStdString(aStringAttr->value()));
+ myListControl->blockSignals(isBlocked);
+
+ return true;
+}
+
+QWidget* ModuleBase_WidgetMultiSelector::getControl() const
+{
+ return myMainWidget;
+}
+
+QList<QWidget*> ModuleBase_WidgetMultiSelector::getControls() const
+{
+ QList<QWidget*> result;
+ result << myListControl;
+ return result;
+}
--- /dev/null
+/*
+ * ModuleBase_WidgetMultiSelector.h
+ *
+ * Created on: Oct 8, 2014
+ * Author: sbh
+ */
+
+#ifndef MODULEBASE_WIDGETMULTISELECTOR_H_
+#define MODULEBASE_WIDGETMULTISELECTOR_H_
+
+#include <ModuleBase.h>
+#include <ModuleBase_ModelWidget.h>
+
+#include <QList>
+#include <QString>
+#include <QStringList>
+
+class QWidget;
+class QTextEdit;
+
+class MODULEBASE_EXPORT ModuleBase_WidgetMultiSelector : public ModuleBase_ModelWidget
+{
+ Q_OBJECT
+ public:
+ ModuleBase_WidgetMultiSelector(QWidget* theParent,
+ const Config_WidgetAPI* theData,
+ const std::string& theParentId);
+ virtual ~ModuleBase_WidgetMultiSelector();
+
+ /// Saves the internal parameters to the given feature
+ /// \param theObject a model feature to be changed
+ virtual bool storeValue() const;
+
+ virtual bool restoreValue();
+
+ /// Returns the internal parent wiget control, that can be shown anywhere
+ /// \returns the widget
+ QWidget* getControl() const;
+
+ /// Returns list of widget controls
+ /// \return a control list
+ virtual QList<QWidget*> getControls() const;
+
+ //public slots:
+
+ private:
+ QTextEdit* myListControl;
+ QWidget* myMainWidget;
+};
+
+#endif /* MODULEBASE_WIDGETFILESELECTOR_H_ */
MyShapeTypes["shell"] = TopAbs_SHELL;
MyShapeTypes["solid"] = TopAbs_SOLID;
}
- if (MyShapeTypes.contains(theType))
- return MyShapeTypes[theType];
+ QString aType = theType.toLower();
+ if (MyShapeTypes.contains(aType))
+ return MyShapeTypes[aType];
throw std::invalid_argument("Shape type defined in XML is not implemented!");
}
{
Q_OBJECT
public:
+ static TopAbs_ShapeEnum shapeType(const QString& theType);
+
ModuleBase_WidgetShapeSelector(QWidget* theParent, ModuleBase_IWorkshop* theWorkshop,
const Config_WidgetAPI* theData, const std::string& theParentId);
// Set the given object as a value of the widget
void setObject(ObjectPtr theObj);
- static TopAbs_ShapeEnum shapeType(const QString& theType);
-
QWidget* myContainer;
QLabel* myLabel;
QLineEdit* myTextLine;