]> SALOME platform Git repositories - modules/shaper.git/commitdiff
Salome HOME
Merge branch 'Dev_1.1.0' of newgeom:newgeom into Dev_1.1.0
authornds <natalia.donis@opencascade.com>
Tue, 10 Mar 2015 09:08:03 +0000 (12:08 +0300)
committernds <natalia.donis@opencascade.com>
Tue, 10 Mar 2015 09:08:03 +0000 (12:08 +0300)
Conflicts:
src/XGUI/XGUI_Workshop.cpp

17 files changed:
src/GeomAlgoAPI/GeomAlgoAPI_DFLoader.cpp
src/Model/CMakeLists.txt
src/Model/Model_AttributeColor.cpp [deleted file]
src/Model/Model_AttributeColor.h [deleted file]
src/Model/Model_AttributeIntArray.cpp [new file with mode: 0644]
src/Model/Model_AttributeIntArray.h [new file with mode: 0644]
src/Model/Model_Data.cpp
src/Model/Model_Data.h
src/Model/Model_ResultBody.cpp
src/ModelAPI/CMakeLists.txt
src/ModelAPI/ModelAPI_AttributeColor.cpp [deleted file]
src/ModelAPI/ModelAPI_AttributeColor.h [deleted file]
src/ModelAPI/ModelAPI_AttributeIntArray.cpp [new file with mode: 0644]
src/ModelAPI/ModelAPI_AttributeIntArray.h [new file with mode: 0644]
src/ModelAPI/ModelAPI_Data.h
src/XGUI/XGUI_Displayer.cpp
src/XGUI/XGUI_Workshop.cpp

index 86c7b0a228059201fde6a5a2530aa90933fd8aab..61e28412aab9d44a70420e17db223e8cee585566 100644 (file)
@@ -23,6 +23,9 @@ const TopoDS_Shape GeomAlgoAPI_DFLoader::refineResult(const  TopoDS_Shape& theRe
     if (nbSubResults == 1) {
       itr.Initialize(theResult);
       if (itr.More()) aResult = itr.Value();
+    } else {
+      /// MPV: store compound anyway: it may be Boolean operation that produces two solids from one
+      aResult = theResult;
     }
   }
   return aResult;
