From 722cced61dc12b73cb086ecab154bf30db70281e Mon Sep 17 00:00:00 2001 From: mpv Date: Wed, 23 Nov 2016 16:08:52 +0300 Subject: [PATCH] Remove not needed attributes from the field feature: they are duplicated in the Tables attribute. --- src/CollectionAPI/CollectionAPI_Field.cpp | 18 ++++++------ src/CollectionAPI/CollectionAPI_Field.h | 11 ++++---- .../CollectionPlugin_Field.cpp | 2 -- src/CollectionPlugin/CollectionPlugin_Field.h | 12 -------- src/CollectionPlugin/Test/TestField.py | 28 +++++++------------ 5 files changed, 26 insertions(+), 45 deletions(-) diff --git a/src/CollectionAPI/CollectionAPI_Field.cpp b/src/CollectionAPI/CollectionAPI_Field.cpp index 98110e861..072041e77 100644 --- a/src/CollectionAPI/CollectionAPI_Field.cpp +++ b/src/CollectionAPI/CollectionAPI_Field.cpp @@ -44,7 +44,6 @@ void CollectionAPI_Field::setComponentsNames(const std::list& theNa //================================================================================================= void CollectionAPI_Field::setValuesType(const std::string& theType) { - fillAttribute(int(valueTypeByStr(theType)), myvaluesType); myvalues->setType(valueTypeByStr(theType)); execute(); } @@ -52,7 +51,6 @@ void CollectionAPI_Field::setValuesType(const std::string& theType) //================================================================================================= void CollectionAPI_Field::setStepsNum(const ModelHighAPI_Integer& theSteps) { - fillAttribute(theSteps, mystepsNum); mystamps->setSize(theSteps.intValue()); execute(); } @@ -70,8 +68,6 @@ void CollectionAPI_Field::addStep(const ModelHighAPI_Integer& theStepNum, \ const ModelHighAPI_Integer& theStamp, \ const std::list >& theComponents) \ { \ - myvalues->setSize(myselection->size() + 1, \ - mycomponentsNames->size(), mystepsNum->value()); \ mystamps->setValue(theStepNum.intValue(), theStamp.intValue()); \ int aRowIndex = 0; \ std::list >::const_iterator \ @@ -101,9 +97,8 @@ void CollectionAPI_Field::dump(ModelHighAPI_Dumper& theDumper) const FeaturePtr aBase = feature(); const std::string& aDocName = theDumper.name(aBase->document()); - theDumper<value()<<", \"" - <value()))<<"\", " - <size()<<", "; + theDumper<tables()<<", \"" + <type())<<"\", "<size()<<", "; theDumper<columns(); aCol++) { if (aCol != 0) theDumper<<", "; - switch(myvaluesType->value()) { + switch(myvalues->type()) { case ModelAPI_AttributeTables::BOOLEAN: theDumper<value(aRow, aCol, aStep).myBool; break; @@ -137,6 +132,11 @@ void CollectionAPI_Field::dump(ModelHighAPI_Dumper& theDumper) const } } +std::shared_ptr CollectionAPI_Field::tableValues() +{ + return myvalues; +} + //================================================================================================= FieldPtr addField(const std::shared_ptr& thePart, const ModelHighAPI_Integer& theStepsNum, @@ -151,6 +151,8 @@ FieldPtr addField(const std::shared_ptr& thePart, aField->setValuesType(theComponentType); aField->setComponentsNames(theComponentNames); aField->setSelection(theSelectionList); + aField->tableValues()->setSize( + int(theSelectionList.size() + 1), theComponentsNum, theStepsNum.intValue()); return aField; } diff --git a/src/CollectionAPI/CollectionAPI_Field.h b/src/CollectionAPI/CollectionAPI_Field.h index d7eef3ee5..302dff44a 100644 --- a/src/CollectionAPI/CollectionAPI_Field.h +++ b/src/CollectionAPI/CollectionAPI_Field.h @@ -33,15 +33,11 @@ public: COLLECTIONAPI_EXPORT virtual ~CollectionAPI_Field(); - INTERFACE_6(CollectionPlugin_Field::ID(), + INTERFACE_4(CollectionPlugin_Field::ID(), selection, CollectionPlugin_Field::SELECTED_ID(), ModelAPI_AttributeSelectionList, /** Field selection list*/, componentsNames, CollectionPlugin_Field::COMPONENTS_NAMES_ID(), ModelAPI_AttributeStringArray, /** Names of components list of strings */, - valuesType, CollectionPlugin_Field::VALUES_TYPE_ID(), - ModelAPI_AttributeInteger, /** Type of the values enumeration */, - stepsNum, CollectionPlugin_Field::STEPS_NB_ID(), - ModelAPI_AttributeInteger, /** Number of steps integer */, stamps, CollectionPlugin_Field::STAMPS_ID(), ModelAPI_AttributeIntArray, /** Identifiers of stamps */, values, CollectionPlugin_Field::VALUES_ID(), ModelAPI_AttributeTables /** Table of values */, @@ -82,6 +78,11 @@ public: /// Dump wrapped feature COLLECTIONAPI_EXPORT virtual void dump(ModelHighAPI_Dumper& theDumper) const; + + /// Returns the internal values tables + COLLECTIONAPI_EXPORT + std::shared_ptr tableValues(); + }; /// Pointer on Field object. diff --git a/src/CollectionPlugin/CollectionPlugin_Field.cpp b/src/CollectionPlugin/CollectionPlugin_Field.cpp index 55fefb6a5..e1921c0b6 100644 --- a/src/CollectionPlugin/CollectionPlugin_Field.cpp +++ b/src/CollectionPlugin/CollectionPlugin_Field.cpp @@ -23,8 +23,6 @@ void CollectionPlugin_Field::initAttributes() { data()->addAttribute(SELECTED_ID(), ModelAPI_AttributeSelectionList::typeId()); data()->addAttribute(COMPONENTS_NAMES_ID(), ModelAPI_AttributeStringArray::typeId()); - //data()->addAttribute(VALUES_TYPE_ID(), ModelAPI_AttributeInteger::typeId()); - //data()->addAttribute(STEPS_NB_ID(), ModelAPI_AttributeInteger::typeId()); data()->addAttribute(STAMPS_ID(), ModelAPI_AttributeIntArray::typeId()); data()->addAttribute(VALUES_ID(), ModelAPI_AttributeTables::typeId()); } diff --git a/src/CollectionPlugin/CollectionPlugin_Field.h b/src/CollectionPlugin/CollectionPlugin_Field.h index 2025c5b51..11b8deb54 100644 --- a/src/CollectionPlugin/CollectionPlugin_Field.h +++ b/src/CollectionPlugin/CollectionPlugin_Field.h @@ -47,18 +47,6 @@ class CollectionPlugin_Field : public ModelAPI_Feature static const std::string MY_COMPONENTS_NAMES_ID("components_names"); return MY_COMPONENTS_NAMES_ID; } - /// attribute name of values types integer identifier - inline static const std::string& VALUES_TYPE_ID() - { - static const std::string MY_VALUES_TYPE_ID("type"); - return MY_VALUES_TYPE_ID; - } - /// attribute name of number of steps - inline static const std::string& STEPS_NB_ID() - { - static const std::string MY_STEPS_NB_ID("steps_nb"); - return MY_STEPS_NB_ID; - } /// attribute name of stamps integer array inline static const std::string& STAMPS_ID() { diff --git a/src/CollectionPlugin/Test/TestField.py b/src/CollectionPlugin/Test/TestField.py index 5bf10bdac..d6ae47a56 100644 --- a/src/CollectionPlugin/Test/TestField.py +++ b/src/CollectionPlugin/Test/TestField.py @@ -66,8 +66,8 @@ anExtrusionFt.selectionList("base").append(aSketchResult, aSketchFaces[0]) anExtrusionFt.string("CreationMethod").setValue("BySizes") anExtrusionFt.real("to_size").setValue(50) anExtrusionFt.real("from_size").setValue(50) -anExtrusionFt.real("to_offset").setValue(0) #TODO: remove -anExtrusionFt.real("from_offset").setValue(0) #TODO: remove +anExtrusionFt.real("to_offset").setValue(0) +anExtrusionFt.real("from_offset").setValue(0) anExtrusionFt.execute() aSession.finishOperation() anExtrusionBody = modelAPI_ResultBody(anExtrusionFt.firstResult()) @@ -85,13 +85,11 @@ aComponentNames = aField.stringArray("components_names") aComponentNames.setSize(2) # two components aComponentNames.setValue(0, "temperatue") aComponentNames.setValue(1, "porosity") -aField.integer("type").setValue(2) # double -aField.integer("steps_nb").setValue(1) # one step aStamps = aField.intArray("stamps") -aStamps.setSize(1) +aStamps.setSize(1) # one step aStamps.setValue(0, 10) aTables = aField.tables("values") -aTables.setType(2) +aTables.setType(2) # double aTables.setSize(1 + 3, 2, 1) # default row + number of selected, number of compoents, number of steps (tables) aTables.setValue(20, 0, 0, 0) # value, index of selection, index of component, index of step aTables.setValue(35, 1, 0, 0) @@ -113,14 +111,12 @@ aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3") aComponentNames = aField.stringArray("components_names") aComponentNames.setSize(1) # one component aComponentNames.setValue(0, "description") -aField.integer("type").setValue(3) # string -aField.integer("steps_nb").setValue(2) # two steps aStamps = aField.intArray("stamps") -aStamps.setSize(2) +aStamps.setSize(2) # two steps aStamps.setValue(0, 1) aStamps.setValue(1, 3) aTables = aField.tables("values") -aTables.setType(3) +aTables.setType(3) # string aTables.setSize(1 + 1, 1, 2) # default row + number of selected, number of compoents, number of steps (tables) aTables.setValue("-default-", 0, 0, 0) # value, index of selection, index of component, index of step aTables.setValue("-default-", 0, 0, 1) @@ -141,13 +137,11 @@ aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3") aComponentNames = aField.stringArray("components_names") aComponentNames.setSize(1) # one component aComponentNames.setValue(0, "description") -aField.integer("type").setValue(1) # integer -aField.integer("steps_nb").setValue(1) # one step aStamps = aField.intArray("stamps") -aStamps.setSize(1) +aStamps.setSize(1) # one step aStamps.setValue(0, 0) aTables = aField.tables("values") -aTables.setType(1) +aTables.setType(1) # integer aTables.setSize(1 + 1, 1, 1) # default row + number of selected, number of compoents, number of steps (tables) aTables.setValue(0, 0, 0, 0) # value, index of selection, index of component, index of step aTables.setValue(2, 1, 0, 0) @@ -167,13 +161,11 @@ aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3") aComponentNames = aField.stringArray("components_names") aComponentNames.setSize(1) # one component aComponentNames.setValue(0, "description") -aField.integer("type").setValue(0) # boolean -aField.integer("steps_nb").setValue(1) # one step aStamps = aField.intArray("stamps") -aStamps.setSize(1) +aStamps.setSize(1) # one step aStamps.setValue(0, 0) aTables = aField.tables("values") -aTables.setType(0) +aTables.setType(0) # boolean aTables.setSize(1 + 1, 1, 1) # default row + number of selected, number of compoents, number of steps (tables) aTables.setValue(True, 0, 0, 0) # value, index of selection, index of component, index of step aTables.setValue(False, 1, 0, 0) -- 2.39.2