+
+ void
+ CreatePlot(SalomeApp_Module* theModule,
+ _PTR(SObject) theTableSO)
+ {
+ if ( IsSObjectTable(theTableSO) ) {
+ CORBA::Object_var aTable = VISU::ClientSObjectToObject(theTableSO);
+ CORBA::Object_var aContainer = GetVisuGen( theModule )->CreateContainer();
+ if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) {
+ VISU::Table_i* pTable = dynamic_cast<VISU::Table_i*>(VISU::GetServant(aTable).in());
+ VISU::Container_i* pContainer = dynamic_cast<VISU::Container_i*>(VISU::GetServant(aContainer).in());
+
+ if ( pContainer && pTable ) {
+ for ( int i = 2; i <= pTable->GetNbRows(); i++ ) {
+ CORBA::Object_var aNewCurve = GetVisuGen( theModule )->CreateCurve( pTable->_this(), 1, i );
+ if( !CORBA::is_nil( aNewCurve ) ) {
+ VISU::Curve_i* pCrv = dynamic_cast<VISU::Curve_i*>( VISU::GetServant(aNewCurve).in() );
+ if ( pCrv ) {
+ pContainer->AddCurve( pCrv->_this() );
+ }
+ }
+ }
+ PlotContainer( theModule, pContainer, VISU::eDisplay );
+ }
+ }
+ }
+ }
+
+ //************************************************************
+ // Others
+
+ void CreateMesh (const SalomeApp_Module* theModule,
+ const Handle(SALOME_InteractiveObject)& theIO)
+ {
+ _PTR(Study) aStudy = GetCStudy(GetAppStudy(theModule));
+ //if (CheckLock(aStudy))
+ // return;
+
+ _PTR(SObject) aResultSObj = aStudy->FindObjectID(theIO->getEntry());
+
+ // Get VISU::Result
+ VISU::Result_var aResult;
+ VISU::Result_i* pResult = CheckResult(theModule, aResultSObj, aResult);
+ if (pResult == NULL)
+ return;
+
+ Storable::TRestoringMap aMap = getMapOfValue(aResultSObj);
+ bool isExist;
+ string aComment = Storable::FindValue(aMap,"myComment",&isExist).latin1();
+ if (!isExist)
+ return;
+
+ CORBA::Object_var aMesh;
+ string aMeshName = Storable::FindValue(aMap,"myMeshName").latin1();
+#ifdef CHECKTIME
+ Utils_Timer timer;
+ timer.Start();
+#endif
+ if (aComment == "ENTITY") {
+ VISU::Entity anEntity = (VISU::Entity)Storable::FindValue(aMap,"myId").toInt();
+ if (VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),anEntity))
+ aMesh = GetVisuGen(theModule)->MeshOnEntity(aResult,aMeshName.c_str(),anEntity);
+ } else if (aComment == "FAMILY") {
+ VISU::Entity anEntity = (VISU::Entity)Storable::FindValue(aMap,"myEntityId").toInt();
+ string aFamilyName = Storable::FindValue(aMap,"myName").latin1();
+ if (VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),anEntity,aFamilyName.c_str()))
+ aMesh = GetVisuGen(theModule)->FamilyMeshOnEntity
+ (aResult,aMeshName.c_str(),anEntity,aFamilyName.c_str());
+ } else if (aComment == "GROUP") {
+ string aGroupName = Storable::FindValue(aMap,"myName").latin1();
+ if (VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),aGroupName.c_str()))
+ aMesh = GetVisuGen(theModule)->GroupMesh(aResult,aMeshName.c_str(),aGroupName.c_str());
+ }
+#ifdef CHECKTIME
+ timer.Stop();
+ MESSAGE("VisuGUI::CreateMesh() - CREATE MESH");
+ timer.Show();
+#endif
+
+ QApplication::restoreOverrideCursor();
+ VISU::Mesh_i* pPresent = NULL;
+ if (!CORBA::is_nil(aMesh))
+ pPresent = dynamic_cast<VISU::Mesh_i*>(VISU::GetServant(aMesh).in());
+ if (pPresent == NULL) {
+ SUIT_MessageBox::warn1 (GetDesktop(theModule),
+ QObject::tr("WRN_VISU"),
+ QObject::tr("ERR_CANT_BUILD_PRESENTATION"),
+ QObject::tr("BUT_OK"));
+ return;
+ }
+
+ if (SVTK_ViewWindow* aView = GetViewWindow(theModule)) {
+ try {
+#ifdef CHECKTIME
+ Utils_Timer timer;
+ timer.Start();
+#endif
+ PublishInView(theModule, pPresent);
+ aView->onFitAll();
+#ifdef CHECKTIME
+ timer.Stop();
+ MESSAGE("VisuGUI::CreateMesh() - DISPLAY MESH");
+ timer.Show();
+#endif
+ theModule->application()->putInfo(QObject::tr("INF_DONE"));
+ // Make "Save" button active
+ theModule->getApp()->updateActions();
+ } catch (std::runtime_error& exc) {
+ INFOS(exc.what());
+ SUIT_MessageBox::warn1 (GetDesktop(theModule),
+ QObject::tr("WRN_VISU"),
+ QObject::tr("ERR_CANT_CREATE_ACTOR") + " " + QObject::tr(exc.what()),
+ QObject::tr("BUT_OK"));
+ }
+ }
+ }
+
+ // ========================================================================================
+ // GetPrs3dList: find list of presentations for the given object
+ // ========================================================================================
+ std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
+ const Handle(SALOME_InteractiveObject)& theIO)
+ {
+ std::vector<VISU::Prs3d_i*> aList;
+ if (!theIO.IsNull() && theIO->hasEntry()) {
+ _PTR(Study) aCStudy = GetCStudy(GetAppStudy(theModule));
+ _PTR(SObject) aSObject = aCStudy->FindObjectID(theIO->getEntry());
+ aList = GetPrs3dList(theModule, aSObject);
+ }
+ return aList;
+ }
+
+ std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
+ _PTR(SObject) theObject)
+ {
+ std::vector<VISU::Prs3d_i*> aList; int k = 0;
+ if (!theObject)
+ return aList;
+
+ _PTR(Study) aCStudy = GetCStudy(GetAppStudy(theModule));
+
+ CORBA::Object_var aCORBAObject = VISU::ClientSObjectToObject(theObject);
+ if (!CORBA::is_nil(aCORBAObject)) {
+ VISU::Base_var aVisuObj = VISU::Base::_narrow(aCORBAObject);
+ if (!CORBA::is_nil(aVisuObj)) {
+ VISU::VISUType aType = aVisuObj->GetType();
+ switch (aType) {
+ case VISU::TSCALARMAP:
+ case VISU::TISOSURFACE:
+ case VISU::TDEFORMEDSHAPE:
+ case VISU::TCUTPLANES:
+ case VISU::TCUTLINES:
+ case VISU::TVECTORS:
+ case VISU::TSTREAMLINES:
+ case VISU::TPLOT3D:
+ {
+ PortableServer::ServantBase_var aServant = VISU::GetServant(aCORBAObject);
+ if (aServant.in()) {
+ VISU::Prs3d_i* aPrsObject = dynamic_cast<VISU::Prs3d_i*>(aServant.in());
+ aList.resize(k+1);
+ aList[k] = aPrsObject;
+ k++;
+ }
+ }
+ break;
+ case VISU::TFIELD:
+ {
+ _PTR(ChildIterator) anIter = aCStudy->NewChildIterator(theObject);
+ _PTR(SObject) aTimeStamp;
+ anIter->Next(); // First is reference on support
+ for (; anIter->More(); anIter->Next()) {
+ aTimeStamp = anIter->Value();
+ if (!aTimeStamp) continue;
+ std::vector<VISU::Prs3d_i*> aSubList = GetPrs3dList(theModule, aTimeStamp);
+ if (!aSubList.empty()) {
+ int n = aSubList.size();
+ aList.resize(k+n);
+ for (int i = 0; i < n; i++) {
+ aList[k] = aSubList[i];
+ k++;
+ }
+ }
+ }
+ }
+ break;
+ }
+ }
+ } else {
+ _PTR(GenericAttribute) anAttr;
+ if (theObject->FindAttribute(anAttr, "AttributeComment")) {
+ _PTR(AttributeComment) aComment (anAttr);
+ string aComm = aComment->Value();
+ QString strIn (aComm.c_str());
+ VISU::Storable::TRestoringMap pMap;
+ VISU::Storable::StrToMap(strIn, pMap);
+ bool isExist;
+ VISU::VISUType aType =
+ (VISU::VISUType)VISU::Storable::FindValue(pMap,"myType",&isExist).toInt();
+ if (isExist) {
+ switch (aType) {
+ case VISU::TFIELD:
+ {
+ _PTR(ChildIterator) anIter = aCStudy->NewChildIterator(theObject);
+ _PTR(SObject) aTimeStamp;
+ anIter->Next(); // First is reference on support
+ for (; anIter->More(); anIter->Next()) {
+ aTimeStamp = anIter->Value();
+ if (!aTimeStamp) continue;
+ std::vector<VISU::Prs3d_i*> aSubList = GetPrs3dList(theModule, aTimeStamp);
+ if (!aSubList.empty()) {
+ int n = aSubList.size();
+ aList.resize(k+n);
+ for (int i = 0; i < n; i++) {
+ aList[k] = aSubList[i];
+ k++;
+ }
+ }
+ }
+ }
+ break;
+ case VISU::TTIMESTAMP:
+ {
+ _PTR(ChildIterator) anIter = aCStudy->NewChildIterator(theObject);
+ _PTR(SObject) aPrs;
+ for (; anIter->More(); anIter->Next()) {
+ aPrs = anIter->Value();
+ if (!aPrs) continue;
+ std::vector<VISU::Prs3d_i*> aSubList = GetPrs3dList(theModule, aPrs);
+ if (!aSubList.empty()) {
+ int n = aSubList.size();
+ aList.resize(k+n);
+ for (int i = 0; i < n; i++) {
+ aList[k] = aSubList[i];
+ k++;
+ }
+ }
+ }
+ }
+ break;
+ }
+ }
+ }
+ }
+ return aList;
+ }