#include <QGroupBox>
#include <QFrame>
#include <QVBoxLayout>
+#include <QHBoxLayout>
#include <QGridLayout>
#include <QLineEdit>
#include <QCheckBox>
#include <QApplication>
#include <QRadioButton>
+#include <QStandardItemModel>
+#include <QStandardItem>
+#include <QTreeWidget>
+#include <QTreeWidgetItem>
+#include <QModelIndexList>
+
#include <LightApp_SelectionMgr.h>
#include <SalomeApp_Application.h>
#include <SALOME_ListIO.hxx>
STD_TAB = 0,
ADV_TAB,
SMP_TAB,
+ ENF_TAB,
OPTION_ID_COLUMN = 0,
OPTION_NAME_COLUMN,
OPTION_VALUE_COLUMN,
SMP_REMOVE_BTN,
};
+// Enforced verteces inputs
+enum {
+ ENF_VER_BTNS = 0,
+ ENF_VER_X_COORD = 0,
+ ENF_VER_Y_COORD,
+ ENF_VER_Z_COORD,
+ ENF_VER_VERTEX_BTN,
+ ENF_VER_SEPARATOR,
+ ENF_VER_REMOVE_BTN,
+};
+
+// Enforced verteces array columns
+enum {
+// ENF_VER_ENTRY_COLUMN = 0,
+ ENF_VER_NAME_COLUMN = 0,
+ ENF_VER_ENTRY_COLUMN,
+ ENF_VER_X_COLUMN,
+ ENF_VER_Y_COLUMN,
+ ENF_VER_Z_COLUMN,
+ ENF_VER_NB_COLUMNS
+};
+
+
/**************************************************
Begin initialization Python structures and objects
***************************************************/
End initialization Python structures and objects
**************************************************/
+
+class QDoubleValidator;
+
+//
+// BEGIN DoubleLineEditDelegate
+//
+
+DoubleLineEditDelegate::DoubleLineEditDelegate(QObject *parent)
+ : QItemDelegate(parent)
+{
+}
+
+QWidget *DoubleLineEditDelegate::createEditor(QWidget *parent,
+ const QStyleOptionViewItem &/* option */,
+ const QModelIndex &/* index */) const
+{
+ QLineEdit *editor = new QLineEdit(parent);
+ editor->setValidator(new QDoubleValidator(parent));
+
+ return editor;
+}
+
+void DoubleLineEditDelegate::setEditorData(QWidget *editor,
+ const QModelIndex &index) const
+{
+ QString value = index.model()->data(index, Qt::EditRole).toString();
+
+ QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
+ lineEdit->setText(value);
+}
+
+void DoubleLineEditDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
+ const QModelIndex &index) const
+{
+ QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
+ bool ok;
+ double value = lineEdit->text().toDouble(&ok);
+
+ if (ok) {
+ model->setData(index, value, Qt::EditRole);
+ MESSAGE("Value " << value << " was set at index(" << index.row() << "," << index.column() << ")");
+ }
+}
+
+void DoubleLineEditDelegate::updateEditorGeometry(QWidget *editor,
+ const QStyleOptionViewItem &option, const QModelIndex &/* index */) const
+{
+ editor->setGeometry(option.rect);
+}
+
+//
+// END DoubleLineEditDelegate
+//
+
+
/**
* \brief {BLSURFPluginGUI_HypothesisCreator constructor}
* @param theHypType Name of the hypothesis type (here BLSURF_Parameters)
PyRun_SimpleString("from math import *");
PyGILState_Release(gstate);
-
+
}
BLSURFPluginGUI_HypothesisCreator::~BLSURFPluginGUI_HypothesisCreator()
h->SetOptionValues( myOptions ); // restore values
}
- // SizeMap
+ // SizeMap and attractors
if ( ok )
{
mySizeMapTable->setFocus();
}
}
+ // Enforced verteces
+ // TODO
+
return ok;
}
sizeMapHeaders << tr( "SMP_ENTRY_COLUMN" )<< tr( "SMP_NAME_COLUMN" ) << tr( "SMP_SIZEMAP_COLUMN" );
mySizeMapTable->setHorizontalHeaderLabels(sizeMapHeaders);
mySizeMapTable->horizontalHeader()->hideSection( SMP_ENTRY_COLUMN );
+// mySizeMapTable->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
mySizeMapTable->resizeColumnToContents(SMP_NAME_COLUMN);
mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
mySizeMapTable->setAlternatingRowColors(true);
removeButton = new QPushButton(tr("BLSURF_SM_REMOVE"),mySmpGroup);
anSmpLayout->addWidget(removeButton, SMP_REMOVE_BTN, 1, 1, 1);
+ // Enforced verteces parameters
+
+ myEnfGroup = new QWidget();
+ QGridLayout* anEnfLayout = new QGridLayout(myEnfGroup);
+
+ myEnforcedTreeWidget = new QTreeWidget(myEnfGroup);
+ myEnforcedTreeWidget->setColumnCount( ENF_VER_NB_COLUMNS );
+ myEnforcedTreeWidget->setSortingEnabled(true);
+ QStringList enforcedHeaders;
+ enforcedHeaders << tr("BLSURF_ENF_VER_NAME_COLUMN") << tr("BLSURF_ENF_VER_ENTRY_COLUMN") << tr( "BLSURF_ENF_VER_X_COLUMN" )<< tr( "BLSURF_ENF_VER_Y_COLUMN" ) << tr( "BLSURF_ENF_VER_Z_COLUMN" ) ;
+ myEnforcedTreeWidget->setHeaderLabels(enforcedHeaders);
+ myEnforcedTreeWidget->setAlternatingRowColors(true);
+ myEnforcedTreeWidget->setUniformRowHeights(true);
+ myEnforcedTreeWidget->setAnimated(true);
+ myEnforcedTreeWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
+ myEnforcedTreeWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
+ for (int column = 0; column < ENF_VER_NB_COLUMNS; ++column) {
+ myEnforcedTreeWidget->header()->setResizeMode(column,QHeaderView::Interactive);
+ myEnforcedTreeWidget->resizeColumnToContents(column);
+ }
+ myEnforcedTreeWidget->hideColumn(ENF_VER_ENTRY_COLUMN);
+ anEnfLayout->addWidget(myEnforcedTreeWidget, 0, 0, 8, 1);
+
+ QLabel* myXCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_X_LABEL" ), myEnfGroup );
+ anEnfLayout->addWidget(myXCoordLabel, ENF_VER_X_COORD, 1, 1, 1);
+ myXCoord = new QLineEdit(myEnfGroup);
+ myXCoord->setValidator(new QDoubleValidator(myEnfGroup));
+ anEnfLayout->addWidget(myXCoord, ENF_VER_X_COORD, 2, 1, 1);
+
+ QLabel* myYCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_Y_LABEL" ), myEnfGroup );
+ anEnfLayout->addWidget(myYCoordLabel, ENF_VER_Y_COORD, 1, 1, 1);
+ myYCoord = new QLineEdit(myEnfGroup);
+ myYCoord->setValidator(new QDoubleValidator(myEnfGroup));
+ anEnfLayout->addWidget(myYCoord, ENF_VER_Y_COORD, 2, 1, 1);
+
+ QLabel* myZCoordLabel = new QLabel( tr( "BLSURF_ENF_VER_Z_LABEL" ), myEnfGroup );
+ anEnfLayout->addWidget(myZCoordLabel, ENF_VER_Z_COORD, 1, 1, 1);
+ myZCoord = new QLineEdit(myEnfGroup);
+ myZCoord->setValidator(new QDoubleValidator(myEnfGroup));
+ anEnfLayout->addWidget(myZCoord, ENF_VER_Z_COORD, 2, 1, 1);
+
+ addVertexButton = new QPushButton(tr("BLSURF_ENF_VER_VERTEX"),myEnfGroup);
+ anEnfLayout->addWidget(addVertexButton, ENF_VER_VERTEX_BTN, 1, 1, 2);
+
+ QFrame *line = new QFrame(myEnfGroup);
+ line->setFrameShape(QFrame::HLine);
+ line->setFrameShadow(QFrame::Sunken);
+ anEnfLayout->addWidget(line, ENF_VER_SEPARATOR, 1, 1, 2);
+
+ removeVertexButton = new QPushButton(tr("BLSURF_ENF_VER_REMOVE"),myEnfGroup);
+ anEnfLayout->addWidget(removeVertexButton, ENF_VER_REMOVE_BTN, 1, 1, 2);
// ---
tab->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) );
tab->insertTab( ADV_TAB, myAdvGroup, tr( "BLSURF_ADV_ARGS" ) );
tab->insertTab( SMP_TAB, mySmpGroup, tr( "BLSURF_SIZE_MAP" ) );
+ tab->insertTab( ENF_TAB, myEnfGroup, tr( "BLSURF_ENF_VER" ) );
tab->setCurrentIndex( STD_TAB );
// ---
- connect( myGeometricMesh, SIGNAL( activated( int ) ), this, SLOT( onGeometricMeshChanged() ) );
- connect( myPhysicalMesh, SIGNAL( activated( int ) ), this, SLOT( onPhysicalMeshChanged() ) );
- connect( addBtn->menu(), SIGNAL( aboutToShow() ), this, SLOT( onAddOption() ) );
- connect( addBtn->menu(), SIGNAL( triggered( QAction* ) ), this, SLOT( onOptionChosenInPopup( QAction* ) ) );
- connect( rmBtn, SIGNAL( clicked()), this, SLOT( onDeleteOption() ) );
-
- connect(addSurfaceButton, SIGNAL(clicked()), this, SLOT(onAddMapOnSurface()));
- connect(addEdgeButton, SIGNAL(clicked()), this, SLOT(onAddMapOnEdge()));
- connect(addPointButton, SIGNAL(clicked()), this, SLOT(onAddMapOnPoint()));
- connect(removeButton, SIGNAL(clicked()), this, SLOT(onRemoveMap()));
- connect(mySizeMapTable, SIGNAL(cellChanged ( int, int )),this,SLOT (onSetSizeMap(int,int )));
+ connect( myGeometricMesh, SIGNAL( activated( int ) ), this, SLOT( onGeometricMeshChanged() ) );
+ connect( myPhysicalMesh, SIGNAL( activated( int ) ), this, SLOT( onPhysicalMeshChanged() ) );
+ connect( addBtn->menu(), SIGNAL( aboutToShow() ), this, SLOT( onAddOption() ) );
+ connect( addBtn->menu(), SIGNAL( triggered( QAction* ) ), this, SLOT( onOptionChosenInPopup( QAction* ) ) );
+ connect( rmBtn, SIGNAL( clicked()), this, SLOT( onDeleteOption() ) );
+
+ connect( addSurfaceButton, SIGNAL( clicked()), this, SLOT( onAddMapOnSurface() ) );
+ connect( addEdgeButton, SIGNAL( clicked()), this, SLOT( onAddMapOnEdge() ) );
+ connect( addPointButton, SIGNAL( clicked()), this, SLOT( onAddMapOnPoint() ) );
+ connect( removeButton, SIGNAL( clicked()), this, SLOT( onRemoveMap() ) );
+ connect( mySizeMapTable, SIGNAL( cellChanged ( int, int )), this, SLOT( onSetSizeMap(int,int ) ) );
+
+ connect( myEnforcedTreeWidget,SIGNAL( itemClicked(QTreeWidgetItem *, int)), this, SLOT( synchronize(QTreeWidgetItem *, int) ) );
+ connect( myEnforcedTreeWidget,SIGNAL( itemChanged(QTreeWidgetItem *, int)), this, SLOT( update(QTreeWidgetItem *, int) ) );
+ connect( myEnforcedTreeWidget,SIGNAL( activated(QModelIndex&)), this, SLOT( onEnforcedVertexActivated() ) );
+ connect( addVertexButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedVerteces() ) );
+ connect( removeVertexButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedVertex() ) );
return fr;
}
+/** BLSURFPluginGUI_HypothesisCreator::update(item, column)
+This method updates the tooltip of a modified item. The QLineEdit widgets content
+is synchronized with the coordinates of the enforced vertex clicked in the tree widget.
+*/
+void BLSURFPluginGUI_HypothesisCreator::update(QTreeWidgetItem* item, int column) {
+// MESSAGE("BLSURFPluginGUI_HypothesisCreator::updateVertexList");
+ QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
+ if (not x.isNull()) {
+ QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole);
+ QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole);
+ QVariant vertexName = item->data(ENF_VER_NAME_COLUMN, Qt::EditRole);
+
+ QTreeWidgetItem* parent = item->parent();
+ if (parent) {
+ QString shapeName = parent->data(ENF_VER_NAME_COLUMN, Qt::EditRole).toString();
+ QString toolTip = shapeName + QString(": ") + vertexName.toString();
+ toolTip += QString("(") + x.toString();
+ toolTip += QString(", ") + y.toString();
+ toolTip += QString(", ") + z.toString();
+ toolTip += QString(")");
+ item->setToolTip(ENF_VER_NAME_COLUMN,toolTip);
+ }
+
+ myXCoord->setText(x.toString());
+ myYCoord->setText(y.toString());
+ myZCoord->setText(z.toString());
+ }
+}
+
+/** BLSURFPluginGUI_HypothesisCreator::synchronize(item, column)
+This method synchronizes the QLineEdit widgets content with the coordinates
+of the enforced vertex clicked in the tree widget.
+*/
+void BLSURFPluginGUI_HypothesisCreator::synchronize(QTreeWidgetItem* item, int column) {
+// MESSAGE("BLSURFPluginGUI_HypothesisCreator::synchronizeCoords");
+ QVariant x = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
+ if (not x.isNull()) {
+ QVariant y = item->data(ENF_VER_Y_COLUMN, Qt::EditRole);
+ QVariant z = item->data(ENF_VER_Z_COLUMN, Qt::EditRole);
+ myXCoord->setText(x.toString());
+ myYCoord->setText(y.toString());
+ myZCoord->setText(z.toString());
+ }
+}
+
+/** BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(entry, shapeName, x, y, z)
+This method adds an enforced vertex (x,y,z) to shapeName in the tree widget.
+*/
+void BLSURFPluginGUI_HypothesisCreator::addEnforcedVertex(std::string entry, std::string shapeName, double x, double y, double z) {
+ // Find entry item
+ QList<QTreeWidgetItem* > theItemList = myEnforcedTreeWidget->findItems(QString(entry.c_str()),Qt::MatchExactly,ENF_VER_ENTRY_COLUMN);
+ QTreeWidgetItem* theItem;
+ if (theItemList.empty()) {
+ theItem = new QTreeWidgetItem();
+ theItem->setData(ENF_VER_ENTRY_COLUMN, Qt::EditRole, QVariant(entry.c_str()));
+ theItem->setData(ENF_VER_NAME_COLUMN, Qt::EditRole, QVariant(shapeName.c_str()));
+ theItem->setToolTip(ENF_VER_NAME_COLUMN,QString(entry.c_str()));
+ myEnforcedTreeWidget->addTopLevelItem(theItem);
+ }
+ else {
+ theItem = theItemList[0];
+ }
+
+ MESSAGE("theItemName is " << theItem->text(ENF_VER_NAME_COLUMN).toStdString());
+ bool okToCreate = true;
+
+ const int nbVert = theItem->childCount();
+ MESSAGE("Number of child rows: " << nbVert);
+ if (nbVert >0) {
+ double childValueX,childValueY,childValueZ;
+ QTreeWidgetItem* child;
+ for (int row = 0;row<nbVert;row++) {
+ child = theItem->child(row);
+ childValueX = child->data(ENF_VER_X_COLUMN,Qt::EditRole).toDouble();
+ childValueY = child->data(ENF_VER_Y_COLUMN,Qt::EditRole).toDouble();
+ childValueZ = child->data(ENF_VER_Z_COLUMN,Qt::EditRole).toDouble();
+ if ((childValueX == x) and (childValueY == y) and (childValueZ == z)) {
+ okToCreate = false;
+ break;
+ }
+ }
+ }
+ if (okToCreate) {
+ MESSAGE("In " << shapeName << " vertex with coords " << x << ", " << y << ", " << z<< " is created");
+
+ QTreeWidgetItem *vertexItem = new QTreeWidgetItem( theItem);
+ vertexItem->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
+ int vertexIndex=1;
+ QString vertexName;
+ int indexRef = 0;
+ while(indexRef != vertexIndex) {
+ indexRef = vertexIndex;
+ vertexName = QString("Vertex #%1").arg(vertexIndex);
+ for (int row = 0;row<nbVert;row++) {
+ QString name = theItem->child(row)->data(ENF_VER_NAME_COLUMN,Qt::EditRole).toString();
+ if (vertexName == name) {
+ vertexIndex++;
+ break;
+ }
+ }
+ }
+ vertexItem->setData( ENF_VER_NAME_COLUMN, Qt::EditRole, vertexName );
+ vertexItem->setData( ENF_VER_X_COLUMN, Qt::EditRole, QVariant(x) );
+ vertexItem->setData( ENF_VER_Y_COLUMN, Qt::EditRole, QVariant(y) );
+ vertexItem->setData( ENF_VER_Z_COLUMN, Qt::EditRole, QVariant(z) );
+ QString toolTip = QString(shapeName.c_str())+QString(": ")+vertexName;
+ toolTip += QString(" (%1, ").arg(x);
+ toolTip += QString("%1, ").arg(y);
+ toolTip += QString("%1)").arg(z);
+ vertexItem->setToolTip(ENF_VER_NAME_COLUMN,toolTip);
+ theItem->setExpanded(true);
+ myEnforcedTreeWidget->setCurrentItem(vertexItem,ENF_VER_NAME_COLUMN);
+ }
+ else
+ MESSAGE("In " << shapeName << " vertex with coords " << x << ", " << y << ", " << z<< " already exist: dont create again");
+}
+
+/** BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVerteces()
+This method is called when a item is added into the enforced verteces tree widget
+*/
+void BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVerteces() {
+ MESSAGE("BLSURFPluginGUI_HypothesisCreator::onAddEnforcedVerteces");
+
+ for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
+ myEnforcedTreeWidget->resizeColumnToContents(column);
+
+ BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
+
+ if ((myXCoord->text().isEmpty()) or (myYCoord->text().isEmpty()) or (myZCoord->text().isEmpty())) return;
+
+ double x = myXCoord->text().toDouble();
+ double y = myYCoord->text().toDouble();
+ double z = myZCoord->text().toDouble();
+
+ TopAbs_ShapeEnum shapeType;
+ string entry, shapeName;
+ GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool();
+ LightApp_SelectionMgr* mySel = myGeomToolSelected->selectionMgr();
+ SALOME_ListIO ListSelectedObjects;
+ mySel->selectedObjects(ListSelectedObjects, NULL, false );
+ if (!ListSelectedObjects.IsEmpty()) {
+ SALOME_ListIteratorOfListIO Object_It(ListSelectedObjects);
+ for (; Object_It.More(); Object_It.Next()) {
+ Handle(SALOME_InteractiveObject) anObject = Object_It.Value();
+ entry = myGeomToolSelected->getEntryOfObject(anObject);
+ shapeName = anObject->getName();
+ shapeType = myGeomToolSelected->entryToShapeType(entry);
+// MESSAGE("Object Name = " << shapeName << "& Type is " << anObject->getComponentDataType() << " & ShapeType is " << shapeType);
+ if (shapeType == TopAbs_FACE) {
+ addEnforcedVertex(entry, shapeName, x, y, z);
+ }
+ }
+ }
+ for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
+ myEnforcedTreeWidget->resizeColumnToContents(column);
+
+ if ( myPhysicalMesh->currentIndex() != SizeMap ) {
+ myPhysicalMesh->setCurrentIndex( SizeMap );
+ onPhysicalMeshChanged();
+ }
+}
+
+/** BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
+This method is called when a item is removed from the enforced verteces tree widget
+*/
+void BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex() {
+ MESSAGE("BLSURFPluginGUI_HypothesisCreator::onRemoveEnforcedVertex");
+ QList<QTreeWidgetItem *> selectedItems = myEnforcedTreeWidget->selectedItems();
+ QList<QTreeWidgetItem *> selectedVerteces;
+ QSet<QTreeWidgetItem *> selectedEntries;
+ QTreeWidgetItem* item;
+
+ foreach( item, selectedItems ) {
+ QVariant value = item->data(ENF_VER_X_COLUMN, Qt::EditRole);
+ if (not value.isNull())
+ selectedVerteces.append(item);
+
+ else
+ selectedEntries.insert(item);
+ }
+
+ foreach(item,selectedVerteces) {
+ QTreeWidgetItem* parent = item->parent();
+ MESSAGE("From geometry "<< parent->text(ENF_VER_NAME_COLUMN).toStdString()<<" remove " << item->text(ENF_VER_NAME_COLUMN).toStdString());
+ parent->removeChild(item);
+ delete item;
+ if (parent->childCount() == 0) {
+ if (selectedEntries.contains(parent))
+ selectedEntries.remove(parent);
+ delete parent;
+ }
+ }
+
+ foreach(item,selectedEntries) {
+ MESSAGE("Remove " << item->text(ENF_VER_NAME_COLUMN).toStdString());
+ delete item;
+ }
+
+ myEnforcedTreeWidget->selectionModel()->clearSelection();
+}
+
+/** BLSURFPluginGUI_HypothesisCreator::retrieveParams()
+This method updates the GUI widgets with the hypothesis data
+*/
void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const
{
MESSAGE("BLSURFPluginGUI_HypothesisCreator::retrieveParams");
myVerbosity->setValue( data.myVerbosity );
if ( myOptions.operator->() ) {
- printf("retrieveParams():myOptions->length()=%d\n",myOptions->length());
+ MESSAGE("retrieveParams():myOptions->length() = " << myOptions->length());
for ( int i = 0, nb = myOptions->length(); i < nb; ++i ) {
QString option = that->myOptions[i].in();
QStringList name_value = option.split( ":", QString::KeepEmptyParts );
if ( name_value.count() > 1 ) {
QString idStr = QString("%1").arg( i );
int row = myOptionTable->rowCount();
- myOptionTable->setRowCount( row+1 );
- myOptionTable->setItem( row, OPTION_ID_COLUMN, new QTableWidgetItem( idStr ) );
- myOptionTable->item( row, OPTION_ID_COLUMN )->setFlags( 0 );
- myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( name_value[0] ) );
- myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 );
- myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( name_value[1] ) );
- myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable |
- Qt::ItemIsEditable |
- Qt::ItemIsEnabled );
+ myOptionTable->setRowCount( row+1 );
+ myOptionTable->setItem( row, OPTION_ID_COLUMN, new QTableWidgetItem( idStr ) );
+ myOptionTable->item( row, OPTION_ID_COLUMN )->setFlags( 0 );
+ myOptionTable->setItem( row, OPTION_NAME_COLUMN, new QTableWidgetItem( name_value[0] ) );
+ myOptionTable->item( row, OPTION_NAME_COLUMN )->setFlags( 0 );
+ myOptionTable->setItem( row, OPTION_VALUE_COLUMN, new QTableWidgetItem( name_value[1] ) );
+ myOptionTable->item( row, OPTION_VALUE_COLUMN )->setFlags( Qt::ItemIsSelectable |
+ Qt::ItemIsEditable |
+ Qt::ItemIsEnabled );
}
}
}
myOptionTable->resizeColumnToContents( OPTION_NAME_COLUMN );
- printf("retrieveParams():that->mySMPMap.size()=%d\n",that->mySMPMap.size());
+ // Sizemaps
+ MESSAGE("retrieveParams():that->mySMPMap.size() = " << that->mySMPMap.size());
QMapIterator<QString, QString> i(that->mySMPMap);
GeomSelectionTools* myGeomToolSelected = that->getGeomSelectionTool();
while (i.hasNext()) {
mySizeMapTable->resizeColumnToContents( SMP_NAME_COLUMN );
mySizeMapTable->resizeColumnToContents(SMP_SIZEMAP_COLUMN);
+ // Enforced verteces
+ MESSAGE("retrieveParams(): data.enfVertMap.size() = " << data.enfVertMap.size());
+ std::map<std::string, std::set<std::vector<double> > >::const_iterator evmIt = data.enfVertMap.begin();
+ for ( ; evmIt != data.enfVertMap.end() ; ++evmIt) {
+ std::string entry = (*evmIt).first;
+ std::string shapeName = myGeomToolSelected->getNameFromEntry(entry);
+ MESSAGE("retrieveParams(): entry " << entry << ", shape: " << shapeName);
+
+ std::set<std::vector<double> > evs;
+ std::set<std::vector<double> >::const_iterator evsIt;
+ try {
+ MESSAGE("evs = (*evmIt)[entry];");
+ evs = (*evmIt).second;
+ }
+ catch(...) {
+ MESSAGE("Fail");
+ break;
+ }
+
+ MESSAGE("retrieveParams(): evs.size() = " << evs.size());
+
+ evsIt = evs.begin();
+ for ( ; evsIt != evs.end() ; ++evsIt) {
+ double x, y, z;
+ x = (*evsIt)[0];
+ y = (*evsIt)[1];
+ z = (*evsIt)[2];
+ that->addEnforcedVertex(entry, shapeName, x, y, z);
+ }
+ }
+ for (int column = 0; column < myEnforcedTreeWidget->columnCount(); ++column)
+ myEnforcedTreeWidget->resizeColumnToContents(column);
+
// update widgets
that->onPhysicalMeshChanged();
that->onGeometricMeshChanged();
}
+/** BLSURFPluginGUI_HypothesisCreator::storeParams()
+This method updates the hypothesis data with the GUI widgets content.
+*/
QString BLSURFPluginGUI_HypothesisCreator::storeParams() const
{
BLSURFPluginGUI_HypothesisCreator* that = (BLSURFPluginGUI_HypothesisCreator*)this;
return guiHyp;
}
+/** BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo(h_data)
+Updates the hypothesis data from hypothesis values.
+*/
bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData& h_data ) const
{
MESSAGE("BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo");
MESSAGE("mySMPShapeTypeMap[" << myAttractorList[0].toStdString() << "] = " << that->mySMPShapeTypeMap[myAttractorList[0]]);
}
}
-
+
+ // Enforced verteces
+ BLSURFPlugin::TEnforcedVertexMap_var enforcedVertexMap = h->GetAllEnforcedVerteces();
+ MESSAGE("enforcedVertexMap->length() = " << enforcedVertexMap->length());
+
+ for ( int i = 0;i<enforcedVertexMap->length(); ++i ) {
+ std::string entry = enforcedVertexMap[i].entry.in();
+// BLSURFPlugin::TEnforcedVertexList_var vertexList = enforcedVertexMap[i].vertexList;
+ BLSURFPlugin::TEnforcedVertexList vertexList = enforcedVertexMap[i].vertexList;
+ std:set<std::vector<double> > evs;
+ for (int j=0 ; j<vertexList.length(); ++j) {
+ double x = vertexList[j][0];
+ double y = vertexList[j][1];
+ double z = vertexList[j][2];
+ std::vector<double> ev;
+ ev.push_back(x);
+ ev.push_back(y);
+ ev.push_back(z);
+ evs.insert(ev);
+ MESSAGE("New enf vertex for entry " << entry << ": " << x << ", " << y << ", " << z);
+ }
+ h_data.enfVertMap[entry] = evs;
+ if (evs.size() == 0) {
+ MESSAGE("No enf vertex for entry " << entry << ": key is erased");
+ h_data.enfVertMap.erase(entry);
+ }
+ }
+
return true;
}
+/** BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo(h_data)
+Saves the hypothesis data to hypothesis values.
+*/
bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesisData& h_data ) const
{
MESSAGE("BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo");
h->SetSizeMapEntry( entry.toLatin1().constData(), fullSizeMap.toLatin1().constData() );
}
}
+
+ // Enforced verteces
+ std::map<std::string, std::set<std::vector<double> > >::const_iterator evmIt = h_data.enfVertMap.begin();
+ for ( ; evmIt != h_data.enfVertMap.end() ; ++evmIt) {
+ std::string entry = evmIt->first;
+ std::set<std::vector<double> > evs;
+ std::set<std::vector<double> >::const_iterator evsIt;
+ double x, y, z;
+ BLSURFPlugin::TEnforcedVertexList_var hypVertexList;
+ int hypNbVertex = 0;
+ try {
+ hypVertexList = h->GetEnforcedVertecesEntry(entry.c_str());
+ hypNbVertex = hypVertexList->length();
+ }
+ catch(...) {
+ }
+ evs = evmIt->second;
+ evsIt = evs.begin();
+ for ( ; evsIt != evs.end() ; ++evsIt) {
+ x = (*evsIt)[0];
+ y = (*evsIt)[1];
+ z = (*evsIt)[2];
+ MESSAGE("SetEnforcedVertexEntry("<<entry<<", "<<x<<", "<<y<<", "<<z<<")");
+ h->SetEnforcedVertexEntry( entry.c_str(), x, y, z );
+ }
+ // Remove old verteces
+ if (hypNbVertex >0) {
+ for (int i =0 ; i<hypNbVertex ; i++) {
+ x = hypVertexList[i][0];
+ y = hypVertexList[i][1];
+ z = hypVertexList[i][2];
+ std::vector<double> vertex;
+ vertex.push_back(x);
+ vertex.push_back(y);
+ vertex.push_back(z);
+ if (evs.find(vertex) == evs.end()) {
+ MESSAGE("UnsetEnforcedVertexEntry("<<entry<<", "<<x<<", "<<y<<", "<<z<<")");
+ h->UnsetEnforcedVertexEntry( entry.c_str(), x, y, z );
+ }
+ }
+ }
+ }
}
catch(const SALOME::SALOME_Exception& ex)
{
return ok;
}
+/** BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets(h_data)
+Stores the widgets content to the hypothesis data.
+*/
QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothesisData& h_data ) const
{
MESSAGE("BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets");
{
QString entry = mySizeMapTable->item( row, SMP_ENTRY_COLUMN )->text();
if ( that->mySMPMap.contains(entry) )
- guiHyp += entry + " = " + that->mySMPMap[entry] + "; ";
+ guiHyp += "SetSizeMapEntry(" + entry + ", " + that->mySMPMap[entry] + "); ";
}
- MESSAGE("guiHyp : " << guiHyp.toLatin1().data());
+ // Enforced verteces
+ // h_data.enfVertMap
+
+ int nbEnforcedShapes = myEnforcedTreeWidget->topLevelItemCount();
+ int nbEnforcedVerteces = 0;
+ MESSAGE("Nb of enforced shapes: " << nbEnforcedShapes);
+ for (int i=0 ; i<nbEnforcedShapes ; i++) {
+ QTreeWidgetItem* shapeItem = myEnforcedTreeWidget->topLevelItem(i);
+ if (shapeItem) {
+ std::string entry = shapeItem->data(ENF_VER_ENTRY_COLUMN,Qt::EditRole).toString().toStdString();
+ nbEnforcedVerteces = shapeItem->childCount();
+ if (nbEnforcedVerteces >0) {
+ double childValueX,childValueY,childValueZ;
+ QTreeWidgetItem* child;
+ std::set<std::vector<double> > evs;
+ for (row = 0;row<nbEnforcedVerteces;row++) {
+ child = shapeItem->child(row);
+ childValueX = child->data(ENF_VER_X_COLUMN,Qt::EditRole).toDouble();
+ childValueY = child->data(ENF_VER_Y_COLUMN,Qt::EditRole).toDouble();
+ childValueZ = child->data(ENF_VER_Z_COLUMN,Qt::EditRole).toDouble();
+ std::vector<double> vertex;
+ vertex.push_back(childValueX);
+ vertex.push_back(childValueY);
+ vertex.push_back(childValueZ);
+ evs.insert(vertex);
+ }
+ h_data.enfVertMap[entry] = evs;
+ }
+ }
+ }
+ MESSAGE("guiHyp : " << guiHyp.toLatin1().data());
return guiHyp;
}
SUIT_MessageBox::warning( dlg(),"Definition of size map : Error" , "Size map can't be empty");
return false;
}
-
- if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_FACE)
- expr = "def f(u,v) : return " + that->mySMPMap[myEntry].toStdString();
- else if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_EDGE)
- expr = "def f(t) : return " + that->mySMPMap[myEntry].toStdString();
- else if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_VERTEX)
- expr = "def f() : return " + that->mySMPMap[myEntry].toStdString();
+ else {
+ if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_FACE)
+ expr = "def f(u,v) : return " + that->mySMPMap[myEntry].toStdString();
+ else if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_EDGE)
+ expr = "def f(t) : return " + that->mySMPMap[myEntry].toStdString();
+ else if ( that->mySMPShapeTypeMap[myEntry] == TopAbs_VERTEX)
+ expr = "def f() : return " + that->mySMPMap[myEntry].toStdString();
+ }
}
//assert(Py_IsInitialized());
if (not Py_IsInitialized())