1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
3 // File: Model_AttributeColor.cpp
5 // Author: Natalia ERMOLAEVA
7 #include <Model_AttributeColor.h>
8 #include <ModelAPI_AttributeString.h>
9 #include <ModelAPI_Attribute.h>
10 #include <ModelAPI_Data.h>
11 #include <ModelAPI_Object.h>
13 #include <Standard_TypeDef.hxx>
14 #include <TCollection_AsciiString.hxx>
15 #include <TCollection_ExtendedString.hxx>
16 #include <TDataStd_Integer.hxx>
17 #include <TDataStd_Name.hxx>
21 void Model_AttributeColor::setValues(const int theRed,
25 if (!myIsInitialized || myRed->Get() != theRed ||
26 myGreen->Get() != theGreen || myBlue->Get() != theBlue) {
28 myGreen->Set(theGreen);
31 owner()->data()->sendAttributeUpdated(this);
35 void Model_AttributeColor::setValuesRandom()
37 setValues(300, 150, 40);
40 void Model_AttributeColor::values(int& theRed, int& theGreen, int& theBlue)
42 theRed = myRed->Get();
43 theGreen = myGreen->Get();
44 theBlue = myBlue->Get();
47 Model_AttributeColor::Model_AttributeColor(TDF_Label& theLabel)
49 // check the attribute could be already presented in this doc (after load document)
50 myIsInitialized = theLabel.FindAttribute(TDataStd_Integer::GetID(), myRed) == Standard_True;
51 if (!myIsInitialized) {
52 // create attribute: not initialized by value yet, just zero
53 myRed = TDataStd_Integer::Set(theLabel, 0);
54 myGreen = TDataStd_Integer::Set(theLabel, 0);
55 myBlue = TDataStd_Integer::Set(theLabel, 0);