#endif // CollectionAPI_swig_H_
%}
+%{
+ #include "ModelHighAPI_swig.h"
+
+ // fix for SWIG v2.0.4
+ #define SWIGPY_SLICE_ARG(obj) ((PySliceObject*)(obj))
+%}
+
%include "doxyhelp.i"
// import other modules
// standard definitions
%include "typemaps.i"
+%include "std_list.i"
+%include "std_string.i"
%include "std_shared_ptr.i"
+%template(StringList) std::list<std::string>;
+%template(IntegerList) std::list<int>;
+%template(DoubleList) std::list<double>;
+%template(BooleanList) std::list<bool>;
+%template(StringListList) std::list<std::list<std::string> >;
+%template(IntegerListList) std::list<std::list<int> >;
+%template(DoubleListList) std::list<std::list<double> >;
+%template(BooleanListList) std::list<std::list<bool> >;
+
// shared pointers
%shared_ptr(CollectionAPI_Group)
%shared_ptr(CollectionAPI_Field)
#include <ModelHighAPI_Integer.h>
#include <ModelHighAPI_Selection.h>
#include <ModelHighAPI_Tools.h>
-#include <ModelHighAPI_ComponentValue.h>
#include <ModelAPI_AttributeTables.h>
#include <ModelAPI_AttributeStringArray.h>
execute();
}
-//=================================================================================================
-void CollectionAPI_Field::setComponentsNum(const ModelHighAPI_Integer& theNum)
-{
- fillAttribute(theNum, mycomponentsNum);
- execute();
-}
-
//=================================================================================================
void CollectionAPI_Field::setComponentsNames(const std::list<std::string>& theNames)
{
void CollectionAPI_Field::setValuesType(const std::string& theType)
{
fillAttribute(int(valueTypeByStr(theType)), myvaluesType);
+ myvalues->setType(valueTypeByStr(theType));
execute();
}
void CollectionAPI_Field::setStepsNum(const ModelHighAPI_Integer& theSteps)
{
fillAttribute(theSteps, mystepsNum);
+ mystamps->setSize(theSteps.intValue());
execute();
}
}
//=================================================================================================
-void CollectionAPI_Field::addStep(const ModelHighAPI_Integer& theStepNum,
- const ModelHighAPI_Integer& theStamp,
- const std::list<std::list<ModelHighAPI_ComponentValue> >& theComponents)
-{
- // set the table size to be sure the values are up to date
- myvalues->setSize(myselection->size() + 1 /* with defaults */,
- mycomponentsNum->value(), mystepsNum->value());
-
- // set values one by one
- int aRowIndex = 0;
- std::list<std::list<ModelHighAPI_ComponentValue> >::const_iterator
- aRowsIter = theComponents.begin();
- for(; aRowsIter != theComponents.end(); aRowsIter++, aRowIndex++) {
- int aColIndex = 0;
- std::list<ModelHighAPI_ComponentValue>::const_iterator aColIter = aRowsIter->begin();
- for(; aColIter != aRowsIter->end(); aColIter++, aColIndex++) {
- aColIter->fill(myvalues, theStepNum.intValue(), aColIndex, aRowIndex);
- }
- }
- execute();
+#define addStepImplementation(type, fieldType, type2, fieldType2, type3, fieldType3) \
+void CollectionAPI_Field::addStep(const ModelHighAPI_Integer& theStepNum, \
+ const ModelHighAPI_Integer& theStamp, \
+ const std::list<std::list<type> >& theComponents) \
+{ \
+ myvalues->setSize(myselection->size() + 1, \
+ mycomponentsNames->size(), mystepsNum->value()); \
+ mystamps->setValue(theStepNum.intValue(), theStamp.intValue()); \
+ int aRowIndex = 0; \
+ std::list<std::list<type> >::const_iterator \
+ aRowsIter = theComponents.begin(); \
+ for(; aRowsIter != theComponents.end(); aRowsIter++, aRowIndex++) { \
+ int aColIndex = 0; \
+ std::list<type>::const_iterator aColIter = aRowsIter->begin(); \
+ for(; aColIter != aRowsIter->end(); aColIter++, aColIndex++) { \
+ ModelAPI_AttributeTables::Value aVal; \
+ aVal.fieldType = *aColIter; \
+ aVal.fieldType2 = type2(*aColIter); \
+ aVal.fieldType3 = type3(*aColIter); \
+ myvalues->setValue(aVal, aRowIndex, aColIndex, theStepNum.intValue()); \
+ } \
+ } \
+ execute(); \
}
+addStepImplementation(double, myDouble, int, myInt, bool, myBool);
+addStepImplementation(int, myInt, double, myDouble, bool, myBool);
+addStepImplementation(bool, myBool, int, myInt, double, myDouble);
+addStepImplementation(std::string, myStr, std::string, myStr, std::string, myStr);
+
//=================================================================================================
void CollectionAPI_Field::dump(ModelHighAPI_Dumper& theDumper) const
{
FeaturePtr aBase = feature();
const std::string& aDocName = theDumper.name(aBase->document());
- theDumper<<aBase<<" = model.addField("<<aDocName<<", "<<mystepsNum<<", "
- <<strByValueType(ModelAPI_AttributeTables::ValueType(myvaluesType->value()))<<", "
- <<mycomponentsNum->value()<<", ";
+ theDumper<<aBase<<" = model.addField("<<aDocName<<", "<<mystepsNum->value()<<", \""
+ <<strByValueType(ModelAPI_AttributeTables::ValueType(myvaluesType->value()))<<"\", "
+ <<mycomponentsNames->size()<<", ";
theDumper<<mycomponentsNames<<", ";
theDumper<<myselection<<")"<<std::endl;
// set values step by step
for(int aCol = 0; aCol < myvalues->columns(); aCol++) {
if (aCol != 0)
theDumper<<", ";
- switch(myvalues->type()) {
+ switch(myvaluesType->value()) {
case ModelAPI_AttributeTables::BOOLEAN:
theDumper<<myvalues->value(aRow, aCol, aStep).myBool;
break;
theDumper<<myvalues->value(aRow, aCol, aStep).myDouble;
break;
case ModelAPI_AttributeTables::STRING:
- theDumper<<myvalues->value(aRow, aCol, aStep).myStr;
+ theDumper<<'"'<<myvalues->value(aRow, aCol, aStep).myStr<<'"';
break;
}
}
theDumper<<"]";
}
- theDumper<<")"<<std::endl;
+ theDumper<<"])"<<std::endl;
}
}
//=================================================================================================
FieldPtr addField(const std::shared_ptr<ModelAPI_Document>& thePart,
const ModelHighAPI_Integer& theStepsNum,
- std::string& theComponentType,
+ const std::string& theComponentType,
const int theComponentsNum,
const std::list<std::string>& theComponentNames,
const std::list<ModelHighAPI_Selection>& theSelectionList)
std::shared_ptr<CollectionAPI_Field> aField(new CollectionAPI_Field(aFeature));
aField->setStepsNum(theStepsNum);
aField->setValuesType(theComponentType);
- aField->setComponentsNum(theComponentsNum);
aField->setComponentsNames(theComponentNames);
aField->setSelection(theSelectionList);
COLLECTIONAPI_EXPORT
virtual ~CollectionAPI_Field();
- INTERFACE_7(CollectionPlugin_Field::ID(),
+ INTERFACE_6(CollectionPlugin_Field::ID(),
selection, CollectionPlugin_Field::SELECTED_ID(),
ModelAPI_AttributeSelectionList, /** Field selection list*/,
- componentsNum, CollectionPlugin_Field::COMPONENTS_NB_ID(),
- ModelAPI_AttributeInteger, /** Number of components integer */,
componentsNames, CollectionPlugin_Field::COMPONENTS_NAMES_ID(),
ModelAPI_AttributeStringArray, /** Names of components list of strings */,
valuesType, CollectionPlugin_Field::VALUES_TYPE_ID(),
/// Set selected objects.
COLLECTIONAPI_EXPORT
void setSelection(const std::list<ModelHighAPI_Selection>& theFieldList);
- /// Set number of components
- COLLECTIONAPI_EXPORT
- void setComponentsNum(const ModelHighAPI_Integer& theNum);
/// Set names of components
COLLECTIONAPI_EXPORT
void setComponentsNames(const std::list<std::string>& theNames);
/// Set stamps identifiers
COLLECTIONAPI_EXPORT
void setStamps(const std::list<ModelHighAPI_Integer>& theStamps);
- /// Sets the values of specific step
+ /// Sets the double values of specific step
+ COLLECTIONAPI_EXPORT
+ void addStep(const ModelHighAPI_Integer& theStepNum, const ModelHighAPI_Integer& theStamp,
+ const std::list<std::list<double> >& theComponents);
+ /// Sets the integer values of specific step
+ COLLECTIONAPI_EXPORT
+ void addStep(const ModelHighAPI_Integer& theStepNum, const ModelHighAPI_Integer& theStamp,
+ const std::list<std::list<int> >& theComponents);
+ /// Sets the string values of specific step
+ COLLECTIONAPI_EXPORT
+ void addStep(const ModelHighAPI_Integer& theStepNum, const ModelHighAPI_Integer& theStamp,
+ const std::list<std::list<std::string> >& theComponents);
+ /// Sets the boolean values of specific step
COLLECTIONAPI_EXPORT
void addStep(const ModelHighAPI_Integer& theStepNum, const ModelHighAPI_Integer& theStamp,
- const std::list<std::list<ModelHighAPI_ComponentValue> >& theComponents);
+ const std::list<std::list<bool> >& theComponents);
/// Dump wrapped feature
COLLECTIONAPI_EXPORT
COLLECTIONAPI_EXPORT
FieldPtr addField(const std::shared_ptr<ModelAPI_Document>& thePart,
const ModelHighAPI_Integer& theStepsNum,
- std::string& theComponentType,
+ const std::string& theComponentType,
const int theComponentsNum,
const std::list<std::string>& theComponentNames,
const std::list<ModelHighAPI_Selection>& theSelectionList);
../GeomValidators
../Events
../ModuleBase
+ ../Config
+ ${CAS_INCLUDE_DIRS}
)
SET(PROJECT_LIBRARIES
ModuleBase
)
-ADD_DEFINITIONS(-DCOLLECTIONPLUGIN_EXPORTS)
+ADD_DEFINITIONS(-DCOLLECTIONPLUGIN_EXPORTS ${CAS_DEFINITIONS})
ADD_LIBRARY(CollectionPlugin MODULE ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${XML_RESOURCES} ${TEXT_RESOURCES})
TARGET_LINK_LIBRARIES(CollectionPlugin ${PROJECT_LIBRARIES})
ADD_UNIT_TESTS(
TestGroup.py
+ TestField.py
)
void CollectionPlugin_Field::initAttributes()
{
data()->addAttribute(SELECTED_ID(), ModelAPI_AttributeSelectionList::typeId());
- data()->addAttribute(COMPONENTS_NB_ID(), ModelAPI_AttributeInteger::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());
class CollectionPlugin_Field : public ModelAPI_Feature
{
public:
- /// Extrusion kind
+ /// Feature kind
inline static const std::string& ID()
{
static const std::string MY_FIELD_ID("Field");
static const std::string MY_SELECTED_ID("selected");
return MY_SELECTED_ID;
}
- /// attribute name of components number
- inline static const std::string& COMPONENTS_NB_ID()
- {
- static const std::string MY_COMPONENTS_NB_ID("components_nb");
- return MY_COMPONENTS_NB_ID;
- }
/// attribute name of componenets titles array
inline static const std::string& COMPONENTS_NAMES_ID()
{
void CollectionPlugin_Group::initAttributes()
{
- //data()->addAttribute(CollectionPlugin_Group::NAME_ID(), ModelAPI_AttributeString::typeId());
- data()->addAttribute(CollectionPlugin_Group::LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
+ data()->addAttribute(CollectionPlugin_Group::LIST_ID(),
+ ModelAPI_AttributeSelectionList::typeId());
}
void CollectionPlugin_Group::execute()
const std::string& theType,
QWidget* theParent,
Config_WidgetAPI* theWidgetApi,
- ModuleBase_IWorkshop* /*theWorkshop*/)
+ ModuleBase_IWorkshop* theWorkshop)
{
ModuleBase_ModelWidget* aWidget = 0;
if (myPanelTypes.find(theType) == myPanelTypes.end())
return aWidget;
if (theType == "field-panel") {
- aWidget = new CollectionPlugin_WidgetField(theParent, theWidgetApi);
+ aWidget = new CollectionPlugin_WidgetField(theParent, theWorkshop, theWidgetApi);
}
return aWidget;
#include "CollectionPlugin_WidgetField.h"
+#include <ModuleBase_Tools.h>
+#include <ModuleBase_IWorkshop.h>
+#include <ModuleBase_ISelection.h>
+
#include <QLayout>
#include <QWidget>
#include <QFormLayout>
#include <QTableWidget>
#include <QPushButton>
#include <QHeaderView>
+#include <QStackedWidget>
+#include <QValidator>
+#include <QStyledItemDelegate>
+#include <QLineEdit>
+
+
+class DataTableItemDelegate : public QStyledItemDelegate
+{
+public:
+ enum DataType {
+ DoubleType,
+ IntegerType,
+ BooleanType,
+ StringType };
+
+ DataTableItemDelegate(DataType theType) : QStyledItemDelegate() { myType = theType; }
+
+ virtual QWidget* createEditor(QWidget* theParent,
+ const QStyleOptionViewItem & theOption,
+ const QModelIndex& theIndex) const;
+
+ virtual void setModelData(QWidget* theEditor, QAbstractItemModel* theModel,
+ const QModelIndex& theIndex) const;
+
+ DataType dataType() const { return myType; }
+
+ void setDataType(DataType theType) { myType = theType; }
+
+private:
+ DataType myType;
+};
+
+QWidget* DataTableItemDelegate::createEditor(QWidget* theParent,
+ const QStyleOptionViewItem & theOption,
+ const QModelIndex& theIndex ) const
+{
+ if ((theIndex.column() != 0) && (theIndex.row() != 0)) {
+ QLineEdit* aLineEdt = 0;
+ switch (myType) {
+ case DoubleType:
+ aLineEdt = dynamic_cast<QLineEdit*>(QStyledItemDelegate::createEditor(theParent,
+ theOption,
+ theIndex));
+ if (aLineEdt) {
+ aLineEdt->setValidator(new QDoubleValidator(aLineEdt));
+ return aLineEdt;
+ }
+ case IntegerType:
+ aLineEdt = dynamic_cast<QLineEdit*>(QStyledItemDelegate::createEditor(theParent,
+ theOption,
+ theIndex));
+ if (aLineEdt) {
+ aLineEdt->setValidator(new QIntValidator(aLineEdt));
+ return aLineEdt;
+ }
+ case BooleanType:
+ {
+ QComboBox* aBox = new QComboBox(theParent);
+ aBox->addItem("True");
+ aBox->addItem("False");
+ return aBox;
+ }
+ }
+ }
+ return QStyledItemDelegate::createEditor(theParent, theOption, theIndex);
+}
+
+
+void DataTableItemDelegate::setModelData(QWidget* theEditor, QAbstractItemModel* theModel,
+ const QModelIndex& theIndex) const
+{
+ QComboBox* aBox = dynamic_cast<QComboBox*>(theEditor);
+ if (aBox) {
+ theModel->setData(theIndex, aBox->currentText());
+ } else
+ QStyledItemDelegate::setModelData(theEditor, theModel, theIndex);
+}
+
+
CollectionPlugin_WidgetField::
- CollectionPlugin_WidgetField(QWidget* theParent, const Config_WidgetAPI* theData):
-ModuleBase_ModelWidget(theParent, theData)
+ CollectionPlugin_WidgetField(QWidget* theParent,
+ ModuleBase_IWorkshop* theWorkshop,
+ const Config_WidgetAPI* theData):
+ModuleBase_WidgetSelector(theParent, theWorkshop, theData)
{
QVBoxLayout* aMainLayout = new QVBoxLayout(this);
aSliderLayout->addWidget(myMaxLbl);
// Stamp value
- aStepLayout->addWidget(new QLabel(tr("Stamp"), aStepFrame), 2, 0);
- myStampSpn = new QSpinBox(aStepFrame);
- aStepLayout->addWidget(myStampSpn, 2, 1);
-
- // Data table
- myDataTbl = new QTableWidget(2, 2, aStepFrame);
- myDataTbl->verticalHeader()->hide();
- myDataTbl->horizontalHeader()->hide();
- myDataTbl->setRowHeight(0, 25);
- myDataTbl->setRowHeight(1, 25);
-
- QTableWidgetItem* aItem = new QTableWidgetItem("Shape");
- aItem->setBackgroundColor(Qt::lightGray);
- aItem->setFlags(Qt::NoItemFlags | Qt::ItemIsEnabled);
- myDataTbl->setItem(0, 0, aItem);
-
- aItem = new QTableWidgetItem("Comp 1");
- aItem->setBackgroundColor(Qt::lightGray);
- myDataTbl->setItem(0, 1, aItem);
-
- aItem = new QTableWidgetItem("Default value");
- aItem->setBackgroundColor(Qt::lightGray);
- aItem->setFlags(Qt::NoItemFlags | Qt::ItemIsEnabled);
- myDataTbl->setItem(1, 0, aItem);
-
- aItem = new QTableWidgetItem("0");
- aItem->setBackgroundColor(Qt::lightGray);
- myDataTbl->setItem(1, 1, aItem);
-
- aStepLayout->addWidget(myDataTbl, 3, 0, 1, 2);
+ myCompNamesList << "Comp 1";
+ myStepWgt = new QStackedWidget(aStepFrame);
+ aStepLayout->addWidget(myStepWgt, 2, 0, 1, 2);
+ appendStepControls();
// Buttons below
QWidget* aBtnWgt = new QWidget(this);
aBtnLayout->addStretch(1);
- QPushButton* aRemoveBtn = new QPushButton(tr("Remove step"), aBtnWgt);
- aBtnLayout->addWidget(aRemoveBtn);
+ myRemoveBtn = new QPushButton(tr("Remove step"), aBtnWgt);
+ aBtnLayout->addWidget(myRemoveBtn);
+ myRemoveBtn->setEnabled(false);
connect(myNbComponentsSpn, SIGNAL(valueChanged(int)), SLOT(onNbCompChanged(int)));
connect(aAddBtn, SIGNAL(clicked(bool)), SLOT(onAddStep()));
- connect(aRemoveBtn, SIGNAL(clicked(bool)), SLOT(onRemoveStep()));
+ connect(myRemoveBtn, SIGNAL(clicked(bool)), SLOT(onRemoveStep()));
connect(myStepSlider, SIGNAL(valueChanged(int)), SLOT(onStepMove(int)));
+ connect(myFieldTypeCombo, SIGNAL(currentIndexChanged(int)), SLOT(onFieldTypeChanged(int)));
+}
+
+void CollectionPlugin_WidgetField::appendStepControls()
+{
+ QWidget* aWidget = new QWidget(myStepWgt);
+ QGridLayout* aStepLayout = new QGridLayout(aWidget);
+ aStepLayout->setContentsMargins(0, 0, 0, 0);
+
+ aStepLayout->addWidget(new QLabel(tr("Stamp"), aWidget), 0, 0);
+
+ QSpinBox* aStampSpn = new QSpinBox(aWidget);
+ aStepLayout->addWidget(aStampSpn, 0, 1);
+
+ myStampSpnList.append(aStampSpn);
+
+ // Data table
+ QTableWidget* aDataTbl = new QTableWidget(2, myCompNamesList.count() + 1, aWidget);
+ aDataTbl->setItemDelegate(
+ new DataTableItemDelegate((DataTableItemDelegate::DataType) myFieldTypeCombo->currentIndex()));
+ aDataTbl->verticalHeader()->hide();
+ aDataTbl->horizontalHeader()->hide();
+ aDataTbl->setRowHeight(0, 25);
+ aDataTbl->setRowHeight(1, 25);
+
+ QTableWidgetItem* aItem = new QTableWidgetItem("Shape");
+ aItem->setBackgroundColor(Qt::lightGray);
+ aItem->setFlags(Qt::NoItemFlags | Qt::ItemIsEnabled);
+ aDataTbl->setItem(0, 0, aItem);
+
+ aItem = new QTableWidgetItem("Default value");
+ aItem->setBackgroundColor(Qt::lightGray);
+ aItem->setFlags(Qt::NoItemFlags | Qt::ItemIsEnabled);
+ aDataTbl->setItem(1, 0, aItem);
+
+ for (int i = 0; i < myCompNamesList.count(); i++) {
+ aItem = new QTableWidgetItem(myCompNamesList[i]);
+ aItem->setBackgroundColor(Qt::lightGray);
+ aDataTbl->setItem(0, i + 1, aItem);
+
+ aItem = new QTableWidgetItem("0");
+ aItem->setBackgroundColor(Qt::lightGray);
+ aDataTbl->setItem(1, i + 1, aItem);
+ }
+ aStepLayout->addWidget(aDataTbl, 1, 0, 1, 2);
+
+ QAbstractItemDelegate* aDel = aDataTbl->itemDelegate();
+ myDataTblList.append(aDataTbl);
+
+ myStepWgt->addWidget(aWidget);
+}
+
+void CollectionPlugin_WidgetField::removeStepControls()
+{
+ int aCurWgtId = myStepWgt->currentIndex();
+ myStepWgt->removeWidget(myStepWgt->currentWidget());
+
+ myStampSpnList.removeAt(aCurWgtId);
+ myDataTblList.removeAt(aCurWgtId);
}
+
QList<QWidget*> CollectionPlugin_WidgetField::getControls() const
{
QList<QWidget*> aControls;
// this control will accept focus and will be highlighted in the Property Panel
- //aControls.push_back(myComboBox);
+ //aControls.push_back(myShapeTypeCombo);
+ //aControls.push_back(myFieldTypeCombo);
+ //aControls.push_back(myNbComponentsSpn);
return aControls;
}
void CollectionPlugin_WidgetField::onNbCompChanged(int theVal)
{
- int aOldCol = myDataTbl->columnCount() - 1;
- int aNbRows = myDataTbl->rowCount();
- myDataTbl->setColumnCount(theVal + 1);
+ int aOldCol = myCompNamesList.count();
+ int aNbRows = myDataTblList.first()->rowCount();
int aDif = theVal - aOldCol;
QTableWidgetItem* aItem = 0;
- for (int i = 0; i < aDif; i++) {
- for (int j = 0; j < aNbRows; j++) {
- aItem = new QTableWidgetItem();
- if (j == 0)
- aItem->setText(QString("Comp %1").arg(i + aOldCol + 1));
- else
- aItem->setText("0");
- if (j < 3)
- aItem->setBackgroundColor(Qt::lightGray);
- myDataTbl->setItem(j, i + aOldCol + 1, aItem);
+
+ while (myCompNamesList.count() != theVal) {
+ if (aDif > 0)
+ myCompNamesList.append(QString("Comp %1").arg(myCompNamesList.count() + 1));
+ else
+ myCompNamesList.removeLast();
+ }
+
+ foreach(QTableWidget* aDataTbl, myDataTblList) {
+ aDataTbl->setColumnCount(theVal + 1);
+ for (int i = 0; i < myCompNamesList.count(); i++) {
+ for (int j = 0; j < aNbRows; j++) {
+ aItem = new QTableWidgetItem();
+ if (j == 0)
+ aItem->setText(myCompNamesList.at(i));
+ else
+ aItem->setText("0");
+ if (j < 3)
+ aItem->setBackgroundColor(Qt::lightGray);
+ aDataTbl->setItem(j, i + aOldCol + 1, aItem);
+ }
}
}
}
aMax++;
myStepSlider->setMaximum(aMax);
myMaxLbl->setText(QString::number(aMax));
- clearData();
+ appendStepControls();
myStepSlider->setValue(aMax);
+ myRemoveBtn->setEnabled(aMax > 1);
}
void CollectionPlugin_WidgetField::onRemoveStep()
{
int aMax = myStepSlider->maximum();
aMax--;
- myStepSlider->setMaximum(aMax);
myMaxLbl->setText(QString::number(aMax));
+ removeStepControls();
+ myStepSlider->setMaximum(aMax);
+ myRemoveBtn->setEnabled(aMax > 1);
}
void CollectionPlugin_WidgetField::clearData()
{
- int aNbRows = myDataTbl->rowCount();
- int aNbCol = myDataTbl->columnCount();
-
- QString aDefValue;
- for (int i = 1; i < aNbCol; i++) {
- aDefValue = myDataTbl->item(1, i)->text();
- for (int j = 2; j < aNbRows; j++) {
- myDataTbl->item(j, i)->setText(aDefValue);
+ int aNbRows = myDataTblList.first()->rowCount();
+ int aNbCol = myDataTblList.first()->columnCount();
+
+ foreach(QTableWidget* aDataTbl, myDataTblList) {
+ QString aDefValue;
+ for (int i = 1; i < aNbCol; i++) {
+ aDefValue = aDataTbl->item(1, i)->text();
+ for (int j = 2; j < aNbRows; j++) {
+ aDataTbl->item(j, i)->setText(aDefValue);
+ }
}
}
}
void CollectionPlugin_WidgetField::onStepMove(int theStep)
{
myCurStepLbl->setText(QString::number(theStep));
+ myStepWgt->setCurrentIndex(theStep - 1);
+}
+
+QIntList CollectionPlugin_WidgetField::shapeTypes() const
+{
+ QIntList aRes;
+ switch (myShapeTypeCombo->currentIndex()) {
+ case 0: //"Vertices"
+ aRes.append(ModuleBase_Tools::shapeType("vertex"));
+ break;
+ case 1: // "Edges"
+ aRes.append(ModuleBase_Tools::shapeType("edge"));
+ break;
+ case 2: // "Faces"
+ aRes.append(ModuleBase_Tools::shapeType("face"));
+ break;
+ case 3: // "Solids"
+ aRes.append(ModuleBase_Tools::shapeType("solid"));
+ break;
+ case 4: // "Results"
+ aRes.append(ModuleBase_Tools::shapeType("object"));
+ break;
+ case 5: // "Parts"
+ // TODO: Selection mode for Parts
+ break;
+ }
+ return aRes;
+}
+
+bool CollectionPlugin_WidgetField::
+ isValidSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePrs)
+{
+ return true;
+}
+
+void CollectionPlugin_WidgetField::onSelectionChanged()
+{
+ QList<ModuleBase_ViewerPrsPtr> aSelected =
+ myWorkshop->selection()->getSelected(ModuleBase_ISelection::AllControls);
+
+ clearData();
+
+ foreach(ModuleBase_ViewerPrsPtr aPrs, aSelected) {
+
+ }
+}
+
+void CollectionPlugin_WidgetField::onFieldTypeChanged(int theIdx)
+{
+ DataTableItemDelegate* aDelegate = 0;
+ foreach(QTableWidget* aTable, myDataTblList) {
+ aDelegate = dynamic_cast<DataTableItemDelegate*>(aTable->itemDelegate());
+ if (aDelegate)
+ aDelegate->setDataType((DataTableItemDelegate::DataType)theIdx);
+ }
}
#include "CollectionPlugin.h"
-#include <ModuleBase_ModelWidget.h>
+#include <ModuleBase_WidgetSelector.h>
+#include <ModuleBase_ViewerPrs.h>
+
+#include <QList>
+#include <QStringList>
+
class QWidget;
class QComboBox;
class QLabel;
class QSlider;
class QTableWidget;
+class QStackedWidget;
+class QPushButton;
/*!
* \ingroup GUI
* Represent a content of the property panel to show/modify parameters of a Field feature.
*/
-class CollectionPlugin_WidgetField : public ModuleBase_ModelWidget
+class CollectionPlugin_WidgetField : public ModuleBase_WidgetSelector
{
Q_OBJECT
public:
- CollectionPlugin_WidgetField(QWidget* theParent, const Config_WidgetAPI* theData);
+ CollectionPlugin_WidgetField(QWidget* theParent,
+ ModuleBase_IWorkshop* theWorkshop,
+ const Config_WidgetAPI* theData);
virtual ~CollectionPlugin_WidgetField() {}
/// \return a control list
virtual QList<QWidget*> getControls() const;
+ /// Checks the widget validity. By default, it returns true.
+ /// \param thePrs a selected presentation in the view
+ /// \return a boolean value
+ virtual bool isValidSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& theValue);
+
+
protected:
/// Saves the internal parameters to the given feature
/// \return True in success
/// Restore value from attribute data to the widget's control
virtual bool restoreValueCustom();
+ /// Retunrs a list of possible shape types
+ /// \return a list of shapes
+ virtual QIntList shapeTypes() const;
+
+
+protected slots:
+ /// Slot which is called on selection event
+ virtual void onSelectionChanged();
+
private slots:
void onNbCompChanged(int theVal);
void onStepMove(int theStep);
+ void onFieldTypeChanged(int theIdx);
+
private:
void clearData();
+ void appendStepControls();
+ void removeStepControls();
+
/// Types of shapes selection
QComboBox* myShapeTypeCombo;
QSlider* myStepSlider;
/// Stamp value
- QSpinBox* myStampSpn;
+ QList<QSpinBox*> myStampSpnList;
- QTableWidget* myDataTbl;
+ QList<QTableWidget*> myDataTblList;
QLabel* myMaxLbl;
+
+ QStackedWidget* myStepWgt;
+
+ QStringList myCompNamesList;
+
+ QList<ModuleBase_ViewerPrsPtr> mySelection;
+
+ QPushButton* myRemoveBtn;
};
#endif
\ No newline at end of file
--- /dev/null
+"""
+ TestBoolean.py
+ Unit test of FeaturesPlugin_Group class
+
+ class FeaturesPlugin_Group
+ static const std::string MY_GROUP_ID("Group");
+ static const std::string MY_GROUP_LIST_ID("group_list");
+
+ data()->addAttribute(FeaturesPlugin_Group::LIST_ID(), ModelAPI_AttributeSelectionList::typeId());
+"""
+#=========================================================================
+# Initialization of the test
+#=========================================================================
+from ModelAPI import *
+from GeomDataAPI import *
+from GeomAlgoAPI import *
+from GeomAPI import *
+
+__updated__ = "2014-12-16"
+
+aSession = ModelAPI_Session.get()
+# Create a part for extrusions & boolean
+aSession.startOperation()
+aPartFeature = aSession.moduleDocument().addFeature("Part")
+aSession.finishOperation()
+aPart = aSession.activeDocument()
+#=========================================================================
+# Create a sketch with triangle and extrude it
+#=========================================================================
+aSession.startOperation()
+aTriangleSketchFeature = featureToCompositeFeature(aPart.addFeature("Sketch"))
+origin = geomDataAPI_Point(aTriangleSketchFeature.attribute("Origin"))
+origin.setValue(0, 0, 0)
+dirx = geomDataAPI_Dir(aTriangleSketchFeature.attribute("DirX"))
+dirx.setValue(1, 0, 0)
+norm = geomDataAPI_Dir(aTriangleSketchFeature.attribute("Norm"))
+norm.setValue(0, 0, 1)
+aSketchLineA = aTriangleSketchFeature.addFeature("SketchLine")
+aSketchLineB = aTriangleSketchFeature.addFeature("SketchLine")
+aSketchLineC = aTriangleSketchFeature.addFeature("SketchLine")
+aLineAStartPoint = geomDataAPI_Point2D(aSketchLineA.attribute("StartPoint"))
+aLineAEndPoint = geomDataAPI_Point2D(aSketchLineA.attribute("EndPoint"))
+aLineBStartPoint = geomDataAPI_Point2D(aSketchLineB.attribute("StartPoint"))
+aLineBEndPoint = geomDataAPI_Point2D(aSketchLineB.attribute("EndPoint"))
+aLineCStartPoint = geomDataAPI_Point2D(aSketchLineC.attribute("StartPoint"))
+aLineCEndPoint = geomDataAPI_Point2D(aSketchLineC.attribute("EndPoint"))
+aLineAStartPoint.setValue(-100., 0.)
+aLineAEndPoint.setValue(100., 0.)
+aLineBStartPoint.setValue(100., 0.)
+aLineBEndPoint.setValue(0., 173.2)
+aLineCStartPoint.setValue(0., 173.2)
+aLineCEndPoint.setValue(-100., 0.)
+aSession.finishOperation()
+# Build sketch faces
+aSession.startOperation()
+aSketchResult = aTriangleSketchFeature.firstResult()
+aSketchEdges = modelAPI_ResultConstruction(aSketchResult).shape()
+origin = geomDataAPI_Point(aTriangleSketchFeature.attribute("Origin")).pnt()
+dirX = geomDataAPI_Dir(aTriangleSketchFeature.attribute("DirX")).dir()
+norm = geomDataAPI_Dir(aTriangleSketchFeature.attribute("Norm")).dir()
+aSketchFaces = ShapeList()
+GeomAlgoAPI_SketchBuilder.createFaces(origin, dirX, norm, aSketchEdges, aSketchFaces)
+# Create extrusion on them
+anExtrusionFt = aPart.addFeature("Extrusion")
+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.execute()
+aSession.finishOperation()
+anExtrusionBody = modelAPI_ResultBody(anExtrusionFt.firstResult())
+#=========================================================================
+# Create doubles field on vertices
+#=========================================================================
+aSession.startOperation()
+aField = aSession.activeDocument().addFeature("Field")
+aSelectionListAttr = aField.selectionList("selected")
+aSelectionListAttr.setSelectionType("vertex")
+aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/To_Face_1_1")
+aSelectionListAttr.append("Extrusion_1_1/Generated_Face_2&Extrusion_1_1/Generated_Face_1&Extrusion_1_1/To_Face_1_1")
+aSelectionListAttr.append("Extrusion_1_1/Generated_Face_3&Extrusion_1_1/Generated_Face_2&Extrusion_1_1/From_Face_1_1")
+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.setValue(0, 10)
+aTables = aField.tables("values")
+aTables.setType(2)
+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)
+aTables.setValue(27, 2, 0, 0)
+aTables.setValue(28, 3, 0, 0)
+aTables.setValue(0.5, 0, 1, 0)
+aTables.setValue(0.55, 1, 1, 0)
+aTables.setValue(0.39, 2, 1, 0)
+aTables.setValue(0.40, 3, 1, 0)
+aSession.finishOperation()
+#=========================================================================
+# Create strings field on faces
+#=========================================================================
+aSession.startOperation()
+aField = aSession.activeDocument().addFeature("Field")
+aSelectionListAttr = aField.selectionList("selected")
+aSelectionListAttr.setSelectionType("face")
+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.setValue(0, 1)
+aStamps.setValue(1, 3)
+aTables = aField.tables("values")
+aTables.setType(3)
+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)
+aTables.setValue("Face one", 1, 0, 0)
+aTables.setValue("Face two", 1, 0, 1)
+aSession.finishOperation()
+
+aFieldResult = aField.firstResult()
+assert(aFieldResult)
+#=========================================================================
+# Create integer field on faces
+#=========================================================================
+aSession.startOperation()
+aField = aSession.activeDocument().addFeature("Field")
+aSelectionListAttr = aField.selectionList("selected")
+aSelectionListAttr.setSelectionType("face")
+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.setValue(0, 0)
+aTables = aField.tables("values")
+aTables.setType(1)
+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)
+aSession.finishOperation()
+
+aFieldResult = aField.firstResult()
+assert(aFieldResult)
+
+#=========================================================================
+# Create Boolean field on faces
+#=========================================================================
+aSession.startOperation()
+aField = aSession.activeDocument().addFeature("Field")
+aSelectionListAttr = aField.selectionList("selected")
+aSelectionListAttr.setSelectionType("face")
+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.setValue(0, 0)
+aTables = aField.tables("values")
+aTables.setType(0)
+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)
+aSession.finishOperation()
+
+aFieldResult = aField.firstResult()
+assert(aFieldResult)
+
+import model
+assert(model.checkPythonDump())
std::string aPlacedName = "Placed";
std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theTransformAlgo.mapOfSubShapes();
- FeaturesPlugin_Tools::storeModifiedShapes(theTransformAlgo, theResultBody, theBaseShape, aPlacedTag, aPlacedName, *aSubShapes.get());
+ FeaturesPlugin_Tools::storeModifiedShapes(theTransformAlgo, theResultBody,
+ theBaseShape, aPlacedTag, aPlacedName,
+ *aSubShapes.get());
}
std::string aRotatedName = "Rotated";
std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theRotaionAlgo.mapOfSubShapes();
- FeaturesPlugin_Tools::storeModifiedShapes(theRotaionAlgo, theResultBody, theBaseShape, aRotatedTag, aRotatedName, *aSubShapes.get());
+ FeaturesPlugin_Tools::storeModifiedShapes(theRotaionAlgo, theResultBody,
+ theBaseShape, aRotatedTag, aRotatedName,
+ *aSubShapes.get());
}
std::string aTranslatedName = "Translated";
std::shared_ptr<GeomAPI_DataMapOfShapeShape> aSubShapes = theTranslationAlgo.mapOfSubShapes();
- FeaturesPlugin_Tools::storeModifiedShapes(theTranslationAlgo, theResultBody, theBaseShape, aTranslatedTag, aTranslatedName, *aSubShapes.get());
+ FeaturesPlugin_Tools::storeModifiedShapes(theTranslationAlgo, theResultBody,
+ theBaseShape, aTranslatedTag, aTranslatedName,
+ *aSubShapes.get());
}
static const std::string aPostFix("_");
TNaming_Iterator anItL(aNS);
for(int i = 1; anItL.More(); anItL.Next(), i++) {
- if(anItL.NewShape().IsSame(theShape)) { // in #1766 IsEqual produced no index of the face
+ // in #1766 IsEqual produced no index of the face
+ if(anItL.NewShape().IsSame(theShape)) {
aName += aPostFix;
aName += TCollection_AsciiString (i).ToCString();
break;
%shared_ptr(ModelAPI_ResultParameter)
%shared_ptr(ModelAPI_ResultCompSolid)
+%typecheck(SWIG_TYPECHECK_POINTER) const ModelAPI_AttributeTables::Value {
+ $1 = (PyFloat_Check($input) || PyInt_Check($input) || PyLong_Check($input) || PyString_Check($input) || PyBool_Check($input)) ? 1 : 0;
+}
+
+// Tables Value reading as int, double, boolean or string
+%typemap(in) const ModelAPI_AttributeTables::Value {
+ if (PyInt_Check($input)) {
+ $1.myInt = int(PyInt_AsLong($input));
+ $1.myDouble = double(PyInt_AsLong($input));
+ $1.myBool = PyInt_AsLong($input) != 0;
+ } else if (PyFloat_Check($input)) {
+ $1.myInt = int(PyFloat_AsDouble($input));
+ $1.myDouble = PyFloat_AsDouble($input);
+ } else if (PyBool_Check($input)) {
+ $1.myBool = $input == Py_True;
+ } else if (PyString_Check($input)) {
+ $1.myStr = PyString_AsString($input);
+ } else if ((SWIG_ConvertPtr($input, (void **)&$1, $1_descriptor, SWIG_POINTER_EXCEPTION)) == 0) {
+ } else {
+ PyErr_SetString(PyExc_ValueError, "Tables value must be int, double, string or bool.");
+ return NULL;
+ }
+}
+
// all supported interfaces
%include "ModelAPI_Entity.h"
%include "ModelAPI_Document.h"
{
return data()->integer(theID);
}
+ /// Returns the integer array attribute by the identifier
+ inline std::shared_ptr<ModelAPI_AttributeIntArray> intArray(const std::string& theID)
+ {
+ return data()->intArray(theID);
+ }
/// Returns the reference attribute by the identifier
inline std::shared_ptr<ModelAPI_AttributeRefAttr> refattr(const std::string& theID)
{
{
return data()->string(theID);
}
+ /// Returns the string array attribute by the identifier
+ inline std::shared_ptr<ModelAPI_AttributeStringArray> stringArray(const std::string& theID)
+ {
+ return data()->stringArray(theID);
+ }
+ /// Returns the tables attribute by the identifier
+ inline std::shared_ptr<ModelAPI_AttributeTables> tables(const std::string& theID)
+ {
+ return data()->tables(theID);
+ }
/// Returns the attribute by the identifier
inline std::shared_ptr<ModelAPI_Attribute> attribute(const std::string& theID)
{
ModelHighAPI_RefAttr.h
ModelHighAPI_Reference.h
ModelHighAPI_Selection.h
- ModelHighAPI_ComponentValue.h
ModelHighAPI_Services.h
ModelHighAPI_Tools.h
ModelHighAPI_FeatureStore.h
ModelHighAPI_RefAttr.cpp
ModelHighAPI_Reference.cpp
ModelHighAPI_Selection.cpp
- ModelHighAPI_ComponentValue.cpp
ModelHighAPI_Services.cpp
ModelHighAPI_Tools.cpp
ModelHighAPI_FeatureStore.cpp
%template(RefAttrList) std::list<ModelHighAPI_RefAttr>;
%template(RefList) std::list<ModelHighAPI_Reference>;
+
// fix compilarion error: ‘res*’ was not declared in this scope
%typemap(freearg) const std::list<ModelHighAPI_RefAttr> & {}
%typemap(freearg) const std::list<std::shared_ptr<ModelAPI_Object> > & {}
%include "ModelHighAPI_RefAttr.h"
%include "ModelHighAPI_Reference.h"
%include "ModelHighAPI_Selection.h"
-%include "ModelHighAPI_ComponentValue.h"
%include "ModelHighAPI_Services.h"
%include "ModelHighAPI_Macro.h"
%include "ModelHighAPI_Tools.h"
+++ /dev/null
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-// Name : ModelHighAPI_ComponentValue.cpp
-// Purpose:
-//
-// History:
-// 29/03/16 - Sergey POKHODENKO - Creation of the file
-
-//--------------------------------------------------------------------------------------
-#include "ModelHighAPI_ComponentValue.h"
-
-#include <ModelAPI_AttributeInteger.h>
-
-#include <sstream>
-
-//--------------------------------------------------------------------------------------
-ModelHighAPI_ComponentValue::ModelHighAPI_ComponentValue(const bool theValue)
- : myType(ModelAPI_AttributeTables::BOOLEAN)
-{
- // initialize everything since in python there may be problem with correct typification
- myValue.myBool = theValue;
- myValue.myInt = theValue ? 1 : 0;
- myValue.myDouble = theValue ? 1. : 0.;
- myValue.myStr = theValue ? "True" : "False";
-}
-//--------------------------------------------------------------------------------------
-ModelHighAPI_ComponentValue::ModelHighAPI_ComponentValue(const int theValue)
- : myType(ModelAPI_AttributeTables::INTEGER)
-{
- // initialize everything since in python there may be problem with correct typification
- myValue.myBool = theValue == 0 ? false : true;
- myValue.myInt = theValue;
- myValue.myDouble = theValue;
- std::ostringstream s;
- s << theValue;
- myValue.myStr = s.str();
-}
-//--------------------------------------------------------------------------------------
-ModelHighAPI_ComponentValue::ModelHighAPI_ComponentValue(const double theValue)
- : myType(ModelAPI_AttributeTables::DOUBLE)
-{
- // initialize everything since in python there may be problem with correct typification
- myValue.myBool = theValue == 0. ? false : true;
- myValue.myInt = int(theValue);
- myValue.myDouble = theValue;
- std::ostringstream s;
- s << theValue;
- myValue.myStr = s.str();
-}
-//--------------------------------------------------------------------------------------
-ModelHighAPI_ComponentValue::ModelHighAPI_ComponentValue(const std::string& theValue)
- : myType(ModelAPI_AttributeTables::STRING)
-{
- myValue.myBool = (theValue.empty() || theValue == "False" || theValue == "0") ? false : true;
-
- std::stringstream stream1(theValue);
- myValue.myInt = 0;
- stream1 >> myValue.myInt;
- std::stringstream stream2(theValue);
- myValue.myDouble = 0.;
- stream2 >> myValue.myDouble;
-
- myValue.myStr = theValue;
-}
-
-//--------------------------------------------------------------------------------------
-ModelHighAPI_ComponentValue::~ModelHighAPI_ComponentValue()
-{
-}
-
-//--------------------------------------------------------------------------------------
-void ModelHighAPI_ComponentValue::fill(const std::shared_ptr<ModelAPI_AttributeTables>& theAttr,
- const int theTable, const int theColumn, const int theRow) const
-{
- theAttr->setValue(myValue, theRow, theColumn, theTable);
-}
+++ /dev/null
-// Copyright (C) 2014-20xx CEA/DEN, EDF R&D
-// Name : ModelHighAPI_ComponentValue.h
-// Purpose:
-//
-// History:
-// 16/11/16 - Mikhail Ponikarov - Creation of the file
-
-#ifndef SRC_MODELHIGHAPI_ModelHighAPI_ComponentValue_H_
-#define SRC_MODELHIGHAPI_ModelHighAPI_ComponentValue_H_
-
-//--------------------------------------------------------------------------------------
-#include "ModelHighAPI.h"
-
-#include <ModelAPI_AttributeTables.h>
-
-//--------------------------------------------------------------------------------------
-/**\class ModelHighAPI_ComponentValue
- * \ingroup CPPHighAPI
- * \brief Class for filling ModelAPI_AttributeTable elements
- */
-class ModelHighAPI_ComponentValue
-{
-public:
- /// Constructor for Boolean
- MODELHIGHAPI_EXPORT ModelHighAPI_ComponentValue(const bool theValue = false);
- /// Constructor for int
- MODELHIGHAPI_EXPORT ModelHighAPI_ComponentValue(const int theValue);
- /// Constructor for double
- MODELHIGHAPI_EXPORT ModelHighAPI_ComponentValue(const double theValue);
- /// Constructor for std::string
- MODELHIGHAPI_EXPORT ModelHighAPI_ComponentValue(const std::string & theValue);
- /// Destructor
- MODELHIGHAPI_EXPORT virtual ~ModelHighAPI_ComponentValue();
-
- /// Sets value to the table
- MODELHIGHAPI_EXPORT virtual void fill(const std::shared_ptr<ModelAPI_AttributeTables>& theAttr,
- const int theTable, const int theColumn, const int theRow) const;
-
-private:
- ModelAPI_AttributeTables::ValueType myType; ///< type of the value set
- ModelAPI_AttributeTables::Value myValue; ///< value itself
-};
-
-//--------------------------------------------------------------------------------------
-//--------------------------------------------------------------------------------------
-#endif /* SRC_MODELHIGHAPI_ModelHighAPI_ComponentValue_H_ */
{
myDumpBuffer<<"[";
for(int anIndex = 0; anIndex < theArray->size(); ++anIndex) {
-
- myDumpBuffer<<"\""<<theArray->value(anIndex)<<"\"";
if (anIndex != 0)
myDumpBuffer<<", ";
+
+ myDumpBuffer<<"\""<<theArray->value(anIndex)<<"\"";
}
myDumpBuffer<<"]";
#include <ModelAPI_AttributeSelection.h>
#include <ModelAPI_AttributeSelectionList.h>
#include <ModelAPI_AttributeString.h>
+#include <ModelAPI_AttributeStringArray.h>
#include <ModelAPI_AttributeDoubleArray.h>
+#include <ModelAPI_AttributeTables.h>
#include <ModelAPI_Validator.h>
#include <GeomDataAPI_Dir.h>
std::dynamic_pointer_cast<ModelAPI_AttributeDoubleArray>(theAttr);
for(int a = 0; a < anAttr->size(); a++)
aResult<<anAttr->value(a)<<" ";
+ } else if (aType == ModelAPI_AttributeStringArray::typeId()) {
+ AttributeStringArrayPtr anAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeStringArray>(theAttr);
+ for(int a = 0; a < anAttr->size(); a++)
+ aResult<<"'"<<anAttr->value(a)<<"'"<<" ";
+ } else if (aType == ModelAPI_AttributeTables::typeId()) {
+ AttributeTablesPtr anAttr =
+ std::dynamic_pointer_cast<ModelAPI_AttributeTables>(theAttr);
+ aResult<<anAttr->tables()<<"x"<<anAttr->rows()<<"x"<<anAttr->columns()<<" ";
+ for(int aTab = 0; aTab < anAttr->tables(); aTab++) {
+ for(int aRow = 0; aRow < anAttr->rows(); aRow++) {
+ for( int aCol = 0; aCol < anAttr->columns(); aCol++) {
+ switch(anAttr->type()) {
+ case ModelAPI_AttributeTables::BOOLEAN:
+ aResult<<anAttr->value(aRow, aCol, aTab).myBool<<" ";
+ break;
+ case ModelAPI_AttributeTables::INTEGER:
+ aResult<<anAttr->value(aRow, aCol, aTab).myInt<<" ";
+ break;
+ case ModelAPI_AttributeTables::DOUBLE:
+ aResult<<anAttr->value(aRow, aCol, aTab).myDouble<<" ";
+ break;
+ case ModelAPI_AttributeTables::STRING:
+ aResult<<"'"<<anAttr->value(aRow, aCol, aTab).myStr.c_str()<<"' ";
+ break;
+ }
+ }
+ }
+ }
} else if (aType == GeomDataAPI_Point::typeId()) {
AttributePointPtr anAttr = std::dynamic_pointer_cast<GeomDataAPI_Point>(theAttr);
double aValues[3] = {anAttr->x(), anAttr->y(), anAttr->z()};
#include "ModelHighAPI_RefAttr.h"
#include "ModelHighAPI_Reference.h"
#include "ModelHighAPI_Selection.h"
- #include "ModelHighAPI_ComponentValue.h"
#include "ModelHighAPI_Services.h"
#include "ModelHighAPI_Tools.h"
"""Package for Collection plugin for the Parametric Geometry API of the Modeler.
"""
-from CollectionAPI import addGroup
+from CollectionAPI import addGroup, addField