#include "SMESH_TypeDefs.hxx"
#include "SMESHDS_GroupBase.hxx"
+// SALOME KERNEL includes
+#include "SALOMEDSClient.hxx"
+#include <SALOMEDSClient_definitions.hxx>
+// // IDL headers
+// #include <SALOMEconfig.h>
+// #include CORBA_SERVER_HEADER(SALOMEDS)
+
#ifndef GHS3D_VERSION
#define GHS3D_VERSION 41
#endif
throw (SALOME::SALOME_Exception) {
ASSERT(myBaseImpl);
MESSAGE("IDL : SetEnforcedVertex( "<< x << ", " << y << ", " << z << ", " << size << ")");
- return _SetEnforcedVertex(size, x, y, z);
+ return p_SetEnforcedVertex(size, x, y, z);
+}
+
+bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexNamed(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName)
+ throw (SALOME::SALOME_Exception) {
+ ASSERT(myBaseImpl);
+ MESSAGE("IDL : SetEnforcedVertexNamed( "<< x << ", " << y << ", " << z << ", " << size << ", " << theVertexName << ")");
+ return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", "");
}
bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theGroupName)
throw (SALOME::SALOME_Exception) {
ASSERT(myBaseImpl);
MESSAGE("IDL : SetEnforcedVertexWithGroup( "<< x << ", " << y << ", " << z << ", " << size << ", " << theGroupName << ")");
- return _SetEnforcedVertex(size, x, y, z, "", "", theGroupName);
+ return p_SetEnforcedVertex(size, x, y, z, "", "", theGroupName);
+}
+
+bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexNamedWithGroup(CORBA::Double x, CORBA::Double y, CORBA::Double z, CORBA::Double size, const char* theVertexName, const char* theGroupName)
+ throw (SALOME::SALOME_Exception) {
+ ASSERT(myBaseImpl);
+ MESSAGE("IDL : SetEnforcedVertexNamedWithGroup( "<< x << ", " << y << ", " << z << ", " << size << ", " << theVertexName << ", " << theGroupName << ")");
+ return p_SetEnforcedVertex(size, x, y, z, theVertexName, "", theGroupName);
}
bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeom(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size)
}
string theVertexEntry = theVertex->GetStudyEntry();
+ CORBA::Double x = 0, y = 0, z = 0;
+ CORBA::Boolean isCompound = false;
+ GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
+ SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
if (theVertexEntry.empty()) {
- GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
- SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
string aName;
- if (theVertex->GetShapeType() == GEOM::VERTEX)
+ if (theVertex->GetShapeType() == GEOM::VERTEX) {
aName = "Vertex_";
- if (theVertex->GetShapeType() == GEOM::COMPOUND)
+ }
+ if (theVertex->GetShapeType() == GEOM::COMPOUND) {
aName = "Compound_";
+ isCompound = true;
+ }
aName += theVertex->GetEntry();
SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
if (!theSVertex->_is_nil())
if (theVertexEntry.empty())
THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
+ if (theVertex->GetShapeType() == GEOM::VERTEX) {
+ GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations( smeshGen->GetCurrentStudy()->StudyId() );
+ if (CORBA::is_nil(measureOp))
+ return false;
+
+ measureOp->PointCoordinates (theVertex, x, y, z);
+ MESSAGE("Point coordinates from measureOp: " << x << ", " << y << ", " << z);
+ }
+
string theVertexName = theVertex->GetName();
MESSAGE("IDL : SetEnforcedVertexGeom( "<< theVertexEntry << ", " << size<< ")");
- return _SetEnforcedVertex(size, 0, 0, 0, theVertexName.c_str(), theVertexEntry.c_str());
+ return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), "", isCompound);
}
bool GHS3DPlugin_Hypothesis_i::SetEnforcedVertexGeomWithGroup(GEOM::GEOM_Object_ptr theVertex, CORBA::Double size, const char* theGroupName)
}
string theVertexEntry = theVertex->GetStudyEntry();
+ CORBA::Double x = 0, y = 0, z = 0;
+ CORBA::Boolean isCompound = false;
+ GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
+ SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
if (theVertexEntry.empty()) {
- GEOM::GEOM_Gen_ptr geomGen = SMESH_Gen_i::GetGeomEngine();
- SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
string aName;
- if (theVertex->GetShapeType() == GEOM::VERTEX)
+ if (theVertex->GetShapeType() == GEOM::VERTEX) {
aName = "Vertex_";
- if (theVertex->GetShapeType() == GEOM::COMPOUND)
+ }
+ if (theVertex->GetShapeType() == GEOM::COMPOUND) {
aName = "Compound_";
+ isCompound = true;
+ }
aName += theVertex->GetEntry();
SALOMEDS::SObject_ptr theSVertex = geomGen->PublishInStudy(smeshGen->GetCurrentStudy(), NULL, theVertex, aName.c_str());
if (!theSVertex->_is_nil())
if (theVertexEntry.empty())
THROW_SALOME_CORBA_EXCEPTION( "Geom object is not published in study" ,SALOME::BAD_PARAM );
+ if (theVertex->GetShapeType() == GEOM::VERTEX) {
+ GEOM::GEOM_IMeasureOperations_var measureOp = geomGen->GetIMeasureOperations( smeshGen->GetCurrentStudy()->StudyId() );
+ if (CORBA::is_nil(measureOp))
+ return false;
+
+ measureOp->PointCoordinates (theVertex, x, y, z);
+ MESSAGE("Point coordinates from measureOp: " << x << ", " << y << ", " << z);
+ }
+
string theVertexName = theVertex->GetName();
MESSAGE("IDL : SetEnforcedVertexGeomWithGroup( "<< theVertexEntry << ", " << size<< ", " << theGroupName << ")");
- return _SetEnforcedVertex(size, 0, 0, 0, theVertexName.c_str(), theVertexEntry.c_str(), theGroupName);
+ return p_SetEnforcedVertex(size, x, y, z, theVertexName.c_str(), theVertexEntry.c_str(), theGroupName, isCompound);
}
-bool GHS3DPlugin_Hypothesis_i:: _SetEnforcedVertex(CORBA::Double size, CORBA::Double x, CORBA::Double y, CORBA::Double z,
- const char* theVertexName, const char* theVertexEntry, const char* theGroupName)
+bool GHS3DPlugin_Hypothesis_i:: p_SetEnforcedVertex(CORBA::Double size, CORBA::Double x, CORBA::Double y, CORBA::Double z,
+ const char* theVertexName, const char* theVertexEntry, const char* theGroupName,
+ CORBA::Boolean isCompound)
throw (SALOME::SALOME_Exception) {
ASSERT(myBaseImpl);
- MESSAGE("IDL : _SetEnforcedVertex(" << size << ", " << x << ", " << y << ", " << z << ", \"" << theVertexName << "\", \"" << theVertexEntry << "\", \"" << theGroupName << "\")");
+ MESSAGE("IDL : p_SetEnforcedVertex(" << size << ", " << x << ", " << y << ", " << z << ", \"" << theVertexName << "\", \"" << theVertexEntry << "\", \"" << theGroupName << "\", " << isCompound<< ")");
bool newValue = false;
+ ::GHS3DPlugin_Hypothesis::TCoordsGHS3DEnforcedVertexMap coordsList;
+ ::GHS3DPlugin_Hypothesis::TGeomEntryGHS3DEnforcedVertexMap enfVertexEntryList;
if (string(theVertexEntry).empty()) {
- ::GHS3DPlugin_Hypothesis::TCoordsGHS3DEnforcedVertexMap coordsList = this->GetImpl()->_GetEnforcedVerticesByCoords();
+ coordsList = this->GetImpl()->_GetEnforcedVerticesByCoords();
std::vector<double> coords;
coords.push_back(x);
coords.push_back(y);
if (coordsList.find(coords) == coordsList.end()) {
MESSAGE("Coords not found: add it in coordsList");
newValue = true;
- } else {
+ }
+ else {
MESSAGE("Coords already found, compare names");
::GHS3DPlugin_Hypothesis::TGHS3DEnforcedVertex *enfVertex = this->GetImpl()->GetEnforcedVertex(x, y, z);
if ((enfVertex->name != theVertexName) || (enfVertex->groupName != theGroupName) || (enfVertex->size != size)) {
SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertex(" << x << ", " << y << ", " << z << ", " << size << ")";
else
SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theGroupName << "\")";
-// else
-// if (string(theGroupName).empty())
-// SMESH::TPythonDump() << _this() << ".SetEnforcedVertexNamed(" << theFaceEntry << ", " << x << ", " << y << ", " << z << ", \"" << theVertexName << "\")";
-// else
-// SMESH::TPythonDump() << _this() << ".SetEnforcedVertexNamedWithGroup(" << theFaceEntry << ", " << x << ", " << y << ", " << z << ", \""
-// << theVertexName << "\", \"" << theGroupName << "\")";
+ }
+ else {
+ if (string(theGroupName).empty())
+ SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamed(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theVertexName << "\")";
+ else
+ SMESH::TPythonDump() << "isDone = " << _this() << ".SetEnforcedVertexNamedWithGroup(" << x << ", " << y << ", " << z << ", " << size << ", \"" << theVertexName << "\", \"" << theGroupName << "\")";
}
}
- } else {
- ::GHS3DPlugin_Hypothesis::TGeomEntryGHS3DEnforcedVertexMap enfVertexEntryList = this->GetImpl()->_GetEnforcedVerticesByEntry();
+ }
+ else {
+// if (isCompound || (!isCompound && !string(theVertexEntry).empty())) {
+ enfVertexEntryList = this->GetImpl()->_GetEnforcedVerticesByEntry();
// ::BLSURFPlugin_Hypothesis::TGeomEntryGHS3DEnforcedVertexMap::const_iterator it = enfVertexEntryList.find(theVertexEntry);
if ( enfVertexEntryList.find(theVertexEntry) == enfVertexEntryList.end()) {
MESSAGE("Geom entry not found: add it in enfVertexEntryList");
}
if (newValue)
- this->GetImpl()->SetEnforcedVertex(theVertexName, theVertexEntry, theGroupName, size, x, y, z);
+ this->GetImpl()->SetEnforcedVertex(theVertexName, theVertexEntry, theGroupName, size, x, y, z, isCompound);
MESSAGE("IDL : SetEnforcedVertexEntry END");
return newValue;
enfVertex->groupName = CORBA::string_dup(currentVertex->groupName.c_str());
// Size
enfVertex->size = currentVertex->size;
+ // isCompound
+ enfVertex->isCompound = currentVertex->isCompound;
result[i]=enfVertex;
}
- SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
+// SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
return result._retn();
}
SMESH::TPythonDump () << _this() << ".ClearEnforcedMeshes() ";
}
+//=======================================================================
+//function : GetEnforcedMeshes
+//=======================================================================
+
+GHS3DPlugin::GHS3DEnforcedMeshList* GHS3DPlugin_Hypothesis_i::GetEnforcedMeshes()
+{
+ ASSERT(myBaseImpl);
+ GHS3DPlugin::GHS3DEnforcedMeshList_var result = new GHS3DPlugin::GHS3DEnforcedMeshList();
+
+ const ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMeshList enfMeshList = this->GetImpl()->_GetEnforcedMeshes();
+ result->length( enfMeshList.size() );
+
+ ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMeshList::const_iterator it = enfMeshList.begin();
+
+ for (int i = 0 ; it != enfMeshList.end(); ++it, ++i ) {
+ ::GHS3DPlugin_Hypothesis::TGHS3DEnforcedMesh* currentMesh = (*it);
+ GHS3DPlugin::GHS3DEnforcedMesh_var enfMesh = new GHS3DPlugin::GHS3DEnforcedMesh();
+ // Name
+ enfMesh->name = CORBA::string_dup(currentMesh->name.c_str());
+ // Mesh Entry
+ enfMesh->entry = CORBA::string_dup(currentMesh->entry.c_str());
+ // isCompound
+ enfMesh->elementType = currentMesh->elementType;
+ // Group Name
+ enfMesh->groupName = CORBA::string_dup(currentMesh->groupName.c_str());
+ // Size
+ enfMesh->size = currentMesh->size;
+
+ result[i]=enfMesh;
+ }
+
+// SMESH::TPythonDump() << "allEnforcedVertices = " << _this() << ".GetEnforcedVertices()";
+
+ return result._retn();
+}
+
/*!
* \brief Adds enforced elements of type elementType using another mesh/sub-mesh/mesh group theSource. The elements will be grouped in theGroupName.
*/
throw (SALOME::SALOME_Exception)
{
#if GHS3D_VERSION >= 42
- bool res = _SetEnforcedMesh(theSource, theType, -1.0, theGroupName);
- SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
- SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
- SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast<SMESH_GroupOnGeom_i*>( theSource);
- if (theGroup_i || theGroupOnGeom_i)
- {
- SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
- << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
- }
- else if (theMesh_i)
- {
- SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
- << theSource << ".GetMesh(), " << theType << ", \"" << theGroupName << "\" )";
- }
- return res;
+ return p_SetEnforcedMesh(theSource, theType, -1.0, theGroupName);
+// bool res = p_SetEnforcedMesh(theSource, theType, -1.0, theGroupName);
+// SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
+// SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
+// SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast<SMESH_GroupOnGeom_i*>( theSource);
+// if (theGroup_i || theGroupOnGeom_i)
+// {
+// SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
+// << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
+// }
+// else if (theMesh_i)
+// {
+// SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
+// << theSource << ".GetMesh(), " << theType << ", \"" << theGroupName << "\" )";
+// }
+// return res;
#else
SALOME::ExceptionStruct ExDescription;
ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
bool GHS3DPlugin_Hypothesis_i::SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType)
throw (SALOME::SALOME_Exception)
{
- MESSAGE("GHS3DPlugin_Hypothesis_i::SetEnforcedMesh");
+// MESSAGE("GHS3DPlugin_Hypothesis_i::SetEnforcedMesh");
#if GHS3D_VERSION >= 42
- bool res = _SetEnforcedMesh(theSource, theType, -1.0);
- SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
- SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
- SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast<SMESH_GroupOnGeom_i*>( theSource);
- if (theGroup_i || theGroupOnGeom_i)
- {
- SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
- << theSource << ", " << theType << " )";
- }
- else if (theMesh_i)
- {
- SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
- << theSource << ".GetMesh(), " << theType << " )";
- }
- return res;
+ return p_SetEnforcedMesh(theSource, theType);
+// bool res = p_SetEnforcedMesh(theSource, theType);
+// SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
+// SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
+// SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast<SMESH_GroupOnGeom_i*>( theSource);
+// if (theGroup_i || theGroupOnGeom_i)
+// {
+// SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
+// << theSource << ", " << theType << " )";
+// }
+// else if (theMesh_i)
+// {
+// SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
+// << theSource << ".GetMesh(), " << theType << " )";
+// }
+// return res;
#else
SALOME::ExceptionStruct ExDescription;
ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSizeWithGroup(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize, const char* theGroupName)
throw (SALOME::SALOME_Exception)
{
- if (theSize <= 0) {
+#if GHS3D_VERSION >= 42
+ if (theSize < 0) {
SALOME::ExceptionStruct ExDescription;
ExDescription.text = "Size cannot be negative";
ExDescription.type = SALOME::BAD_PARAM;
throw SALOME::SALOME_Exception(ExDescription);
}
- bool res = _SetEnforcedMesh(theSource, theType, theSize,theGroupName);
- SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
- SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
- SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast<SMESH_GroupOnGeom_i*>( theSource);
- if (theGroup_i || theGroupOnGeom_i)
- {
- SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshSizeWithGroup( "
- << theSource << ", " << theType << ", " << theSize << ", \"" << theGroupName << "\" )";
- }
- else if (theMesh_i)
- {
- SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshSizeWithGroup( "
- << theSource << ".GetMesh(), " << theType << ", " << theSize << ", \"" << theGroupName << "\" )";
- }
- return res;
+ return p_SetEnforcedMesh(theSource, theType, theSize, theGroupName);
+// bool res = p_SetEnforcedMesh(theSource, theType, theSize, theGroupName);
+// SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
+// SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
+// SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast<SMESH_GroupOnGeom_i*>( theSource);
+// if (theGroup_i || theGroupOnGeom_i)
+// {
+// SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshSizeWithGroup( "
+// << theSource << ", " << theType << ", " << theSize << ", \"" << theGroupName << "\" )";
+// }
+// else if (theMesh_i)
+// {
+// SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshSizeWithGroup( "
+// << theSource << ".GetMesh(), " << theType << ", " << theSize << ", \"" << theGroupName << "\" )";
+// }
+// return res;
+#else
+ SALOME::ExceptionStruct ExDescription;
+ ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
+ ExDescription.type = SALOME::BAD_PARAM;
+ ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
+ ExDescription.lineNumber = 750;
+ throw SALOME::SALOME_Exception(ExDescription);
+#endif
}
/*!
bool GHS3DPlugin_Hypothesis_i::SetEnforcedMeshSize(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize)
throw (SALOME::SALOME_Exception)
{
- if (theSize <= 0) {
+#if GHS3D_VERSION >= 42
+ if (theSize < 0) {
SALOME::ExceptionStruct ExDescription;
ExDescription.text = "Size cannot be negative";
ExDescription.type = SALOME::BAD_PARAM;
ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
- ExDescription.lineNumber = 812;
+ ExDescription.lineNumber = 781;
throw SALOME::SALOME_Exception(ExDescription);
}
-
- bool res = _SetEnforcedMesh(theSource, theType, theSize);
- SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
- SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
- SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast<SMESH_GroupOnGeom_i*>( theSource);
- if (theGroup_i || theGroupOnGeom_i)
- {
- SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshSize( "
- << theSource << ", " << theType << ", " << theSize << " )";
- }
- else if (theMesh_i)
- {
- SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshSize( "
- << theSource << ".GetMesh(), " << theType << ", " << theSize << " )";
- }
- return res;
+ return p_SetEnforcedMesh(theSource, theType, theSize);
+// bool res = p_SetEnforcedMesh(theSource, theType, theSize);
+// SMESH_Mesh_i* theMesh_i = SMESH::DownCast<SMESH_Mesh_i*>( theSource);
+// SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
+// SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast<SMESH_GroupOnGeom_i*>( theSource);
+// if (theGroup_i || theGroupOnGeom_i)
+// {
+// SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshSize( "
+// << theSource << ", " << theType << ", " << theSize << " )";
+// }
+// else if (theMesh_i)
+// {
+// SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshSize( "
+// << theSource << ".GetMesh(), " << theType << ", " << theSize << " )";
+// }
+// return res;
+#else
+ SALOME::ExceptionStruct ExDescription;
+ ExDescription.text = "Bad version of GHS3D. It must >= 4.2.";
+ ExDescription.type = SALOME::BAD_PARAM;
+ ExDescription.sourceFile = "GHS3DPlugin_Hypothesis_i.cxx";
+ ExDescription.lineNumber = 750;
+ throw SALOME::SALOME_Exception(ExDescription);
+#endif
}
-bool GHS3DPlugin_Hypothesis_i::_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize, const char* theGroupName)
+bool GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh(SMESH::SMESH_IDSource_ptr theSource, SMESH::ElementType theType, double theSize, const char* theGroupName)
throw (SALOME::SALOME_Exception)
{
- MESSAGE("GHS3DPlugin_Hypothesis_i::_SetEnforcedMesh");
+ MESSAGE("GHS3DPlugin_Hypothesis_i::p_SetEnforcedMesh");
ASSERT(myBaseImpl);
if (CORBA::is_nil( theSource ))
SMESH_Group_i* theGroup_i = SMESH::DownCast<SMESH_Group_i*>( theSource);
SMESH_GroupOnGeom_i* theGroupOnGeom_i = SMESH::DownCast<SMESH_GroupOnGeom_i*>( theSource);
TIDSortedElemSet theElemSet;
-
+ SMESH_Gen_i *smeshGen = SMESH_Gen_i::GetSMESHGen();
+ SALOMEDS::SObject_ptr SObj = smeshGen->ObjectToSObject(smeshGen->GetCurrentStudy(),theSource);
if (theMesh_i)
{
try {
- return this->GetImpl()->SetEnforcedMesh(theMesh_i->GetImpl(), theType, theSize, theGroupName);
+ bool res = this->GetImpl()->SetEnforcedMesh(theMesh_i->GetImpl(), theType, SObj->GetName() , SObj->GetID(), theSize, theGroupName);
+ if (theSize > 0) {
+ if (theGroupName != "") {
+ SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshSizeWithGroup( "
+ << theSource << ".GetMesh(), " << theType << ", " << theSize << ", \"" << theGroupName << "\" )";
+ }
+ else {
+ SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshSize( "
+ << theSource << ".GetMesh(), " << theType << ", " << theSize << ", \"" << theGroupName << "\" )";
+ }
+ }
+ else {
+ if (theGroupName != "") {
+ SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
+ << theSource << ".GetMesh(), " << theType << ", \"" << theGroupName << "\" )";
+ }
+ else {
+ SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
+ << theSource << ".GetMesh(), " << theType << " )";
+ }
+ }
+ return res;
}
catch (const std::invalid_argument& ex) {
SALOME::ExceptionStruct ExDescription;
{
MESSAGE("The source is a group")
try {
- return this->GetImpl()->SetEnforcedGroup(theGroup_i->GetGroupDS()->GetMesh(),theGroup_i->GetListOfID(), theType, theSize, theGroupName);
+ bool res = this->GetImpl()->SetEnforcedGroup(theGroup_i->GetGroupDS()->GetMesh(), theGroup_i->GetListOfID(), theType, SObj->GetName() , SObj->GetID(), theSize, theGroupName);
+ if (theSize > 0) {
+ if (theGroupName != "") {
+ SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshSizeWithGroup( "
+ << theSource << ", " << theType << ", " << theSize << ", \"" << theGroupName << "\" )";
+ }
+ else {
+ SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshSize( "
+ << theSource << ", " << theType << ", " << theSize << ", \"" << theGroupName << "\" )";
+ }
+ }
+ else {
+ if (theGroupName != "") {
+ SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
+ << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
+ }
+ else {
+ SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
+ << theSource << ", " << theType << " )";
+ }
+ }
+ return res;
}
catch (const std::invalid_argument& ex) {
SALOME::ExceptionStruct ExDescription;
{
MESSAGE("The source is a group on geom")
try {
- return this->GetImpl()->SetEnforcedGroup(theGroupOnGeom_i->GetGroupDS()->GetMesh(),theGroupOnGeom_i->GetListOfID(), theType, theSize, theGroupName);
+ bool res = this->GetImpl()->SetEnforcedGroup(theGroupOnGeom_i->GetGroupDS()->GetMesh(),theGroupOnGeom_i->GetListOfID(), theType, SObj->GetName() , SObj->GetID(), theSize, theGroupName);
+ if (theSize > 0) {
+ if (theGroupName != "") {
+ SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshSizeWithGroup( "
+ << theSource << ", " << theType << ", " << theSize << ", \"" << theGroupName << "\" )";
+ }
+ else {
+ SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshSize( "
+ << theSource << ", " << theType << ", " << theSize << ", \"" << theGroupName << "\" )";
+ }
+ }
+ else {
+ if (theGroupName != "") {
+ SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMeshWithGroup( "
+ << theSource << ", " << theType << ", \"" << theGroupName << "\" )";
+ }
+ else {
+ SMESH::TPythonDump () << "isDone = " << _this() << ".SetEnforcedMesh( "
+ << theSource << ", " << theType << " )";
+ }
+ }
+ return res;
}
catch (const std::invalid_argument& ex) {
SALOME::ExceptionStruct ExDescription;
// $Header:
//
#include "GHS3DPluginGUI_HypothesisCreator.h"
+// #include "GHS3DPluginGUI_EnforcedDelegates.h"
+#include "GHS3DPluginGUI_Enums.h"
+
+#include "GeometryGUI.h"
#include <SMESHGUI_Utils.h>
+#include <SMESHGUI_SpinBox.h>
#include <SMESHGUI_HypothesesUtils.h>
+#include <SMESH_NumberFilter.hxx>
+#include <SMESH_TypeFilter.hxx>
+#include <StdMeshersGUI_ObjectReferenceParamWdg.h>
+#include <LightApp_SelectionMgr.h>
#include <SUIT_Session.h>
#include <SUIT_MessageBox.h>
#include <SUIT_ResourceMgr.h>
#include <SalomeApp_Tools.h>
#include <SalomeApp_TypeFilter.h>
+#include <TopoDS_Iterator.hxx>
+
#include <QComboBox>
+#include <QPalette>
#include <QLabel>
#include <QFrame>
#include <QVBoxLayout>
#include <QSpinBox>
#include <QPushButton>
#include <QFileInfo>
+#include <QGroupBox>
#include <QTableWidget>
-#include <QStandardItemModel>
-#include <QStandardItem>
+#include <QTableWidgetItem>
#include <QHeaderView>
-#include <QModelIndexList>
#include <stdexcept>
#include <utilities.h>
-// tabs
-enum {
- STD_TAB = 0,
- ADV_TAB,
- ENF_VER_TAB
-};
-
-// Enforced vertices array columns
-enum {
- ENF_VER_X_COLUMN = 0,
- ENF_VER_Y_COLUMN,
- ENF_VER_Z_COLUMN,
- ENF_VER_SIZE_COLUMN,
- ENF_VER_NB_COLUMNS
-};
-
-// Enforced vertices inputs
-enum {
- ENF_VER_BTNS = 0,
- ENF_VER_X_COORD,
- ENF_VER_Y_COORD,
- ENF_VER_Z_COORD,
- ENF_VER_SIZE,
- ENF_VER_VERTEX_BTN,
- ENF_VER_SEPARATOR,
- ENF_VER_REMOVE_BTN,
-};
+#include <boost/algorithm/string.hpp>
namespace {
}
}
-class QDoubleValidator;
-
//
-// BEGIN DoubleLineEditDelegate
+// BEGIN EnforcedVertexTableWidgetDelegate
//
-DoubleLineEditDelegate::DoubleLineEditDelegate(QObject *parent)
+EnforcedVertexTableWidgetDelegate::EnforcedVertexTableWidgetDelegate(QObject *parent)
: QItemDelegate(parent)
{
}
-QWidget *DoubleLineEditDelegate::createEditor(QWidget *parent,
- const QStyleOptionViewItem &/* option */,
- const QModelIndex &/* index */) const
+QWidget *EnforcedVertexTableWidgetDelegate::createEditor(QWidget *parent,
+ const QStyleOptionViewItem & option ,
+ const QModelIndex & index ) const
{
+ QModelIndex father = index.parent();
+ QString entry = father.child(index.row(), ENF_VER_ENTRY_COLUMN).data().toString();
+
+ if (index.column() == ENF_VER_X_COLUMN ||
+ index.column() == ENF_VER_Y_COLUMN ||
+ index.column() == ENF_VER_Z_COLUMN ||
+ index.column() == ENF_VER_SIZE_COLUMN) {
+ SMESHGUI_SpinBox *editor = new SMESHGUI_SpinBox(parent);
+ if (index.column() == ENF_VER_SIZE_COLUMN)
+ editor->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
+ else
+ editor->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
+ editor->setReadOnly(!entry.isEmpty());
+ editor->setDisabled(!entry.isEmpty());
+ return editor;
+ }
+// else if (index.column() == ENF_VER_COMPOUND_COLUMN) {
+// QCheckBox *editor = new QCheckBox(parent);
+// editor->setDisabled(!entry.isEmpty());
+// return editor;
+// }
+ else if (index.column() == ENF_VER_GROUP_COLUMN ||
+ index.column() == ENF_VER_NAME_COLUMN) {
+// else {
QLineEdit *editor = new QLineEdit(parent);
- editor->setValidator(new QDoubleValidator(parent));
-
+ if (index.column() != ENF_VER_GROUP_COLUMN) {
+ editor->setReadOnly(!entry.isEmpty());
+ editor->setDisabled(!entry.isEmpty());
+ }
return editor;
+ }
+ return QItemDelegate::createEditor(parent, option, index);
}
-void DoubleLineEditDelegate::setEditorData(QWidget *editor,
- const QModelIndex &index) const
+void EnforcedVertexTableWidgetDelegate::setEditorData(QWidget *editor,
+ const QModelIndex &index) const
{
- QString value = index.model()->data(index, Qt::EditRole).toString();
+ if (index.column() == ENF_VER_X_COLUMN ||
+ index.column() == ENF_VER_Y_COLUMN ||
+ index.column() == ENF_VER_Z_COLUMN ||
+ index.column() == ENF_VER_SIZE_COLUMN)
+ {
+ SMESHGUI_SpinBox *lineEdit = qobject_cast<SMESHGUI_SpinBox*>(editor);
+ lineEdit->SetValue(index.data().toDouble());
+ }
+ else if (index.column() == ENF_VER_COMPOUND_COLUMN) {
+ QCheckBox *checkBox = qobject_cast<QCheckBox*>(editor);
+ checkBox->setChecked(index.data().toBool());
+ }
+ else {
+ QItemDelegate::setEditorData(editor, index);
+ }
+}
- QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
- lineEdit->setText(value);
+void EnforcedVertexTableWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
+ const QModelIndex &index) const
+{
+ QModelIndex parent = index.parent();
+
+ QString entry = parent.child(index.row(), ENF_VER_ENTRY_COLUMN).data().toString();
+ bool isCompound = parent.child(index.row(), ENF_VER_COMPOUND_COLUMN).data(Qt::CheckStateRole).toBool();
+
+ if (index.column() == ENF_VER_X_COLUMN ||
+ index.column() == ENF_VER_Y_COLUMN ||
+ index.column() == ENF_VER_Z_COLUMN) {
+ SMESHGUI_SpinBox *lineEdit = qobject_cast<SMESHGUI_SpinBox*>(editor);
+ if (!isCompound && !vertexExists(model, index, lineEdit->GetString()))
+ model->setData(index, lineEdit->GetValue(), Qt::EditRole);
+ }
+ else if (index.column() == ENF_VER_SIZE_COLUMN)
+ {
+ SMESHGUI_SpinBox *lineEdit = qobject_cast<SMESHGUI_SpinBox*>(editor);
+ const double newsize = lineEdit->GetValue();
+ if (newsize > 0)
+ model->setData(index, newsize, Qt::EditRole);
+ }
+ else if (index.column() == ENF_VER_NAME_COLUMN) {
+ QLineEdit *lineEdit = qobject_cast<QLineEdit*>(editor);
+ QString value = lineEdit->text();
+ if (entry.isEmpty() && !vertexExists(model, index, value))
+ model->setData(index, value, Qt::EditRole);
+ }
+ else if (index.column() == ENF_VER_ENTRY_COLUMN) {
+ QLineEdit *lineEdit = qobject_cast<QLineEdit*>(editor);
+ QString value = lineEdit->text();
+ if (! vertexExists(model, index, value))
+ model->setData(index, value, Qt::EditRole);
+ }
+ else if (index.column() == ENF_VER_COMPOUND_COLUMN) {
+ QCheckBox *checkBox = qobject_cast<QCheckBox*>(editor);
+ model->setData(index, checkBox->isChecked(), Qt::CheckStateRole);
+ }
+ else {
+ QItemDelegate::setModelData(editor, model, index);
+ }
}
-void DoubleLineEditDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
- const QModelIndex &index) const
+void EnforcedVertexTableWidgetDelegate::updateEditorGeometry(QWidget *editor,
+ const QStyleOptionViewItem &option, const QModelIndex &/* index */) const
{
- QLineEdit *lineEdit = static_cast<QLineEdit*>(editor);
- bool ok;
- double value = lineEdit->text().toDouble(&ok);
+ editor->setGeometry(option.rect);
+}
- if (ok) {
- model->setData(index, value, Qt::EditRole);
- MESSAGE("Value " << value << " was set at index(" << index.row() << "," << index.column() << ")");
+bool EnforcedVertexTableWidgetDelegate::vertexExists(QAbstractItemModel *model,
+ const QModelIndex &index,
+ QString value) const
+{
+ bool exists = false;
+ QModelIndex parent = index.parent();
+ int row = index.row();
+ int col = index.column();
+
+ if (parent.isValid() && !value.isEmpty()) {
+ if (col == ENF_VER_X_COLUMN || col == ENF_VER_Y_COLUMN || col == ENF_VER_Z_COLUMN) {
+ double x, y, z;
+ if (col == ENF_VER_X_COLUMN) {
+ x = value.toDouble();
+ y = parent.child(row, ENF_VER_Y_COLUMN).data().toDouble();
+ z = parent.child(row, ENF_VER_Z_COLUMN).data().toDouble();
+ }
+ if (col == ENF_VER_Y_COLUMN) {
+ y = value.toDouble();
+ x = parent.child(row, ENF_VER_X_COLUMN).data().toDouble();
+ z = parent.child(row, ENF_VER_Z_COLUMN).data().toDouble();
+ }
+ if (col == ENF_VER_Z_COLUMN) {
+ z = value.toDouble();
+ x = parent.child(row, ENF_VER_X_COLUMN).data().toDouble();
+ y = parent.child(row, ENF_VER_Y_COLUMN).data().toDouble();
+ }
+ int nbChildren = model->rowCount(parent);
+ for (int i = 0 ; i < nbChildren ; i++) {
+ if (i != row) {
+ double childX = parent.child(i, ENF_VER_X_COLUMN).data().toDouble();
+ double childY = parent.child(i, ENF_VER_Y_COLUMN).data().toDouble();
+ double childZ = parent.child(i, ENF_VER_Z_COLUMN).data().toDouble();
+ if ((childX == x) && (childY == y) && (childZ == z)) {
+ exists = true;
+ break;
+ }
+ }
+ }
+ }
+ else if (col == ENF_VER_NAME_COLUMN) {
+ QString name = parent.child(row, ENF_VER_NAME_COLUMN).data().toString();
+ if (name == value)
+ exists = true;
}
+ }
+
+ return exists;
}
-void DoubleLineEditDelegate::updateEditorGeometry(QWidget *editor,
+//
+// END EnforcedVertexTableWidgetDelegate
+//
+
+//
+// BEGIN EnforcedMeshTableWidgetDelegate
+//
+
+EnforcedMeshTableWidgetDelegate::EnforcedMeshTableWidgetDelegate(QObject *parent)
+ : QItemDelegate(parent)
+{
+}
+
+QWidget *EnforcedMeshTableWidgetDelegate::createEditor(QWidget *parent,
+ const QStyleOptionViewItem & option ,
+ const QModelIndex & index ) const
+{
+ if (index.column() == ENF_MESH_SIZE_COLUMN) {
+ SMESHGUI_SpinBox *editor = new SMESHGUI_SpinBox(parent);
+ editor->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
+ return editor;
+ }
+ return QItemDelegate::createEditor(parent, option, index);
+}
+
+void EnforcedMeshTableWidgetDelegate::setEditorData(QWidget *editor,
+ const QModelIndex &index) const
+{
+ if (index.column() == ENF_MESH_SIZE_COLUMN) {
+ SMESHGUI_SpinBox *spinBox = qobject_cast<SMESHGUI_SpinBox*>(editor);
+ spinBox->SetValue(index.data().toDouble());
+ }
+ else
+ QItemDelegate::setEditorData(editor, index);
+}
+
+void EnforcedMeshTableWidgetDelegate::setModelData(QWidget *editor, QAbstractItemModel *model,
+ const QModelIndex &index) const
+{
+ if (index.column() == ENF_MESH_SIZE_COLUMN)
+ {
+ SMESHGUI_SpinBox *spinBox = qobject_cast<SMESHGUI_SpinBox*>(editor);
+ const double newsize = spinBox->GetValue();
+ if (newsize > 0)
+ model->setData(index, newsize, Qt::EditRole);
+ }
+ else
+ QItemDelegate::setModelData(editor, model, index);
+
+}
+
+void EnforcedMeshTableWidgetDelegate::updateEditorGeometry(QWidget *editor,
const QStyleOptionViewItem &option, const QModelIndex &/* index */) const
{
editor->setGeometry(option.rect);
}
+// bool EnforcedMeshTableWidgetDelegate::enfMeshExists(QAbstractItemModel *model,
+// const QModelIndex &index,
+// QString value) const
+// {
+// bool exists = false;
+// QModelIndex parent = index.parent();
+// int row = index.row();
+// int col = index.column();
+// return exists;
+// }
+
//
-// END DoubleLineEditDelegate
+// END EnforcedMeshTableWidgetDelegate
//
+
GHS3DPluginGUI_HypothesisCreator::GHS3DPluginGUI_HypothesisCreator( const QString& theHypType )
: SMESHGUI_GenericHypothesisCreator( theHypType )
{
+ GeomToolSelected = NULL;
+ GeomToolSelected = getGeomSelectionTool();
+
+ iconVertex = QPixmap(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_OBJBROWSER_VERTEX")));
+ iconCompound = QPixmap(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_OBJBROWSER_COMPOUND")));
+// mySelectionMgr = SMESH::GetSelectionMgr(SMESHGUI::GetSMESHGUI());
+ myEnfMeshConstraintLabels << tr( "GHS3D_ENF_MESH_CONSTRAINT_NODE" ) << tr( "GHS3D_ENF_MESH_CONSTRAINT_EDGE" ) << tr("GHS3D_ENF_MESH_CONSTRAINT_FACE");
}
GHS3DPluginGUI_HypothesisCreator::~GHS3DPluginGUI_HypothesisCreator()
{
+ GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
+ that->getGeomSelectionTool()->selectionMgr()->clearFilters();
+ myEnfMeshWdg->deactivateSelection();
+}
+
+/**
+ * \brief {Get or create the geom selection tool for active study}
+ * */
+GeomSelectionTools* GHS3DPluginGUI_HypothesisCreator::getGeomSelectionTool()
+{
+ GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
+ _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+ if (that->GeomToolSelected == NULL || that->GeomToolSelected->getMyStudy() != aStudy) {
+ that->GeomToolSelected = new GeomSelectionTools(aStudy);
+ }
+ return that->GeomToolSelected;
+}
+
+GEOM::GEOM_Gen_var GHS3DPluginGUI_HypothesisCreator::getGeomEngine()
+{
+ return GeometryGUI::GetGeomGen();
}
QFrame* GHS3DPluginGUI_HypothesisCreator::buildFrame()
myToMeshHolesCheck = new QCheckBox( tr( "GHS3D_TO_MESH_HOLES" ), myStdGroup );
aStdLayout->addWidget( myToMeshHolesCheck, row++, 0, 1, 2 );
- aStdLayout->addWidget( new QLabel( tr( "GHS3D_OPTIMIZATIOL_LEVEL" ), myStdGroup ), row, 0 );
+ aStdLayout->addWidget( new QLabel( tr( "GHS3D_OPTIMIZATIOL_LEVEL" ), myStdGroup ), row, 0, 1, 1 );
myOptimizationLevelCombo = new QComboBox( myStdGroup );
aStdLayout->addWidget( myOptimizationLevelCombo, row++, 1, 1, 1 );
types << tr( "LEVEL_NONE" ) << tr( "LEVEL_LIGHT" ) << tr( "LEVEL_MEDIUM" ) << tr( "LEVEL_STANDARDPLUS" ) << tr( "LEVEL_STRONG" );
myOptimizationLevelCombo->addItems( types );
- aStdLayout->setRowStretch( row, 5 );
+ aStdLayout->setRowStretch( row, 10 );
// advanced parameters
myAdvGroup = new QWidget();
anAdvLayout->addWidget( aTextOptionLabel, 9, 0, 1, 1 );
anAdvLayout->addWidget( myTextOption, 9, 1, 1, 2 );
- // Size Maps parameters
+ // Enforced vertices parameters
myEnfGroup = new QWidget();
- QGridLayout* anSmpLayout = new QGridLayout(myEnfGroup);
-
- mySmpModel = new QStandardItemModel(0, ENF_VER_NB_COLUMNS);
- myEnforcedTableView = new QTableView(myEnfGroup);
- myEnforcedTableView->setModel(mySmpModel);
- myEnforcedTableView->setSortingEnabled(true);
- myEnforcedTableView->setItemDelegateForColumn(ENF_VER_SIZE_COLUMN,new DoubleLineEditDelegate(this));
- anSmpLayout->addWidget(myEnforcedTableView, 1, 0, 9, 1);
+ QGridLayout* anEnfLayout = new QGridLayout(myEnfGroup);
+
+ myEnforcedTableWidget = new QTableWidget(myEnfGroup);
+ myEnforcedTableWidget ->setMinimumWidth(300);
+ myEnforcedTableWidget->setRowCount( 0 );
+ myEnforcedTableWidget->setColumnCount( ENF_VER_NB_COLUMNS );
+ myEnforcedTableWidget->setSortingEnabled(true);
QStringList enforcedHeaders;
- enforcedHeaders << tr( "GHS3D_ENF_VER_X_COLUMN" )<< tr( "GHS3D_ENF_VER_Y_COLUMN" ) << tr( "GHS3D_ENF_VER_Z_COLUMN" ) << tr( "GHS3D_ENF_VER_SIZE_COLUMN" );
- mySmpModel->setHorizontalHeaderLabels(enforcedHeaders);
- myEnforcedTableView->setAlternatingRowColors(true);
- myEnforcedTableView->verticalHeader()->hide();
- myEnforcedTableView->horizontalHeader()->setResizeMode(QHeaderView::Stretch);
+ enforcedHeaders << tr( "GHS3D_ENF_NAME_COLUMN" )
+ << tr( "GHS3D_ENF_VER_X_COLUMN" )<< tr( "GHS3D_ENF_VER_Y_COLUMN" ) << tr( "GHS3D_ENF_VER_Z_COLUMN" )
+ << tr( "GHS3D_ENF_SIZE_COLUMN" ) << tr("GHS3D_ENF_ENTRY_COLUMN") << tr("GHS3D_ENF_VER_COMPOUND_COLUMN") << tr( "GHS3D_ENF_GROUP_COLUMN" );
+
+ myEnforcedTableWidget->setHorizontalHeaderLabels(enforcedHeaders);
+ myEnforcedTableWidget->verticalHeader()->hide();
+ myEnforcedTableWidget->horizontalHeader()->setStretchLastSection(true);
+ myEnforcedTableWidget->setAlternatingRowColors(true);
+ myEnforcedTableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
+ myEnforcedTableWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
+ myEnforcedTableWidget->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
+ myEnforcedTableWidget->resizeColumnsToContents();
+ myEnforcedTableWidget->hideColumn(ENF_VER_ENTRY_COLUMN);
+ myEnforcedTableWidget->hideColumn(ENF_VER_COMPOUND_COLUMN);
+
+ myEnforcedTableWidget->setItemDelegate(new EnforcedVertexTableWidgetDelegate());
+
+// VERTEX SELECTION
+ TColStd_MapOfInteger shapeTypes;
+ shapeTypes.Add( TopAbs_VERTEX );
+ shapeTypes.Add( TopAbs_COMPOUND );
+
+ SMESH_NumberFilter* vertexFilter = new SMESH_NumberFilter("GEOM", TopAbs_SHAPE, 1, shapeTypes);
+ myEnfVertexWdg = new StdMeshersGUI_ObjectReferenceParamWdg( vertexFilter, 0, /*multiSel=*/true, /*stretch=*/false);
+ myEnfVertexWdg->SetDefaultText(tr("GHS3D_ENF_SELECT_VERTEX"), "QLineEdit { color: grey }");
QLabel* myXCoordLabel = new QLabel( tr( "GHS3D_ENF_VER_X_LABEL" ), myEnfGroup );
- anSmpLayout->addWidget(myXCoordLabel, ENF_VER_X_COORD, 1, 1, 1);
- myXCoord = new QLineEdit(myEnfGroup);
- myXCoord->setValidator(new QDoubleValidator(myEnfGroup));
- anSmpLayout->addWidget(myXCoord, ENF_VER_X_COORD, 2, 1, 1);
+ myXCoord = new SMESHGUI_SpinBox(myEnfGroup);
+ myXCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
QLabel* myYCoordLabel = new QLabel( tr( "GHS3D_ENF_VER_Y_LABEL" ), myEnfGroup );
- anSmpLayout->addWidget(myYCoordLabel, ENF_VER_Y_COORD, 1, 1, 1);
- myYCoord = new QLineEdit(myEnfGroup);
- myYCoord->setValidator(new QDoubleValidator(myEnfGroup));
- anSmpLayout->addWidget(myYCoord, ENF_VER_Y_COORD, 2, 1, 1);
+ myYCoord = new SMESHGUI_SpinBox(myEnfGroup);
+ myYCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
QLabel* myZCoordLabel = new QLabel( tr( "GHS3D_ENF_VER_Z_LABEL" ), myEnfGroup );
- anSmpLayout->addWidget(myZCoordLabel, ENF_VER_Z_COORD, 1, 1, 1);
- myZCoord = new QLineEdit(myEnfGroup);
- myZCoord->setValidator(new QDoubleValidator(myEnfGroup));
- anSmpLayout->addWidget(myZCoord, ENF_VER_Z_COORD, 2, 1, 1);
- QLabel* mySizeLabel = new QLabel( tr( "GHS3D_ENF_VER_SIZE_LABEL" ), myEnfGroup );
- anSmpLayout->addWidget(mySizeLabel, ENF_VER_SIZE, 1, 1, 1);
- mySizeValue = new QLineEdit(myEnfGroup);
- mySizeValue->setValidator(new QDoubleValidator(myEnfGroup));
- anSmpLayout->addWidget(mySizeValue, ENF_VER_SIZE, 2, 1, 1);
-
- addVertexButton = new QPushButton(tr("GHS3D_ENF_VER_VERTEX"),myEnfGroup);
- anSmpLayout->addWidget(addVertexButton, ENF_VER_VERTEX_BTN, 1, 1, 2);
+ myZCoord = new SMESHGUI_SpinBox(myEnfGroup);
+ myZCoord->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
+ QLabel* mySizeLabel = new QLabel( tr( "GHS3D_ENF_SIZE_LABEL" ), myEnfGroup );
+ mySizeValue = new SMESHGUI_SpinBox(myEnfGroup);
+ mySizeValue->RangeStepAndValidator(COORD_MIN, COORD_MAX, 10.0, "length_precision");
+
+ QLabel* myGroupNameLabel = new QLabel( tr( "GHS3D_ENF_GROUP_LABEL" ), myEnfGroup );
+ myGroupName = new QLineEdit(myEnfGroup);
+
+ addVertexButton = new QPushButton(tr("GHS3D_ENF_ADD"),myEnfGroup);
addVertexButton->setEnabled(false);
+ removeVertexButton = new QPushButton(tr("GHS3D_ENF_REMOVE"),myEnfGroup);
+// myGlobalGroupName = new QCheckBox(tr("GHS3D_ENF_VER_GROUPS"), myEnfGroup);
+// myGlobalGroupName->setChecked(false);
+
+ QGroupBox* GroupBox = new QGroupBox( myEnfGroup );
+ QLabel* info = new QLabel( GroupBox );
+ info->setText( tr( "GHS3D_ENF_VER_INFO" ) );
+ info->setWordWrap( true );
+ QVBoxLayout* GroupBoxVLayout = new QVBoxLayout( GroupBox );
+ GroupBoxVLayout->setSpacing( 6 );
+ GroupBoxVLayout->setMargin( 11 );
+ GroupBoxVLayout->addWidget( info );
+
+
+ anEnfLayout->addWidget(GroupBox, ENF_VER_WARNING, 0, 1, 2 );
+ anEnfLayout->addWidget(myEnforcedTableWidget, ENF_VER_VERTEX, 0, ENF_VER_NB_LINES, 1);
+
+ QGridLayout* anEnfLayout2 = new QGridLayout(myEnfGroup);
+ anEnfLayout2->addWidget(myEnfVertexWdg, ENF_VER_VERTEX, 0, 1, 2);
+ anEnfLayout2->addWidget(myXCoordLabel, ENF_VER_X_COORD, 0, 1, 1);
+ anEnfLayout2->addWidget(myXCoord, ENF_VER_X_COORD, 1, 1, 1);
+ anEnfLayout2->addWidget(myYCoordLabel, ENF_VER_Y_COORD, 0, 1, 1);
+ anEnfLayout2->addWidget(myYCoord, ENF_VER_Y_COORD, 1, 1, 1);
+ anEnfLayout2->addWidget(myZCoordLabel, ENF_VER_Z_COORD, 0, 1, 1);
+ anEnfLayout2->addWidget(myZCoord, ENF_VER_Z_COORD, 1, 1, 1);
+ anEnfLayout2->addWidget(mySizeLabel, ENF_VER_SIZE, 0, 1, 1);
+ anEnfLayout2->addWidget(mySizeValue, ENF_VER_SIZE, 1, 1, 1);
+ anEnfLayout2->addWidget(myGroupNameLabel, ENF_VER_GROUP, 0, 1, 1);
+ anEnfLayout2->addWidget(myGroupName, ENF_VER_GROUP, 1, 1, 1);
+ anEnfLayout2->addWidget(addVertexButton, ENF_VER_BTN, 0, 1, 1);
+ anEnfLayout2->addWidget(removeVertexButton, ENF_VER_BTN, 1, 1, 1);
+ anEnfLayout2->setRowStretch(ENF_VER_NB_LINES, 1);
+
+ anEnfLayout->addLayout(anEnfLayout2, ENF_VER_VERTEX, 1,ENF_VER_NB_LINES, 1);
+ anEnfLayout->setRowStretch(ENF_VER_VERTEX, 10);
+
+
+ // Enforced meshes parameters
+ myEnfMeshGroup = new QWidget();
+ QGridLayout* anEnfMeshLayout = new QGridLayout(myEnfMeshGroup);
+
+ myEnforcedMeshTableWidget = new QTableWidget(myEnfGroup);
+ myEnforcedMeshTableWidget->setRowCount( 0 );
+ myEnforcedMeshTableWidget->setColumnCount( ENF_MESH_NB_COLUMNS );
+ myEnforcedMeshTableWidget->setSortingEnabled(true);
+ myEnforcedMeshTableWidget->verticalHeader()->hide();
+ QStringList enforcedMeshHeaders;
+ enforcedMeshHeaders << tr( "GHS3D_ENF_NAME_COLUMN" )
+ << tr( "GHS3D_ENF_ENTRY_COLUMN" )
+ << tr( "GHS3D_ENF_MESH_CONSTRAINT_COLUMN" )
+ << tr( "GHS3D_ENF_SIZE_COLUMN" )
+ << tr( "GHS3D_ENF_GROUP_COLUMN" );
+ myEnforcedMeshTableWidget->setHorizontalHeaderLabels(enforcedMeshHeaders);
+ myEnforcedMeshTableWidget->horizontalHeader()->setStretchLastSection(true);
+ myEnforcedMeshTableWidget->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
+ myEnforcedMeshTableWidget->setAlternatingRowColors(true);
+ myEnforcedMeshTableWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
+ myEnforcedMeshTableWidget->setSelectionBehavior(QAbstractItemView::SelectItems);
+ myEnforcedMeshTableWidget->resizeColumnsToContents();
+ myEnforcedMeshTableWidget->hideColumn(ENF_MESH_ENTRY_COLUMN);
+
+ myEnforcedMeshTableWidget->setItemDelegate(new EnforcedMeshTableWidgetDelegate());
+
+// myEnfMesh = SMESH::SMESH_Mesh::_nil();
+// myEnfMeshArray = new SMESH::mesh_array();
- QFrame *line = new QFrame(myEnfGroup);
- line->setFrameShape(QFrame::HLine);
- line->setFrameShadow(QFrame::Sunken);
- anSmpLayout->addWidget(line, ENF_VER_SEPARATOR, 1, 1, 2);
+ myEnfMeshWdg = new StdMeshersGUI_ObjectReferenceParamWdg( IDSOURCE, myEnfMeshGroup, /*multiSel=*/true);
+ myEnfMeshWdg->SetDefaultText(tr("GHS3D_ENF_SELECT_MESH"), "QLineEdit { color: grey }");
+
+ myEnfMeshWdg->AvoidSimultaneousSelection(myEnfVertexWdg);
+
+ QLabel* myMeshConstraintLabel = new QLabel( tr( "GHS3D_ENF_MESH_CONSTRAINT_LABEL" ), myEnfMeshGroup );
+ myEnfMeshConstraint = new QComboBox(myEnfMeshGroup);
+ myEnfMeshConstraint->insertItems(0,myEnfMeshConstraintLabels);
+ myEnfMeshConstraint->setEditable(false);
+ myEnfMeshConstraint->setCurrentIndex(0);
+
+ QLabel* myMeshSizeLabel = new QLabel( tr( "GHS3D_ENF_SIZE_LABEL" ), myEnfMeshGroup );
+ myMeshSizeValue = new SMESHGUI_SpinBox(myEnfMeshGroup);
+ myMeshSizeValue->RangeStepAndValidator(0, COORD_MAX, 10.0, "length_precision");
- removeVertexButton = new QPushButton(tr("GHS3D_ENF_VER_REMOVE"),myEnfGroup);
- anSmpLayout->addWidget(removeVertexButton, ENF_VER_REMOVE_BTN, 1, 1, 2);
-
+ QLabel* myMeshGroupNameLabel = new QLabel( tr( "GHS3D_ENF_GROUP_LABEL" ), myEnfMeshGroup );
+ myMeshGroupName = new QLineEdit(myEnfMeshGroup);
+
+ addEnfMeshButton = new QPushButton(tr("GHS3D_ENF_ADD"),myEnfMeshGroup);
+// addEnfMeshButton->setEnabled(false);
+ removeEnfMeshButton = new QPushButton(tr("GHS3D_ENF_REMOVE"),myEnfMeshGroup);
+
+ QGroupBox* GroupBox2 = new QGroupBox( myEnfMeshGroup );
+ QLabel* info2 = new QLabel( GroupBox2 );
+ info2->setText( tr( "GHS3D_ENF_MESH_INFO" ) );
+ info2->setWordWrap( true );
+ QVBoxLayout* GroupBox2VLayout = new QVBoxLayout( GroupBox2 );
+ GroupBox2VLayout->setSpacing( 6 );
+ GroupBox2VLayout->setMargin( 11 );
+ GroupBox2VLayout->addWidget( info2 );
+
+ anEnfMeshLayout->addWidget( GroupBox2, ENF_MESH_WARNING, 0, 1, 2 );
+ anEnfMeshLayout->addWidget(myEnforcedMeshTableWidget, ENF_MESH_MESH, 0, ENF_MESH_NB_LINES , 1);
+
+ QGridLayout* anEnfMeshLayout2 = new QGridLayout(myEnfMeshGroup);
+ anEnfMeshLayout2->addWidget(myEnfMeshWdg, ENF_MESH_MESH, 0, 1, 2);
+ anEnfMeshLayout2->addWidget(myMeshConstraintLabel, ENF_MESH_CONSTRAINT, 0, 1, 1);
+ anEnfMeshLayout2->addWidget(myEnfMeshConstraint, ENF_MESH_CONSTRAINT, 1, 1, 1);
+ anEnfMeshLayout2->addWidget(myMeshSizeLabel, ENF_MESH_SIZE, 0, 1, 1);
+ anEnfMeshLayout2->addWidget(myMeshSizeValue, ENF_MESH_SIZE, 1, 1, 1);
+ anEnfMeshLayout2->addWidget(myMeshGroupNameLabel, ENF_MESH_GROUP, 0, 1, 1);
+ anEnfMeshLayout2->addWidget(myMeshGroupName, ENF_MESH_GROUP, 1, 1, 1);
+ anEnfMeshLayout2->addWidget(addEnfMeshButton, ENF_MESH_BTN, 0, 1, 1);
+ anEnfMeshLayout2->addWidget(removeEnfMeshButton, ENF_MESH_BTN, 1, 1, 1);
+ anEnfMeshLayout2->setRowStretch(ENF_MESH_NB_LINES, 1);
+
+ anEnfMeshLayout->addLayout(anEnfMeshLayout2, ENF_MESH_MESH, 1, ENF_MESH_NB_LINES, 1);
+ anEnfMeshLayout->setRowStretch(ENF_MESH_MESH, 10);
+
// add tabs
tab->insertTab( STD_TAB, myStdGroup, tr( "SMESH_ARGUMENTS" ) );
tab->insertTab( ADV_TAB, myAdvGroup, tr( "GHS3D_ADV_ARGS" ) );
tab->insertTab( ENF_VER_TAB, myEnfGroup, tr( "GHS3D_ENFORCED_VERTICES" ) );
+ tab->insertTab( ENF_MESH_TAB, myEnfMeshGroup, tr( "GHS3D_ENFORCED_MESHES" ) );
tab->setCurrentIndex( STD_TAB );
// connections
connect( myInitialMemoryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
connect( myBoundaryRecoveryCheck, SIGNAL( toggled( bool ) ), this, SLOT( updateWidgets() ) );
connect( dirBtn, SIGNAL( clicked() ), this, SLOT( onDirBtnClicked() ) );
- connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( checkVertexIsDefined() ) );
- connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( checkVertexIsDefined() ) );
- connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( checkVertexIsDefined() ) );
- connect( mySizeValue, SIGNAL( textChanged(const QString&) ), this, SLOT( checkVertexIsDefined() ) );
+ connect( myEnforcedTableWidget, SIGNAL( itemClicked(QTableWidgetItem *)), this, SLOT( synchronizeCoords() ) );
+ connect( myEnforcedTableWidget, SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
+ connect( myEnforcedTableWidget, SIGNAL( itemSelectionChanged() ), this, SLOT( synchronizeCoords() ) );
+ connect( addVertexButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedVertex() ) );
+ connect( removeVertexButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedVertex() ) );
+ connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
+ connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
+ connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
+ connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
+ connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
+ connect( mySizeValue, SIGNAL( textChanged(const QString&) ), this, SLOT( checkVertexIsDefined() ) );
+ connect( myXCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
+ connect( myYCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
+ connect( myZCoord, SIGNAL( valueChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
+ connect( mySizeValue, SIGNAL( valueChanged(const QString&) ), this, SLOT( checkVertexIsDefined() ) );
connect( this, SIGNAL( vertexDefined(bool) ), addVertexButton, SLOT( setEnabled(bool) ) );
- connect( addVertexButton, SIGNAL( clicked() ), this, SLOT( onVertexBtnClicked() ) );
- connect( removeVertexButton, SIGNAL( clicked() ), this, SLOT( onRemoveVertexBtnClicked() ) );
-
+ connect( addEnfMeshButton, SIGNAL( clicked()), this, SLOT( onAddEnforcedMesh() ) );
+ connect( removeEnfMeshButton, SIGNAL( clicked()), this, SLOT( onRemoveEnforcedMesh() ) );
+// connect( myEnfMeshWdg, SIGNAL( contentModified()), this, SLOT( checkEnfMeshIsDefined() ) );
+// connect( myEnfMeshConstraint, SIGNAL( currentIndexChanged(int) ), this, SLOT( checkEnfMeshIsDefined() ) );
+// connect( myMeshSizeValue, SIGNAL( textChanged(const QString&) ), this, SLOT( checkEnfMeshIsDefined() ) );
+// connect( this, SIGNAL( enfMeshDefined(bool) ), addEnfMeshButton, SLOT( setEnabled(bool) ) );
return fr;
}
-bool GHS3DPluginGUI_HypothesisCreator::smpVertexExists(double x, double y, double z) const
-{
- const int rowCount = mySmpModel->rowCount();
- for (int i=0 ; i < rowCount ; i++) {
- double myX = mySmpModel->data(mySmpModel->index(i, ENF_VER_X_COLUMN)).toDouble();
- if (myX == x) {
-// MESSAGE("Found x value " << x << " at row " << i);
- double myY = mySmpModel->data(mySmpModel->index(i, ENF_VER_Y_COLUMN)).toDouble();
- if (myY == y) {
-// MESSAGE("Found y value " << y << " at row " << i);
- double myZ = mySmpModel->data(mySmpModel->index(i, ENF_VER_Z_COLUMN)).toDouble();
- if (myZ == z) {
- MESSAGE("Found x value " << x << " at row " << i);
- MESSAGE("Found y value " << y << " at row " << i);
- MESSAGE("Found z value " << z << " at row " << i);
- return true;
- }
- }
+/**
+ * This method checks if an enforced vertex is defined;
+**/
+void GHS3DPluginGUI_HypothesisCreator::clearEnfVertexSelection()
+{
+ if (myEnfVertexWdg->NbObjects() != 0) {
+ disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
+ disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
+ myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
+ connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
+ connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( checkVertexIsDefined() ) );
+ }
+ GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
+ that->checkVertexIsDefined();
+}
+
+/**
+ * This method checks if an enforced vertex is defined;
+**/
+void GHS3DPluginGUI_HypothesisCreator::checkVertexIsDefined()
+{
+ bool enfVertexIsDefined = false;
+ enfVertexIsDefined = (!mySizeValue->GetString().isEmpty() &&
+ (!myEnfVertexWdg->NbObjects() == 0 ||
+ (myEnfVertexWdg->NbObjects() == 0 && !myXCoord->GetString().isEmpty()
+ && !myYCoord->GetString().isEmpty()
+ && !myZCoord->GetString().isEmpty())));
+ emit vertexDefined(enfVertexIsDefined);
+}
+
+/**
+ * This method checks if an enforced mesh is defined;
+**/
+void GHS3DPluginGUI_HypothesisCreator::checkEnfMeshIsDefined()
+{
+ emit enfMeshDefined((!myMeshSizeValue->GetString().isEmpty() && !myEnfVertexWdg->NbObjects() == 0));
+}
+
+/**
+ * This method resets the content of the X, Y, Z, size and GroupName widgets;
+**/
+void GHS3DPluginGUI_HypothesisCreator::clearEnforcedVertexWidgets()
+{
+ myXCoord->setCleared(true);
+ myYCoord->setCleared(true);
+ myZCoord->setCleared(true);
+// mySizeValue->setCleared(true);
+ myXCoord->setText("");
+ myYCoord->setText("");
+ myZCoord->setText("");
+// mySizeValue->setText("");
+// myGroupName->setText("");
+ addVertexButton->setEnabled(false);
+}
+
+/** GHS3DPluginGUI_HypothesisCreator::updateEnforcedVertexValues(item)
+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 GHS3DPluginGUI_HypothesisCreator::updateEnforcedVertexValues(QTableWidgetItem* item) {
+// MESSAGE("GHS3DPluginGUI_HypothesisCreator::updateEnforcedVertexValues");
+ int row = myEnforcedTableWidget->row(item);
+
+ QVariant vertexName = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole);
+ QVariant x = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data( Qt::EditRole);
+ QVariant y = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data( Qt::EditRole);
+ QVariant z = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data( Qt::EditRole);
+ QVariant size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data( Qt::EditRole);
+ QVariant entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
+ QString groupName = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data( Qt::EditRole).toString();
+
+ clearEnforcedVertexWidgets();
+
+ if ( !x.isNull() || !entry.isNull()) {
+ QString toolTip = vertexName.toString();
+ toolTip += QString("(");
+ if (entry.isNull() || (!entry.isNull() && entry.toString() == "")) {
+ toolTip += x.toString();
+ toolTip += QString(", ") + y.toString();
+ toolTip += QString(", ") + z.toString();
+ }
+ else
+ toolTip += entry.toString();
+ toolTip += QString(")");
+
+ if (!size.isNull())
+ toolTip += QString("=") + size.toString();
+
+ if (!groupName.isEmpty())
+ toolTip += QString(" [") + groupName + QString("]");
+
+// MESSAGE("Tooltip: " << toolTip.toStdString());
+ for (int col=0;col<ENF_VER_NB_COLUMNS;col++)
+ myEnforcedTableWidget->item(row,col)->setToolTip(toolTip);
+
+ if (!x.isNull()) {
+ disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
+ disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
+ disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
+ myXCoord->SetValue(x.toDouble());
+ myYCoord->SetValue(y.toDouble());
+ myZCoord->SetValue(z.toDouble());
+ connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
+ connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
+ connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
+ }
+ if (!size.isNull())
+ mySizeValue->SetValue(size.toDouble());
+
+ if (!groupName.isEmpty())
+ myGroupName->setText(groupName);
+ }
+}
+
+void GHS3DPluginGUI_HypothesisCreator::onSelectEnforcedVertex() {
+ int nbSelEnfVertex = myEnfVertexWdg->NbObjects();
+ clearEnforcedVertexWidgets();
+ if (nbSelEnfVertex == 1)
+ {
+ if ( CORBA::is_nil( getGeomEngine() ) && !GeometryGUI::InitGeomGen() )
+ return ;
+
+ myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(nbSelEnfVertex-1);
+ if (myEnfVertex == GEOM::GEOM_Object::_nil())
+ return;
+ if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
+ GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
+ GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() );
+ if (CORBA::is_nil(measureOp))
+ return;
+
+ CORBA::Double x,y,z;
+ measureOp->PointCoordinates (myEnfVertex, x, y, z);
+ if ( measureOp->IsDone() )
+ {
+ disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
+ disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
+ disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
+ myXCoord->SetValue(x);
+ myYCoord->SetValue(y);
+ myZCoord->SetValue(z);
+ connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
+ connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
+ connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
}
}
-// MESSAGE("Not found x,y,z values: " << x << " " << y << " " << z);
- return false;
+ }
+}
+
+/** GHS3DPluginGUI_HypothesisCreator::synchronizeCoords()
+This method synchronizes the QLineEdit/SMESHGUI_SpinBox widgets content with the coordinates
+of the enforced vertex clicked in the tree widget.
+*/
+void GHS3DPluginGUI_HypothesisCreator::synchronizeCoords() {
+ clearEnforcedVertexWidgets();
+ QList<QTableWidgetItem *> items = myEnforcedTableWidget->selectedItems();
+// myEnfVertexWdg->disconnect(SIGNAL(contentModified()));
+ disconnect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
+ if (! items.isEmpty()) {
+ QTableWidgetItem *item;
+ int row;
+ QVariant entry;
+ if (items.size() == 1) {
+ item = items[0];
+ row = myEnforcedTableWidget->row(item);
+ QVariant x = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data( Qt::EditRole);
+ QVariant y = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data( Qt::EditRole);
+ QVariant z = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data( Qt::EditRole);
+ QVariant size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data( Qt::EditRole);
+ entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
+ if (!entry.isNull()) {
+ SMESH::string_array_var objIds = new SMESH::string_array;
+ objIds->length(1);
+ objIds[0] = entry.toString().toStdString().c_str();
+ myEnfVertexWdg->SetObjects(objIds);
+ }
+ else {
+ myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
+ }
+ QVariant group = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data( Qt::EditRole);
+ if (!x.isNull()/* && entry.isNull()*/) {
+// disconnect( myXCoord, SIGNAL( textChanged(const QString &)), this, SLOT( onSelectEnforcedVertex() ) );
+ disconnect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
+ disconnect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
+ disconnect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
+ myXCoord->SetValue(x.toDouble());
+ myYCoord->SetValue(y.toDouble());
+ myZCoord->SetValue(z.toDouble());
+ connect( myXCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
+ connect( myYCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
+ connect( myZCoord, SIGNAL( textChanged(const QString&) ), this, SLOT( clearEnfVertexSelection() ) );
+ }
+ if (!size.isNull())
+ mySizeValue->SetValue(size.toDouble());
+
+ if (!group.isNull() && (!x.isNull() || !entry.isNull()))
+ myGroupName->setText(group.toString());
+ }
+ else {
+ QList<QString> entryList;
+ for (int i = 0; i < items.size(); ++i) {
+ item = items[i];
+ row = myEnforcedTableWidget->row(item);
+ entry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data( Qt::EditRole);
+ if (!entry.isNull())
+ entryList << entry.toString();
+ }
+ if (entryList.size() > 0) {
+ SMESH::string_array_var objIds = new SMESH::string_array;
+ objIds->length(entryList.size());
+ for (int i = 0; i < entryList.size() ; i++)
+ objIds[i] = entryList.at(i).toStdString().c_str();
+ myEnfVertexWdg->SetObjects(objIds);
+ }
+ else {
+ myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
+ }
+ }
+ }
+ else {
+ myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
+ }
+ connect( myEnfVertexWdg, SIGNAL( contentModified()), this, SLOT( onSelectEnforcedVertex() ) );
+ GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
+ that->checkVertexIsDefined();
}
-bool GHS3DPluginGUI_HypothesisCreator::checkVertexIsDefined()
+/** GHS3DPluginGUI_HypothesisCreator::addEnforcedMesh( x, y, z, vertexName, geomEntry, groupName)
+This method adds in the tree widget an enforced mesh from mesh, submesh or group with optionally size and and groupName.
+*/
+void GHS3DPluginGUI_HypothesisCreator::addEnforcedMesh(std::string name, std::string entry, int elementType, double size, std::string groupName)
{
- bool val = (!myXCoord->text().isEmpty())&&(!myYCoord->text().isEmpty())&&(!myZCoord->text().isEmpty())&&(!mySizeValue->text().isEmpty());
- bool isDefined = val;
- if (val)
- isDefined = ! smpVertexExists(myXCoord->text().toDouble(),myYCoord->text().toDouble(),myZCoord->text().toDouble());
+ MESSAGE("addEnforcedMesh(\"" << name << ", \"" << entry << "\", " << elementType << ", " << size << ", \"" << groupName << "\")");
+ bool okToCreate = true;
+ QString itemEntry = "";
+ int itemElementType = 0;
+ int rowCount = myEnforcedMeshTableWidget->rowCount();
+ bool allColumns = true;
+ for (int row = 0;row<rowCount;row++) {
+ for (int col = 0 ; col < ENF_MESH_NB_COLUMNS ; col++) {
+ MESSAGE("col: " << col);
+ if (col == ENF_MESH_CONSTRAINT_COLUMN){
+ if (qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row, col)) == 0) {
+ allColumns = false;
+ MESSAGE("allColumns = false");
+ break;
+ }
+ }
+ else if (myEnforcedMeshTableWidget->item(row, col) == 0) {
+ allColumns = false;
+ MESSAGE("allColumns = false");
+ break;
+ }
+ if (col == ENF_MESH_CONSTRAINT_COLUMN) {
+ QComboBox* itemComboBox = qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row, col));
+ itemElementType = itemComboBox->currentIndex();
+ MESSAGE("itemElementType: " << itemElementType);
+ }
+ else if (col == ENF_MESH_ENTRY_COLUMN)
+ itemEntry = myEnforcedMeshTableWidget->item(row, col)->data(Qt::EditRole).toString();
+ }
+
+ if (!allColumns)
+ break;
+
+ if (itemEntry == QString(entry.c_str()) && itemElementType == elementType) {
+// // update size
+// if (itemSize != size) {
+// MESSAGE("Size is updated from \"" << itemSize << "\" to \"" << size << "\"");
+// myEnforcedMeshTableWidget->item(row, ENF_MESH_SIZE_COLUMN)->setData( Qt::EditRole, QVariant(size));
+// }
+// // update group name
+// if (itemGroupName.toStdString() != groupName) {
+// MESSAGE("Group is updated from \"" << itemGroupName.toStdString() << "\" to \"" << groupName << "\"");
+// myEnforcedMeshTableWidget->item(row, ENF_MESH_GROUP_COLUMN)->setData( Qt::EditRole, QVariant(groupName.c_str()));
+// }
+ okToCreate = false;
+ break;
+ } // if
+ } // for
- emit vertexDefined(isDefined);
- return isDefined;
+
+ if (!okToCreate)
+ return;
+
+ MESSAGE("Creation of enforced mesh");
+
+ myEnforcedMeshTableWidget->setRowCount(rowCount+1);
+ myEnforcedMeshTableWidget->setSortingEnabled(false);
+
+ for (int col=0;col<ENF_MESH_NB_COLUMNS;col++) {
+ MESSAGE("Column: " << col);
+ if (col == ENF_MESH_CONSTRAINT_COLUMN) {
+ QComboBox* comboBox = new QComboBox();
+ QPalette pal = comboBox->palette();
+ pal.setColor(QPalette::Button, Qt::white);
+ comboBox->setPalette(pal);
+ comboBox->insertItems(0,myEnfMeshConstraintLabels);
+ comboBox->setEditable(false);
+ comboBox->setCurrentIndex(elementType);
+ MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << comboBox->currentText().toStdString());
+ myEnforcedMeshTableWidget->setCellWidget(rowCount,col,comboBox);
+ }
+ else {
+ QTableWidgetItem* item = new QTableWidgetItem();
+ item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
+ switch (col) {
+ case ENF_MESH_NAME_COLUMN:
+ item->setData( 0, name.c_str() );
+ item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+ MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
+ myEnforcedMeshTableWidget->setItem(rowCount,col,item);
+ break;
+ case ENF_MESH_ENTRY_COLUMN:
+ item->setData( 0, entry.c_str() );
+ item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+ MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
+ myEnforcedMeshTableWidget->setItem(rowCount,col,item);
+ break;
+ case ENF_MESH_SIZE_COLUMN:
+ item->setData( 0, size );
+ MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
+ myEnforcedMeshTableWidget->setItem(rowCount,col,item);
+ break;
+ case ENF_MESH_GROUP_COLUMN:
+ item->setData( 0, groupName.c_str() );
+ MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
+ myEnforcedMeshTableWidget->setItem(rowCount,col,item);
+ break;
+ default:
+ break;
+ }
+ }
+ MESSAGE("Done");
+ }
+
+// connect( myEnforcedMeshTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
+
+ myEnforcedMeshTableWidget->setSortingEnabled(true);
+// myEnforcedTableWidget->setCurrentItem(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
+// updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
+
}
-void GHS3DPluginGUI_HypothesisCreator::onVertexBtnClicked()
+/** GHS3DPluginGUI_HypothesisCreator::addEnforcedVertex( x, y, z, size, vertexName, geomEntry, groupName)
+This method adds in the tree widget an enforced vertex with given size and coords (x,y,z) or GEOM vertex or compound and with optionally groupName.
+*/
+void GHS3DPluginGUI_HypothesisCreator::addEnforcedVertex(double x, double y, double z, double size, std::string vertexName, std::string geomEntry, std::string groupName, bool isCompound)
{
- MESSAGE("GHS3DPluginGUI_HypothesisCreator::onVertexBtnClicked()");
- const int row = mySmpModel->rowCount() ;
- double x = myXCoord->text().toDouble();
- double y = myYCoord->text().toDouble();
- double z = myZCoord->text().toDouble();
- double size = mySizeValue->text().toDouble();
+ MESSAGE("addEnforcedVertex(" << x << ", " << y << ", " << z << ", " << size << ", \"" << vertexName << ", \"" << geomEntry << "\", \"" << groupName << "\", " << isCompound << ")");
+ myEnforcedTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
+ bool okToCreate = true;
+ double itemX,itemY,itemZ,itemSize = 0;
+ QString itemEntry, itemGroupName = QString("");
+// bool itemIsCompound;
+ int rowCount = myEnforcedTableWidget->rowCount();
+ QVariant data;
+ bool allColumns;
+ for (int row = 0;row<rowCount;row++) {
+ allColumns = true;
+ for (int col = 0 ; col < ENF_VER_NB_COLUMNS ; col++) {
+ if (myEnforcedTableWidget->item(row, col) == 0) {
+ allColumns = false;
+ break;
+ }
+
+ data = myEnforcedTableWidget->item(row, col)->data(Qt::EditRole);
+ if (!data.isNull()) {
+ switch (col) {
+ case ENF_VER_GROUP_COLUMN:
+ itemGroupName = data.toString();
+ break;
+ case ENF_VER_ENTRY_COLUMN:
+ itemEntry = data.toString();
+ break;
+// case ENF_VER_COMPOUND_COLUMN:
+// itemIsCompound = data.toBool();
+// break;
+ case ENF_VER_X_COLUMN:
+ itemX = data.toDouble();
+ break;
+ case ENF_VER_Y_COLUMN:
+ itemY = data.toDouble();
+ break;
+ case ENF_VER_Z_COLUMN:
+ itemZ = data.toDouble();
+ break;
+ case ENF_VER_SIZE_COLUMN:
+ itemSize = data.toDouble();
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+ if (!allColumns)
+ break;
+
+
+ if (( !isCompound && ((itemX == x) && (itemY == y) && (itemZ == z))) || /*( (itemEntry.toStdString() != "") && */ (itemEntry.toStdString() == geomEntry)/*)*/) {
+ // update size
+ if (itemSize != size) {
+ MESSAGE("Size is updated from \"" << itemSize << "\" to \"" << size << "\"");
+ myEnforcedTableWidget->item(row, ENF_VER_SIZE_COLUMN)->setData( Qt::EditRole, QVariant(size));
+ }
+ // update group name
+ if (itemGroupName.toStdString() != groupName) {
+ MESSAGE("Group is updated from \"" << itemGroupName.toStdString() << "\" to \"" << groupName << "\"");
+ myEnforcedTableWidget->item(row, ENF_VER_GROUP_COLUMN)->setData( Qt::EditRole, QVariant(groupName.c_str()));
+ }
+ okToCreate = false;
+ break;
+ } // if
+ } // for
+ if (!okToCreate) {
+ if (geomEntry.empty()) {
+ MESSAGE("Vertex with coords " << x << ", " << y << ", " << z << " already exist: dont create again");
+ }
+ else {
+ MESSAGE("Vertex with entry " << geomEntry << " already exist: dont create again");
+ }
+ return;
+ }
- if (smpVertexExists(x,y,z)) return;
+ if (geomEntry.empty()) {
+ MESSAGE("Vertex with coords " << x << ", " << y << ", " << z<< " is created");
+ }
+ else {
+ MESSAGE("Vertex with geom entry " << geomEntry << " is created");
+ }
+
+ int vertexIndex=0;
+ int indexRef = -1;
+ QString myVertexName;
+ while(indexRef != vertexIndex) {
+ indexRef = vertexIndex;
+ if (vertexName.empty())
+ myVertexName = QString("Vertex #%1").arg(vertexIndex);
+ else
+ myVertexName = QString(vertexName.c_str());
+
+ for (int row = 0;row<rowCount;row++) {
+ QString name = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole).toString();
+ if (myVertexName == name) {
+ vertexIndex++;
+ break;
+ }
+ }
+ }
+
+ MESSAGE("myVertexName is \"" << myVertexName.toStdString() << "\"");
+ myEnforcedTableWidget->setRowCount(rowCount+1);
+ myEnforcedTableWidget->setSortingEnabled(false);
+ for (int col=0;col<ENF_VER_NB_COLUMNS;col++) {
+ MESSAGE("Column: " << col);
+ QTableWidgetItem* item = new QTableWidgetItem();
+ item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
+ switch (col) {
+ case ENF_VER_NAME_COLUMN:
+ item->setData( Qt::EditRole, myVertexName );
+ if (!geomEntry.empty()) {
+ if (isCompound)
+ item->setIcon(QIcon(iconCompound.scaled(iconCompound.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
+ else
+ item->setIcon(QIcon(iconVertex.scaled(iconVertex.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
+ }
+ break;
+ case ENF_VER_X_COLUMN:
+ if (!isCompound)
+ item->setData( 0, QVariant(x) );
+ break;
+ case ENF_VER_Y_COLUMN:
+ if (!isCompound)
+ item->setData( 0, QVariant(y) );
+ break;
+ case ENF_VER_Z_COLUMN:
+ if (!isCompound)
+ item->setData( 0, QVariant(z) );
+ break;
+ case ENF_VER_SIZE_COLUMN:
+ item->setData( 0, QVariant(size) );
+ break;
+ case ENF_VER_ENTRY_COLUMN:
+ if (!geomEntry.empty())
+ item->setData( 0, QString(geomEntry.c_str()) );
+ break;
+ case ENF_VER_COMPOUND_COLUMN:
+ item->setData( Qt::CheckStateRole, isCompound );
+ item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
+ break;
+ case ENF_VER_GROUP_COLUMN:
+ if (!groupName.empty())
+ item->setData( 0, QString(groupName.c_str()) );
+ break;
+ default:
+ break;
+ }
-// double size = 10.0;
- // ENF_VER_X_COLUMN
- mySmpModel->setData(mySmpModel->index(row, ENF_VER_X_COLUMN),x);
- mySmpModel->setItem( row, ENF_VER_X_COLUMN, new QStandardItem(QString::number(x)) );
- mySmpModel->item( row, ENF_VER_X_COLUMN )->setFlags( Qt::ItemIsSelectable );
- // ENF_VER_Y_COLUMN
- mySmpModel->setData(mySmpModel->index(row, ENF_VER_Y_COLUMN),y);
- mySmpModel->setItem( row, ENF_VER_Y_COLUMN, new QStandardItem(QString::number(y)) );
- mySmpModel->item( row, ENF_VER_Y_COLUMN )->setFlags( Qt::ItemIsSelectable );
- // ENF_VER_Z_COLUMN
- mySmpModel->setData(mySmpModel->index(row, ENF_VER_Z_COLUMN),z);
- mySmpModel->setItem( row, ENF_VER_Z_COLUMN, new QStandardItem(QString::number(z)) );
- mySmpModel->item( row, ENF_VER_Z_COLUMN )->setFlags( Qt::ItemIsSelectable );
- // ENF_VER_SIZE_COLUMN
- mySmpModel->setData(mySmpModel->index(row, ENF_VER_SIZE_COLUMN),size);
- mySmpModel->setItem( row, ENF_VER_SIZE_COLUMN, new QStandardItem(QString::number(size,'f')) );
-
- myEnforcedTableView->clearSelection();
- myEnforcedTableView->scrollTo( mySmpModel->item( row, ENF_VER_SIZE_COLUMN )->index() );
- checkVertexIsDefined();
-}
-
-void GHS3DPluginGUI_HypothesisCreator::onRemoveVertexBtnClicked()
-{
- QList<int> selectedRows;
- QList<QModelIndex> selectedIndex = myEnforcedTableView->selectionModel()->selectedIndexes();
- int row;
- QModelIndex index;
- foreach( index, selectedIndex ) {
- row = index.row();
- if ( !selectedRows.contains( row ) )
- selectedRows.append( row );
- }
- qSort( selectedRows );
- QListIterator<int> it( selectedRows );
- it.toBack();
- while ( it.hasPrevious() ) {
- row = it.previous();
- MESSAGE("delete row #"<< row);
- mySmpModel->removeRow(row );
- }
- myEnforcedTableView->clearSelection();
+ MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
+ myEnforcedTableWidget->setItem(rowCount,col,item);
+ MESSAGE("Done");
+ }
+
+ connect( myEnforcedTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
+
+ myEnforcedTableWidget->setSortingEnabled(true);
+// myEnforcedTableWidget->setCurrentItem(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
+ updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
+}
+
+/** GHS3DPluginGUI_HypothesisCreator::onAddEnforcedMesh()
+This method is called when a item is added into the enforced meshes tree widget
+*/
+void GHS3DPluginGUI_HypothesisCreator::onAddEnforcedMesh()
+{
+ MESSAGE("GHS3DPluginGUI_HypothesisCreator::onAddEnforcedMesh()");
+
+ GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
+
+ that->getGeomSelectionTool()->selectionMgr()->clearFilters();
+ myEnfMeshWdg->deactivateSelection();
+
+ for (int column = 0; column < myEnforcedMeshTableWidget->columnCount(); ++column)
+ myEnforcedMeshTableWidget->resizeColumnToContents(column);
+
+ // Vertex selection
+ int selEnfMeshes = myEnfMeshWdg->NbObjects();
+ if (selEnfMeshes == 0)
+ return;
+
+ std::string groupName = myMeshGroupName->text().toStdString();
+// if (myGlobalGroupName->isChecked())
+// groupName = myGlobalGroupName->text().toStdString();
+
+ if (boost::trim_copy(groupName).empty())
+ groupName = "";
+
+
+ double size = -1;
+ if (!myMeshSizeValue->GetString().isEmpty())
+ size = myMeshSizeValue->GetValue();
+// if (size < 0)
+// return;
+
+ int elementType = myEnfMeshConstraint->currentIndex();
+
+
+ _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+ _PTR(SObject) aSObj; //SMESH::SMESH_IDSource::_nil;
+ QString meshEntry = myEnfMeshWdg->GetValue();
+ MESSAGE("myEnfMeshWdg->GetValue()" << meshEntry.toStdString());
+
+ if (selEnfMeshes == 1)
+ {
+ MESSAGE("1 SMESH object selected");
+// myEnfMesh = myEnfMeshWdg->GetObject< SMESH::SMESH_IDSource >();
+// std::string entry = myEnfMeshWdg->GetValue();
+ aSObj = aStudy->FindObjectID(meshEntry.toStdString().c_str());
+ CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj,aStudy);
+ if (!CORBA::is_nil(anObj)) {
+// SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
+ addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, size, groupName);
+ }
+ }
+ else
+ {
+ MESSAGE(selEnfMeshes << " SMESH objects selected");
+ QStringList meshEntries = meshEntry.split(" ", QString::SkipEmptyParts);
+ QStringListIterator meshEntriesIt (meshEntries);
+ while (meshEntriesIt.hasNext()) {
+ aSObj = aStudy->FindObjectID(meshEntriesIt.next().toStdString().c_str());
+ CORBA::Object_var anObj = SMESH::SObjectToObject(aSObj,aStudy);
+ if (!CORBA::is_nil(anObj)) {
+// SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
+ addEnforcedMesh( aSObj->GetName(), aSObj->GetID(), elementType, size, groupName);
+ }
+ }
+ }
+
+ myEnfVertexWdg->SetObject(SMESH::SMESH_IDSource::_nil());
+
+ for (int column = 0; column < myEnforcedMeshTableWidget->columnCount(); ++column)
+ myEnforcedMeshTableWidget->resizeColumnToContents(column);
+}
+
+
+/** GHS3DPluginGUI_HypothesisCreator::onAddEnforcedVertex()
+This method is called when a item is added into the enforced vertices tree widget
+*/
+void GHS3DPluginGUI_HypothesisCreator::onAddEnforcedVertex()
+{
+ MESSAGE("GHS3DPluginGUI_HypothesisCreator::onAddEnforcedVertex()");
+
+ GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
+
+ that->getGeomSelectionTool()->selectionMgr()->clearFilters();
+ myEnfVertexWdg->deactivateSelection();
+
+ for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
+ myEnforcedTableWidget->resizeColumnToContents(column);
+
+ // Vertex selection
+ int selEnfVertex = myEnfVertexWdg->NbObjects();
+ bool coordsEmpty = (myXCoord->text().isEmpty()) || (myYCoord->text().isEmpty()) || (myZCoord->text().isEmpty());
+ if ((selEnfVertex == 0) && coordsEmpty)
+ return;
+
+ std::string groupName = myGroupName->text().toStdString();
+// if (myGlobalGroupName->isChecked())
+// groupName = myGlobalGroupName->text().toStdString();
+
+ if (boost::trim_copy(groupName).empty())
+ groupName = "";
+
+ double size = mySizeValue->GetValue();
+
+ if (selEnfVertex <= 1)
+ {
+ MESSAGE("0 or 1 GEOM object selected");
+ double x = 0, y = 0, z=0;
+ if (myXCoord->GetString() != "") {
+ x = myXCoord->GetValue();
+ y = myYCoord->GetValue();
+ z = myZCoord->GetValue();
+ }
+ if (selEnfVertex == 1) {
+ MESSAGE("1 GEOM object selected");
+ myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >();
+ std::string entry = "";
+ if (myEnfVertex != GEOM::GEOM_Object::_nil())
+ entry = myEnfVertex->GetStudyEntry();
+ addEnforcedVertex(x, y, z, size, myEnfVertex->GetName(),entry, groupName, myEnfVertex->GetShapeType() == GEOM::COMPOUND);
+ }
+ else {
+ MESSAGE("0 GEOM object selected");
+ MESSAGE("Coords: ("<<x<<","<<y<<","<<z<<")");
+ addEnforcedVertex(x, y, z, size, "", "", groupName);
+ }
+ }
+ else
+ {
+ if ( CORBA::is_nil(getGeomEngine()))
+ return;
+
+ GEOM::GEOM_IMeasureOperations_var measureOp = getGeomEngine()->GetIMeasureOperations( that->getGeomSelectionTool()->getMyStudy()->StudyId() );
+ if (CORBA::is_nil(measureOp))
+ return;
+
+ CORBA::Double x = 0, y = 0,z = 0;
+ for (int j = 0 ; j < selEnfVertex ; j++)
+ {
+ myEnfVertex = myEnfVertexWdg->GetObject< GEOM::GEOM_Object >(j);
+ if (myEnfVertex == GEOM::GEOM_Object::_nil())
+ continue;
+ if (myEnfVertex->GetShapeType() == GEOM::VERTEX) {
+ measureOp->PointCoordinates (myEnfVertex, x, y, z);
+ if ( measureOp->IsDone() )
+ addEnforcedVertex(x, y, z, size, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName);
+ } else if (myEnfVertex->GetShapeType() == GEOM::COMPOUND) {
+ addEnforcedVertex(0., 0., 0., size, myEnfVertex->GetName(),myEnfVertex->GetStudyEntry(), groupName, true);
+ }
+ }
+ }
+
+ myEnfVertexWdg->SetObject(GEOM::GEOM_Object::_nil());
+
+ for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
+ myEnforcedTableWidget->resizeColumnToContents(column);
+}
+
+/** GHS3DPluginGUI_HypothesisCreator::onRemoveEnforcedMesh()
+This method is called when a item is removed from the enforced meshes tree widget
+*/
+void GHS3DPluginGUI_HypothesisCreator::onRemoveEnforcedMesh()
+{
+ QList<int> selectedRows;
+ QList<QTableWidgetItem *> selectedItems = myEnforcedMeshTableWidget->selectedItems();
+ QTableWidgetItem* item;
+ int row;
+ foreach( item, selectedItems ) {
+ row = item->row();
+ if (!selectedRows.contains( row ) )
+ selectedRows.append(row);
+ }
+
+ qSort( selectedRows );
+ QListIterator<int> it( selectedRows );
+ it.toBack();
+ while ( it.hasPrevious() ) {
+ row = it.previous();
+ MESSAGE("delete row #"<< row);
+ myEnforcedMeshTableWidget->removeRow(row );
+ }
+
+ myEnforcedMeshTableWidget->selectionModel()->clearSelection();
}
+
+/** GHS3DPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
+This method is called when a item is removed from the enforced vertices tree widget
+*/
+void GHS3DPluginGUI_HypothesisCreator::onRemoveEnforcedVertex()
+{
+ QList<int> selectedRows;
+ QList<QTableWidgetItem *> selectedItems = myEnforcedTableWidget->selectedItems();
+ QTableWidgetItem* item;
+ int row;
+ foreach( item, selectedItems ) {
+ row = item->row();
+ if (!selectedRows.contains( row ) )
+ selectedRows.append(row);
+ }
+
+ qSort( selectedRows );
+ QListIterator<int> it( selectedRows );
+ it.toBack();
+ while ( it.hasPrevious() ) {
+ row = it.previous();
+ MESSAGE("delete row #"<< row);
+ myEnforcedTableWidget->removeRow(row );
+ }
+
+ myEnforcedTableWidget->selectionModel()->clearSelection();
+}
+
void GHS3DPluginGUI_HypothesisCreator::onDirBtnClicked()
{
QString dir = SUIT_FileDlg::getExistingDirectory( dlg(), myWorkingDir->text(), QString() );
void GHS3DPluginGUI_HypothesisCreator::retrieveParams() const
{
MESSAGE("GHS3DPluginGUI_HypothesisCreator::retrieveParams");
+ GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
GHS3DHypothesisData data;
readParamsFromHypo( data );
myTextOption ->setText ( data.myTextOption );
TEnfVertexList::const_iterator it;
- int row = 0;
+ int rowCount = 0;
+ myEnforcedTableWidget->setSortingEnabled(false);
+ myEnforcedTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
for(it = data.myEnforcedVertices.begin() ; it != data.myEnforcedVertices.end(); it++ )
{
TEnfVertex* enfVertex = (*it);
- if (enfVertex->coords.size()) {
- double x = enfVertex->coords.at(0);
- double y = enfVertex->coords.at(1);
- double z = enfVertex->coords.at(2);
- double size = enfVertex->size;
- // ENF_VER_X_COLUMN
- mySmpModel->setData(mySmpModel->index(row, ENF_VER_X_COLUMN),x);
- mySmpModel->setItem( row, ENF_VER_X_COLUMN, new QStandardItem(QString::number(x)) );
- mySmpModel->item( row, ENF_VER_X_COLUMN )->setFlags( Qt::ItemIsSelectable );
- // ENF_VER_Y_COLUMN
- mySmpModel->setData(mySmpModel->index(row, ENF_VER_Y_COLUMN),y);
- mySmpModel->setItem( row, ENF_VER_Y_COLUMN, new QStandardItem(QString::number(y)) );
- mySmpModel->item( row, ENF_VER_Y_COLUMN )->setFlags( Qt::ItemIsSelectable );
- // ENF_VER_Z_COLUMN
- mySmpModel->setData(mySmpModel->index(row, ENF_VER_Z_COLUMN),z);
- mySmpModel->setItem( row, ENF_VER_Z_COLUMN, new QStandardItem(QString::number(z)) );
- mySmpModel->item( row, ENF_VER_Z_COLUMN )->setFlags( Qt::ItemIsSelectable );
- // ENF_VER_SIZE_COLUMN
- mySmpModel->setData(mySmpModel->index(row, ENF_VER_SIZE_COLUMN),size);
- mySmpModel->setItem( row, ENF_VER_SIZE_COLUMN, new QStandardItem(QString::number(size)) );
-
- MESSAGE("Row " << row << ": (" << x << ","<< y << ","<< z << ") ="<< size);
- row++;
+ myEnforcedTableWidget->setRowCount(rowCount+1);
+
+ for (int col=0;col<ENF_VER_NB_COLUMNS;col++) {
+ MESSAGE("Column: " << col);
+// MESSAGE("enfVertex->isCompound: " << enfVertex->isCompound);
+ QTableWidgetItem* item = new QTableWidgetItem();
+ item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
+ switch (col) {
+ case ENF_VER_NAME_COLUMN:
+ item->setData( 0, enfVertex->name.c_str() );
+ if (!enfVertex->geomEntry.empty()) {
+ if (enfVertex->isCompound)
+ item->setIcon(QIcon(iconCompound.scaled(iconCompound.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
+ else
+ item->setIcon(QIcon(iconVertex.scaled(iconVertex.size()*0.7,Qt::KeepAspectRatio,Qt::SmoothTransformation)));
+
+ MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
+ }
+ break;
+ case ENF_VER_X_COLUMN:
+ if (!enfVertex->isCompound) {
+ item->setData( 0, enfVertex->coords.at(0) );
+ MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
+ }
+ break;
+ case ENF_VER_Y_COLUMN:
+ if (!enfVertex->isCompound) {
+ item->setData( 0, enfVertex->coords.at(1) );
+ MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
+ }
+ break;
+ case ENF_VER_Z_COLUMN:
+ if (!enfVertex->isCompound) {
+ item->setData( 0, enfVertex->coords.at(2) );
+ MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
+ }
+ break;
+ case ENF_VER_SIZE_COLUMN:
+ item->setData( 0, enfVertex->size );
+ MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
+ break;
+ case ENF_VER_ENTRY_COLUMN:
+ item->setData( 0, enfVertex->geomEntry.c_str() );
+ MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
+ break;
+ case ENF_VER_COMPOUND_COLUMN:
+ item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable);
+ item->setData( Qt::CheckStateRole, enfVertex->isCompound );
+ MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << enfVertex->isCompound);
+ break;
+ case ENF_VER_GROUP_COLUMN:
+ item->setData( 0, enfVertex->groupName.c_str() );
+ MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
+ break;
+ default:
+ break;
+ }
+
+ myEnforcedTableWidget->setItem(rowCount,col,item);
+ MESSAGE("Done");
}
+ that->updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
+ rowCount++;
}
+
+ connect( myEnforcedTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
+ myEnforcedTableWidget->setSortingEnabled(true);
+
+ for (int column = 0; column < myEnforcedTableWidget->columnCount(); ++column)
+ myEnforcedTableWidget->resizeColumnToContents(column);
+
+ // Update Enforced meshes QTableWidget
+ TEnfMeshList::const_iterator itMesh;
+ rowCount = 0;
+ myEnforcedMeshTableWidget->setSortingEnabled(false);
+// myEnforcedMeshTableWidget->disconnect(SIGNAL( itemChanged(QTableWidgetItem *)));
+ for(itMesh = data.myEnforcedMeshes.begin() ; itMesh != data.myEnforcedMeshes.end(); itMesh++ )
+ {
+ TEnfMesh* enfMesh = (*itMesh);
+ myEnforcedMeshTableWidget->setRowCount(rowCount+1);
+
+ for (int col=0;col<ENF_MESH_NB_COLUMNS;col++) {
+ MESSAGE("Column: " << col);
+ if (col == ENF_MESH_CONSTRAINT_COLUMN) {
+ QComboBox* comboBox = new QComboBox();
+ QPalette pal = comboBox->palette();
+ pal.setColor(QPalette::Button, Qt::white);
+ comboBox->setPalette(pal);
+ comboBox->insertItems(0,myEnfMeshConstraintLabels);
+ comboBox->setEditable(false);
+ comboBox->setCurrentIndex(enfMesh->elementType);
+ MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << comboBox->currentText().toStdString());
+ myEnforcedMeshTableWidget->setCellWidget(rowCount,col,comboBox);
+ }
+ else {
+ QTableWidgetItem* item = new QTableWidgetItem();
+ item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled);
+ switch (col) {
+ case ENF_MESH_NAME_COLUMN:
+ item->setData( 0, enfMesh->name.c_str() );
+ item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+ MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
+ myEnforcedMeshTableWidget->setItem(rowCount,col,item);
+ break;
+ case ENF_MESH_ENTRY_COLUMN:
+ item->setData( 0, enfMesh->entry.c_str() );
+ item->setFlags( Qt::ItemIsSelectable | Qt::ItemIsEnabled);
+ MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
+ myEnforcedMeshTableWidget->setItem(rowCount,col,item);
+ break;
+ case ENF_MESH_SIZE_COLUMN:
+ item->setData( 0, enfMesh->size );
+ MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
+ myEnforcedMeshTableWidget->setItem(rowCount,col,item);
+ break;
+ case ENF_MESH_GROUP_COLUMN:
+ item->setData( 0, enfMesh->groupName.c_str() );
+ MESSAGE("Add item in table at (" << rowCount << "," << col << "): " << item->text().toStdString());
+ myEnforcedMeshTableWidget->setItem(rowCount,col,item);
+ break;
+ default:
+ break;
+ }
+ }
+
+// myEnforcedMeshTableWidget->setItem(rowCount,col,item);
+ MESSAGE("Done");
+ }
+// that->updateEnforcedVertexValues(myEnforcedTableWidget->item(rowCount,ENF_VER_NAME_COLUMN));
+ rowCount++;
+ }
+
+// connect( myEnforcedMeshTableWidget,SIGNAL( itemChanged(QTableWidgetItem *)), this, SLOT( updateEnforcedVertexValues(QTableWidgetItem *) ) );
+ myEnforcedMeshTableWidget->setSortingEnabled(true);
+
+ for (int col=0;col<ENF_MESH_NB_COLUMNS;col++)
+ myEnforcedMeshTableWidget->resizeColumnToContents(col);
- GHS3DPluginGUI_HypothesisCreator* that = (GHS3DPluginGUI_HypothesisCreator*)this;
that->updateWidgets();
+ that->checkVertexIsDefined();
}
QString GHS3DPluginGUI_HypothesisCreator::storeParams() const
valStr += " ";
valStr += data.myTextOption;
- valStr += " #BEGIN ENFORCED VERTICES#";
- // Add size map parameters storage
- for (int i=0 ; i<mySmpModel->rowCount() ; i++) {
- valStr += " (";
- double x = mySmpModel->data(mySmpModel->index(i,ENF_VER_X_COLUMN)).toDouble();
- double y = mySmpModel->data(mySmpModel->index(i,ENF_VER_Y_COLUMN)).toDouble();
- double z = mySmpModel->data(mySmpModel->index(i,ENF_VER_Z_COLUMN)).toDouble();
- double size = mySmpModel->data(mySmpModel->index(i,ENF_VER_SIZE_COLUMN)).toDouble();
- valStr += QString::number( x );
- valStr += ",";
- valStr += QString::number( y );
- valStr += ",";
- valStr += QString::number( z );
- valStr += ")=";
- valStr += QString::number( size );
- if (i!=mySmpModel->rowCount()-1)
- valStr += ";";
- }
- valStr += " #END ENFORCED VERTICES#";
- MESSAGE(valStr.toStdString());
+// valStr += " #BEGIN ENFORCED VERTICES#";
+// // Add size map parameters storage
+// for (int i=0 ; i<mySmpModel->rowCount() ; i++) {
+// valStr += " (";
+// double x = mySmpModel->data(mySmpModel->index(i,ENF_VER_X_COLUMN)).toDouble();
+// double y = mySmpModel->data(mySmpModel->index(i,ENF_VER_Y_COLUMN)).toDouble();
+// double z = mySmpModel->data(mySmpModel->index(i,ENF_VER_Z_COLUMN)).toDouble();
+// double size = mySmpModel->data(mySmpModel->index(i,ENF_VER_SIZE_COLUMN)).toDouble();
+// valStr += QString::number( x );
+// valStr += ",";
+// valStr += QString::number( y );
+// valStr += ",";
+// valStr += QString::number( z );
+// valStr += ")=";
+// valStr += QString::number( size );
+// if (i!=mySmpModel->rowCount()-1)
+// valStr += ";";
+// }
+// valStr += " #END ENFORCED VERTICES#";
+// MESSAGE(valStr.toStdString());
return valStr;
}
myVertex->geomEntry = CORBA::string_dup(vertices[i].geomEntry.in());
myVertex->groupName = CORBA::string_dup(vertices[i].groupName.in());
myVertex->size = vertices[i].size;
+ myVertex->isCompound = vertices[i].isCompound;
if (vertices[i].coords.length()) {
for (int c = 0; c < vertices[i].coords.length() ; c++)
myVertex->coords.push_back(vertices[i].coords[c]);
}
h_data.myEnforcedVertices.insert(myVertex);
}
+
+ GHS3DPlugin::GHS3DEnforcedMeshList_var enfMeshes = h->GetEnforcedMeshes();
+ MESSAGE("enfMeshes->length(): " << enfMeshes->length());
+ h_data.myEnforcedMeshes.clear();
+ for (int i=0 ; i<enfMeshes->length() ; i++) {
+ TEnfMesh* myEnfMesh = new TEnfMesh();
+ myEnfMesh->name = CORBA::string_dup(enfMeshes[i].name.in());
+ myEnfMesh->entry = CORBA::string_dup(enfMeshes[i].entry.in());
+ myEnfMesh->groupName = CORBA::string_dup(enfMeshes[i].groupName.in());
+ myEnfMesh->size = enfMeshes[i].size;
+ switch (enfMeshes[i].elementType) {
+ case SMESH::NODE:
+ myEnfMesh->elementType = 0;
+ break;
+ case SMESH::EDGE:
+ myEnfMesh->elementType = 1;
+ break;
+ case SMESH::FACE:
+ myEnfMesh->elementType = 2;
+ break;
+ }
+// myEnfMesh->elementType = enfMeshes[i].elementType;
+ h_data.myEnforcedMeshes.insert(myEnfMesh);
+ }
return true;
}
if ( h->GetTextOption() != h_data.myTextOption )
h->SetTextOption ( h_data.myTextOption.toLatin1().constData() );
+ // Enforced vertices
int nbVertex = (int) h_data.myEnforcedVertices.size();
GHS3DPlugin::GHS3DEnforcedVertexList_var vertexHyp = h->GetEnforcedVertices();
int nbVertexHyp = vertexHyp->length();
MESSAGE("Store params for size maps: " << nbVertex << " enforced vertices");
MESSAGE("h->GetEnforcedVertices()->length(): " << nbVertexHyp);
- // Some vertices were removed
- if (nbVertex < nbVertexHyp) {
-// if (nbVertex == 0)
-// h->ClearEnforcedVertices();
-// else {
- // iterate over vertices of hypo
- for(int i = 0 ; i <nbVertexHyp ; i++) {
- if (vertexHyp[i].coords.length()) {
- double x = vertexHyp[i].coords[0];
- double y = vertexHyp[i].coords[1];
- double z = vertexHyp[i].coords[2];
- // vertex is removed
- if (!smpVertexExists(x,y,z))
- h->RemoveEnforcedVertex(x,y,z);
- }
- }
-// }
- }
+ // 1. Clear all enforced vertices in hypothesis
+ // 2. Add new enforced vertex according to h_data
+ if ( nbVertexHyp > 0)
+ h->ClearEnforcedVertices();
TEnfVertexList::const_iterator it;
+ double x = 0, y = 0, z = 0;
for(it = h_data.myEnforcedVertices.begin() ; it != h_data.myEnforcedVertices.end(); it++ ) {
TEnfVertex* enfVertex = (*it);
+ x =y =z = 0;
if (enfVertex->coords.size()) {
- double x = enfVertex->coords.at(0);
- double y = enfVertex->coords.at(1);
- double z = enfVertex->coords.at(2);
- double size = enfVertex->size;
- MESSAGE("(" << x << ", "
- << y << ", "
- << z << ") = "
- << size );
- double mySize;
- try {
- mySize = h->GetEnforcedVertex(x,y,z);
- MESSAGE("Old size: " << mySize);
- if (mySize != size) {
- MESSAGE("Setting new size: " << size);
- h->SetEnforcedVertex(x,y,z,size);
- }
- }
- catch (...) {
- MESSAGE("Setting new size: " << size);
- h->SetEnforcedVertex( x, y, z, size);
- }
+ x = enfVertex->coords.at(0);
+ y = enfVertex->coords.at(1);
+ z = enfVertex->coords.at(2);
}
- }
- }
+ ok = h->p_SetEnforcedVertex( enfVertex->size, x, y, z, enfVertex->name.c_str(), enfVertex->geomEntry.c_str(), enfVertex->groupName.c_str(), enfVertex->isCompound);
+ } // for
+
+ // Enforced Meshes
+ int nbEnfMeshes = (int) h_data.myEnforcedMeshes.size();
+ GHS3DPlugin::GHS3DEnforcedMeshList_var enfMeshListHyp = h->GetEnforcedMeshes();
+ int nbEnfMeshListHyp = enfMeshListHyp->length();
+
+ MESSAGE("Store params for size maps: " << nbEnfMeshes << " enforced meshes");
+ MESSAGE("h->GetEnforcedMeshes()->length(): " << nbEnfMeshListHyp);
+
+ // 1. Clear all enforced vertices in hypothesis
+ // 2. Add new enforced vertex according to h_data
+ if ( nbEnfMeshListHyp > 0)
+ h->ClearEnforcedMeshes();
+
+ TEnfMeshList::const_iterator itEnfMesh;
+ _PTR(Study) aStudy = SMESH::GetActiveStudyDocument();
+ for(itEnfMesh = h_data.myEnforcedMeshes.begin() ; itEnfMesh != h_data.myEnforcedMeshes.end(); itEnfMesh++ ) {
+ TEnfMesh* enfMesh = (*itEnfMesh);
+
+ _PTR(SObject) aSObj = aStudy->FindObjectID(enfMesh->entry.c_str());
+ SMESH::SMESH_IDSource_var theSource = SMESH::SObjectToInterface<SMESH::SMESH_IDSource>( aSObj );
+ SMESH::ElementType elementType;
+ switch(enfMesh->elementType) {
+ case 0:
+ elementType = SMESH::NODE;
+ case 1:
+ elementType = SMESH::EDGE;
+ case 2:
+ elementType = SMESH::FACE;
+ }
+
+ ok = h->p_SetEnforcedMesh(theSource, elementType, enfMesh->size, enfMesh->groupName.c_str());
+ } // for
+ } // try
+// catch(const std::exception& ex) {
+// std::cout << "Exception: " << ex.what() << std::endl;
+// throw ex;
+// }
catch ( const SALOME::SALOME_Exception& ex )
{
SalomeApp_Tools::QtCatchCorbaException( ex );
h_data.myBoundaryRecovery = myBoundaryRecoveryCheck->isChecked();
h_data.myFEMCorrection = myFEMCorrectionCheck->isChecked();
h_data.myTextOption = myTextOption->text();
+
+ // Enforced vertices
h_data.myEnforcedVertices.clear();
-
- for (int i=0 ; i<mySmpModel->rowCount() ; i++) {
+ QVariant valueX, valueY, valueZ;
+ for (int row=0 ; row<myEnforcedTableWidget->rowCount() ; row++) {
+
TEnfVertex *myVertex = new TEnfVertex();
- myVertex->name = "";
- myVertex->geomEntry = "";
- myVertex->groupName = "";
- myVertex->coords.push_back(mySmpModel->data(mySmpModel->index(i,ENF_VER_X_COLUMN)).toDouble());
- myVertex->coords.push_back(mySmpModel->data(mySmpModel->index(i,ENF_VER_Y_COLUMN)).toDouble());
- myVertex->coords.push_back(mySmpModel->data(mySmpModel->index(i,ENF_VER_Z_COLUMN)).toDouble());
- myVertex->size = mySmpModel->data(mySmpModel->index(i,ENF_VER_SIZE_COLUMN)).toDouble();
- MESSAGE("Add new enforced vertex (" << myVertex->coords.at(0) << ", "
- << myVertex->coords.at(1) << ", "
- << myVertex->coords.at(2) << ") = "
- << myVertex->size);
+ myVertex->name = myEnforcedTableWidget->item(row,ENF_VER_NAME_COLUMN)->data(Qt::EditRole).toString().toStdString();
+ MESSAGE("Add new enforced vertex \"" << myVertex->name << "\"" );
+ myVertex->geomEntry = myEnforcedTableWidget->item(row,ENF_VER_ENTRY_COLUMN)->data(Qt::EditRole).toString().toStdString();
+ if (myVertex->geomEntry.size())
+ MESSAGE("Geom entry is \"" << myVertex->geomEntry << "\"" );
+ myVertex->groupName = myEnforcedTableWidget->item(row,ENF_VER_GROUP_COLUMN)->data(Qt::EditRole).toString().toStdString();
+ if (myVertex->groupName.size())
+ MESSAGE("Group name is \"" << myVertex->groupName << "\"" );
+ valueX = myEnforcedTableWidget->item(row,ENF_VER_X_COLUMN)->data(Qt::EditRole);
+ valueY = myEnforcedTableWidget->item(row,ENF_VER_Y_COLUMN)->data(Qt::EditRole);
+ valueZ = myEnforcedTableWidget->item(row,ENF_VER_Z_COLUMN)->data(Qt::EditRole);
+ if (!valueX.isNull() && !valueY.isNull() && !valueZ.isNull()) {
+ myVertex->coords.push_back(valueX.toDouble());
+ myVertex->coords.push_back(valueY.toDouble());
+ myVertex->coords.push_back(valueZ.toDouble());
+ MESSAGE("Coords are (" << myVertex->coords.at(0) << ", "
+ << myVertex->coords.at(1) << ", "
+ << myVertex->coords.at(2) << ")");
+ }
+ myVertex->size = myEnforcedTableWidget->item(row,ENF_VER_SIZE_COLUMN)->data(Qt::EditRole).toDouble();
+ MESSAGE("Size is " << myVertex->size);
+ myVertex->isCompound = myEnforcedTableWidget->item(row,ENF_VER_COMPOUND_COLUMN)->data(Qt::CheckStateRole).toBool();
+ MESSAGE("Is compound ? " << myVertex->isCompound);
h_data.myEnforcedVertices.insert(myVertex);
}
+
+ // Enforced meshes
+ h_data.myEnforcedMeshes.clear();
+ for (int row=0 ; row<myEnforcedMeshTableWidget->rowCount() ; row++) {
+
+ TEnfMesh *myEnfMesh = new TEnfMesh();
+ myEnfMesh->name = myEnforcedMeshTableWidget->item(row,ENF_MESH_NAME_COLUMN)->data(Qt::EditRole).toString().toStdString();
+ MESSAGE("Add new enforced mesh \"" << myEnfMesh->name << "\"" );
+ myEnfMesh->entry = myEnforcedMeshTableWidget->item(row,ENF_MESH_ENTRY_COLUMN)->data(Qt::EditRole).toString().toStdString();
+ MESSAGE("Entry is \"" << myEnfMesh->entry << "\"" );
+ myEnfMesh->groupName = myEnforcedMeshTableWidget->item(row,ENF_MESH_GROUP_COLUMN)->data(Qt::EditRole).toString().toStdString();
+ MESSAGE("Group name is \"" << myEnfMesh->groupName << "\"" );
+ myEnfMesh->size = myEnforcedMeshTableWidget->item(row,ENF_MESH_SIZE_COLUMN)->data(Qt::EditRole).toDouble();
+ MESSAGE("Size is " << myEnfMesh->size);
+ QComboBox* combo = qobject_cast<QComboBox*>(myEnforcedMeshTableWidget->cellWidget(row,ENF_MESH_CONSTRAINT_COLUMN));
+ myEnfMesh->elementType = combo->currentIndex();
+ MESSAGE("Element type: " << myEnfMesh->elementType);
+ h_data.myEnforcedMeshes.insert(myEnfMesh);
+ }
return true;
}
{
return "ghs3d_hypo_page.html";
}
-
-//=============================================================================
-/*! GetHypothesisCreator
- *
- */
-//=============================================================================
-extern "C"
-{
- GHS3DPLUGINGUI_EXPORT
- SMESHGUI_GenericHypothesisCreator* GetHypothesisCreator( const QString& aHypType )
- {
- if ( aHypType == "GHS3D_Parameters" )
- return new GHS3DPluginGUI_HypothesisCreator( aHypType );
- return 0;
- }
-}