Salome HOME
Enforced verteces (continue):
authornge <nge>
Tue, 6 Oct 2009 15:13:22 +0000 (15:13 +0000)
committernge <nge>
Tue, 6 Oct 2009 15:13:22 +0000 (15:13 +0000)
- add GUI
- debug engine

TODO: hdf save process

idl/BLSURFPlugin_Algorithm.idl
src/BLSURFPlugin/BLSURFPlugin_BLSURF.cxx
src/BLSURFPlugin/BLSURFPlugin_Hypothesis_i.cxx
src/GUI/BLSURFPluginGUI_HypothesisCreator.cxx
src/GUI/BLSURFPluginGUI_HypothesisCreator.h
src/GUI/BLSURFPlugin_msg_en.ts

index 4e06ed18f65df624f8ca002f71b576ff812ad8af..c4e6bba76e80fc109e235eee32e969b700ccb7b6 100644 (file)
@@ -230,17 +230,17 @@ module BLSURFPlugin
 //     void         UnsetEnforcedVertexList(in GEOM::GEOM_Object GeomObj, in TEnforcedVertexList vertexList) raises (SALOME::SALOME_Exception);
     void         UnsetEnforcedVerteces(in GEOM::GEOM_Object GeomObj) raises (SALOME::SALOME_Exception);
     
-//    /*!
-//     * Set/get/unset an enforced vertex on geom object given by entry
-//     */
-//     void         SetEnforcedVertexEntry(in string entry, in double x, in double y, in double z) raises (SALOME::SALOME_Exception);
+   /*!
+    * Set/get/unset an enforced vertex on geom object given by entry
+    */
+    void         SetEnforcedVertexEntry(in string entry, in double x, in double y, in double z) raises (SALOME::SALOME_Exception);
 //     void         SetEnforcedVertexListEntry(in string entry, in TEnforcedVertexList vertexList) raises (SALOME::SALOME_Exception);
 //     
-//     TEnforcedVertexList GetEnforcedVertexListEntry(in string entry) raises (SALOME::SALOME_Exception);
+    TEnforcedVertexList GetEnforcedVertecesEntry(in string entry) raises (SALOME::SALOME_Exception);
 //     
-//     void         UnsetEnforcedVertexEntry(in string entry, in double x, in double y, in double z) raises (SALOME::SALOME_Exception);
+    void         UnsetEnforcedVertexEntry(in string entry, in double x, in double y, in double z) raises (SALOME::SALOME_Exception);
 //     void         UnsetEnforcedVertexListEntry(in string entry, in TEnforcedVertexList vertexList) raises (SALOME::SALOME_Exception);
-//     void         UnsetEnforcedVertecesEntry(in string entry) raises (SALOME::SALOME_Exception);
+    void         UnsetEnforcedVertecesEntry(in string entry) raises (SALOME::SALOME_Exception);
     
     ///////////////////////
 