index 20c1c0b29733f0b0bddafad48ffc1ed7d61f2f86..ef4c82c12077d0ba4b2d4067fcf226634c746b2b 100644 (file)
@@ -14,7 +14,7 @@ SET(PROJECT_HEADERS
     Model_AttributeRefAttr.h
     Model_AttributeRefList.h
     Model_AttributeBoolean.h
-    Model_AttributeColor.h
+    Model_AttributeIntArray.h
     Model_AttributeString.h
     Model_AttributeInteger.h
     Model_AttributeSelection.h
@@ -40,7 +40,7 @@ SET(PROJECT_SOURCES
     Model_AttributeRefAttr.cpp
     Model_AttributeRefList.cpp
     Model_AttributeBoolean.cpp
-    Model_AttributeColor.cpp
+    Model_AttributeIntArray.cpp
     Model_AttributeString.cpp
     Model_AttributeInteger.cpp
     Model_AttributeSelection.cpp
diff --git a/src/Model/Model_AttributeColor.cpp b/src/Model/Model_AttributeColor.cpp
deleted file mode 100644 (file)
index 920e35a..0000000
+++ /dev/null
@@ -1,57 +0,0 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File:        Model_AttributeColor.cpp
-// Created:     6 Mar 2015
-// Author:      Natalia ERMOLAEVA
-
-#include <Model_AttributeColor.h>
-#include <ModelAPI_AttributeString.h>
-#include <ModelAPI_Attribute.h>
-#include <ModelAPI_Data.h>
-#include <ModelAPI_Object.h>
-
-#include <Standard_TypeDef.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <TCollection_ExtendedString.hxx>
-#include <TDataStd_Integer.hxx>
-#include <TDataStd_Name.hxx>
-
-#include <string>
-
-void Model_AttributeColor::setValues(const int theRed,
-                                     const int theGreen,
-                                     const int theBlue)
-{
-  if (!myIsInitialized || myRed->Get() != theRed ||
-      myGreen->Get() != theGreen || myBlue->Get() != theBlue) {
-    myRed->Set(theRed);
-    myGreen->Set(theGreen);
-    myBlue->Set(theBlue);
-
-    owner()->data()->sendAttributeUpdated(this);
-  }
-}
-
-void Model_AttributeColor::setValuesRandom()
-{
-  setValues(300, 150, 40);
-}
-
-void Model_AttributeColor::values(int& theRed, int& theGreen, int& theBlue)
-{
-  theRed = myRed->Get();
-  theGreen = myGreen->Get();
-  theBlue = myBlue->Get();
-}
-
-Model_AttributeColor::Model_AttributeColor(TDF_Label& theLabel)
-{
-  // check the attribute could be already presented in this doc (after load document)
-  myIsInitialized = theLabel.FindAttribute(TDataStd_Integer::GetID(), myRed) == Standard_True;
-  if (!myIsInitialized) {
-    // create attribute: not initialized by value yet, just zero
-    myRed = TDataStd_Integer::Set(theLabel, 0);
-    myGreen = TDataStd_Integer::Set(theLabel, 0);
-    myBlue = TDataStd_Integer::Set(theLabel, 0);
-  }
-}
diff --git a/src/Model/Model_AttributeColor.h b/src/Model/Model_AttributeColor.h
deleted file mode 100644 (file)
index 7c5922d..0000000
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File:        Model_AttributeColor.h
-// Created:     6 Mar 2015
-// Author:      Natalia ERMOLAEVA
-
-#ifndef MODEL_ATTRIBUTECOLOR_H_
-#define MODEL_ATTRIBUTECOLOR_H_
-
-#include <Model.h>
-#include <ModelAPI_AttributeColor.h>
-
-#include <TDF_Label.hxx>
-#include <TDataStd_Integer.hxx>
-
-#include <string>
-
-/**\class Model_AttributeColor
- * \ingroup DataModel
- * \brief Attribute that contains three integer values which define the color.
- */
-
-class Model_AttributeColor : public ModelAPI_AttributeColor
-{
-  Handle_TDataStd_Integer myRed;
-  Handle_TDataStd_Integer myGreen;
-  Handle_TDataStd_Integer myBlue;
- public:
-  /// Defines the color value
-  /// \param theRed the red part of the color
-  /// \param theRed the green part of the color
-  /// \param theRed the blue part of the color
-  MODELAPI_EXPORT virtual void setValues(const int theRed,
-                                         const int theGreen,
-                                         const int theBlue);
-
-  /// Fills the attribute values by a random color
-  MODELAPI_EXPORT virtual void setValuesRandom();
-
-  /// Returns the color value
-  MODELAPI_EXPORT virtual void values(int& theRed, int& theGreen, int& theBlue);
-
- protected:
-  /// Initializes attibutes
-  Model_AttributeColor(TDF_Label& theLabel);
-
-  friend class Model_Data;
-};
-
-#endif
diff --git a/src/Model/Model_AttributeIntArray.cpp b/src/Model/Model_AttributeIntArray.cpp
new file mode 100644 (file)
index 0000000..8f21a42
--- /dev/null
@@ -0,0 +1,70 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        Model_AttributeIntArray.cpp
+// Created:     6 Mar 2015
+// Author:      Natalia ERMOLAEVA
+
+#include <Model_AttributeIntArray.h>
+#include <ModelAPI_AttributeString.h>
+#include <ModelAPI_Attribute.h>
+#include <ModelAPI_Data.h>
+#include <ModelAPI_Object.h>
+
+#include <Standard_TypeDef.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_ExtendedString.hxx>
+#include <TDataStd_Integer.hxx>
+#include <TDataStd_Name.hxx>
+
+#include <string>
+
+int Model_AttributeIntArray::size()
+{
+  return myArray.IsNull() ? 0 : myArray->Length();
+}
+
+void Model_AttributeIntArray::setSize(const int theSize)
+{
+  if (myArray.IsNull()) { // create array if it is not done yet
+    if (theSize != 0) { // if size is zero, nothing to do (null array means there is no array)
+      myArray = TDataStd_IntegerArray::Set(myLab, 0, theSize);
+      owner()->data()->sendAttributeUpdated(this);
+    }
+  } else { // reset the old array
+    if (theSize) {
+      if (theSize != myArray->Length()) { // old data is not keept, a new array is created
+        Handle(TColStd_HArray1OfInteger) aNewArray = new TColStd_HArray1OfInteger(0, theSize - 1);
+        myArray->ChangeArray(aNewArray);
+        owner()->data()->sendAttributeUpdated(this);
+      }
+    } else { // size is zero => array must be erased
+      if (!myArray.IsNull()) {
+        myArray.Nullify();
+        myLab.ForgetAttribute(TDataStd_IntegerArray::GetID());
+        owner()->data()->sendAttributeUpdated(this);
+      }
+    }
+  }
+}
+
+void Model_AttributeIntArray::setValue(const int theIndex,
+                                       const int theValue)
+{
+  if (myArray->Value(theIndex) != theValue) {
+    myArray->SetValue(theIndex, theValue);
+    owner()->data()->sendAttributeUpdated(this);
+  }
+}
+
+int Model_AttributeIntArray::value(const int theIndex)
+{
+  return myArray->Value(theIndex);
+}
+
+Model_AttributeIntArray::Model_AttributeIntArray(TDF_Label& theLabel)
+{
+  myLab = theLabel;
+  // check the attribute could be already presented in this doc (after load document)
+  myIsInitialized = 
+    myLab.FindAttribute(TDataStd_IntegerArray::GetID(), myArray) == Standard_True;
+}
diff --git a/src/Model/Model_AttributeIntArray.h b/src/Model/Model_AttributeIntArray.h
new file mode 100644 (file)
index 0000000..82808f5
--- /dev/null
@@ -0,0 +1,54 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        Model_AttributeIntArray.h
+// Created:     6 Mar 2015
+// Author:      Natalia ERMOLAEVA
+
+#ifndef MODEL_ATTRIBUTEINTARRAY_H_
+#define MODEL_ATTRIBUTEINTARRAY_H_
+
+#include <Model.h>
+#include <ModelAPI_AttributeIntArray.h>
+
+#include <TDF_Label.hxx>
+#include <TDataStd_IntegerArray.hxx>
+
+#include <string>
+
+/**\class Model_AttributeIntArray
+ * \ingroup DataModel
+ * \brief API for the attribute that contains several integers in the array inside.
+ * Used for RGB color storage for an example. By default size is one, zero-based.
+ * Represented as array in OCCT. Empty array means that this attribute does not exists.
+ */
+
+class Model_AttributeIntArray : public ModelAPI_AttributeIntArray
+{
+  /// The OCCT array that keeps all values. 
+  Handle_TDataStd_IntegerArray myArray;
+  /// Stores the label as a field to set array if size is not null (null array is buggy in OCAF)
+  TDF_Label myLab;
+ public:
+
+  /// Returns the size of the array (zero means that it is empty)
+  MODEL_EXPORT virtual int size();
+
+  /// Sets the new size of the array. The previous data is erased.
+  MODEL_EXPORT virtual void setSize(const int theSize);
+
+  /// Defines the value of the array by index [0; size-1]
+  MODEL_EXPORT virtual void setValue(const int theIndex,
+                                     const int theValue);
+
+  /// Returns the value by the index
+  MODEL_EXPORT virtual int value(const int theIndex);
+
+
+ protected:
+  /// Initializes attibutes
+  Model_AttributeIntArray(TDF_Label& theLabel);
+
+  friend class Model_Data;
+};
+
+#endif
index 4d0ed5d23bceac061d541d288830bf553acce213..b8aeabaffbba9e19dd2c04e33422da9bb9c59cea 100644 (file)
@@ -15,7 +15,7 @@
 #include <Model_AttributeString.h>
 #include <Model_AttributeSelection.h>
 #include <Model_AttributeSelectionList.h>
-#include <Model_AttributeColor.h>
+#include <Model_AttributeIntArray.h>
 #include <Model_Events.h>
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Result.h>
@@ -91,8 +91,8 @@ void Model_Data::addAttribute(const std::string& theID, const std::string theAtt
     anAttr = new Model_AttributeRefAttr(anAttrLab);
   } else if (theAttrType == ModelAPI_AttributeRefList::type()) {
     anAttr = new Model_AttributeRefList(anAttrLab);
-  } else if (theAttrType == ModelAPI_AttributeColor::type()) {
-    anAttr = new Model_AttributeColor(anAttrLab);
+  } else if (theAttrType == ModelAPI_AttributeIntArray::type()) {
+    anAttr = new Model_AttributeIntArray(anAttrLab);
   } 
   // create also GeomData attributes here because only here the OCAF strucure is known
   else if (theAttrType == GeomData_Point::type()) {
@@ -133,6 +133,7 @@ GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeSelection, selection);
 GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeSelectionList, selectionList);
 GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeRefAttr, refattr);
 GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeRefList, reflist);
