From 05cb02b0c3c6d67123c471e18fa9fd0e13ebcf53 Mon Sep 17 00:00:00 2001 From: ouv Date: Tue, 7 Nov 2006 15:10:08 +0000 Subject: [PATCH] Simple implementation of VisuGUI_InputPane --- src/VISUGUI/Makefile.in | 6 +- src/VISUGUI/VisuGUI_InputPane.cxx | 233 +++++++++++++++++++++++++++ src/VISUGUI/VisuGUI_InputPane.h | 77 +++++++++ src/VISUGUI/VisuGUI_Prs3dTools.h | 10 +- src/VISUGUI/VisuGUI_ScalarBarDlg.cxx | 48 +++++- src/VISUGUI/VisuGUI_ScalarBarDlg.h | 8 +- 6 files changed, 373 insertions(+), 9 deletions(-) create mode 100644 src/VISUGUI/VisuGUI_InputPane.cxx create mode 100644 src/VISUGUI/VisuGUI_InputPane.h diff --git a/src/VISUGUI/Makefile.in b/src/VISUGUI/Makefile.in index bf48a9ec..369dcaf9 100644 --- a/src/VISUGUI/Makefile.in +++ b/src/VISUGUI/Makefile.in @@ -76,7 +76,8 @@ LIB_SRC = VisuGUI.cxx \ VisuGUI_BuildProgressDlg.cxx \ VisuGUI_TransparencyDlg.cxx \ VisuGUI_Timer.cxx \ - VisuGUI_Slider.cxx + VisuGUI_Slider.cxx \ + VisuGUI_InputPane.cxx LIB_MOC = VisuGUI.h \ VisuGUI_Module.h \ @@ -102,7 +103,8 @@ LIB_MOC = VisuGUI.h \ VisuGUI_SetupPlot2dDlg.h \ VisuGUI_BuildProgressDlg.h \ VisuGUI_TransparencyDlg.h \ - VisuGUI_Slider.h + VisuGUI_Slider.h \ + VisuGUI_InputPane.h LIB_CLIENT_IDL = SALOME_Exception.idl \ VISU_Gen.idl \ diff --git a/src/VISUGUI/VisuGUI_InputPane.cxx b/src/VISUGUI/VisuGUI_InputPane.cxx new file mode 100644 index 00000000..60612e89 --- /dev/null +++ b/src/VISUGUI/VisuGUI_InputPane.cxx @@ -0,0 +1,233 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : VisuGUI_InputPane.cxx +// Author : Oleg UVAROV +// Module : VISU + +#include "VisuGUI_InputPane.h" + +#include "VisuGUI_Tools.h" + +#include "VISU_ColoredPrs3d_i.hh" +#include "VISU_Result_i.hh" + +#include "SUIT_ResourceMgr.h" + +#include "SalomeApp_Module.h" + +#include "LightApp_Application.h" +#include "LightApp_SelectionMgr.h" + +#include "SALOME_ListIO.hxx" + +#include "SALOMEDSClient_AttributeComment.hxx" +#include "SALOMEDSClient_AttributeName.hxx" + +#include +#include +#include +#include + +using namespace VISU; + +VisuGUI_InputPane::VisuGUI_InputPane( SalomeApp_Module* theModule, QWidget* parent ) : + QGroupBox( 2, Qt::Horizontal, parent ), + myModule( theModule ) +{ + //SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); + + setFrameStyle( QFrame::Box | QFrame::Sunken ); + + LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr( myModule ); + connect( aSelectionMgr, SIGNAL( selectionChanged() ), SLOT( onSelectionChanged() ) ); + + new QLabel( "Med File : ", this ); + myMedFile = new QLineEdit( this ); + myMedFile->setReadOnly( true ); + myMedFile->setEnabled( false ); + myMedFile->setPaletteForegroundColor( Qt::black ); + + new QLabel( "Mesh : ", this ); + myMeshName = new QLineEdit( this ); + myMeshName->setReadOnly( true ); + myMeshName->setEnabled( false ); + myMeshName->setPaletteForegroundColor( Qt::black ); + + new QLabel( "Entity : ", this ); + myEntityName = new QLineEdit( this ); + myEntityName->setReadOnly( true ); + myEntityName->setEnabled( false ); + myEntityName->setPaletteForegroundColor( Qt::black ); + + new QLabel( "Field : ", this ); + myFieldName = new QLineEdit( this ); + myFieldName->setReadOnly( true ); + + new QLabel( "Time Stamp : ", this ); + myTimeStamps = new QComboBox( this ); + + onSelectionChanged(); + + hide(); +} + +VisuGUI_InputPane::~VisuGUI_InputPane() +{ +} + +bool VisuGUI_InputPane::check() +{ + return myTimeStamps->count() != 0; +} + +void VisuGUI_InputPane::clear() +{ + myMedFile->clear(); + myMeshName->clear(); + myEntityName->clear(); + myFieldName->clear(); + myTimeStamps->clear(); +} + +void VisuGUI_InputPane::onSelectionChanged() +{ + clear(); + + SALOME_ListIO aListIO; + GetSelectionMgr( myModule )->selectedObjects(aListIO); + + if (aListIO.Extent() != 1) + return; + + const Handle(SALOME_InteractiveObject)& anIO = aListIO.First(); + + _PTR(Study) aCStudy = GetCStudy(GetAppStudy(myModule)); + _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry()); + if (!aSObject) + return; + + VISU::Storable::TRestoringMap aMap; + _PTR(GenericAttribute) anAttr; + if (!aSObject->FindAttribute(anAttr, "AttributeComment")) + return; + + _PTR(AttributeComment) aComment (anAttr); + string aComm = aComment->Value(); + QString strIn (aComm.c_str()); + VISU::Storable::StrToMap(strIn, aMap); + bool isExist; + VISU::VISUType aType = (VISU::VISUType)VISU::Storable::FindValue(aMap,"myType",&isExist).toInt(); + if (aType == VISU::TFIELD) + { + _PTR(SObject) aMedObject = aSObject->GetFather()->GetFather()->GetFather(); + if( !aMedObject ) + return; + + QString anEntityName, aTimeStampName; + + _PTR(StudyBuilder) aBuilder = aCStudy->NewBuilder(); + _PTR(ChildIterator) aIter = aCStudy->NewChildIterator(aSObject); + for( ; aIter->More(); aIter->Next() ) + { + _PTR(SObject) aChildObj = aIter->Value(); + if( !aChildObj ) + return; + + if( anEntityName.isNull() ) + { + _PTR(SObject) aRefObj; + if( aChildObj->ReferencedObject( aRefObj ) ) + anEntityName = aRefObj->GetName().c_str(); + } + + if( VISU::getValue(aChildObj, "myComment") == "TIMESTAMP" ) + { + aTimeStampName = aChildObj->GetName().c_str(); + myTimeStamps->insertItem( aTimeStampName ); + } + } + + myResult = FindResult( VISU::GetSObject( aSObject ).in() ); + + myEntity = VISU::getValue( aSObject, "myEntityId" ).toInt(); + + QString aMedFile = aMedObject->GetName().c_str(); + QString aMeshName = VISU::getValue(aSObject, "myMeshName"); + QString aFieldName = VISU::getValue(aSObject, "myName"); + + myMedFile->setText( aMedFile ); + myMeshName->setText( aMeshName ); + myEntityName->setText( anEntityName ); + myFieldName->setText( aFieldName ); + myTimeStamps->setCurrentItem( 0 ); + } +} + +void VisuGUI_InputPane::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs ) +{ + clear(); + + CORBA::Long aTimeStampNumber = thePrs->GetTimeStampNumber(); + VISU::ColoredPrs3d::TimeStampsRange_var aTimeStampsRange = thePrs->GetTimeStampsRange(); + CORBA::Long aLength = aTimeStampsRange->length(); + + for( int index = 0; index < aLength; index++ ) + { + VISU::ColoredPrs3d::TimeStampInfo anInfo = aTimeStampsRange[ index ]; + QString aTime = anInfo.myTime.in(); + myTimeStamps->insertItem( aTime ); + } + + myResult = thePrs->GetResultObject(); + VISU::Result_i* aResult = dynamic_cast(GetServant(myResult).in()); + myMedFile->setText( aResult->GetName().c_str() ); + + myEntity = (int)thePrs->GetEntity(); + + QString anEntityName; + switch( myEntity ) + { + case NODE_ENTITY: anEntityName = "onNodes"; break; + case EDGE_ENTITY: anEntityName = "onEdges"; break; + case FACE_ENTITY: anEntityName = "onFaces"; break; + case CELL_ENTITY: anEntityName = "onCells"; break; + default: break; + } + myEntityName->setText( anEntityName ); + + myMeshName->setText( thePrs->GetMeshName() ); + myFieldName->setText( thePrs->GetFieldName() ); + myTimeStamps->setCurrentItem( thePrs->GetTimeStampIndexByNumber( aTimeStampNumber ) ); +} + +int VisuGUI_InputPane::storeToPrsObject( VISU::ColoredPrs3d_i* thePrs ) +{ + thePrs->SetResultObject( myResult ); + + thePrs->SetMeshName( myMeshName->text().latin1() ); + thePrs->SetEntity( VISU::Entity( myEntity ) ); + thePrs->SetFieldName( myFieldName->text().latin1() ); + thePrs->SetTimeStampNumber( thePrs->GetTimeStampNumberByIndex( myTimeStamps->currentItem() ) ); + return ( int )thePrs->Apply(); +} diff --git a/src/VISUGUI/VisuGUI_InputPane.h b/src/VISUGUI/VisuGUI_InputPane.h new file mode 100644 index 00000000..8adf941a --- /dev/null +++ b/src/VISUGUI/VisuGUI_InputPane.h @@ -0,0 +1,77 @@ +// 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.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// +// +// File : VisuGUI_InputPane.h +// Author : Oleg UVAROV +// Module : VISU + +#ifndef VISUGUI_INPUTPANE_H +#define VISUGUI_INPUTPANE_H + +#include "VISUConfig.hh" + +#include + +class QComboBox; +class QLineEdit; + +class SalomeApp_Module; + +namespace VISU +{ + class ColoredPrs3d_i; + class Result_i; +} + +class VisuGUI_InputPane : public QGroupBox +{ + Q_OBJECT + +public: + VisuGUI_InputPane( SalomeApp_Module* theModule, QWidget* parent ); + virtual ~VisuGUI_InputPane(); + +public: + virtual bool check(); + virtual void clear(); + + void initFromPrsObject( VISU::ColoredPrs3d_i* ); + int storeToPrsObject( VISU::ColoredPrs3d_i* ); + +public slots: + virtual void onSelectionChanged(); + +private: + SalomeApp_Module* myModule; + + QLineEdit* myMedFile; + QLineEdit* myMeshName; + QLineEdit* myEntityName; + QLineEdit* myFieldName; + QComboBox* myTimeStamps; + + VISU::Result_var myResult; + int myEntity; +}; + +#endif diff --git a/src/VISUGUI/VisuGUI_Prs3dTools.h b/src/VISUGUI/VisuGUI_Prs3dTools.h index dc4161d5..0198f998 100644 --- a/src/VISUGUI/VisuGUI_Prs3dTools.h +++ b/src/VISUGUI/VisuGUI_Prs3dTools.h @@ -36,6 +36,7 @@ namespace VISU { + class ColoredPrs3d_i; class CutLines_i; //--------------------------------------------------------------- @@ -55,9 +56,14 @@ namespace VISU SVTK_ViewWindow* theViewWindow) { if (TPrs3d_i* aPrs3d = dynamic_cast(thePrs3d)) { + bool isModal = TIsDlgModal; + if( ColoredPrs3d_i* aColoredPrs3d = dynamic_cast(aPrs3d) ) + if( !aColoredPrs3d->IsTimeStampFixed() ) + isModal = 0; + TDlg* aDlg = new TDlg (theModule); aDlg->initFromPrsObject(aPrs3d); - if (runAndWait(aDlg,TIsDlgModal)) { + if (runAndWait(aDlg,isModal)) { if (!(aDlg->storeToPrsObject(aPrs3d))) { delete aDlg; return; @@ -255,7 +261,7 @@ namespace VISU return; if(aPublishInStudyMode == VISU::ColoredPrs3d_i::EPublishIndependently){ - CreatePrs3dInViewer + CreatePrs3dInViewer (theModule,aTimeStampSObj,anIO,aPublishInStudyMode); return; }else{ diff --git a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx index 47fa0a69..88ef543d 100644 --- a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx +++ b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx @@ -28,6 +28,8 @@ #include "VisuGUI_ScalarBarDlg.h" +#include "VisuGUI_InputPane.h" + #include "VisuGUI.h" #include "VisuGUI_Tools.h" #include "VisuGUI_ViewTools.h" @@ -42,6 +44,8 @@ #include "VISU_ScalarMap_i.hh" #include "VISU_ScalarMapAct.h" +#include "VISU_Result_i.hh" + #include "LightApp_Application.h" #include "SUIT_Session.h" @@ -52,7 +56,7 @@ #include #include #include - +#include #include using namespace std; @@ -1069,7 +1073,7 @@ void VisuGUI_ScalarBarPane::onPreviewCheck (bool thePreview) Constructor */ VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg (SalomeApp_Module* theModule, bool SetPref) - : QDialog(VISU::GetDesktop(theModule), 0, true, + : QDialog(VISU::GetDesktop(theModule), 0, false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) { setName("VisuGUI_ScalarBarDlg"); @@ -1080,8 +1084,14 @@ VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg (SalomeApp_Module* theModule, bool Se TopLayout->setSpacing(6); TopLayout->setMargin(11); + myTabBox = new QTabWidget(this); myScalarPane = new VisuGUI_ScalarBarPane(this, SetPref); - TopLayout->addWidget(myScalarPane); + myScalarPane->setMargin( 5 ); + myInputPane = new VisuGUI_InputPane(theModule, this); + myTabBox->addTab(myScalarPane, "Scalar Bar"); + myTabBox->addTab(myInputPane, "Input"); + + TopLayout->addWidget(myTabBox); // Common buttons =========================================================== QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); @@ -1154,6 +1164,38 @@ void VisuGUI_ScalarBarDlg::onHelp() } } +/*! + Initialize dialog from the presentation +*/ +void VisuGUI_ScalarBarDlg::initFromPrsObject(VISU::ScalarMap_i* thePrs) +{ + myScalarPane->initFromPrsObject( thePrs ); + + if( thePrs->IsTimeStampFixed() ) + myTabBox->removePage( myInputPane ); + else + { + myInputPane->initFromPrsObject( thePrs ); + myTabBox->showPage( myInputPane ); + } + + myTabBox->setCurrentPage( 0 ); +} + +int VisuGUI_ScalarBarDlg::storeToPrsObject(VISU::ScalarMap_i* thePrs) +{ + int ok = 1; + if( !thePrs->IsTimeStampFixed() ) + { + if( !myInputPane->check() ) + return 0; + + ok = myInputPane->storeToPrsObject( thePrs ); + } + + return ok && myScalarPane->storeToPrsObject(thePrs); +} + /*! Provides help on F1 button click */ diff --git a/src/VISUGUI/VisuGUI_ScalarBarDlg.h b/src/VISUGUI/VisuGUI_ScalarBarDlg.h index d9d0f6f2..10fe93af 100644 --- a/src/VISUGUI/VisuGUI_ScalarBarDlg.h +++ b/src/VISUGUI/VisuGUI_ScalarBarDlg.h @@ -57,11 +57,13 @@ class QLineEdit; class QComboBox; class QVBox; class QToolButton; +class QTabWidget; class QtxDblSpinBox; class SalomeApp_Module; class SVTK_FontWidget; class VISU_ScalarMapAct; +class VisuGUI_InputPane; class VisuGUI_TextPrefDlg: public QDialog { @@ -203,8 +205,8 @@ class VisuGUI_ScalarBarDlg : public QDialog void initFromResources() {myScalarPane->initFromResources();} void storeToResources() {myScalarPane->storeToResources();} - void initFromPrsObject(VISU::ScalarMap_i* thePrs) {myScalarPane->initFromPrsObject(thePrs);} - int storeToPrsObject(VISU::ScalarMap_i* thePrs) {return myScalarPane->storeToPrsObject(thePrs);} + void initFromPrsObject(VISU::ScalarMap_i* thePrs); + int storeToPrsObject(VISU::ScalarMap_i* thePrs); private: void keyPressEvent( QKeyEvent* e ); @@ -216,6 +218,8 @@ class VisuGUI_ScalarBarDlg : public QDialog protected: VisuGUI_ScalarBarPane* myScalarPane; + VisuGUI_InputPane* myInputPane; + QTabWidget* myTabBox; }; #endif // VISUGUI_SCALARBARDLG_H -- 2.39.2