index ae1122a4766c78208d326149177820879fcb21aa..6c7b214f2fa31ca407b74756da39d13e47ca5bce 100644 (file)
@@ -412,7 +412,6 @@ void createEnforcedVertexOnFace(TopoDS_Shape GeomShape, BLSURFPlugin_Hypothesis:
   double xe, ye, ze;
   std::vector<double> coords;
   BLSURFPlugin_Hypothesis::TEnforcedVertex enforcedVertex;
-  // enforcedVertexList = set < vector<double> >
   BLSURFPlugin_Hypothesis::TEnforcedVertexList::const_iterator evlIt = enforcedVertexList.begin();
 
   for( ; evlIt != enforcedVertexList.end() ; ++evlIt ) {
@@ -445,18 +444,33 @@ void createEnforcedVertexOnFace(TopoDS_Shape GeomShape, BLSURFPlugin_Hypothesis:
     else {
       key = FacesWithEnforcedVerteces.FindIndex(TopoDS::Face(GeomShape));
     }
-    
+
+    // If a node is already created by an attractor, do not create enforced vertex
+    int attractorKey = FacesWithSizeMap.FindIndex(TopoDS::Face(GeomShape));
+    bool sameAttractor = false;
+    if (attractorKey >= 0)
+      if (FaceId2AttractorCoords.count(attractorKey) > 0)
+        if (FaceId2AttractorCoords[attractorKey] == coords)
+          sameAttractor = true;
+
     if (FaceId2EnforcedVertexCoords.find(key) != FaceId2EnforcedVertexCoords.end()) {
       MESSAGE("Map of enf. vertex has key " << key)
       MESSAGE("Enf. vertex list size is: " << FaceId2EnforcedVertexCoords[key].size())
-      FaceId2EnforcedVertexCoords[key].insert(coords);
+      if (not sameAttractor)
+        FaceId2EnforcedVertexCoords[key].insert(coords); // there should be no redondant coords here (see std::set management)
+      else
+        MESSAGE("An attractor node is already defined: I don't add the enforced vertex");
       MESSAGE("New Enf. vertex list size is: " << FaceId2EnforcedVertexCoords[key].size())
     }
     else {
       MESSAGE("Map of enf. vertex has not key " << key << ": creating it")
-      std::set< std::vector<double> > ens;
-      ens.insert(coords);
-      FaceId2EnforcedVertexCoords[key] = ens;
+      if (not sameAttractor) {
+        std::set< std::vector<double> > ens;
+        ens.insert(coords);
+        FaceId2EnforcedVertexCoords[key] = ens;
+      }
+      else
+        MESSAGE("An attractor node is already defined: I don't add the enforced vertex");
     }
   }
 }
@@ -469,6 +483,7 @@ void createAttractorOnFace(TopoDS_Shape GeomShape, std::string AttractorFunction
   double a, b;       // Attractor parameter
   bool createNode=false; // To create a node on attractor projection
   int pos1, pos2;
+  const char *sep = ";";
   // atIt->second has the following pattern:
   // ATTRACTOR(xa;ya;za;a;b)
   // where:
@@ -478,29 +493,29 @@ void createAttractorOnFace(TopoDS_Shape GeomShape, std::string AttractorFunction
   //
   // We search the parameters in the string
   // xa
-  pos1 = AttractorFunction.find(";");
+  pos1 = AttractorFunction.find(sep);
   if (pos1!=string::npos)
   xa = atof(AttractorFunction.substr(10, pos1-10).c_str());
   // ya
-  pos2 = AttractorFunction.find(";", pos1+1);
+  pos2 = AttractorFunction.find(sep, pos1+1);
   if (pos2!=string::npos) {
   ya = atof(AttractorFunction.substr(pos1+1, pos2-pos1-1).c_str());
   pos1 = pos2;
     }
   // za
-  pos2 = AttractorFunction.find(";", pos1+1);
+  pos2 = AttractorFunction.find(sep, pos1+1);
   if (pos2!=string::npos) {
   za = atof(AttractorFunction.substr(pos1+1, pos2-pos1-1).c_str());
   pos1 = pos2;
   }
   // a
-  pos2 = AttractorFunction.find(";", pos1+1);
+  pos2 = AttractorFunction.find(sep, pos1+1);
   if (pos2!=string::npos) {
   a = atof(AttractorFunction.substr(pos1+1, pos2-pos1-1).c_str());
   pos1 = pos2;
   }
   // b
-  pos2 = AttractorFunction.find(";", pos1+1);
+  pos2 = AttractorFunction.find(sep, pos1+1);
   if (pos2!=string::npos) {
   b = atof(AttractorFunction.substr(pos1+1, pos2-pos1-1).c_str());
     pos1 = pos2;
index 9541fad2ce685527af6d3243a340ffa28d466120..9b8d01fd3ed8fd46e1f035f7b5067a2690795ee2 100644 (file)
@@ -787,29 +787,36 @@ BLSURFPlugin::string_array* BLSURFPlugin_Hypothesis_i::GetCustomSizeMapEntries()
 
 BLSURFPlugin::TEnforcedVertexMap* BLSURFPlugin_Hypothesis_i::GetAllEnforcedVerteces()
 {
+  MESSAGE("IDL: GetAllEnforcedVerteces()");
   ASSERT(myBaseImpl);
   BLSURFPlugin::TEnforcedVertexMap_var resultMap = new BLSURFPlugin::TEnforcedVertexMap();
   const ::BLSURFPlugin_Hypothesis::TEnforcedVertexMap enforcedVertexMap = this->GetImpl()->_GetAllEnforcedVerteces();
   resultMap->length(enforcedVertexMap.size());
+  MESSAGE("Enforced Vertex map size is " << enforcedVertexMap.size());
 
   ::BLSURFPlugin_Hypothesis::TEnforcedVertexList enforcedVertexList;
   ::BLSURFPlugin_Hypothesis::TEnforcedVertexMap::const_iterator evmIt = enforcedVertexMap.begin();
   for ( int i = 0 ; evmIt != enforcedVertexMap.end(); ++evmIt, ++i ) {
     string entry = evmIt->first;
+    MESSAGE("Entry: " << entry);
     enforcedVertexList = evmIt->second;
 
     BLSURFPlugin::TEnforcedVertexMapElement_var mapElement = new BLSURFPlugin::TEnforcedVertexMapElement();
 
     BLSURFPlugin::TEnforcedVertexList_var vertexList = new BLSURFPlugin::TEnforcedVertexList();
     vertexList->length(enforcedVertexList.size());
+    MESSAGE("Number of enforced verteces: " << enforcedVertexList.size());
 
     ::BLSURFPlugin_Hypothesis::TEnforcedVertexList::const_iterator evlIt = enforcedVertexList.begin();
     for ( int j = 0 ; evlIt != enforcedVertexList.end(); ++evlIt, ++j ) {
+      MESSAGE("Enforced Vertex #" << j);
       BLSURFPlugin::TEnforcedVertex_var enforcedVertex = new BLSURFPlugin::TEnforcedVertex();
+      enforcedVertex->length(3);
       enforcedVertex[0] = (*evlIt)[0];
       enforcedVertex[1] = (*evlIt)[1];
       enforcedVertex[2] = (*evlIt)[2];
       vertexList[j] = enforcedVertex;
+      MESSAGE("Enforced vertex: " << enforcedVertex[0] << ", " << enforcedVertex[1] << ", " << enforcedVertex[2]);
     }
 
     mapElement->entry = CORBA::string_dup(entry.c_str());
index 1daca3f9029f6ad6c56e59bb41a0f960bfd564f5..7fc5eeb9bfe13382391e53a6917cf1e526eecded 100644 (file)
@@ -40,6 +40,7 @@
 #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>
@@ -89,6 +96,7 @@ enum {
   STD_TAB = 0,
   ADV_TAB,
   SMP_TAB,
+  ENF_TAB,
   OPTION_ID_COLUMN = 0,
   OPTION_NAME_COLUMN,
   OPTION_VALUE_COLUMN,
@@ -110,6 +118,29 @@ enum {
   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
 ***************************************************/
@@ -216,6 +247,61 @@ PyObject * newPyStdOut( std::string& out )
 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)
@@ -246,7 +332,7 @@ BLSURFPluginGUI_HypothesisCreator::BLSURFPluginGUI_HypothesisCreator( const QStr
 
   PyRun_SimpleString("from math import *");
   PyGILState_Release(gstate);
-
+  
 }
 
 BLSURFPluginGUI_HypothesisCreator::~BLSURFPluginGUI_HypothesisCreator()
@@ -340,7 +426,7 @@ bool BLSURFPluginGUI_HypothesisCreator::checkParams() const
     h->SetOptionValues( myOptions ); // restore values
   }
 
-  // SizeMap
+  // SizeMap and attractors
   if ( ok )
   {
     mySizeMapTable->setFocus();
@@ -377,6 +463,9 @@ bool BLSURFPluginGUI_HypothesisCreator::checkParams() const
     }
   }
 
+  // Enforced verteces
+  // TODO
+  
   return ok;
 }
 
@@ -525,6 +614,7 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
   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);
@@ -556,30 +646,292 @@ QFrame* BLSURFPluginGUI_HypothesisCreator::buildFrame()
   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");
@@ -611,28 +963,29 @@ void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const
   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()) {
@@ -655,11 +1008,47 @@ void BLSURFPluginGUI_HypothesisCreator::retrieveParams() const
   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;
@@ -671,6 +1060,9 @@ QString BLSURFPluginGUI_HypothesisCreator::storeParams() const
   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");
@@ -766,10 +1158,40 @@ bool BLSURFPluginGUI_HypothesisCreator::readParamsFromHypo( BlsurfHypothesisData
       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");
@@ -863,6 +1285,48 @@ bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesi
         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)
   {
@@ -872,6 +1336,9 @@ bool BLSURFPluginGUI_HypothesisCreator::storeParamsToHypo( const BlsurfHypothesi
   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");
@@ -932,11 +1399,41 @@ QString BLSURFPluginGUI_HypothesisCreator::readParamsFromWidgets( BlsurfHypothes
   {
       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;
 }
 
@@ -1299,13 +1796,14 @@ bool BLSURFPluginGUI_HypothesisCreator::sizeMapValidationFromEntry(QString myEnt
         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())
index db48e08e2fab018cff1f14197d3c02b8240680c1..5a9877bbe872e7f6fd19461541f5afccf4e50c70 100644 (file)
 #endif
 
 #include <Python.h>
+
+#include <QItemDelegate>
+
 #include <SMESHGUI_Hypotheses.h>
 #include <SALOMEconfig.h>
 #include <cstring>
 #include <map>
+#include <set>
+#include <vector>
 #include <TopAbs_ShapeEnum.hxx>
 #include <GeomSelectionTools.h>
 #include CORBA_SERVER_HEADER(BLSURFPlugin_Algorithm)
 
 class QGroupBox;
-class QtxDoubleSpinBox;
 class QComboBox;
 class QCheckBox;
 class QLineEdit;
 class QTableWidget;
-class QTableView;
+class QTreeWidget;
 class QModelIndex;
 class QSpinBox;
 class QMenu;
 class QAction;
+class QTreeWidgetItem;
+
+class SalomeApp_DoubleSpinBox;
 class LightApp_SelectionMgr;
 
 typedef struct
@@ -64,7 +71,8 @@ typedef struct
   int     myPhysicalMesh, myGeometricMesh;
   double  myAngleMeshS, myAngleMeshC, myGradation;
   QString myPhySize, myGeoMin, myGeoMax, myPhyMin,myPhyMax;
-  bool    myAllowQuadrangles, myDecimesh,mySmpsurface,mySmpedge,mySmppoint;
+  bool    myAllowQuadrangles, myDecimesh,mySmpsurface,mySmpedge,mySmppoint,myEnforcedVertex;
+  std::map<std::string, std::set<std::vector<double> > > enfVertMap;
   QString myName;
 } BlsurfHypothesisData;
 
@@ -100,12 +108,19 @@ protected slots:
   void                onAddOption();
   void                onDeleteOption();
   void                onOptionChosenInPopup( QAction* );
+//  void                onAddAttractor();
   void                onAddMapOnSurface();
   void                onAddMapOnEdge();
   void                onAddMapOnPoint();
   void                onRemoveMap();
   void                onSetSizeMap(int,int);
 
+  void                addEnforcedVertex(std::string, std::string, double, double, double);
+  void                onAddEnforcedVerteces();
+  void                onRemoveEnforcedVertex();
+  void                synchronize(QTreeWidgetItem* , int );
+  void                update(QTreeWidgetItem* , int );
+
 private:
   bool                readParamsFromHypo( BlsurfHypothesisData& ) const;
   QString             readParamsFromWidgets( BlsurfHypothesisData& ) const;
@@ -123,11 +138,11 @@ private:
   QLineEdit*          myPhyMin;
   QLineEdit*          myPhyMax;
   QComboBox*          myGeometricMesh;
-  QtxDoubleSpinBox*   myAngleMeshS;
-  QtxDoubleSpinBox*   myAngleMeshC;
+  SalomeApp_DoubleSpinBox*   myAngleMeshS;
+  SalomeApp_DoubleSpinBox*   myAngleMeshC;
   QLineEdit*          myGeoMin;
   QLineEdit*          myGeoMax;
-  QtxDoubleSpinBox*   myGradation;
+  SalomeApp_DoubleSpinBox*   myGradation;
   QCheckBox*          myAllowQuadrangles;
   QCheckBox*          myDecimesh;
 
@@ -136,7 +151,7 @@ private:
   QSpinBox*           myVerbosity;
   QTableWidget*       myOptionTable;
 
-  QWidget             *mySmpGroup;  
+  QWidget             *mySmpGroup;
   QTableWidget        *mySizeMapTable;
   QPushButton         *addAttractorButton;
   QPushButton         *addSurfaceButton;
@@ -144,6 +159,14 @@ private:
   QPushButton         *addPointButton;
   QPushButton         *removeButton;
 
+  QWidget*            myEnfGroup;
+  QTreeWidget*        myEnforcedTreeWidget;
+  QLineEdit*          myXCoord;
+  QLineEdit*          myYCoord;
+  QLineEdit*          myZCoord;
+  QPushButton*        addVertexButton;
+  QPushButton*        removeVertexButton;
+
   // map =  entry , size map
   QMap<QString, QString>          mySMPMap;
   QMap<QString, TopAbs_ShapeEnum> mySMPShapeTypeMap;
@@ -156,4 +179,23 @@ private:
   PyObject *          main_dict;
 };
 
+
+class DoubleLineEditDelegate : public QItemDelegate
+{
+    Q_OBJECT
+
+public:
+  DoubleLineEditDelegate(QObject *parent = 0);
+
+  QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
+                        const QModelIndex &index) const;
+
+  void setEditorData(QWidget *editor, const QModelIndex &index) const;
+  void setModelData(QWidget *editor, QAbstractItemModel *model,
+                    const QModelIndex &index) const;
+
+  void updateEditorGeometry(QWidget *editor,
+  const QStyleOptionViewItem &option, const QModelIndex &index) const;
+};
+
 #endif // BLSURFPLUGINGUI_HypothesisCreator_H
index 5fb60b85c16258312ac0fd0b04549deaff96a35a..1da2a840c65814feff6cacd913e11e5f2dc8ad69 100644 (file)
             <source>BLSURF_PHY_MESH</source>
             <translation>Physical Mesh</translation>
         </message>
+        <message>
+            <source>BLSURF_ADV_ARGS</source>
+            <translation>Advanced</translation>
+        </message>
+        <message>
+            <source>BLSURF_TITLE</source>
+            <translation>Hypothesis Construction</translation>
+        </message>
+        <message>
+            <source>BLSURF_TOPOLOGY</source>
+            <translation>Topology</translation>
+        </message>
+        <message>
+            <source>BLSURF_TOPOLOGY_CAD</source>
+            <translation>From CAD</translation>
+        </message>
+        <message>
+            <source>BLSURF_TOPOLOGY_PROCESS</source>
+            <translation>Pre-process</translation>
+        </message>
+        <message>
+            <source>BLSURF_TOPOLOGY_PROCESS2</source>
+            <translation>Pre-process++</translation>
+        </message>
+        <message>
+            <source>BLSURF_VERBOSITY</source>
+            <translation>Verbosity level</translation>
+        </message>
+        <message>
+            <source>OBLIGATORY_VALUE</source>
+            <translation>(Obligatory value)</translation>
+        </message>
+        <message>
+            <source>OPTION_NAME_COLUMN</source>
+            <translation>Option</translation>
+        </message>
+        <message>
+            <source>OPTION_VALUE_COLUMN</source>
+            <translation>Value</translation>
+        </message>
+        <message>
+            <source>REMOVE_OPTION</source>
+            <translation>Clear option</translation>
+        </message>
         <message>
             <source>BLSURF_SIZE_MAP</source>
             <translation>Size Map</translation>
             <translation>Size on Point(s)</translation>
         </message>
         <message>
-            <source>BLSURF_ADV_ARGS</source>
-            <translation>Advanced</translation>
+            <source>BLSURF_ENF_VER</source>
+            <translation>Enforced verteces</translation>
         </message>
         <message>
-            <source>BLSURF_TITLE</source>
-            <translation>Hypothesis Construction</translation>
+            <source>BLSURF_ENF_VER_ENTRY_COLUMN</source>
+            <translation>Entry</translation>
         </message>
         <message>
-            <source>BLSURF_TOPOLOGY</source>
-            <translation>Topology</translation>
+            <source>BLSURF_ENF_VER_NAME_COLUMN</source>
+            <translation>Name</translation>
         </message>
         <message>
-            <source>BLSURF_TOPOLOGY_CAD</source>
-            <translation>From CAD</translation>
+            <source>BLSURF_ENF_VER_X_COLUMN</source>
+            <translation>X</translation>
         </message>
         <message>
-            <source>BLSURF_TOPOLOGY_PROCESS</source>
-            <translation>Pre-process</translation>
+            <source>BLSURF_ENF_VER_Y_COLUMN</source>
+            <translation>Y</translation>
         </message>
         <message>
-            <source>BLSURF_TOPOLOGY_PROCESS2</source>
-            <translation>Pre-process++</translation>
+            <source>BLSURF_ENF_VER_Z_COLUMN</source>
+            <translation>Z</translation>
         </message>
         <message>
-            <source>BLSURF_VERBOSITY</source>
-            <translation>Verbosity level</translation>
+            <source>BLSURF_ENF_VER_X_LABEL</source>
+            <translation>X:</translation>
         </message>
         <message>
-            <source>OBLIGATORY_VALUE</source>
-            <translation>(Obligatory value)</translation>
+            <source>BLSURF_ENF_VER_Y_LABEL</source>
+            <translation>Y:</translation>
         </message>
         <message>
-            <source>OPTION_NAME_COLUMN</source>
-            <translation>Option</translation>
+            <source>BLSURF_ENF_VER_Z_LABEL</source>
+            <translation>Z:</translation>
         </message>
         <message>
-            <source>OPTION_VALUE_COLUMN</source>
-            <translation>Value</translation>
+            <source>BLSURF_ENF_VER_VERTEX</source>
+            <translation>Add enforced vertex</translation>
         </message>
         <message>
-            <source>REMOVE_OPTION</source>
-            <translation>Clear option</translation>
+            <source>BLSURF_ENF_VER_REMOVE</source>
+            <translation>Remove vertex</translation>
         </message>
     </context>
 </TS>