From c82b46267b5cf8a96395b74cf49a6ba801317d1b Mon Sep 17 00:00:00 2001 From: nds Date: Fri, 2 Sep 2016 09:21:49 +0300 Subject: [PATCH] Recover Eye button --- .../ModuleBase_WidgetConcealedObjects.cpp | 274 +++++++++--------- .../ModuleBase_WidgetConcealedObjects.h | 146 +++++----- src/PartSet/PartSet_icons.qrc | 34 ++- src/PartSet/icons/concealed_off.png | Bin 0 -> 344 bytes src/PartSet/icons/concealed_on.png | Bin 0 -> 3184 bytes 5 files changed, 237 insertions(+), 217 deletions(-) create mode 100644 src/PartSet/icons/concealed_off.png create mode 100644 src/PartSet/icons/concealed_on.png 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 0000000000000000000000000000000000000000..31c505d82d1b08a54ac666f380e47837c04a9247 GIT binary patch literal 344 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf6I14-?iy0WWg+Z8+Vb&Z8pdd@S zqpu?a!^Xav-+_~Xe1&9>AYTTCDpdxChGqtapZ|gMO9qBg0|tgy2@DKYGZ+}e^C!h0 zbpxtB=jq}YQgLg`g}q)*j54er?(g*wk?M6SZd-7Lc?-+M3t|_!P0V(f{Xe+!s?!SF z7o4|lH+Mu8t$6Abuq9$iMwEAw>6Irl`P!MEEC2jp9wco3z&Rn-BTl&>U-6Uw^&Q z+YbKhU*1G_PHCP|D)HrP#igwaTB7dk=+3H{dZ)8;J6l`al52BL-Z|bcT3xtO)zBo} l>!#KLZ*U+5Lu!Sk^o_Z5E4Meg@_7P6crJiNL9pw)e1;Xm069{HJUZAPk55R%$-RIA z6-eL&AQ0xu!e<4=008gy@A0LT~suv4>S3ILP<0Bm`DLLvaF4FK%)Nj?Pt*r}7;7Xa9z9H|HZjR63e zC`Tj$K)V27Re@400>HumpsYY5E(E}?0f1SyGDiY{y#)Yvj#!WnKwtoXnL;eg03bL5 z07D)V%>y7z1E4U{zu>7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