const static char* WDG_STRINGVALUE = "stringvalue";
const static char* WDG_MULTISELECTOR = "multi_selector";
const static char* WDG_SHAPE_SELECTOR = "shape_selector";
+const static char* WDG_CONCEALED_OBJECTS_VIEW = "concealed_objects_view";
const static char* WDG_CHOICE = "choice";
const static char* WDG_DOUBLEVALUE_EDITOR = "doublevalue_editor";
const static char* WDG_FILE_SELECTOR= "file_selector";
FeaturesPlugin.h
FeaturesPlugin_Plugin.h
FeaturesPlugin_Extrusion.h
+ FeaturesPlugin_Recover.h
FeaturesPlugin_Revolution.h
FeaturesPlugin_Rotation.h
FeaturesPlugin_Translation.h
SET(PROJECT_SOURCES
FeaturesPlugin_Plugin.cpp
FeaturesPlugin_Extrusion.cpp
+ FeaturesPlugin_Recover.cpp
FeaturesPlugin_Revolution.cpp
FeaturesPlugin_Rotation.cpp
FeaturesPlugin_Translation.cpp
translation_widget.xml
boolean_widget.xml
group_widget.xml
+ recover_widget.xml
partition_widget.xml
placement_widget.xml
intersection_widget.xml
#include <FeaturesPlugin_Partition.h>
#include <FeaturesPlugin_Pipe.h>
#include <FeaturesPlugin_Placement.h>
+#include <FeaturesPlugin_Recover.h>
#include <FeaturesPlugin_RemoveSubShapes.h>
#include <FeaturesPlugin_Revolution.h>
#include <FeaturesPlugin_RevolutionCut.h>
return FeaturePtr(new FeaturesPlugin_Pipe);
} else if (theFeatureID == FeaturesPlugin_Placement::ID()) {
return FeaturePtr(new FeaturesPlugin_Placement);
+ } else if (theFeatureID == FeaturesPlugin_Recover::ID()) {
+ return FeaturePtr(new FeaturesPlugin_Recover);
} else if (theFeatureID == FeaturesPlugin_ExtrusionCut::ID()) {
return FeaturePtr(new FeaturesPlugin_ExtrusionCut);
} else if (theFeatureID == FeaturesPlugin_ExtrusionFuse::ID()) {
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File: FeaturesPlugin_Recover.cpp
+// Created: 29 Jul 2016
+// Author: Natalia ERMOLAEVA
+
+#include "FeaturesPlugin_Recover.h"
+
+#include <ModelAPI_Data.h>
+#include <ModelAPI_Document.h>
+#include <ModelAPI_AttributeReference.h>
+#include <ModelAPI_AttributeRefList.h>
+#include <ModelAPI_Session.h>
+#include <ModelAPI_Validator.h>
+
+using namespace std;
+
+FeaturesPlugin_Recover::FeaturesPlugin_Recover()
+{
+}
+
+void FeaturesPlugin_Recover::initAttributes()
+{
+ data()->addAttribute(BASE_SHAPE_ID(), ModelAPI_AttributeReference::typeId());
+ data()->addAttribute(RECOVERED_ENTITIES(), ModelAPI_AttributeRefList::typeId());
+
+ /// temporary modification for empty list
+ ModelAPI_Session::get()->validators()->registerNotObligatory(getKind(), RECOVERED_ENTITIES());
+}
+
+void FeaturesPlugin_Recover::execute()
+{
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+// File: FeaturesPlugin_Recover.h
+// Created: 29 Jul 2016
+// Author: Natalia ERMOLAEVA
+
+#ifndef FEATURESPLUGIN_RECOVER_H_
+#define FEATURESPLUGIN_RECOVER_H_
+
+#include "FeaturesPlugin.h"
+#include <ModelAPI_Feature.h>
+#include <GeomAPI_Shape.h>
+
+/**\class FeaturesPlugin_Recover
+ * \ingroup Plugins
+ * \brief Feature for display of concealed attributes of some feature.
+ */
+class FeaturesPlugin_Recover : public ModelAPI_Feature
+{
+ public:
+ /// Extrusion kind
+ inline static const std::string& ID()
+ {
+ static const std::string MY_GROUP_ID("Recover");
+ return MY_GROUP_ID;
+ }
+ /// Attribute name of base shape.
+ inline static const std::string& BASE_SHAPE_ID()
+ {
+ static const std::string MY_BASE_SHAPE_ID("base_shape");
+ return MY_BASE_SHAPE_ID;
+ }
+
+ /// Attribute name of base shape.
+ inline static const std::string& RECOVERED_ENTITIES()
+ {
+ static const std::string MY_RECOVERED_ENTITIES_ID("recovered_entities");
+ return MY_RECOVERED_ENTITIES_ID;
+ }
+
+ /// Returns the kind of a feature
+ FEATURESPLUGIN_EXPORT virtual const std::string& getKind()
+ {
+ static std::string MY_KIND = FeaturesPlugin_Recover::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_Recover();
+
+};
+
+#endif
<source path="group_widget.xml"/>
</feature>
</group>
+ <group id="Recover">
+ <feature id="Recover"
+ title="Recover"
+ tooltip="Visualize concealed objects"
+ icon="">
+ <source path="recover_widget.xml"/>
+ </feature>
+ </group>
</workbench>
<workbench id="Part">
<group id="Movement">
--- /dev/null
+<!-- Copyright (C) 2014-20xx CEA/DEN, EDF R&D -->
+
+<source>
+ <shape_selector id="base_shape"
+ label="Shape:"
+ tooltip="Select a feature of concealed objects."
+ shape_types="objects"/>
+ <concealed_objects_view id="recovered_entities"
+ tooltip="Concealed objects"
+ base_shape_attribute="base_shape"
+ obligatory="0"/>
+</source>
\ No newline at end of file
ModuleBase_WidgetAction.h
ModuleBase_WidgetBoolValue.h
ModuleBase_WidgetChoice.h
+ ModuleBase_WidgetConcealedObjects.h
ModuleBase_WidgetCreatorFactory.h
ModuleBase_WidgetDoubleValue.h
ModuleBase_WidgetEditor.h
ModuleBase_WidgetAction.cpp
ModuleBase_WidgetBoolValue.cpp
ModuleBase_WidgetChoice.cpp
+ ModuleBase_WidgetConcealedObjects.cpp
ModuleBase_WidgetCreatorFactory.cpp
ModuleBase_WidgetDoubleValue.cpp
ModuleBase_WidgetEditor.cpp
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: ModuleBase_WidgetConcealedObjects.cpp
+// Created: 29 Jul 2016
+// Author: Natalia ERMOLAEVA
+
+#include <ModuleBase_WidgetConcealedObjects.h>
+#include <ModuleBase_Tools.h>
+
+#include <ModelAPI_Result.h>
+#include <ModelAPI_AttributeReference.h>
+#include <ModelAPI_AttributeRefList.h>
+
+#include <Config_WidgetAPI.h>
+
+#include <QGridLayout>
+#include <QCheckBox>
+
+#include <QWidget>
+#include <QTableWidget>
+#include <QHeaderView>
+
+ModuleBase_WidgetConcealedObjects::ModuleBase_WidgetConcealedObjects(QWidget* theParent,
+ const Config_WidgetAPI* theData)
+: ModuleBase_ModelWidget(theParent, theData)
+{
+ myBaseShapeAttribute = theData->getProperty("base_shape_attribute");
+ QGridLayout* aMainLay = new QGridLayout(this);
+ ModuleBase_Tools::adjustMargins(aMainLay);
+
+ myView = new QTableWidget(this);
+ aMainLay->addWidget(myView);
+
+ myView->setColumnCount(2);
+ myView->horizontalHeader()->setVisible(false);
+ myView->verticalHeader()->setVisible(false);
+}
+
+ModuleBase_WidgetConcealedObjects::~ModuleBase_WidgetConcealedObjects()
+{
+}
+
+bool ModuleBase_WidgetConcealedObjects::storeValueCustom()
+{
+ if(!myFeature)
+ return false;
+ DataPtr aData = myFeature->data();
+ AttributeRefListPtr anAttributeList = aData->reflist(attributeID());
+ anAttributeList->clear();
+ int aSize1 = anAttributeList->size(false);
+ for (int i = 0, aSize = myView->rowCount(); i < aSize; i++) {
+ QCheckBox* aButton = dynamic_cast<QCheckBox*>(myView->cellWidget(i, 0));
+ if (aButton->isChecked())
+ anAttributeList->append(myConcealedResults[i]);
+ }
+ int aSize = anAttributeList->size(false);
+ return true;
+}
+
+bool ModuleBase_WidgetConcealedObjects::restoreValueCustom()
+{
+ FeaturePtr aBaseFeature;
+ ObjectPtr anObject;
+ if (myFeature) {
+ anObject = ModuleBase_Tools::getObject(myFeature->attribute(myBaseShapeAttribute));
+ if (anObject.get() != NULL)
+ aBaseFeature = ModelAPI_Feature::feature(anObject);
+ }
+ if (myBaseFeature != aBaseFeature) {
+ myView->setRowCount(0);
+ myConcealedResults.clear();
+ myBaseFeature = aBaseFeature;
+ if (myBaseFeature.get()) {
+ std::list<std::pair<std::string, std::list<std::shared_ptr<ModelAPI_Object> > > > aRefs;
+ myBaseFeature->data()->referencesToObjects(aRefs);
+ std::list<std::pair<std::string, std::list<ObjectPtr> > >::const_iterator
+ anIt = aRefs.begin(), aLast = aRefs.end();
+ for (; anIt != aLast; anIt++) {
+ std::list<ObjectPtr> anObjects = (*anIt).second;
+ std::list<ObjectPtr>::const_iterator anOIt = anObjects.begin(), anOLast = anObjects.end();
+ for (; anOIt != anOLast; anOIt++) {
+ ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(*anOIt);
+ if (aResult->isConcealed()) {
+ int aRowId = myView->rowCount();
+ addViewRow(aResult);
+ myConcealedResults[aRowId] = aResult;
+ }
+ }
+ }
+ }
+ }
+
+ DataPtr aData = myFeature->data();
+ AttributeRefListPtr anAttributeList = aData->reflist(attributeID());
+ int aSize = anAttributeList->size();
+ for (int i = 0, aSize = myView->rowCount(); i < aSize; i++) {
+ ResultPtr aResult = myConcealedResults[i];
+ QCheckBox* aButton = dynamic_cast<QCheckBox*>(myView->cellWidget(i, 0));
+ bool isChecked = anAttributeList->isInList(aResult);
+
+ bool aBlocked = aButton->blockSignals(true);
+ aButton->setChecked(isChecked);
+ aButton->blockSignals(aBlocked);
+ }
+ return true;
+}
+
+QList<QWidget*> ModuleBase_WidgetConcealedObjects::getControls() const
+{
+ QList<QWidget*> result;
+ result << myView;
+ return result;
+}
+
+void ModuleBase_WidgetConcealedObjects::addViewRow(const std::shared_ptr<ModelAPI_Result>& theResult)
+{
+ int anId = myView->rowCount();
+ myView->setRowCount(anId+1);
+
+ QCheckBox* aVisibilityBox = new QCheckBox(this);
+ connect(aVisibilityBox, SIGNAL(toggled(bool)), this, SLOT(onItemToggled(bool)));
+ aVisibilityBox->setChecked(false);
+ myView->setCellWidget(anId, 0, aVisibilityBox);
+ myView->setItem(anId, 1, new QTableWidgetItem(theResult->data()->name().c_str()));
+}
+
+void ModuleBase_WidgetConcealedObjects::onItemToggled(bool theState)
+{
+ emit valuesChanged();
+ updateObject(myFeature);
+}
--- /dev/null
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File: ModuleBase_WidgetConcealedObjects.h
+// Created: 29 Jul 2016
+// Author: Natalia ERMOLAEVA
+
+#ifndef MODULEBASE_WIDGETCONCEALEDOBJECTS_H_
+#define MODULEBASE_WIDGETCONCEALEDOBJECTS_H_
+
+#include <ModuleBase.h>
+#include <ModuleBase_ModelWidget.h>
+
+#include <string>
+#include <map>
+#include <memory>
+
+class ModelAPI_Object;
+
+class QWidget;
+class QTableWidget;
+
+/**
+* \ingroup GUI
+* Implementation of model widget for table of concealed objects.
+*/
+class MODULEBASE_EXPORT ModuleBase_WidgetConcealedObjects : public ModuleBase_ModelWidget
+{
+ Q_OBJECT
+ public:
+ /// Constructor
+ /// \param theParent the parent object
+ /// \param theData the widget configuration.
+ ModuleBase_WidgetConcealedObjects(QWidget* theParent,
+ const Config_WidgetAPI* theData);
+ virtual ~ModuleBase_WidgetConcealedObjects();
+
+ /// Redefinition of virtual method
+ virtual QList<QWidget*> getControls() const;
+
+ /// The widget can not accept focus
+ virtual bool canAcceptFocus() const { return false; };
+
+protected:
+ /// Saves the internal parameters to the given feature
+ /// \return True in success
+ virtual bool storeValueCustom();
+
+ /// Redefinition of virtual method
+ virtual bool restoreValueCustom();
+
+private:
+ /// Creates a row in view
+ /// \param theResult a result for the row
+ void addViewRow(const std::shared_ptr<ModelAPI_Result>& theResult);
+
+private slots:
+ /// Processes the display button click in the view.
+ /// \param theState a new state
+ void onItemToggled(bool theState);
+
+private:
+ std::string myBaseShapeAttribute; ///< attribute of the base object
+ QTableWidget* myView; ///< table view of visibility states
+
+ std::shared_ptr<ModelAPI_Feature> myBaseFeature; ///< backup of feature of filling the table view
+ /// backup of visualized in the view concealed objects, stored to avoid table rebuild by restore
+ std::map<int, std::shared_ptr<ModelAPI_Result> > myConcealedResults;
+};
+
+#endif /* MODULEBASE_WIDGETCONCEALEDOBJECTS_H_ */
#include <ModuleBase_Tools.h>
#include <ModuleBase_WidgetLineEdit.h>
#include <ModuleBase_WidgetMultiSelector.h>
+#include <ModuleBase_WidgetConcealedObjects.h>
#include <ModuleBase_WidgetLabel.h>
#include <ModuleBase_WidgetToolbox.h>
#include <ModuleBase_PageBase.h>
result = new ModuleBase_WidgetExprEditor( theParent, myWidgetApi, aPlaceHolder );
} else if (theType == WDG_MULTISELECTOR) {
result = new ModuleBase_WidgetMultiSelector(theParent, myWorkshop, myWidgetApi);
+ } else if (theType == WDG_CONCEALED_OBJECTS_VIEW) {
+ result = new ModuleBase_WidgetConcealedObjects(theParent, myWidgetApi);
} else if (theType == WDG_TOOLBOX) {
result = new ModuleBase_WidgetToolbox(theParent, myWidgetApi);
} else if (theType == WDG_SWITCH) {