+ VISU::VISU_Gen_i* aVisuGen = VISU::GetVisuGen( theModule );
+
+ // implementation moved to VISU_I package (see VISU_Tools.h)
+ VISU::CreatePlot( aVisuGen, aPlot, theTableSO );
+ }
+
+ //************************************************************
+ // Others
+ VISU::Mesh_i*
+ CreateMesh(VisuGUI* theModule,
+ const Handle(SALOME_InteractiveObject)& theIO,
+ SVTK_ViewWindow* theViewWindow)
+ {
+ _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 NULL;
+
+ Storable::TRestoringMap aMap = Storable::GetStorableMap(aResultSObj);
+ if (aMap.empty())
+ return NULL;
+
+ CORBA::Object_var aMesh;
+ string aComment = Storable::FindValue(aMap,"myComment").toLatin1().data();
+ string aMeshName = Storable::FindValue(aMap,"myMeshName").toLatin1().data();
+#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").toLatin1().data();
+ 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").toLatin1().data();
+ 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::warning (GetDesktop(theModule),
+ QObject::tr("WRN_VISU"),
+ QObject::tr("ERR_CANT_BUILD_PRESENTATION") );
+ return NULL;
+ }
+
+ if (theViewWindow) {
+ try {
+#ifdef CHECKTIME
+ Utils_Timer timer;
+ timer.Start();
+#endif
+ if(GetResourceMgr()->booleanValue("VISU","display_only",false)){
+ const VisuGUI* av = dynamic_cast<const VisuGUI*>(theModule);
+ if(av)(const_cast<VisuGUI*>(av))->OnEraseAll();
+ }
+ PublishMeshInView(theModule, pPresent, theViewWindow);
+ if(GetResourceMgr()->booleanValue("VISU","automatic_fit_all",false)){
+ SetFitAll(theViewWindow);
+ }
+#ifdef CHECKTIME
+ timer.Stop();
+ MESSAGE("VisuGUI::CreateMesh() - DISPLAY MESH");
+ timer.Show();
+#endif
+ } catch (std::runtime_error& exc) {
+ INFOS(exc.what());
+ SUIT_MessageBox::warning(GetDesktop(theModule), QObject::tr("WRN_VISU"),
+ QObject::tr("ERR_CANT_CREATE_ACTOR") + ": " + QObject::tr(exc.what()) );
+ }
+ }
+
+ UpdateObjBrowser(theModule, false, aResultSObj);
+
+ theModule->application()->putInfo(QObject::tr("INF_DONE"));
+ // Make "Save" button active
+ theModule->getApp()->updateActions();
+ return pPresent;
+ }
+
+ // ========================================================================================
+ // GetPrs3dList: find list of presentations for the given object
+ // ========================================================================================
+ std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
+ const Handle(SALOME_InteractiveObject)& theIO,
+ bool theGP)
+ {
+ 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, theGP);
+ }
+ return aList;
+ }
+
+ std::vector<VISU::Prs3d_i*> GetPrs3dList (const SalomeApp_Module* theModule,
+ _PTR(SObject) theObject,
+ bool theGP)
+ {
+ 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::TGAUSSPOINTS:
+ if ( !theGP ) break;
+ case VISU::TSCALARMAP:
+ case VISU::TISOSURFACES:
+ case VISU::TDEFORMEDSHAPE:
+ case VISU::TCUTPLANES:
+ case VISU::TCUTLINES:
+ case VISU::TCUTSEGMENT:
+ case VISU::TVECTORS:
+ case VISU::TSTREAMLINES:
+ case VISU::TPLOT3D:
+ case VISU::TSCALARMAPONDEFORMEDSHAPE:
+ case VISU::TDEFORMEDSHAPEANDSCALARMAP:
+ case VISU::TMESH:
+ {
+ 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;
+ case VISU::TCOLOREDPRS3DHOLDER:
+ {
+ PortableServer::ServantBase_var aServant = VISU::GetServant(aCORBAObject);
+ if (aServant.in()) {
+ VISU::ColoredPrs3dHolder_i* aPrsHolderObject = dynamic_cast<VISU::ColoredPrs3dHolder_i*>(aServant.in());
+ if( aPrsHolderObject ) {
+ VISU::Prs3d_i* aPrsObject = aPrsHolderObject->GetPrs3dDevice();
+ aList.resize(k+1);
+ aList[k] = aPrsObject;
+ k++;
+ }
+ }
+ }
+ }
+ }
+ } else {
+ VISU::VISUType aType = VISU::Storable::SObject2Type(theObject);
+ 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;
+ }
+
+ //------------------------------------------------------------
+ int GetFreePositionOfDefaultScalarBar(VisuGUI* theModule, SVTK_ViewWindow* theViewWindow)
+ {
+ int minIndx = 1;
+ std::set<int> aIndexes;
+ TViewToPrs3d aMap = theModule->getScalarBarsMap();
+ TViewToPrs3d::const_iterator aViewToPrsIter = aMap.find(theViewWindow);
+ if (aViewToPrsIter != aMap.end()) {
+ TSetPrs3d::const_iterator aPrsIter = (aViewToPrsIter->second).begin();
+ for (; aPrsIter != (aViewToPrsIter->second).end(); aPrsIter++) {
+ aIndexes.insert((*aPrsIter).second);
+ }
+ }
+ std::set<int>::const_iterator aIter = aIndexes.begin();
+ for (int i = 1,length = aIndexes.size(); i <= length; i++) {
+ std::set<int>::const_iterator aIter = aIndexes.find(i);
+ if (aIter == aIndexes.end()) { minIndx = i; break; }
+ else minIndx = i + 1;
+ }
+ return minIndx;
+ }
+
+ //------------------------------------------------------------
+ void AddScalarBarPosition (VisuGUI* theModule, SVTK_ViewWindow* theViewWindow,
+ VISU::Prs3d_i* thePrs3d, int pos)
+ {
+ TViewToPrs3d& aMap = theModule->getScalarBarsMap();
+ TPrs3dToInd aPair; aPair.first = thePrs3d; aPair.second = pos;
+ aMap[theViewWindow].insert(aPair);
+ }
+
+ //------------------------------------------------------------
+ void RemoveScalarBarPosition(VisuGUI* theModule, SVTK_ViewWindow* theViewWindow,
+ VISU::Prs3d_i* thePrs3d)
+ {
+ TViewToPrs3d& aMap = theModule->getScalarBarsMap();
+ TSetPrs3d::iterator aIter = aMap[theViewWindow].begin();
+ for (; aIter != aMap[theViewWindow].end(); aIter++)
+ if ((*aIter).first == thePrs3d) {
+ aMap[theViewWindow].erase(*aIter);
+ return;