+GET_ATTRIBUTE_BY_ID(ModelAPI_AttributeIntArray, intArray);
 
 std::shared_ptr<ModelAPI_Attribute> Model_Data::attribute(const std::string& theID)
 {
index 6604e86e8a246dfce43bccf065e6944fb5637dfc..1787b2a9e0c2aa9fe9f5a3da79a1f9c7c7c690de 100644 (file)
@@ -17,6 +17,7 @@
 #include <ModelAPI_AttributeReference.h>
 #include <ModelAPI_AttributeRefList.h>
 #include <ModelAPI_AttributeString.h>
+#include <ModelAPI_AttributeIntArray.h>
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Feature.h>
 #include <ModelAPI_Object.h>
@@ -100,6 +101,10 @@ class Model_Data : public ModelAPI_Data
   /// Returns the attribute that contains real value with double precision
   MODEL_EXPORT virtual std::shared_ptr<ModelAPI_AttributeString>
     string(const std::string& theID);
+  /// Returns the attribute that contains integer values array
+  MODEL_EXPORT virtual std::shared_ptr<ModelAPI_AttributeIntArray>
+    intArray(const std::string& theID);
+
   /// Returns the generic attribute by identifier
   /// \param theID identifier of the attribute
   MODEL_EXPORT virtual std::shared_ptr<ModelAPI_Attribute> attribute(const std::string& theID);
index 6db5c94303e66708d66c5a2921632990a6437e64..7b7e3c3be3a8eab1722a97f0a049137e33274161 100644 (file)
@@ -7,7 +7,7 @@
 #include <Model_ResultBody.h>
 #include <Model_Data.h>
 #include <Model_Document.h>
-#include <ModelAPI_AttributeColor.h>
+#include <ModelAPI_AttributeIntArray.h>
 #include <TNaming_Builder.hxx>
 #include <TNaming_NamedShape.hxx>
 #include <TDataStd_Name.hxx>
@@ -48,19 +48,14 @@ void Model_ResultBody::initAttributes()
 {
   // append the color attribute
   DataPtr aData = data();
-  aData->addAttribute(COLOR_ID(), ModelAPI_AttributeColor::type());
-  // set the default value
-  bool anIsRandomColor = Config_PropManager::boolean("Visualization", "random_result_color",
-                                                     "true");
-  AttributeColorPtr aColorAttr = std::dynamic_pointer_cast<ModelAPI_AttributeColor>
-                                                             (aData->attribute(COLOR_ID()));
-  if (anIsRandomColor)
-    aColorAttr->setValuesRandom();
-  else {
-    std::vector<int> aRGB;
-    aRGB = Config_PropManager::color("Visualization", "result_body_color", RESULT_BODY_COLOR);
-    aColorAttr->setValues(aRGB[0], aRGB[1], aRGB[2]);
-  }
+  aData->addAttribute(COLOR_ID(), ModelAPI_AttributeIntArray::type());
+  AttributeIntArrayPtr aColorAttr = aData->intArray(COLOR_ID());
+  std::vector<int> aRGB;
+  aRGB = Config_PropManager::color("Visualization", "result_body_color", RESULT_BODY_COLOR);
+  aColorAttr->setSize(3);
+  aColorAttr->setValue(0, aRGB[0]);
+  aColorAttr->setValue(1, aRGB[1]);
+  aColorAttr->setValue(2, aRGB[2]);
 }
 
 void Model_ResultBody::store(const std::shared_ptr<GeomAPI_Shape>& theShape)
index 497fe5365b604573f73a95f6bc306ea7b45b2ac8..44602ce1c17ab5e8dbff136c9bab23e62280acb5 100644 (file)
@@ -9,7 +9,7 @@ SET(PROJECT_HEADERS
     ModelAPI.h
     ModelAPI_Attribute.h
     ModelAPI_AttributeBoolean.h
-    ModelAPI_AttributeColor.h
+    ModelAPI_AttributeIntArray.h
     ModelAPI_AttributeDocRef.h
     ModelAPI_AttributeDouble.h
     ModelAPI_AttributeInteger.h
@@ -45,7 +45,7 @@ SET(PROJECT_HEADERS
 SET(PROJECT_SOURCES
     ModelAPI_Attribute.cpp
     ModelAPI_AttributeBoolean.cpp
-    ModelAPI_AttributeColor.cpp
+    ModelAPI_AttributeIntArray.cpp
     ModelAPI_AttributeDocRef.cpp
     ModelAPI_AttributeDouble.cpp
     ModelAPI_AttributeInteger.cpp
diff --git a/src/ModelAPI/ModelAPI_AttributeColor.cpp b/src/ModelAPI/ModelAPI_AttributeColor.cpp
deleted file mode 100644 (file)
index 1909fc3..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File:        ModelAPI_AttributeColor.cpp
-// Created:     6 Mar 2015
-// Author:      Natalia ERMOLAEVA
-
-#include <ModelAPI_AttributeColor.h>
-
-
-std::string ModelAPI_AttributeColor::attributeType()
-{
-  return type();
-}
-
-/// To virtually destroy the fields of successors
-ModelAPI_AttributeColor::~ModelAPI_AttributeColor()
-{
-}
-
-ModelAPI_AttributeColor::ModelAPI_AttributeColor()
-{
-}
diff --git a/src/ModelAPI/ModelAPI_AttributeColor.h b/src/ModelAPI/ModelAPI_AttributeColor.h
deleted file mode 100644 (file)
index 6d3986a..0000000
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-
-// File:        ModelAPI_AttributeColor.h
-// Created:     6 Mar 2015
-// Author:      Natalia ERMOLAEVA
-
-#ifndef ModelAPI_AttributeColor_H_
-#define ModelAPI_AttributeColor_H_
-
-#include <ModelAPI.h>
-#include <ModelAPI_Attribute.h>
-
-#include <string>
-
-
-/**\class ModelAPI_AttributeColor
- * \ingroup DataModel
- * \brief API for the attribute that contains color (int, int, int). The color is in the range [0, 255]
- * There is an opportunity to fill the attribute by a random color
- */
-
-class ModelAPI_AttributeColor : public ModelAPI_Attribute
-{
- public:
-  /// Defines the color value
-  /// \param theRed the red part of the color
-  /// \param theRed the green part of the color
-  /// \param theRed the blue part of the color
-  MODELAPI_EXPORT virtual void setValues(const int theRed,
-                                         const int theGreen,
-                                         const int theBlue) = 0;
-
-  /// Fills the attribute values by a random color
-  MODELAPI_EXPORT virtual void setValuesRandom() = 0;
-
-  /// Returns the color value
-  MODELAPI_EXPORT virtual void values(int& theRed, int& theGreen, int& theBlue) = 0;
-
-  /// Returns the type of this class of attributes
-  MODELAPI_EXPORT static std::string type()
-  {
-    return "Color";
-  }
-
-  /// Returns the type of this class of attributes, not static method
-  MODELAPI_EXPORT virtual std::string attributeType();
-
-  /// To virtually destroy the fields of successors
-  MODELAPI_EXPORT virtual ~ModelAPI_AttributeColor();
-
- protected:
-  /// Objects are created for features automatically
-  MODELAPI_EXPORT ModelAPI_AttributeColor();
-};
-
-//! Pointer on double attribute
-typedef std::shared_ptr<ModelAPI_AttributeColor> AttributeColorPtr;
-
-#endif
diff --git a/src/ModelAPI/ModelAPI_AttributeIntArray.cpp b/src/ModelAPI/ModelAPI_AttributeIntArray.cpp
new file mode 100644 (file)
index 0000000..0e0304c
--- /dev/null
@@ -0,0 +1,22 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ModelAPI_AttributeIntArray.cpp
+// Created:     6 Mar 2015
+// Author:      Natalia ERMOLAEVA
+
+#include <ModelAPI_AttributeIntArray.h>
+
+
+std::string ModelAPI_AttributeIntArray::attributeType()
+{
+  return type();
+}
+
+/// To virtually destroy the fields of successors
+ModelAPI_AttributeIntArray::~ModelAPI_AttributeIntArray()
+{
+}
+
+ModelAPI_AttributeIntArray::ModelAPI_AttributeIntArray()
+{
+}
diff --git a/src/ModelAPI/ModelAPI_AttributeIntArray.h b/src/ModelAPI/ModelAPI_AttributeIntArray.h
new file mode 100644 (file)
index 0000000..177db04
--- /dev/null
@@ -0,0 +1,59 @@
+// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
+
+// File:        ModelAPI_AttributeIntArray.h
+// Created:     6 Mar 2015
+// Author:      Natalia ERMOLAEVA
+
+#ifndef ModelAPI_AttributeIntArray_H_
+#define ModelAPI_AttributeIntArray_H_
+
+#include <ModelAPI.h>
+#include <ModelAPI_Attribute.h>
+
+#include <string>
+
+
+/**\class ModelAPI_AttributeIntArray
+ * \ingroup DataModel
+ * \brief API for the attribute that contains several integers in the array inside.
+ * Used for RGB color storage for an example. By default size is one, zero-based.
+ */
+
+class ModelAPI_AttributeIntArray : public ModelAPI_Attribute
+{
+ public:
+
+  /// Returns the size of the array (zero means that it is empty)
+  MODELAPI_EXPORT virtual int size() = 0;
+
+  /// Sets the new size of the array. The previous data is erased.
+  MODELAPI_EXPORT virtual void setSize(const int theSize) = 0;
+
+  /// Defines the value of the array by index [0; size-1]
+  MODELAPI_EXPORT virtual void setValue(const int theIndex,
+                                         const int theValue) = 0;
+
+  /// Returns the value by the index
+  MODELAPI_EXPORT virtual int value(const int theIndex) = 0;
+
+  /// Returns the type of this class of attributes
+  MODELAPI_EXPORT static std::string type()
+  {
+    return "IntArray";
+  }
+
+  /// Returns the type of this class of attributes, not static method
+  MODELAPI_EXPORT virtual std::string attributeType();
+
+  /// To virtually destroy the fields of successors
+  MODELAPI_EXPORT virtual ~ModelAPI_AttributeIntArray();
+
+ protected:
+  /// Objects are created for features automatically
+  MODELAPI_EXPORT ModelAPI_AttributeIntArray();
+};
+
+//! Pointer on double attribute
+typedef std::shared_ptr<ModelAPI_AttributeIntArray> AttributeIntArrayPtr;
+
+#endif
index bb532ce08bc51bb56e97357cceae56636489f3af..2d6baddb0d7c5b4f7bf59ed71a5647e22e6f5a40 100644 (file)
@@ -26,6 +26,7 @@ class ModelAPI_Attribute;
 class ModelAPI_Feature;
 class ModelAPI_AttributeSelection;
 class ModelAPI_AttributeSelectionList;
+class ModelAPI_AttributeIntArray;
 class ModelAPI_Object;
 class GeomAPI_Shape;
 
@@ -75,6 +76,8 @@ class MODELAPI_EXPORT ModelAPI_Data
   virtual std::shared_ptr<ModelAPI_AttributeBoolean> boolean(const std::string& theID) = 0;
   /// Returns the attribute that contains boolean value
   virtual std::shared_ptr<ModelAPI_AttributeString> string(const std::string& theID) = 0;
+  /// Returns the attribute that contains integer values array
+  virtual std::shared_ptr<ModelAPI_AttributeIntArray> intArray(const std::string& theID) = 0;
 
   /// Returns the generic attribute by identifier
   /// \param theID identifier of the attribute
index 88e8d599c3856ec43e16a4f2500976eecc6fd70e..0db30a1453b772c1efbbd1ac8371d15ed615b0d0 100644 (file)
@@ -16,7 +16,7 @@
 #include <ModelAPI_Data.h>
 #include <ModelAPI_Object.h>
 #include <ModelAPI_Tools.h>
-#include <ModelAPI_AttributeColor.h>
+#include <ModelAPI_AttributeIntArray.h>
 
 #include <ModuleBase_ResultPrs.h>
 
@@ -764,12 +764,13 @@ void XGUI_Displayer::customizeObject(ObjectPtr theObject)
   // correct the result's color it it has the attribute
   ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(theObject);
   if (aResult.get() != NULL && aResult->data()->attribute(ModelAPI_Result::COLOR_ID()).get() != NULL) {
-    int aRed, aGreen, aBlue;
-
-    AttributeColorPtr aColorAttr = std::dynamic_pointer_cast<ModelAPI_AttributeColor>(
-                                              aResult->data()->attribute(ModelAPI_Result::COLOR_ID()));
-    aColorAttr->values(aRed, aGreen, aBlue);
-    anAISObj->setColor(aRed, aGreen, aBlue);
+    AttributeIntArrayPtr aColorAttr = aResult->data()->intArray(ModelAPI_Result::COLOR_ID());
+    if (aColorAttr.get() && aColorAttr->size()) {
+      int aRed = aColorAttr->value(0);
+      int aGreen = aColorAttr->value(1);
+      int aBlue = aColorAttr->value(2);
+      anAISObj->setColor(aRed, aGreen, aBlue);
+    }
   }
   else {
     // Customization of presentation
index 7a7a820620845e76e33582eae1dac9610d84bff5..dacaa1512da880587ec7efdc42d68434920aad24 100644 (file)
@@ -1408,24 +1408,23 @@ bool XGUI_Workshop::canChangeColor() const
 #include <QDialogButtonBox>
 #include <QHBoxLayout>
 #include <QtxColorButton.h>
-#include <ModelAPI_AttributeColor.h>
+#include <ModelAPI_AttributeIntArray.h>
 void XGUI_Workshop::changeColor(const QObjectPtrList& theObjects)
 {
   // 1. find the initial value of the color
-  AttributeColorPtr aColorAttr;
+  AttributeIntArrayPtr aColorAttr;
   foreach(ObjectPtr anObj, theObjects) {
     ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObj);
     if (aResult.get() != NULL) {
-      AttributePtr anAttr = aResult->data()->attribute(ModelAPI_Result::COLOR_ID());
-      if (anAttr.get() != NULL)
-        aColorAttr = std::dynamic_pointer_cast<ModelAPI_AttributeColor>(anAttr);
+      aColorAttr = aResult->data()->intArray(ModelAPI_Result::COLOR_ID());
     }
   }
   // there is no object with the color attribute
-  if (aColorAttr.get() == NULL)
+  if (aColorAttr.get() == NULL || aColorAttr->size() == 0)
     return;
-  int aRed, aGreen, aBlue;
-  aColorAttr->values(aRed, aGreen, aBlue);
+  int aRed = aColorAttr->value(0);
+  int aGreen = aColorAttr->value(1);
+  int aBlue = aColorAttr->value(2);
 
   // 2. show the dialog to change the value
   QDialog* aDlg = new QDialog();
@@ -1468,13 +1467,15 @@ void XGUI_Workshop::changeColor(const QObjectPtrList& theObjects)
   foreach(ObjectPtr anObj, theObjects) {
     ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObj);
     if (aResult.get() != NULL) {
-      AttributePtr anAttr = aResult->data()->attribute(ModelAPI_Result::COLOR_ID());
-      if (anAttr.get() != NULL) {
-        aColorAttr = std::dynamic_pointer_cast<ModelAPI_AttributeColor>(anAttr);
-        if (aColorAttr.get() != NULL) {
-          aColorAttr->setValues(aRedResult, aGreenResult, aBlueResult);
-          ModelAPI_EventCreator::get()->sendUpdated(anObj, EVENT_DISP);
+      aColorAttr = aResult->data()->intArray(ModelAPI_Result::COLOR_ID());
+      if (aColorAttr.get() != NULL) {
+        if (!aColorAttr->size()) {
+          aColorAttr->setSize(3);
         }
+        aColorAttr->setValue(0, aRedResult);
+        aColorAttr->setValue(1, aGreenResult);
+        aColorAttr->setValue(2, aBlueResult);
+        ModelAPI_EventCreator::get()->sendUpdated(anObj, EVENT_DISP);
       }
     }
   }