From: nri Date: Thu, 10 Jul 2003 13:47:28 +0000 (+0000) Subject: NRI : Merge from V1_2. X-Git-Tag: V_02092003~21 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c76448b4bd154155dae8cc5c7bedbf50d18fcde4;p=modules%2Fvisu.git NRI : Merge from V1_2. --- diff --git a/src/VISUGUI/Makefile.in b/src/VISUGUI/Makefile.in index e134bef1..f6e08af4 100644 --- a/src/VISUGUI/Makefile.in +++ b/src/VISUGUI/Makefile.in @@ -1,15 +1,35 @@ -# -* Makefile *- +# VISU VISUGUI : GUI of VISU component # -# Author : Marc Tajchman (CEA) -# Date : 5/07/2001 -# $Header$ +# 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 # - -# source path +# +# +# File : Makefile.in +# Author : Marc Tajchman (CEA) +# Module : VISU +# $Header$ + top_srcdir=@top_srcdir@ top_builddir=../.. srcdir=@srcdir@ -VPATH=.:@srcdir@:$(top_srcdir)/idl:$(top_builddir)/idl +VPATH=.:@srcdir@ @COMMENCE@ @@ -22,10 +42,10 @@ EXPORT_HEADERS= \ # .po files to transform in .qm PO_FILES = \ - VISU_msg_en.po VISU_icons.po + VisuGUI_msg_en.po VisuGUI_icons.po # Libraries targets -LIB = libVISUGUI.la +LIB = libVisuGUI.la LIB_SRC = VisuGUI.cxx \ VisuGUI_CellsResultsDlg.cxx \ VisuGUI_PointsResultsDlg.cxx \ @@ -44,7 +64,8 @@ LIB_SRC = VisuGUI.cxx \ VisuGUI_VisuAsDlg.cxx \ VisuGUI_NonIsometricDlg.cxx \ VisuGUI_StreamLinesDlg.cxx \ - VisuGUI_TimeAnimation.cxx + VisuGUI_TimeAnimation.cxx \ + VisuGUI_CutLinesDlg.cxx LIB_MOC = \ VisuGUI.h \ @@ -64,7 +85,8 @@ LIB_MOC = \ VisuGUI_VisuAsDlg.h \ VisuGUI_NonIsometricDlg.h \ VisuGUI_StreamLinesDlg.h \ - VisuGUI_TimeAnimation.h + VisuGUI_TimeAnimation.h \ + VisuGUI_CutLinesDlg.h LIB_CLIENT_IDL = SALOME_Exception.idl \ VISU_Gen.idl \ @@ -79,12 +101,10 @@ LIB_SERVER_IDL = # additionnal information to compil and link file -CPPFLAGS += -ftemplate-depth-32 $(QT_INCLUDES) $(VTK_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) \ - $(MED2_INCLUDES) $(HDF5_INCLUDES) $(QWT_INCLUDES) \ - -I${KERNEL_ROOT_DIR}/include/salome -CXXFLAGS += -ftemplate-depth-32 $(OCC_CXXFLAGS) -I${KERNEL_ROOT_DIR}/include/salome +CPPFLAGS += -ftemplate-depth-32 $(QT_INCLUDES) $(VTK_INCLUDES) $(OCC_INCLUDES) $(PYTHON_INCLUDES) $(MED2_INCLUDES) $(HDF5_INCLUDES) $(QWT_INCLUDES) +CXXFLAGS += -ftemplate-depth-32 $(OCC_CXXFLAGS) -LDFLAGS += $(OCC_LIBS) $(MED2_LIBS) $(HDF5_LIBS) $(VTK_LIBS) $(QWT_LIBS) -lSalomeGUI -lSalomeNS \ +LDFLAGS += $(MED2_LIBS) $(HDF5_LIBS) $(VTK_LIBS) $(QWT_LIBS) -lSalomeGUI -lSalomeNS \ -lVisuObject -lVISUEngine -lmed -lVTKViewer -L${KERNEL_ROOT_DIR}/lib/salome diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index caacd80e..78af7a0d 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -1,12 +1,32 @@ -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$ +using namespace std; #include "VisuGUI.h" #include "VisuGUI_PhaseDlg.h" #include "VisuGUI_MagnitudeDlg.h" @@ -16,6 +36,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" @@ -51,6 +72,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" @@ -87,50 +109,28 @@ using namespace std; #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 #ifdef DEBUG -static int MYDEBUG = 1; +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 +151,39 @@ 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(); +} + +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 +214,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 +240,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,27 +271,14 @@ int GetScalarMode(VISU::Result_i* theResult, const char* theFieldName){ } -VisuGUI::VisuGUI(){ -} +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; } @@ -384,20 +317,11 @@ 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); + vtkRenderer *theRenderer = GetRenderer(); - //vtkActorCollection* aActors = theRenderer->GetActors(); - //cout<<"### Actors Nb="<GetNumberOfItems()<myActiveStudy->getStudyDocument(); //Document OCAF de l'etude active + 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; @@ -451,34 +375,6 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) 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 +400,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 +421,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 +459,7 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) /* ========================================================================================================================= */ case 4211 : - ChangeViewer(parent, theRenderer, true, 1); + ChangeViewer(1); break; /* ========================================================================================================================= */ @@ -656,7 +467,7 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) /* ========================================================================================================================= */ case 4212 : - ChangeViewer(parent, theRenderer, true, 2); + ChangeViewer(2); break; /* ========================================================================================================================= */ @@ -664,7 +475,7 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) /* ========================================================================================================================= */ case 4213 : - ChangeViewer(parent, theRenderer, true, 0); + ChangeViewer(0); break; /* ========================================================================================================================= */ @@ -672,8 +483,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; /* ========================================================================================================================= */ @@ -760,72 +570,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; } @@ -841,9 +591,9 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) 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); if (CORBA::is_nil(aMedGen)) return false; @@ -852,15 +602,15 @@ bool VisuGUI::OnGUIEvent(int theCommandID, QAD_Desktop* parent) 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 +618,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,238 +636,25 @@ 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(); +VISU_Actor *VisuGUI::GetActor(int* theSelectionType){ + VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d(); + if (!aPrs3d) return NULL; - 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(); - } + VTKViewer_ViewFrame* vf = VisuGUI::GetVtkViewFrame(); + if(!vf) return NULL; - 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; + if(theSelectionType){ + QAD_Study *aStudy = QAD_Application::getDesktop()->getActiveStudy(); + SALOME_Selection *aSel = SALOME_Selection::Selection(aStudy->getSelection()); + *theSelectionType = aSel->SelectionMode(); } - 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(); - } - } + return GetActor(aPrs3d,vf); } /* ********************************************************************************** */ @@ -1137,9 +664,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(); } /* ********************************************************************************** */ @@ -1156,16 +683,25 @@ 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(); +void VisuGUI::ChangeViewer(int theType){ + VTKViewer_ViewFrame* vf = GetVtkViewFrame(); + if (!vf) return; - for(ac->InitTraversal();(actor = ac->GetNextActor())!=NULL;) - actor->GetProperty()->SetRepresentation(Type); + vtkActor *anActor; + vtkRenderer *aRen = vf->getRenderer(); + vtkActorCollection *anActColl = aRen->GetActors(); + for(anActColl->InitTraversal(); (anActor = anActColl->GetNextActor()) != NULL; ){ + if(anActor->IsA("VISU_Actor")){ + VISU_Actor* anVISUActor = VISU_Actor::SafeDownCast(anActor); + if(anVISUActor->GetVisibility() > 0) + if(theType > 0) + anVISUActor->SetRepresentation(theType); + else if(theType == -1) + anVISUActor->VisibilityOff(); + else + anVISUActor->VisibilityOn(); + } + } } @@ -1192,7 +728,7 @@ 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() ) @@ -1220,12 +756,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 +775,7 @@ CREATEPRESENTATION(VisuGUI::CreateDeformedShape); CREATEPRESENTATION(VisuGUI::CreateVectors); CREATEPRESENTATION(VisuGUI::CreateIsoSurfaces); CREATEPRESENTATION(VisuGUI::CreateCutPlanes); +CREATEPRESENTATION(VisuGUI::CreateCutLines); CREATEPRESENTATION(VisuGUI::CreateStreamLines); @@ -1260,29 +797,18 @@ bool VisuGUI::setSettings(QAD_Desktop* parent) //===================================================================================== void VisuGUI::DisplayPrs() { MESSAGE("VisuGUI::DisplayPrs"); - string aComment; 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"); 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; } @@ -1316,13 +842,11 @@ void VisuGUI::DisplayPrs() { //===================================================================================== void VisuGUI::DisplayOnlyPrs() { MESSAGE("VisuGUI::DisplayOnlyPrs"); - string aComment; - Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj(aComment, anIO, myActiveStudy); + 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){ + PortableServer::Servant aServant = VISU::GetServant(anObject); + if(VISU::Prs3d_i* aPrsObject = dynamic_cast(aServant)){ MESSAGE("VisuGUI::DisplayOnlyPrs : Prs3d object"); UpdateViewer(aPrsObject, true); VTKViewer_ViewFrame* vf = GetVtkViewFrame(); @@ -1330,28 +854,15 @@ void VisuGUI::DisplayOnlyPrs() { vf->getRenderer()->ResetCameraClippingRange(); vf->Repaint(); } - return; - } - // is it Curve ? - VISU::Curve_i* aCurve = dynamic_cast(VISU::GetServant(anObject)); - if(aCurve){ + }else if(VISU::Curve_i* aCurve = dynamic_cast(aServant)){ MESSAGE("VisuGUI::DisplayOnlyPrs : Curve object"); PlotCurve(aCurve, VISU::eDisplayOnly ); - return; - } - // is it Container ? - VISU::Container_i* aContainer = dynamic_cast(VISU::GetServant(anObject)); - if(aContainer){ + }else if(VISU::Container_i* aContainer = dynamic_cast(aServant)){ MESSAGE("VisuGUI::DisplayOnlyPrs : Container object"); PlotContainer(aContainer, VISU::eDisplayOnly ); - return; - } - // is it Table ? - VISU::Table_i* aTable = dynamic_cast(VISU::GetServant(anObject)); - if(aTable){ + }else if(VISU::Table_i* aTable = dynamic_cast(aServant)){ MESSAGE("VisuGUI::DisplayOnlyPrs : Table object"); PlotTable(aTable, VISU::eDisplayOnly ); - return; } } } @@ -1362,9 +873,7 @@ void VisuGUI::DisplayOnlyPrs() { //===================================================================================== void VisuGUI::ErasePrs() { MESSAGE("VisuGUI::ErasePrs"); - string aComment; - Handle(SALOME_InteractiveObject) anIO; - CORBA::Object_var anObject = GetSelectedObj(aComment, anIO, myActiveStudy); + CORBA::Object_var anObject = GetSelectedObj(); if ( !CORBA::is_nil( anObject ) ) { // is it Prs3d object ? VISU::Prs3d_i* aPrsObject = dynamic_cast(VISU::GetServant(anObject)); @@ -1397,61 +906,136 @@ void VisuGUI::ErasePrs() { } } - //===================================================================================== -// 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() +{ + 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){ + 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){ + MESSAGE("VisuGUI::DisplayManyPrs: Curve object"); + PlotCurve(aCurve, VISU::eDisplay ); + continue; + } + // is it Container ? + VISU::Container_i* aContainer = dynamic_cast(VISU::GetServant(aCORBAObject)); + if(aContainer){ + MESSAGE("VisuGUI::DisplayManyPrs : Container object"); + PlotContainer(aContainer, VISU::eDisplay ); + continue; + } + // is it Table ? + VISU::Table_i* aTable = dynamic_cast(VISU::GetServant(aCORBAObject)); + if(aTable){ + 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; +} - VISU_Actor* anVISUActor = GetActor(thePrs); - int isVisible = false; +//===================================================================================== +// function : EraseManyPrs() +// purpose : +//===================================================================================== +void VisuGUI::EraseManyPrs() +{ + 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){ + 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){ + MESSAGE("VisuGUI::EraseManyPrs : Curve object"); + PlotCurve(aCurve, VISU::eErase ); + continue; + } + // is it Container ? + VISU::Container_i* aContainer = dynamic_cast(VISU::GetServant(aCORBAObject)); + if(aContainer){ + MESSAGE("VisuGUI::EraseManyPrs : Container object"); + PlotContainer(aContainer, VISU::eErase ); + continue; + } + // is it Table ? + VISU::Table_i* aTable = dynamic_cast(VISU::GetServant(aCORBAObject)); + if(aTable){ + MESSAGE("VisuGUI::EraseManyPrs : Table object"); + PlotTable(aTable, VISU::eErase ); + continue; + } + } + } + } + } +} - 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(); +//===================================================================================== +// function : RecreateActor() +// purpose : +//===================================================================================== +void VisuGUI::RecreateActor(VISU::Prs3d_i* thePrs) { + QApplication::setOverrideCursor(Qt::waitCursor); + 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); + } QApplication::restoreOverrideCursor(); - - if (!anVISUActor) return; - anVISUActor->SetVisibility(isVisible); - aRen->AddActor(anVISUActor); - if (anVISUActor->HasScalarBar()) { - anVISUActor->getScalarBar()->SetVisibility(isVisible); - aRen->AddActor2D(anVISUActor->getScalarBar()); - } } @@ -1474,6 +1058,7 @@ void VisuGUI::RecreateActor(VISU::Prs3d_i* thePrs) { if ( vf->getRenderer()->GetActors()->GetNumberOfItems () > 0 ) { \ vf->getRenderer()->ResetCameraClippingRange(); \ vf->onViewFitAll(); \ + vf->Repaint(); \ }\ } \ } \ @@ -1483,7 +1068,7 @@ 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 +1086,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; @@ -1519,7 +1108,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); @@ -1546,14 +1135,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,10 +1147,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; @@ -1580,141 +1172,156 @@ 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 if(aComment == "ENTITY"){ VISU::Entity anEntity = (VISU::Entity)VISU::Storable::FindValue(aMap,"myId").toInt(); - aMesh = myComponent->MeshOnEntity(aResult,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()); + 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()); + 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"); + MESSAGE("VisuGUI::CreateMesh() - CREATE MESH"); 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); + VISU_Actor *anActor = pPresent->CreateActor(); + if (! anActor ) { + QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), + tr ("ERR_CANT_CREATE_ACTOR"), + tr ("VISU_BUT_OK") ); + return; + } #ifdef CHECKTIME - OSD_Timer timer; + Utils_Timer timer; timer.Start(); #endif vf->AddActor(anActor); - vf->getRenderer()->AddActor(anActor->EdgeDevice); vf->getRenderer()->ResetCameraClippingRange(); vf->onViewFitAll(); #ifdef CHECKTIME timer.Stop(); - MESSAGE("Check time on VisuGUI::CreateMesh - vf->AddActor + vf->onViewFitAll"); + MESSAGE("VisuGUI::CreateMesh() - DISPLAY MESH"); timer.Show(); #endif } - myActiveStudy->updateObjBrowser(); //update Object browser - myDesktop->putInfo("Ready"); + //GetActiveStudy()->updateObjBrowser(); //not necessary + GetDesktop()->putInfo("Ready"); } - //===================================================================================== -// function : ChangeRepresentation() +// function : CreateManyMesh() // purpose : //===================================================================================== +void VisuGUI::CreateManyMesh() +{ + if (checkLock(GetStudyDocument())) return; -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(); - break; - } - aPrevSource = anObject->GetSource(); - anObject = aPrevSource->GetInputs()[0]; - } - + SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection()); + SALOME_ListIteratorOfListIO It( Sel->StoredIObjects() ); + for ( ; It.More(); It.Next() ) { + SALOMEDS::SObject_var aSObject = GetActiveStudy()->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; - Actor->IsShrunk = false; - if ( Actor->GetProperty()->GetRepresentation() == 2 ) - Actor->EdgeDevice->VisibilityOn(); + 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)); + VISU_Actor *anActor = pPresent->CreateActor(); + if (! anActor ) return; + if(VTKViewer_ViewFrame* vf = GetVtkViewFrame()){ + vf->AddActor(anActor); + vf->getRenderer()->ResetCameraClippingRange(); + vf->onViewFitAll(); + } + } + GetDesktop()->putInfo("Ready"); } -void VisuGUI::ChangeRepresentation(RepresentType theType) { - VISU::Prs3d_i* aPrsObject = GetSelectedPrs(); - if(!aPrsObject) return; +//===================================================================================== +// function : ChangeRepresentation() +// purpose : +//===================================================================================== -#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; +static void ShrinkMesh(VISU_Actor *theActor){ + if(theActor->isShrunk()) + theActor->unShrink(); + else + theActor->setShrink(0.8); +} + +void VisuGUI::ChangeRepresentation(RepresentType theType) { + if(VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d()){ + if(VISU_Actor* anActor = GetActor(aPrsObject)){ + switch (theType) { + case POINTS: + case WIREFRAME: + case SURFACE: + anActor->SetRepresentation(theType); + break; + case SHRINK: + ShrinkMesh(anActor); + break; + } + if (VTKViewer_ViewFrame* vf = GetVtkViewFrame()) + vf->Repaint(); + } } - 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::MakeWireframe() { @@ -1742,15 +1349,14 @@ 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); +VISU::Prs3d_i* VisuGUI::GetSelectedPrs3d(Handle(SALOME_InteractiveObject)* theIO) { + CORBA::Object_var anObject = GetSelectedObj(theIO); + if(CORBA::is_nil(anObject)) return NULL; return dynamic_cast(VISU::GetServant(anObject)); } void VisuGUI::ChageColor() { - VISU::Prs3d_i* aPrsObject = GetSelectedPrs(); + VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d(); if(!aPrsObject) return; VISU_Actor* anActor = GetActor(aPrsObject); @@ -1759,17 +1365,17 @@ void VisuGUI::ChageColor() { } void VisuGUI::ChangeOutlineColor() { - VISU::Prs3d_i* aPrsObject = GetSelectedPrs(); + VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d(); if(!aPrsObject) return; - VISU_Actor* anActor = GetActor(aPrsObject); + VISUMesh_Actor* anActor = dynamic_cast(GetActor(aPrsObject)); if (!anActor) return; NewOutlineColor(anActor); } void VisuGUI::ChangeOpacity() { - VISU::Prs3d_i* aPrsObject = GetSelectedPrs(); + VISU::Prs3d_i* aPrsObject = GetSelectedPrs3d(); if(!aPrsObject) return; VISU_Actor* anActor = GetActor(aPrsObject); @@ -1779,7 +1385,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); @@ -1789,15 +1395,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 +1442,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 ); + } } } } @@ -1850,8 +1464,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 +1504,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 ); } } } @@ -1899,8 +1520,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 +1563,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 +1581,17 @@ 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 +1600,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 +1614,49 @@ 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() { + VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); + 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 +1669,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 +1679,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 +1708,7 @@ void VisuGUI::PlotData() { } } } - VisuGUI::myActiveStudy->updateObjBrowser( true ); + GetActiveStudy()->updateObjBrowser( true ); PlotContainer( pContainer, VISU::eDisplay ); } } @@ -2061,9 +1719,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 +1739,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 +1749,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 +1781,7 @@ void VisuGUI::PlotData() { } } } - VisuGUI::myActiveStudy->updateObjBrowser( true ); + GetActiveStudy()->updateObjBrowser( true ); PlotContainer( pContainer, VISU::eDisplay ); } } @@ -2131,13 +1789,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 ); } } @@ -2152,12 +1810,10 @@ void VisuGUI::PlotData() { */ 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 +1823,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 +1837,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 ) { @@ -2212,13 +1868,11 @@ void VisuGUI::CurveProperties() { */ 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 +1882,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 +1892,63 @@ void VisuGUI::ClearContainer() { void VisuGUI::DeletePrs() { - DeletePresentation(GetSelectedPrs()); + DeletePresentation(GetSelectedPrs3d()); } + void VisuGUI::SaveViewParams() { - if (checkLock(myStudy)) return; + if (checkLock(GetStudyDocument())) 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 ) ) - return; - VISU::ViewManager_i* pVM = dynamic_cast( VISU::GetServant( aVM ) ); - if ( !pVM ) + SALOME_Selection* Sel = SALOME_Selection::Selection( GetActiveStudy()->getSelection() ); + if ( Sel->IObjectCount() > 1 || GetActiveStudy()->getActiveStudyFrame()->getTypeView() != VIEW_VTK ) 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 +1957,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 +1980,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 +2006,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); - } + for (int j=0 ; jSetMapScale(aPercents); + aPrsObject->UpdateActor(aActor); + vf->getRW()->getRenderWindow()->Render(); + 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(); - } - } - break; } QApplication::restoreOverrideCursor(); } @@ -2467,14 +2024,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,71 +2051,59 @@ void VisuGUI::TimeAnimation() { } - void VisuGUI::ImportMedField() { - if (checkLock(myStudy)) return; - + if (checkLock(GetStudyDocument())) return; VisuGUI::GetOrCreateVisuGUI( QAD_Application::getDesktop() ); - SALOME_Selection* Sel = SALOME_Selection::Selection( VisuGUI::myActiveStudy->getSelection() ); + 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()); - 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; - } - } - } - } + Handle(SALOME_InteractiveObject) anIO = It.Value(); + SALOMEDS::SObject_var aSObject = GetStudyDocument()->FindObjectID(anIO->getEntry()); + if(!aSObject->_is_nil()){ + 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() ); + 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( aComment,anIO, GetActiveStudy()); 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 ); + GetVisuGen->ImportMedMesh( aMesh ); + GetActiveStudy()->updateObjBrowser( true ); } SALOME_MED::SUPPORT_ptr aSupport = SALOME_MED::SUPPORT::_narrow( anObject ); if( !CORBA::is_nil( aSupport ) ) { - VisuGUI::myComponent->ImportMedSupport( aSupport ); - VisuGUI::myActiveStudy->updateObjBrowser( true ); + GetVisuGen->ImportMedSupport( aSupport ); + GetActiveStudy()->updateObjBrowser( true ); } } } @@ -2568,14 +2113,27 @@ void VisuGUI::ImportMedMesh() { // purpose : //===================================================================================== void VisuGUI::Rename() { - if (checkLock(myStudy)) return; + if (checkLock(GetStudyDocument())) return; 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; - SALOMEDS::SObject_var aSObj = myStudy->FindObjectID( Sel->firstIObject()->getEntry() ); + 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; @@ -2584,7 +2142,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 ( curve ) + curve->SetName( Name.latin1() ); + GetActiveStudy()->renameIObject( Sel->firstIObject(), Name ); QApplication::restoreOverrideCursor(); //int TypeMode; bool InViewer; @@ -2600,8 +2160,8 @@ void VisuGUI::Rename() { // 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 +2169,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 +2177,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 +2185,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 +2193,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::TISOSURFACE: + 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: { 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 +2217,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,33 +2225,29 @@ 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, +void VisuGUI::InfoOnPoint(){ + SALOME_Selection *aSel = SALOME_Selection::Selection(GetActiveStudy()->getSelection()); + int aTypeMode = aSel->SelectionMode(); + if ( aTypeMode == SelectionPoint ){ + if(VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d()){ + vtkDataSet* aDataSet = aPrs3d->GetMapper()->GetInput(); + VisuGUI_Selection::PickingPoint( GetActiveStudy(), aDataSet); + } + }else + QAD_MessageBox::warn1( GetDesktop(), tr ("WARNING"), - tr ("Not Point selection mode"), + tr ("ERR_WRONG_SELECTION_MODE"), tr ("VISU_BUT_OK") ); } @@ -2691,22 +2255,18 @@ void VisuGUI::InfoOnPoint() // 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(){ + SALOME_Selection *aSel = SALOME_Selection::Selection(GetActiveStudy()->getSelection()); + int aTypeMode = aSel->SelectionMode(); + if( aTypeMode == SelectionCell){ + if(VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d()){ + vtkDataSet* aDataSet = aPrs3d->GetMapper()->GetInput(); + VisuGUI_Selection::PickingCell( GetActiveStudy(), aDataSet); + } + }else + QAD_MessageBox::warn1( GetDesktop(), tr ("WARNING"), - tr ("Not Cell/Edge selection mode"), + tr ("ERR_WRONG_SELECTION_MODE"), tr ("VISU_BUT_OK") ); } @@ -2714,91 +2274,56 @@ 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, +void VisuGUI::SelectPoint(){ + SALOME_Selection *aSel = SALOME_Selection::Selection(GetActiveStudy()->getSelection()); + if ( aSel->SelectionMode() != SelectionPoint ) { + QAD_MessageBox::warn1( GetDesktop(), tr ("WARNING"), - tr ("Not Point selection mode"), + tr ("ERR_WRONG_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 ); + Handle(SALOME_InteractiveObject) anIO; + if(VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d(&anIO)){ + bool ok = FALSE; + int anId = SALOMEGUI_SetValueDlg::getInteger( tr("Point selection"), + tr("Point number:" ), + 0, + &ok, + GetDesktop()); + vtkDataSet *aDataSet = aPrs3d->GetMapper()->GetInput(); + int aMaxId = aDataSet->GetNumberOfPoints(); + if (ok && 0 < anId && anId <= aMaxId ) + VisuGUI_Selection::Highlight( GetActiveStudy(), anIO, anId ); + } } //===================================================================================== // function : SelectCell() [ slot ] // purpose : //===================================================================================== -void VisuGUI::SelectCell() -{ - 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, +void VisuGUI::SelectCell(){ + SALOME_Selection *aSel = SALOME_Selection::Selection(GetActiveStudy()->getSelection()); + if ( aSel->SelectionMode() != SelectionCell) { + 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); + if(VISU::Prs3d_i* aPrs3d = GetSelectedPrs3d(&anIO)){ + bool ok = FALSE; + int anId = SALOMEGUI_SetValueDlg::getInteger( tr("Cell selection"), + tr("Cell number:" ), + 0, + &ok, + GetDesktop()); + vtkDataSet *aDataSet = aPrs3d->GetMapper()->GetInput(); + int aMaxId = aDataSet->GetNumberOfCells(); + if (ok && 0 < anId && anId <= aMaxId ) + VisuGUI_Selection::Highlight( GetActiveStudy(), anIO, anId ); } - 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); } //===================================================================================== @@ -2813,6 +2338,109 @@ void VisuGUI::DefinePopup( QString & theContext, QString & theParent, QString & } +//===================================================================================== +// 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; + } + } + return selMode; +} + +//===================================================================================== +// function : GetNbChildren() [ static ] +// purpose : get number of children +//===================================================================================== +int GetNbChildren( SALOMEDS::SObject_var SO, bool refToo ) +{ + 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 : @@ -2824,10 +2452,10 @@ bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QStri 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()); + SALOME_Selection* Sel = SALOME_Selection::Selection(GetActiveStudy()->getSelection()); if ( Sel->IObjectCount() == 0 ) { if ( theParent == "Viewer" && isVTKViewer) // Available only for VTK viewer @@ -2835,19 +2463,37 @@ bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QStri return false; } + if( Sel->IObjectCount() > 1 ) { + int selMode = checkHomoSelection(); + MESSAGE( "VisuGUI::CustomPopup: multiple selection : selMode = "<getActiveStudyFrame()->getTypeView() == VIEW_PLOT2D ) { + thePopup->insertItem( "Display", visuGUI, SLOT( DisplayManyPrs() ) ); + thePopup->insertItem( "Erase", visuGUI, SLOT( EraseManyPrs () ) ); + } + } + 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; - + 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( "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 +2539,9 @@ 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( "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() ) ); @@ -2909,12 +2559,24 @@ bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QStri 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) + QPopupMenu* aPresMenu = new QPopupMenu(GetDesktop()); + int aRepresent = anVISUActor->GetRepresentation(); + switch(aRepresent){ + case 0: //POINTS + aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe())); + aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface())); + break; + case 1: //WIREFRAME + aPresMenu->insertItem("Surface", visuGUI, SLOT(MakeSurface())); + aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints())); + break; + case 2: //SURFACE + aPresMenu->insertItem("Wireframe", visuGUI, SLOT(MakeWireframe())); + aPresMenu->insertItem("Points", visuGUI, SLOT(MakePoints())); + break; + } + if (anVISUActor->GetShrinkable()) { + if (anVISUActor->isShrunk()) aPresMenu->insertItem("Unshrink", visuGUI, SLOT(MakeShrink())); else aPresMenu->insertItem("Shrink", visuGUI, SLOT(MakeShrink())); @@ -2923,11 +2585,11 @@ bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QStri } // Add Properties - QPopupMenu* aPropMenu = new QPopupMenu(VisuGUI::myDesktop); + QPopupMenu* aPropMenu = new QPopupMenu(GetDesktop()); if ((aType == VISU::TMESH) || (aType == VISU::TDEFORMEDSHAPE) || (aType == VISU::TVECTORS) || - (aType == VISU::TSTREAMLINES)) // Mesh, deformed shape, vectors + (aType == VISU::TSTREAMLINES)) aPropMenu->insertItem("Color", visuGUI, SLOT(ChageColor())); if (aType == VISU::TMESH) aPropMenu->insertItem("Outline Color", visuGUI, SLOT(ChangeOutlineColor())); @@ -2945,8 +2607,12 @@ 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::TVECTORS) && (aType != VISU::TSTREAMLINES) + && (aType != VISU::TCUTLINES) && isVTKViewer) + thePopup->insertItem("Sweep", visuGUI, SLOT(Sweep())); + + if (aType == VISU::TCUTLINES) + thePopup->insertItem( "Create Table", visuGUI, SLOT( CreateTable() ) ); } if (isVTKViewer) { if ( theParent == "Viewer" && @@ -2958,23 +2624,24 @@ bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QStri thePopup->insertItem("Results at Point", visuGUI, SLOT(InfoOnPoint())); thePopup->insertItem("Select a Point", visuGUI, SLOT(SelectPoint())); } - else if ( Sel->SelectionMode() == SelectionCell || Sel->SelectionMode() == SelectionEdge ) { + else if ( Sel->SelectionMode() == SelectionCell) { 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())); + 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())); + } } } } @@ -2982,88 +2649,81 @@ bool VisuGUI::CustomPopup(QAD_Desktop* parent, QPopupMenu* thePopup, const QStri } 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() ) ); + 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( "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())); + thePopup->insertItem(rmgr->loadPixmap( "VisuGUI", tr("ICON_CUT_LINES") ), + "Cut Lines...", visuGUI, SLOT(CreateCutLines())); + 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())); + } + 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( "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())); - 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())); - } - } } - return false; } //=========================================================================== @@ -3082,12 +2742,12 @@ void VisuGUI::BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO) 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); @@ -3114,9 +2774,6 @@ void VisuGUI::BuildPresentation(const Handle(SALOME_InteractiveObject)& theIO) } VTKViewer_ViewFrame* vf = GetVtkViewFrame(); vf->AddActor(SelectedActor); - if(SelectedActor->HasScalarBar()){ - Renderer->AddActor2D(SelectedActor->getScalarBar()); - } } else { MESSAGE("CORBA::is_nil(anObject) = true"); @@ -3177,80 +2834,65 @@ 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()){ + SALOMEDS::Color anOldColor = aPrs3d->GetColor(), 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.; + aPrs3d->SetColor(aNewColor); + aPrs3d->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(aPrs3d,aViewFrame)) + aPrs3d->UpdateActor(anActor); + } + } + } } -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::NewOutlineColor(VISUMesh_Actor *theActor){ + if(VISU::Mesh_i* aPrs3d = dynamic_cast(theActor->getPrs3d())){ + SALOMEDS::Color anOldColor = aPrs3d->GetColor(), 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.; + aPrs3d->SetLinkColor(aNewColor); + 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(aPrs3d,aViewFrame)) + aPrs3d->UpdateActor(anActor); + } + } + } } ////////////////////////////////////////////////////////////////////////////////// @@ -3307,7 +2949,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 +2959,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; } @@ -3413,17 +3055,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; } @@ -3434,21 +3077,19 @@ PRSTYPE* FNAME(SALOMEDS::SObject_var theField, \ const char* theFieldName, double 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 +3098,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,12 +3107,19 @@ 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(); \ + Utils_Timer timer; \ + if(MYCHECKTIME) timer.Start(); \ TYPE* pPresent = FCREATE(theField,aMeshName,(VISU::Entity)anEntity.toInt(),aFieldName,aTimeStampId.toDouble()); \ + if(MYCHECKTIME) { \ + timer.Stop(); \ + MESSAGE("BUILDPRS(TYPE, FCREATE, FNAME, DLGNAME) - CREATE PRSOBJECT"); \ + timer.Show(); \ + } \ if (pPresent) { \ DLGNAME* aDlg = new DLGNAME(); \ aDlg->initFromPrsObject(pPresent); \ @@ -3493,6 +3142,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); @@ -3512,7 +3162,7 @@ void VisuGUI::ImportTablesFromFile(){ aDir = QAD_Tools::getDirFromPath(aFile); QAD_CONFIG->addSetting("Visu:InputDir",aDir); QApplication::setOverrideCursor( Qt::waitCursor ); - QAD_PyInterp* myPyInterp = myActiveStudy->get_PyInterp(); + QAD_PyInterp* myPyInterp = GetActiveStudy()->get_PyInterp(); myPyInterp->run("import VisuGUI"); myPyInterp->run("reload(VisuGUI)"); myPyInterp->run("VisuGUI.AddTablesInStudyFromFile('"+aFile+"')"); @@ -3523,7 +3173,7 @@ void VisuGUI::ImportTablesFromFile(){ // tr ("VISU_BUT_OK") ); // else // QAD_Application::getDesktop()->putInfo(aFile+" imported."); - myActiveStudy->updateObjBrowser(); //update Object browser + GetActiveStudy()->updateObjBrowser(); //update Object browser QApplication::restoreOverrideCursor(); } } @@ -3532,7 +3182,7 @@ 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)" ); @@ -3544,21 +3194,41 @@ void VisuGUI::ImportFromFile(){ QAD_Application::getDesktop()->putInfo( "Importing From File " + aFile + "..." ); aDir = QAD_Tools::getDirFromPath(aFile); 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; + + CORBA::Object_var anObject; +#ifdef CHECKTIME + Utils_Timer timer; + timer.Start(); +#endif + if(aFileInfo.extension(false) == "med") + anObject = GetVisuGen()->ImportFile(aFileInfo.filePath()); + else if(aFileInfo.extension(false) == "xls") + anObject = GetVisuGen()->ImportTables(aFileInfo.filePath()); +#ifdef CHECKTIME + timer.Stop(); + MESSAGE("VisuGUI::ImportFromFile() - IMPORT FILE"); + timer.Show(); +#endif + + if(CORBA::is_nil(anObject)) { + 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)" ); @@ -3576,166 +3246,47 @@ void VisuGUI::ExportToFile(){ 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->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 +3304,30 @@ 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(); } } } if (aResActor) return aResActor; -#ifdef CHECKTIME - OSD_Timer timer; - timer.Start(); -#endif anVISUActor = thePrs->CreateActor(); MESSAGE("UpdateViewer - thePrs->CreateActor() = "<AddActor(anVISUActor); - if(anVISUActor->HasScalarBar()){ - aRen->AddActor2D(anVISUActor->getScalarBar()); - } } else 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 return anVISUActor; } @@ -3816,14 +3344,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,41 +3355,19 @@ 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 } /** @@ -3877,36 +3379,22 @@ void VisuGUI::CreateActor(VISU::Prs3d_i* thePrs) { VTKViewer_ViewFrame* vf = GetVtkViewFrame(); if (vf) { #ifdef CHECKTIME - OSD_Timer timer; - timer.Start(); + Utils_Timer timer; + timer.Start(); #endif VISU_Actor* aActor = thePrs->CreateActor(); if ( ! aActor ) { QApplication::restoreOverrideCursor(); QAD_MessageBox::warn1 ( QAD_Application::getDesktop(), tr ("VISU_WARNING"), - tr ("The presentation can't be visualized.\n Null actor is created."), + tr ("WRN_CANT_VISUALIZE_PRS"), tr ("VISU_BUT_OK") ); return; } -#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"); - timer.Show(); + timer.Stop(); + MESSAGE("VisuGUI::CreateActor(VISU::Prs3d_i* thePrs) - DISPLAY ACTOR"); + timer.Show(); #endif } QApplication::restoreOverrideCursor(); @@ -3953,13 +3441,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 ; -} diff --git a/src/VISUGUI/VisuGUI.h b/src/VISUGUI/VisuGUI.h index 8af43519..ad52d84f 100644 --- a/src/VISUGUI/VisuGUI.h +++ b/src/VISUGUI/VisuGUI.h @@ -1,9 +1,29 @@ -// File : VisuGUI.h -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// 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.h +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ #ifndef VisuGUI_HeaderFile @@ -28,30 +48,7 @@ #include #include "SALOME_ListIteratorOfListIO.hxx" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static QString filters[] = { "DAT Files (*.dat)", - "Pressures Files (*.pre)", - "Displacements Files (*.dis)", - "Scalars Files (*.sca)", - "Vectors Files (*.vec)", - "Data Files (*.dat )", - "Vtk Files (*.vtk )", - "Med Files (*.med)", - "Results Files (*.res )", - "Print Files (*.tif)", - "Plot Files (*.plt)", - "Test Files (*.tst)" }; - -typedef enum {SOLVER,DAT_FILE,VTK_FILE,RES_FILE,MED_FILE,SMESH_FILE,VISU_FILE,SCALAR_FILE,ERROR} result ; +class vtkRenderer; enum RepresentType { POINTS, WIREFRAME, SURFACE, SHRINK }; @@ -61,218 +58,185 @@ enum RepresentType { POINTS, WIREFRAME, SURFACE, SHRINK }; // CLASS VIUSGUI // ====================================================================== // -class VisuGUI : public QObject -{ - Q_OBJECT - -public : -VisuGUI(); -~VisuGUI(); - -// Methods PUBLIC for Visualization -// - static SALOMEDS::Study_var GetCurrentStudy() { return myStudy; } - static QAD_Study* GetGUICurrentStudy() { return myActiveStudy; } - static VTKViewer_ViewFrame* GetVtkViewFrame(); - static SALOMEDS::StudyBuilder_var GetStudyBuilder() { return myStudyBuilder;} - static VISU::Storable::TRestoringMap getMapOfValue(SALOMEDS::SObject_var theSObject); - - static vtkRenderer* GetRenderer(QAD_Study* theStudy); - - -static VisuGUI* GetOrCreateVisuGUI( QAD_Desktop* desktop ); -static VisuGUI* GetVisuGUI() ; -static VISU::Result_i* CreatePresent(SALOMEDS::SObject_var theField, VISU::Result_var& theResult); - -bool CreateScalarMap(SALOMEDS::SObject_var theField); -static VISU::ScalarMap_i* CreateScalarMapPrs(SALOMEDS::SObject_var theField, +class VisuGUI : public QObject{ + Q_OBJECT; + public: + VisuGUI(); + ~VisuGUI(); + + static VISU::VISU_Gen_i* GetVisuGen(); + + static QAD_Desktop* GetDesktop(); + static QAD_Study* GetActiveStudy(); + static vtkRenderer* GetRenderer(); + static VTKViewer_ViewFrame* GetVtkViewFrame(); + static SALOMEDS::Study_var GetStudyDocument(); + static SALOMEDS::StudyBuilder_var NewBuilder(); + static VISU::Storable::TRestoringMap getMapOfValue(SALOMEDS::SObject_var theSObject); + + static VisuGUI* GetOrCreateVisuGUI(QAD_Desktop* desktop); + static VisuGUI* GetVisuGUI() ; + + static VISU::Result_i* CreatePresent(SALOMEDS::SObject_var theField, VISU::Result_var& theResult); + + bool CreateScalarMap(SALOMEDS::SObject_var theField); + static VISU::ScalarMap_i* CreateScalarMapPrs(SALOMEDS::SObject_var theField, + const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, double theTimeId); + bool CreateDeformedShape(SALOMEDS::SObject_var theField); + static VISU::DeformedShape_i* CreateDeformedShapePrs(SALOMEDS::SObject_var theField, + const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, double theTimeId); + bool CreateVectors(SALOMEDS::SObject_var theField); + static VISU::Vectors_i* CreateVectorsPrs(SALOMEDS::SObject_var theField, + const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, double theTimeId); + bool CreateIsoSurfaces(SALOMEDS::SObject_var theField); + static VISU::IsoSurfaces_i* CreateIsoSurfacesPrs(SALOMEDS::SObject_var theField, + const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, double theTimeId); + bool CreateCutPlanes(SALOMEDS::SObject_var theField); + static VISU::CutPlanes_i* CreateCutPlanesPrs(SALOMEDS::SObject_var theField, + const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, double theTimeId); + bool CreateCutLines(SALOMEDS::SObject_var theField); + static VISU::CutLines_i* CreateCutLinesPrs(SALOMEDS::SObject_var theField, const char* theMeshName, VISU::Entity theEntity, const char* theFieldName, double theTimeId); -bool CreateDeformedShape(SALOMEDS::SObject_var theField); -static VISU::DeformedShape_i* CreateDeformedShapePrs(SALOMEDS::SObject_var theField, - const char* theMeshName, VISU::Entity theEntity, - const char* theFieldName, double theTimeId); -bool CreateVectors(SALOMEDS::SObject_var theField); -static VISU::Vectors_i* CreateVectorsPrs(SALOMEDS::SObject_var theField, - const char* theMeshName, VISU::Entity theEntity, - const char* theFieldName, double theTimeId); -bool CreateIsoSurfaces(SALOMEDS::SObject_var theField); -static VISU::IsoSurfaces_i* CreateIsoSurfacesPrs(SALOMEDS::SObject_var theField, - const char* theMeshName, VISU::Entity theEntity, - const char* theFieldName, double theTimeId); -bool CreateCutPlanes(SALOMEDS::SObject_var theField); -static VISU::CutPlanes_i* CreateCutPlanesPrs(SALOMEDS::SObject_var theField, - const char* theMeshName, VISU::Entity theEntity, - const char* theFieldName, double theTimeId); -bool CreateStreamLines(SALOMEDS::SObject_var theField); -static VISU::StreamLines_i* CreateStreamLinesPrs(SALOMEDS::SObject_var theField, - const char* theMeshName, VISU::Entity theEntity, - const char* theFieldName, double theTimeId); -bool TestObjectBrowser(SALOMEDS::SObject_var *objVisu); - -static void ClearViewer(QAD_Desktop* parent, vtkRenderer *ren, int TypeOfActor); -static void ShowTrihedron(bool Show); -static void ChangeViewer(QAD_Desktop* parent, vtkRenderer *ren, bool ScalarBar, int Type); - -static void NewColor(VISU_Actor *Actor); -static void NewOutlineColor(VISU_Actor *Actor); -static void NewOpacity(VISU_Actor *Actor); -static void NewLinewidth(VISU_Actor *Actor); - -static void ChangeScalarBar(); -static void SetSweepingPreferences(); -static VISU_Actor *ReferenceActor(QAD_Desktop* parent); - -static void PlotTable( VISU::Table_i* table, int theDisplaying ); -static void PlotCurve( VISU::Curve_i* curve, int theDisplaying ); -static void PlotContainer( VISU::Container_i* container, int theDisplaying ); - -void PrintRW(QString prFile, bool toPrinter); - -static QString getVisuInputDir(); -static QString getVisuOutputDir(); - -static VISU_Actor *ActorSelected(QAD_Desktop* parent, bool InViewer, int *Mode); -static VISU_Actor *GetActorObjBrowser(SALOMEDS::SObject_var objVisu, vtkRenderer *ren); -static VISU_Actor *GetActor(QAD_Desktop* parent, Handle_SALOME_InteractiveObject IO, vtkRenderer *ren); - - static QString getValue(SALOMEDS::SObject_var theSObject, QString theKey); - - -VISU_Actor* UpdateViewer(VISU::Prs3d_i* thePrs, bool theDispOnly=false); -bool IsDisplayed(VISU::Prs3d_i* thePrs); -void ErasePrs(VISU::Prs3d_i* thePrs); - -VISU_Actor* GetActor(VISU::Prs3d_i* thePrs); -static VISU::Prs3d_i* GetSelectedPrs(); -void RecreateActor(VISU::Prs3d_i* thePrs); -static void CreateActor(VISU::Prs3d_i* thePrs); - -void VisuGUI::ChangeRepresentation(RepresentType theType); -void DeletePresentation(VISU::Prs3d_i* thePrs); - - -void SetState(int aState ); -void ResetState(); -void EmitSignalDeactivateDialog(); -void EmitSignalCloseAllDialogs(); -QDialog* GetActiveDialogBox(); -void SetActiveDialogBox(QDialog* aDlg); -QAD_Study* GetActiveStudy(); -QAD_Desktop* GetDesktop(); - + bool CreateStreamLines(SALOMEDS::SObject_var theField); + static VISU::StreamLines_i* CreateStreamLinesPrs(SALOMEDS::SObject_var theField, + const char* theMeshName, VISU::Entity theEntity, + const char* theFieldName, double theTimeId); + bool TestObjectBrowser(SALOMEDS::SObject_var& objVisu); + + static void ShowTrihedron(bool Show); + static void ChangeViewer(int theType); + + static void NewColor(VISU_Actor *Actor); + static void NewOutlineColor(VISUMesh_Actor *Actor); + static void NewOpacity(VISU_Actor *Actor); + static void NewLinewidth(VISU_Actor *Actor); + + static void ChangeScalarBar(); + static void SetSweepingPreferences(); + + static void PlotTable( VISU::Table_i* table, int theDisplaying ); + static void PlotCurve( VISU::Curve_i* curve, int theDisplaying ); + static void PlotContainer( VISU::Container_i* container, int theDisplaying ); + + static QString getVisuInputDir(); + static QString getVisuOutputDir(); + + static QString getValue(SALOMEDS::SObject_var theSObject, QString theKey); + static int checkHomoSelection(); + + VISU_Actor* UpdateViewer(VISU::Prs3d_i* thePrs, bool theDispOnly=false); + bool IsDisplayed(VISU::Prs3d_i* thePrs); + void ErasePrs(VISU::Prs3d_i* thePrs); + + static VISU::Prs3d_i* GetSelectedPrs3d(Handle(SALOME_InteractiveObject)* theIO = NULL); + void RecreateActor(VISU::Prs3d_i* thePrs); + static void CreateActor(VISU::Prs3d_i* thePrs); + static VISU_Actor *GetActor(int* theSelectionType = NULL); + static VISU_Actor* GetActor(VISU::Prs3d_i* thePrs, VTKViewer_ViewFrame* theViewFrame = NULL); + + void VisuGUI::ChangeRepresentation(RepresentType theType); + void DeletePresentation(VISU::Prs3d_i* thePrs); + + void SetState(int aState ); + void ResetState(); + void EmitSignalDeactivateDialog(); + void EmitSignalCloseAllDialogs(); + QDialog* GetActiveDialogBox(); + void SetActiveDialogBox(QDialog* aDlg); + // ---------------------------------------- // All method of standard EXPORT // ---------------------------------------- -// -Standard_EXPORT static bool OnGUIEvent (int theCommandID, QAD_Desktop* parent); - -Standard_EXPORT static bool setSettings (QAD_Desktop* parent); - -Standard_EXPORT static void DefinePopup(QString & theContext, - QString & theParent, - QString & theObject ) ; - -Standard_EXPORT static bool CustomPopup (QAD_Desktop* parent, - QPopupMenu* popup, - const QString & theContext, - const QString & theParent, - const QString & theObject); - -Standard_EXPORT static void BuildPresentation(const Handle(SALOME_InteractiveObject)&); - -Standard_EXPORT static bool OnMousePress (QMouseEvent* pe , + Standard_EXPORT static bool OnGUIEvent(int theCommandID, QAD_Desktop* parent); + Standard_EXPORT static bool setSettings(QAD_Desktop* parent); + Standard_EXPORT static void DefinePopup(QString & theContext, + QString & theParent, + QString & theObject ) ; + Standard_EXPORT static bool CustomPopup(QAD_Desktop* parent, + QPopupMenu* popup, + const QString & theContext, + const QString & theParent, + const QString & theObject); + Standard_EXPORT static void BuildPresentation(const Handle(SALOME_InteractiveObject)&); + Standard_EXPORT static bool OnMousePress(QMouseEvent* pe , + QAD_Desktop* parent, + QAD_StudyFrame* studyFrame); + Standard_EXPORT static bool OnMouseMove(QMouseEvent* pe , QAD_Desktop* parent, QAD_StudyFrame* studyFrame); - -Standard_EXPORT static bool OnMouseMove (QMouseEvent* pe , - QAD_Desktop* parent, + Standard_EXPORT static bool OnKeyPress(QKeyEvent* pe, + QAD_Desktop* parent, QAD_StudyFrame* studyFrame); - -Standard_EXPORT static bool OnKeyPress (QKeyEvent* pe, - QAD_Desktop* parent, - QAD_StudyFrame* studyFrame); - -Standard_EXPORT static bool APIreaderVTK (QString FileMesh, QString FileResultat); - -Standard_EXPORT static bool getObjectRef(QAD_Desktop* parent, SALOMEDS::SObject_ptr obj, - _CORBA_ObjRef_OUT_arg< SALOMEDS::_objref_SObject, SALOMEDS::SObject_Helper > objres, - const char* Type); - -public slots: - void ImportTablesFromFile(); - void ImportFromFile(); - void ExportToFile(); - void CreateMesh(); - void CreateScalarMap(); - void CreateDeformedShape(); - void CreateVectors(); - void CreateIsoSurfaces(); - void CreateCutPlanes(); - void CreateStreamLines(); - - void DisplayPrs(); - void DisplayOnlyPrs(); - void ErasePrs(); - void EditPrs(); - void EditScalarBar(); - - void MakeWireframe(); - void MakeSurface(); - void MakePoints(); - void MakeShrink(); - - void ChageColor(); - void ChangeOutlineColor(); - void ChangeOpacity(); - void ChangeLines(); - - void ShowTable(); - void PlotData(); - void CurveProperties(); - void ClearContainer(); - - void SaveViewParams(); - void RestoreViewParams(); - - void DeletePrs(); - void Rename(); - void Sweep(); - void TimeAnimation(); - - void ImportMedField(); - //void ImportMedMesh(); - - void DeleteViewParams(); - void CopyPresentation(); - - void InfoOnPoint(); - void InfoOnCell(); - void SelectPoint(); - void SelectCell(); - -protected: + public slots: + void ImportTablesFromFile(); + void ImportFromFile(); + void ExportToFile(); + void CreateMesh(); + void CreateScalarMap(); + void CreateDeformedShape(); + void CreateVectors(); + void CreateIsoSurfaces(); + void CreateCutPlanes(); + void CreateCutLines(); + void CreateStreamLines(); + void CreateManyMesh(); - // Methods PROTECTED - // - + void DisplayPrs(); + void DisplayOnlyPrs(); + void ErasePrs(); + void EditPrs(); + void EditScalarBar(); + void DisplayManyPrs(); + void EraseManyPrs(); + + void MakeWireframe(); + void MakeSurface(); + void MakePoints(); + void MakeShrink(); + + void ChageColor(); + void ChangeOutlineColor(); + void ChangeOpacity(); + void ChangeLines(); + + void ShowTable(); + void CreateTable(); + void PlotData(); + void CurveProperties(); + void ClearContainer(); + + void SaveViewParams(); + void RestoreViewParams(); + + void DeletePrs(); + void Rename(); + void Sweep(); + void TimeAnimation(); + + void ImportMedField(); + //void ImportMedMesh(); + + void DeleteViewParams(); + void CopyPresentation(); - // Fields PROTECTED - // + void InfoOnPoint(); + void InfoOnCell(); + void SelectPoint(); + void SelectCell(); private : - static VISU::VISU_Gen_var myComponent; - static SALOMEDS::Study_var myStudy; - static SALOMEDS::StudyBuilder_var myStudyBuilder; - static QAD_Desktop* myDesktop; - static QAD_Study* myActiveStudy; - QDialog* myActiveDialogBox; - int myState ; - int myStudyId; - + QDialog* myActiveDialogBox; + int myState ; + signals: - void SignalDeactivateActiveDialog(); - void SignalCloseAllDialogs(); + void SignalDeactivateActiveDialog(); + void SignalCloseAllDialogs(); }; #endif diff --git a/src/VISUGUI/VisuGUI.py b/src/VISUGUI/VisuGUI.py index 5cf88ec8..c2eed503 100644 --- a/src/VISUGUI/VisuGUI.py +++ b/src/VISUGUI/VisuGUI.py @@ -1,3 +1,12 @@ +# VISU VISUGUI : GUI of VISU component +# +# Copyright (C) 2003 CEA/DEN, EDF R&D +# +# +# +# File : VisuGUI.py +# Module : VISU + class Row: def __init__(self): self.title = "" diff --git a/src/VISUGUI/VisuGUI_CellsResultsDlg.cxx b/src/VISUGUI/VisuGUI_CellsResultsDlg.cxx index b95055fc..5ee37e60 100644 --- a/src/VISUGUI/VisuGUI_CellsResultsDlg.cxx +++ b/src/VISUGUI/VisuGUI_CellsResultsDlg.cxx @@ -1,12 +1,32 @@ -using namespace std; -// File : VisuGUI_CellsResultsDlg.cxx -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// 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_CellsResultsDlg.cxx +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ +using namespace std; #include "VisuGUI_CellsResultsDlg.h" #include #include diff --git a/src/VISUGUI/VisuGUI_CellsResultsDlg.h b/src/VISUGUI/VisuGUI_CellsResultsDlg.h index 65e1a849..e937e91c 100644 --- a/src/VISUGUI/VisuGUI_CellsResultsDlg.h +++ b/src/VISUGUI/VisuGUI_CellsResultsDlg.h @@ -1,9 +1,29 @@ -// File : VisuGUI_CellsResultsDlg.h -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// 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_CellsResultsDlg.h +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ #ifndef VISUGUI_CELLSRESULTSDLG_H diff --git a/src/VISUGUI/VisuGUI_CursorDlg.cxx b/src/VISUGUI/VisuGUI_CursorDlg.cxx index bb29dc65..c3c83227 100644 --- a/src/VISUGUI/VisuGUI_CursorDlg.cxx +++ b/src/VISUGUI/VisuGUI_CursorDlg.cxx @@ -1,12 +1,32 @@ -using namespace std; -// File : VisuGUI_CursorDlg.cxx -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// 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_CursorDlg.cxx +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ +using namespace std; #include "VisuGUI_CursorDlg.h" #include diff --git a/src/VISUGUI/VisuGUI_CursorDlg.h b/src/VISUGUI/VisuGUI_CursorDlg.h index 0668aa6f..72958e42 100644 --- a/src/VISUGUI/VisuGUI_CursorDlg.h +++ b/src/VISUGUI/VisuGUI_CursorDlg.h @@ -1,9 +1,29 @@ -// File : VisuGUI_CursorDlg.h -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// 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_CursorDlg.h +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ #ifndef VISUGUI_CURSORDLG_H diff --git a/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx b/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx index fc0d175d..0e87bf97 100644 --- a/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx +++ b/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx @@ -1,12 +1,32 @@ -using namespace std; -// File : VisuGUI_CutPlanesDlg.cxx -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// 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_CutPlanesDlg.cxx +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ +using namespace std; #include "VisuGUI_CutPlanesDlg.h" #include #include "QAD_Application.h" @@ -24,56 +44,7 @@ VisuGUI_CutPlanesDlg::VisuGUI_CutPlanesDlg() QGridLayout* TopLayout = new QGridLayout( this ); TopLayout->setSpacing( 6 ); TopLayout->setMargin( 11 ); - /* - QGridLayout* CommentLayout = new QGridLayout; - CommentLayout->setMargin( 0 ); - CommentLayout->setSpacing( 6 ); - - QLabel* Comment1 = new QLabel( tr( "Enter plane position between" ), this, "Comment1" ); - Comment1->setText( tr( "Enter plane position between" ) ); - Comment1->setAlignment( AlignCenter ); - - Comment2_1 = new QLabel( tr( "v1" ), this, "Comment2_1" ); - Comment2_1->setMinimumSize( QSize( 70, 0 ) ); - Comment2_1->setAlignment( AlignCenter); - - QLabel* Comment2 = new QLabel( tr( " and " ), this, "Comment2" ); - Comment2->setAlignment( AlignCenter ); - - Comment2_2 = new QLabel( tr( "v2" ), this, "Comment2_2" ); - Comment2_2->setMinimumSize( QSize( 70, 0 ) ); - Comment2_2->setAlignment( AlignCenter ); - - QLabel* Comment3 = new QLabel( tr( "or in fraction between" ), this, "Comment3" ); - Comment3->setAlignment( AlignCenter ); - - QLabel* Commento4 = new QLabel( tr( " and " ), this, "Comment4" ); - Comment4->setAlignment( AlignCenter ); - - QLabel* Comment4_1 = new QLabel( tr( "0" ), this, "Comment4_1" ); - Comment4_1->setMinimumSize( QSize( 70, 0 ) ); - Comment4_1->setAlignment( AlignCenter ); - - QLabel* Comment4_2 = new QLabel( tr( "100" ), this, "Comment4_2" ); - Comment4_2->setMinimumSize( QSize( 70, 0 ) ); - Comment4_2->setAlignment( AlignCenter ); - QFont font = Comment3->font(); font.setBold( true ); - Comment2_1->setFont( font ); - Comment2_2->setFont( font ); - Comment4_1->setFont( font ); - Comment4_2->setFont( font ); - - CommentLayout->addMultiCellWidget( Comment1, 0, 0, 0, 2 ); - CommentLayout->addWidget( Comment2_1, 1, 0 ); - CommentLayout->addWidget( Comment2, 1, 1 ); - CommentLayout->addWidget( Comment2_2, 1, 2 ); - CommentLayout->addMultiCellWidget( Comment3, 2, 2, 0, 2 ); - CommentLayout->addWidget( Comment4_1, 3, 0 ); - CommentLayout->addWidget( Comment4, 3, 1 ); - CommentLayout->addWidget( Comment4_2, 3, 2 ); - CommentLayout->setColStretch( 0 , 5 ); - CommentLayout->setColStretch( 2 , 5 ); - */ + QButtonGroup* SelPlane = new QButtonGroup( tr( "Orientation" ), this, "SelPlane" ); SelPlane->setTitle( tr( "Orientation" ) ); SelPlane->setColumnLayout(0, Qt::Vertical ); @@ -96,57 +67,7 @@ VisuGUI_CutPlanesDlg::VisuGUI_CutPlanesDlg() nbPlan = new QSpinBox( 1, 100, 1, this, "nbPlan" ); nbPlan->setValue( 1 ); nbPlan->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - /* - GBplan1 = new QGroupBox( tr( "First plane" ), this, "GBplan1" ); - GBplan1->setColumnLayout(0, Qt::Vertical ); - GBplan1->layout()->setSpacing( 0 ); - GBplan1->layout()->setMargin( 0 ); - QGridLayout* GBplan1Layout = new QGridLayout( GBplan1->layout() ); - GBplan1Layout->setAlignment( Qt::AlignTop ); - GBplan1Layout->setSpacing( 6 ); - GBplan1Layout->setMargin( 11 ); - - QLabel* LabelPos = new QLabel( tr( "Plane position (value):" ), GBplan1, "LabelPos" ); - GBplan1Layout->addWidget( LabelPos, 0, 0 ); - - PosPlan1 = new QAD_SpinBoxDbl( GBplan1, -999.999, 999.999, 0.1 ); - PosPlan1->setValue( 0 ); - PosPlan1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - GBplan1Layout->addWidget( PosPlan1, 0, 1 ); - - QLabel* LabelPosi = new QLabel( tr( "Plane position (fraction):" ), GBplan1, "LabelPosi" ); - GBplan1Layout->addWidget( LabelPosi, 1, 0 ); - - PosFrac1 = new QAD_SpinBoxDbl( GBplan1, 0, 100, 0.1 ); - PosFrac1->setValue( 0 ); - PosFrac1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - GBplan1Layout->addWidget( PosFrac1, 1, 1 ); - - GBplan2 = new QGroupBox( tr( "Second plane" ), this, "GBplan2" ); - GBplan2->setColumnLayout(0, Qt::Vertical ); - GBplan2->layout()->setSpacing( 0 ); - GBplan2->layout()->setMargin( 0 ); - QGridLayout* GBplan2Layout = new QGridLayout( GBplan2->layout() ); - GBplan2Layout->setAlignment( Qt::AlignTop ); - GBplan2Layout->setSpacing( 6 ); - GBplan2Layout->setMargin( 11 ); - - QLabel* LabelPos_5 = new QLabel( tr( "Plane position (value):" ), GBplan2, "LabelPos_5" ); - GBplan2Layout->addWidget( LabelPos_5, 0, 0); - - PosPlan2 = new QAD_SpinBoxDbl( GBplan2, -999.999, 999.999, 0.1 ); - PosPlan2->setValue( 0 ); - PosPlan2->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - GBplan2Layout->addWidget( PosPlan2, 0, 1 ); - - QLabel* LabelPosi_6 = new QLabel( tr( "Plane position (fraction):" ), GBplan2, "LabelPosi_6" ); - GBplan2Layout->addWidget( LabelPosi_6, 1, 0); - - PosFrac2 = new QAD_SpinBoxDbl( GBplan2, 0, 100, 0.1 ); - PosFrac2->setValue( 100 ); - PosFrac2->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - GBplan2Layout->addWidget( PosFrac2, 1, 1 ); - */ + QGroupBox* GBrot = new QGroupBox( tr( "Rotations" ), this, "GBrot" ); GBrot->setColumnLayout(0, Qt::Vertical ); GBrot->layout()->setSpacing( 0 ); @@ -193,23 +114,20 @@ VisuGUI_CutPlanesDlg::VisuGUI_CutPlanesDlg() buttonCancel->setAutoDefault( TRUE ); GroupButtonsLayout->addWidget( buttonCancel, 0, 2 ); + QLabel* aPosLbl = new QLabel(tr( "LBL_POS" ), this); + myPosSpn = new QAD_SpinBoxDbl( this, 0, 1, 0.1 ); + // layouting TopLayout->addMultiCellWidget( SelPlane, 0, 0, 0, 1 ); - // TopLayout->addLayout( CommentLayout, 0, 1 ); TopLayout->addWidget( LabelPosi_3, 1, 0 ); TopLayout->addWidget( nbPlan, 1, 1 ); - //TopLayout->addMultiCellWidget( GBplan1, 2, 2, 0, 1 ); - //TopLayout->addMultiCellWidget( GBplan2, 3, 3, 0, 1 ); TopLayout->addMultiCellWidget( GBrot, 2, 2, 0, 1 ); - TopLayout->addMultiCellWidget( GroupButtons, 3, 3, 0, 1 ); + TopLayout->addWidget(aPosLbl, 3, 0 ); + TopLayout->addWidget(myPosSpn, 3, 1 ); + TopLayout->addMultiCellWidget( GroupButtons, 4, 4, 0, 1 ); // signals and slots connections - connect( SelPlane, SIGNAL( clicked( int ) ), this, SLOT( orientationChanged( int ) ) ); - //connect( PosPlan1, SIGNAL( valueChanged( double ) ), this, SLOT( posChanged( double ) ) ); - //connect( PosPlan2, SIGNAL( valueChanged( double ) ), this, SLOT( posChanged( double ) ) ); - //connect( PosFrac1, SIGNAL( valueChanged( double ) ), this, SLOT( fracChanged( double ) ) ); - //connect( PosFrac2, SIGNAL( valueChanged( double ) ), this, SLOT( fracChanged( double ) ) ); - //connect( nbPlan, SIGNAL( valueChanged( int ) ), this, SLOT( nbPlanChanged( int ) ) ); + connect( SelPlane, SIGNAL( clicked( int )), this, SLOT( orientationChanged( int ) ) ); connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) ); connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); @@ -218,10 +136,8 @@ VisuGUI_CutPlanesDlg::VisuGUI_CutPlanesDlg() X1 = 0; X2 = 0; Y1 = 0; Y2 = 0; Z1 = 0; Z2 = 0; - //nbPold = 0; RBxy->setChecked( true ); orientationChanged( 0 ); - //nbPlanChanged( 1 ); } /*! @@ -236,6 +152,7 @@ void VisuGUI_CutPlanesDlg::initFromPrsObject(VISU::CutPlanes_i* thePrs) { setNbPlanes(thePrs->GetNbPlanes()); setRotation(thePrs->GetRotateX()*180./PI, thePrs->GetRotateY()*180./PI); setPlanePos(thePrs->GetOrientationType()); + myPosSpn->setValue(thePrs->GetDisplacement()); } void VisuGUI_CutPlanesDlg::storeToPrsObject(VISU::CutPlanes_i* thePrs) { @@ -243,6 +160,7 @@ void VisuGUI_CutPlanesDlg::storeToPrsObject(VISU::CutPlanes_i* thePrs) { thePrs->SetRotateX(getRotation1()*PI/180.); thePrs->SetRotateY(getRotation2()*PI/180.); thePrs->SetOrientationType(getOrientaion()); + thePrs->SetDisplacement(myPosSpn->value()); thePrs->Update(); } @@ -254,159 +172,16 @@ void VisuGUI_CutPlanesDlg::orientationChanged( int ) if ( RBxy->isChecked() ) { LabelRot1->setText( tr( "Rotation around X (Y to Z):" ) ); LabelRot2->setText( tr( "Rotation around Y (Z to X):" ) ); - //Comment2_1->setText( QString::number( Z1 ) ); - //Comment2_2->setText( QString::number( Z2 ) ); - //PosPlan1->setMinValue( Z1 ); - //PosPlan1->setMaxValue( Z2 ); - //PosPlan2->setMinValue( Z1 ); - //PosPlan2->setMaxValue( Z2 ); - /* - if( nbPlan->value() == 1 ) { -// PosFrac1->setValue( 50 ); - PosPlan1->setValue( ( Z1 + Z2 ) / 2 ); -// PosFrac2->setValue( 50 ); - PosPlan2->setValue( ( Z1 + Z2 ) / 2 ); - } - else { -// PosFrac1->setValue( 0 ); - //PosPlan1->setValue( Z1 ); -// PosFrac2->setValue(100); - PosPlan2->setValue( Z2 ); - }*/ - } - else if ( RByz->isChecked() ) { + } else if ( RByz->isChecked() ) { LabelRot1->setText( tr( "Rotation around Y (Z to X):" ) ); LabelRot2->setText( tr( "Rotation around Z (X to Y):" ) ); - //Comment2_1->setText( QString::number( X1 ) ); - //Comment2_2->setText( QString::number( X2 ) ); - //PosPlan1->setMinValue( X1 ); - //PosPlan1->setMaxValue( X2 ); - //PosPlan2->setMinValue( X1 ); - //PosPlan2->setMaxValue( X2 ); - /* - if( nbPlan->value() == 1 ) { -// PosFrac1->setValue( 50 ); - PosPlan1->setValue( ( X1 + X2 ) / 2 ); -// PosFrac2->setValue( 50 ); - PosPlan2->setValue( ( X1 + X2 ) / 2 ); - } - else { -// PosFrac1->setValue( 0 ); - PosPlan1->setValue( X1 ); -// PosFrac2->setValue( 100 ); - PosPlan2->setValue( X2 ); - }*/ - } - else { // RBzx->isChecked() - //Comment2_1->setText( QString::number( Y1 ) ); - //Comment2_2->setText( QString::number( Y2 ) ); - //PosPlan1->setMinValue( Y1 ); - //PosPlan1->setMaxValue( Y2 ); - //PosPlan2->setMinValue( Y1 ); - //PosPlan2->setMaxValue( Y2 ); + } else { LabelRot1->setText( tr( "Rotation around Z (X to Y):" ) ); LabelRot2->setText( tr( "Rotation around X (Y to Z):" ) ); - /* - if( (nbPlan->value()) == 1 ) { -// PosFrac1->setValue( 50 ); - PosPlan1->setValue( ( Y1 + Y2 ) / 2 ); -// PosFrac2->setValue( 50 ); - PosPlan2->setValue( ( Y1 + Y2 ) / 2 ); - } - else { -// PosFrac1->setValue( 0 ); - PosPlan1->setValue( Y1 ); -// PosFrac2->setValue( 100 ); - PosPlan2->setValue( Y2 ); - }*/ } } -/*! - Called when nb of planes is changed -*/ -/*void VisuGUI_CutPlanesDlg::nbPlanChanged( int nb ) -{ - int nold = ( nbPold == 0 ? 0 : ( nbPold > 1 ? 2 : 1 ) ); - int nnew = ( nb == 0 ? 0 : ( nb > 1 ? 2 : 1 ) ); - - if( nold != nnew ) - orientationChanged( 0 ); - //GBplan1->setEnabled( nnew != 0 ); - //GBplan2->setEnabled( nnew > 1 && nnew != 0 ); - nbPold = nb; - }*/ -/*! - Called when position ( fraction ) is changed -*/ -/*void VisuGUI_CutPlanesDlg::fracChanged( double value ) -{ - if ( signalsBlocked() ) - return; - QAD_SpinBoxDbl* spin = 0; - double V1, V2; - if ( sender() == PosFrac1 ) - spin = PosPlan1; - if ( sender() == PosFrac2 ) - spin = PosPlan2; - if( RBxy->isChecked() ) { - V1 = Z1; V2 = Z2; - } - else if( RByz->isChecked() ) { - V1 = X1; V2 = X2; - } - else { - V1 = Y1; V2 = Y2; - } - if ( spin ) { - blockSignals( true ); - spin->setValue( V1 + ( V2 - V1 ) * value / 100 ); - blockSignals( false ); - } - }*/ - -/*! - Called when position ( value ) is changed -*/ -/*void VisuGUI_CutPlanesDlg::posChanged( double value ) -{ - if ( signalsBlocked() ) - return; - QAD_SpinBoxDbl* spin = 0; - double V; - if ( sender() == PosPlan1 ) - spin = PosFrac1; - if ( sender() == PosPlan2 ) - spin = PosFrac2; - if( RBxy->isChecked() ) { - if ( value <= Z1 ) - V = 0; - else if ( value >= Z2 ) - V = 100; - else - V = ( value - Z1 ) / ( Z2 - Z1 ) * 100; - } - else if( RByz->isChecked() ) - if ( value <= X1 ) - V = 0; - else if ( value >= X2 ) - V = 100; - else - V = ( value - X1 ) / ( X2 - X1 ) * 100; - else - if ( value <= Y1 ) - V = 0; - else if ( value >= Y2 ) - V = 100; - else - V = ( value - Y1 ) / ( Y2 - Y1 ) * 100; - if ( spin ) { - blockSignals( true ); - spin->setValue( V ); - blockSignals( false ); - } - }*/ /*! Sets bounds ( must be called first ) @@ -449,25 +224,8 @@ void VisuGUI_CutPlanesDlg::setPlanePos( const VISU::CutPlanes::Orientation orie else // zx RBzx->setChecked( true ); orientationChanged( 0 ); - //PosPlan1->setValue( pos1 ); - //PosPlan2->setValue( pos2 ); } -/*! - Sets planes orientation and position ( fraction ) -*/ -/*void VisuGUI_CutPlanesDlg::setPlanePosFrac( const int orient, const double frac1, const double frac2 ) -{ - if ( orient == 1 ) // xy - RBxy->setChecked( true ); - else if ( orient == 2) // yz - RByz->setChecked( true ); - else // zx - RBzx->setChecked( true ); - orientationChanged( 0 ); - PosFrac1->setValue( frac1 ); - PosFrac2->setValue( frac2 ); - }*/ /*! Gets planes orientation @@ -484,21 +242,6 @@ VISU::CutPlanes::Orientation VisuGUI_CutPlanesDlg::getOrientaion() return orient; } -/*! - Gets planes position 1 -*/ -/*double VisuGUI_CutPlanesDlg::getPlanePos1() -{ - return PosPlan1->value(); - }*/ - -/*! - Gets planes position 2 -*/ -/*double VisuGUI_CutPlanesDlg::getPlanePos2() -{ - return PosPlan2->value(); - }*/ /*! Sets planes rotation diff --git a/src/VISUGUI/VisuGUI_CutPlanesDlg.h b/src/VISUGUI/VisuGUI_CutPlanesDlg.h index 16968782..9432108f 100644 --- a/src/VISUGUI/VisuGUI_CutPlanesDlg.h +++ b/src/VISUGUI/VisuGUI_CutPlanesDlg.h @@ -1,9 +1,29 @@ -// File : VisuGUI_CutPlanesDlg.h -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// 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_CutPlanesDlg.h +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ #ifndef VISUGUI_CUTPLANESDLG_H @@ -35,10 +55,7 @@ public: void setNbPlanes( const int nbp ); int getNbPlanes(); void setPlanePos( const VISU::CutPlanes::Orientation orient/*, const double pos1, const double pos2 */); - //void setPlanePosFrac( const int orient, const double frac1, const double frac2 ); VISU::CutPlanes::Orientation getOrientaion(); - //double getPlanePos1(); - //double getPlanePos2(); void setRotation( const double r1, const double r2 ); double getRotation1(); double getRotation2(); @@ -46,39 +63,26 @@ public: void initFromPrsObject(VISU::CutPlanes_i* thePrs); void storeToPrsObject(VISU::CutPlanes_i* thePrs); -protected slots: - private: - //QLabel* Comment2_1; - //QLabel* Comment2_2; QLabel* LabelRot1; QLabel* LabelRot2; QSpinBox* nbPlan; - //QAD_SpinBoxDbl* PosPlan1; - //QAD_SpinBoxDbl* PosFrac1; - //QAD_SpinBoxDbl* PosPlan2; - //QAD_SpinBoxDbl* PosFrac2; QAD_SpinBoxDbl* Rot1; QAD_SpinBoxDbl* Rot2; QRadioButton* RBzx; QRadioButton* RByz; QRadioButton* RBxy; - //QGroupBox* GBplan1; - //QGroupBox* GBplan2; + QAD_SpinBoxDbl* myPosSpn; double X1, X2; double Y1, Y2; double Z1, Z2; - //int nbPold; private slots: void editScalarBar(); void orientationChanged( int ); - //void nbPlanChanged( int ); - //void fracChanged( double ); - //void posChanged( double ); }; #endif // VISUGUI_CUTPLANESDLG_H diff --git a/src/VISUGUI/VisuGUI_InitMeshDlg.cxx b/src/VISUGUI/VisuGUI_InitMeshDlg.cxx index 40bc7979..e2d50eda 100644 --- a/src/VISUGUI/VisuGUI_InitMeshDlg.cxx +++ b/src/VISUGUI/VisuGUI_InitMeshDlg.cxx @@ -1,13 +1,32 @@ -using namespace std; -// File : VisuGUI_InitMeshDlg.cxx -// Created : Mon May 27 10:20:11 2002 -// Author : Nicolas REJNERI - -// Project : SALOME -// Module : Visu -// Copyright : Open CASCADE 2002 +// 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_InitMeshDlg.cxx +// Author : Nicolas REJNERI +// Module : VISU // $Header$ +using namespace std; #include "VisuGUI_InitMeshDlg.h" #include "VisuGUI.h" diff --git a/src/VISUGUI/VisuGUI_InitMeshDlg.h b/src/VISUGUI/VisuGUI_InitMeshDlg.h index bd32536d..a5525828 100644 --- a/src/VISUGUI/VisuGUI_InitMeshDlg.h +++ b/src/VISUGUI/VisuGUI_InitMeshDlg.h @@ -1,10 +1,29 @@ -// File : VisuGUI_InitMeshDlg.h -// Created : Mon May 27 10:23:17 2002 -// Author : Nicolas REJNERI - -// Project : SALOME -// Module : Visu -// Copyright : Open CASCADE 2002 +// 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_InitMeshDlg.h +// Author : Nicolas REJNERI +// Module : VISU // $Header$ #ifndef DIALOGBOX_INIT_MESH_H diff --git a/src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx b/src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx index a5cc4f61..858902f4 100644 --- a/src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx +++ b/src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx @@ -1,16 +1,39 @@ -using namespace std; -// File : VisuGUI_IsoSurfacesDlg.cxx -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// 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_IsoSurfacesDlg.cxx +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ +using namespace std; #include "VisuGUI_IsoSurfacesDlg.h" #include #include "QAD_Application.h" #include "QAD_Desktop.h" +#include +#include "QAD_MessageBox.h" + /*! Constructor @@ -36,16 +59,22 @@ VisuGUI_IsoSurfacesDlg::VisuGUI_IsoSurfacesDlg() QLabel* LabelMin = new QLabel( tr( "Minimum value:" ), TopGroup, "LabelMin" ); TopGroupLayout->addWidget( LabelMin, 0, 0 ); - MinIso = new QAD_SpinBoxDbl( TopGroup, -999.99, 999.99, 0.1 ); + //MinIso = new QAD_SpinBoxDbl( TopGroup, -DBL_MAX, DBL_MAX, 0.1 ); + MinIso = new QLineEdit( TopGroup ); + MinIso->setValidator( new QDoubleValidator(this) ); MinIso->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); MinIso->setMinimumSize( 70, 0 ); + LabelMin->setBuddy(MinIso); TopGroupLayout->addWidget( MinIso, 0, 1 ); QLabel* LabelMax = new QLabel( tr( "Maximum value:" ), TopGroup, "LabelMax" ); TopGroupLayout->addWidget( LabelMax, 1, 0 ); - MaxIso = new QAD_SpinBoxDbl( TopGroup, -999.99, 999.99, 0.1); + //MaxIso = new QAD_SpinBoxDbl( TopGroup, -DBL_MAX, DBL_MAX, 0.1); + MaxIso = new QLineEdit( TopGroup ); + MaxIso->setValidator( new QDoubleValidator(this) ); MaxIso->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); MaxIso->setMinimumSize( 70, 0 ); + LabelMax->setBuddy(MaxIso); TopGroupLayout->addWidget( MaxIso, 1, 1 ); QLabel* LabelNbr = new QLabel( tr( "Number of surfaces:" ), TopGroup, "LabelNbr" ); @@ -91,13 +120,22 @@ VisuGUI_IsoSurfacesDlg::~VisuGUI_IsoSurfacesDlg() void VisuGUI_IsoSurfacesDlg::initFromPrsObject(VISU::IsoSurfaces_i* thePrs) { NbrIso->setValue(thePrs->GetNbSurfaces()); - MinIso->setValue(thePrs->GetRangeMin()); - MaxIso->setValue(thePrs->GetRangeMax()); + MinIso->setText(QString::number(thePrs->GetRangeMin())); + MaxIso->setText(QString::number(thePrs->GetRangeMax())); } void VisuGUI_IsoSurfacesDlg::storeToPrsObject(VISU::IsoSurfaces_i* thePrs) { thePrs->SetNbSurfaces(NbrIso->value()); - thePrs->SetRange(MinIso->value(), MaxIso->value()); + thePrs->SetRange(MinIso->text().toDouble(), MaxIso->text().toDouble()); thePrs->Update(); } + +void VisuGUI_IsoSurfacesDlg::accept() { + if (MinIso->text().toDouble() >= MaxIso->text().toDouble()) + QAD_MessageBox::warn1( this,tr("VISU_WARNING"), + tr("MSG_MINMAX_VALUES"), + tr("VISU_BUT_OK")); + else + QDialog::accept(); +} diff --git a/src/VISUGUI/VisuGUI_IsoSurfacesDlg.h b/src/VISUGUI/VisuGUI_IsoSurfacesDlg.h index 68ca04cd..b6658369 100644 --- a/src/VISUGUI/VisuGUI_IsoSurfacesDlg.h +++ b/src/VISUGUI/VisuGUI_IsoSurfacesDlg.h @@ -1,9 +1,29 @@ -// File : VisuGUI_IsoSurfacesDlg.h -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// 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_IsoSurfacesDlg.h +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ #ifndef VISUGUI_ISOSURFACESDLG_H @@ -14,8 +34,8 @@ #include #include #include -#include "QAD_SpinBoxDbl.h" #include "VISU_PrsObject_i.hh" +#include class VisuGUI_IsoSurfacesDlg : public QDialog @@ -29,9 +49,12 @@ public: void initFromPrsObject(VISU::IsoSurfaces_i* thePrs); void storeToPrsObject(VISU::IsoSurfaces_i* thePrs); +protected slots: + void accept(); + private: - QAD_SpinBoxDbl* MinIso; - QAD_SpinBoxDbl* MaxIso; + QLineEdit* MinIso; + QLineEdit* MaxIso; QSpinBox* NbrIso; }; diff --git a/src/VISUGUI/VisuGUI_MagnitudeDlg.cxx b/src/VISUGUI/VisuGUI_MagnitudeDlg.cxx index d1b60b60..28c0f1af 100644 --- a/src/VISUGUI/VisuGUI_MagnitudeDlg.cxx +++ b/src/VISUGUI/VisuGUI_MagnitudeDlg.cxx @@ -1,12 +1,32 @@ -using namespace std; -// File : VisuGUI_MagnitudeDlg.cxx -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// 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_MagnitudeDlg.cxx +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ +using namespace std; #include "VisuGUI_MagnitudeDlg.h" #include #include "QAD_Application.h" diff --git a/src/VISUGUI/VisuGUI_MagnitudeDlg.h b/src/VISUGUI/VisuGUI_MagnitudeDlg.h index 2ae11299..c1436aea 100644 --- a/src/VISUGUI/VisuGUI_MagnitudeDlg.h +++ b/src/VISUGUI/VisuGUI_MagnitudeDlg.h @@ -1,9 +1,29 @@ -// File : VisuGUI_MagnitudeDlg.h -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// 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_MagnitudeDlg.h +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ #ifndef VISUGUI_MAGNITUDEDLG_H diff --git a/src/VISUGUI/VisuGUI_NonIsometricDlg.cxx b/src/VISUGUI/VisuGUI_NonIsometricDlg.cxx index 8cf133c2..df3f1c27 100644 --- a/src/VISUGUI/VisuGUI_NonIsometricDlg.cxx +++ b/src/VISUGUI/VisuGUI_NonIsometricDlg.cxx @@ -1,35 +1,33 @@ -using namespace std; -// File : SALOMEGUI_NonIsometricDlg.cxx -// Created : Thu Dec 18 12:01:00 2002 -// Author : Vasily Rusyaev -// Project : SALOME PRO -// Module : SALOMEGUI -// Copyright : Open CASCADE +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : SALOMEGUI_NonIsometricDlg.cxx +// Author : Vasily Rusyaev +// Module : VISU // $Header$ +using namespace std; #include "VisuGUI_NonIsometricDlg.h" #include #include #include -#include -#include #include -#include -//#include - #include "QAD_SpinBoxDbl.h" -#include "utilities.h" - #include "QAD_Application.h" #include "QAD_Desktop.h" #include "QAD_StudyFrame.h" #include "QAD_RightFrame.h" #include "VTKViewer_ViewFrame.h" #include "VISU_Actor.h" +#include "utilities.h" -#include -#include +#include "SALOME_Selection.h" +#include "SALOME_ListIteratorOfListIO.hxx" +#include "SALOME_ListIO.hxx" /*! Constructor @@ -39,190 +37,99 @@ VisuGUI_NonIsometricDlg::VisuGUI_NonIsometricDlg( QWidget* parent, const char* n { QAD_StudyFrame* sf = QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame(); - VTKViewer_NonIsometricTransform *aTransform = NULL; - if ( sf->getTypeView() == VIEW_VTK ) - { - VTKViewer_ViewFrame* vf = (VTKViewer_ViewFrame*) ( sf->getRightFrame()->getViewFrame() ); - aTransform = vf->getNonIsometricTransform(); - } - - if ( !name ) - setName( "NonIsometricDlg" ); - setCaption( tr( "Scaling" ) ); - setSizeGripEnabled( TRUE ); - - // Create layout for this dialog - QGridLayout* layoutDlg = new QGridLayout( this ); - layoutDlg->setSpacing(6); - layoutDlg->setMargin(11); - - // Create croup box with grid layout - QGroupBox* GroupBox = new QGroupBox( this, "GroupBox" ); - - QGridLayout* glGroupBox = new QGridLayout( GroupBox ); - glGroupBox->setMargin(11); - glGroupBox->setSpacing(6); - - //Create font: 14pnts, bold, italic - //It will be used for all labels in this group box - QFont m_font14bi = font(); - m_font14bi.setPointSize((int)(m_font14bi.pointSize()*1.4)); -// m_font14bi.setItalic( TRUE ); - m_font14bi.setBold( TRUE ); - - // Create "Choose function" label - QLabel* TextLabel1 = new QLabel( tr( "Choose function:" ), GroupBox, "TextLabel1" ); - glGroupBox->addWidget ( TextLabel1, 1, 0 ); - - // Create "Type the coefficient" label - QLabel* TextLabel2 = new QLabel( tr( "Coefficient:" ), GroupBox, "TextLabel2" ); - glGroupBox->addWidget ( TextLabel2, 2, 0 ); - - // Create "Applying function" label - QLabel* TextLabel3 = new QLabel( tr( "Applying function:" ), GroupBox, "TextLabel3" ); - glGroupBox->addWidget ( TextLabel3, 3, 0 ); - - glGroupBox->addColSpacing ( 1, 10 ); - - // Create "X" label - QLabel* TextLabelX = new QLabel( "X", GroupBox, "TextLabelX" ); - TextLabelX->setAlignment( int( QLabel::AlignCenter ) ); - TextLabelX->setFont( m_font14bi ); - glGroupBox->addWidget ( TextLabelX, 0, 2 ); - - // Create combobox for selecting scaling function on a X axis - m_cbXfunction = new QComboBox( FALSE, GroupBox, "m_cbXFunction"); - m_cbXfunction->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); - m_cbXfunction->setMinimumWidth( 80 ); - glGroupBox->addWidget(m_cbXfunction, 1, 2 ); - - // Create double spinbox for changing coef. in the scaling function on a X axis - m_sbXcoeff = new QAD_SpinBoxDbl( GroupBox, "m_sbXcoeff" ); - m_sbXcoeff->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); - m_sbXcoeff->setMinimumWidth( 80 ); - glGroupBox->addWidget(m_sbXcoeff, 2, 2 ); - - // Create informative label about the applying scaling function on a X axis - m_lXFunction = new QLabel( GroupBox, "m_lXFunction" ); - m_lXFunction->setFont( m_font14bi ); - m_lXFunction->setAlignment( int( QLabel::AlignCenter ) ); - glGroupBox->addWidget(m_lXFunction, 3, 2 ); - - FillComboBox( m_cbXfunction ); - - // Create "Y" label - QLabel* TextLabelY = new QLabel( "Y", GroupBox, "TextLabelY" ); - TextLabelY->setAlignment( int( QLabel::AlignCenter ) ); - TextLabelY->setFont( m_font14bi ); - glGroupBox->addWidget ( TextLabelY, 0, 3 ); - - // Create combobox for selecting scaling function on a Y axis - m_cbYfunction = new QComboBox( FALSE, GroupBox, "m_cbYFunction"); - m_cbYfunction->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); - m_cbYfunction->setMinimumWidth( 80 ); - glGroupBox->addWidget(m_cbYfunction, 1, 3 ); - - // Create double spinbox for changing coef. in the scaling function on a Y axis - m_sbYcoeff = new QAD_SpinBoxDbl( GroupBox, "m_sbYcoeff" ); - m_sbYcoeff->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); - m_sbYcoeff->setMinimumWidth( 80 ); - glGroupBox->addWidget(m_sbYcoeff, 2, 3 ); - - // Create informative label about the applying scaling function on a Y axis - m_lYFunction = new QLabel( GroupBox, "m_lYFunction" ); - m_lYFunction->setAlignment( int( QLabel::AlignCenter ) ); - m_lYFunction->setFont( m_font14bi ); - glGroupBox->addWidget(m_lYFunction, 3, 3 ); - - FillComboBox( m_cbYfunction ); - - // Create "Z" label - QLabel* TextLabelZ = new QLabel( "Z", GroupBox, "TextLabelZ" ); - TextLabelZ->setAlignment( int( QLabel::AlignCenter ) ); - TextLabelZ->setFont( m_font14bi ); - glGroupBox->addWidget ( TextLabelZ, 0, 4 ); - - // Create combobox for selecting scaling function on a Z axis - m_cbZfunction = new QComboBox( FALSE, GroupBox, "m_cbZFunction"); - m_cbZfunction->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); - m_cbZfunction->setMinimumWidth( 80 ); - glGroupBox->addWidget(m_cbZfunction, 1, 4 ); - - // Create double spinbox for changing coef. in the scaling function on a Z axis - m_sbZcoeff = new QAD_SpinBoxDbl( GroupBox, "m_sbZcoeff" ); - m_sbZcoeff->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); - m_sbZcoeff->setMinimumWidth( 80 ); - glGroupBox->addWidget(m_sbZcoeff, 2, 4 ); - - // Create informative label about the applying scaling function on a Z axis - m_lZFunction = new QLabel( GroupBox, "m_lZFunction" ); - m_lZFunction->setAlignment( int( QLabel::AlignCenter ) ); - m_lZFunction->setFont( m_font14bi ); - glGroupBox->addWidget(m_lZFunction, 3, 4 ); - - FillComboBox( m_cbZfunction ); - - if ( aTransform ) { - int item = aTransform->GetFunctionType(AxisFunction::XAxis); - m_cbXfunction->setCurrentItem(item); - if (item) { - m_sbXcoeff ->setEnabled (TRUE); - FunctionChanged( m_cbXfunction); - } - item = aTransform->GetFunctionType(AxisFunction::YAxis); - m_cbYfunction->setCurrentItem(item); - if (item) { - m_sbYcoeff ->setEnabled (TRUE); - FunctionChanged( m_cbYfunction ); - } - item = aTransform->GetFunctionType(AxisFunction::ZAxis); - m_cbZfunction->setCurrentItem(item); - if (item) { - m_sbZcoeff ->setEnabled (TRUE); - FunctionChanged( m_cbZfunction); - } - m_sbXcoeff -> setValue(aTransform->GetCoeff(AxisFunction::XAxis)); - m_sbYcoeff -> setValue(aTransform->GetCoeff(AxisFunction::YAxis)); - m_sbZcoeff -> setValue(aTransform->GetCoeff(AxisFunction::ZAxis)); - } - - // Create button - QPushButton* m_bReset = new QPushButton( tr( "&Reset" ), GroupBox, "m_bReset" ); - glGroupBox->addWidget( m_bReset, 4, 4 ); - - layoutDlg->addWidget(GroupBox,0,0); - - // OK, CANCEL, Apply button - QGroupBox* aWgt = new QGroupBox( this ); - QHBoxLayout* aHBoxLayout = new QHBoxLayout( aWgt ); - aHBoxLayout->setMargin(11); - aHBoxLayout->setSpacing(6); - - // Create button - QPushButton* m_bOk = new QPushButton( tr( "O&K" ), aWgt, "m_bOk" ); - m_bOk->setDefault( TRUE ); - m_bOk->setAutoDefault( TRUE ); - aHBoxLayout->addWidget( m_bOk ); - aHBoxLayout->addStretch(); - - // Create button - QPushButton* m_bApply = new QPushButton( tr( "&Apply" ), aWgt, "m_bApply" ); - m_bApply->setAutoDefault( TRUE ); - aHBoxLayout->addWidget( m_bApply ); - aHBoxLayout->addStretch(); + VTKViewer_ViewFrame* aViewFrame = dynamic_cast(sf->getRightFrame()->getViewFrame()); - // Create button - QPushButton* m_bCancel = new QPushButton( tr( "&Cancel" ), aWgt, "m_bCancel" ); - m_bCancel->setAutoDefault( TRUE ); - aHBoxLayout->addWidget( m_bCancel ); - - layoutDlg->addWidget(aWgt,1,0); - - // signals and slots connections - connect( m_bCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); - connect( m_bOk, SIGNAL( clicked() ), this, SLOT( onClickOk( ) ) ); - connect( m_bApply, SIGNAL( clicked() ), this, SLOT( onClickApply( ) ) ); - connect( m_bReset, SIGNAL( clicked() ), this, SLOT( onClickReset( ) ) ); + if ( !name ) + setName( "NonIsometricDlg" ); + setCaption( tr( "Scaling" ) ); + setSizeGripEnabled( TRUE ); + + // Create layout for this dialog + QGridLayout* layoutDlg = new QGridLayout( this ); + layoutDlg->setSpacing(6); + layoutDlg->setMargin(11); + + // Create croup box with grid layout + QGroupBox* GroupBox = new QGroupBox( this, "GroupBox" ); + QGridLayout* glGroupBox = new QGridLayout( GroupBox ); + glGroupBox->setMargin(11); + glGroupBox->setSpacing(6); + + // "X" scaling + QLabel* TextLabelX = new QLabel( "X: ", GroupBox, "TextLabelX" ); + m_sbXcoeff = new QAD_SpinBoxDbl( GroupBox, -DBL_MAX, DBL_MAX, 0.1 ); +//m_sbXcoeff->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); + m_sbXcoeff->setMinimumWidth( 80 ); + m_sbXcoeff->setValue( 1.0 ); + + // "Y" scaling + QLabel* TextLabelY = new QLabel( "Y", GroupBox, "TextLabelY" ); + m_sbYcoeff = new QAD_SpinBoxDbl( GroupBox, -DBL_MAX, DBL_MAX, 0.1 ); +//m_sbYcoeff->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); + m_sbYcoeff->setMinimumWidth( 80 ); + m_sbYcoeff->setValue( 1.0 ); + + // "Z" scaling + QLabel* TextLabelZ = new QLabel( "Z", GroupBox, "TextLabelZ" ); + m_sbZcoeff = new QAD_SpinBoxDbl( GroupBox, -DBL_MAX, DBL_MAX, 0.1 ); +//m_sbZcoeff->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Fixed)); + m_sbZcoeff->setMinimumWidth( 80 ); + m_sbZcoeff->setValue( 1.0 ); + + // Get initial values from the current VTK viewer + if ( aViewFrame ) { + double aScaleFactor[3]; + aViewFrame->GetScale(aScaleFactor); + m_sbXcoeff -> setValue(aScaleFactor[0]); + m_sbYcoeff -> setValue(aScaleFactor[1]); + m_sbZcoeff -> setValue(aScaleFactor[2]); + } + + // Create button + m_bReset = new QPushButton( tr( "&Reset" ), GroupBox, "m_bReset" ); + + // Layout widgets in the group box + glGroupBox->addWidget( TextLabelX, 0, 0 ); + glGroupBox->addWidget( m_sbXcoeff, 0, 1 ); + glGroupBox->addWidget( TextLabelY, 0, 2 ); + glGroupBox->addWidget( m_sbYcoeff, 0, 3 ); + glGroupBox->addWidget( TextLabelZ, 0, 4 ); + glGroupBox->addWidget( m_sbZcoeff, 0, 5 ); + glGroupBox->addWidget( m_bReset, 0, 6 ); + + // OK, CANCEL, Apply button + QGroupBox* aWgt = new QGroupBox( this ); + QHBoxLayout* aHBoxLayout = new QHBoxLayout( aWgt ); + aHBoxLayout->setMargin(11); + aHBoxLayout->setSpacing(6); + // Create button + QPushButton* m_bOk = new QPushButton( tr( "O&K" ), aWgt, "m_bOk" ); + m_bOk->setDefault( TRUE ); + m_bOk->setAutoDefault( TRUE ); + // Create button + QPushButton* m_bApply = new QPushButton( tr( "&Apply" ), aWgt, "m_bApply" ); + m_bApply->setAutoDefault( TRUE ); + // Create button + QPushButton* m_bCancel = new QPushButton( tr( "&Cancel" ), aWgt, "m_bCancel" ); + m_bCancel->setAutoDefault( TRUE ); + + // Layout buttons + aHBoxLayout->addWidget( m_bOk ); + aHBoxLayout->addWidget( m_bApply ); + aHBoxLayout->addStretch(); + aHBoxLayout->addWidget( m_bCancel ); + + // Layout top level widgets + layoutDlg->addWidget(GroupBox,0,0); + layoutDlg->addWidget(aWgt,1,0); + + // signals and slots connections + connect( m_bCancel, SIGNAL( clicked() ), this, SLOT( reject() ) ); + connect( m_bOk, SIGNAL( clicked() ), this, SLOT( onClickOk( ) ) ); + connect( m_bApply, SIGNAL( clicked() ), this, SLOT( onClickApply( ) ) ); + connect( m_bReset, SIGNAL( clicked() ), this, SLOT( onClickReset( ) ) ); + + this->resize( 100, this->sizeHint().height() ); } /* @@ -241,224 +148,27 @@ void VisuGUI_NonIsometricDlg::onClickOk() accept(); } -void VisuGUI_NonIsometricDlg::onClickApply() -{ - bool changed = false; +void VisuGUI_NonIsometricDlg::onClickApply(){ QAD_StudyFrame* sf = QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame(); - if ( sf->getTypeView() == VIEW_VTK ) - { - int Xfunction = m_cbXfunction->currentItem(); - int Yfunction = m_cbYfunction->currentItem(); - int Zfunction = m_cbZfunction->currentItem(); - - - VTKViewer_ViewFrame* vf = (VTKViewer_ViewFrame*) ( sf->getRightFrame()->getViewFrame() ); - VTKViewer_NonIsometricTransform *aTransform = vf->getNonIsometricTransform(); - - vtkRenderer* Renderer = vf->getRenderer(); - vtkActorCollection* theActors = Renderer->GetActors(); - theActors->InitTraversal(); - vtkActor *actor = theActors->GetNextActor(); - - aTransform->SetFunction( AxisFunction::XAxis, - (VTKViewer_NonIsometricTransform::Function) Xfunction, - m_sbXcoeff->value() ); - - aTransform->SetFunction( AxisFunction::YAxis, - (VTKViewer_NonIsometricTransform::Function) Yfunction, - m_sbYcoeff->value() ); - - aTransform->SetFunction( AxisFunction::ZAxis, - (VTKViewer_NonIsometricTransform::Function) Zfunction, - m_sbZcoeff->value() ); + SALOME_Selection* Sel = SALOME_Selection::Selection( sf->getStudy()->getSelection() ); - while( actor ) - { - //SALOME_Actor* pSA = dynamic_cast (actor); - SALOME_Actor* pSA = dynamic_cast (actor); - if (pSA) - { - //MESSAGE (actor->GetMapper()->GetClassName ()) - vtkPolyDataMapper* mapper = NULL; - vtkMapper* initialMapper = pSA->GetInitialMapper(); - if ( initialMapper == NULL ) - initialMapper = actor->GetMapper(); - if ( initialMapper->IsA("vtkDataSetMapper") ) - mapper = vtkDataSetMapper::SafeDownCast( initialMapper )->GetPolyDataMapper (); - else - mapper = vtkPolyDataMapper::SafeDownCast( initialMapper ); - //MESSAGE (mapper->GetClassName ()) - if (mapper) - { - //create transformation + if( VTKViewer_ViewFrame* vf = dynamic_cast(sf->getRightFrame()->getViewFrame())){ + double aScale[3] = {m_sbXcoeff->value(), m_sbYcoeff->value(), m_sbZcoeff->value()}; + vf->SetScale(aScale); + } - //create Filter - vtkTransformPolyDataFilter *aTransformFilter = vtkTransformPolyDataFilter::New(); - aTransformFilter->SetInput ( mapper->GetInput() ); - aTransformFilter->SetTransform (aTransform); - - //create new mapper - vtkDataSetMapper *aMapper = vtkDataSetMapper::New(); - aMapper->SetInput (aTransformFilter->GetOutput()); - aMapper->ShallowCopy ( actor->GetMapper()); - - //set new mapper - actor->SetMapper (aMapper); - - aTransformFilter->Delete(); - aMapper->Delete(); - changed = true; - } - } - actor = theActors->GetNextActor(); - } - if (changed) - vf->Repaint(); - //in order to improve perfomance - if ( !Xfunction && !Yfunction && !Zfunction ) - vf->setNonIsometricTransform( NULL ); - } + SALOME_ListIteratorOfListIO Itinit( Sel->StoredIObjects() ); + for (; Itinit.More(); Itinit.Next()) { + sf->getStudy()->highlight(Itinit.Value(), true); + } } void VisuGUI_NonIsometricDlg::onClickReset() { - //it's workaround for QComboBox - it doesn't send activated signal using setCurrentItem function - //therefore we connect on highlighted signal, use setCurrentItem() and disconnect highlighted signal - - connect (m_cbXfunction, SIGNAL( highlighted ( const QString& ) ), this, SLOT( onFunctionChanged ( ) ) ); - - m_cbXfunction->setCurrentItem ( 0 ); - m_cbXfunction->disconnect( SIGNAL( highlighted ( const QString& ) ) ); - - connect (m_cbYfunction, SIGNAL( highlighted ( const QString& ) ), this, SLOT( onFunctionChanged ( ) ) ); - m_cbYfunction->setCurrentItem ( 0 ); - m_cbYfunction->disconnect( SIGNAL( highlighted ( const QString& ) ) ); - - connect (m_cbZfunction, SIGNAL( highlighted ( const QString& ) ), this, SLOT( onFunctionChanged ( ) ) ); - m_cbZfunction->setCurrentItem ( 0 ); - m_cbZfunction->disconnect( SIGNAL( highlighted ( const QString& ) ) ); -} - -//Populates combobox and makes all needed connects -void VisuGUI_NonIsometricDlg::FillComboBox(QComboBox* cb) -{ - cb->insertItem( tr ("None") ); - cb->insertItem ( tr ("Linear") ); -// cb->insertItem ( tr ("Logarithmic") ); - - - connect (cb, SIGNAL( activated ( const QString& ) ), this, SLOT( onFunctionChanged ( ) ) ); - - //it's workaround for QComboBox - it doesn't send activated signal using setCurrentItem function - //therefore we connect on highlighted signal, use setCurrentItem() and disconnect highlighted signal - cb->setCurrentItem ( 1 ); - connect (cb, SIGNAL( highlighted ( const QString& ) ), this, SLOT( onFunctionChanged ( ) ) ); - cb->setCurrentItem ( 0 ); - cb->disconnect( SIGNAL( highlighted ( const QString& ) ) ); - + m_bReset->setFocus(); + m_sbXcoeff->setValue( 1.0 ); + m_sbYcoeff->setValue( 1.0 ); + m_sbZcoeff->setValue( 1.0 ); } -void VisuGUI_NonIsometricDlg::onFunctionChanged() -{ - //TODO - const QComboBox* cbFunction = (const QComboBox* ) sender(); - FunctionChanged(cbFunction); -} - -void VisuGUI_NonIsometricDlg::FunctionChanged(const QComboBox* cbFunction ) -{ - //TODO - const QString & function = cbFunction-> currentText(); - QAD_SpinBoxDbl* sbCoeff; - QLabel* lFunction; - QString axis; - QString formula; - //this variable stores index in bounds array for vtkRenderer - // 0 - xmin, xmax - // 2 - ymin, ymax - // 4 - zmin, zmax - int boundIndex; - - if (cbFunction == m_cbXfunction) - { - sbCoeff = m_sbXcoeff; - lFunction = m_lXFunction; - axis = "x"; - boundIndex = 0; - } - else - if (cbFunction == m_cbYfunction) - { - sbCoeff = m_sbYcoeff; - lFunction = m_lYFunction; - axis = "y"; - boundIndex = 2; - } - else - if (cbFunction == m_cbZfunction) - { - sbCoeff = m_sbZcoeff; - lFunction = m_lZFunction; - axis = "z"; - boundIndex = 4; - } - else - return ; - - sbCoeff->setEnabled (TRUE); - formula = axis; - - if ( function == tr ("None") ) - { - sbCoeff->setMinValue( 1.0 ); - sbCoeff->setMaxValue( 1.0 ); - sbCoeff->setValue( 1.0 ); - sbCoeff->setEnabled ( FALSE ); - formula += QString(" = "); - formula += axis; - lFunction->setText( formula ); - } - else - if ( function == tr ("Linear") ) - { - sbCoeff->setMinValue( -1.7E308 ); - sbCoeff->setMaxValue( 1.7E+308 ); - // sbCoeff->setValue( 1.0 ); - formula += QString(" = k"); - formula += axis; - lFunction->setText( formula ); - } - else - if ( function == tr ("Logarithmic") ) - { - // TODO - QAD_StudyFrame* sf = QAD_Application::getDesktop()->getActiveStudy()->getActiveStudyFrame(); - if ( sf->getTypeView() == VIEW_VTK ) - { - vtkRenderer* Renderer = ((VTKViewer_ViewFrame*)sf->getRightFrame()->getViewFrame())->getRenderer(); - float bounds[6]; - Renderer->ComputeVisiblePropBounds (bounds); - //we use following formula lg (x+a) and x+a >= 1 - //therefore a >= 1-x - double minValue; - if ( bounds[boundIndex] > 0 && bounds[boundIndex+1] > 0 ) - minValue = 1 - bounds[boundIndex+1]; - else - minValue = 1 - bounds[boundIndex]; - MESSAGE ( "Bounds " << bounds[0] << " " << bounds[1] << " " << bounds[2] << " " << bounds[3] << " " << bounds[4] << " " << bounds[5] << " " ) - sbCoeff->setMinValue( minValue ); - sbCoeff->setMaxValue( 1.7E+308 ); - sbCoeff->setValue( minValue ); - formula += QString(" = lg("); - formula += axis; - formula += QString("+a), a >= %1").arg( minValue ); - } - else - { - sbCoeff->setEnabled (FALSE); - formula = ""; - } - lFunction->setText( formula ); - } -} diff --git a/src/VISUGUI/VisuGUI_NonIsometricDlg.h b/src/VISUGUI/VisuGUI_NonIsometricDlg.h index 074b5b3c..1169a5e3 100644 --- a/src/VISUGUI/VisuGUI_NonIsometricDlg.h +++ b/src/VISUGUI/VisuGUI_NonIsometricDlg.h @@ -1,51 +1,40 @@ -// File : VisuGUI_NonIsometricDlg.h -// Created : Thu Dec 18 12:01:00 2002 -// Author : Vasily Rusyaev -// Project : SALOME PRO -// Module : SALOMEGUI -// Copyright : Open CASCADE +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VisuGUI_NonIsometricDlg.h +// Author : Vasily Rusyaev +// Module : VISU // $Header$ #ifndef VisuGUI_NONISOMETRICDLG_H #define VisuGUI_NONISOMETRICDLG_H #include -class QLabel; class QAD_SpinBoxDbl; -class QComboBox; +class QPushButton; class VisuGUI_NonIsometricDlg : public QDialog { Q_OBJECT - public: +public: VisuGUI_NonIsometricDlg( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); ~VisuGUI_NonIsometricDlg(); - private: - - QComboBox* m_cbXfunction; +private: QAD_SpinBoxDbl* m_sbXcoeff; - QLabel* m_lXFunction; - - QComboBox* m_cbYfunction; QAD_SpinBoxDbl* m_sbYcoeff; - QLabel* m_lYFunction; - - QComboBox* m_cbZfunction; QAD_SpinBoxDbl* m_sbZcoeff; - QLabel* m_lZFunction; - - //Populates combobox and makes all needed connects - void FillComboBox(QComboBox* cb); - - void FunctionChanged( const QComboBox* cbox); + QPushButton* m_bReset ; - private slots: - void onClickApply(); - void onClickReset(); - void onClickOk(); - void onFunctionChanged(); +private slots: + void onClickApply(); + void onClickReset(); + void onClickOk(); + void onFunctionChanged(); }; #endif // VisuGUI_NONISOMETRICDLG_H diff --git a/src/VISUGUI/VisuGUI_PartialScaDlg.cxx b/src/VISUGUI/VisuGUI_PartialScaDlg.cxx index e3e8557c..24dc6c65 100644 --- a/src/VISUGUI/VisuGUI_PartialScaDlg.cxx +++ b/src/VISUGUI/VisuGUI_PartialScaDlg.cxx @@ -1,12 +1,32 @@ -using namespace std; -// File : VisuGUI_PartialScaDlg.cxx -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// 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_PartialScaDlg.cxx +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ +using namespace std; #include "VisuGUI_PartialScaDlg.h" #include diff --git a/src/VISUGUI/VisuGUI_PartialScaDlg.h b/src/VISUGUI/VisuGUI_PartialScaDlg.h index b1ec05de..00342e43 100644 --- a/src/VISUGUI/VisuGUI_PartialScaDlg.h +++ b/src/VISUGUI/VisuGUI_PartialScaDlg.h @@ -1,9 +1,29 @@ -// File : VisuGUI_PartialScaDlg.h -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// 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_PartialScaDlg.h +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ #ifndef VISUGUI_PARTIALSCADLG_H diff --git a/src/VISUGUI/VisuGUI_PhaseDlg.cxx b/src/VISUGUI/VisuGUI_PhaseDlg.cxx index 74746811..a677d481 100644 --- a/src/VISUGUI/VisuGUI_PhaseDlg.cxx +++ b/src/VISUGUI/VisuGUI_PhaseDlg.cxx @@ -1,12 +1,32 @@ -using namespace std; -// File : VisuGUI_PhaseDlg.cxx -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// 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_PhaseDlg.cxx +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ +using namespace std; #include "VisuGUI_PhaseDlg.h" #include diff --git a/src/VISUGUI/VisuGUI_PhaseDlg.h b/src/VISUGUI/VisuGUI_PhaseDlg.h index 1a0933c2..428c813e 100644 --- a/src/VISUGUI/VisuGUI_PhaseDlg.h +++ b/src/VISUGUI/VisuGUI_PhaseDlg.h @@ -1,9 +1,29 @@ -// File : VisuGUI_PhaseDlg.h -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// 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_PhaseDlg.h +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ #ifndef VISUGUI_PHASEDLG_H diff --git a/src/VISUGUI/VisuGUI_PhaseMagnitudeDlg.cxx b/src/VISUGUI/VisuGUI_PhaseMagnitudeDlg.cxx index b3d6ece2..dc94dc2e 100644 --- a/src/VISUGUI/VisuGUI_PhaseMagnitudeDlg.cxx +++ b/src/VISUGUI/VisuGUI_PhaseMagnitudeDlg.cxx @@ -1,12 +1,32 @@ -using namespace std; -// File : VisuGUI_PhaseMagnitudeDlg.cxx -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// 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_PhaseMagnitudeDlg.cxx +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ +using namespace std; #include "VisuGUI_PhaseMagnitudeDlg.h" #include diff --git a/src/VISUGUI/VisuGUI_PhaseMagnitudeDlg.h b/src/VISUGUI/VisuGUI_PhaseMagnitudeDlg.h index 0c9baa48..fae0c39d 100644 --- a/src/VISUGUI/VisuGUI_PhaseMagnitudeDlg.h +++ b/src/VISUGUI/VisuGUI_PhaseMagnitudeDlg.h @@ -1,9 +1,29 @@ -// File : VisuGUI_PhaseMagnitudeDlg.h -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// 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_PhaseMagnitudeDlg.h +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ #ifndef VISUGUI_PHASEMAGNITUDEDLG_H diff --git a/src/VISUGUI/VisuGUI_PointsResultsDlg.cxx b/src/VISUGUI/VisuGUI_PointsResultsDlg.cxx index 7231f86f..06bd3ebb 100644 --- a/src/VISUGUI/VisuGUI_PointsResultsDlg.cxx +++ b/src/VISUGUI/VisuGUI_PointsResultsDlg.cxx @@ -1,12 +1,32 @@ -using namespace std; -// File : VisuGUI_PointsResultsDlg.cxx -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// 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_PointsResultsDlg.cxx +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ +using namespace std; #include "VisuGUI_PointsResultsDlg.h" #include diff --git a/src/VISUGUI/VisuGUI_PointsResultsDlg.h b/src/VISUGUI/VisuGUI_PointsResultsDlg.h index 76be17c8..9adc0f80 100644 --- a/src/VISUGUI/VisuGUI_PointsResultsDlg.h +++ b/src/VISUGUI/VisuGUI_PointsResultsDlg.h @@ -1,9 +1,29 @@ -// File : VisuGUI_PointsResultsDlg.h -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// 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_PointsResultsDlg.h +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ #ifndef VISUGUI_POINTSRESULTSDLG_H diff --git a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx index 3b9b32ee..8b6d6408 100644 --- a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx +++ b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx @@ -1,21 +1,41 @@ -using namespace std; -// File : VisuGUI_ScalarBarDlg.cxx -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// 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_ScalarBarDlg.cxx +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ +using namespace std; #include "VisuGUI_ScalarBarDlg.h" #include +#include #include "QAD_Application.h" #include "QAD_Desktop.h" #include "QAD_Config.h" +#include "QAD_MessageBox.h" #include "VISU_Convertor.hxx" - -static double MAXVALUE = 1.0E+300; /*! Constructor */ @@ -28,13 +48,15 @@ VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg(bool SetPref) myVerX = 0.01; myVerY = 0.10; myVerW = 0.10; myVerH = 0.80; myHorX = 0.20; myHorY = 0.01; myHorW = 0.60; myHorH = 0.12; + Imin = 0.0; Imax = 0.0; Fmin = 0.0; Fmax = 0.0; Rmin = 0.0; Rmax = 0.0; + myRangeMode = -1; QVBoxLayout* TopLayout = new QVBoxLayout( this ); TopLayout->setSpacing( 6 ); TopLayout->setMargin( 11 ); // Range ============================================================ - QButtonGroup* RangeGroup = new QButtonGroup( tr( "Scalar range" ), this, "RangeGroup" ); + RangeGroup = new QButtonGroup( tr( "Scalar range" ), this, "RangeGroup" ); RangeGroup->setColumnLayout(0, Qt::Vertical ); RangeGroup->layout()->setSpacing( 0 ); RangeGroup->layout()->setMargin( 0 ); @@ -56,21 +78,23 @@ VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg(bool SetPref) RBFrange = new QRadioButton( tr( "Use field range" ), RangeGroup, "RBFrange" ); RBIrange = new QRadioButton( tr( "Use imposed range" ), RangeGroup, "RBIrange" ); - RBIrange->setChecked( true ); + RBFrange->setChecked( true ); - MinSpin = new QAD_SpinBoxDbl( RangeGroup, -MAXVALUE, MAXVALUE, 0.1 ); - MinSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - MinSpin->setMinimumWidth( 70 ); - MinSpin->setValue( 0 ); + MinEdit = new QLineEdit( RangeGroup, "MinEdit" ); + MinEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + MinEdit->setMinimumWidth( 70 ); + MinEdit->setValidator( new QDoubleValidator(this) ); + MinEdit->setText( "0.0" ); QLabel* MinLabel = new QLabel( tr( "Min:" ), RangeGroup, "MinLabel" ); - MinLabel->setBuddy(MinSpin); + MinLabel->setBuddy(MinEdit); - MaxSpin = new QAD_SpinBoxDbl( RangeGroup, -MAXVALUE, MAXVALUE, 0.1 ); - MaxSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - MaxSpin->setMinimumWidth( 70 ); - MaxSpin->setValue( 0 ); + MaxEdit = new QLineEdit( RangeGroup, "MaxEdit" ); + MaxEdit->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + MaxEdit->setMinimumWidth( 70 ); + MaxEdit->setValidator( new QDoubleValidator(this) ); + MaxEdit->setText( "0.0" ); QLabel* MaxLabel = new QLabel( tr( "Max:" ), RangeGroup, "MaxLabel" ); - MaxLabel->setBuddy(MaxSpin); + MaxLabel->setBuddy(MaxEdit); RangeGroupLayout->addWidget( myModeLbl, 0, 0 ); RangeGroupLayout->addMultiCellWidget( myModeCombo, 0, 0, 1, 3); @@ -78,9 +102,9 @@ VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg(bool SetPref) RangeGroupLayout->addMultiCellWidget( RBFrange, 2, 2, 0, 1); RangeGroupLayout->addMultiCellWidget( RBIrange, 2, 2, 2, 3); RangeGroupLayout->addWidget( MinLabel, 3, 0 ); - RangeGroupLayout->addWidget( MinSpin, 3, 1 ); + RangeGroupLayout->addWidget( MinEdit, 3, 1 ); RangeGroupLayout->addWidget( MaxLabel, 3, 2 ); - RangeGroupLayout->addWidget( MaxSpin, 3, 3 ); + RangeGroupLayout->addWidget( MaxEdit, 3, 3 ); TopLayout->addWidget( RangeGroup ); @@ -95,7 +119,7 @@ VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg(bool SetPref) ColLabGroupLayout->setMargin( 11 ); QLabel* ColorLabel = new QLabel( tr( "Nb. of colors:" ), ColLabGroup, "ColorLabel" ); - ColorSpin = new QSpinBox( 2, 64, 1, ColLabGroup ); + ColorSpin = new QSpinBox( 2, 256, 1, ColLabGroup ); ColorSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); ColorSpin->setMinimumWidth( 70 ); ColorSpin->setValue( 64 ); @@ -361,8 +385,8 @@ void VisuGUI_ScalarBarDlg::storeToResources() { } bool sbRange = RBIrange->isChecked(); - float sbVmin = MinSpin->value(); - float sbVmax = MaxSpin->value(); + float sbVmin = (float)(MinEdit->text().toDouble()); + float sbVmax = (float)(MaxEdit->text().toDouble()); if(sbVmin > sbVmax) { sbVmin=0.; @@ -406,6 +430,9 @@ void VisuGUI_ScalarBarDlg::initFromPrsObject(VISU::ScalarMap_i* thePrs) { default: setLogarithmic(false); } + float aRange[2]; + thePrs->GetFieldRange(aRange); + Rmin = aRange[0]; Rmax = aRange[1]; setRange( thePrs->GetMin(), thePrs->GetMax(), 0.0, 0.0, thePrs->isRangeFixed() ); setScalarBarData( thePrs->GetNbColors(), thePrs->GetLabels() ); @@ -423,15 +450,15 @@ void VisuGUI_ScalarBarDlg::storeToPrsObject(VISU::ScalarMap_i* thePrs) { thePrs->SetPosition(XSpin->value(), YSpin->value()); thePrs->SetSize(WidthSpin->value(), HeightSpin->value()); thePrs->SetOrientation((RBvert->isChecked())? VISU::ScalarMap::VERTICAL : VISU::ScalarMap::HORIZONTAL); - if(isLogarithmic()) - thePrs->SetScaling(VISU::LOGARITHMIC); - else - thePrs->SetScaling(VISU::LINEAR); if (RBFrange->isChecked()) { thePrs->CalculateRange(); } else { - thePrs->SetRange(MinSpin->value(), MaxSpin->value()); + thePrs->SetRange(MinEdit->text().toDouble(), MaxEdit->text().toDouble()); } + if(isLogarithmic()) + thePrs->SetScaling(VISU::LOGARITHMIC); + else + thePrs->SetScaling(VISU::LINEAR); thePrs->SetNbColors(ColorSpin->value()); thePrs->SetLabels(LabelSpin->value()); thePrs->Update(); @@ -465,24 +492,36 @@ void VisuGUI_ScalarBarDlg::changeDefaults( int ) */ void VisuGUI_ScalarBarDlg::changeRange( int ) { + int mode = -1; + if ( RBFrange->isChecked() ) + mode = 0; + if ( RBIrange->isChecked() ) + mode = 1; + if ( myRangeMode == mode ) + return; //MinSpin->setMaxValue( Fmin ); //MaxSpin->setMinValue( Fmax ); if ( RBFrange->isChecked() ) { //MinLabel->setEnabled( false ); - MinSpin->setEnabled( false ); + MinEdit->setEnabled( false ); //MaxLabel->setEnabled( false ); - MaxSpin->setEnabled( false ); - MinSpin->setValue( Fmin ); - MaxSpin->setValue( Fmax ); + MaxEdit->setEnabled( false ); + if ( mode != -1 ) { + Imin = MinEdit->text().toDouble(); + Imax = MaxEdit->text().toDouble(); + } + MinEdit->setText( QString::number( Rmin ) ); + MaxEdit->setText( QString::number( Rmax ) ); } else { //MinLabel->setEnabled( true ); - MinSpin->setEnabled( true ); + MinEdit->setEnabled( true ); //MaxLabel->setEnabled( true ); - MaxSpin->setEnabled( true ); - MinSpin->setValue( Imin ); - MaxSpin->setValue( Imax ); + MaxEdit->setEnabled( true ); + MinEdit->setText( QString::number( Imin ) ); + MaxEdit->setText( QString::number( Imax ) ); } + myRangeMode = mode; } /*! @@ -505,6 +544,15 @@ void VisuGUI_ScalarBarDlg::XYChanged( double ) void VisuGUI_ScalarBarDlg::setRange( double imin, double imax, double fmin, double fmax, bool sbRange ) { Imin = imin; Imax = imax; Fmin = fmin; Fmax = fmax; + if ( RBIrange->isChecked() ) { + MinEdit->setText( QString::number( Imin ) ); + MaxEdit->setText( QString::number( Imax ) ); + } + else { + MinEdit->setText( QString::number( Rmin ) ); + MaxEdit->setText( QString::number( Rmax ) ); + } + myRangeMode = -1; if( sbRange ) RBIrange->setChecked( true ); else @@ -615,7 +663,7 @@ bool VisuGUI_ScalarBarDlg::isIRange() */ double VisuGUI_ScalarBarDlg::getMin() { - return MinSpin->value(); + return MinEdit->text().toDouble(); } /*! @@ -623,7 +671,7 @@ double VisuGUI_ScalarBarDlg::getMin() */ double VisuGUI_ScalarBarDlg::getMax() { - return MaxSpin->value(); + return MaxEdit->text().toDouble(); } /*! @@ -649,3 +697,52 @@ void VisuGUI_ScalarBarDlg::setLogarithmic( bool on ) { CBLog->setChecked( on ); } + +/*! + Called when button is clicked, validates data and closes dialog +*/ +void VisuGUI_ScalarBarDlg::accept() +{ + double minVal = MinEdit->text().toDouble(); + double maxVal = MaxEdit->text().toDouble(); + if ( RBIrange->isChecked() ) { + if (minVal >= maxVal) { + QAD_MessageBox::warn1( this,tr("VISU_WARNING"), + tr("MSG_MINMAX_VALUES"), + tr("VISU_BUT_OK")); + return; + } + } + // check if logarithmic mode is on and check imposed range to not contain negative values + if ( CBLog->isChecked() ) { + if ( RBIrange->isChecked() ) { + if ( (minVal > 0) && (maxVal > 0) ) { + // nothing to do + } + else { + QAD_MessageBox::warn1( this, + tr("VISU_WARNING"), + tr("WRN_LOGARITHMIC_RANGE"), + tr("VISU_BUT_OK")); + return; + } + } + else { + if ( Rmin > 0 && Rmax > 0 ) { + // nothing to do + } + else { + QAD_MessageBox::warn1( this, + tr("VISU_WARNING"), + tr("WRN_LOGARITHMIC_FIELD_RANGE"), + tr("VISU_BUT_OK")); + RBIrange->setChecked(1); + changeRange(1); + //MinEdit->setText( QString::number( Rmin ) ); + //MaxEdit->setText( QString::number( Rmax ) ); + return; + } + } + } + QDialog::accept(); +} diff --git a/src/VISUGUI/VisuGUI_ScalarBarDlg.h b/src/VISUGUI/VisuGUI_ScalarBarDlg.h index ec665bb8..a1706e82 100644 --- a/src/VISUGUI/VisuGUI_ScalarBarDlg.h +++ b/src/VISUGUI/VisuGUI_ScalarBarDlg.h @@ -1,9 +1,29 @@ -// File : VisuGUI_ScalarBarDlg.h -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// 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_ScalarBarDlg.h +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ #ifndef VISUGUI_SCALARBARDLG_H @@ -57,10 +77,11 @@ public: protected: + QButtonGroup* RangeGroup; QRadioButton* RBFrange; QRadioButton* RBIrange; - QAD_SpinBoxDbl* MinSpin; - QAD_SpinBoxDbl* MaxSpin; + QLineEdit* MinEdit; + QLineEdit* MaxEdit; QRadioButton* RBhori; QRadioButton* RBvert; @@ -79,9 +100,13 @@ protected: QLabel* myModeLbl; QComboBox* myModeCombo; - double Imin, Imax, Fmin, Fmax; + double Imin, Imax, Fmin, Fmax, Rmin, Rmax; double myHorX, myHorY, myHorW, myHorH; double myVerX, myVerY, myVerW, myVerH; + int myRangeMode; + +protected slots: + void accept(); private slots: void changeDefaults( int ); diff --git a/src/VISUGUI/VisuGUI_SelVectCompDlg.cxx b/src/VISUGUI/VisuGUI_SelVectCompDlg.cxx index 9644578d..adf9eb69 100644 --- a/src/VISUGUI/VisuGUI_SelVectCompDlg.cxx +++ b/src/VISUGUI/VisuGUI_SelVectCompDlg.cxx @@ -1,12 +1,32 @@ -using namespace std; -// File : VisuGUI_SelVectCompDlg.cxx -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// 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_SelVectCompDlg.cxx +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ +using namespace std; #include "VisuGUI_SelVectCompDlg.h" #include diff --git a/src/VISUGUI/VisuGUI_SelVectCompDlg.h b/src/VISUGUI/VisuGUI_SelVectCompDlg.h index f11ad40d..2f11bed0 100644 --- a/src/VISUGUI/VisuGUI_SelVectCompDlg.h +++ b/src/VISUGUI/VisuGUI_SelVectCompDlg.h @@ -1,9 +1,29 @@ -// File : VisuGUI_SelVectCompDlg.h -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// 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_SelVectCompDlg.h +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ #ifndef VISUGUI_SELVECTCOMPDLG_H diff --git a/src/VISUGUI/VisuGUI_Selection.cxx b/src/VISUGUI/VisuGUI_Selection.cxx index 8e72c078..ff359e22 100644 --- a/src/VISUGUI/VisuGUI_Selection.cxx +++ b/src/VISUGUI/VisuGUI_Selection.cxx @@ -1,175 +1,126 @@ -using namespace std; -// File : VisuGUI_Selection.cxx -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// 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_Selection.cxx +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ +using namespace std; #include "utilities.h" -#include -#include #include "SALOME_ListIteratorOfListIO.hxx" - #include "SALOME_Selection.h" #include "VISU_Actor.h" +#include "VISU_PrsObject_i.hh" + +#include +#include #include -#include -#include -#include #include #include #include -#include -#include -#include -#include -#include #include #include -#include -#include #include "VisuGUI_CellsResultsDlg.h" #include "VisuGUI_PointsResultsDlg.h" #include "VisuGUI_Selection.h" - int mode=0; - int scal=0; - int vect=0; - char Msg[80]=""; - - int id=0; - char Msg_1[150]=""; - char Msg_2[150]=""; - float Coord[3]; - float ScalarValue=0; - float VectorValue[3]; - -int VisuGUI_Selection::PickViewer(QAD_Study *ActiveStudy, int mode) -{ - SALOME_Selection *Sel = SALOME_Selection::Selection(ActiveStudy->getSelection()); - SALOME_ListIteratorOfListIO It(Sel->StoredIObjects()); - for(;It.More();It.Next()) - { - Handle(SALOME_InteractiveObject)IObject = It.Value(); - if (Sel->SelectionMode() == mode ) // Selection MODE - { - if (Sel->HasIndex(IObject)) - { - TColStd_MapOfInteger MapIndex ; - Sel->GetIndex(IObject, MapIndex) ; - TColStd_MapIteratorOfMapOfInteger ite(MapIndex); - for (;ite.More(); ite.Next()) - { - MESSAGE("Cell ID =" << ite.Key()) - return (ite.Key()); - } - } +int PickViewer(QAD_Study *theActiveStudy, int theSelectionMode){ + SALOME_Selection *aSel = SALOME_Selection::Selection(theActiveStudy->getSelection()); + SALOME_ListIteratorOfListIO It(aSel->StoredIObjects()); + for(;It.More(); It.Next()){ + Handle(SALOME_InteractiveObject) IObject = It.Value(); + if (aSel->SelectionMode() == theSelectionMode ){ + if (aSel->HasIndex(IObject)) { + TColStd_MapOfInteger MapIndex ; + aSel->GetIndex(IObject, MapIndex) ; + TColStd_MapIteratorOfMapOfInteger ite(MapIndex); + for(;ite.More(); ite.Next()) + return ite.Key(); } + } } - return (-1); + return -1; } -void VisuGUI_Selection::PickingResults(QAD_Study *ActiveStudy, int mode, VISU_Actor *Actor) -{ - - if ( (mode == SelectionCell) || (mode == SelectionEdge) ) // Cell mode - { - PickingCell(ActiveStudy, Actor); - } - - else if (mode == SelectionPoint) // Point Mode - { - PickingPoint(ActiveStudy, Actor); - } +template void SetMessage(TData* theData, int theId, TDialog* theDialog){ + // Scalar result + QString Msg_1; + if (vtkDataArray *Scalar = theData->GetScalars()){ + float aVal = Scalar->GetTuple1(theId); + Msg_1.sprintf("%6.3g",aVal); + }else + Msg_1.sprintf("NO DATA"); + theDialog->ScalValue->setText( Msg_1.latin1() ); + + // Vector result + QString Msg_2; + if (vtkDataArray *Vector = theData->GetVectors()){ + float *aVal = Vector->GetTuple3(theId); + Msg_2.sprintf("%6.3g; %6.3g; %6.3g",aVal[0],aVal[1],aVal[2]); + }else + Msg_2.sprintf("NO DATA"); + theDialog->VectTxt->setText( Msg_2.latin1() ); } // ============================================================================================ // // PICKING CELL // // ============================================================================================ // -void VisuGUI_Selection::PickingCell(QAD_Study *ActiveStudy, VISU_Actor *Actor) -{ - vtkDataSet *Data ; - vtkScalars *Scalar; - vtkVectors *Vector; - vtkCell *Cell; - vtkIdList *PointList; - vtkCellData *CellData; - vtkPointData *PointData; - vtkPoints *Points = vtkPoints::New(); - float Point_Coord[12][3]; - float CoordCurrent[3]; - int idCurrent; - - mode = SelectionCell; - - vtkActor* anActor = vtkActor::SafeDownCast( Actor ); - id=PickViewer(ActiveStudy,mode); - if (id >= 0) // Cell exist - { - VisuGUI_CellsResultsDlg *ResultsDlg = new VisuGUI_CellsResultsDlg(QAD_Application::getDesktop(), 0, TRUE, 0); - - vtkDataSetMapper *Mapper = (vtkDataSetMapper*) (anActor->GetMapper()); - Mapper->SetInput(anActor->GetMapper()->GetInput()); - Data=Mapper->GetInput(); - Cell=Data->GetCell(id); - CellData=Data->GetCellData(); - int NbOfPoints=Cell->GetNumberOfPoints(); - PointList=Cell->GetPointIds(); - QListViewItem* item = 0; - for(int i=0; iGetId(i); - Data->GetPoint(idCurrent,CoordCurrent); - for (int j=0; j<3; j++) - Point_Coord[i][j]=CoordCurrent[j]; - item = new QListViewItem(ResultsDlg->ListPoints, - item, - QString::number( idCurrent ), - QString::number( Point_Coord[i][0] ), - QString::number( Point_Coord[i][1] ), - QString::number( Point_Coord[i][2] )); - } - - // Scalar result - Scalar=CellData->GetScalars(); - if (Scalar!=NULL) - { - scal = 1; - ScalarValue=Scalar->GetScalar(id); - sprintf(Msg_1,"( %s ) %4f",Actor->FieldName,ScalarValue); - } - else - { - scal = 2; - sprintf(Msg_1,"No scalar on Cell"); - } - - // Vector result - Vector=CellData->GetVectors(); - if (Vector!=NULL) - { - vect = 1; - Vector->GetVector(id,VectorValue); - sprintf(Msg_2,"( %s ) %.4f %.4f %.4f",Actor->FieldName,VectorValue[0],VectorValue[1],VectorValue[2]); - } - else - { - vect = 2; - sprintf(Msg_2,"No Vector on Cell"); - } - - ResultsDlg->IdCell->setText( QString::number( id ) ); - ResultsDlg->NbPoint->setText( QString::number( NbOfPoints ) ); - ResultsDlg->ScalValue->setText( Msg_1 ); - ResultsDlg->VectTxt->setText( Msg_2 ); - ResultsDlg->exec(); - delete ResultsDlg; +void VisuGUI_Selection::PickingCell(QAD_Study *theActiveStudy, vtkDataSet *theDataSet){ + int id = PickViewer(theActiveStudy,SelectionCell); + if(id >= 0){ + VisuGUI_CellsResultsDlg *aResultsDlg = new VisuGUI_CellsResultsDlg(QAD_Application::getDesktop(), 0, TRUE, 0); + vtkCellData *aData = theDataSet->GetCellData(); + vtkCell *aCell = theDataSet->GetCell(id); + + float aPntCoord[12][3]; + int aNbOfPoints = aCell->GetNumberOfPoints(); + vtkIdList *aPointList = aCell->GetPointIds(); + QListViewItem* anItem = NULL; + for(int i = 0; i < aNbOfPoints; i++){ + float aCoord[3]; + int idCurrent = aPointList->GetId(i); + theDataSet->GetPoint(idCurrent,aCoord); + for (int j=0; j<3; j++) + aPntCoord[i][j]=aCoord[j]; + anItem = new QListViewItem(aResultsDlg->ListPoints, + anItem, + QString::number( idCurrent ), + QString::number( aPntCoord[i][0] ), + QString::number( aPntCoord[i][1] ), + QString::number( aPntCoord[i][2] )); + } + + SetMessage(aData,id,aResultsDlg); + + aResultsDlg->IdCell->setText( QString::number( id ) ); + aResultsDlg->NbPoint->setText( QString::number( aNbOfPoints ) ); + aResultsDlg->exec(); + delete aResultsDlg; } } @@ -178,179 +129,29 @@ void VisuGUI_Selection::PickingCell(QAD_Study *ActiveStudy, VISU_Actor *Actor) // PICKING POINT // // ============================================================================================ // -void VisuGUI_Selection::PickingPoint(QAD_Study *ActiveStudy, VISU_Actor *Actor) -{ - vtkDataSet *Data ; - vtkScalars *Scalar; - vtkVectors *Vector; - vtkPointData *PointData; - - mode = SelectionPoint; - - id=PickViewer(ActiveStudy,mode); - if (id >= 0) - { - VisuGUI_PointsResultsDlg *ResultsDlg = new VisuGUI_PointsResultsDlg(QAD_Application::getDesktop(), 0, TRUE, 0); - vtkDataSetMapper *Mapper = (vtkDataSetMapper*) (Actor->GetMapper()); - Data=Mapper->GetInput(); - PointData=Data->GetPointData(); - - Data->GetPoint(id,Coord); - ResultsDlg->CoordX->setText( QString::number( Coord[0] ) ); - ResultsDlg->CoordY->setText( QString::number( Coord[1] ) ); - ResultsDlg->CoordZ->setText( QString::number( Coord[2] ) ); -// ActiveStudy->setMessage(Msg); - - Scalar=PointData->GetScalars(); - if (Scalar!=NULL) - { - scal = 1; - ScalarValue=Scalar->GetScalar(id); - sprintf(Msg_1,"( %s ) %4f",Actor->FieldName,ScalarValue); - } - else - { - scal = 2; - sprintf(Msg_1,"No scalar at Point"); - } -// ActiveStudy->setMessage(Msg_1); - - // Vector result - Vector=PointData->GetVectors(); - if (Vector!=NULL) - { - vect = 1; - Vector->GetVector(id,VectorValue); - sprintf(Msg_2,"( %s ) %.4f %.4f %.4f",Actor->FieldName,VectorValue[0],VectorValue[1],VectorValue[2]); - } - else - { - vect = 2; - sprintf(Msg_2,"No Vector at Point"); - } - ResultsDlg->IdPoint->setText( QString::number(id) ); - ResultsDlg->ScalValue->setText(Msg_1); - ResultsDlg->VectTxt->setText(Msg_2); - ResultsDlg->exec(); - delete ResultsDlg; - -// ActiveStudy->setMessage( Msg_2 ) ; +void VisuGUI_Selection::PickingPoint(QAD_Study *theActiveStudy, vtkDataSet *theDataSet){ + int id = PickViewer(theActiveStudy,SelectionPoint); + if(id >= 0){ + VisuGUI_PointsResultsDlg *aResultsDlg = new VisuGUI_PointsResultsDlg(QAD_Application::getDesktop(), 0, TRUE, 0); + vtkPointData *aData = theDataSet->GetPointData(); + + float Coord[3]; + theDataSet->GetPoint(id,Coord); + aResultsDlg->CoordX->setText( QString::number( Coord[0] ) ); + aResultsDlg->CoordY->setText( QString::number( Coord[1] ) ); + aResultsDlg->CoordZ->setText( QString::number( Coord[2] ) ); + aResultsDlg->IdPoint->setText( QString::number(id) ); + + SetMessage(aData,id,aResultsDlg); + + aResultsDlg->exec(); + delete aResultsDlg; } } -// ============================================================================================ // -// HIGHLIGHT CELL // -// ============================================================================================ // -// -void VisuGUI_Selection::HighlightCell(int idCell, VISU_Actor *Actor, vtkRenderer *ren) -{ - MESSAGE("HighlightCell") - vtkActor *Cell_Actor = vtkActor::New(); - - vtkUnstructuredGrid* Cell_UGrid = vtkUnstructuredGrid::New(); - if ( Actor->GetMapper()->GetInput()->IsA("vtkUnstructuredGrid") ) { - vtkUnstructuredGrid* UGrid = vtkUnstructuredGrid::SafeDownCast( Actor->GetMapper()->GetInput() ); -// if (UGrid != NULL) // LCO 1707 -// { - vtkIdList *ptIds = vtkIdList::New(); ptIds->Allocate(12); - vtkDataSetMapper* Cell_Mapper = vtkDataSetMapper::New(); - - Cell_UGrid->SetPoints( UGrid->GetPoints() ); - UGrid->GetCellPoints( idCell, ptIds ); - Cell_UGrid->InsertNextCell(Actor->GetMapper()->GetInput()->GetCellType( idCell ), ptIds); - - Cell_Mapper->SetInput(Cell_UGrid); - Cell_Actor->SetMapper(Cell_Mapper); - - ren->AddActor( Cell_Actor ); - - Cell_Actor->GetProperty()->SetColor(1,1,0); - Cell_Actor->GetProperty()->SetRepresentationToSurface(); - Cell_Actor->VisibilityOn(); - - ren->Render(); - } // LCO - Cell_Actor->Delete(); -} - -// ============================================================================================ // -// HIGHLIGHT POINT // -// ============================================================================================ // -// -void VisuGUI_Selection::HighlightPoint(int idPoint, int nbPoints, VISU_Actor *Actor, vtkRenderer *ren) -{ - vtkActor *Point_Actor = vtkActor::New(); - - MESSAGE("HighlightPoint") - if ( Actor->GetMapper()->GetInput()->IsA("vtkUnstructuredGrid") ) { - vtkUnstructuredGrid* UGrid = vtkUnstructuredGrid::SafeDownCast( Actor->GetMapper()->GetInput() ); -// if (UGrid != NULL) // LCO 1707 -// { - vtkUnstructuredGrid* Point_UGrid = vtkUnstructuredGrid::New(); - float pts[3]; - - vtkPoints *Points = vtkPoints::New(); - vtkMaskPoints* verts = vtkMaskPoints::New(); - vtkPolyDataMapper* vertMapper = vtkPolyDataMapper::New(); - Points->SetNumberOfPoints(nbPoints); - - UGrid->GetPoint( idPoint, pts) ; - // Points->SetPoint(idPoint, 0., 0., 0. ); - Points->SetPoint(idPoint, pts); - Point_UGrid->SetPoints(Points); - verts->SetInput(Point_UGrid); - verts->SetGenerateVertices(1); - verts->SetOnRatio(1); - vertMapper->SetInput(verts->GetOutput()); - Point_Actor->SetMapper(vertMapper); - ren->AddActor( Point_Actor ); - Point_Actor->GetProperty()->SetColor(1,1,0); - Point_Actor->GetProperty()->SetRepresentationToSurface(); - Point_Actor->VisibilityOn(); - ren->Render(); - } //LCO - Point_Actor->Delete(); +void VisuGUI_Selection::Highlight(QAD_Study *theActiveStudy, const Handle(SALOME_InteractiveObject)& theIO, int theId){ + MESSAGE("HighlightCell"); + SALOME_Selection *aSel = SALOME_Selection::Selection(theActiveStudy->getSelection()); + aSel->AddIObject( theIO, false ); + aSel->AddOrRemoveIndex( theIO, theId, false, true ); } - -// ============================================================================================ // -// Function to return results individual // -// ============================================================================================ // - -int VisuGUI_Selection::getId() -{ - return (id); -} - -char *VisuGUI_Selection::getMsg(int nb) -{ - if (nb==1) - return (Msg_1); - else - return (Msg_2); -} - -float *VisuGUI_Selection::getCoord() -{ - return (Coord); -} - -float VisuGUI_Selection::getScalar() -{ - if (scal == 1) - return (ScalarValue); - else - return (0); -} - -float *VisuGUI_Selection::getVector() -{ - if (vect == 1) - return (VectorValue); - else - return (0); -} - -int VisuGUI_Selection::getMode() -{ - return (mode ); -} diff --git a/src/VISUGUI/VisuGUI_Selection.h b/src/VISUGUI/VisuGUI_Selection.h index c4aeed1b..09e43574 100644 --- a/src/VISUGUI/VisuGUI_Selection.h +++ b/src/VISUGUI/VisuGUI_Selection.h @@ -1,73 +1,49 @@ -// File : VisuGUI_Selection.h -// Created : Wed Apr 03 10:23:06 2002 -// Author : Laurent CORNABE & Hubert ROLLAND -// 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_Selection.h +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ #ifndef VisuGUI_Selection_HeaderFile #define VisuGUI_Selection_HeaderFile -#ifndef _Standard_HeaderFile -#include -#endif - +#include "SALOMEconfig.h" #include "QAD_Desktop.h" -#include -#include - -#include #include "VISU_Actor.h" +#include + #define SelectionPoint 1 #define SelectionEdge 2 #define SelectionCell 3 #define SelectionActor 4 -class VisuGUI_Selection -{ - -public : - -// Methods PUBLIC -// -// - -int PickViewer(QAD_Study *ActiveStudy, int mode); -void PickingResults(QAD_Study *ActiveStudy, int mode, VISU_Actor *Actor); - -void PickingCell(QAD_Study *ActiveStudy, VISU_Actor *Actor); -void PickingPoint(QAD_Study *ActiveStudy, VISU_Actor *Actor); -void HighlightCell(int idCell, VISU_Actor *Actor, vtkRenderer *ren); -void HighlightPoint(int idPoint, int nbPoints, VISU_Actor *Actor, vtkRenderer *ren); - -int getId(); -char *getMsg(int nb); -float *getCoord(); -float getScalar(); -float *getVector(); -int getMode(); - -protected: - - // Methods PROTECTED - // - - - // Fields PROTECTED - // - - -private: - - // Methods PRIVATE - // - - - // Fields PRIVATE - // - +namespace VisuGUI_Selection{ + void PickingCell(QAD_Study *theActiveStudy, vtkDataSet *theDataSet); + void PickingPoint(QAD_Study *theActiveStudy, vtkDataSet *theDataSet); + void Highlight(QAD_Study *theActiveStudy, const Handle(SALOME_InteractiveObject)& theIO, int theId); }; #endif diff --git a/src/VISUGUI/VisuGUI_StreamLinesDlg.cxx b/src/VISUGUI/VisuGUI_StreamLinesDlg.cxx index aaa91c6f..44e46939 100644 --- a/src/VISUGUI/VisuGUI_StreamLinesDlg.cxx +++ b/src/VISUGUI/VisuGUI_StreamLinesDlg.cxx @@ -1,22 +1,29 @@ -// File : VisuGUI_StreamLinesDlg.cxx -// Created : 06 / 03 / 2003 -// Author : Vitaly SMETANNIKOV -// Project : SALOME -// Module : VISUGUI -// Copyright : Open CASCADE - +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VisuGUI_StreamLinesDlg.cxx +// Author : Vitaly SMETANNIKOV +// Module : VISU #include "VisuGUI_StreamLinesDlg.h" +#include #include #include #include #include "QAD_Application.h" #include "QAD_Desktop.h" #include "QAD_Config.h" +#include "VisuGUI.h" +#include "SALOME_Selection.h" + +extern VisuGUI *visuGUI; VisuGUI_StreamLinesDlg::VisuGUI_StreamLinesDlg() - : QDialog( QAD_Application::getDesktop(), "VisuGUI_StreamLinesDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) + : QDialog( QAD_Application::getDesktop(), "VisuGUI_StreamLinesDlg", false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) { setCaption("Stream lines Preferences"); setSizeGripEnabled( TRUE ); @@ -25,40 +32,96 @@ VisuGUI_StreamLinesDlg::VisuGUI_StreamLinesDlg() TopLayout->setSpacing( 6 ); TopLayout->setMargin( 11 ); + // Source box + QGroupBox* aSourceBox = new QGroupBox(tr("Source"), this); + aSourceBox->setColumnLayout(0, Qt::Vertical); + QGridLayout* aSrcLayout = new QGridLayout( aSourceBox->layout() ); + aSrcLayout->setSpacing( 6 ); + aSrcLayout->setMargin( 0 ); + + myUseSrcChk = new QCheckBox(tr("Use source presentation"), aSourceBox); + aSrcLayout->addMultiCellWidget(myUseSrcChk, 0, 0, 0, 1); + + mySrcCombo = new QComboBox(aSourceBox); + mySrcCombo->setEnabled(myUseSrcChk->isChecked()); + + // Find All prs obj + QAD_Study* aActiveStudy = VisuGUI::GetActiveStudy(); + SALOME_Selection* aSel = SALOME_Selection::Selection( aActiveStudy->getSelection() ); + if( aSel->IObjectCount() > 0 ) { + Handle(SALOME_InteractiveObject) aIO = aSel->firstIObject(); + if (aIO->hasEntry()){ + SALOMEDS::SObject_var aSObject = VisuGUI::GetStudyDocument()->FindObjectID(aIO->getEntry()); + SALOMEDS::SComponent_var aComp = aSObject->GetFatherComponent(); + SALOMEDS::ChildIterator_var aIter = VisuGUI::GetStudyDocument()->NewChildIterator( aComp ); + + for (aIter->InitEx(true); aIter->More(); aIter->Next() ) { + SALOMEDS::SObject_var aChildSObj = aIter->Value(); + CORBA::Object_var aChildObject = VISU::SObjectToObject( aChildSObj ); + if(!CORBA::is_nil( aChildObject ) ) { + VISU::Prs3d_var aPrsObj = VISU::Prs3d::_narrow( aChildObject ); + if( !CORBA::is_nil( aPrsObj ) ) { + if (aPrsObj->GetType() != VISU::TSTREAMLINES) { + SALOMEDS::GenericAttribute_var anAttr; + if ( aChildSObj->FindAttribute(anAttr, "AttributeName") ) { + SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr); + mySrcCombo->insertItem(QString(aName->Value())); + myPrsList.append(aPrsObj); + } + } + } + } + } + } + } + + connect(myUseSrcChk, SIGNAL(toggled(bool)), mySrcCombo, SLOT(setEnabled(bool))); + aSrcLayout->addMultiCellWidget(mySrcCombo, 1, 1, 0, 1); + + QLabel* aPercentLbl = new QLabel( tr( "Used points (0..1)" ), aSourceBox); + aSrcLayout->addWidget(aPercentLbl, 2, 0); + + myPntPercent = new QAD_SpinBoxDbl( aSourceBox, 0, 1, 0.1); + aSrcLayout->addWidget(myPntPercent, 2, 1); + + TopLayout->addMultiCellWidget(aSourceBox, 0, 0, 0, 1); + + QLabel* aStepLenLbl = new QLabel( tr( "Step Length" ), this); - TopLayout->addWidget(aStepLenLbl, 0, 0); - myStepLen = new QAD_SpinBoxDbl( this); + TopLayout->addWidget(aStepLenLbl, 1, 0); + myStepLen = new QAD_SpinBoxDbl( this, DBL_MIN, DBL_MAX, 0.1); myStepLen->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - TopLayout->addWidget(myStepLen, 0, 1); + TopLayout->addWidget(myStepLen, 1, 1); QLabel* aIntegStepLenLbl = new QLabel( tr( "Integration Step" ), this); - TopLayout->addWidget(aIntegStepLenLbl, 1, 0); - myIntegStepLen = new QAD_SpinBoxDbl( this); + TopLayout->addWidget(aIntegStepLenLbl, 2, 0); + myIntegStepLen = new QAD_SpinBoxDbl( this, DBL_MIN, DBL_MAX, 0.1); myIntegStepLen->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - TopLayout->addWidget(myIntegStepLen, 1, 1); + TopLayout->addWidget(myIntegStepLen, 2, 1); QLabel* aPropagationLbl = new QLabel( tr( "Propagation Time" ), this); - TopLayout->addWidget(aPropagationLbl, 2, 0); - myPropTime = new QAD_SpinBoxDbl( this, 0, 1000, 10); + TopLayout->addWidget(aPropagationLbl, 3, 0); + myPropTime = new QAD_SpinBoxDbl( this, DBL_MIN, DBL_MAX, 1); myPropTime->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - TopLayout->addWidget(myPropTime, 2, 1); + TopLayout->addWidget(myPropTime, 3, 1); + + connect(myPropTime, SIGNAL(valueChanged(double)), this, SLOT(PropagationTimeChanged(double))); QLabel* aDirLbl = new QLabel( tr( "Direction" ), this); - TopLayout->addWidget(aDirLbl, 3, 0); + TopLayout->addWidget(aDirLbl, 4, 0); myDirCombo = new QComboBox(this); myDirCombo->insertItem("Forward"); myDirCombo->insertItem("Backward"); myDirCombo->insertItem("Both"); - TopLayout->addWidget(myDirCombo, 3, 1); + TopLayout->addWidget(myDirCombo, 4, 1); myUseScalar = new QCheckBox( tr( "Magnitude coloring" ), this, "UseMagn" ); - // TopLayout->addMultiCellWidget(myUseScalar, 4, 4, 0, 1); connect( myUseScalar, SIGNAL( clicked() ), this, SLOT( enableSetColor() ) ); - TopLayout->addWidget(myUseScalar, 4, 0); + TopLayout->addWidget(myUseScalar, 5, 0); SelColor = new QPushButton( tr( "Use Color" ), this, "SelColor" ); connect( SelColor, SIGNAL( clicked() ), this, SLOT( setVColor() ) ); - TopLayout->addWidget( SelColor, 4, 1); + TopLayout->addWidget( SelColor, 5, 1); QGroupBox* aGroupButtons = new QGroupBox( this, "GroupButtons" ); aGroupButtons->setColumnLayout(0, Qt::Vertical ); @@ -81,7 +144,7 @@ VisuGUI_StreamLinesDlg::VisuGUI_StreamLinesDlg() aGroupButtonsLayout->addWidget( aCancelBtn, 0, 2 ); connect( aOkBtn, SIGNAL( clicked() ), this, SLOT( accept() ) ); connect( aCancelBtn, SIGNAL( clicked() ), this, SLOT( reject() ) ); - TopLayout->addMultiCellWidget( aGroupButtons, 5, 5, 0, 1 ); + TopLayout->addMultiCellWidget( aGroupButtons, 6, 6, 0, 1 ); enableSetColor(); } @@ -102,11 +165,30 @@ void VisuGUI_StreamLinesDlg::initFromPrsObject(VISU::StreamLines_i* thePrs) { myDirCombo->setCurrentItem(2); } myUseScalar->setChecked(thePrs->isColored()); + myPntPercent->setValue(thePrs->GetUsedPoints()); - setColor(QColor(thePrs->GetColor()[0]*255, - thePrs->GetColor()[1]*255, - thePrs->GetColor()[2]*255)); + myUseSrcChk->setChecked(false); + QString aSrcEntry = thePrs->GetSourceEntry(); + if (!aSrcEntry.isEmpty()) { + for (int i = 0; i < myPrsList.count(); i++) { + VISU::Prs3d_i* aPrs = dynamic_cast(VISU::GetServant(myPrsList[i])); + if (aSrcEntry == aPrs->GetEntry()) { + myUseSrcChk->setChecked(true); + mySrcCombo->setCurrentItem(i); + break; + } + } + } + + SALOMEDS::Color anOldColor = thePrs->GetColor(); + QColor aColor = QColor(int(255*anOldColor.R),int(255*anOldColor.G),int(255*anOldColor.B)); + setColor(aColor); enableSetColor(); + + myIntegStepLen->setMaxValue(thePrs->GetMaxIntegrationStep()); + myIntegStepLen->setMinValue(thePrs->GetMinIntegrationStep()); + myStepLen->setMaxValue(myPropTime->value()); + myStepLen->setMinValue(myPropTime->value()/10000.); } @@ -126,13 +208,18 @@ void VisuGUI_StreamLinesDlg::storeToPrsObject(VISU::StreamLines_i* thePrs) { thePrs->SetDirection(VISU::StreamLines::BOTH); } thePrs->setColored(myUseScalar->isChecked()); - - float aColor[3]; - aColor[0] = myColor.red()/255.; - aColor[1] = myColor.green()/255.; - aColor[2] = myColor.blue()/255.; - - thePrs->SetColor(aColor); + if(!thePrs->isColored()){ + SALOMEDS::Color aColor; + aColor.R = myColor.red()/255.; + aColor.G = myColor.green()/255.; + aColor.B = myColor.blue()/255.; + thePrs->SetColor(aColor); + } + if (myUseSrcChk->isChecked() && (myPrsList.count() > 0)) { + thePrs->SetSource(myPrsList[mySrcCombo->currentItem()]); + } else + thePrs->SetSource(VISU::Prs3d::_nil()); + thePrs->SetUsedPoints(myPntPercent->value()); } /*! @@ -173,3 +260,8 @@ void VisuGUI_StreamLinesDlg::enableSetColor() SelColor->setEnabled(!myUseScalar->isChecked() ); } +void VisuGUI_StreamLinesDlg::PropagationTimeChanged(double theValue) { + myStepLen->setMaxValue(theValue); + myStepLen->setMinValue(theValue/1000000.); +} + diff --git a/src/VISUGUI/VisuGUI_StreamLinesDlg.h b/src/VISUGUI/VisuGUI_StreamLinesDlg.h index 94a6a1b0..1e1d9788 100644 --- a/src/VISUGUI/VisuGUI_StreamLinesDlg.h +++ b/src/VISUGUI/VisuGUI_StreamLinesDlg.h @@ -1,10 +1,12 @@ -// File : VisuGUI_StreamLinesDlg.h -// Created : 06 / 03 / 2003 -// Author : Vitaly SMETANNIKOV -// Project : SALOME -// Module : VISUGUI -// Copyright : Open CASCADE - +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VisuGUI_StreamLinesDlg.h +// Author : Vitaly SMETANNIKOV +// Module : VISU #ifndef VISUGUI_STREAMLINESDLG_H #define VISUGUI_STREAMLINESDLG_H @@ -28,6 +30,10 @@ public: void setColor( QColor color ); void enableMagnColor( bool enable ); +private slots: + void onSelectionActive(bool theActive); + void PropagationTimeChanged(double theValue); + private: QAD_SpinBoxDbl* myStepLen; QAD_SpinBoxDbl* myIntegStepLen; @@ -36,6 +42,10 @@ private: QCheckBox* myUseScalar; QPushButton* SelColor; QColor myColor; + QCheckBox* myUseSrcChk; + QAD_SpinBoxDbl* myPntPercent; + QComboBox* mySrcCombo; + QValueList myPrsList; private slots: void setVColor(); diff --git a/src/VISUGUI/VisuGUI_SweepPrefDlg.cxx b/src/VISUGUI/VisuGUI_SweepPrefDlg.cxx index afce7cfc..26d08600 100644 --- a/src/VISUGUI/VisuGUI_SweepPrefDlg.cxx +++ b/src/VISUGUI/VisuGUI_SweepPrefDlg.cxx @@ -1,12 +1,32 @@ -using namespace std; -// File : VisuGUI_SweepPrefDlg.cxx -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// 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_SweepPrefDlg.cxx +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ +using namespace std; #include "VisuGUI_SweepPrefDlg.h" #include diff --git a/src/VISUGUI/VisuGUI_SweepPrefDlg.h b/src/VISUGUI/VisuGUI_SweepPrefDlg.h index 5e3c3fd5..d6d5056f 100644 --- a/src/VISUGUI/VisuGUI_SweepPrefDlg.h +++ b/src/VISUGUI/VisuGUI_SweepPrefDlg.h @@ -1,9 +1,29 @@ -// File : VisuGUI_SweepPrefDlg.h -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// 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_SweepPrefDlg.h +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ #ifndef VISUGUI_SWEEPPREFDLG_H diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.cxx b/src/VISUGUI/VisuGUI_TimeAnimation.cxx index edc926a8..2c971c41 100644 --- a/src/VISUGUI/VisuGUI_TimeAnimation.cxx +++ b/src/VISUGUI/VisuGUI_TimeAnimation.cxx @@ -1,10 +1,12 @@ -// File : VisuGUI_TimeAnimation.cxx -// Created : 28 / 03 / 2003 -// Author : Vitaly SMETANNIKOV -// Project : SALOME -// Module : VISUGUI -// Copyright : Open CASCADE - +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VisuGUI_TimeAnimation.cxx +// Author : Vitaly SMETANNIKOV +// Module : VISU #include "VisuGUI_TimeAnimation.h" #include "VisuGUI.h" @@ -17,7 +19,7 @@ #include #include #include - +#include #include "QAD_Application.h" #include "QAD_Desktop.h" @@ -61,9 +63,14 @@ SetupDlg::SetupDlg(QWidget* theParent, VISU_TimeAnimation* theAnimator) QLabel* aMinLbl = new QLabel("From", aRangeGrp); aMinLbl->setEnabled(myUseRangeChk->isChecked()); aRangeLayout->addWidget(aMinLbl, 1, 0); - myMinVal = new QAD_SpinBoxDbl(aRangeGrp, -MAXVALUE, MAXVALUE, 0.1 ); + double aStep = (myAnimator->getMaxTime() - myAnimator->getMinTime())/(theAnimator->getFieldData(0).myNbTimes - 1); + myMinVal = new QAD_SpinBoxDbl(aRangeGrp, myAnimator->getMinTime(), myAnimator->getMaxTime(), aStep ); myMinVal->setEnabled(myUseRangeChk->isChecked()); - myMinVal->setValue( 0 ); + if (myUseRangeChk->isChecked()) + myMinVal->setValue( myAnimator->getMinRange() ); + else + myMinVal->setValue( myAnimator->getMinTime() ); + connect(myMinVal, SIGNAL( valueChanged(double)), this, SLOT( onMinValue(double) )); aRangeLayout->addWidget(myMinVal, 1, 1); @@ -71,9 +78,13 @@ SetupDlg::SetupDlg(QWidget* theParent, VISU_TimeAnimation* theAnimator) QLabel* aMaxLbl = new QLabel("To", aRangeGrp); aMaxLbl->setEnabled(myUseRangeChk->isChecked()); aRangeLayout->addWidget(aMaxLbl, 1, 2); - myMaxVal = new QAD_SpinBoxDbl(aRangeGrp, -MAXVALUE, MAXVALUE, 0.1 ); + myMaxVal = new QAD_SpinBoxDbl(aRangeGrp, myAnimator->getMinTime(), myAnimator->getMaxTime(), aStep ); myMaxVal->setEnabled(myUseRangeChk->isChecked()); - myMaxVal->setValue( 0 ); + if (myUseRangeChk->isChecked()) + myMaxVal->setValue( myAnimator->getMaxRange() ); + else + myMaxVal->setValue( myAnimator->getMaxTime() ); + connect(myMaxVal, SIGNAL( valueChanged(double)), this, SLOT( onMaxValue(double) )); aRangeLayout->addWidget(myMaxVal, 1, 3); @@ -211,7 +222,7 @@ void SetupDlg::onScalarBarDlg() { VisuGUI_ScalarBarDlg* aScalarBarDlg = new VisuGUI_ScalarBarDlg(); aScalarBarDlg->initFromPrsObject(aData.myPrs[0]); if (aScalarBarDlg->exec()) { - for (int i = 0; i < aData.myNbTimes; i++) + for (int i = 0; i < aData.myNbFrames; i++) aScalarBarDlg->storeToPrsObject(aData.myPrs[i]); } } @@ -230,7 +241,7 @@ void SetupDlg::onPreferencesDlg() { VisuGUI_IsoSurfacesDlg* aDlg = new VisuGUI_IsoSurfacesDlg(); aDlg->initFromPrsObject(dynamic_cast(aData.myPrs[0])); if (aDlg->exec()) { - for (int i = 0; i < aData.myNbTimes; i++) + for (int i = 0; i < aData.myNbFrames; i++) aDlg->storeToPrsObject(dynamic_cast(aData.myPrs[i])); } } @@ -240,7 +251,7 @@ void SetupDlg::onPreferencesDlg() { VisuGUI_CutPlanesDlg* aDlg = new VisuGUI_CutPlanesDlg(); aDlg->initFromPrsObject(dynamic_cast(aData.myPrs[0])); if (aDlg->exec()) { - for (int i = 0; i < aData.myNbTimes; i++) + for (int i = 0; i < aData.myNbFrames; i++) aDlg->storeToPrsObject(dynamic_cast(aData.myPrs[i])); } } @@ -250,7 +261,7 @@ void SetupDlg::onPreferencesDlg() { VisuGUI_MagnitudeDlg* aDlg = new VisuGUI_MagnitudeDlg(); aDlg->initFromPrsObject(dynamic_cast(aData.myPrs[0])); if (aDlg->exec()) { - for (int i = 0; i < aData.myNbTimes; i++) + for (int i = 0; i < aData.myNbFrames; i++) aDlg->storeToPrsObject(dynamic_cast(aData.myPrs[i])); } } @@ -260,7 +271,7 @@ void SetupDlg::onPreferencesDlg() { VisuGUI_VectorsDlg* aDlg = new VisuGUI_VectorsDlg(); aDlg->initFromPrsObject(dynamic_cast(aData.myPrs[0])); if (aDlg->exec()) { - for (int i = 0; i < aData.myNbTimes; i++) + for (int i = 0; i < aData.myNbFrames; i++) aDlg->storeToPrsObject(dynamic_cast(aData.myPrs[i])); } } @@ -270,7 +281,7 @@ void SetupDlg::onPreferencesDlg() { VisuGUI_StreamLinesDlg* aDlg = new VisuGUI_StreamLinesDlg(); aDlg->initFromPrsObject(dynamic_cast(aData.myPrs[0])); if (aDlg->exec()) { - for (int i = 0; i < aData.myNbTimes; i++) + for (int i = 0; i < aData.myNbFrames; i++) aDlg->storeToPrsObject(dynamic_cast(aData.myPrs[i])); } } @@ -288,10 +299,23 @@ void SetupDlg::onRangeCheck(bool theCheck) { if (!theCheck) myAnimator->setAnimationRange(0, 0); + else { + // if (myMinVal->value() < myMaxVal->value()) + myAnimator->setAnimationRange(myMinVal->value(), myMaxVal->value()); +// else if (myMinVal->value() > myMaxVal->value()) +// myAnimator->setAnimationRange(myMaxVal->value(), myMinVal->value()); +// else // equal case +// myAnimator->setAnimationRange(0, 0); + } } //************************************************************************ void SetupDlg::onMinValue(double theVal) { + if (theVal > myAnimator->getMaxRange()) { + myMinVal->setValue( myAnimator->getMinTime() ); + myMinVal->setFocus(); + return; + } for (int i = 0; i < myAnimator->getNbFields(); i++) myAnimator->clearData(myAnimator->getFieldData(i)); myAnimator->setAnimationRange(theVal, myAnimator->getMaxRange()); @@ -299,6 +323,11 @@ void SetupDlg::onMinValue(double theVal) { //************************************************************************ void SetupDlg::onMaxValue(double theVal) { + if (theVal < myAnimator->getMinRange()) { + myMaxVal->setValue( myAnimator->getMaxTime() ); + myMaxVal->setFocus(); + return; + } for (int i = 0; i < myAnimator->getNbFields(); i++) myAnimator->clearData(myAnimator->getFieldData(i)); myAnimator->setAnimationRange(myAnimator->getMinRange(), theVal); @@ -418,26 +447,29 @@ VisuGUI_TimeAnimationDlg::VisuGUI_TimeAnimationDlg(SALOMEDS::Study_var theStudy) { setCaption("Animation"); setSizeGripEnabled( TRUE ); - myStudy = theStudy; + isClosing = false; + myAnimator = new VISU_TimeAnimation(theStudy); myAnimator->setSpeed(1); myAnimator->setViewer(VisuGUI::GetVtkViewFrame()); connect( myAnimator, SIGNAL( frameChanged(long, double) ), this, SLOT( onExecution(long, double) ) ); + connect( myAnimator, SIGNAL( stopped() ), + this, SLOT( onStop() ) ); QVBoxLayout* aMainLayout = new QVBoxLayout(this, 7, 6); aMainLayout->setSpacing(5); - QPushButton* aSetupBtn = new QPushButton("Setup Animation...", this); - connect( aSetupBtn, SIGNAL( clicked() ), + mySetupBtn = new QPushButton("Setup Animation...", this); + connect( mySetupBtn, SIGNAL( clicked() ), this, SLOT( onSetupDlg() ) ); - aMainLayout->addWidget(aSetupBtn); + aMainLayout->addWidget(mySetupBtn); - QPushButton* aGenBtn = new QPushButton("Generate frames", this); - connect( aGenBtn, SIGNAL( clicked() ), + myGenBtn = new QPushButton("Generate frames", this); + connect( myGenBtn, SIGNAL( clicked() ), this, SLOT( createFrames() ) ); - aMainLayout->addWidget(aGenBtn); + aMainLayout->addWidget(myGenBtn); myPlayFrame = new QFrame(this); myPlayFrame->setFrameStyle(QFrame::WinPanel | QFrame::Sunken); @@ -510,32 +542,47 @@ VisuGUI_TimeAnimationDlg::VisuGUI_TimeAnimationDlg(SALOMEDS::Study_var theStudy) this, SLOT(onSpeedChange(double)) ); TopLayout->addMultiCellWidget(aWheel, 1, 3, 3, 3, Qt::AlignRight); + QCheckBox* aCycleCheck = new QCheckBox("Cycled animation",myPlayFrame); + aCycleCheck->setChecked(myAnimator->isCycling()); + connect(aCycleCheck, SIGNAL(toggled(bool)), myAnimator, SLOT(setCyclingSlot(bool))); + TopLayout->addMultiCellWidget(aCycleCheck, 5, 5, 0, 3); + QCheckBox* aPropCheck = new QCheckBox("Use proportional timing",myPlayFrame); aPropCheck->setChecked(myAnimator->isProportional()); - connect(aPropCheck, SIGNAL(toggled(bool)), myAnimator, SLOT(setProportional(bool))); - TopLayout->addMultiCellWidget(aPropCheck, 5, 5, 0, 3); + connect(aPropCheck, SIGNAL(toggled(bool)), myAnimator, SLOT(setProportionalSlot(bool))); + TopLayout->addMultiCellWidget(aPropCheck, 6, 6, 0, 3); - mySaveCheck = new QCheckBox("Save pictures to directory",myPlayFrame); - mySaveCheck->setChecked(false); - TopLayout->addMultiCellWidget(mySaveCheck, 6, 6, 0, 3); + QGroupBox* aSaveBox = new QGroupBox( "Saving", myPlayFrame ); + aSaveBox->setColumnLayout(0, Qt::Horizontal ); + QGridLayout* aSaveLay = new QGridLayout(aSaveBox->layout()); + aSaveLay->setSpacing( 5 ); + aSaveLay->setMargin( 5 ); + + mySaveCheck = new QCheckBox("Save pictures to directory", aSaveBox); + aSaveLay->addMultiCellWidget(mySaveCheck, 0, 0, 0, 2); - QLabel* aPathLbl = new QLabel("Path:", myPlayFrame); + QLabel* aPathLbl = new QLabel("Path:", aSaveBox); aPathLbl->setEnabled(false); connect(mySaveCheck, SIGNAL( toggled(bool)), aPathLbl, SLOT( setEnabled(bool) )); - TopLayout->addWidget(aPathLbl, 7, 0); + aSaveLay->addWidget(aPathLbl, 1, 0); - myPathEdit = new QLineEdit(myPlayFrame); + myPathEdit = new QLineEdit(aSaveBox); + myPathEdit->setEnabled(false); connect(mySaveCheck, SIGNAL( toggled(bool)), myPathEdit, SLOT( setEnabled(bool) )); - TopLayout->addMultiCellWidget(myPathEdit, 7, 7, 1, 2); + aSaveLay->addWidget(myPathEdit, 1, 1); - QPushButton* aBrowseBtn = new QPushButton("Browse...", myPlayFrame); + QPushButton* aBrowseBtn = new QPushButton("Browse...", aSaveBox); + aBrowseBtn->setEnabled(false); connect(mySaveCheck, SIGNAL( toggled(bool)), aBrowseBtn, SLOT( setEnabled(bool) )); connect(aBrowseBtn, SIGNAL( clicked()), this, SLOT( onBrowse() )); - TopLayout->addWidget(aBrowseBtn, 7, 3); + mySaveCheck->setChecked(false); + aSaveLay->addWidget(aBrowseBtn, 1, 2); + + TopLayout->addMultiCellWidget(aSaveBox, 7, 7, 0, 3); aMainLayout->addWidget(myPlayFrame); @@ -554,9 +601,7 @@ VisuGUI_TimeAnimationDlg::VisuGUI_TimeAnimationDlg(SALOMEDS::Study_var theStudy) //************************************************************************ VisuGUI_TimeAnimationDlg::~VisuGUI_TimeAnimationDlg() { - VTKViewer_ViewFrame* aView = myAnimator->getViewer(); delete myAnimator; - aView->Repaint(); } @@ -588,12 +633,14 @@ void VisuGUI_TimeAnimationDlg::createFrames() { myAnimator->generatePresentations(i); } mySlider->setMaxValue(myAnimator->getNbFrames()-1); + myPlayFrame->setEnabled(true); if (!myAnimator->generateFrames()) { QApplication::restoreOverrideCursor(); - QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), "Defined presentation can not be created"); + //myPlayFrame->setEnabled(false); + QMessageBox::warning(QAD_Application::getDesktop(), tr("ERROR"), myAnimator->getLastErrorMsg()); return; } - myPlayFrame->setEnabled(true); + //myPlayFrame->setEnabled(true); QApplication::restoreOverrideCursor(); } @@ -607,37 +654,38 @@ void VisuGUI_TimeAnimationDlg::onPlayPressed() { myAnimator->dumpTo(myPathEdit->text()); else myAnimator->dumpTo(""); + mySetupBtn->setEnabled(false); + myGenBtn->setEnabled(false); myAnimator->startAnimation(); } else { myPlayBtn->setIconSet(MYplayPixmap); myAnimator->stopAnimation(); + mySetupBtn->setEnabled(true); + myGenBtn->setEnabled(true); } } //************************************************************************ void VisuGUI_TimeAnimationDlg::onBackPressed() { - stopAnimation(); + //stopAnimation(); myAnimator->prevFrame(); } //************************************************************************ void VisuGUI_TimeAnimationDlg::onForvardPressed() { - stopAnimation(); myAnimator->nextFrame(); } //************************************************************************ void VisuGUI_TimeAnimationDlg::onLastPressed() { - stopAnimation(); myAnimator->lastFrame(); } //************************************************************************ void VisuGUI_TimeAnimationDlg::onFirstPressed() { - stopAnimation(); myAnimator->firstFrame(); } @@ -651,9 +699,13 @@ void VisuGUI_TimeAnimationDlg::clearView() { //************************************************************************ void VisuGUI_TimeAnimationDlg::closeEvent(QCloseEvent* theEvent) { - stopAnimation(); - clearView(); - QDialog::closeEvent(theEvent); + myAnimator->stopAnimation(); + if (myAnimator->running() && (! myAnimator->finished())) { + isClosing = true; + myEvent = theEvent; + } else { + QDialog::closeEvent(theEvent); + } } @@ -675,6 +727,8 @@ void VisuGUI_TimeAnimationDlg::stopAnimation() { myAnimator->stopAnimation(); myPlayBtn->setOn(false); myPlayBtn->setIconSet(MYplayPixmap); + mySetupBtn->setEnabled(true); + myGenBtn->setEnabled(true); } //************************************************************************ @@ -688,6 +742,7 @@ void VisuGUI_TimeAnimationDlg::onExecution(long theNewFrame, double theTime) { void VisuGUI_TimeAnimationDlg::onSetupDlg() { SetupDlg* aDlg = new SetupDlg(this, myAnimator); aDlg->exec(); + myPlayFrame->setEnabled(false); delete aDlg; } @@ -695,3 +750,16 @@ void VisuGUI_TimeAnimationDlg::onSetupDlg() { void VisuGUI_TimeAnimationDlg::onBrowse() { myPathEdit->setText(QAD_FileDlg::getExistingDirectory(this, "/","Select path")); } + + +//************************************************************************ +void VisuGUI_TimeAnimationDlg::onStop() { + if (isClosing) { + QDialog::closeEvent(myEvent); + } else { + myPlayBtn->setOn(false); + myPlayBtn->setIconSet(MYplayPixmap); + mySetupBtn->setEnabled(true); + myGenBtn->setEnabled(true); + } +} diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.h b/src/VISUGUI/VisuGUI_TimeAnimation.h index 5299cb42..9ae881e7 100644 --- a/src/VISUGUI/VisuGUI_TimeAnimation.h +++ b/src/VISUGUI/VisuGUI_TimeAnimation.h @@ -1,9 +1,12 @@ -// File : VisuGUI_TimeAnimation.h -// Created : 28 / 03 / 2003 -// Author : Vitaly SMETANNIKOV -// Project : SALOME -// Module : VISUGUI -// Copyright : Open CASCADE +// VISU VISUGUI : GUI of VISU component +// +// Copyright (C) 2003 CEA/DEN, EDF R&D +// +// +// +// File : VisuGUI_TimeAnimation.h +// Author : Vitaly SMETANNIKOV +// Module : VISU #ifndef VISUGUI_TIMEANIMATION_H #define VISUGUI_TIMEANIMATION_H @@ -77,6 +80,7 @@ class VisuGUI_TimeAnimationDlg: public QDialog void onSpeedChange(double theSpeed); void onExecution(long theNewFrame, double theTime); void onBrowse(); + void onStop(); private: QSlider* mySlider; @@ -84,6 +88,8 @@ class VisuGUI_TimeAnimationDlg: public QDialog QPushButton* myPropBtn; QToolButton* myPlayBtn; QLabel* myTimeLbl; + QPushButton* mySetupBtn; + QPushButton* myGenBtn; QFrame* myPlayFrame; SALOMEDS::Study_var myStudy; @@ -91,5 +97,7 @@ class VisuGUI_TimeAnimationDlg: public QDialog VISU_TimeAnimation* myAnimator; QCheckBox* mySaveCheck; QLineEdit* myPathEdit; + bool isClosing; + QCloseEvent* myEvent; }; #endif //VISUGUI_TIMEANIMATION_H diff --git a/src/VISUGUI/VisuGUI_VectorsDlg.cxx b/src/VISUGUI/VisuGUI_VectorsDlg.cxx index 9771df6f..174ee491 100644 --- a/src/VISUGUI/VisuGUI_VectorsDlg.cxx +++ b/src/VISUGUI/VisuGUI_VectorsDlg.cxx @@ -1,12 +1,32 @@ -using namespace std; -// File : VisuGUI_VectorsDlg.cxx -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// 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_VectorsDlg.cxx +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ +using namespace std; #include "VisuGUI_VectorsDlg.h" #include #include @@ -157,11 +177,11 @@ VisuGUI_VectorsDlg::~VisuGUI_VectorsDlg() void VisuGUI_VectorsDlg::initFromPrsObject(VISU::Vectors_i* thePrs) { setScaleFactor(thePrs->GetScale()); - setLineWidth(thePrs->GetLineWidth()); + setLineWidth((int)thePrs->GetLineWidth()); setUseMagnColor(thePrs->isColored()); - setColor(QColor(thePrs->GetColor()[0]*255, - thePrs->GetColor()[1]*255, - thePrs->GetColor()[2]*255)); + SALOMEDS::Color anOldColor = thePrs->GetColor(); + QColor aColor = QColor(int(255*anOldColor.R),int(255*anOldColor.G),int(255*anOldColor.B)); + setColor(aColor); if (thePrs->GetGlyphType() != VISU::Vectors::NONE) { setUseGlyphs(true); @@ -178,14 +198,13 @@ void VisuGUI_VectorsDlg::storeToPrsObject(VISU::Vectors_i* thePrs) { thePrs->SetScale(getScaleFactor()); thePrs->SetLineWidth(getLineWidth()); thePrs->setColored(getUseMagnColor()); - - float aColor[3]; - aColor[0] = myColor.red()/255.; - aColor[1] = myColor.green()/255.; - aColor[2] = myColor.blue()/255.; - - thePrs->SetColor(aColor); - + if(!thePrs->isColored()){ + SALOMEDS::Color aColor; + aColor.R = myColor.red()/255.; + aColor.G = myColor.green()/255.; + aColor.B = myColor.blue()/255.; + thePrs->SetColor(aColor); + } if (getUseGlyphs()) { thePrs->SetGlyphPos(getGlyphPos()); thePrs->SetGlyphType(getGlyphType()); diff --git a/src/VISUGUI/VisuGUI_VectorsDlg.h b/src/VISUGUI/VisuGUI_VectorsDlg.h index 0cebbaa7..68f560f8 100644 --- a/src/VISUGUI/VisuGUI_VectorsDlg.h +++ b/src/VISUGUI/VisuGUI_VectorsDlg.h @@ -1,9 +1,29 @@ -// File : VisuGUI_VectorsDlg.h -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// 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_VectorsDlg.h +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ #ifndef VISUGUI_VECTORSDLG_H diff --git a/src/VISUGUI/VisuGUI_VisuAsDlg.cxx b/src/VISUGUI/VisuGUI_VisuAsDlg.cxx index b61b507f..3de24794 100644 --- a/src/VISUGUI/VisuGUI_VisuAsDlg.cxx +++ b/src/VISUGUI/VisuGUI_VisuAsDlg.cxx @@ -1,13 +1,34 @@ -using namespace std; -// File : VisuGUI_VisuAsDlg.cxx -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// 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_VisuAsDlg.cxx +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ +using namespace std; #include "VisuGUI_VisuAsDlg.h" +#include "VISU_PrsObject_i.hh" #include "QAD_Application.h" #include "QAD_Desktop.h" #include "QAD_RightFrame.h" @@ -115,15 +136,15 @@ void VisuGUI_VisuAsDlg::RefreshListActors( const QString &VAType ) if ( VAType == QString( "All" ) ) test = -1; else if ( VAType == QString( "Deformed Shape" ) ) - test = VisuActorType_DeformedShape; + test = VISU::TDEFORMEDSHAPE; else if ( VAType == QString( "Vectors" ) ) - test = VisuActorType_Vectors; + test = VISU::TVECTORS; else if ( VAType == QString( "Scalar Map" ) ) - test = VisuActorType_ScalarMap; + test = VISU::TSCALARMAP; else if ( VAType == QString( "Iso-Surfaces" ) ) - test = VisuActorType_IsoSurfaces; + test = VISU::TISOSURFACE; else if ( VAType == QString( "Cut Planes" ) ) - test = VisuActorType_CutPlanes; + test = VISU::TCUTPLANES; else return; @@ -154,23 +175,23 @@ void VisuGUI_VisuAsDlg::RefreshListActors( const QString &VAType ) */ bool VisuGUI_VisuAsDlg::ActorTypeIsValid( VISU_Actor* Actor, int test ) { - if( test == -1 ) { - if( Actor->VisuActorType < VisuActorType_DeformedShape || - Actor->VisuActorType > VisuActorType_CutPlanes ) - return false; - else + VISU::Prs3d_i* aPrs3d = Actor->getPrs3d(); + if(!aPrs3d) return false; + if(test == -1) { + switch(aPrs3d->GetType()){ + case VISU::TSCALARMAP: + case VISU::TISOSURFACE: + case VISU::TDEFORMEDSHAPE: + case VISU::TCUTPLANES: + case VISU::TCUTLINES: + case VISU::TVECTORS: + case VISU::TSTREAMLINES: return true; - } - else { - if( test < VisuActorType_DeformedShape || - test > VisuActorType_CutPlanes ) + default: return false; - else { - if( Actor->VisuActorType == test) - return true; - else - return false; } + }else{ + return aPrs3d->GetType() == test; } } diff --git a/src/VISUGUI/VisuGUI_VisuAsDlg.h b/src/VISUGUI/VisuGUI_VisuAsDlg.h index ff48404f..62fa0ff7 100644 --- a/src/VISUGUI/VisuGUI_VisuAsDlg.h +++ b/src/VISUGUI/VisuGUI_VisuAsDlg.h @@ -1,9 +1,29 @@ -// File : VisuGUI_VisuAsDlg.h -// Created : Wed Aug 01 10:23:06 2001 -// Author : Laurent CORNABE & Hubert ROLLAND -// 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_VisuAsDlg.h +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU // $Header$ #ifndef VISUGUI_VISUASDLG_H