From: nds Date: Fri, 2 Sep 2016 06:21:49 +0000 (+0300) Subject: Recover Eye button X-Git-Tag: V_2.5.0~79 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c82b46267b5cf8a96395b74cf49a6ba801317d1b;p=modules%2Fshaper.git Recover Eye button --- diff --git a/src/ModuleBase/ModuleBase_WidgetConcealedObjects.cpp b/src/ModuleBase/ModuleBase_WidgetConcealedObjects.cpp index 2e3e0aa8a..c39cbd4da 100644 --- a/src/ModuleBase/ModuleBase_WidgetConcealedObjects.cpp +++ b/src/ModuleBase/ModuleBase_WidgetConcealedObjects.cpp @@ -1,131 +1,143 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: ModuleBase_WidgetConcealedObjects.cpp -// Created: 29 Jul 2016 -// Author: Natalia ERMOLAEVA - -#include -#include - -#include -#include -#include - -#include - -#include -#include - -#include -#include -#include - -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(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 > > > aRefs; - myBaseFeature->data()->referencesToObjects(aRefs); - std::list > >::const_iterator - anIt = aRefs.begin(), aLast = aRefs.end(); - for (; anIt != aLast; anIt++) { - std::list anObjects = (*anIt).second; - std::list::const_iterator anOIt = anObjects.begin(), anOLast = anObjects.end(); - for (; anOIt != anOLast; anOIt++) { - ResultPtr aResult = std::dynamic_pointer_cast(*anOIt); - if (aResult && 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(myView->cellWidget(i, 0)); - bool isChecked = anAttributeList->isInList(aResult); - - bool aBlocked = aButton->blockSignals(true); - aButton->setChecked(isChecked); - aButton->blockSignals(aBlocked); - } - return true; -} - -QList ModuleBase_WidgetConcealedObjects::getControls() const -{ - QList result; - result << myView; - return result; -} - -void ModuleBase_WidgetConcealedObjects::addViewRow(const std::shared_ptr& 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); -} +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + +// File: ModuleBase_WidgetConcealedObjects.cpp +// Created: 29 Jul 2016 +// Author: Natalia ERMOLAEVA + +#include +#include + +#include +#include +#include + +#include + +#include + +#include +#include +#include +#include + +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++) { + QToolButton* aButton = dynamic_cast(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 > > > aRefs; + myBaseFeature->data()->referencesToObjects(aRefs); + std::list > >::const_iterator + anIt = aRefs.begin(), aLast = aRefs.end(); + for (; anIt != aLast; anIt++) { + std::list anObjects = (*anIt).second; + std::list::const_iterator anOIt = anObjects.begin(), anOLast = anObjects.end(); + for (; anOIt != anOLast; anOIt++) { + ResultPtr aResult = std::dynamic_pointer_cast(*anOIt); + if (aResult && 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]; + QToolButton* aButton = dynamic_cast(myView->cellWidget(i, 0)); + bool isChecked = anAttributeList->isInList(aResult); + + bool aBlocked = aButton->blockSignals(true); + aButton->setChecked(isChecked); + this->updateItemIcon(aButton); + aButton->blockSignals(aBlocked); + } + return true; +} + +QList ModuleBase_WidgetConcealedObjects::getControls() const +{ + QList result; + result << myView; + return result; +} + +void ModuleBase_WidgetConcealedObjects::addViewRow(const std::shared_ptr& theResult) +{ + int anId = myView->rowCount(); + myView->setRowCount(anId+1); + + QToolButton* aVisibilityBtn = new QToolButton(this); + connect(aVisibilityBtn, SIGNAL(toggled(bool)), this, SLOT(onItemToggled(bool))); + aVisibilityBtn->setCheckable(true); + aVisibilityBtn->setChecked(false); + updateItemIcon(aVisibilityBtn); + + myView->setCellWidget(anId, 0, aVisibilityBtn); + myView->setItem(anId, 1, new QTableWidgetItem(theResult->data()->name().c_str())); +} + +void ModuleBase_WidgetConcealedObjects::onItemToggled(bool theState) +{ + emit valuesChanged(); + updateObject(myFeature); +} + +void ModuleBase_WidgetConcealedObjects::updateItemIcon(QToolButton* theButton) +{ + bool isChecked = theButton->isChecked(); + theButton->setIcon(isChecked ? QIcon(":icons/concealed_on.png") + : QIcon(":icons/concealed_off.png")); + theButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); +} diff --git a/src/ModuleBase/ModuleBase_WidgetConcealedObjects.h b/src/ModuleBase/ModuleBase_WidgetConcealedObjects.h index b289d7a87..5a42a775c 100644 --- a/src/ModuleBase/ModuleBase_WidgetConcealedObjects.h +++ b/src/ModuleBase/ModuleBase_WidgetConcealedObjects.h @@ -1,70 +1,76 @@ -// 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 -#include - -#include -#include -#include - -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 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& 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 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 > myConcealedResults; -}; - -#endif /* MODULEBASE_WIDGETCONCEALEDOBJECTS_H_ */ +// 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 +#include + +#include +#include +#include + +class ModelAPI_Object; + +class QWidget; +class QTableWidget; +class QToolButton; + +/** +* \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 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& theResult); + +private slots: + /// Processes the display button click in the view. + /// \param theState a new state + void onItemToggled(bool theState); + +private: + /// Updates icon of button + /// \param theButton a button of the table + void updateItemIcon(QToolButton* theButton); + +private: + std::string myBaseShapeAttribute; ///< attribute of the base object + QTableWidget* myView; ///< table view of visibility states + + std::shared_ptr 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 > myConcealedResults; +}; + +#endif /* MODULEBASE_WIDGETCONCEALEDOBJECTS_H_ */ diff --git a/src/PartSet/PartSet_icons.qrc b/src/PartSet/PartSet_icons.qrc index d4b209b39..ede7c88f0 100644 --- a/src/PartSet/PartSet_icons.qrc +++ b/src/PartSet/PartSet_icons.qrc @@ -1,16 +1,18 @@ - - - icons/activate.png - icons/angle_32x32.png - icons/color.png - icons/deactivate.png - icons/edit.png - icons/exec_state_failed.png - icons/exec_state_invalid_parameters.png - icons/hand_point.png - icons/move_to_end.png - icons/sketch_shape.png - icons/expression.png - icons/paper_roll.png - - + + + icons/activate.png + icons/angle_32x32.png + icons/color.png + icons/concealed_on.png + icons/concealed_off.png + icons/deactivate.png + icons/edit.png + icons/exec_state_failed.png + icons/exec_state_invalid_parameters.png + icons/hand_point.png + icons/move_to_end.png + icons/sketch_shape.png + icons/expression.png + icons/paper_roll.png + + diff --git a/src/PartSet/icons/concealed_off.png b/src/PartSet/icons/concealed_off.png new file mode 100644 index 000000000..31c505d82 Binary files /dev/null and b/src/PartSet/icons/concealed_off.png differ diff --git a/src/PartSet/icons/concealed_on.png b/src/PartSet/icons/concealed_on.png new file mode 100644 index 000000000..61ebe4703 Binary files /dev/null and b/src/PartSet/icons/concealed_on.png differ