Salome HOME
Recover Eye button
authornds <nds@opencascade.com>
Fri, 2 Sep 2016 06:21:49 +0000 (09:21 +0300)
committernds <nds@opencascade.com>
Fri, 2 Sep 2016 06:21:49 +0000 (09:21 +0300)
src/ModuleBase/ModuleBase_WidgetConcealedObjects.cpp
src/ModuleBase/ModuleBase_WidgetConcealedObjects.h
src/PartSet/PartSet_icons.qrc
src/PartSet/icons/concealed_off.png [new file with mode: 0644]
src/PartSet/icons/concealed_on.png [new file with mode: 0644]

index 2e3e0aa8a3964a71643f7d4f1551b4babe2f3467..c39cbd4da9671f6a8fcb524bc9422dff4ca839ac 100644 (file)
-// 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 && 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);
-}
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D\r
+\r
+// File:        ModuleBase_WidgetConcealedObjects.cpp\r
+// Created:     29 Jul 2016\r
+// Author:      Natalia ERMOLAEVA\r
+\r
+#include <ModuleBase_WidgetConcealedObjects.h>\r
+#include <ModuleBase_Tools.h>\r
+\r
+#include <ModelAPI_Result.h>\r
+#include <ModelAPI_AttributeReference.h>\r
+#include <ModelAPI_AttributeRefList.h>\r
+\r
+#include <Config_WidgetAPI.h>\r
+\r
+#include <QGridLayout>\r
+\r
+#include <QWidget>\r
+#include <QTableWidget>\r
+#include <QHeaderView>\r
+#include <QToolButton>\r
+\r
+ModuleBase_WidgetConcealedObjects::ModuleBase_WidgetConcealedObjects(QWidget* theParent,\r
+                                                     const Config_WidgetAPI* theData)\r
+: ModuleBase_ModelWidget(theParent, theData)\r
+{\r
+  myBaseShapeAttribute = theData->getProperty("base_shape_attribute");\r
+  QGridLayout* aMainLay = new QGridLayout(this);\r
+  ModuleBase_Tools::adjustMargins(aMainLay);\r
+\r
+  myView = new QTableWidget(this);\r
+  aMainLay->addWidget(myView);\r
+\r
+  myView->setColumnCount(2);\r
+  myView->horizontalHeader()->setVisible(false);\r
+  myView->verticalHeader()->setVisible(false);\r
+}\r
+\r
+ModuleBase_WidgetConcealedObjects::~ModuleBase_WidgetConcealedObjects()\r
+{\r
+}\r
+\r
+bool ModuleBase_WidgetConcealedObjects::storeValueCustom()\r
+{\r
+  if(!myFeature)\r
+    return false;\r
+  DataPtr aData = myFeature->data();\r
+  AttributeRefListPtr anAttributeList = aData->reflist(attributeID());\r
+  anAttributeList->clear();\r
+  int aSize1 = anAttributeList->size(false);\r
+  for (int i = 0, aSize = myView->rowCount(); i < aSize; i++) {\r
+    QToolButton* aButton = dynamic_cast<QToolButton*>(myView->cellWidget(i, 0));;\r
+    if (aButton->isChecked())\r
+      anAttributeList->append(myConcealedResults[i]);\r
+  }\r
+  int aSize = anAttributeList->size(false);\r
+  return true;\r
+}\r
+\r
+bool ModuleBase_WidgetConcealedObjects::restoreValueCustom()\r
+{\r
+  FeaturePtr aBaseFeature;\r
+  ObjectPtr anObject;\r
+  if (myFeature) {\r
+    anObject = ModuleBase_Tools::getObject(myFeature->attribute(myBaseShapeAttribute));\r
+    if (anObject.get() != NULL)\r
+      aBaseFeature = ModelAPI_Feature::feature(anObject);\r
+  }\r
+  if (myBaseFeature != aBaseFeature) {\r
+    myView->setRowCount(0);\r
+    myConcealedResults.clear();\r
+    myBaseFeature = aBaseFeature;\r
+    if (myBaseFeature.get()) {\r
+      std::list<std::pair<std::string, std::list<std::shared_ptr<ModelAPI_Object> > > > aRefs;\r
+      myBaseFeature->data()->referencesToObjects(aRefs);\r
+      std::list<std::pair<std::string, std::list<ObjectPtr> > >::const_iterator\r
+                                                      anIt = aRefs.begin(), aLast = aRefs.end();\r
+      for (; anIt != aLast; anIt++) {\r
+        std::list<ObjectPtr> anObjects = (*anIt).second;\r
+        std::list<ObjectPtr>::const_iterator anOIt = anObjects.begin(), anOLast = anObjects.end();\r
+        for (; anOIt != anOLast; anOIt++) {\r
+          ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(*anOIt);\r
+          if (aResult && aResult->isConcealed()) {\r
+            int aRowId = myView->rowCount();\r
+            addViewRow(aResult);\r
+            myConcealedResults[aRowId] = aResult;\r
+          }\r
+        }\r
+      }\r
+    }\r
+  }\r
+  \r
+  DataPtr aData = myFeature->data();\r
+  AttributeRefListPtr anAttributeList = aData->reflist(attributeID());\r
+  int aSize = anAttributeList->size();\r
+  for (int i = 0, aSize = myView->rowCount(); i < aSize; i++) {\r
+    ResultPtr aResult = myConcealedResults[i];\r
+    QToolButton* aButton = dynamic_cast<QToolButton*>(myView->cellWidget(i, 0));\r
+    bool isChecked = anAttributeList->isInList(aResult);\r
+\r
+    bool aBlocked = aButton->blockSignals(true);\r
+    aButton->setChecked(isChecked);\r
+    this->updateItemIcon(aButton);\r
+    aButton->blockSignals(aBlocked);\r
+  }\r
+  return true;\r
+}\r
+\r
+QList<QWidget*> ModuleBase_WidgetConcealedObjects::getControls() const\r
+{\r
+  QList<QWidget*> result;\r
+  result << myView;\r
+  return result;\r
+}\r
+\r
+void ModuleBase_WidgetConcealedObjects::addViewRow(const std::shared_ptr<ModelAPI_Result>& theResult)\r
+{\r
+  int anId = myView->rowCount();\r
+  myView->setRowCount(anId+1);\r
+\r
+  QToolButton* aVisibilityBtn = new QToolButton(this);\r
+  connect(aVisibilityBtn, SIGNAL(toggled(bool)), this, SLOT(onItemToggled(bool)));\r
+  aVisibilityBtn->setCheckable(true);\r
+  aVisibilityBtn->setChecked(false);\r
+  updateItemIcon(aVisibilityBtn);\r
+\r
+  myView->setCellWidget(anId, 0, aVisibilityBtn);\r
+  myView->setItem(anId, 1, new QTableWidgetItem(theResult->data()->name().c_str()));\r
+}\r
+\r
+void ModuleBase_WidgetConcealedObjects::onItemToggled(bool theState)\r
+{\r
+  emit valuesChanged();\r
+  updateObject(myFeature);\r
+}\r
+\r
+void ModuleBase_WidgetConcealedObjects::updateItemIcon(QToolButton* theButton)\r
+{\r
+  bool isChecked = theButton->isChecked();\r
+  theButton->setIcon(isChecked ? QIcon(":icons/concealed_on.png")\r
+                               : QIcon(":icons/concealed_off.png"));\r
+  theButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);\r
+}\r
index b289d7a87d5dcfbffba0e5ffbefee39db9d17a66..5a42a775c5c465eaa0e231277f86684bdb08cac9 100644 (file)
@@ -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 <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_ */
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D\r
+\r
+// File:        ModuleBase_WidgetConcealedObjects.h\r
+// Created:     29 Jul 2016\r
+// Author:      Natalia ERMOLAEVA\r
+\r
+#ifndef MODULEBASE_WIDGETCONCEALEDOBJECTS_H_\r
+#define MODULEBASE_WIDGETCONCEALEDOBJECTS_H_\r
+\r
+#include <ModuleBase.h>\r
+#include <ModuleBase_ModelWidget.h>\r
+\r
+#include <string>\r
+#include <map>\r
+#include <memory>\r
+\r
+class ModelAPI_Object;\r
+\r
+class QWidget;\r
+class QTableWidget;\r
+class QToolButton;\r
+\r
+/**\r
+* \ingroup GUI\r
+* Implementation of model widget for table of concealed objects.\r
+*/\r
+class MODULEBASE_EXPORT ModuleBase_WidgetConcealedObjects : public ModuleBase_ModelWidget\r
+{\r
+  Q_OBJECT\r
+ public:\r
+  /// Constructor\r
+  /// \param theParent the parent object\r
+  /// \param theData the widget configuration.\r
+  ModuleBase_WidgetConcealedObjects(QWidget* theParent,\r
+                                    const Config_WidgetAPI* theData);\r
+  virtual ~ModuleBase_WidgetConcealedObjects();\r
+\r
+  /// Redefinition of virtual method\r
+  virtual QList<QWidget*> getControls() const;\r
+\r
+  /// The widget can not accept focus\r
+  virtual bool canAcceptFocus() const { return false; };\r
+\r
+protected:\r
+  /// Saves the internal parameters to the given feature\r
+  /// \return True in success\r
+  virtual bool storeValueCustom();\r
+\r
+  /// Redefinition of virtual method\r
+  virtual bool restoreValueCustom();\r
+\r
+private:\r
+  /// Creates a row in view\r
+  /// \param theResult a result for the row\r
+  void addViewRow(const std::shared_ptr<ModelAPI_Result>& theResult);\r
+\r
+private slots:\r
+  /// Processes the display button click in the view.\r
+  /// \param theState a new state\r
+  void onItemToggled(bool theState);\r
+\r
+private:\r
+  /// Updates icon of button\r
+  /// \param theButton a button of the table\r
+  void updateItemIcon(QToolButton* theButton);\r
+\r
+private:\r
+  std::string myBaseShapeAttribute; ///< attribute of the base object\r
+  QTableWidget* myView; ///< table view of visibility states\r
+\r
+  std::shared_ptr<ModelAPI_Feature> myBaseFeature; ///< backup of feature of filling the table view\r
+  /// backup of visualized in the view concealed objects, stored to avoid table rebuild by restore\r
+  std::map<int, std::shared_ptr<ModelAPI_Result> > myConcealedResults;\r
+};\r
+\r
+#endif /* MODULEBASE_WIDGETCONCEALEDOBJECTS_H_ */\r
index d4b209b39177a6c4460b7b2fd132126264c2c0d2..ede7c88f0590fc77a436bd5d82048597ffadab3f 100644 (file)
@@ -1,16 +1,18 @@
- <!DOCTYPE RCC><RCC version="1.0">
- <qresource>
-     <file>icons/activate.png</file>
-     <file>icons/angle_32x32.png</file>
-     <file>icons/color.png</file>
-     <file>icons/deactivate.png</file>
-     <file>icons/edit.png</file>
-     <file>icons/exec_state_failed.png</file>
-     <file>icons/exec_state_invalid_parameters.png</file>
-     <file>icons/hand_point.png</file>
-     <file>icons/move_to_end.png</file>
-     <file>icons/sketch_shape.png</file>
-     <file>icons/expression.png</file>
-     <file>icons/paper_roll.png</file>
- </qresource>
- </RCC>
+ <!DOCTYPE RCC><RCC version="1.0">\r
+ <qresource>\r
+     <file>icons/activate.png</file>\r
+     <file>icons/angle_32x32.png</file>\r
+     <file>icons/color.png</file>\r
+     <file>icons/concealed_on.png</file>\r
+     <file>icons/concealed_off.png</file>\r
+     <file>icons/deactivate.png</file>\r
+     <file>icons/edit.png</file>\r
+     <file>icons/exec_state_failed.png</file>\r
+     <file>icons/exec_state_invalid_parameters.png</file>\r
+     <file>icons/hand_point.png</file>\r
+     <file>icons/move_to_end.png</file>\r
+     <file>icons/sketch_shape.png</file>\r
+     <file>icons/expression.png</file>\r
+     <file>icons/paper_roll.png</file>\r
+ </qresource>\r
+ </RCC>\r
diff --git a/src/PartSet/icons/concealed_off.png b/src/PartSet/icons/concealed_off.png
new file mode 100644 (file)
index 0000000..31c505d
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 (file)
index 0000000..61ebe47
Binary files /dev/null and b/src/PartSet/icons/concealed_on.png differ