X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FVISUGUI%2FVisuGUI.cxx;h=9073b28a20b634ed505b6f1151c8b88c3236f446;hb=b91e2c5bef063cd22f17998ed588a2038adfec80;hp=b95a9273463c9497dce6ec7b0170efa550595245;hpb=a616d40f9eee86639c188d8a115a9a9c85a31e60;p=modules%2Fvisu.git diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index b95a9273..9073b28a 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -1,13 +1,54 @@ -using namespace std; -// File : VisuGUI.cxx -// Created : Wed Aug 01 10:20:18 2001 -// Author : Laurent CORNABE -// Project : SALOME -// Module : VISUGUI -// Copyright : PRINCIPIA +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// +// +// +// File : VisuGUI.cxx +// Author : Laurent CORNABE +// Module : VISU // $Header$ #include "VisuGUI.h" + +#include "VISU_Gen_i.hh" +#include "VISU_Result_i.hh" +#include "VISU_PrsObject_i.hh" +#include "VISU_ViewManager_i.hh" + +#include "VISU_PipeLine.hxx" + +#include "VISU_Prs3d_i.hh" +#include "VISU_Mesh_i.hh" +#include "VISU_ScalarMap_i.hh" +#include "VISU_IsoSurfaces_i.hh" +#include "VISU_DeformedShape_i.hh" +#include "VISU_CutPlanes_i.hh" +#include "VISU_CutLines_i.hh" +#include "VISU_Vectors_i.hh" +#include "VISU_StreamLines_i.hh" +#include "VISU_Table_i.hh" + +#include "VISU_Actor.h" +#include "VISU_MeshAct.h" + #include "VisuGUI_PhaseDlg.h" #include "VisuGUI_MagnitudeDlg.h" #include "VisuGUI_PhaseMagnitudeDlg.h" @@ -16,6 +57,7 @@ using namespace std; #include "VisuGUI_ScalarBarDlg.h" #include "VisuGUI_SweepPrefDlg.h" #include "VisuGUI_CutPlanesDlg.h" +#include "VisuGUI_CutLinesDlg.h" #include "VisuGUI_VectorsDlg.h" #include "VisuGUI_IsoSurfacesDlg.h" #include "VisuGUI_StreamLinesDlg.h" @@ -26,14 +68,6 @@ using namespace std; #include "VisuGUI_SelVectCompDlg.h" #include "VisuGUI_NonIsometricDlg.h" -#include "VISU_Gen_i.hh" -#include "VISU_Result_i.hh" -#include "VISU_Extractor.hxx" -#include "VISU_Table_i.hh" -#include "VISU_ViewManager_i.hh" -#include "VISU_LookupTable.hxx" -#include "VISU_ScalarBarActor.hxx" - #include "SALOMEGUI_ImportOperation.h" #include "SALOMEGUI_QtCatchCorbaException.hxx" #include "utilities.h" @@ -51,6 +85,7 @@ using namespace std; #include "QAD_Resource.h" #include "QAD_ResourceMgr.h" #include "QAD_FileDlg.h" +#include "QAD_WaitCursor.h" #include "SALOME_Selection.h" #include "SALOMEGUI_NameDlg.h" #include "SALOMEGUI_TableDlg.h" @@ -59,6 +94,7 @@ using namespace std; #include "Plot2d_SetupPlot2dDlg.h" #include "Plot2d_ViewFrame.h" #include "VTKViewer_ViewFrame.h" +#include "VisuGUI_FileDlg.h" // QT Includes #define INCLUDE_MENUITEM_DEF @@ -84,53 +120,33 @@ using namespace std; #include #include -#include CORBA_CLIENT_HEADER(Med_Gen) +#include CORBA_CLIENT_HEADER(MED_Gen) #include -#include -//#include #include -#include -#include -#include -#include // Open CASCADE Include #include -//#define CHECKTIME +//#define CHECKTIME #ifdef CHECKTIME -#include +static int MYCHECKTIME = 1; +#else +static int MYCHECKTIME = 0; #endif +#include + +using namespace std; -#ifdef DEBUG -static int MYDEBUG = 1; +#ifdef _DEBUG_ +static int MYDEBUG = 0; static int MYDEBUGWITHFILES = 0; #else static int MYDEBUG = 0; static int MYDEBUGWITHFILES = 0; #endif -// unique name visu entity -//static bool localContext = false; -static VisuGUI_Selection *Selection; -static int VISU_POINT_SIZE = 5; - -QAD_Study* VisuGUI::myActiveStudy = NULL; -VISU::VISU_Gen_var VisuGUI::myComponent = VISU::VISU_Gen::_nil(); -SALOMEDS::Study_var VisuGUI::myStudy = SALOMEDS::Study::_nil(); -SALOMEDS::StudyBuilder_var VisuGUI::myStudyBuilder = SALOMEDS::StudyBuilder::_nil(); -QAD_Desktop* VisuGUI::myDesktop = NULL; - -QAD_Study* MYActiveStudy = NULL; -SALOMEDS::StudyBuilder_var MYStudyBuilder = SALOMEDS::StudyBuilder::_nil(); -SALOMEDS::Study_var MYStudyDocument = SALOMEDS::Study::_nil(); - -const QString ObjectTypes("FIELD VIEW3D MESH TIMESTAMP ENTITY FAMILY GROUP"); - - -class CustomItem : public QCustomMenuItem -{ +class CustomItem : public QCustomMenuItem{ public: CustomItem( const QString& s, const QFont& f ) : string( s ), font( f ){}; @@ -151,16 +167,108 @@ private: QFont font; }; -static VisuGUI *visuGUI = 0; -static QString PREFIX = QString(getenv("USER")) + "-VISU-"; +static VisuGUI MYVISUGUI; +static VisuGUI *visuGUI = &MYVISUGUI; + +VISU::VISU_Gen_i* VisuGUI::GetVisuGen(){ + VISU::VISU_Gen_i::GetVisuGenImpl()->SetCurrentStudy(GetStudyDocument()); + return VISU::VISU_Gen_i::GetVisuGenImpl(); +} + +static int ComputeVisiblePropBounds(VTKViewer_ViewFrame* theViewFrame, float allBounds[6], + const char* theActorClassName = "VISU_Actor") +{ + vtkRenderer *aRen = theViewFrame->getRenderer(); + vtkActorCollection *anActColl = aRen->GetActors(); + vtkProp *prop; + float *bounds; + int nothingVisible=1; + + allBounds[0] = allBounds[2] = allBounds[4] = VTK_LARGE_FLOAT; + allBounds[1] = allBounds[3] = allBounds[5] = -VTK_LARGE_FLOAT; + // loop through all props + for (anActColl->InitTraversal(); (prop = anActColl->GetNextProp()); ){ + // if it's invisible, or has no geometry, we can skip the rest + if ( prop->GetVisibility() && prop->IsA(theActorClassName)){ + bounds = prop->GetBounds(); + // make sure we haven't got bogus bounds + if ( bounds != NULL && + bounds[0] > -VTK_LARGE_FLOAT && bounds[1] < VTK_LARGE_FLOAT && + bounds[2] > -VTK_LARGE_FLOAT && bounds[3] < VTK_LARGE_FLOAT && + bounds[4] > -VTK_LARGE_FLOAT && bounds[5] < VTK_LARGE_FLOAT ) + { + nothingVisible = 0; + if (bounds[0] < allBounds[0]) allBounds[0] = bounds[0]; + if (bounds[1] > allBounds[1]) allBounds[1] = bounds[1]; + if (bounds[2] < allBounds[2]) allBounds[2] = bounds[2]; + if (bounds[3] > allBounds[3]) allBounds[3] = bounds[3]; + if (bounds[4] < allBounds[4]) allBounds[4] = bounds[4]; + if (bounds[5] > allBounds[5]) allBounds[5] = bounds[5]; + }//not bogus + } + } + return nothingVisible; +} + +VisuGUI::CameraOrient VisuGUI::SetFitAll(VTKViewer_ViewFrame* theViewFrame){ + static float PRECISION = 0.000001; + static float DEVIATION = 600; + float XYZ_Bnd[6]; + if(ComputeVisiblePropBounds(theViewFrame,XYZ_Bnd)) return e3D; + + float absX = XYZ_Bnd[1]-XYZ_Bnd[0]; + + float absY = XYZ_Bnd[3]-XYZ_Bnd[2]; + + float absZ = XYZ_Bnd[5]-XYZ_Bnd[4]; + + CameraOrient aCameraOrient = e3D; + if(absX <= PRECISION) aCameraOrient = eFront; + else {if(absY <= PRECISION) aCameraOrient = eLeft; + else {if(absZ <= PRECISION) aCameraOrient = eTop;}} + + float dev_abs_XY = absX / absY; + float dev_abs_YZ = absY / absZ; + float dev_abs_XZ = absX / absZ; + if(dev_abs_XY >= DEVIATION || 1./dev_abs_YZ >= DEVIATION) aCameraOrient = eLeft; + else{if(1./dev_abs_XY >= DEVIATION || 1./dev_abs_XZ >= DEVIATION) aCameraOrient = eFront; + else {if(dev_abs_XZ >= DEVIATION || dev_abs_YZ >= DEVIATION) aCameraOrient = eTop;}} + + switch(aCameraOrient){ + case eFront: theViewFrame->onViewFront(); break; + case eLeft: theViewFrame->onViewLeft(); break; + case eTop: theViewFrame->onViewTop(); break; + case e3D: theViewFrame->onViewReset(); break; + } + theViewFrame->getRenderer()->ResetCameraClippingRange(); + theViewFrame->onViewFitAll(); +} + +QAD_Desktop* VisuGUI::GetDesktop(){ + return QAD_Application::getDesktop() ; +} + +QAD_Study* VisuGUI::GetActiveStudy(){ + return GetDesktop()->getActiveStudy() ; +} +vtkRenderer* VisuGUI::GetRenderer(){ + if(VTKViewer_ViewFrame* aViewFrame = GetVtkViewFrame()) + return aViewFrame->getRenderer(); + return NULL; +} +VTKViewer_ViewFrame* VisuGUI::GetVtkViewFrame(){ + QAD_ViewFrame* aViewFrame = GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame(); + return dynamic_cast(aViewFrame); +} -vtkRenderer* VisuGUI::GetRenderer(QAD_Study* theStudy){ - if (theStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) - return NULL; +SALOMEDS::Study_var VisuGUI::GetStudyDocument(){ + return GetActiveStudy()->getStudyDocument(); +} - return ((VTKViewer_ViewFrame*)theStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); +SALOMEDS::StudyBuilder_var VisuGUI::NewBuilder(){ + return GetStudyDocument()->NewBuilder(); } @@ -191,51 +299,15 @@ QString VisuGUI::getValue(SALOMEDS::SObject_var theSObject, QString theKey) { } -CORBA::Object_var GetSelectedObj(string& theComment, Handle(SALOME_InteractiveObject)& theIO, QAD_Study* theStudy){ - SALOME_Selection* Sel = SALOME_Selection::Selection(theStudy->getSelection()); - if( Sel->IObjectCount() > 0 ) { - theIO = Sel->firstIObject(); - if (theIO->hasEntry()){ - SALOMEDS::SObject_var aSObject = MYStudyDocument->FindObjectID(theIO->getEntry()); - if(!aSObject->_is_nil()){ - SALOMEDS::GenericAttribute_var anAttr; - if (aSObject->FindAttribute(anAttr, "AttributeComment")) { - SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr); - theComment = aComment->Value(); - QString strIn(theComment.c_str()); - VISU::Storable::TRestoringMap aMap; - VISU::Storable::StrToMap(strIn,aMap); - bool isExist; - theComment = VISU::Storable::FindValue(aMap,"myComment",&isExist).latin1(); - if(!isExist) theComment = "NONE"; - } else { - theComment = "NONE"; - } - aSObject->FindAttribute(anAttr, "AttributeIOR"); - if(!anAttr->_is_nil()){ - SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - if(!anIOR->_is_nil()){ - CORBA::String_var aValue = anIOR->Value(); - if(strcmp(aValue,"") != 0){ - CORBA::ORB_var anORB = VISU::GetORB(); - CORBA::Object_var anObject = anORB->string_to_object(aValue); - return anObject; - } - } - } - } - } - } - return CORBA::Object::_nil(); -} - -CORBA::Object_var GetSelectedObj(QAD_Study* theStudy, Handle(SALOME_InteractiveObject)* pIO = NULL, +CORBA::Object_var GetSelectedObj(Handle(SALOME_InteractiveObject)* pIO = NULL, QAD_Study* theStudy = NULL, VISU::Storable::TRestoringMap* pMap = NULL) { - SALOME_Selection* Sel = SALOME_Selection::Selection(theStudy->getSelection()); - if( Sel->IObjectCount() > 0 ) { - Handle(SALOME_InteractiveObject)& anIO = (*pIO) = Sel->firstIObject(); - if (anIO->hasEntry()){ + if(theStudy == NULL) theStudy = VisuGUI::GetActiveStudy(); + SALOME_Selection* aSel = SALOME_Selection::Selection(theStudy->getSelection()); + if(aSel->IObjectCount() > 0){ + const Handle(SALOME_InteractiveObject)& anIO = aSel->firstIObject(); + if(pIO != NULL) *pIO = anIO; + if(anIO->hasEntry()){ SALOMEDS::Study_var aStudy = theStudy->getStudyDocument(); SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry()); if(!aSObject->_is_nil()){ @@ -253,57 +325,16 @@ CORBA::Object_var GetSelectedObj(QAD_Study* theStudy, Handle(SALOME_InteractiveO return CORBA::Object::_nil(); } -int IsTrihedronDisplayed(){ - QAD_ViewFrame* aViewFrame = MYActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame(); - VTKViewer_ViewFrame* aVTKViewFrame = dynamic_cast(aViewFrame); - return aVTKViewFrame->isTrihedronDisplayed(); -} - -VTKViewer_ViewFrame* VisuGUI::GetVtkViewFrame(){ - QAD_ViewFrame* aViewFrame = myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame(); - return dynamic_cast(aViewFrame); +int IsTrihedronDisplayed(){ + if(VTKViewer_ViewFrame* aVTKViewFrame = VisuGUI::GetVtkViewFrame()) + return aVTKViewFrame->isTrihedronDisplayed(); + return 1; } void RepaintCurrentView(){ - VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame(); - if (vf) - vf->Repaint(); -} - - -VISU_Actor* GetActorByIO(const Handle(SALOME_InteractiveObject)& theIO, vtkRenderer* theRen) { - vtkActorCollection* aActors = theRen->GetActors(); - vtkActor* anActor; - VISU_Actor* aVisuActor; - for (aActors->InitTraversal(); (anActor = aActors->GetNextActor())!=NULL;) { - if (anActor->IsA("VISU_Actor")) { - aVisuActor = VISU_Actor::SafeDownCast(anActor); - if (aVisuActor->hasIO()) { - if (theIO->isSame(aVisuActor->getIO())) - return aVisuActor; - } - } - } - return 0; -} - -VISU::Base_i* GetSelectedVisuObj(){ - SALOME_Selection* Sel = SALOME_Selection::Selection(MYActiveStudy->getSelection()); - SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); - if(It.More()){ - Handle(SALOME_InteractiveObject) IObject = It.Value(); - if (IObject->hasEntry()){ - SALOMEDS::SObject_var aSObject = MYStudyDocument->FindObjectID(IObject->getEntry()); - if(!aSObject->_is_nil()){ - CORBA::Object_var aObject = VISU::SObjectToObject(aSObject); - if(!CORBA::is_nil(aObject)) - return dynamic_cast(VISU::GetServant(aObject)); - } - } - } - return NULL; + if(VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame()) vf->Repaint(); } /** @@ -325,37 +356,7 @@ int GetScalarMode(VISU::Result_i* theResult, const char* theFieldName){ } -VisuGUI::VisuGUI(){ -} - - -VisuGUI* VisuGUI::GetOrCreateVisuGUI( QAD_Desktop* desktop ){ - if(!visuGUI){ - static VisuGUI VISUGUI; - visuGUI = &VISUGUI; - Engines::Component_var comp = QAD_Application::getDesktop()->getEngine("FactoryServer", "Visu"); - myComponent = VISU::VISU_Gen::_narrow(comp); - } - /* study may have changed */ - myDesktop = desktop; - myActiveStudy = myDesktop->getActiveStudy(); - myStudy = myActiveStudy->getStudyDocument(); //Document OCAF de l'etude active - myComponent->SetCurrentStudy(myStudy); - myStudyBuilder = myStudy->NewBuilder(); - - MYActiveStudy = myActiveStudy; - MYStudyDocument = myStudy; - MYStudyBuilder = myStudyBuilder; - return visuGUI; -} - -/* ********************************************************************************* */ -/* Function to return VisuGUI object */ -/* ********************************************************************************* */ -VisuGUI* VisuGUI::GetVisuGUI( ) -{ - return VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop()); -} +VisuGUI::VisuGUI(){} /* ==================================================================================== */ /* ==================================================================================== */ @@ -370,7 +371,7 @@ static int isStudyLocked(const SALOMEDS::Study_var& theStudy){ static int checkLock(const SALOMEDS::Study_var& theStudy) { if (isStudyLocked(theStudy)) { QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(), - QObject::tr("WARNING"), + QObject::tr("WRN_WARNING"), QObject::tr("WRN_STUDY_LOCKED"), QObject::tr("BUT_OK") ); return true; @@ -383,31 +384,20 @@ static int checkLock(const SALOMEDS::Study_var& theStudy) { bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) { try{ - VisuGUI::GetOrCreateVisuGUI(parent); -// get Visu directories from configuration file. Default values are enabled. -/* if (visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) { // BugID: SAL931 - QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), - tr ("Not available in Non-VTK viewers"), - tr ("VISU_BUT_OK") ); - }*/ - QString VisuInputDir = getVisuInputDir(); - QString VisuOutputDir = getVisuOutputDir(); - vtkRenderer *theRenderer = GetRenderer(visuGUI->myActiveStudy); - - //vtkActorCollection* aActors = theRenderer->GetActors(); - //cout<<"### Actors Nb="<GetNumberOfItems()<myActiveStudy->getStudyDocument(); //Document OCAF de l'etude active - SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributeIOR_var anIOR; - - switch (theCommandID) - { - /* ======================================================================================== */ - /* Define Selection Mode */ - /* ======================================================================================== */ + QString VisuInputDir = getVisuInputDir(); + QString VisuOutputDir = getVisuOutputDir(); + vtkRenderer *theRenderer = GetRenderer(); + + SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument(); //Document OCAF de l'etude active + SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + SALOMEDS::AttributeIOR_var anIOR; + + switch (theCommandID){ + /* ======================================================================================== */ + /* Define Selection Mode */ + /* ======================================================================================== */ case 101: case 102: case 103: @@ -447,38 +437,10 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) case 122: { - visuGUI->ExportToFile(); + //visuGUI->ExportToFile(); break; } - /* ========================================================================================================================= */ - /* Print to printer (132) or in file (131) */ - /* ========================================================================================================================= */ - - case 131 : - case 132 : - { - QString prFile; - if (theCommandID == 131) { // save the file - prFile = QAD_FileDlg::getFileName(QAD_Application::getDesktop(), - VisuOutputDir, - filters[9], - tr("TIFF File"), - false); - if ( prFile.isEmpty() ) - break; - - VisuOutputDir = QAD_Tools::getDirFromPath(prFile); // set VisuOutputDir - QAD_CONFIG->addSetting("Visu:OutputDir",VisuOutputDir); - - visuGUI->PrintRW(prFile, false); - } else { - prFile=VisuOutputDir+"SalomeVisu.tif"; - visuGUI->PrintRW(prFile, true); - } - break; - } - /* ========================================================================== */ /* Visualization of Results : */ /* 4011 : Scalar Map */ @@ -504,6 +466,9 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) case 4015 : visuGUI->CreateCutPlanes(); break; + case 4018 : + visuGUI->CreateCutLines(); + break; case 4016 : visuGUI->CreateStreamLines(); break; @@ -522,120 +487,32 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) /* ========================================================================================================================= */ case 4111 : - { - visuGUI->SelectCell(); - break; -/* VSR 12/03/03: see VisuGUI::SelectCell() - int TypeMode; - VISU_Actor *ActorTmp; - string aComment; - Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj(aComment,anIO,visuGUI->myActiveStudy); - //srn: Added check if anObject is Null, then break -// if(CORBA::is_nil(anObject)) break; - - VISU::ScalarMap_i* aPrsObject = NULL; - if(!CORBA::is_nil(anObject)) - aPrsObject = dynamic_cast(VISU::GetServant(anObject)); - if(aPrsObject){ - //aPrsObject->SetIO(anIO); - //ActorTmp = aPrsObject->GetActor(); - //UpdateViewer(ActorTmp); - ActorTmp = visuGUI->UpdateViewer(aPrsObject); - } else { - ActorTmp = ActorSelected(parent,true,&TypeMode); - } - if (ActorTmp==NULL) - break; - - bool ok=FALSE; - vtkDataSetMapper *Mapper = (vtkDataSetMapper*) (ActorTmp->GetMapper()); - Mapper->SetInput(ActorTmp->DataSource); - vtkDataSet *Data=Mapper->GetInput(); - int nbCells=Data->GetNumberOfCells(); - int selectedCell = QInputDialog::getInteger( tr( "Please choose a cell number" ), tr("Cell selection"), 0, 0, (int)(nbCells), 1, &ok, parent ,""); - if (ok && theRenderer) - Selection->HighlightCell(selectedCell , ActorTmp , theRenderer); - break; -*/ - } + visuGUI->SelectCell(); + break; /* ========================================================================================================================= */ /* Selection - Cell - information attribute */ /* ========================================================================================================================= */ case 4112 : - { - visuGUI->InfoOnCell(); - break; -/* VSR 12/03/03: see VisuGUI::InfoOnCell() - int TypeMode; - VISU_Actor *ActorTmp; - ActorTmp = ActorSelected(parent,true,&TypeMode); - if (ActorTmp==NULL) - break; - - if ((TypeMode == SelectionCell) || (TypeMode == SelectionEdge)) - Selection->PickingResults(visuGUI->myActiveStudy,TypeMode,ActorTmp); - else - QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("WARNING"), - tr ("Not Selected View - Cell Selection Mode"), - tr ("VISU_BUT_OK") ); - break; -*/ - } + visuGUI->InfoOnCell(); + break; /* ========================================================================================================================= */ /* Selection - Point - information number */ /* ========================================================================================================================= */ case 4121 : - { - visuGUI->SelectPoint(); - break; -/* VSR 12/03/03: see VisuGUI::SelectPoint() - int TypeMode; - VISU_Actor *ActorTmp; - ActorTmp = ActorSelected(parent,true,&TypeMode); - if (ActorTmp==NULL) - break; - - bool ok=FALSE; - vtkDataSetMapper *Mapper = (vtkDataSetMapper*) (ActorTmp->GetMapper()); - Mapper->SetInput(ActorTmp->DataSource); - vtkDataSet *Data=Mapper->GetInput(); - int nbPoints=Data->GetNumberOfPoints(); - int selectedPoint = QInputDialog::getInteger( tr( "Please choose a Point number" ), tr("Point selection"), 0, 0, (int)(nbPoints-1), 1, &ok, parent ,""); - if (ok && theRenderer) - Selection->HighlightPoint(selectedPoint , nbPoints, ActorTmp , theRenderer); - break; -*/ - } + visuGUI->SelectPoint(); + break; /* ========================================================================================================================= */ /* Selection - Point - information attribute */ /* ========================================================================================================================= */ case 4122 : - { - visuGUI->InfoOnPoint(); - break; -/* VSR 12/03/03: see VisuGUI::InfoOnPoint() - int TypeMode; - VISU_Actor *ActorTmp; - ActorTmp = ActorSelected(parent,true,&TypeMode); - if (ActorTmp==NULL) - break; - - if (TypeMode == SelectionPoint) - Selection->PickingResults(visuGUI->myActiveStudy,TypeMode,ActorTmp); - else - QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("WARNING"), - tr ("Not Selected View - Point Selection Mode"), - tr ("VISU_BUT_OK") ); - break; -*/ - } + visuGUI->InfoOnPoint(); + break; /* ========================================================================================================================= */ /* Selection - Shape */ @@ -648,7 +525,7 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) /* ========================================================================================================================= */ case 4211 : - ChangeViewer(parent, theRenderer, true, 1); + ChangeViewer(1); break; /* ========================================================================================================================= */ @@ -656,7 +533,7 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) /* ========================================================================================================================= */ case 4212 : - ChangeViewer(parent, theRenderer, true, 2); + ChangeViewer(2); break; /* ========================================================================================================================= */ @@ -664,7 +541,7 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) /* ========================================================================================================================= */ case 4213 : - ChangeViewer(parent, theRenderer, true, 0); + ChangeViewer(0); break; /* ========================================================================================================================= */ @@ -672,8 +549,7 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) /* ========================================================================================================================= */ case 422 : - if (visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) - ClearViewer(parent, theRenderer, -1); + ChangeViewer(-1); break; /* ========================================================================================================================= */ @@ -722,22 +598,22 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) case 8041 : // Object representation : Wireframe case 9041 : // Object representation : Wireframe - visuGUI->ChangeRepresentation(WIREFRAME); + visuGUI->ChangeRepresentation(VISU::WIREFRAME); break; case 8042 : // Object representation : Surface case 9042 : // Object representation : Surface - visuGUI->ChangeRepresentation(SURFACE); + visuGUI->ChangeRepresentation(VISU::SHADED); break; case 8043 : // Object representation : Points case 9043 : // Object representation : Points - visuGUI->ChangeRepresentation(POINTS); + visuGUI->ChangeRepresentation(VISU::POINT); break; case 8044 : // Object representation : Shrink/Unshrink case 9044 : // Object representation : Shrink/Unshrink - visuGUI->ChangeRepresentation(SHRINK); + visuGUI->ChangeRepresentation(VISU::SHRINK); break; case 8051 : // Change object color @@ -760,72 +636,12 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) visuGUI->Sweep(); break; - case 807 : // Modify visualization - case 809 : // Return Cell Id - case 810 : // Highlight Cell parameter - // ---------------- For Popup in ObjectBrowser - case 907 : // Modify visualization - - { - int TypeMode; - bool InViewer; - VISU_Actor *ActorTmp; - string aComment; - Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj(aComment,anIO,visuGUI->myActiveStudy); - VISU::ScalarMap_i* aPrsObject = dynamic_cast(VISU::GetServant(anObject)); - if(aPrsObject){ - ActorTmp = visuGUI->UpdateViewer(aPrsObject); - } else { - if ( ((theCommandID >= 801) && (theCommandID <= 809)) || ((theCommandID >= 8041) && (theCommandID <= 8059)) ) - InViewer= true; - else if ( ((theCommandID >= 901) && (theCommandID <= 909)) || ((theCommandID >= 9041) && (theCommandID <= 9059)) ) - InViewer = false; - - ActorTmp = ActorSelected(parent,InViewer,&TypeMode); - } - if (ActorTmp==NULL) - break; - - - if (theCommandID == 809) // return results of object picked, in the message box - { - Selection->PickingResults(visuGUI->myActiveStudy,TypeMode,ActorTmp); - MESSAGE("Valeur : " << Selection->getId()) - } - - if (theCommandID == 810) // Highlight Cell or point with parameter - { - bool ok=FALSE; - vtkDataSetMapper *Mapper = (vtkDataSetMapper*) (ActorTmp->GetMapper()); - Mapper->SetInput(ActorTmp->DataSource); - vtkDataSet *Data=Mapper->GetInput(); - if (TypeMode == SelectionPoint) - { - int nbPoints=Data->GetNumberOfPoints(); - int selectedPoint = QInputDialog::getInteger( tr( "Please choose a Point number" ), tr("Point selection"), 0, 0, (int)(nbPoints-1), 1, &ok, parent ,""); - if (ok) - Selection->HighlightPoint(selectedPoint , nbPoints, ActorTmp , theRenderer); - } - if ( (TypeMode == SelectionCell) || (TypeMode == SelectionEdge) ) - { - int nbCells=Data->GetNumberOfCells()-1; - int selectedCell = QInputDialog::getInteger( tr( "Please choose a cell number" ), tr("Cell selection"), 0, 0, (int)(nbCells), 1, &ok, parent ,""); - if (ok) - Selection->HighlightCell(selectedCell , ActorTmp , theRenderer); - } - } - - break; - } - /* ======================================================================================== */ /* Preferences for Scalar Bar */ /* ======================================================================================== */ case 51: { ChangeScalarBar(); - break; } @@ -837,30 +653,50 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) SetSweepingPreferences(); } break; - + +/* ======================================================================================== */ +/* Preferences for Full loading */ +/* ======================================================================================== */ + case 53: + case 54: + { + QMenuData* pp; + QMenuItem* item = parent->menuBar()->findItem(theCommandID,&pp); + bool check = !pp->isItemChecked(theCommandID); + pp->setItemChecked(theCommandID,check); + switch(theCommandID){ + case 53: + QAD_CONFIG->addSetting( "Visu:BuildResult", check ); + break; + case 54: + QAD_CONFIG->addSetting( "Visu:BuildDefaultPrs3d", check ); + break; + } + } + break; case 113: // Load MED using MED component { - if (checkLock(myStudy)) break; + if (checkLock(GetStudyDocument())) break; - Engines::Component_var aMedComp = myDesktop->getEngine("FactoryServer", "Med"); + Engines::Component_var aMedComp = GetDesktop()->getEngine("FactoryServer", "MED"); if (CORBA::is_nil(aMedComp)) return false; - Engines::Med_Gen_var aMedGen = Engines::Med_Gen::_narrow(aMedComp); + SALOME_MED::MED_Gen_var aMedGen = SALOME_MED::MED_Gen::_narrow(aMedComp); if (CORBA::is_nil(aMedGen)) return false; QStringList filtersList ; filtersList.append( tr("MED_MEN_IMPORT_MED") ); filtersList.append( tr("MED_MEN_ALL_FILES") ) ; - QString aFileName = QAD_FileDlg::getFileName(myDesktop, + QString aFileName = QAD_FileDlg::getFileName(GetDesktop(), "", filtersList, tr("MED_MEN_IMPORT"), true); if (!aFileName.isEmpty()) { QApplication::setOverrideCursor( Qt::waitCursor ); - aMedGen->readStructFileWithFieldType(aFileName.latin1(), myActiveStudy->getTitle()); - myActiveStudy->updateObjBrowser(); + aMedGen->readStructFileWithFieldType(aFileName.latin1(), GetActiveStudy()->getTitle()); + GetActiveStudy()->updateObjBrowser(); QApplication::restoreOverrideCursor(); } } @@ -868,27 +704,17 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) default: QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), - tr ("Not Yet Implemented"), + tr ("MSG_NOT_IMPLEMENTED"), tr ("VISU_BUT_OK") ); break; - } - } -/* - catch(SALOMEDS::GenericAttribute::LockProtection&) { - QAD_MessageBox::warn1 ( (QWidget*)QAD_Application::getDesktop(), - QObject::tr("WARNING"), - QObject::tr("WRN_STUDY_LOCKED"), - QObject::tr("BUT_OK") ); - return false; - } -*/ - catch (const SALOME::SALOME_Exception& S_ex) { + } + }catch (const SALOME::SALOME_Exception& S_ex) { QtCatchCorbaException(S_ex); return false; } catch(...) { QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"), - tr("Unknown exception was caught in VISU module"), + tr("ERR_UNKNOWN_EXCEPTION"), tr("VISU_BUT_OK") ); return false; } @@ -896,240 +722,6 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) } -/* ********************************************************************************* */ -/* Function to find Actor in ObjectBrowser */ -/* ********************************************************************************* */ - -VISU_Actor *VisuGUI::GetActorObjBrowser(SALOMEDS::SObject_var objVisu, vtkRenderer *ren) -{ - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - if ( objVisu->FindAttribute(anAttr, "AttributeName") ) { - aName = SALOMEDS::AttributeName::_narrow(anAttr); - - MESSAGE("GetActor == > Name : " << aName->Value()); - - vtkActorCollection *ac; - vtkActor *actor; - ac = ren->GetActors(); - - for(ac->InitTraversal();(actor = ac->GetNextActor())!=NULL;) { - if (actor->IsA("VISU_Actor")) { - VISU_Actor *VISUActor = VISU_Actor::SafeDownCast(actor); - if (strcmp(VISUActor->getName(), aName->Value()) == 0) - return VISUActor; - } - } - } - return NULL; -} - - -/* ********************************************************************************* */ -/* Function to find Actor in Viewer */ -/* ********************************************************************************* */ - - -VISU_Actor *VisuGUI::GetActor(QAD_Desktop* parent, Handle_SALOME_InteractiveObject IO, vtkRenderer *ren) -{ - VisuGUI::GetOrCreateVisuGUI(parent); - - QString theEntry = IO->getEntry(); - Standard_CString aComment; - Standard_CString Persistent; - //Standard_CString aName = IO->getName(); - VISU_Actor *anActor; - result Test; - - SALOMEDS::Study_var aStudy = visuGUI->myActiveStudy->getStudyDocument(); - - SALOMEDS::SObject_var objlocal = aStudy->FindObjectID(theEntry.latin1()); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeComment_var aCmnt; - SALOMEDS::AttributePersistentRef_var aPRef; - - if (objlocal->FindAttribute(anAttr, "AttributeComment")) { - aCmnt = SALOMEDS::AttributeComment::_narrow(anAttr); - aComment = aCmnt->Value(); - } - if (objlocal->FindAttribute(anAttr, "AttributePersistentRef")) { - aPRef = SALOMEDS::AttributePersistentRef::_narrow(anAttr); - Persistent = aPRef->Value(); - } - - vtkActorCollection *aclocal; - vtkActor *actorlocal; - aclocal = ren->GetActors(); - - // ============================================================================= - // Test if Actor exists in theRenderer - for (aclocal->InitTraversal();(actorlocal = aclocal->GetNextActor())!=NULL;) - { - if (actorlocal->IsA("VISU_Actor")) - { - anActor = VISU_Actor::SafeDownCast(actorlocal); - MESSAGE(" getIO de anActor : " << anActor->getIO()) - if (anActor->hasIO()) - { - if (IO->isSame(anActor->getIO())) - { - MESSAGE("isSame IO") - return anActor; - } - } - } - } - - // ============================================================================= - // If Actor doesn't exist in theRenderer => create same actor in new renderer - /* int nbSf = visuGUI->myActiveStudy->getStudyFramesCount(); - SALOMEDS::SObject_var TheMeshObject= objlocal->GetFather(); - for ( int i = 0; i < nbSf; i++ ) - { - QAD_StudyFrame* sf = visuGUI->myActiveStudy->getStudyFrame(i); - if ( sf->getTypeView() == VIEW_VTK ) - { - vtkRenderer* aRenderer = ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRenderer(); - vtkActorCollection* ac = aRenderer->GetActors(); - vtkActor *actor; - for(ac->InitTraversal();(actor = ac->GetNextActor())!=NULL;) - { - if (actor->IsA("VISU_Actor")) - { - anActor = VISU_Actor::SafeDownCast(actor); - if (anActor->hasIO()) - { - if (IO->isSame(anActor->getIO())) - { - if (aRenderer != ren) - { - return(visuGUI->DuplicateActor(anActor,IO,objlocal,aComment)); - } - } - } - } - } - } - }*/ - return NULL; - //return(visuGUI->DuplicateActor(anActor,IO,objlocal,aComment)); -} - -/* ********************************************************************************** */ -/* Function ActorSelected */ -/* To return the Actor selected in Viewer or in ObjectBrowser */ -/* ********************************************************************************** */ - -VISU_Actor *VisuGUI::ActorSelected(QAD_Desktop* parent, bool InViewer, int *Mode) -{ - VisuGUI::GetOrCreateVisuGUI(parent); - SALOME_Selection *Sel; - QAD_ObjectBrowserItem* item; - VISU_Actor *ActorTmp; - Standard_CString PersRef = ""; - Sel = SALOME_Selection::Selection(visuGUI->myActiveStudy->getSelection()); - vtkRenderer *theRenderer = ((VTKViewer_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRenderer(); - - - - *Mode=Sel->SelectionMode(); - - SALOMEDS::Study_var aStudy = visuGUI->myActiveStudy->getStudyDocument(); //Document OCAF de l'etude active - SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); - //SALOMEDS::SComponent_var father = aStudy->FindComponent("VISU"); - SALOMEDS::GenericAttribute_var anAttr; - SALOMEDS::AttributeName_var aName; - SALOMEDS::AttributePersistentRef_var aPRef; - if ( InViewer ) - { - if (Sel->IObjectCount()==0) - return NULL; - SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); - Handle(SALOME_InteractiveObject) IObject = It.Value(); - ActorTmp=GetActor(parent,IObject,theRenderer); - } - else - { - item = (QAD_ObjectBrowserItem*)(visuGUI->myActiveStudy->getActiveStudyFrame()->getLeftFrame()->getObjectBrowser()->getListView()->currentItem()); - if ( item != NULL ) - { - // Test if a selected visu object - QString theEntry = item->getEntry(); - - MESSAGE("==================== TheEntry : " << theEntry) - if ( theEntry.isEmpty() ) - { - QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), - tr ("Bad Type for Selected Item in Popup Menu"), - tr ("VISU_BUT_OK") ); - return NULL; - } - - SALOMEDS::SObject_var objVisu = aStudy->FindObjectID(theEntry.latin1()); - if (objVisu->FindAttribute(anAttr, "AttributePersistentRef")) { - aPRef = SALOMEDS::AttributePersistentRef::_narrow(anAttr); - PersRef = aPRef->Value(); - } - - if ( objVisu->_is_nil() ) - { - QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), - tr ("nil object"), - tr ("VISU_BUT_OK") ); - return NULL; - } - ActorTmp=GetActorObjBrowser(objVisu,theRenderer); - } - else - return NULL; - } - return (ActorTmp); -} - -/* ********************************************************************************** */ -/* Function ClearViewer - Erase the actors displayed on the viewer */ -/* ********************************************************************************** */ - -void VisuGUI::ClearViewer(QAD_Desktop* parent, vtkRenderer *ren, int TypeOfActor) -{ - // TypeOfActor = -1 : All - // = 1 : VisuActor - // = 2 : ScalarBarActor - // = 4 : Other Actor2D - - vtkActorCollection *ac; - vtkActor2DCollection *ac2D; - vtkActor *actor; - vtkActor2D *actor2D; - ac = ren->GetActors(); - ac2D = ren->GetActors2D(); - - if(TypeOfActor == -1 || TypeOfActor == 1) { - bool TrhVisible = ((VTKViewer_ViewFrame*)visuGUI->myActiveStudy-> - getActiveStudyFrame()->getRightFrame()->getViewFrame())->isTrihedronDisplayed(); - for(ac->InitTraversal();(actor = ac->GetNextActor())!=NULL;) { - if (actor->IsA("VISU_Actor") || actor->IsA("vtkActor") ) - actor->VisibilityOff(); - } - if (TrhVisible) ShowTrihedron(false); - } - - if(TypeOfActor == -1 || TypeOfActor == 2) { - for(ac2D->InitTraversal();(actor2D = ac2D->GetNextActor2D())!=NULL;) - if (actor2D->IsA("vtkScalarBarActor")) - actor2D->VisibilityOff(); - } - - if(TypeOfActor == -1 || TypeOfActor == 4) { - for(ac2D->InitTraversal();(actor2D = ac2D->GetNextActor2D())!=NULL;) - if (!(actor2D->IsA("vtkScalarBarActor"))) // it's a plot2d - { - actor2D->VisibilityOff(); - //actor2D->Delete(); - } - } -} - /* ********************************************************************************** */ /* Function ShowTrihedron */ /* ********************************************************************************** */ @@ -1137,9 +729,9 @@ void VisuGUI::ClearViewer(QAD_Desktop* parent, vtkRenderer *ren, int TypeOfActor void VisuGUI::ShowTrihedron(bool ShowThd){ bool ThdIsVisible = true; if( ShowThd && !ThdIsVisible) - ((VTKViewer_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTrihedron(); + ((VTKViewer_ViewFrame*)visuGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTrihedron(); if( !ShowThd && ThdIsVisible) - ((VTKViewer_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTrihedron(); + ((VTKViewer_ViewFrame*)visuGUI->GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame())->onViewTrihedron(); } /* ********************************************************************************** */ @@ -1148,7 +740,7 @@ void VisuGUI::ShowTrihedron(bool ShowThd){ /* ********************************************************************************** */ VisuGUI::~VisuGUI(){ - MESSAGE("VisuGUI::~VisuGUI"); + if(MYDEBUG) MESSAGE("VisuGUI::~VisuGUI"); } /* ********************************************************************************** */ @@ -1156,26 +748,30 @@ VisuGUI::~VisuGUI(){ /* Change representation of all actors */ /* ********************************************************************************** */ -void VisuGUI::ChangeViewer(QAD_Desktop* parent, vtkRenderer *ren, bool ScalarBar, int Type) -{ - if (!ren) return; - VisuGUI::GetOrCreateVisuGUI(parent); - vtkActorCollection *ac; - vtkActor *actor; - ac = ren->GetActors(); - - for(ac->InitTraversal();(actor = ac->GetNextActor())!=NULL;) - actor->GetProperty()->SetRepresentation(Type); +void VisuGUI::ChangeViewer(int theType){ + if(vtkRenderer *aRen = GetRenderer()){ + vtkActor *anActor; + vtkActorCollection *anActColl = aRen->GetActors(); + for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){ + if(anActor->GetVisibility() > 0) + if(VISU_Actor* anVISUActor = VISU_Actor::SafeDownCast(anActor)){ + anVISUActor = anVISUActor->GetParent(); + if(theType >= 0) + anVISUActor->SetRepresentation(theType); + else + anVISUActor->VisibilityOff(); + } + } + RepaintCurrentView(); + } } - // ----------------------------------------------------------------------------------------- // EVENTS // ----------------------------------------------------------------------------------------- bool VisuGUI::OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) { - VisuGUI::GetOrCreateVisuGUI(parent); return true; } @@ -1183,7 +779,6 @@ bool VisuGUI::OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame bool VisuGUI::OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) { - VisuGUI::GetOrCreateVisuGUI(parent); return true; } @@ -1191,17 +786,16 @@ bool VisuGUI::OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* bool VisuGUI::OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) { - VisuGUI::GetOrCreateVisuGUI(parent); - if (visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) // true = Viewer OCC + if (GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK) // true = Viewer OCC return false; - MESSAGE ( "VisuGUI::onKeyPress : " << pe->key() ) + if(MYDEBUG) MESSAGE( "VisuGUI::onKeyPress : " << pe->key() ) switch ( pe->key() ) { case Key_Escape : { - MESSAGE("--> Key : Escape") + if(MYDEBUG) MESSAGE("--> Key : Escape") return true; } default : @@ -1220,12 +814,12 @@ bool VisuGUI::OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* st #define CREATEPRESENTATION(FunctionName) \ void FunctionName() { \ - if (checkLock(myStudy)) return; \ + if (checkLock(GetStudyDocument())) return; \ SALOMEDS::SObject_var objVisu; \ - if (!TestObjectBrowser(&objVisu)) return; \ + if (!TestObjectBrowser(objVisu)) return; \ if(!FunctionName(objVisu)) return; \ - visuGUI->myActiveStudy->updateObjBrowser(); \ - myDesktop->putInfo("Ready"); \ + GetActiveStudy()->updateObjBrowser(); \ + GetDesktop()->putInfo("Ready"); \ VTKViewer_ViewFrame* vf = GetVtkViewFrame(); \ if (vf) { \ /*vf->getRenderer()->ResetCameraClippingRange();*/ \ @@ -1239,6 +833,7 @@ CREATEPRESENTATION(VisuGUI::CreateDeformedShape); CREATEPRESENTATION(VisuGUI::CreateVectors); CREATEPRESENTATION(VisuGUI::CreateIsoSurfaces); CREATEPRESENTATION(VisuGUI::CreateCutPlanes); +CREATEPRESENTATION(VisuGUI::CreateCutLines); CREATEPRESENTATION(VisuGUI::CreateStreamLines); @@ -1250,7 +845,21 @@ CREATEPRESENTATION(VisuGUI::CreateStreamLines); //===================================================================================== bool VisuGUI::setSettings(QAD_Desktop* parent) { - VisuGUI::GetOrCreateVisuGUI(parent); + int anId = 53; + QMenuData* pp; + QMenuItem* item = parent->menuBar()->findItem(anId,&pp); + QString aValue = QAD_CONFIG->getSetting("Visu:BuildResult"); + + if(aValue.isEmpty()? 0 : aValue.toInt()) + pp->setItemChecked(anId, true); + + anId = 54; + item = parent->menuBar()->findItem(anId,&pp); + aValue = QAD_CONFIG->getSetting("Visu:BuildDefaultPrs3d"); + + if(aValue.isEmpty()? 0 : aValue.toInt()) + pp->setItemChecked(anId, true); + return true; } @@ -1259,51 +868,40 @@ bool VisuGUI::setSettings(QAD_Desktop* parent) // purpose : //===================================================================================== void VisuGUI::DisplayPrs() { - MESSAGE("VisuGUI::DisplayPrs"); - string aComment; + if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs"); Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj(aComment, anIO, myActiveStudy); + CORBA::Object_var anObject = GetSelectedObj(&anIO); if ( !CORBA::is_nil( anObject ) ) { // is it Prs3d object ? VISU::Prs3d_i* aPrsObject = dynamic_cast(VISU::GetServant(anObject)); if(aPrsObject){ - MESSAGE("VisuGUI::DisplayPrs : Prs3d object"); + if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Prs3d object"); UpdateViewer(aPrsObject); - VTKViewer_ViewFrame* vf = GetVtkViewFrame(); - if (vf) { + if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) { vf->getRenderer()->ResetCameraClippingRange(); -#ifdef CHECKTIME - OSD_Timer timer; - timer.Start(); -#endif vf->Repaint(); vf->highlight(anIO, 1); -#ifdef CHECKTIME - timer.Stop(); - MESSAGE("Check time on VisuGUI::DisplayPrs - vf->Repaint + vf->highlight"); - timer.Show(); -#endif } return; } // is it Curve ? VISU::Curve_i* aCurve = dynamic_cast(VISU::GetServant(anObject)); if(aCurve){ - MESSAGE("VisuGUI::DisplayPrs : Curve object"); + if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Curve object"); PlotCurve(aCurve, VISU::eDisplay ); return; } // is it Container ? VISU::Container_i* aContainer = dynamic_cast(VISU::GetServant(anObject)); if(aContainer){ - MESSAGE("VisuGUI::DisplayPrs : Container object"); + if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Container object"); PlotContainer(aContainer, VISU::eDisplay ); return; } // is it Table ? VISU::Table_i* aTable = dynamic_cast(VISU::GetServant(anObject)); if(aTable){ - MESSAGE("VisuGUI::DisplayPrs : Table object"); + if(MYDEBUG) MESSAGE("VisuGUI::DisplayPrs : Table object"); PlotTable(aTable, VISU::eDisplay ); return; } @@ -1315,43 +913,28 @@ void VisuGUI::DisplayPrs() { // purpose : //===================================================================================== void VisuGUI::DisplayOnlyPrs() { - MESSAGE("VisuGUI::DisplayOnlyPrs"); - string aComment; - Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj(aComment, anIO, myActiveStudy); + if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs"); + CORBA::Object_var anObject = GetSelectedObj(); if ( !CORBA::is_nil( anObject ) ) { // is it Prs3d object ? - VISU::Prs3d_i* aPrsObject = dynamic_cast(VISU::GetServant(anObject)); - if(aPrsObject){ - MESSAGE("VisuGUI::DisplayOnlyPrs : Prs3d object"); + PortableServer::Servant aServant = VISU::GetServant(anObject); + if(VISU::Prs3d_i* aPrsObject = dynamic_cast(aServant)){ + if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Prs3d object"); UpdateViewer(aPrsObject, true); VTKViewer_ViewFrame* vf = GetVtkViewFrame(); if (vf) { vf->getRenderer()->ResetCameraClippingRange(); vf->Repaint(); } - return; - } - // is it Curve ? - VISU::Curve_i* aCurve = dynamic_cast(VISU::GetServant(anObject)); - if(aCurve){ - MESSAGE("VisuGUI::DisplayOnlyPrs : Curve object"); + }else if(VISU::Curve_i* aCurve = dynamic_cast(aServant)){ + if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Curve object"); PlotCurve(aCurve, VISU::eDisplayOnly ); - return; - } - // is it Container ? - VISU::Container_i* aContainer = dynamic_cast(VISU::GetServant(anObject)); - if(aContainer){ - MESSAGE("VisuGUI::DisplayOnlyPrs : Container object"); + }else if(VISU::Container_i* aContainer = dynamic_cast(aServant)){ + if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Container object"); PlotContainer(aContainer, VISU::eDisplayOnly ); - return; - } - // is it Table ? - VISU::Table_i* aTable = dynamic_cast(VISU::GetServant(anObject)); - if(aTable){ - MESSAGE("VisuGUI::DisplayOnlyPrs : Table object"); + }else if(VISU::Table_i* aTable = dynamic_cast(aServant)){ + if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyPrs : Table object"); PlotTable(aTable, VISU::eDisplayOnly ); - return; } } } @@ -1361,15 +944,13 @@ void VisuGUI::DisplayOnlyPrs() { // purpose : //===================================================================================== void VisuGUI::ErasePrs() { - MESSAGE("VisuGUI::ErasePrs"); - string aComment; - Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj(aComment, anIO, myActiveStudy); + if(MYDEBUG) MESSAGE("VisuGUI::ErasePrs"); + CORBA::Object_var anObject = GetSelectedObj(); if ( !CORBA::is_nil( anObject ) ) { // is it Prs3d object ? VISU::Prs3d_i* aPrsObject = dynamic_cast(VISU::GetServant(anObject)); if(aPrsObject){ - MESSAGE("VisuGUI::ErasePrs : Prs3d object"); + if(MYDEBUG) MESSAGE("VisuGUI::ErasePrs : Prs3d object"); ErasePrs(aPrsObject); VTKViewer_ViewFrame* vf = GetVtkViewFrame(); if (vf) { @@ -1379,79 +960,232 @@ void VisuGUI::ErasePrs() { // is it Curve ? VISU::Curve_i* aCurve = dynamic_cast(VISU::GetServant(anObject)); if(aCurve){ - MESSAGE("VisuGUI::ErasePrs : Curve object"); + if(MYDEBUG) MESSAGE("VisuGUI::ErasePrs : Curve object"); PlotCurve(aCurve, VISU::eErase ); } // is it Container ? VISU::Container_i* aContainer = dynamic_cast(VISU::GetServant(anObject)); if(aContainer){ - MESSAGE("VisuGUI::ErasePrs : Container object"); + if(MYDEBUG) MESSAGE("VisuGUI::ErasePrs : Container object"); PlotContainer(aContainer, VISU::eErase ); } // is it Table ? VISU::Table_i* aTable = dynamic_cast(VISU::GetServant(anObject)); if(aTable){ - MESSAGE("VisuGUI::ErasePrs : Table object"); + if(MYDEBUG) MESSAGE("VisuGUI::ErasePrs : Table object"); PlotTable(aTable, VISU::eErase ); } } } - //===================================================================================== -// function : RecreateActor() +// function : DisplayManyPrs() // purpose : //===================================================================================== -void VisuGUI::RecreateActor(VISU::Prs3d_i* thePrs) { - /* BEGIN_OF("VisuGUI::RecreateActor"); - - VTKViewer_ViewFrame* vf = GetVtkViewFrame(); - if (!vf) return; - QApplication::setOverrideCursor( Qt::waitCursor ); - vtkRenderer *aRen = vf->getRenderer(); - VISU_Actor* anVISUActor = GetActor(thePrs); - - if(anVISUActor == NULL){ - anVISUActor= thePrs->CreateActor(); - anVISUActor->SetVisibility(true); - vf->AddActor(anVISUActor); - if (anVISUActor->HasScalarBar()) { - anVISUActor->getScalarBar()->SetVisibility(true); - aRen->AddActor2D(anVISUActor->getScalarBar()); +void VisuGUI::DisplayManyPrs() +{ + if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs"); + SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection()); + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + for ( ; It.More(); It.Next() ) { + Handle(SALOME_InteractiveObject)& anIO = It.Value(); + if ( anIO->hasEntry() ) { + SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); + SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() ); + VISU::Storable::TRestoringMap pMap; + if( !aSObject->_is_nil() ) { + CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject); + if ( !CORBA::is_nil( aCORBAObject ) ) { + // is it Prs3d object ? + VISU::Prs3d_i* aPrsObject = dynamic_cast(VISU::GetServant(aCORBAObject)); + if(aPrsObject){ + if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs : Prs3d object"); + UpdateViewer(aPrsObject); + VTKViewer_ViewFrame* vf = GetVtkViewFrame(); + if (vf) { + vf->getRenderer()->ResetCameraClippingRange(); + vf->Repaint(); + vf->highlight(anIO, 1); + } + continue; + } + // is it Curve ? + VISU::Curve_i* aCurve = dynamic_cast(VISU::GetServant(aCORBAObject)); + if(aCurve){ + if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs: Curve object"); + PlotCurve(aCurve, VISU::eDisplay ); + continue; + } + // is it Container ? + VISU::Container_i* aContainer = dynamic_cast(VISU::GetServant(aCORBAObject)); + if(aContainer){ + if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs : Container object"); + PlotContainer(aContainer, VISU::eDisplay ); + continue; + } + // is it Table ? + VISU::Table_i* aTable = dynamic_cast(VISU::GetServant(aCORBAObject)); + if(aTable){ + if(MYDEBUG) MESSAGE("VisuGUI::DisplayManyPrs : Table object"); + PlotTable(aTable, VISU::eDisplay ); + continue; + } + } + } } } - vf->Repaint(); - - QApplication::restoreOverrideCursor(); +} - END_OF("VisuGUI::RecreateActor") */ - VTKViewer_ViewFrame* vf = GetVtkViewFrame(); - if (!vf) return; +//===================================================================================== +// function : DisplayOnlyManyPrs() +// purpose : +//===================================================================================== +void VisuGUI::DisplayOnlyManyPrs() { + if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs"); + SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection()); + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + bool aFirstElem = true; + for ( ; It.More(); It.Next() ) { + Handle(SALOME_InteractiveObject)& anIO = It.Value(); + if ( anIO->hasEntry() ) { + SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); + SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() ); + VISU::Storable::TRestoringMap pMap; + if( !aSObject->_is_nil() ) { + CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject); + if ( !CORBA::is_nil( aCORBAObject ) ) { + // is it Prs3d object ? + VISU::Prs3d_i* aPrsObject = dynamic_cast(VISU::GetServant(aCORBAObject)); + if(aPrsObject){ + if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs : Prs3d object"); + UpdateViewer(aPrsObject, aFirstElem); + if (aFirstElem) aFirstElem = false; + VTKViewer_ViewFrame* vf = GetVtkViewFrame(); + if (vf) { + vf->getRenderer()->ResetCameraClippingRange(); + vf->Repaint(); + vf->highlight(anIO, 1); + } + continue; + } + // is it Curve ? + VISU::Curve_i* aCurve = dynamic_cast(VISU::GetServant(aCORBAObject)); + if(aCurve){ + if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs: Curve object"); + if (aFirstElem) { + PlotCurve(aCurve, VISU::eDisplayOnly ); + aFirstElem = false; + } + else PlotCurve(aCurve, VISU::eDisplay ); + continue; + } + // is it Container ? + VISU::Container_i* aContainer = dynamic_cast(VISU::GetServant(aCORBAObject)); + if(aContainer){ + if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs : Container object"); + if (aFirstElem) { + PlotContainer(aContainer, VISU::eDisplayOnly ); + aFirstElem = false; + } + else PlotContainer(aContainer, VISU::eDisplay ); + continue; + } + // is it Table ? + VISU::Table_i* aTable = dynamic_cast(VISU::GetServant(aCORBAObject)); + if(aTable){ + if(MYDEBUG) MESSAGE("VisuGUI::DisplayOnlyManyPrs : Table object"); + if (aFirstElem) { + PlotTable(aTable, VISU::eDisplayOnly ); + aFirstElem = false; + } + else PlotTable(aTable, VISU::eDisplay ); + continue; + } + } + } + } + } +} - VISU_Actor* anVISUActor = GetActor(thePrs); - int isVisible = false; - QApplication::setOverrideCursor( Qt::waitCursor ); - vtkRenderer *aRen = vf->getRenderer(); - if (anVISUActor) { - isVisible = anVISUActor->GetVisibility(); - Handle(SALOME_InteractiveObject) anIO = anVISUActor->getIO(); - if (anVISUActor->HasScalarBar()) - aRen->RemoveActor(anVISUActor->getScalarBar()); - aRen->RemoveActor(anVISUActor); - anVISUActor->Delete(); - anVISUActor = thePrs->CreateActor(anIO); - } else - anVISUActor = thePrs->CreateActor(); - QApplication::restoreOverrideCursor(); +//===================================================================================== +// function : EraseManyPrs() +// purpose : +//===================================================================================== +void VisuGUI::EraseManyPrs() +{ + if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs"); + SALOME_Selection* Sel = SALOME_Selection::Selection(QAD_Application::getDesktop()->getActiveStudy()->getSelection()); + SALOME_ListIO LIO; LIO = Sel->StoredIObjects(); + SALOME_ListIteratorOfListIO It( LIO ); + for ( ; It.More(); It.Next() ) { + Handle(SALOME_InteractiveObject)& anIO = It.Value(); + if ( anIO->hasEntry() ) { + SALOMEDS::Study_var aStudy = QAD_Application::getDesktop()->getActiveStudy()->getStudyDocument(); + SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() ); + VISU::Storable::TRestoringMap pMap; + if( !aSObject->_is_nil() ) { + CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject); + if ( !CORBA::is_nil( aCORBAObject ) ) { + // is it Prs3d object ? + VISU::Prs3d_i* aPrsObject = dynamic_cast(VISU::GetServant(aCORBAObject)); + if(aPrsObject){ + if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Prs3d object"); + ErasePrs(aPrsObject); + VTKViewer_ViewFrame* vf = GetVtkViewFrame(); + if (vf) { + vf->Repaint(); + } + continue; + } + // is it Curve ? + VISU::Curve_i* aCurve = dynamic_cast(VISU::GetServant(aCORBAObject)); + if(aCurve){ + if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Curve object"); + PlotCurve(aCurve, VISU::eErase ); + continue; + } + // is it Container ? + VISU::Container_i* aContainer = dynamic_cast(VISU::GetServant(aCORBAObject)); + if(aContainer){ + if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Container object"); + PlotContainer(aContainer, VISU::eErase ); + continue; + } + // is it Table ? + VISU::Table_i* aTable = dynamic_cast(VISU::GetServant(aCORBAObject)); + if(aTable){ + if(MYDEBUG) MESSAGE("VisuGUI::EraseManyPrs : Table object"); + PlotTable(aTable, VISU::eErase ); + continue; + } + } + } + } + } +} - if (!anVISUActor) return; - anVISUActor->SetVisibility(isVisible); - aRen->AddActor(anVISUActor); - if (anVISUActor->HasScalarBar()) { - anVISUActor->getScalarBar()->SetVisibility(isVisible); - aRen->AddActor2D(anVISUActor->getScalarBar()); +//===================================================================================== +// function : RecreateActor() +// purpose : +//===================================================================================== +void VisuGUI::RecreateActor(VISU::Prs3d_i* thePrs) { + QApplication::setOverrideCursor(Qt::waitCursor); + try{ + thePrs->Update(); + for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++) + if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){ + QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame(); + if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast(aVFrame)) + if(VISU_Actor* anActor = GetActor(thePrs,aViewFrame)) + thePrs->UpdateActor(anActor); + } + }catch(std::runtime_error& ex){ + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), + tr ("ERR_CANT_BUILD_PRESENTATION"), + tr ("VISU_BUT_OK") ); } + QApplication::restoreOverrideCursor(); } @@ -1464,16 +1198,16 @@ void VisuGUI::RecreateActor(VISU::Prs3d_i* thePrs) { PrsName* aPrsObject = dynamic_cast(aPrs3d); \ if (aPrsObject) { \ DlgName* aDlg = new DlgName(); \ - aDlg->initFromPrsObject(aPrsObject); \ + aDlg->initFromPrsObject(aPrsObject); \ if ( aDlg->exec() ) { \ aDlg->storeToPrsObject(aPrsObject); \ RecreateActor(aPrsObject); \ /*RepaintCurrentView();*/ \ - VTKViewer_ViewFrame* vf = GetVtkViewFrame(); \ - if (vf) { \ + if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) { \ if ( vf->getRenderer()->GetActors()->GetNumberOfItems () > 0 ) { \ vf->getRenderer()->ResetCameraClippingRange(); \ vf->onViewFitAll(); \ + vf->Repaint(); \ }\ } \ } \ @@ -1481,9 +1215,8 @@ void VisuGUI::RecreateActor(VISU::Prs3d_i* thePrs) { } \ } - void VisuGUI::EditPrs() { - VISU::Prs3d_i* aPrs3d = GetSelectedPrs(); + VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d(); switch (aPrs3d->GetType()) { case VISU::TMESH: // Mesh 13 @@ -1501,6 +1234,10 @@ void VisuGUI::EditPrs() { EDITPRS(VISU::CutPlanes_i, VisuGUI_CutPlanesDlg); break; + case VISU::TCUTLINES: // Cut planes 42 + EDITPRS(VISU::CutLines_i, VisuGUI_CutLinesDlg); + break; + case VISU::TISOSURFACE: // Iso surfaces EDITPRS(VISU::IsoSurfaces_i, VisuGUI_IsoSurfacesDlg); break; @@ -1510,7 +1247,15 @@ void VisuGUI::EditPrs() { case VISU::TSTREAMLINES: EDITPRS(VISU::StreamLines_i, VisuGUI_StreamLinesDlg); + default: + return; } + + Handle(SALOME_InteractiveObject) anIO; + CORBA::Object_var anObject = GetSelectedObj(&anIO); + if ( !CORBA::is_nil( anObject ) ) + if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) + vf->highlight(anIO, 1); } @@ -1519,7 +1264,7 @@ void VisuGUI::EditPrs() { // purpose : //===================================================================================== void VisuGUI::EditScalarBar() { - VISU::Prs3d_i* aPrs3d = GetSelectedPrs(); + VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d(); VISU::ScalarMap_i* aPrsObject = dynamic_cast(aPrs3d); if (aPrsObject) { VisuGUI_ScalarBarDlg* aDlg = new VisuGUI_ScalarBarDlg(false); @@ -1530,7 +1275,14 @@ void VisuGUI::EditScalarBar() { VTKViewer_ViewFrame* vf = GetVtkViewFrame(); if (vf) - vf->Repaint(); + { + vf->Repaint(); + + Handle(SALOME_InteractiveObject) anIO; + CORBA::Object_var anObject = GetSelectedObj(&anIO); + if ( !CORBA::is_nil( anObject ) ) + vf->highlight(anIO, 1); + } if (aDlg->isToSave()) aDlg->storeToResources(); @@ -1546,14 +1298,10 @@ void VisuGUI::EditScalarBar() { // purpose : //===================================================================================== void VisuGUI::CreateMesh() { + SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection()); + SALOMEDS::SObject_var aSObject = GetActiveStudy()->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() ); - //string aComment; - //Handle(SALOME_InteractiveObject) anIO; - //CORBA::Object_var anObject = GetSelectedObj(aComment,anIO, VisuGUI::myActiveStudy); - SALOME_Selection* Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); - SALOMEDS::SObject_var aSObject = myActiveStudy->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() ); - - if (checkLock(myStudy)) return; + if (checkLock(GetStudyDocument())) return; SALOMEDS::SObject_var aSObj = aSObject->GetFather(); aSObj = aSObj->GetFather(); @@ -1562,11 +1310,17 @@ void VisuGUI::CreateMesh() { if(CORBA::is_nil(anObject)) { aSObj = aSObj->GetFather(); anObject = VISU::SObjectToObject(aSObj); - if(CORBA::is_nil(anObject)) return; } - VISU::Result_var aResult = VISU::Result::_narrow(anObject); - if(CORBA::is_nil(aResult)) return; - + VISU::Result_var aResult; + if (!CORBA::is_nil(anObject)) { + aResult = VISU::Result::_narrow(anObject); + } + if(CORBA::is_nil(aResult)) { + QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"), + tr ("WRN_NO_AVAILABLE_DATA"), + tr ("VISU_BUT_OK")); + return; + } VISU::Storable::TRestoringMap aMap; SALOMEDS::GenericAttribute_var anAttr; if(aSObject->FindAttribute(anAttr, "AttributeComment")) { @@ -1580,160 +1334,183 @@ void VisuGUI::CreateMesh() { if(!isExist) return; CORBA::Object_var aMesh; string aMeshName = VISU::Storable::FindValue(aMap,"myMeshName").latin1(); +#ifdef CHECKTIME + Utils_Timer timer; + timer.Start(); +#endif + VISU::Result_i* pResult = dynamic_cast(VISU::GetServant(aResult.in())); if(aComment == "ENTITY"){ VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myId").toInt(); - aMesh = myComponent->MeshOnEntity(aResult,aMeshName.c_str(),anEntity); + if(VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),anEntity)) + aMesh = GetVisuGen()->MeshOnEntity(aResult,aMeshName.c_str(),anEntity); }else if(aComment == "FAMILY"){ VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myEntityId").toInt(); string aFamilyName = VISU::Storable::FindValue(aMap,"myName").latin1(); - aMesh = myComponent->FamilyMeshOnEntity(aResult,aMeshName.c_str(),anEntity,aFamilyName.c_str()); + if(VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),anEntity,aFamilyName.c_str())) + aMesh = GetVisuGen()->FamilyMeshOnEntity(aResult,aMeshName.c_str(),anEntity,aFamilyName.c_str()); }else if(aComment == "GROUP"){ string aGroupName = VISU::Storable::FindValue(aMap,"myName").latin1(); - aMesh = myComponent->GroupMesh(aResult,aMeshName.c_str(),aGroupName.c_str()); + if(VISU::Mesh_i::IsPossible(pResult,aMeshName.c_str(),aGroupName.c_str())) + aMesh = GetVisuGen()->GroupMesh(aResult,aMeshName.c_str(),aGroupName.c_str()); } - QApplication::restoreOverrideCursor(); - if(CORBA::is_nil(aMesh)) return; - - VISU::Mesh_i* pPresent = dynamic_cast(VISU::GetServant(aMesh)); -#ifdef CHECKTIME - OSD_Timer timer; - timer.Start(); -#endif - VISU_Actor *anActor = pPresent->CreateActor(); - if (! anActor ) return; #ifdef CHECKTIME timer.Stop(); - MESSAGE("Check time on VisuGUI::CreateMesh - pPresent->CreateActor"); + cout<<"VisuGUI::CreateMesh() - CREATE MESH\n"; timer.Show(); #endif + + QApplication::restoreOverrideCursor(); + VISU::Mesh_i* pPresent = NULL; + if(!CORBA::is_nil(aMesh)) + pPresent = dynamic_cast(VISU::GetServant(aMesh)); + if (pPresent == NULL) { + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), + tr ("ERR_CANT_BUILD_PRESENTATION"), + tr ("VISU_BUT_OK") ); + return; + } + if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){ - vtkRenderer *aRenderer = vf->getRenderer(); - //visuGUI->ClearViewer(QAD_Application::getDesktop(), aRenderer, -1); - //visuGUI->ShowTrihedron(true); + try{ + VISU_Actor *anActor = pPresent->CreateActor(); #ifdef CHECKTIME - OSD_Timer timer; - timer.Start(); + Utils_Timer timer; + timer.Start(); #endif - vf->AddActor(anActor); - vf->getRenderer()->AddActor(anActor->EdgeDevice); - vf->getRenderer()->ResetCameraClippingRange(); - vf->onViewFitAll(); + vf->AddActor(anActor); + SetFitAll(vf); #ifdef CHECKTIME - timer.Stop(); - MESSAGE("Check time on VisuGUI::CreateMesh - vf->AddActor + vf->onViewFitAll"); - timer.Show(); + timer.Stop(); + cout<<"VisuGUI::CreateMesh() - DISPLAY MESH\n"; + timer.Show(); #endif + //GetActiveStudy()->updateObjBrowser(); //not necessary + GetDesktop()->putInfo("Ready"); + }catch(std::runtime_error& exc){ + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), + tr ("ERR_CANT_CREATE_ACTOR"), + tr ("VISU_BUT_OK") ); + } } - myActiveStudy->updateObjBrowser(); //update Object browser - myDesktop->putInfo("Ready"); } +//===================================================================================== +// function : CreateManyMesh() +// purpose : +//===================================================================================== +void VisuGUI::CreateManyMesh(){ + if (checkLock(GetStudyDocument())) return; + + SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection()); + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + for ( ; It.More(); It.Next() ) { + SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(It.Value()->getEntry()); + SALOMEDS::SObject_var aSObj = aSObject->GetFather(); + aSObj = aSObj->GetFather(); + aSObj = aSObj->GetFather(); + CORBA::Object_var anObject = VISU::SObjectToObject(aSObj); + if(CORBA::is_nil(anObject)) { + aSObj = aSObj->GetFather(); + anObject = VISU::SObjectToObject(aSObj); + if(CORBA::is_nil(anObject)) return; + } + VISU::Result_var aResult = VISU::Result::_narrow(anObject); + if(CORBA::is_nil(aResult)) return; + + VISU::Storable::TRestoringMap aMap; + SALOMEDS::GenericAttribute_var anAttr; + if(aSObject->FindAttribute(anAttr, "AttributeComment")) { + SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr); + string aComm = aComment->Value(); + QString strIn(aComm.c_str()); + VISU::Storable::StrToMap(strIn,aMap); + } + bool isExist; + string aComment = VISU::Storable::FindValue(aMap,"myComment",&isExist).latin1(); + if(!isExist) return; + CORBA::Object_var aMesh; + string aMeshName = VISU::Storable::FindValue(aMap,"myMeshName").latin1(); + if(aComment == "ENTITY"){ + VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myId").toInt(); + aMesh = GetVisuGen()->MeshOnEntity(aResult,aMeshName.c_str(),anEntity); + }else if(aComment == "FAMILY"){ + VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myEntityId").toInt(); + string aFamilyName = VISU::Storable::FindValue(aMap,"myName").latin1(); + aMesh = GetVisuGen()->FamilyMeshOnEntity(aResult,aMeshName.c_str(),anEntity,aFamilyName.c_str()); + }else if(aComment == "GROUP"){ + string aGroupName = VISU::Storable::FindValue(aMap,"myName").latin1(); + aMesh = GetVisuGen()->GroupMesh(aResult,aMeshName.c_str(),aGroupName.c_str()); + } + QApplication::restoreOverrideCursor(); + if(CORBA::is_nil(aMesh)) return; + + VISU::Mesh_i* pPresent = dynamic_cast(VISU::GetServant(aMesh)); + try{ + VISU_Actor *anActor = pPresent->CreateActor(); + if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){ + vf->AddActor(anActor); + SetFitAll(vf); + } + GetDesktop()->putInfo("Ready"); + }catch(std::runtime_error& exc){ + } + } +} //===================================================================================== // function : ChangeRepresentation() // purpose : //===================================================================================== -static void ShrinkMesh(VISU_Actor *Actor){ - if (!(Actor->IsShrunk)){ - vtkDataSetMapper *mapper = (vtkDataSetMapper*) (Actor->GetMapper()); - vtkShrinkFilter *shrink = vtkShrinkFilter::New(); - shrink->SetInput(mapper->GetInput()); - shrink->SetShrinkFactor(0.8); - mapper->SetInput(shrink->GetOutput()); - Actor->IsShrunk = true; - shrink->Delete(); - Actor->EdgeDevice->VisibilityOff(); - }else{ - vtkDataSetMapper *mapper = (vtkDataSetMapper*) (Actor->GetMapper()); - // mpv: we wish to remove shrink filter only instead of all filters ignore -// mapper->SetInput(Actor->DataSource); - vtkDataObject* anObject = mapper->GetInput(); - vtkSource* aPrevSource = (vtkSource*)mapper; - while(anObject != Actor->DataSource) { - vtkShrinkFilter* aShrink = vtkShrinkFilter::SafeDownCast(anObject->GetSource()); - if (aShrink) { - vtkSource* aSource = aShrink->GetInput()->GetSource(); - vtkDataObject** Inputs = aPrevSource->GetInputs(); - vtkDataObject** Outputs = aSource->GetOutputs(); - Outputs[0]->UnRegister(aShrink); - Inputs[0]->UnRegister(aShrink); - Outputs[0]->Register(aPrevSource); - Inputs[0]->Register(aSource); - Inputs[0] = aSource->GetOutputs()[0]; - aSource->Modified(); - aSource->Update(); - - mapper->Update(); +static void ShrinkMesh(VISU_Actor *theActor){ + if(theActor->IsShrunk()) + theActor->UnShrink(); + else + theActor->SetShrink(0.8); +} + +void VisuGUI::ChangeRepresentation(VISU::PresentationType theType) { + if(VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d()) + if(VISU_Actor* anActor = GetActor(aPrsObject)){ + switch (theType) { + case VISU::SHRINK: + ShrinkMesh(anActor); break; + default: + if(VISU::Mesh_i* aMesh = dynamic_cast(aPrsObject)){ + aMesh->SetPresentationType(theType); + RecreateActor(aMesh); + }else + anActor->SetRepresentation(theType); } - aPrevSource = anObject->GetSource(); - anObject = aPrevSource->GetInputs()[0]; + if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) + vf->Repaint(); } - - - Actor->IsShrunk = false; - if ( Actor->GetProperty()->GetRepresentation() == 2 ) - Actor->EdgeDevice->VisibilityOn(); - } } -void VisuGUI::ChangeRepresentation(RepresentType theType) { - VISU::Prs3d_i* aPrsObject = GetSelectedPrs(); - if(!aPrsObject) return; -#ifdef CHECKTIME - OSD_Timer timer; - timer.Start(); -#endif - VISU_Actor* anActor = GetActor(aPrsObject); - if (!anActor) return; - switch (theType) { - case POINTS: - anActor->EdgeDevice->VisibilityOff(); - anActor->GetProperty()->SetRepresentation(0); - anActor->GetProperty()->SetPointSize(VISU_POINT_SIZE); - break; - case WIREFRAME: - anActor->EdgeDevice->VisibilityOff(); - anActor->GetProperty()->SetRepresentation(1); - break; - case SURFACE: - if ( !anActor->IsShrunk ) - anActor->EdgeDevice->VisibilityOn(); - anActor->GetProperty()->SetRepresentation(2); - break; - case SHRINK: - ShrinkMesh(anActor); - break; - } - VTKViewer_ViewFrame* vf = GetVtkViewFrame(); - if (vf) - vf->Repaint(); -#ifdef CHECKTIME - timer.Stop(); - MESSAGE("Cheking time in VisuGUI::ChangeRepresentation - anActor->GetProperty()->SetRepresentation + vf->Repaint"); - timer.Show(); -#endif +void VisuGUI::MakeSurfaceframe() { + ChangeRepresentation(VISU::SURFACEFRAME); +} + +void VisuGUI::MakeInsideframe() { + ChangeRepresentation(VISU::INSIDEFRAME); } void VisuGUI::MakeWireframe() { - ChangeRepresentation(WIREFRAME); + ChangeRepresentation(VISU::WIREFRAME); } - void VisuGUI::MakeSurface() { - ChangeRepresentation(SURFACE); + ChangeRepresentation(VISU::SHADED); } - void VisuGUI::MakePoints() { - ChangeRepresentation(POINTS); + ChangeRepresentation(VISU::POINT); } - void VisuGUI::MakeShrink() { - ChangeRepresentation(SHRINK); + ChangeRepresentation(VISU::SHRINK); } @@ -1742,15 +1519,16 @@ void VisuGUI::MakeShrink() { // functions : Change Propertise // purpose : //===================================================================================== -VISU::Prs3d_i* VisuGUI::GetSelectedPrs() { - string aComment; - Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj(aComment, anIO, myActiveStudy); - return dynamic_cast(VISU::GetServant(anObject)); +VISU::Prs3d_i* VisuGUI::GetSelectedPrs3d(Handle(SALOME_InteractiveObject)* theIO) { + CORBA::Object_var anObject = GetSelectedObj(theIO); + if(CORBA::is_nil(anObject)) return NULL; + PortableServer::Servant aServant = VISU::GetServant(anObject); + if(!aServant) return NULL; + return dynamic_cast(aServant); } void VisuGUI::ChageColor() { - VISU::Prs3d_i* aPrsObject = GetSelectedPrs(); + VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d(); if(!aPrsObject) return; VISU_Actor* anActor = GetActor(aPrsObject); @@ -1758,18 +1536,18 @@ void VisuGUI::ChageColor() { NewColor(anActor); } -void VisuGUI::ChangeOutlineColor() { - VISU::Prs3d_i* aPrsObject = GetSelectedPrs(); +void VisuGUI::ChangeWireframeColor() { + VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d(); if(!aPrsObject) return; - VISU_Actor* anActor = GetActor(aPrsObject); + VISU_MeshAct* anActor = dynamic_cast(GetActor(aPrsObject)); if (!anActor) return; - NewOutlineColor(anActor); + NewWireframeColor(anActor); } void VisuGUI::ChangeOpacity() { - VISU::Prs3d_i* aPrsObject = GetSelectedPrs(); + VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d(); if(!aPrsObject) return; VISU_Actor* anActor = GetActor(aPrsObject); @@ -1779,7 +1557,7 @@ void VisuGUI::ChangeOpacity() { void VisuGUI::ChangeLines() { - VISU::Prs3d_i* aPrsObject = GetSelectedPrs(); + VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d(); if(!aPrsObject) return; VISU_Actor* anActor = GetActor(aPrsObject); @@ -1788,16 +1566,15 @@ void VisuGUI::ChangeLines() { } void VisuGUI::PlotTable( VISU::Table_i* table, int theDisplaying ) { - VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); - if ( table && visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) { - Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame(); + if ( table && GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) { + Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame(); if ( theDisplaying == VISU::eDisplayOnly ) aPlot->EraseAll(); QList clist; aPlot->getCurves( clist ); - SALOMEDS::SObject_var TableSO = visuGUI->myActiveStudy->getStudyDocument()->FindObjectID( table->GetEntry() ); + SALOMEDS::SObject_var TableSO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetEntry() ); if ( !TableSO->_is_nil() ) { - SALOMEDS::ChildIterator_var Iter = visuGUI->myActiveStudy->getStudyDocument()->NewChildIterator( TableSO ); + SALOMEDS::ChildIterator_var Iter = GetActiveStudy()->getStudyDocument()->NewChildIterator( TableSO ); for ( ; Iter->More(); Iter->Next() ) { CORBA::Object_var childObject = VISU::SObjectToObject( Iter->Value() ); if( !CORBA::is_nil( childObject ) ) { @@ -1836,8 +1613,16 @@ void VisuGUI::PlotTable( VISU::Table_i* table, int theDisplaying ) } else { Plot2d_Curve* crv = theCurve->CreatePresentation(); - if ( crv ) + if ( crv ) { aPlot->displayCurve( crv, false ); + theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() ); + theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker()); + SALOMEDS::Color newColor; + newColor.R = crv->getColor().red()/255.; + newColor.G = crv->getColor().green()/255.; + newColor.B = crv->getColor().blue()/255.; + theCurve->SetColor( newColor ); + } } } } @@ -1849,9 +1634,8 @@ void VisuGUI::PlotTable( VISU::Table_i* table, int theDisplaying ) } void VisuGUI::PlotCurve( VISU::Curve_i* theCurve, int theDisplaying ) { - VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); - if ( theCurve && visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) { - Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame(); + if ( theCurve && GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) { + Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame(); // if ( theDisplaying == VISU::eDisplayOnly ) // aPlot->EraseAll(); QList clist; @@ -1890,6 +1674,13 @@ void VisuGUI::PlotCurve( VISU::Curve_i* theCurve, int theDisplaying ) Plot2d_Curve* crv = theCurve->CreatePresentation(); if ( crv ) { aPlot->displayCurve( crv, false ); + theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() ); + theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker()); + SALOMEDS::Color newColor; + newColor.R = crv->getColor().red()/255.; + newColor.G = crv->getColor().green()/255.; + newColor.B = crv->getColor().blue()/255.; + theCurve->SetColor( newColor ); } } } @@ -1898,9 +1689,8 @@ void VisuGUI::PlotCurve( VISU::Curve_i* theCurve, int theDisplaying ) } void VisuGUI::PlotContainer( VISU::Container_i* container, int theDisplaying ) { - VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); - if ( container && visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) { - Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame(); + if ( container && GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) { + Plot2d_ViewFrame* aPlot = (Plot2d_ViewFrame*)GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame(); if ( theDisplaying == VISU::eDisplayOnly ) aPlot->EraseAll(); QList clist; @@ -1942,8 +1732,16 @@ void VisuGUI::PlotContainer( VISU::Container_i* container, int theDisplaying ) } else { Plot2d_Curve* crv = theCurve->CreatePresentation(); - if ( crv ) + if ( crv ) { aPlot->displayCurve( crv, false ); + theCurve->SetLine( (VISU::Curve::LineType)crv->getLine(), crv->getLineWidth() ); + theCurve->SetMarker( (VISU::Curve::MarkerType)crv->getMarker()); + SALOMEDS::Color newColor; + newColor.R = crv->getColor().red()/255.; + newColor.G = crv->getColor().green()/255.; + newColor.B = crv->getColor().blue()/255.; + theCurve->SetColor( newColor ); + } } } } @@ -1952,17 +1750,16 @@ void VisuGUI::PlotContainer( VISU::Container_i* container, int theDisplaying ) aPlot->Repaint(); } } + /*! Slot : opens Table view : for Table object or SObject with table attribute selected */ void VisuGUI::ShowTable() { - VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); - SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() ); + SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() ); if( Sel->IObjectCount() !=1 ) return; - string aComment; - Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj( aComment, anIO, VisuGUI::myActiveStudy ); + Handle(SALOME_InteractiveObject) anIO; + CORBA::Object_var anObject = GetSelectedObj(&anIO); SALOMEDS::SObject_var SO; if ( !CORBA::is_nil( anObject ) ) { VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject); @@ -1971,13 +1768,13 @@ void VisuGUI::ShowTable() { if( !CORBA::is_nil( aTable ) ) { VISU::Table_i* table = dynamic_cast( VISU::GetServant( aTable ) ); if ( table ) { - SO = VisuGUI::myActiveStudy->getStudyDocument()->FindObjectID( table->GetObjectEntry() ); + SO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetObjectEntry() ); } } } } else { // possibly this is Table SObject - SO = VisuGUI::myActiveStudy->getStudyDocument()->FindObjectID( anIO->getEntry() ); + SO = GetActiveStudy()->getStudyDocument()->FindObjectID( anIO->getEntry() ); } SALOMEDS::GenericAttribute_var anAttr; if ( SO->_is_nil() || ( !SO->FindAttribute( anAttr, "AttributeTableOfInteger" ) @@ -1985,20 +1782,47 @@ void VisuGUI::ShowTable() { return; SALOMEGUI_TableDlg* dlg = new SALOMEGUI_TableDlg( QAD_Application::getDesktop(), SO, - false ); + false, + //SAL2670 Orientation of show tables + SALOMEGUI_TableDlg::ttAuto, + Qt::Vertical ); dlg->show(); } + +/*! + Slot : opens Table view : for Table object or SObject with table attribute selected +*/ +void VisuGUI::CreateTable() { + SALOME_Selection* aSel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() ); + if( aSel->IObjectCount() !=1 ) + return; + + Handle(SALOME_InteractiveObject) anIO = aSel->firstIObject(); + if (anIO->hasEntry()){ + SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument(); + SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry()); + if(!aSObject->_is_nil()) { + CORBA::Object_var anObject = VISU::SObjectToObject(aSObject); + VISU::CutLines_var aCutLines = VISU::CutLines::_narrow( anObject ); + SALOMEDS::GenericAttribute_var anAttr; + if(!aCutLines->_is_nil() || + aSObject->FindAttribute( anAttr, "AttributeTableOfInteger") || + aSObject->FindAttribute( anAttr, "AttributeTableOfReal" ) ){ + GetVisuGen()->CreateTable(aSObject->GetID()); + GetActiveStudy()->updateObjBrowser(); + } + } + } +} + /*! Opens dialog box for curves creation. Acts only for selected SObject with table attribute. */ void VisuGUI::PlotData() { - VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); - SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() ); + SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() ); if( Sel->IObjectCount() !=1 ) return; - string aComment; - Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj( aComment, anIO, VisuGUI::myActiveStudy ); + CORBA::Object_var anObject = GetSelectedObj(); SALOMEDS::SObject_var SO; if ( !CORBA::is_nil( anObject ) ) { VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject); @@ -2011,7 +1835,7 @@ void VisuGUI::PlotData() { SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::AttributeName_var aName; QString SOName; - SALOMEDS::SObject_var SO = VisuGUI::myActiveStudy->getStudyDocument()->FindObjectID( table->GetObjectEntry() ); + SALOMEDS::SObject_var SO = GetActiveStudy()->getStudyDocument()->FindObjectID( table->GetObjectEntry() ); if ( !SO->_is_nil() && ( SO->FindAttribute( anAttr, "AttributeTableOfInteger" ) || SO->FindAttribute( anAttr, "AttributeTableOfReal" ) ) ) { // get name of SObject @@ -2021,19 +1845,19 @@ void VisuGUI::PlotData() { } Plot2d_SetupPlot2dDlg* dlg = new Plot2d_SetupPlot2dDlg( SO, QAD_Application::getDesktop() ); if ( dlg->exec() == QDialog::Accepted ) { - if ( !isStudyLocked( visuGUI->myActiveStudy->getStudyDocument() ) ) { + if ( !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) { // if study is not locked - create new container, create curves // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type int horIndex; QValueList verIndices; dlg->getCurvesSource( horIndex, verIndices ); if ( horIndex >= 0 && verIndices.count() > 0 ) { - CORBA::Object_var aContainer = myComponent->CreateContainer(); + CORBA::Object_var aContainer = GetVisuGen()->CreateContainer(); if( !CORBA::is_nil( aContainer ) ) { VISU::Container_i* pContainer = dynamic_cast( VISU::GetServant( aContainer ) ); if ( pContainer ) { for ( int i = 0; i < verIndices.count(); i++ ) { - CORBA::Object_var aNewCurve = myComponent->CreateCurve( table->_this(), horIndex+1, verIndices[i]+1 ); + CORBA::Object_var aNewCurve = GetVisuGen()->CreateCurve( table->_this(), horIndex+1, verIndices[i]+1 ); if( !CORBA::is_nil( aNewCurve ) ) { VISU::Curve_i* pCrv = dynamic_cast( VISU::GetServant( aNewCurve ) ); if ( pCrv ) { @@ -2050,7 +1874,7 @@ void VisuGUI::PlotData() { } } } - VisuGUI::myActiveStudy->updateObjBrowser( true ); + GetActiveStudy()->updateObjBrowser( true ); PlotContainer( pContainer, VISU::eDisplay ); } } @@ -2061,9 +1885,9 @@ void VisuGUI::PlotData() { Plot2d_CurveContainer container; dlg->getCurves( container ); if ( !container.isEmpty() ) { - ((Plot2d_ViewFrame*)(visuGUI->myActiveStudy->getActiveStudyFrame()-> + ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()-> getRightFrame()->getViewFrame()))->displayCurves( container, true ); - ((Plot2d_ViewFrame*)(visuGUI->myActiveStudy->getActiveStudyFrame()-> + ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()-> getRightFrame()->getViewFrame()))->setTitle( SOName ); } } @@ -2081,7 +1905,7 @@ void VisuGUI::PlotData() { QString SOName; // check if Table SObject is selected - SALOMEDS::SObject_var SO = VisuGUI::myActiveStudy->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() ); + SALOMEDS::SObject_var SO = GetActiveStudy()->getStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() ); if ( !SO->_is_nil() && ( SO->FindAttribute( anAttr, "AttributeTableOfInteger" ) || SO->FindAttribute( anAttr, "AttributeTableOfReal" ) ) ) { // get name of SObject @@ -2091,22 +1915,22 @@ void VisuGUI::PlotData() { } Plot2d_SetupPlot2dDlg* dlg = new Plot2d_SetupPlot2dDlg( SO, QAD_Application::getDesktop() ); if ( dlg->exec() == QDialog::Accepted ) { - if ( !isStudyLocked( visuGUI->myActiveStudy->getStudyDocument() ) ) { + if ( !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) { // if study is not locked - create new table and container objects, create curves // and insert them into container, then plot container if current viewer is of VIEW_PLOT2D type int horIndex; QValueList verIndices; dlg->getCurvesSource( horIndex, verIndices ); if ( horIndex >= 0 && verIndices.count() > 0 ) { - CORBA::Object_var aTable = myComponent->CreateTable( SO->GetID() ); - CORBA::Object_var aContainer = myComponent->CreateContainer(); + CORBA::Object_var aTable = GetVisuGen()->CreateTable( SO->GetID() ); + CORBA::Object_var aContainer = GetVisuGen()->CreateContainer(); if ( !CORBA::is_nil( aTable ) && !CORBA::is_nil( aContainer ) ) { VISU::Table_i* pTable = dynamic_cast( VISU::GetServant( aTable ) ); VISU::Container_i* pContainer = dynamic_cast( VISU::GetServant( aContainer ) ); if ( pContainer && pTable ) { for ( int i = 0; i < verIndices.count(); i++ ) { - CORBA::Object_var aNewCurve = myComponent->CreateCurve( pTable->_this(), horIndex+1, verIndices[i]+1 ); + CORBA::Object_var aNewCurve = GetVisuGen()->CreateCurve( pTable->_this(), horIndex+1, verIndices[i]+1 ); if( !CORBA::is_nil( aNewCurve ) ) { VISU::Curve_i* pCrv = dynamic_cast( VISU::GetServant( aNewCurve ) ); if ( pCrv ) { @@ -2123,7 +1947,7 @@ void VisuGUI::PlotData() { } } } - VisuGUI::myActiveStudy->updateObjBrowser( true ); + GetActiveStudy()->updateObjBrowser( true ); PlotContainer( pContainer, VISU::eDisplay ); } } @@ -2131,13 +1955,13 @@ void VisuGUI::PlotData() { } else { // if study is locked just get curves info and plot them if current viewer is of VIEW_PLOT2D type - if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) { + if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) { Plot2d_CurveContainer container; dlg->getCurves( container ); if ( !container.isEmpty() ) { - ((Plot2d_ViewFrame*)(visuGUI->myActiveStudy->getActiveStudyFrame()-> + ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()-> getRightFrame()->getViewFrame()))->displayCurves( container, true ); - ((Plot2d_ViewFrame*)(visuGUI->myActiveStudy->getActiveStudyFrame()-> + ((Plot2d_ViewFrame*)(GetActiveStudy()->getActiveStudyFrame()-> getRightFrame()->getViewFrame()))->setTitle( SOName ); } } @@ -2151,13 +1975,10 @@ void VisuGUI::PlotData() { Slot : Opens "Setup curve" dialog to set curve properties : for Curve object selected */ void VisuGUI::CurveProperties() { - VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); - SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() ); + SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() ); if( Sel->IObjectCount() !=1 ) return; - string aComment; - Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj( aComment, anIO, VisuGUI::myActiveStudy ); + CORBA::Object_var anObject = GetSelectedObj(); SALOMEDS::SObject_var SO; if (CORBA::is_nil( anObject )) return; @@ -2167,7 +1988,7 @@ void VisuGUI::CurveProperties() { CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject ); if( !CORBA::is_nil( aCurve ) ) { VISU::Curve_i* curve = dynamic_cast( VISU::GetServant( aCurve ) ); - if ( curve && !isStudyLocked( visuGUI->myActiveStudy->getStudyDocument() ) ) { + if ( curve && !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) { SALOMEGUI_SetupCurveDlg* dlg = new SALOMEGUI_SetupCurveDlg( QAD_Application::getDesktop() ); dlg->setLine( (int)curve->GetLine(), curve->GetLineWidth() ); dlg->setMarker( (int)curve->GetMarker() ); @@ -2181,7 +2002,7 @@ void VisuGUI::CurveProperties() { newColor.G = dlg->getColor().green()/255.; newColor.B = dlg->getColor().blue()/255.; curve->SetColor( newColor ); - QList sfList = VisuGUI::myActiveStudy->getStudyFrames(); + QList sfList = GetActiveStudy()->getStudyFrames(); if ( sfList.count() > 0 ) { QListIterator it( sfList ); for ( ; it.current(); ++it ) { @@ -2211,14 +2032,11 @@ void VisuGUI::CurveProperties() { Slot : Clears container contents : for Container object selected */ void VisuGUI::ClearContainer() { - VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); - SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() ); + SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() ); if( Sel->IObjectCount() !=1 ) return; - - string aComment; - Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj( aComment, anIO, VisuGUI::myActiveStudy ); + + CORBA::Object_var anObject = GetSelectedObj(); SALOMEDS::SObject_var SO; if (CORBA::is_nil( anObject )) return; @@ -2228,9 +2046,9 @@ void VisuGUI::ClearContainer() { CORBA::Object_ptr aCnt = VISU::Container::_narrow( anObject ); if( !CORBA::is_nil( aCnt ) ) { VISU::Container_i* container = dynamic_cast( VISU::GetServant( aCnt ) ); - if ( container && container->GetNbCurves() > 0 && !isStudyLocked( visuGUI->myActiveStudy->getStudyDocument() ) ) { + if ( container && container->GetNbCurves() > 0 && !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) { container->Clear(); - VisuGUI::myActiveStudy->updateObjBrowser(); + GetActiveStudy()->updateObjBrowser(); } } } @@ -2238,76 +2056,61 @@ void VisuGUI::ClearContainer() { void VisuGUI::DeletePrs() { - DeletePresentation(GetSelectedPrs()); + DeletePresentation(GetSelectedPrs3d()); } + void VisuGUI::SaveViewParams() { - if (checkLock(myStudy)) return; - VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); - SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() ); - if ( Sel->IObjectCount() > 1 || VisuGUI::myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) - return; - // getting view manager - CORBA::Object_var aVM = VisuGUI::myComponent->GetViewManager(); - if( CORBA::is_nil( aVM ) ) + if (checkLock(GetStudyDocument())) return; + SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() ); + if ( Sel->IObjectCount() > 1 || GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) return; - VISU::ViewManager_i* pVM = dynamic_cast( VISU::GetServant( aVM ) ); - if ( !pVM ) - return; - // getting current 3d view - CORBA::Object_var aView = pVM->GetCurrentView(); - if( CORBA::is_nil( aView ) ) - return; - VISU::View3D_i* pView = dynamic_cast( VISU::GetServant( aView ) ); - if ( !pView ) - return; - if ( Sel->IObjectCount() == 0 ) { - // Save view parameters by new name - pView->SaveViewParams( 0 ); - VisuGUI::myActiveStudy->updateObjBrowser( true ); - } - else { - // Try to save view parameters by selected object's name - string aComment; - Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj( aComment, anIO, VisuGUI::myActiveStudy ); -// QString strIn( aComment.c_str() ); -// VISU::Storable::RestoringMapType aMap; -// VISU::Storable::StrToMap( strIn,aMap ); -// QString aCmt = VISU::Storable::FindValue( aMap, "myComment" ); - if (ObjectTypes.find( aComment.c_str() ) == 6 ) { - pView->SaveViewParams( anIO->getName() ); - VisuGUI::myActiveStudy->updateObjBrowser( true ); + VISU::ViewManager_var aVM = GetVisuGen()->GetViewManager(); + if(!CORBA::is_nil(aVM.in())){ + VISU::View_var aView = aVM->GetCurrentView(); + if(!CORBA::is_nil(aView.in())){ + VISU::View3D_var aView3D = VISU::View3D::_narrow(aView); + if(CORBA::is_nil(aView3D.in())) return; + if ( Sel->IObjectCount() == 0 ) { + // Save view parameters by new name + aView3D->SaveViewParams( 0 ); + GetActiveStudy()->updateObjBrowser( true ); + }else{ + bool isExist; + VISU::Storable::TRestoringMap aMap; + Handle(SALOME_InteractiveObject) anIO; + CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap); + VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt(); + if(isExist && aType == VISU::TVIEW3D){ + aView3D->SaveViewParams( anIO->getName() ); + GetActiveStudy()->updateObjBrowser( true ); + } + } } } } + + void VisuGUI::RestoreViewParams() { - VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); - SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() ); - if ( Sel->IObjectCount() > 1 || VisuGUI::myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) - return; - // getting view manager - CORBA::Object_var aVM = VisuGUI::myComponent->GetViewManager(); - if( CORBA::is_nil( aVM ) ) - return; - VISU::ViewManager_i* pVM = dynamic_cast( VISU::GetServant( aVM ) ); - if ( !pVM ) - return; - // getting current 3d view - CORBA::Object_var aView = pVM->GetCurrentView(); - if( CORBA::is_nil( aView ) ) + SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() ); + if ( Sel->IObjectCount() > 1 || GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) return; - VISU::View3D_i* pView = dynamic_cast( VISU::GetServant( aView ) ); - if ( !pView ) - return; - string aComment; - Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj( aComment, anIO, VisuGUI::myActiveStudy ); - QString aCmt = aComment.c_str(); - if ( !aCmt.isEmpty() && ObjectTypes.find( aCmt ) == 6 ) { - pView->RestoreViewParams( anIO->getName() ); + VISU::ViewManager_var aVM = GetVisuGen()->GetViewManager(); + if(!CORBA::is_nil(aVM.in())){ + VISU::View_var aView = aVM->GetCurrentView(); + if(!CORBA::is_nil(aView.in())){ + VISU::View3D_var aView3D = VISU::View3D::_narrow(aView); + if(CORBA::is_nil(aView3D.in())) return; + bool isExist; + VISU::Storable::TRestoringMap aMap; + Handle(SALOME_InteractiveObject) anIO; + CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap); + VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt(); + if(isExist && aType == VISU::TVIEW3D) + aView3D->RestoreViewParams( anIO->getName() ); + } } } @@ -2316,37 +2119,21 @@ void VisuGUI::RestoreViewParams() // purpose : //===================================================================================== void VisuGUI::DeleteViewParams() { - VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); - SALOME_Selection* Sel = SALOME_Selection::Selection(VisuGUI::myActiveStudy->getSelection()); - if( Sel->IObjectCount() > 0 ) { - SALOME_ListIteratorOfListIO aSelectionIterator(Sel->StoredIObjects()); - for(;aSelectionIterator.More(); aSelectionIterator.Next()) { - Handle(SALOME_InteractiveObject) anIO = aSelectionIterator.Value(); - if (anIO->hasEntry()){ - SALOMEDS::SObject_var aSObject = MYStudyDocument->FindObjectID(anIO->getEntry()); - if(!aSObject->_is_nil()){ - SALOMEDS::GenericAttribute_var anAttr; - if (aSObject->FindAttribute(anAttr, "AttributeComment")) { - SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr); - int aType; - // possibly this is view params - QString strIn(aComment->Value()); - VISU::Storable::TRestoringMap aMap; - VISU::Storable::StrToMap( strIn, aMap ); - QString aCmt; - bool isExist; - aCmt = VISU::Storable::FindValue( aMap, "myComment", &isExist ); - if ( isExist ) aType = ObjectTypes.find( aCmt ); - if (aType == 6) { - MYStudyDocument->NewBuilder()->RemoveObject(aSObject); - Sel->RemoveIObject(anIO, 0); - } - } - } - } - } + bool isExist; + VISU::Storable::TRestoringMap aMap; + Handle(SALOME_InteractiveObject) anIO; + CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap); + VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt(); + if(isExist && aType == VISU::TVIEW3D){ + SALOMEDS::Study_var aStudy = GetStudyDocument(); + SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(anIO->getEntry()); + aStudy->NewBuilder()->RemoveObject(aSObject); + + SALOME_Selection* aSel = SALOME_Selection::Selection(GetActiveStudy()->getSelection()); + aSel->RemoveIObject(anIO, 0); + + GetActiveStudy()->updateObjBrowser( true ); } - VisuGUI::myActiveStudy->updateObjBrowser( true ); } @@ -2355,9 +2142,12 @@ void VisuGUI::DeleteViewParams() { // purpose : //===================================================================================== void VisuGUI::Sweep() { - VISU::ScalarMap_i* aPrsObject = dynamic_cast(GetSelectedPrs()); + VISU::ScalarMap_i* aPrsObject = dynamic_cast(GetSelectedPrs3d()); if (!aPrsObject) return; + VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame(); + if(!vf) return; + int aTemp=100000; QString aTempoStr = QAD_CONFIG->getSetting("Visu:SweepTempo"); if ( !aTempoStr.isEmpty() ) @@ -2378,88 +2168,17 @@ void VisuGUI::Sweep() { if (!aActor->GetVisibility()) { aActor->VisibilityOn(); - if (aActor->HasScalarBar()) - aActor->getScalarBar()->VisibilityOn(); } - vtkDataSetMapper* aMapper = (vtkDataSetMapper*) aActor->GetMapper(); - VISU_LookupTable* aLookupTbl = (VISU_LookupTable*) aMapper->GetLookupTable(); QApplication::setOverrideCursor( Qt::waitCursor ); - - switch (aPrsObject->GetType()) { - case VISU::TCUTPLANES: // Cut planes 42 - case VISU::TSCALARMAP: // ScalarMap 18 - for (int j=0 ; jSetMapScale(float(i)/float(aSteps)); - RepaintCurrentView(); - usleep(aTemp); - } - } - break; - - case VISU::TDEFORMEDSHAPE: // Deformed Shape 28 - { - VISU::DeformedShape_i* aDefPrs = dynamic_cast(aPrsObject); - if (aDefPrs) { - float aScale = aDefPrs->GetScale(); - bool isColored = aDefPrs->isColored(); - - vtkWarpVector* aWarp = vtkWarpVector::New(); - if((VISU::Entity)aDefPrs->GetField()->myEntity == VISU::CELL) { - vtkCellDataToPointData *aFilter = vtkCellDataToPointData::New(); - aFilter->SetInput(aDefPrs->GetInput()->GetUnstructuredGridOutput()); - aFilter->PassCellDataOn(); - aWarp->SetInput(aFilter->GetUnstructuredGridOutput()); - aFilter->Delete(); - } else - aWarp->SetInput(aDefPrs->GetInput()->GetUnstructuredGridOutput()); - for (int j=0 ; jSetScaleFactor(aScale*float(i)/float(aSteps)); - aMapper->SetInput(aWarp->GetOutput()); - - if (isColored) - aLookupTbl->SetMapScale(float(i)/float(aSteps)); - RepaintCurrentView(); - usleep(aTemp); - } - } - aWarp->Delete(); - } - } - break; - - case VISU::TISOSURFACE: // Iso surfaces - { - VISU::IsoSurfaces_i* aIsoPrs = dynamic_cast(aPrsObject); - if (aIsoPrs) { - int nbIso = aIsoPrs->GetNbSurfaces(); - if (nbIso <= 1) break; - vtkContourFilter* aContourFilter = vtkContourFilter::New(); - if ((VISU::Entity)aIsoPrs->GetField()->myEntity == VISU::CELL) { - vtkCellDataToPointData *aFilter = vtkCellDataToPointData::New(); - aFilter->SetInput(aIsoPrs->GetInput()->GetUnstructuredGridOutput()); - aFilter->PassCellDataOn(); - aContourFilter->SetInput(aFilter->GetOutput()); - aFilter->Delete(); - } else - aContourFilter->SetInput(aIsoPrs->GetInput()->GetUnstructuredGridOutput()); - float aMul; - for (int j=0 ; jSetMapScale(aMul); - aContourFilter->GenerateValues(nbIso*(i+1)/aSteps,aIsoPrs->GetRangeMin(),aIsoPrs->GetRangeMax()); - aMapper->SetInput(aContourFilter->GetOutput()); - RepaintCurrentView(); - usleep(aTemp); - } - } - aContourFilter->Delete(); - } + for (int j=0 ; jSetMapScale(aPercents); + aPrsObject->UpdateActor(aActor); + vf->getRW()->getRenderWindow()->Render(); + usleep(aTemp); } - break; } QApplication::restoreOverrideCursor(); } @@ -2467,14 +2186,14 @@ void VisuGUI::Sweep() { void VisuGUI::TimeAnimation() { - VisuGUI_TimeAnimationDlg* aAnimationDlg = new VisuGUI_TimeAnimationDlg(myStudy); - SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() ); + VisuGUI_TimeAnimationDlg* aAnimationDlg = new VisuGUI_TimeAnimationDlg(GetStudyDocument()); + SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() ); bool isDefined = false; long aNbTimes = 0; SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); for (; It.More(); It.Next()) { - SALOMEDS::SObject_var aSObject = myStudy->FindObjectID( It.Value()->getEntry() ); + SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID( It.Value()->getEntry() ); if (aSObject->_is_nil()) continue; if (getValue(aSObject, "myComment") == QString("FIELD")) { long aNumber = getValue(aSObject, "myNbTimeStamps").toLong(); @@ -2494,88 +2213,157 @@ void VisuGUI::TimeAnimation() { } - void VisuGUI::ImportMedField() { - if (checkLock(myStudy)) return; - - VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); - SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() ); + if (checkLock(GetStudyDocument())) return; + SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() ); SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); QApplication::setOverrideCursor( Qt::waitCursor ); for(;It.More();It.Next()) { Handle(SALOME_InteractiveObject) anIO = It.Value(); - SALOMEDS::SObject_var aSObject = MYStudyDocument->FindObjectID(anIO->getEntry()); + SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry()); if(!aSObject->_is_nil()){ - SALOMEDS::GenericAttribute_var anAttr; - aSObject->FindAttribute(anAttr, "AttributeIOR"); - if(!anAttr->_is_nil()){ - SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr); - if(!anIOR->_is_nil()){ - CORBA::String_var aValue = anIOR->Value(); - if(strcmp(aValue,"") != 0){ - CORBA::ORB_var anORB = VISU::GetORB(); - CORBA::Object_var anObject = anORB->string_to_object(aValue); - if ( !CORBA::is_nil( anObject ) ) { - SALOME_MED::FIELD_ptr aField = SALOME_MED::FIELD::_narrow( anObject ); - if( !CORBA::is_nil( aField ) ) { - VisuGUI::myComponent->ImportMed( aField ); - continue; - } - SALOME_MED::MESH_ptr aMesh = SALOME_MED::MESH::_narrow( anObject ); - if( !CORBA::is_nil( aMesh ) ) { - VisuGUI::myComponent->ImportMedMesh( aMesh ); - continue; - } - SALOME_MED::SUPPORT_ptr aSupport = SALOME_MED::SUPPORT::_narrow( anObject ); - if( !CORBA::is_nil( aSupport ) ) { - VisuGUI::myComponent->ImportMedSupport( aSupport ); - continue; - } - } - } - } + CORBA::Object_var anObject = VISU::SObjectToObject(aSObject); + if(!CORBA::is_nil(anObject)){ + SALOME_MED::MED_var aMED = SALOME_MED::MED::_narrow( anObject ); + if(!CORBA::is_nil(aMED.in())) + GetVisuGen()->ImportMed( aSObject ); + SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow( anObject ); + if(!CORBA::is_nil(aField.in())) + GetVisuGen()->ImportMedField( aField ); + }else{ + SALOMEDS::SObject_var aSFather = aSObject->GetFather(); + SALOMEDS::GenericAttribute_var anAttr; + aSFather->FindAttribute(anAttr, "AttributeName"); + SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr); + CORBA::String_var aValue = aName->Value(); + if(strcmp(aValue.in(),"MEDFIELD") == 0) + GetVisuGen()->ImportMed(aSObject); + //if(strcmp(aValue.in(),"MEDMESH") == 0) + // VisuGUI::myComponent->ImportMed(aSObject); } } } - VisuGUI::myActiveStudy->updateObjBrowser( true ); + GetActiveStudy()->updateObjBrowser( true ); QApplication::restoreOverrideCursor(); } -/* -void VisuGUI::ImportMedMesh() { - VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); - SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() ); + +//===================================================================================== +// functions : Rename() +// purpose : +//===================================================================================== +void VisuGUI::Rename() { + if (checkLock(GetStudyDocument())) return; + SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() ); if ( Sel->IObjectCount() != 1 ) return; - string aComment; - Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj( aComment,anIO, VisuGUI::myActiveStudy); - if ( !CORBA::is_nil( anObject ) ) { - SALOME_MED::MESH_ptr aMesh = SALOME_MED::MESH::_narrow( anObject ); - if( !CORBA::is_nil( aMesh ) ) { - VisuGUI::myComponent->ImportMedMesh( aMesh ); - VisuGUI::myActiveStudy->updateObjBrowser( true ); + SALOMEDS::SObject_var aSObj = GetStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() ); + if( aSObj->_is_nil() ) return; + + VISU::Curve_i* curve = 0; + CORBA::Object_var anObject = GetSelectedObj(); + if ( !CORBA::is_nil( anObject )) { + VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject); + if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCURVE) { + // Curve object + CORBA::Object_ptr aCurve = VISU::Curve::_narrow( anObject ); + if( !CORBA::is_nil( aCurve ) ) { + curve = dynamic_cast( VISU::GetServant( aCurve ) ); + } + } + } + + //TEST DU PARENT == VISU + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + if ( aSObj->FindAttribute(anAttr, "AttributeName") ) { + aName = SALOMEDS::AttributeName::_narrow( anAttr ); + QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), aName->Value() ); + if ( !Name.isEmpty() ) { + QApplication::setOverrideCursor( Qt::waitCursor ); + if ( curve ) + curve->SetName( Name.latin1() ); + GetActiveStudy()->renameIObject( Sel->firstIObject(), Name ); + QApplication::restoreOverrideCursor(); + + //int TypeMode; bool InViewer; + //VISU_Actor *ActorTmp = ActorSelected(parent,InViewer,&TypeMode); + //ActorTmp->setName((Standard_CString)Name.latin1()); + } + } +} + +//===================================================================================== +// functions : RenameTable() +// purpose : +//===================================================================================== +void VisuGUI::RenameTable() { + if (checkLock(GetStudyDocument())) return; + SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() ); + if ( Sel->IObjectCount() != 1 ) + return; + SALOMEDS::SObject_var aSObj = GetStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() ); + if( aSObj->_is_nil() ) return; + + VISU::Table_i* table = 0; + CORBA::Object_var anObject = GetSelectedObj(); + if ( !CORBA::is_nil( anObject )) { + VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject); + if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TTABLE) { + // Table object + CORBA::Object_ptr aTable = VISU::Table::_narrow( anObject ); + if( !CORBA::is_nil( aTable ) ) { + table = dynamic_cast( VISU::GetServant( aTable ) ); + } } - SALOME_MED::SUPPORT_ptr aSupport = SALOME_MED::SUPPORT::_narrow( anObject ); - if( !CORBA::is_nil( aSupport ) ) { - VisuGUI::myComponent->ImportMedSupport( aSupport ); - VisuGUI::myActiveStudy->updateObjBrowser( true ); + } + + //TEST DU PARENT == VISU + SALOMEDS::GenericAttribute_var anAttr; + SALOMEDS::AttributeName_var aName; + if ( aSObj->FindAttribute(anAttr, "AttributeName") ) { + aName = SALOMEDS::AttributeName::_narrow( anAttr ); + QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), aName->Value() ); + if ( !Name.isEmpty() ) { + QApplication::setOverrideCursor( Qt::waitCursor ); + if ( table ) + table->SetName( Name.latin1() ); + GetActiveStudy()->renameIObject( Sel->firstIObject(), Name ); + QApplication::restoreOverrideCursor(); + + //int TypeMode; bool InViewer; + //VISU_Actor *ActorTmp = ActorSelected(parent,InViewer,&TypeMode); + //ActorTmp->setName((Standard_CString)Name.latin1()); } } } -*/ + + + //===================================================================================== -// functions : Rename() +// functions : RenameContainer() // purpose : //===================================================================================== -void VisuGUI::Rename() { - if (checkLock(myStudy)) return; - VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); - SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() ); +void VisuGUI::RenameContainer() { + if (checkLock(GetStudyDocument())) return; + SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() ); if ( Sel->IObjectCount() != 1 ) return; - SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( Sel->firstIObject()->getEntry() ); + SALOMEDS::SObject_var aSObj = GetStudyDocument()->FindObjectID( Sel->firstIObject()->getEntry() ); if( aSObj->_is_nil() ) return; + VISU::Container_i* container = 0; + CORBA::Object_var anObject = GetSelectedObj(); + if ( !CORBA::is_nil( anObject )) { + VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject); + if (!CORBA::is_nil(aVisuObj) && aVisuObj->GetType() == VISU::TCONTAINER) { + // Curve object + CORBA::Object_ptr aContainer = VISU::Container::_narrow( anObject ); + if( !CORBA::is_nil( aContainer ) ) { + container = dynamic_cast( VISU::GetServant( aContainer ) ); + } + } + } + //TEST DU PARENT == VISU SALOMEDS::GenericAttribute_var anAttr; SALOMEDS::AttributeName_var aName; @@ -2584,7 +2372,9 @@ void VisuGUI::Rename() { QString Name = SALOMEGUI_NameDlg::getName( QAD_Application::getDesktop(), aName->Value() ); if ( !Name.isEmpty() ) { QApplication::setOverrideCursor( Qt::waitCursor ); - VisuGUI::myActiveStudy->renameIObject( Sel->firstIObject(), Name ); + if ( container ) + container->SetName( Name.latin1() ); + GetActiveStudy()->renameIObject( Sel->firstIObject(), Name ); QApplication::restoreOverrideCursor(); //int TypeMode; bool InViewer; @@ -2595,13 +2385,14 @@ void VisuGUI::Rename() { } + //===================================================================================== // function : CopyPresentation() // purpose : //===================================================================================== void VisuGUI::CopyPresentation(){ - if (checkLock(myStudy)) return; - VISU::Prs3d_i* aPrsObject = GetSelectedPrs(); + if (checkLock(GetStudyDocument())) return; + VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d(); if (!aPrsObject) return; switch (aPrsObject->GetType()) { case VISU::TMESH: @@ -2609,7 +2400,7 @@ void VisuGUI::CopyPresentation(){ VISU::Mesh_i* aMeshPrs = dynamic_cast(aPrsObject); VISU::Mesh_i* aSameMesh = new VISU::Mesh_i(aMeshPrs->GetResult()); aSameMesh->SameAs(aMeshPrs); - UpdateViewer(aSameMesh, true); + UpdateViewer(aSameMesh); } break; case VISU::TSCALARMAP: @@ -2617,7 +2408,7 @@ void VisuGUI::CopyPresentation(){ VISU::ScalarMap_i* aScalarPrs = dynamic_cast(aPrsObject); VISU::ScalarMap_i* aSameScalar = new VISU::ScalarMap_i(aScalarPrs->GetResult()); aSameScalar->SameAs(aScalarPrs); - UpdateViewer(aSameScalar, true); + UpdateViewer(aSameScalar); } break; case VISU::TDEFORMEDSHAPE: @@ -2625,7 +2416,7 @@ void VisuGUI::CopyPresentation(){ VISU::DeformedShape_i* aDefPrs = dynamic_cast(aPrsObject); VISU::DeformedShape_i* aSameDeformed = new VISU::DeformedShape_i(aDefPrs->GetResult()); aSameDeformed->SameAs(aDefPrs); - UpdateViewer(aSameDeformed, true); + UpdateViewer(aSameDeformed); } break; case VISU::TCUTPLANES: @@ -2633,15 +2424,23 @@ void VisuGUI::CopyPresentation(){ VISU::CutPlanes_i* aCutPrs = dynamic_cast(aPrsObject); VISU::CutPlanes_i* aSameCut = new VISU::CutPlanes_i(aCutPrs->GetResult()); aSameCut->SameAs(aCutPrs); - UpdateViewer(aSameCut, true); + UpdateViewer(aSameCut); + } + break; + case VISU::TCUTLINES: + { + VISU::CutLines_i* aCutPrs = dynamic_cast(aPrsObject); + VISU::CutLines_i* aSameCut = new VISU::CutLines_i(aCutPrs->GetResult()); + aSameCut->SameAs(aCutPrs); + UpdateViewer(aSameCut); } break; - case VISU::TISOSURFACE: + case VISU::TISOSURFACE: { VISU::IsoSurfaces_i* aIsoPrs = dynamic_cast(aPrsObject); VISU::IsoSurfaces_i* aSameIso = new VISU::IsoSurfaces_i(aIsoPrs->GetResult()); aSameIso->SameAs(aIsoPrs); - UpdateViewer(aSameIso, true); + UpdateViewer(aSameIso); } break; case VISU::TSTREAMLINES: @@ -2649,7 +2448,7 @@ void VisuGUI::CopyPresentation(){ VISU::StreamLines_i* aLinesPrs = dynamic_cast(aPrsObject); VISU::StreamLines_i* aSameLines = new VISU::StreamLines_i(aLinesPrs->GetResult()); aSameLines->SameAs(aLinesPrs); - UpdateViewer(aSameLines, true); + UpdateViewer(aSameLines); } break; case VISU::TVECTORS: @@ -2657,56 +2456,51 @@ void VisuGUI::CopyPresentation(){ VISU::Vectors_i* aVectorsPrs = dynamic_cast(aPrsObject); VISU::Vectors_i* aSameVectors = new VISU::Vectors_i(aVectorsPrs->GetResult()); aSameVectors->SameAs(aVectorsPrs); - UpdateViewer(aSameVectors, true); + UpdateViewer(aSameVectors); } break; } - myActiveStudy->updateObjBrowser(); + GetActiveStudy()->updateObjBrowser(); } //===================================================================================== // function : InfoOnPoint() [ slot ] // purpose : //===================================================================================== -void VisuGUI::InfoOnPoint() -{ - VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop()); - if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) - return; - int TypeMode; - VISU_Actor* ActorTmp = ActorSelected( visuGUI->myDesktop, true, &TypeMode ); - if ( !ActorTmp ) - return; - - if ( TypeMode == SelectionPoint ) - Selection->PickingResults( visuGUI->myActiveStudy, TypeMode, ActorTmp ); - else - QAD_MessageBox::warn1( visuGUI->myDesktop, - tr ("WARNING"), - tr ("Not Point selection mode"), - tr ("VISU_BUT_OK") ); +void VisuGUI::InfoOnPoint(){ + GetInfo(SelectionPoint,&(VisuGUI_Selection::PickingPoint)); } //===================================================================================== // function : InfoOnCell() [ slot ] // purpose : //===================================================================================== -void VisuGUI::InfoOnCell() -{ - VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop()); - if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) - return; - int TypeMode; - VISU_Actor* ActorTmp = ActorSelected( visuGUI->myDesktop, true, &TypeMode ); - if ( !ActorTmp ) - return; - - if ( TypeMode == SelectionCell || TypeMode == SelectionEdge ) - Selection->PickingResults( visuGUI->myActiveStudy, TypeMode, ActorTmp ); - else - QAD_MessageBox::warn1( visuGUI->myDesktop, +void VisuGUI::InfoOnCell(){ + GetInfo(SelectionCell,&(VisuGUI_Selection::PickingCell)); +} + +void VisuGUI::GetInfo(int theSelectionMode, TGetInfoFun theGetInfoFun){ + SALOME_Selection *aSel = SALOME_Selection::Selection(GetActiveStudy()->getSelection()); + if ( aSel->SelectionMode() == theSelectionMode ){ + Handle(SALOME_InteractiveObject) anIO; + if(VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d(&anIO)){ + TColStd_MapOfInteger aMapIndex; + aSel->GetIndex(anIO,aMapIndex); + TColStd_MapIteratorOfMapOfInteger anIter(aMapIndex); + if(anIter.More()){ + vtkDataSet* aDataSet = aPrs3d->GetPipeLine()->GetMapper()->GetInput(); + (*theGetInfoFun)(GetActiveStudy(), aDataSet, anIter.Key()); + return; + } + } + QAD_MessageBox::warn1(QAD_Application::getDesktop(), + tr ("VISU_WARNING"), + tr ("WRN_NO_AVAILABLE_DATA"), + tr ("VISU_BUT_OK")); + }else + QAD_MessageBox::warn1( GetDesktop(), tr ("WARNING"), - tr ("Not Cell/Edge selection mode"), + tr ("ERR_WRONG_SELECTION_MODE"), tr ("VISU_BUT_OK") ); } @@ -2714,105 +2508,169 @@ void VisuGUI::InfoOnCell() // function : SelectPoint() [ slot ] // purpose : //===================================================================================== -void VisuGUI::SelectPoint() -{ - VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop()); - if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) - return; - vtkRenderer* theRenderer = GetRenderer( visuGUI->myActiveStudy ); - int TypeMode; - VISU_Actor* ActorTmp = ActorSelected( visuGUI->myDesktop, true, &TypeMode ); - if ( !ActorTmp ) - return; - if ( TypeMode != SelectionPoint ) { - QAD_MessageBox::warn1( visuGUI->myDesktop, - tr ("WARNING"), - tr ("Not Point selection mode"), - tr ("VISU_BUT_OK") ); - return; - } - - bool ok = FALSE; - vtkDataSetMapper* Mapper = (vtkDataSetMapper*) (ActorTmp->GetMapper()); - Mapper->SetInput(ActorTmp->DataSource); - vtkDataSet *Data=Mapper->GetInput(); - int nbPoints=Data->GetNumberOfPoints(); - int selectedPoint = SALOMEGUI_SetValueDlg::getInteger( tr("Point selection"), - tr("Point number:" ), - 0, - &ok, - visuGUI->myDesktop ); - if ( ok && theRenderer && selectedPoint > 0 && selectedPoint <= nbPoints ) - Selection->HighlightPoint( selectedPoint, nbPoints, ActorTmp, theRenderer ); +void VisuGUI::SelectPoint(){ + Select(SelectionPoint,&vtkDataSet::GetNumberOfPoints,"Point selection","Point number:"); } //===================================================================================== // function : SelectCell() [ slot ] // purpose : //===================================================================================== -void VisuGUI::SelectCell() +void VisuGUI::SelectCell(){ + Select(SelectionCell,&vtkDataSet::GetNumberOfCells,"Cell selection","Cell number:"); +} + +void VisuGUI::Select(int theSelectionMode, TSelectFun theSelectFun, + const char* theTitle, const char* theRequest) { - VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop()); - SALOME_Selection* Sel = SALOME_Selection::Selection(visuGUI->myActiveStudy->getSelection()); - if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) - return; - vtkRenderer* theRenderer = GetRenderer( visuGUI->myActiveStudy ); - int TypeMode=Sel->SelectionMode(); - if ( TypeMode != SelectionCell && TypeMode != SelectionEdge ) { - QAD_MessageBox::warn1( visuGUI->myDesktop, + SALOME_Selection *aSel = SALOME_Selection::Selection(GetActiveStudy()->getSelection()); + if(aSel->SelectionMode() == theSelectionMode){ + Handle(SALOME_InteractiveObject) anIO; + if(VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d(&anIO)){ + bool ok = FALSE; + int anIndex = 0; + TColStd_MapOfInteger aMapIndex; + aSel->GetIndex(anIO,aMapIndex); + TColStd_MapIteratorOfMapOfInteger anIter(aMapIndex); + if(anIter.More()) anIndex = anIter.Key(); + int anId = SALOMEGUI_SetValueDlg::getInteger( tr(theTitle), + tr(theRequest), + anIndex, + &ok, + GetDesktop()); + if(!ok) return; + vtkDataSet* aDataSet = aPrs3d->GetPipeLine()->GetMapper()->GetInput(); + int aMaxId = (aDataSet->*theSelectFun)(); + if(0 <= anId && anId < aMaxId){ + VisuGUI_Selection::Highlight( GetActiveStudy(), anIO, anId ); + return; + } + } + QAD_MessageBox::warn1(QAD_Application::getDesktop(), + tr ("VISU_WARNING"), + tr ("WRN_NO_AVAILABLE_DATA"), + tr ("VISU_BUT_OK")); + }else + QAD_MessageBox::warn1( GetDesktop(), tr ("WARNING"), - tr ("Not Cell/Edge selection mode"), + tr ("ERR_WRONG_SELECTION_MODE"), tr ("VISU_BUT_OK") ); - return; - } - VISU_Actor* ActorTmp; - string aComment; - Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj(aComment,anIO,visuGUI->myActiveStudy); - //srn: Added check if anObject is Null, then break -// if(CORBA::is_nil(anObject)) break; - - VISU::Prs3d_i* aPrsObject = NULL; - if(!CORBA::is_nil(anObject)) - aPrsObject = dynamic_cast(VISU::GetServant(anObject)); - if(aPrsObject){ - //aPrsObject->SetIO(anIO); - //ActorTmp = aPrsObject->GetActor(); - //UpdateViewer(ActorTmp); - ActorTmp = visuGUI->UpdateViewer(aPrsObject); - } else { - ActorTmp = ActorSelected(visuGUI->myDesktop,true,&TypeMode); +} + +//===================================================================================== +// function : DefinePopup() +// purpose : +//===================================================================================== +void VisuGUI::DefinePopup( QString & theContext, QString & theParent, QString & theObject ) +{ + theObject = ""; + theContext = ""; +} + + +//===================================================================================== +// function : checkHomoSelection() +// purpose : +//===================================================================================== +enum { homoNone=0, homoCurves, homoPresentations, homoPresentable, homoAnimatable, homoOther }; +int VisuGUI::checkHomoSelection() +{ + int selMode = homoNone; + SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection()); + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + for ( ; It.More(); It.Next() ) { + int selNext = homoOther; + Handle(SALOME_InteractiveObject)& anIO = It.Value(); + if ( anIO->hasEntry() ) { + SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument(); + SALOMEDS::SObject_var aSObject = aStudy->FindObjectID( anIO->getEntry() ); + VISU::Storable::TRestoringMap pMap; + if( !aSObject->_is_nil() ) { + CORBA::Object_var aCORBAObject = VISU::SObjectToObject(aSObject); + 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::TTABLE: + case VISU::TCURVE: + case VISU::TCONTAINER: + selNext = homoCurves; break; + case VISU::TMESH: + case VISU::TSCALARMAP: + case VISU::TISOSURFACE: + case VISU::TDEFORMEDSHAPE: + case VISU::TCUTPLANES: + case VISU::TCUTLINES: + case VISU::TVECTORS: + case VISU::TSTREAMLINES: + selNext = homoPresentations; break; + case VISU::TFIELD: + if (getValue(aSObject, "myNbTimeStamps").toLong() > 1) { + selNext = homoAnimatable; break; + } + selNext = homoOther; break; + default: + selNext = homoOther; + } + } + } + else { + SALOMEDS::GenericAttribute_var anAttr; + if ( aSObject->FindAttribute( anAttr, "AttributeComment") ) { + SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow( anAttr ); + string aComm = aComment->Value(); + QString strIn( aComm.c_str() ); + 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::TENTITY: + case VISU::TFAMILY: + case VISU::TGROUP: + selNext = homoPresentable; break; + case VISU::TFIELD: + if (getValue(aSObject, "myNbTimeStamps").toLong() > 1) { + selNext = homoAnimatable; break; + } + selNext = homoOther; break; + default: + selNext = homoOther; + } + } + } + } + } + } + if ( selMode == homoNone ) + selMode = selNext; + else { + if ( selMode != selNext ) + return homoNone; + } } - if (ActorTmp==NULL) - return; - - bool ok=FALSE; - vtkDataSetMapper *Mapper = (vtkDataSetMapper*) (ActorTmp->GetMapper()); - Mapper->SetInput(ActorTmp->DataSource); - vtkDataSet *Data=Mapper->GetInput(); - int nbCells=Data->GetNumberOfCells(); - int selectedCell = SALOMEGUI_SetValueDlg::getInteger( tr("Cell selection"), - tr("Cell number:" ), - 0, - &ok, - visuGUI->myDesktop ); - if ( ok && theRenderer && selectedCell > 0 && selectedCell <= nbCells ) - if (ok && theRenderer ) - Selection->HighlightCell(selectedCell , ActorTmp , theRenderer); + return selMode; } //===================================================================================== -// function : DefinePopup() -// purpose : +// function : GetNbChildren() [ static ] +// purpose : get number of children //===================================================================================== -void VisuGUI::DefinePopup( QString & theContext, QString & theParent, QString & theObject ) +int GetNbChildren( SALOMEDS::SObject_var SO, bool refToo ) { - VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop()); - theObject = ""; - theContext = ""; + if ( SO->_is_nil() ) + return 0; + int cnt = 0; + SALOMEDS::ChildIterator_var Iter = SO->GetStudy()->NewChildIterator( SO ); + for ( ; Iter->More(); Iter->Next() ) { + SALOMEDS::SObject_var refSO; + if ( !Iter->Value()->ReferencedObject( refSO ) || refToo ) + cnt++; + } + return cnt; } - //===================================================================================== // function : CustomPopup() // purpose : @@ -2821,35 +2679,50 @@ bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QStri const QString & theParent, const QString & theObject) { int isViewer = (theParent.compare("ObjectBrowser") != 0), initId = isViewer? 800: 900; - VisuGUI::GetOrCreateVisuGUI(parent); QAD_ResourceMgr* rmgr = parent->createResourceManager(); - bool isVTKViewer = (visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK); + bool isVTKViewer = (GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK); thePopup->clear(); - - SALOME_Selection* Sel = SALOME_Selection::Selection(VisuGUI::myActiveStudy->getSelection()); - if ( Sel->IObjectCount() == 0 ) { + SALOME_Selection* aSelection = SALOME_Selection::Selection(GetActiveStudy()->getSelection()); + if ( aSelection->IObjectCount() == 0 ) { if ( theParent == "Viewer" && isVTKViewer) // Available only for VTK viewer thePopup->insertItem( "Save view parameters", visuGUI, SLOT( SaveViewParams() ) ); return false; } - + if( aSelection->IObjectCount() > 1 ) { + int selMode = checkHomoSelection(); + if(MYDEBUG) MESSAGE("VisuGUI::CustomPopup: multiple selection : selMode = "<getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) { + thePopup->insertItem( "Display", visuGUI, SLOT( DisplayManyPrs() ) ); + thePopup->insertItem( "Erase", visuGUI, SLOT( EraseManyPrs () ) ); + thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyManyPrs() ) ); + } + } + else if ( selMode == homoPresentations ) { + if (isVTKViewer) { + thePopup->insertItem( "Display", visuGUI, SLOT( DisplayManyPrs() ) ); + thePopup->insertItem( "Erase", visuGUI, SLOT( EraseManyPrs () ) ); + } + } + else if ( selMode == homoPresentable ) { + thePopup->insertItem("Create Presentations", visuGUI, SLOT(CreateManyMesh())); + } + else if ( selMode == homoAnimatable ) { + thePopup->insertItem( "Animation...", visuGUI, SLOT( TimeAnimation() ) ); + } + return true; + } VISU::Storable::TRestoringMap aMap; - Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj(VisuGUI::myActiveStudy,&anIO,&aMap); - bool isExist; - string aComment = VISU::Storable::FindValue(aMap,"myComment",&isExist).latin1(); - if(!isExist) aComment = "NONE"; - SALOMEDS::GenericAttribute_var anAttr; - + Handle(SALOME_InteractiveObject) anIO; + CORBA::Object_var anObject = GetSelectedObj(&anIO,GetActiveStudy(),&aMap); if (!CORBA::is_nil(anObject)) { + SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry()); VISU::Base_var aVisuObj = VISU::Base::_narrow(anObject); if (!CORBA::is_nil(aVisuObj)) { - if( Sel->IObjectCount() > 1) return false; - VISU::VISUType aType = aVisuObj->GetType(); - MESSAGE("VisuGUI::CustomPopup - VISU object :: "<insertItem("Import From File", visuGUI, SLOT(ImportFromFile())); @@ -2857,25 +2730,30 @@ bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QStri case VISU::TRESULT: //thePopup->insertItem("Create Mesh", visuGUI, SLOT(CreateMesh())); - thePopup->insertItem("Export To File", visuGUI, SLOT(ExportToFile())); + //thePopup->insertItem("Export To File", visuGUI, SLOT(ExportToFile())); //thePopup->insertItem("Delete", visuGUI, SLOT(DeletePrs())); break; case VISU::TTABLE: + thePopup->insertItem( "Rename...", visuGUI, SLOT( RenameTable() ) ); thePopup->insertItem( "Show Table", visuGUI, SLOT( ShowTable() ) ); thePopup->insertItem( "Create Curves", visuGUI, SLOT( PlotData() ) ); - if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) { - thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) ); - thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) ); - thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) ); + if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) { + if ( GetNbChildren( aSObject, false ) > 0 ) { + thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) ); + thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) ); + thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) ); + } } break; case VISU::TCURVE: - if ( !isStudyLocked( visuGUI->myActiveStudy->getStudyDocument() ) ) + if ( !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) { thePopup->insertItem( "Properties", visuGUI, SLOT( CurveProperties() ) ); - if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) { - if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame()->isVisible( anIO ) ) + thePopup->insertItem( "Rename...", visuGUI, SLOT(Rename())); + } + if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) { + if ( GetActiveStudy()->getActiveStudyFrame()->getRightFrame()->getViewFrame()->isVisible( anIO ) ) thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) ); else thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) ); @@ -2889,9 +2767,11 @@ bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QStri if( !CORBA::is_nil( aCnt ) ) { VISU::Container_i* container = dynamic_cast( VISU::GetServant( aCnt ) ); if ( container && container->GetNbCurves() > 0 ) { - if ( !isStudyLocked( visuGUI->myActiveStudy->getStudyDocument() ) ) + if ( !isStudyLocked( GetActiveStudy()->getStudyDocument() ) ) { + thePopup->insertItem( "Rename...", visuGUI, SLOT( RenameContainer() ) ); thePopup->insertItem( "Clear", visuGUI, SLOT( ClearContainer() ) ); - if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) { + } + if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) { thePopup->insertItem( "Display", visuGUI, SLOT( DisplayPrs() ) ); thePopup->insertItem( "Erase", visuGUI, SLOT( ErasePrs () ) ); thePopup->insertItem( "Display Only", visuGUI, SLOT( DisplayOnlyPrs() ) ); @@ -2905,39 +2785,78 @@ bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QStri { VISU::Prs3d_i* aPrsObject = dynamic_cast(VISU::GetServant(anObject)); if (aPrsObject) { - VISU_Actor* anVISUActor = visuGUI->GetActor(aPrsObject); if (isVTKViewer) { // Add Presentation menu - if ((aType != VISU::TSTREAMLINES) && anVISUActor) { - QPopupMenu* aPresMenu = new QPopupMenu(VisuGUI::myDesktop); - aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe())); - aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface())); - aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints())); - if (anVISUActor->IsShrinkable) { - if (anVISUActor->IsShrunk) - aPresMenu->insertItem("Unshrink", visuGUI, SLOT(MakeShrink())); - else - aPresMenu->insertItem("Shrink", visuGUI, SLOT(MakeShrink())); + if (VISU_Actor* anVISUActor = visuGUI->GetActor(aPrsObject)){ + QPopupMenu* aPresMenu = new QPopupMenu(GetDesktop()); + int aRepresent = anVISUActor->GetRepresentation(); + switch(aRepresent){ + case VISU::POINT : + aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe())); + aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface())); + if (aType == VISU::TMESH || aType == VISU::TSCALARMAP || aType == VISU::TDEFORMEDSHAPE) + aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe())); + if (aType == VISU::TMESH) + aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe())); + break; + case VISU::WIREFRAME : + aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints())); + aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface())); + if (aType == VISU::TMESH || aType == VISU::TSCALARMAP || aType == VISU::TDEFORMEDSHAPE) + aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe())); + if (aType == VISU::TMESH) + aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe())); + break; + case VISU::SHADED : + aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints())); + aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe())); + if (aType == VISU::TMESH || aType == VISU::TSCALARMAP || aType == VISU::TDEFORMEDSHAPE) + aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe())); + if (aType == VISU::TMESH) + aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe())); + break; + case VISU::INSIDEFRAME : + aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints())); + aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface())); + aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe())); + if (aType == VISU::TMESH) + aPresMenu->insertItem("Surfaceframe", visuGUI, SLOT(MakeSurfaceframe())); + break; + case VISU::SURFACEFRAME : + aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints())); + aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface())); + aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe())); + aPresMenu->insertItem("Insideframe", visuGUI, SLOT(MakeInsideframe())); + break; + } + if(anVISUActor->GetShrinkable()) + if(aType != VISU::TVECTORS && aType != VISU::TSTREAMLINES){ + if (anVISUActor->IsShrunk()) + aPresMenu->insertItem("Unshrink", visuGUI, SLOT(MakeShrink())); + else + aPresMenu->insertItem("Shrink", visuGUI, SLOT(MakeShrink())); + } + thePopup->insertItem("Representation", aPresMenu); + + // Add Properties + QPopupMenu* aPropMenu = new QPopupMenu(GetDesktop()); + if(aType == VISU::TMESH){ + if(aRepresent == VISU::SURFACEFRAME){ + aPropMenu->insertItem("Cell Color", visuGUI, SLOT(ChageColor())); + aPropMenu->insertItem("Edge Color", visuGUI, SLOT(ChangeWireframeColor())); + }else + aPropMenu->insertItem("Color", visuGUI, SLOT(ChageColor())); + }else if(aType == VISU::TDEFORMEDSHAPE) + aPropMenu->insertItem("Color", visuGUI, SLOT(ChageColor())); + + if (aType != VISU::TVECTORS && aType != VISU::TSTREAMLINES) + aPropMenu->insertItem("Opacity", visuGUI, SLOT(ChangeOpacity())); + if (aType != VISU::TVECTORS){ + aPropMenu->insertItem("Line width", visuGUI, SLOT(ChangeLines())); + thePopup->insertItem("Properties", aPropMenu); } - thePopup->insertItem("Representation", aPresMenu); + thePopup->insertSeparator(); } - - // Add Properties - QPopupMenu* aPropMenu = new QPopupMenu(VisuGUI::myDesktop); - if ((aType == VISU::TMESH) || - (aType == VISU::TDEFORMEDSHAPE) || - (aType == VISU::TVECTORS) || - (aType == VISU::TSTREAMLINES)) // Mesh, deformed shape, vectors - aPropMenu->insertItem("Color", visuGUI, SLOT(ChageColor())); - if (aType == VISU::TMESH) - aPropMenu->insertItem("Outline Color", visuGUI, SLOT(ChangeOutlineColor())); - - if ((aType != VISU::TVECTORS) && (aType != VISU::TSTREAMLINES)) - aPropMenu->insertItem("Opacity", visuGUI, SLOT(ChangeOpacity())); - aPropMenu->insertItem("Line width", visuGUI, SLOT(ChangeLines())); - thePopup->insertItem("Properties", aPropMenu); - - thePopup->insertSeparator(); } thePopup->insertItem("Rename...", visuGUI, SLOT(Rename())); if (aType != VISU::TMESH) { @@ -2945,8 +2864,11 @@ bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QStri thePopup->insertItem("Edit...", visuGUI, SLOT(EditPrs())); thePopup->insertItem("Edit Scalar Bar...", visuGUI, SLOT(EditScalarBar())); - if ((aType != VISU::TVECTORS) && (aType != VISU::TSTREAMLINES) && isVTKViewer) - thePopup->insertItem("Animate", visuGUI, SLOT(Sweep())); + if (aType == VISU::TCUTLINES) + thePopup->insertItem( "Create Table", visuGUI, SLOT( CreateTable() ) ); + + thePopup->insertItem("Sweep", visuGUI, SLOT(Sweep())); + } if (isVTKViewer) { if ( theParent == "Viewer" && @@ -2954,116 +2876,117 @@ bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QStri aType == VISU::TSCALARMAP || aType == VISU::TDEFORMEDSHAPE ) ) { thePopup->insertSeparator(); - if ( Sel->SelectionMode() == SelectionPoint ) { - thePopup->insertItem("Results at Point", visuGUI, SLOT(InfoOnPoint())); + TColStd_MapOfInteger aMapIndex; + aSelection->GetIndex(anIO,aMapIndex); + if ( aSelection->SelectionMode() == SelectionPoint ) { + if(aMapIndex.Extent() == 1) + thePopup->insertItem("Results at Point", visuGUI, SLOT(InfoOnPoint())); thePopup->insertItem("Select a Point", visuGUI, SLOT(SelectPoint())); } - else if ( Sel->SelectionMode() == SelectionCell || Sel->SelectionMode() == SelectionEdge ) { - thePopup->insertItem("Results on Cell", visuGUI, SLOT(InfoOnCell())); + else if ( aSelection->SelectionMode() == SelectionCell) { + if(aMapIndex.Extent() == 1) + thePopup->insertItem("Results on Cell", visuGUI, SLOT(InfoOnCell())); thePopup->insertItem("Select a Cell", visuGUI, SLOT(SelectCell())); } } thePopup->insertSeparator(); - if (visuGUI->IsDisplayed(aPrsObject) ) - thePopup->insertItem("Hide", visuGUI, SLOT(ErasePrs())); + + if (visuGUI->IsDisplayed(aPrsObject) ){ + thePopup->insertItem("Erase", visuGUI, SLOT(ErasePrs())); + } else thePopup->insertItem("Display", visuGUI, SLOT(DisplayPrs())); thePopup->insertItem("Display Only", visuGUI, SLOT(DisplayOnlyPrs())); } - if (aType != VISU::TMESH) + if (aType != VISU::TMESH) { thePopup->insertItem("Delete", visuGUI, SLOT(DeletePrs())); - thePopup->insertSeparator(); - thePopup->insertItem("Same As", visuGUI, SLOT(CopyPresentation())); + thePopup->insertSeparator(); + thePopup->insertItem("Same As", visuGUI, SLOT(CopyPresentation())); + } } } } return false; } + else { - // possibly this is the MED field/mesh and suppot objects - /*CORBA::Object_var anObj = SALOME_MED::FIELD::_narrow( anObject ); - if( !CORBA::is_nil( anObj ) ) { - thePopup->insertItem( "Import Field", visuGUI, SLOT( ImportMedField() ) ); - return false; - } - anObj = SALOME_MED::MESH::_narrow( anObject ); - if( !CORBA::is_nil( anObj ) ) { - thePopup->insertItem( "Import Mesh", visuGUI, SLOT( ImportMedField() ) ); - return false; - } - anObj = SALOME_MED::GROUP::_narrow( anObject ); - if( !CORBA::is_nil( anObj ) ) { - thePopup->insertItem( "Import Group", visuGUI, SLOT( ImportMedField() ) ); + // possibly this is the MED field/mesh and support objects + SALOME_MED::MED_ptr aMED = SALOME_MED::MED::_narrow( anObject ); + if(!CORBA::is_nil(aMED)) + thePopup->insertItem( "Import Structure", visuGUI, SLOT( ImportMedField() ) ); + SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow( anObject ); + if(!CORBA::is_nil(aField)) + thePopup->insertItem( "Import TimeStamp", visuGUI, SLOT( ImportMedField() ) ); + return false; + } + }else{ + SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry()); + if(!aSObject->_is_nil()){ + bool isExist; + VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt(); + if(isExist){ + switch (aType) { + case VISU::TENTITY: + case VISU::TFAMILY: + case VISU::TGROUP: + thePopup->insertItem("Create Presentation", visuGUI, SLOT(CreateMesh())); + break; + case VISU::TVIEW3D: + if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { + // Available only for VTK viewer + thePopup->insertItem( "Save view parameters", visuGUI, SLOT( SaveViewParams() ) ); + thePopup->insertItem( "Restore view parameters", visuGUI, SLOT( RestoreViewParams() ) ); + } + thePopup->insertItem( "Rename...", visuGUI, SLOT( Rename() ) ); + thePopup->insertItem("Delete", visuGUI, SLOT(DeleteViewParams())); + break; + case VISU::TFIELD: + if ((getValue(aSObject, "myNbTimeStamps").toLong() > 1) && isVTKViewer) + thePopup->insertItem( "Animation...", visuGUI, SLOT( TimeAnimation() ) ); + break; + case VISU::TTIMESTAMP: { + int aNunComponent = VISU::Storable::FindValue(aMap,"myNumComponent",&isExist).toInt(); + thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_SCALAR_MAP") ), + "Scalar Map...", visuGUI, SLOT(CreateScalarMap())); + thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_ISO_SURFACES") ), + "Iso Surfaces...", visuGUI, SLOT(CreateIsoSurfaces())); + thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_CUT_PLANES") ), + "Cut Planes...", visuGUI, SLOT(CreateCutPlanes())); + thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_CUT_LINES") ), + "Cut Lines...", visuGUI, SLOT(CreateCutLines())); + if(aNunComponent > 1){ + thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_DEFORMED_SHAPE") ), + "Deformed Shape...", visuGUI, SLOT(CreateDeformedShape())); + thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_VECTORS") ), + "Vectors...", visuGUI, SLOT(CreateVectors())); + thePopup->insertItem(rmgr->loadPixmap( "VISU", tr("ICON_STREAM_LINES") ), + "Stream lines...", visuGUI, SLOT(CreateStreamLines())); + } + break; + } + } return false; - } - anObj = SALOME_MED::FAMILY::_narrow( anObject ); - if( !CORBA::is_nil( anObj ) ) { - thePopup->insertItem( "Import Family", visuGUI, SLOT( ImportMedField() ) ); + }else{ + SALOMEDS::GenericAttribute_var anAttr; + if(aSObject->FindAttribute( anAttr, "AttributeTableOfInteger" ) || + aSObject->FindAttribute( anAttr, "AttributeTableOfReal" )){ + thePopup->insertItem( "Show Table", visuGUI, SLOT(ShowTable())); + thePopup->insertItem( "Create Curves", visuGUI, SLOT(PlotData())); + return false; + } + aSObject = aSObject->GetFather(); + aSObject->FindAttribute(anAttr, "AttributeName"); + SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr); + CORBA::String_var aValue = aName->Value(); + //if(strcmp(aValue.in(),"MEDMESH") == 0) + // thePopup->insertItem( "Import MED", visuGUI, SLOT( ImportMedField() ) ); + if(strcmp(aValue.in(),"MEDFIELD") == 0) + thePopup->insertItem( "Import Field", visuGUI, SLOT( ImportMedField() ) ); return false; } - anObj = SALOME_MED::SUPPORT::_narrow( anObject ); - if( !CORBA::is_nil( anObj ) ) { - thePopup->insertItem( "Import Support", visuGUI, SLOT( ImportMedField() ) ); - return false; - }*/ - } - } - int aType = ObjectTypes.find( aComment.c_str() ); - if(MYDEBUG) MESSAGE("VisuGUI::CustomPopup - aComment = "<FindAttribute( anAttr, "AttributeTableOfReal" ) ) ) { - thePopup->insertItem( "Show Table", visuGUI, SLOT( ShowTable() ) ); - thePopup->insertItem( "Create Curves", visuGUI, SLOT( PlotData() ) ); - } - return false; - } - if(aComment == "ENTITY" || aComment == "FAMILY" || aComment == "GROUP") - thePopup->insertItem("Create Presentation", visuGUI, SLOT(CreateMesh())); - switch (aType) { - case 0: // Field - if (getValue(obj, "myNbTimeStamps").toLong() > 1) - thePopup->insertItem( "Animation...", visuGUI, SLOT( TimeAnimation() ) ); - break; - - case 6: // VIEW3D node - if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK ) { - // Available only for VTK viewer - thePopup->insertItem( "Save view parameters", visuGUI, SLOT( SaveViewParams() ) ); - thePopup->insertItem( "Restore view parameters", visuGUI, SLOT( RestoreViewParams() ) ); - } - thePopup->insertItem( "Rename...", visuGUI, SLOT( Rename() ) ); - thePopup->insertItem("Delete", visuGUI, SLOT(DeleteViewParams())); - break; - - //case 13: // Mesh node - //thePopup->insertItem("Create Presentation", visuGUI, SLOT(CreateMesh())); - //break; - - case 18: { // Timestamp -// if( isStudyLocked(VisuGUI::myActiveStudy->getStudyDocument())) -// return false; - int aNunComponent = VISU::Storable::FindValue(aMap,"myNumComponent",&isExist).toInt(); - thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_SCALAR_MAP") ), - "Scalar Map...", visuGUI, SLOT(CreateScalarMap())); - thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_ISO_SURFACES") ), - "Iso Surfaces...", visuGUI, SLOT(CreateIsoSurfaces())); - thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_CUT_PLANES") ), - "Cut Planes...", visuGUI, SLOT(CreateCutPlanes())); - if(aNunComponent > 1){ - thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_DEFORMED_SHAPE") ), - "Deformed Shape...", visuGUI, SLOT(CreateDeformedShape())); - thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_VECTORS") ), - "Vectors...", visuGUI, SLOT(CreateVectors())); - thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_STREAM_LINES") ), - "Stream lines...", visuGUI, SLOT(CreateStreamLines())); } } - } - return false; } //=========================================================================== @@ -3074,55 +2997,42 @@ void VisuGUI::BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO) BEGIN_OF("VisuGUI::BuildPresentation"); if (theIO.IsNull()) { - MESSAGE("VisuGUI::BuildPresentation(): null SALOME_InteractiveObject passed"); + if(MYDEBUG) MESSAGE("VisuGUI::BuildPresentation(): null SALOME_InteractiveObject passed"); return; } - /* Create or retrieve an object VisuGUI */ - - VisuGUI::GetOrCreateVisuGUI(QAD_Application::getDesktop()); - - SALOMEDS::Study_var aStudy = visuGUI->myActiveStudy->getStudyDocument(); + SALOMEDS::Study_var aStudy = GetActiveStudy()->getStudyDocument(); SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder(); - if ( visuGUI->myActiveStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) return; + if ( GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) return; - vtkRenderer *Renderer = GetRenderer(visuGUI->myActiveStudy); + vtkRenderer *Renderer = GetRenderer(); SALOMEDS::SObject_var aSObj = aStudy -> FindObjectID ( theIO->getEntry() ); SCRUTE(aSObj); if (aSObj -> _is_nil() ) { - MESSAGE("No SObject for interacative object is found"); + if(MYDEBUG) MESSAGE("No SObject for interacative object is found"); return; } CORBA::Object_var anObject = VISU::SObjectToObject(aSObj); if(!CORBA::is_nil(anObject)) { - VISU::Prs3d_i* aPrsObject = dynamic_cast(VISU::GetServant(anObject)); if ( !aPrsObject ) { - MESSAGE("The object is not VISU::Prs3d_i"); + if(MYDEBUG) MESSAGE("The object is not VISU::Prs3d_i"); return; } VISU_Actor *SelectedActor = visuGUI->GetActor(aPrsObject); - if ( ! SelectedActor ) - SelectedActor = aPrsObject -> CreateActor(); - SCRUTE(SelectedActor); - if ( SelectedActor == NULL ) { - MESSAGE("VisuGUI::BuildPresentation(): actor doesn't exist in Render"); - return; - } - VTKViewer_ViewFrame* vf = GetVtkViewFrame(); - vf->AddActor(SelectedActor); - if(SelectedActor->HasScalarBar()){ - Renderer->AddActor2D(SelectedActor->getScalarBar()); - } - } - else { - MESSAGE("CORBA::is_nil(anObject) = true"); - } + if(!SelectedActor) + try{ + SelectedActor = aPrsObject -> CreateActor(); + if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()) + vf->AddActor(SelectedActor); + }catch(std::runtime_error& exc){ + } + }else + if(MYDEBUG) MESSAGE("CORBA::is_nil(anObject) = true"); END_OF("VisuGUI::BuildPresentation"); - } extern "C" @@ -3130,25 +3040,25 @@ extern "C" bool OnGUIEvent(int theCommandID, QAD_Desktop* parent) { - //MESSAGE("VisuGUI::OnGUIEvent "<< theCommandID); + //if(MYDEBUG) MESSAGE("VisuGUI::OnGUIEvent "<< theCommandID); return VisuGUI::OnGUIEvent(theCommandID, parent); } bool OnKeyPress (QKeyEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) { - MESSAGE("VisuGUI::OnKeyPress "); + if(MYDEBUG) MESSAGE("VisuGUI::OnKeyPress "); return VisuGUI::OnKeyPress (pe, parent, studyFrame); } bool OnMousePress (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) { - //MESSAGE("VisuGUI::OnMousePress "); + //if(MYDEBUG) MESSAGE("VisuGUI::OnMousePress "); return VisuGUI::OnMousePress (pe, parent, studyFrame); } bool OnMouseMove (QMouseEvent* pe, QAD_Desktop* parent, QAD_StudyFrame* studyFrame) { - //MESSAGE("VisuGUI::OnMouseMove "); + //if(MYDEBUG) MESSAGE("VisuGUI::OnMouseMove "); return VisuGUI::OnMouseMove (pe, parent, studyFrame); } @@ -3177,80 +3087,90 @@ extern "C" VisuGUI::BuildPresentation(theIO); } -} - -// ==================================================================================================================== -// =================================================================================================================== - -bool VisuGUI::getObjectRef( QAD_Desktop* parent, SALOMEDS::SObject_ptr obj, - _CORBA_ObjRef_OUT_arg< SALOMEDS::_objref_SObject, SALOMEDS::SObject_Helper > objres, - const char* Type) { - - VisuGUI::GetOrCreateVisuGUI(parent); - SALOMEDS::Study_var aStudy = visuGUI->myActiveStudy->getStudyDocument(); - SALOMEDS::ChildIterator_var it = aStudy->NewChildIterator(obj); - SALOMEDS::SObject_var RefObj; - - for (; it->More();it->Next()) { - SALOMEDS::SObject_var Fils = it->Value(); - - if ( Fils->ReferencedObject( RefObj ) ) { - SALOMEDS::SComponent_var theComponent = RefObj->GetFatherComponent(); - Standard_CString nameComponent = theComponent->ComponentDataType(); + void supportedViewType(int* buffer, int bufferSize) + { + if (!buffer || !bufferSize) return; + buffer[0] = (int)VIEW_VTK; + if (--bufferSize) buffer[1] = (int)VIEW_PLOT2D; + } - if ( TCollection_AsciiString(nameComponent).IsEqual(strdup(Type)) ) { - objres = SALOMEDS::SObject::_narrow(RefObj); - return true; - } - } - } - return false; } ////////////////////////////////////////////////////////////////////////////////// //////////////// CHANGE ACTOR COLOR //////////////////////// ////////////////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////////// +///////////////// ///////////////////////////////////////////////////////////////// // change actor color // In : Name of Actor // // -void VisuGUI::NewColor(VISU_Actor *Actor) -{ - float oldcolor[3],newcolor[3]; - Actor->GetProperty()->GetColor(oldcolor); - QColor colorold; - colorold = QColor(oldcolor[0]*255, oldcolor[1]*255, oldcolor[2]*255); - QColor colornew = QColorDialog::getColor( colorold, QAD_Application::getDesktop() ); - - if (!colornew.isValid()) return; - - newcolor[0]=colornew.red()/255.; - newcolor[1]=colornew.green()/255.; - newcolor[2]=colornew.blue()/255.; - Actor->GetProperty()->SetColor(newcolor); - if (Actor->getPrs3d()) - Actor->getPrs3d()->SetColor(newcolor); +void VisuGUI::NewColor(VISU_Actor *theActor){ + if(VISU::Prs3d_i* aPrs3d = theActor->GetPrs3d()){ + VISU::Mesh_i* aMesh = dynamic_cast(aPrs3d); + VISU::DeformedShape_i* aDeformedShape = dynamic_cast(aPrs3d); + SALOMEDS::Color anOldColor, aNewColor; + int aRepresent = theActor->GetRepresentation(); + if(aMesh) + switch(aRepresent){ + case VISU::POINT : + anOldColor = aMesh->GetNodeColor(); + break; + case VISU::WIREFRAME : + case VISU::INSIDEFRAME : + anOldColor = aMesh->GetLinkColor(); + break; + case VISU::SHADED : + case VISU::SURFACEFRAME : + anOldColor = aMesh->GetCellColor(); + break; + } + else if(aDeformedShape) + anOldColor = aDeformedShape->GetColor(); + else + return; + QColor aColor = QColor(int(255*anOldColor.R),int(255*anOldColor.G),int(255*anOldColor.B)); + QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop()); + if(aColorNew.isValid()){ + aNewColor.R = aColorNew.red()/255.; + aNewColor.G = aColorNew.green()/255.; + aNewColor.B = aColorNew.blue()/255.; + if(aMesh) + switch(aRepresent){ + case VISU::POINT : + aMesh->SetNodeColor(aNewColor); + break; + case VISU::WIREFRAME : + case VISU::INSIDEFRAME : + aMesh->SetLinkColor(aNewColor); + break; + case VISU::SHADED : + case VISU::SURFACEFRAME : + aMesh->SetCellColor(aNewColor); + break; + } + else + aDeformedShape->SetColor(aNewColor); + RecreateActor(aPrs3d); + } + } } -void VisuGUI::NewOutlineColor(VISU_Actor *Actor) -{ - float oldcolor[3],newcolor[3]; - Actor->EdgeDevice->GetProperty()->GetColor(oldcolor); - QColor colorold; - colorold = QColor(oldcolor[0]*255, oldcolor[1]*255, oldcolor[2]*255); - QColor colornew = QColorDialog::getColor( colorold, QAD_Application::getDesktop() ); - - if (!colornew.isValid()) return; - - SALOMEDS::Color aColor; - aColor.R = newcolor[0]=colornew.red()/255.; - aColor.G = newcolor[1]=colornew.green()/255.; - aColor.B = newcolor[2]=colornew.blue()/255.; - Actor->EdgeDevice->GetProperty()->SetColor(newcolor); - if (Actor->getPrs3d()) - dynamic_cast(Actor->getPrs3d())->SetLinkColor(aColor); +void VisuGUI::NewWireframeColor(VISU_MeshAct *theActor){ + if(VISU::Prs3d_i* aPrs3d = theActor->GetPrs3d()){ + if(VISU::Mesh_i* aMesh = dynamic_cast(aPrs3d)){ + SALOMEDS::Color anOldColor = aMesh->GetLinkColor(), aNewColor; + QColor aColor = QColor(int(255*anOldColor.R),int(255*anOldColor.G),int(255*anOldColor.B)); + QColor aColorNew = QColorDialog::getColor(aColor, GetDesktop()); + if(aColorNew.isValid()){ + aNewColor.R = aColorNew.red()/255.; + aNewColor.G = aColorNew.green()/255.; + aNewColor.B = aColorNew.blue()/255.; + aMesh->SetLinkColor(aNewColor); + VisuGUI::RecreateActor(aMesh); + } + } + } } ////////////////////////////////////////////////////////////////////////////////// @@ -3307,7 +3227,7 @@ void VisuGUI::NewLinewidth(VISU_Actor *Actor) int intlwid; CursorDlg->Comment1->setText("Set value between"); CursorDlg->Comment2->setText("1 (thin) and 10 (thick)"); - oldlwid=Actor->GetProperty()->GetLineWidth(); + oldlwid=Actor->GetLineWidth(); intlwid=int(oldlwid); CursorDlg->SpinBox1->setMinValue(1); CursorDlg->SpinBox1->setMaxValue(10); @@ -3317,7 +3237,7 @@ void VisuGUI::NewLinewidth(VISU_Actor *Actor) if (ret == 1) { intlwid = CursorDlg->SpinBox1->value() ; newlwid = intlwid; - Actor->GetProperty()->SetLineWidth(newlwid); + Actor->SetLineWidth(newlwid); } delete CursorDlg; } @@ -3412,18 +3332,18 @@ QString VisuGUI::getVisuOutputDir() /* ======================================================================================== */ VISU::Result_i* VisuGUI::CreatePresent(SALOMEDS::SObject_var theField, VISU::Result_var& theResult){ if(MYDEBUG) MESSAGE("VisuGUI::CreatePresent"); - VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); - SALOMEDS::SObject_var aSObj = theField->GetFather(); - aSObj = aSObj->GetFather(); - aSObj = aSObj->GetFather(); - aSObj = aSObj->GetFather(); + SALOMEDS::SObject_var aSObj = theField->GetFather(); + if (CORBA::is_nil(aSObj)) return NULL; + aSObj = aSObj->GetFather(); if (CORBA::is_nil(aSObj)) return NULL; + aSObj = aSObj->GetFather(); if (CORBA::is_nil(aSObj)) return NULL; + aSObj = aSObj->GetFather(); if (CORBA::is_nil(aSObj)) return NULL; CORBA::Object_var anObject = VISU::SObjectToObject(aSObj); if(CORBA::is_nil(anObject)) return NULL; theResult = VISU::Result::_narrow(anObject); VISU::Result_i* pResult = dynamic_cast(VISU::GetServant(anObject)); if(pResult == NULL) QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"), - tr ("No Available data in selection"), + tr ("WRN_NO_AVAILABLE_DATA"), tr ("VISU_BUT_OK")); return pResult; } @@ -3431,24 +3351,22 @@ VISU::Result_i* VisuGUI::CreatePresent(SALOMEDS::SObject_var theField, VISU::Res #define CREATEPRS(PRSTYPE, FNAME, FCREATE) \ PRSTYPE* FNAME(SALOMEDS::SObject_var theField, \ const char* theMeshName, VISU::Entity theEntity, \ - const char* theFieldName, double theTimeId) {\ + const char* theFieldName, int theTimeId) {\ VISU::Result_var aResult; \ VISU::Result_i* pResult = CreatePresent(theField,aResult); \ - if(pResult){ \ + if(pResult != NULL){ \ if(PRSTYPE::IsPossible(pResult,theMeshName,(VISU::Entity)theEntity,theFieldName,theTimeId)){ \ QApplication::setOverrideCursor( Qt::waitCursor ); \ - VISU::VISU_Gen_var aVisuGen = VISU::GetVisu(); \ CORBA::Object_var anObject = \ - aVisuGen->FCREATE(aResult,theMeshName,theEntity,theFieldName,theTimeId); \ + GetVisuGen()->FCREATE(aResult,theMeshName,theEntity,theFieldName,theTimeId); \ QApplication::restoreOverrideCursor(); \ - if(CORBA::is_nil(anObject)) return NULL; \ - return dynamic_cast(VISU::GetServant(anObject)); \ + if(!CORBA::is_nil(anObject)) \ + return dynamic_cast(VISU::GetServant(anObject)); \ } \ - } else { \ - QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), \ - tr ("The presentation can't be builded."), \ - tr ("VISU_BUT_OK") ); \ } \ + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), \ + tr ("ERR_CANT_BUILD_PRESENTATION"), \ + tr ("VISU_BUT_OK") ); \ return NULL; \ } @@ -3457,6 +3375,7 @@ CREATEPRS(VISU::DeformedShape_i, VisuGUI::CreateDeformedShapePrs, DeformedShapeO CREATEPRS(VISU::Vectors_i, VisuGUI::CreateVectorsPrs, VectorsOnField); CREATEPRS(VISU::IsoSurfaces_i, VisuGUI::CreateIsoSurfacesPrs, IsoSurfacesOnField); CREATEPRS(VISU::CutPlanes_i, VisuGUI::CreateCutPlanesPrs, CutPlanesOnField); +CREATEPRS(VISU::CutLines_i, VisuGUI::CreateCutLinesPrs, CutLinesOnField); CREATEPRS(VISU::StreamLines_i, VisuGUI::CreateStreamLinesPrs, StreamLinesOnField); @@ -3465,23 +3384,33 @@ bool FNAME(SALOMEDS::SObject_var theField) { \ VISU::Storable::TRestoringMap aMap = getMapOfValue(theField); \ bool isExist; \ QString aType = VISU::Storable::FindValue(aMap,"myType",&isExist); \ - if(!isExist && aType.toInt() != VISU::TTIMESTAMP) return false; \ + if(!isExist || aType.toInt() != VISU::TTIMESTAMP ) return false; \ QString aMeshName = VISU::Storable::FindValue(aMap,"myMeshName",&isExist).latin1(); \ QString anEntity = VISU::Storable::FindValue(aMap,"myEntityId",&isExist).latin1(); \ QString aFieldName = VISU::Storable::FindValue(aMap,"myFieldName",&isExist).latin1(); \ QString aTimeStampId = VISU::Storable::FindValue(aMap,"myTimeStampId",&isExist).latin1(); \ - TYPE* pPresent = FCREATE(theField,aMeshName,(VISU::Entity)anEntity.toInt(),aFieldName,aTimeStampId.toDouble()); \ + Utils_Timer timer; \ + if(MYCHECKTIME) timer.Start(); \ + TYPE* pPresent = FCREATE(theField,aMeshName,(VISU::Entity)anEntity.toInt(),aFieldName,aTimeStampId.toInt()); \ + if(MYCHECKTIME) { \ + timer.Stop(); \ + cout<<"BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) - CREATE PRSOBJECT\n"; \ + timer.Show(); \ + } \ if (pPresent) { \ - DLGNAME* aDlg = new DLGNAME(); \ - aDlg->initFromPrsObject(pPresent); \ - if (aDlg->exec()) { \ - aDlg->storeToPrsObject(pPresent); \ - } else { \ - DeletePresentation(pPresent); \ + QString aValue = QAD_CONFIG->getSetting("Visu:BuildDefaultPrs3d"); \ + if(aValue.isEmpty() || (!aValue.isEmpty() && !aValue.toInt())){ \ + DLGNAME* aDlg = new DLGNAME(); \ + aDlg->initFromPrsObject(pPresent); \ + if (aDlg->exec()) { \ + aDlg->storeToPrsObject(pPresent); \ + } else { \ + DeletePresentation(pPresent); \ + delete aDlg; \ + return false; \ + } \ delete aDlg; \ - return false; \ } \ - delete aDlg; \ CreateActor(pPresent); \ return true; \ } \ @@ -3493,6 +3422,7 @@ BUILDPRS(VISU::DeformedShape_i, CreateDeformedShapePrs, VisuGUI::CreateDeformedS BUILDPRS(VISU::Vectors_i, CreateVectorsPrs, VisuGUI::CreateVectors, VisuGUI_VectorsDlg); BUILDPRS(VISU::IsoSurfaces_i, CreateIsoSurfacesPrs, VisuGUI::CreateIsoSurfaces, VisuGUI_IsoSurfacesDlg); BUILDPRS(VISU::CutPlanes_i, CreateCutPlanesPrs, VisuGUI::CreateCutPlanes, VisuGUI_CutPlanesDlg); +BUILDPRS(VISU::CutLines_i, CreateCutLinesPrs, VisuGUI::CreateCutLines, VisuGUI_CutLinesDlg); BUILDPRS(VISU::StreamLines_i, CreateStreamLinesPrs, VisuGUI::CreateStreamLines, VisuGUI_StreamLinesDlg); @@ -3505,26 +3435,40 @@ void VisuGUI::ImportTablesFromFile(){ flt.append( "Files (*.xls *.txt *.tab)" ); flt.append( "All Files (*.*)" ); QString aDir = getVisuInputDir(); - QString aFile = QAD_FileDlg::getFileName(QAD_Application::getDesktop(), + QFileInfo aFileInfo = QAD_FileDlg::getFileName(QAD_Application::getDesktop(), aDir,flt,tr("Import From File"),true); - if(!aFile.isEmpty()){ - QAD_Application::getDesktop()->putInfo( "Importing From File " + aFile + "..." ); - aDir = QAD_Tools::getDirFromPath(aFile); + + if(aFileInfo.exists()){ + QAD_Application::getDesktop()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." ); + aDir = QAD_Tools::getDirFromPath(aFileInfo.filePath()); QAD_CONFIG->addSetting("Visu:InputDir",aDir); - QApplication::setOverrideCursor( Qt::waitCursor ); - QAD_PyInterp* myPyInterp = myActiveStudy->get_PyInterp(); - myPyInterp->run("import VisuGUI"); - myPyInterp->run("reload(VisuGUI)"); - myPyInterp->run("VisuGUI.AddTablesInStudyFromFile('"+aFile+"')"); - // VISU::Result_var aResult = myComponent->ImportFile(aFile.latin1()); - // if(aResult->_is_nil()) - // QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), - // tr ("There is an error in imported file"), - // tr ("VISU_BUT_OK") ); - // else - // QAD_Application::getDesktop()->putInfo(aFile+" imported."); - myActiveStudy->updateObjBrowser(); //update Object browser - QApplication::restoreOverrideCursor(); + QAD_WaitCursor wc; + + CORBA::Object_var anObject; +#ifdef CHECKTIME + Utils_Timer timer; + timer.Start(); +#endif + + anObject=GetVisuGen()->ImportTables(aFileInfo.filePath()); + +#ifdef CHECKTIME + timer.Stop(); + cout<<"VisuGUI::ImportTablesFromFile() - IMPORT FILE\n"; + timer.Show(); +#endif + + if(CORBA::is_nil(anObject)) { + wc.stop(); + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), + tr ("ERR_ERROR_IN_THE_FILE"), + tr ("VISU_BUT_OK") ); + wc.start(); + } + else { + QAD_Application::getDesktop()->putInfo(aFileInfo.filePath()+" imported."); + } + GetActiveStudy()->updateObjBrowser(); //update Object browser } } @@ -3532,33 +3476,68 @@ void VisuGUI::ImportTablesFromFile(){ /* Global Method to import mesh results in MED and DAT format */ /* ======================================================================================== */ void VisuGUI::ImportFromFile(){ - if (checkLock(myActiveStudy->getStudyDocument())) return; + if (checkLock(GetActiveStudy()->getStudyDocument())) return; QStringList flt; //flt.append( "Exportable Files (*.med *.dat)" ); //flt.append( "Dat Files (*.dat)" ); flt.append( "Med Files (*.med)" ); QString aDir = getVisuInputDir(); - QString aFile = QAD_FileDlg::getFileName(QAD_Application::getDesktop(), - aDir,flt,tr("Import From File"),true); - if(!aFile.isEmpty()){ - QAD_Application::getDesktop()->putInfo( "Importing From File " + aFile + "..." ); - aDir = QAD_Tools::getDirFromPath(aFile); + QFileInfo aFileInfo = VisuGUI_FileDlg::getFileName(QAD_Application::getDesktop(), + aDir,flt,tr("Import From File"),true); + + if(aFileInfo.exists()){ + QAD_Application::getDesktop()->putInfo( "Importing From File " + aFileInfo.filePath() + "..." ); + aDir = QAD_Tools::getDirFromPath(aFileInfo.filePath()); QAD_CONFIG->addSetting("Visu:InputDir",aDir); - QApplication::setOverrideCursor( Qt::waitCursor ); - VISU::Result_var aResult = myComponent->ImportFile(aFile.latin1()); - if(aResult->_is_nil()) + QAD_WaitCursor wc; + + VISU::Result_var aResult; + +#ifdef CHECKTIME + Utils_Timer timer; + timer.Start(); +#endif + if(aFileInfo.extension(false) == "med"){ + QString IsBuild = QAD_CONFIG->getSetting("Visu:BuildResult"); + bool isBuild = (IsBuild.isEmpty()? 0 : IsBuild.toInt()); + + if (VisuGUI_FileDlg::IsBuild) + { + aResult = GetVisuGen()->ImportFile(aFileInfo.filePath()); + if(!CORBA::is_nil(aResult.in())) aResult->BuildAll(); + } + else + { + QAD_CONFIG->addSetting( "Visu:BuildResult", false ); + aResult=GetVisuGen()->ImportFile( aFileInfo.filePath() ); + QAD_CONFIG->addSetting( "Visu:BuildResult", isBuild ); + } + } + +#ifdef CHECKTIME + timer.Stop(); + cout<<"VisuGUI::ImportFromFile() - IMPORT FILE\n"; + timer.Show(); +#endif + + if(CORBA::is_nil(aResult.in())) { + wc.stop(); QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), - tr ("There is an error in imported file"), + tr ("ERR_ERROR_IN_THE_FILE"), tr ("VISU_BUT_OK") ); - else - QAD_Application::getDesktop()->putInfo(aFile+" imported."); - myActiveStudy->updateObjBrowser(); //update Object browser - QApplication::restoreOverrideCursor(); + wc.start(); + } + else { + QAD_Application::getDesktop()->putInfo(aFileInfo.filePath()+" imported."); + } + GetActiveStudy()->updateObjBrowser(); //update Object browser } } void VisuGUI::ExportToFile(){ - VISU::Base_i* aBase = GetSelectedVisuObj(); + CORBA::Object_var anObject = GetSelectedObj(); + if(CORBA::is_nil(anObject)) return; + VISU::Base_i* aBase = dynamic_cast(VISU::GetServant(anObject)); if(aBase != NULL && aBase->GetType() == VISU::TRESULT){ QStringList flt; flt.append( "Dat Files (*.dat)" ); @@ -3572,170 +3551,51 @@ void VisuGUI::ExportToFile(){ QAD_CONFIG->addSetting("Visu:OutputDir",aDir); if(VISU::Result_i* aResult = dynamic_cast(aBase)){ try{ - aResult->GetInput()->ToFile(aFile.latin1()); + //APO - aResult->GetInput()->ToFile(aFile.latin1()); QAD_Application::getDesktop()->putInfo(aFile+" exported."); }catch(...){ QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), - tr ("There is an error during exporting to file"), + tr ("ERR_ERROR_DURING_EXPORT"), tr ("VISU_BUT_OK") ); } } } }else QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"), - tr ("No Available data in selection"), + tr ("WRN_NO_AVAILABLE_DATA"), tr ("VISU_BUT_OK")); } - -/* ======================================================================================== */ -/* Find an Actor to be the reference for a new visualization */ -/* ======================================================================================== */ -VISU_Actor *VisuGUI::ReferenceActor(QAD_Desktop* parent) -{ - bool exiDS = false, exiVE = false, exiSM = false, exiIS = false, exiCP = false; - int nbSf = visuGUI->myActiveStudy->getStudyFramesCount(); - int nbObj = 0; - for ( int i = 0; i < nbSf; i++ ) { - QAD_StudyFrame* sf = visuGUI->myActiveStudy->getStudyFrame(i); - if ( sf->getTypeView() == VIEW_VTK ) { - vtkRenderer* aRenderer = ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRenderer(); - vtkActorCollection* ac = aRenderer->GetActors(); - vtkActor *anActor; - for( ac->InitTraversal(); (anActor = ac->GetNextActor()) != NULL; ) { - if ( anActor->IsA( "VISU_Actor" ) ) { - VISU_Actor *VISUActor = VISU_Actor::SafeDownCast(anActor); - if (VisuGUI_VisuAsDlg::ActorTypeIsValid(VISUActor,-1)) { - // VisuAs->ListObjects->insertItem(VISUActor->getName()); - nbObj++; - int test = VISUActor->VisuActorType; - if(test == VisuActorType_DeformedShape) - exiDS=true; - else if(test == VisuActorType_Vectors) - exiVE=true; - else if(test == VisuActorType_ScalarMap) - exiSM=true; - else if(test == VisuActorType_IsoSurfaces) - exiIS=true; - else if(test == VisuActorType_CutPlanes) - exiCP=true; - } - } - } - } - } - - if ( nbObj > 0 ) { - VisuGUI_VisuAsDlg * VisuAs = new VisuGUI_VisuAsDlg(QAD_Application::getDesktop(), 0, true, 0 ); - - if(exiDS) - VisuAs->addType( tr( "Deformed Shape" ) ); - if(exiVE) - VisuAs->addType( tr( "Vectors" ) ); - if(exiSM) - VisuAs->addType( tr( "Scalar Map" ) ); - if(exiIS) - VisuAs->addType( tr( "Iso-Surfaces" ) ); - if(exiCP) - VisuAs->addType( tr( "Cut Planes" ) ); - - if ( VisuAs->exec() ) { - QString nameActor = VisuAs->getObject(); - if ( !nameActor.isNull() ) { - MESSAGE("Actor --> "<myActiveStudy->getStudyFrame(i); - if ( sf->getTypeView() == VIEW_VTK ) { - vtkRenderer* aRenderer = ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRenderer(); - vtkActorCollection* ac = aRenderer->GetActors(); - vtkActor *anActor; - for( ac->InitTraversal(); (anActor = ac->GetNextActor()) != NULL; ) { - if ( anActor->IsA( "VISU_Actor" ) ) { - VISU_Actor *VISUActor = VISU_Actor::SafeDownCast(anActor); - if (strcmp(VISUActor->getName(),nameActor) == 0) - return VISUActor; - } - } - } - } - } - } - } - return NULL; -} - /* ======================================================================================== */ /* Test and Read Object Browser before display */ /* ======================================================================================== */ -bool VisuGUI::TestObjectBrowser(SALOMEDS::SObject_var *objVisu ){ +bool VisuGUI::TestObjectBrowser(SALOMEDS::SObject_var& objVisu ){ if(MYDEBUG) MESSAGE("VisuGUI::TestObjectBrowser"); - SALOME_Selection* Sel = SALOME_Selection::Selection(myActiveStudy->getSelection()); - SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); - if(It.More()){ - Handle(SALOME_InteractiveObject) IObject = It.Value(); - SALOMEDS::Study_var aStudy = visuGUI->myActiveStudy->getStudyDocument(); //Document OCAF de l'etude active - if (IObject->hasEntry()){ - *objVisu = aStudy->FindObjectID(IObject->getEntry()); - if(!(*objVisu)->_is_nil()) return true; - } + Handle(SALOME_InteractiveObject) anIO; + CORBA::Object_var anObject = GetSelectedObj(&anIO); + if(!anIO.IsNull() && anIO->hasEntry()){ + objVisu = GetStudyDocument()->FindObjectID(anIO->getEntry()); + QString aValue = getValue(objVisu,"myType"); + if((VISU::VISUType)aValue.toInt() == VISU::TTIMESTAMP) return true; } QAD_MessageBox::warn1(QAD_Application::getDesktop(), tr ("VISU_WARNING"), - tr("No Available data in selection"), + tr("WRN_NO_AVAILABLE_DATA"), tr("VISU_BUT_OK") ); return false; } -/* ======================================================================================== */ -/* Print the render window */ -/* ======================================================================================== */ -void VisuGUI::PrintRW( QString prFile, bool toPrinter) -{ - ((VTKViewer_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->Repaint(); - - vtkRenderWindow *renwin = vtkRenderWindow::New(); - vtkRenderWindowInteractor *theInteractor = vtkRenderWindowInteractor::New(); - theInteractor = ((VTKViewer_ViewFrame*)visuGUI->myActiveStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())->getRWInteractor(); - //visuGUI->myActiveStudy->getActiveStudyFrame()->getVTKRWInteractor(); - - renwin=theInteractor->GetRenderWindow(); - vtkWindowToImageFilter *w2if = vtkWindowToImageFilter::New(); - vtkTIFFWriter *rttiffw = vtkTIFFWriter::New(); - w2if->SetInput(renwin); - rttiffw->SetInput(w2if->GetOutput()); - rttiffw->SetFileName(prFile); - rttiffw->Write(); - - if (toPrinter) // print the file - { - QString printer = QAD_CONFIG->getSetting("Visu:Printer"); - if (printer.isEmpty()) - printer="kprinter"; - system(printer + " " + prFile); - } -} - /** * Returns Actor of presentation if it exists */ -VISU_Actor* VisuGUI::GetActor(VISU::Prs3d_i* thePrs){ - VTKViewer_ViewFrame* vf = GetVtkViewFrame(); +VISU_Actor* VisuGUI::GetActor(VISU::Prs3d_i* thePrs, VTKViewer_ViewFrame* theViewFrame){ + VTKViewer_ViewFrame* vf = theViewFrame? theViewFrame: GetVtkViewFrame(); if (!vf) return NULL; - - vtkRenderer *aRen = vf->getRenderer(); - vtkActorCollection *anActColl = aRen->GetActors(); vtkActor *anActor; - VISU_Actor* anVISUActor = NULL; - VISU_Actor* aResActor = NULL; - long aSrcAddr = (long) thePrs; - for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){ - if(anActor->IsA("VISU_Actor")){ - anVISUActor = VISU_Actor::SafeDownCast(anActor); - long aCurrAddr = (long) anVISUActor->getPrs3d(); - if (aSrcAddr == aCurrAddr) { - return anVISUActor; - } - } - } + vtkActorCollection *anActColl = vf->getRenderer()->GetActors(); + for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL;) + if(VISU_Actor* anVISUActor = dynamic_cast(anActor)) + if(thePrs == anVISUActor->GetPrs3d()) + return anVISUActor->GetParent(); return NULL; } @@ -3753,53 +3613,32 @@ VISU_Actor* VisuGUI::UpdateViewer(VISU::Prs3d_i* thePrs, bool theDispOnly){ vtkActor *anActor; VISU_Actor* anVISUActor = NULL; VISU_Actor* aResActor = NULL; - long aSrcAddr = (long) thePrs; + VISU::Prs3d_i* aSrcAddr = thePrs; for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){ if(anActor->IsA("VISU_Actor")){ anVISUActor = VISU_Actor::SafeDownCast(anActor); - long aCurrAddr = (long) anVISUActor->getPrs3d(); - if (aSrcAddr == aCurrAddr) { - aResActor = anVISUActor; + VISU::Prs3d_i* aPrs = anVISUActor->GetPrs3d(); + if(aPrs == NULL) continue; + if (thePrs == aPrs) { + aResActor = anVISUActor->GetParent(); + thePrs->UpdateActor(aResActor); aResActor->VisibilityOn(); - if ( aResActor->VisuActorType == VisuActorType_Mesh ) { - if ( aResActor->GetProperty()->GetRepresentation() == 2 && !aResActor->IsShrunk ) - aResActor->EdgeDevice->VisibilityOn(); - else - aResActor->EdgeDevice->VisibilityOff(); - } - if (aResActor->HasScalarBar()) - aResActor->getScalarBar()->VisibilityOn(); + } else if (theDispOnly) { - anVISUActor->VisibilityOff(); - if ( anVISUActor->VisuActorType == VisuActorType_Mesh) { - anVISUActor->EdgeDevice->VisibilityOff(); - } - if (anVISUActor->HasScalarBar()) - anVISUActor->getScalarBar()->VisibilityOff(); + anVISUActor->GetParent()->VisibilityOff(); } } } if (aResActor) return aResActor; -#ifdef CHECKTIME - OSD_Timer timer; - timer.Start(); -#endif - anVISUActor = thePrs->CreateActor(); - MESSAGE("UpdateViewer - thePrs->CreateActor() = "<CreateActor(); vf->AddActor(anVISUActor); - if(anVISUActor->HasScalarBar()){ - aRen->AddActor2D(anVISUActor->getScalarBar()); - } - } else + }catch(std::runtime_error& exc){ QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), - tr ("Can't visulize current object"), + tr ("ERR_CANT_VISUALIZE_OBJECT"), tr ("VISU_BUT_OK") ); -#ifdef CHECKTIME - timer.Stop(); - MESSAGE("Cheking time in VisuGUI::UpdateViewer - thePrs->CreateActor + vf->AddActor + aRen->AddActor2D"); - timer.Show(); -#endif + anVISUActor = NULL; + } return anVISUActor; } @@ -3816,14 +3655,10 @@ bool VisuGUI::IsDisplayed(VISU::Prs3d_i* thePrs) { * Erases Presentation */ void VisuGUI::ErasePrs(VISU::Prs3d_i* thePrs) { - myActiveStudy->unHighlightAll(); + GetActiveStudy()->unHighlightAll(); VISU_Actor* anVISUActor = GetActor(thePrs); if (anVISUActor) { anVISUActor->VisibilityOff(); - if ( anVISUActor->VisuActorType == VisuActorType_Mesh ) - anVISUActor->EdgeDevice->VisibilityOff(); - if (anVISUActor->HasScalarBar()) - anVISUActor->getScalarBar()->VisibilityOff(); } } @@ -3831,81 +3666,44 @@ void VisuGUI::ErasePrs(VISU::Prs3d_i* thePrs) { * Deletes given presentation from Data structure */ void VisuGUI::DeletePresentation(VISU::Prs3d_i* thePrs) { - if (checkLock(myStudy)) return; - if (!thePrs) return; - - myActiveStudy->unHighlightAll(); - - vtkActor *anActor; - VISU_Actor* aVISUActor = NULL; - long aSrcAddr = (long) thePrs; - int nbFrames = myActiveStudy->getStudyFramesCount(); - QAD_StudyFrame* aFrame; - - for(int i=0; igetStudyFrame(i); - if(!aFrame || aFrame->getTypeView() != VIEW_VTK) continue; - vtkRenderer* aRen = ((VTKViewer_ViewFrame*)aFrame->getRightFrame()->getViewFrame())->getRenderer(); - vtkActorCollection *anActColl = aRen->GetActors(); - - for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){ - if(anActor->IsA("VISU_Actor")) { - aVISUActor = VISU_Actor::SafeDownCast(anActor); - if (aSrcAddr == ((long) aVISUActor->getPrs3d())) { - if (aVISUActor->HasScalarBar()) - aRen->RemoveActor(aVISUActor->getScalarBar()); - aRen->RemoveActor(aVISUActor); - aVISUActor->EdgeDevice->Delete(); - aVISUActor->Delete(); - aVISUActor = NULL; + if(checkLock(GetStudyDocument()) || !thePrs) return; + GetActiveStudy()->unHighlightAll(); + for(int i = 0, nbFrames = GetActiveStudy()->getStudyFramesCount(); i < nbFrames; i++) + if(QAD_StudyFrame* aFrame = GetActiveStudy()->getStudyFrame(i)){ + QAD_ViewFrame* aVFrame = aFrame->getRightFrame()->getViewFrame(); + if(VTKViewer_ViewFrame* aViewFrame = dynamic_cast(aVFrame)) + if(VISU_Actor* anActor = GetActor(thePrs,aViewFrame)){ + aViewFrame->RemoveActor(anActor); + anActor->Delete(); } - } } - } - SALOMEDS::SObject_var aSObj = myStudy->FindObjectID(thePrs->GetEntry()); - if(aSObj->_is_nil()) return; - myStudyBuilder->RemoveObject(aSObj); - myActiveStudy->updateObjBrowser(); //update Object browser + thePrs->Destroy(); + GetActiveStudy()->updateObjBrowser(); //update Object browser } /** * Creates new actor of presentation */ void VisuGUI::CreateActor(VISU::Prs3d_i* thePrs) { - if (!thePrs) return; + if (!thePrs) return; QApplication::setOverrideCursor( Qt::waitCursor ); - VTKViewer_ViewFrame* vf = GetVtkViewFrame(); - if (vf) { + if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){ #ifdef CHECKTIME - OSD_Timer timer; + Utils_Timer timer; timer.Start(); #endif - VISU_Actor* aActor = thePrs->CreateActor(); - if ( ! aActor ) { + try{ + VISU_Actor* aActor = thePrs->CreateActor(); + vf->AddActor(aActor); + }catch(std::runtime_error& exc){ QApplication::restoreOverrideCursor(); QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), - tr ("The presentation can't be visualized.\n Null actor is created."), - tr ("VISU_BUT_OK") ); - return; + tr ("WRN_CANT_VISUALIZE_PRS"), + tr ("VISU_BUT_OK") ); } #ifdef CHECKTIME timer.Stop(); - MESSAGE("Cheking time in VisuGUI::CreateActor - thePrs->CreateActor"); - timer.Show(); -#endif - vtkRenderer *aRenderer = vf->getRenderer(); - //visuGUI->ClearViewer(QAD_Application::getDesktop(), aRenderer, -1); - //visuGUI->ShowTrihedron(true); -#ifdef CHECKTIME - timer.Reset(); - timer.Start(); -#endif - vf->AddActor(aActor); - if (aActor->HasScalarBar()) - aRenderer->AddActor2D(aActor->getScalarBar()); -#ifdef CHECKTIME - timer.Stop(); - MESSAGE("Cheking time in VisuGUI::CreateActor - vf->AddActor"); + cout<<"VisuGUI::CreateActor(VISU::Prs3d_i* thePrs) - DISPLAY ACTOR\n"; timer.Show(); #endif } @@ -3953,13 +3751,3 @@ void VisuGUI::SetActiveDialogBox(QDialog* aDlg) this->myActiveDialogBox = (QDialog*)aDlg ; return ; } - -QAD_Study* VisuGUI::GetActiveStudy() -{ - return this->myActiveStudy ; -} - -QAD_Desktop* VisuGUI::GetDesktop() -{ - return this->myDesktop ; -}