From: ouv Date: Thu, 14 Dec 2006 09:24:56 +0000 (+0000) Subject: VisuGUI_Prs3dDlg - base class for all prs dialogs. X-Git-Tag: WP1_2_3_20-12-2006_bug_fixing~8 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=705084ce3cb2be1f16d6b188b704625c6bd5048f;p=modules%2Fvisu.git VisuGUI_Prs3dDlg - base class for all prs dialogs. theReInit boolean flag is added to Prs3d::Apply() - to reinitialize dialogs when the input is changing. --- diff --git a/idl/VISU_Gen.idl b/idl/VISU_Gen.idl index 252bfad6..90bf2592 100644 --- a/idl/VISU_Gen.idl +++ b/idl/VISU_Gen.idl @@ -321,7 +321,7 @@ module VISU { * \return True of the set of input parameters is correct and was succesfully applied, * False otherwise */ - boolean Apply(); + boolean Apply(in boolean theReInit); //! Sets Result object used by presentation to obtain its input void SetResultObject(in Result theResult); diff --git a/src/PIPELINE/VISU_ScalarMapPL.cxx b/src/PIPELINE/VISU_ScalarMapPL.cxx index e915b3c4..04d4c27a 100644 --- a/src/PIPELINE/VISU_ScalarMapPL.cxx +++ b/src/PIPELINE/VISU_ScalarMapPL.cxx @@ -153,7 +153,9 @@ void VISU_ScalarMapPL ::SetScalarRange(vtkFloatingPointType theRange[2]) { + //cout << "VISU_ScalarMapPL::SetScalarRange" << endl; if(!VISU::CheckIsSameRange(GetScalarRange(), theRange)){ + //cout << "( " << theRange[0] << " : " << theRange[1] << " )"<< endl; myFieldTransform->SetScalarRange(theRange); myBarTable->SetRange(theRange); } diff --git a/src/VISUGUI/Makefile.in b/src/VISUGUI/Makefile.in index 08c5dced..51f876d7 100644 --- a/src/VISUGUI/Makefile.in +++ b/src/VISUGUI/Makefile.in @@ -61,8 +61,9 @@ LIB_SRC = VisuGUI.cxx \ VisuGUI_ClippingDlg.cxx \ VisuGUI_DialogRunner.cxx \ VisuGUI_OffsetDlg.cxx \ - VisuGUI_Plot3DDlg.cxx \ + VisuGUI_Prs3dDlg.cxx \ VisuGUI_ScalarBarDlg.cxx \ + VisuGUI_Plot3DDlg.cxx \ VisuGUI_GaussPointsDlg.cxx \ VisuGUI_DeformedShapeDlg.cxx \ VisuGUI_IsoSurfacesDlg.cxx \ @@ -92,8 +93,9 @@ LIB_MOC = VisuGUI.h \ VisuGUI_ClippingDlg.h \ VisuGUI_DialogRunner.h \ VisuGUI_OffsetDlg.h \ - VisuGUI_Plot3DDlg.h \ + VisuGUI_Prs3dDlg.h \ VisuGUI_ScalarBarDlg.h \ + VisuGUI_Plot3DDlg.h \ VisuGUI_GaussPointsDlg.h \ VisuGUI_DeformedShapeDlg.h \ VisuGUI_IsoSurfacesDlg.h \ diff --git a/src/VISUGUI/VISU_msg_en.po b/src/VISUGUI/VISU_msg_en.po index 25ede96f..8e7dc696 100644 --- a/src/VISUGUI/VISU_msg_en.po +++ b/src/VISUGUI/VISU_msg_en.po @@ -707,6 +707,28 @@ msgid "VisuGUI_NonIsometricDlg::LBL_Z" msgstr "Z :" +#: VisuGUI_InputPane.cxx + +msgid "VisuGUI_InputPane::MED_FILE" +msgstr "Med File :" + +msgid "VisuGUI_InputPane::MESH" +msgstr "Mesh :" + +msgid "VisuGUI_InputPane::ENTITY" +msgstr "Entity :" + +msgid "VisuGUI_InputPane::FIELD" +msgstr "Field :" + +msgid "VisuGUI_InputPane::TIME_STAMP" +msgstr "Time Stamp :" + +msgid "VisuGUI_InputPane::REINITIALIZE" +msgstr "Reinitialize" + + + #: VisuGUI_ScalarBarDlg.cxx msgid "VisuGUI_ScalarBarDlg::&OK" diff --git a/src/VISUGUI/VisuGUI_CutLinesDlg.cxx b/src/VISUGUI/VisuGUI_CutLinesDlg.cxx index 6a30c79c..a5a943b5 100644 --- a/src/VISUGUI/VisuGUI_CutLinesDlg.cxx +++ b/src/VISUGUI/VisuGUI_CutLinesDlg.cxx @@ -32,6 +32,7 @@ #include "VISU_Gen_i.hh" #include "VISU_CutLines_i.hh" +#include "VISU_ColoredPrs3dFactory.hh" #include "VISU_PipeLine.hxx" #include "VISU_PipeLineUtils.hxx" @@ -53,6 +54,7 @@ #include #include #include +#include #include #include @@ -69,9 +71,8 @@ bool VisuGUI_CutLinesDlg::MYGenerateTable = true; bool VisuGUI_CutLinesDlg::MYGenerateCurve = true; VisuGUI_CutLinesDlg::VisuGUI_CutLinesDlg (SalomeApp_Module* theModule) - : QDialog(VISU::GetDesktop(theModule), "VisuGUI_CutLinesDlg", false, - WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu), - myPreviewActor(0),myPreviewActorGlyphs(0) + : VisuGUI_Prs3dDlg(theModule), + myPreviewActor(0),myPreviewActorGlyphs(0) { setCaption("Cut Lines Definition"); setSizeGripEnabled(true); @@ -289,79 +290,87 @@ VisuGUI_CutLinesDlg::~VisuGUI_CutLinesDlg() } //------------------------------------------------------------------------------ -void VisuGUI_CutLinesDlg::initFromPrsObject (VISU::CutLines_i* thePrs) +void VisuGUI_CutLinesDlg::initFromPrsObject (VISU::ColoredPrs3d_i* thePrs, bool theInit) { - myPrs = thePrs; - myScalarPane->initFromPrsObject(thePrs); + if( theInit ) + myPrsCopy = VISU::TSameAsFactory().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish); - if( thePrs->IsTimeStampFixed() ) - myTabBox->removePage( myInputPane ); - else - { - myInputPane->initFromPrsObject( thePrs ); - myTabBox->showPage( myInputPane ); - } - myTabBox->setCurrentPage( 0 ); + myScalarPane->initFromPrsObject(myPrsCopy); - myRotXSpn->setValue(thePrs->GetRotateX()*180./PI); - myRotYSpn->setValue(thePrs->GetRotateY()*180./PI); - myPosSpn->setValue(thePrs->GetDisplacement()); - setOrientation(thePrs->GetOrientationType()); + myRotXSpn->setValue(myPrsCopy->GetRotateX()*180./PI); + myRotYSpn->setValue(myPrsCopy->GetRotateY()*180./PI); + myPosSpn->setValue(myPrsCopy->GetDisplacement()); + setOrientation(myPrsCopy->GetOrientationType()); - myNbSpn->setValue( (int)thePrs->GetNbLines() ); - myRotXSpn2->setValue(thePrs->GetRotateX2()*180./PI); - myRotYSpn2->setValue(thePrs->GetRotateY2()*180./PI); - myPosSpn2->setValue(thePrs->GetDisplacement2()); - setOrientation2(thePrs->GetOrientationType2()); + myNbSpn->setValue( (int)myPrsCopy->GetNbLines() ); + myRotXSpn2->setValue(myPrsCopy->GetRotateX2()*180./PI); + myRotYSpn2->setValue(myPrsCopy->GetRotateY2()*180./PI); + myPosSpn2->setValue(myPrsCopy->GetDisplacement2()); + setOrientation2(myPrsCopy->GetOrientationType2()); hasInit = true; - myCutLines = VISU::TSameAsFactory().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish); - myCutLines->CopyCurvesInverted(thePrs->GetCurvesInverted()); + myCutLines = VISU::TSameAsFactory().Create(myPrsCopy, VISU::ColoredPrs3d_i::EDoNotPublish); + myCutLines->CopyCurvesInverted(myPrsCopy->GetCurvesInverted()); if (myCutLines->IsAllCurvesInverted()) myAllCurvesInvertedCheck->setChecked(true); myBasePlanePos->setText( QString::number(myCutLines->GetBasePlanePosition()) ); - myCBSetDef->setChecked(thePrs->IsDefault()); + myCBSetDef->setChecked(myPrsCopy->IsDefault()); DrawTable(); // Draw Preview if (myPreviewCheck->isChecked()) { createPlanes(); } + + if( !theInit ) + return; + + if( myPrsCopy->IsTimeStampFixed() ) + myTabBox->removePage( myInputPane ); + else + { + myInputPane->initFromPrsObject( myPrsCopy ); + myTabBox->showPage( myInputPane ); + } + myTabBox->setCurrentPage( 0 ); } //------------------------------------------------------------------------------ -int VisuGUI_CutLinesDlg::storeToPrsObject (VISU::CutLines_i* thePrs) +int VisuGUI_CutLinesDlg::storeToPrsObject (VISU::ColoredPrs3d_i* thePrs) { - myScalarPane->storeToPrsObject(thePrs); + myScalarPane->storeToPrsObject(myPrsCopy); - if( !thePrs->IsTimeStampFixed() ) + if( !myPrsCopy->IsTimeStampFixed() ) { if( !myInputPane->check() ) return 0; - myInputPane->storeToPrsObject( thePrs ); + myInputPane->storeToPrsObject( myPrsCopy ); } - thePrs->SetOrientation(getOrientaion(), - myRotXSpn->value()*PI/180., - myRotYSpn->value()*PI/180.); - thePrs->SetDisplacement(myPosSpn->value()); - thePrs->SetNbLines((int)myNbSpn->value()); + myPrsCopy->SetOrientation(getOrientaion(), + myRotXSpn->value()*PI/180., + myRotYSpn->value()*PI/180.); + myPrsCopy->SetDisplacement(myPosSpn->value()); + myPrsCopy->SetNbLines((int)myNbSpn->value()); - thePrs->SetOrientation2(getOrientaion(false), - myRotXSpn2->value()*PI/180., - myRotYSpn2->value()*PI/180.); - thePrs->SetDisplacement2(myPosSpn2->value()); + myPrsCopy->SetOrientation2(getOrientaion(false), + myRotXSpn2->value()*PI/180., + myRotYSpn2->value()*PI/180.); + myPrsCopy->SetDisplacement2(myPosSpn2->value()); if (!myCBSetDef->isChecked()) - thePrs->SetBasePlanePosition(myBasePlanePos->text().toDouble()); - else thePrs->SetDefault(); + myPrsCopy->SetBasePlanePosition(myBasePlanePos->text().toDouble()); + else myPrsCopy->SetDefault(); for (int i = 0; i < (int)myNbSpn->value(); ++i) { if (!((QCheckTableItem*)myPosTable->item( i, 1 ))->isChecked()) - thePrs->SetLinePosition( i, myPosTable->text( i, 0 ).toDouble() ); - else thePrs->SetDefaultPosition(i); + myPrsCopy->SetLinePosition( i, myPosTable->text( i, 0 ).toDouble() ); + else myPrsCopy->SetDefaultPosition(i); } if (myAllCurvesInvertedCheck->isChecked()) - thePrs->SetAllCurvesInverted(true); + myPrsCopy->SetAllCurvesInverted(true); + + VISU::TSameAsFactory().Copy(thePrs, myPrsCopy); + return 1; } @@ -779,13 +788,13 @@ void VisuGUI_CutLinesDlg::accept() MYGenerateCurve = myCurvesCheck->isChecked(); // if (myScalarPane->check()) { /*jfa tmp:((QWidget*)sender())->setDisabled(true); - storeToPrsObject(myPrs); + storeToPrsObject(myPrsCopy); if (myIsCreation) { if (isGenerateTable()) { - visuGUI->GetVisuGen()->CreateTable(myPrs->GetEntry()); + visuGUI->GetVisuGen()->CreateTable(myPrsCopy->GetEntry()); if (isGenerateCurves()) { SALOMEDSClient_Study* aStudy = study()->studyDS(); - SALOMEDSClient_SObject* aSObject = aStudy->FindObjectID(myPrs->GetEntry()); + SALOMEDSClient_SObject* aSObject = aStudy->FindObjectID(myPrsCopy->GetEntry()); if( aSObject ) { SALOMEDSClient_ChildIterator* aIter = aStudy->NewChildIterator( aSObject ); SALOMEDSClient_StudyBuilder* aBuilder = aStudy->NewBuilder(); @@ -803,7 +812,7 @@ void VisuGUI_CutLinesDlg::accept() } if (GET_VTK_VIEWWINDOW(myMgr)) { try { - visuGUI->CreateActor(myPrs); + visuGUI->CreateActor(myPrsCopy); } catch (...) { reject(); return; @@ -811,7 +820,7 @@ void VisuGUI_CutLinesDlg::accept() GET_VTK_VIEWWINDOW(myMgr)->onFitAll(); } } else { - visuGUI->RecreateActor(myPrs); + visuGUI->RecreateActor(myPrsCopy); if (VTKViewer_ViewWindow* vf = GET_VTK_VIEWWINDOW(myMgr)) { if (vf->getRenderer()->GetActors()->GetNumberOfItems() > 0) { vf->getRenderer()->ResetCameraClippingRange(); @@ -820,7 +829,7 @@ void VisuGUI_CutLinesDlg::accept() } // Remove old Table SALOMEDSClient_Study* aStudy = study()->studyDS(); - SALOMEDSClient_SObject* aSObject = aStudy->FindObjectID(myPrs->GetEntry()); + SALOMEDSClient_SObject* aSObject = aStudy->FindObjectID(myPrsCopy->GetEntry()); if( aSObject ) { SALOMEDSClient_ChildIterator* aIter = aStudy->NewChildIterator( aSObject ); SALOMEDSClient_StudyBuilder* aBuilder = aStudy->NewBuilder(); @@ -863,7 +872,7 @@ void VisuGUI_CutLinesDlg::accept() void VisuGUI_CutLinesDlg::reject() { /*jfa tmp:if (myIsCreation) { - myPrs->RemoveFromStudy(); + myPrsCopy->RemoveFromStudy(); VisuGUI::application()->objectBrowser()->updateTree(); }*/ myScalarPane->deletePreview(); @@ -892,11 +901,11 @@ void VisuGUI_CutLinesDlg::onAllCurvesInvertedCheck(bool theInvert) { if (myAllCurvesInvertedCheck->isChecked()){ myCutLines->SetAllCurvesInverted(true); - myPrs->SetAllCurvesInverted(true); + myPrsCopy->SetAllCurvesInverted(true); } else { myCutLines->SetAllCurvesInverted(false); - myPrs->SetAllCurvesInverted(false); + myPrsCopy->SetAllCurvesInverted(false); } updateGlyphs(true); } diff --git a/src/VISUGUI/VisuGUI_CutLinesDlg.h b/src/VISUGUI/VisuGUI_CutLinesDlg.h index 0894d5ad..40cc9ede 100644 --- a/src/VISUGUI/VisuGUI_CutLinesDlg.h +++ b/src/VISUGUI/VisuGUI_CutLinesDlg.h @@ -29,6 +29,9 @@ #include #include #include +#include + +class QLineEdit; class SUIT_ViewManager; class SalomeApp_Module; @@ -38,7 +41,7 @@ namespace VISU{ class CutLines_i; } -class VisuGUI_CutLinesDlg: public QDialog +class VisuGUI_CutLinesDlg: public VisuGUI_Prs3dDlg { Q_OBJECT @@ -46,8 +49,8 @@ public: VisuGUI_CutLinesDlg (SalomeApp_Module* theModule); ~VisuGUI_CutLinesDlg(); - void initFromPrsObject (VISU::CutLines_i* thePrs); - int storeToPrsObject (VISU::CutLines_i* thePrs); + virtual void initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit = true); + virtual int storeToPrsObject(VISU::ColoredPrs3d_i* thePrs); bool isGenerateTable() { return myCreateTable->isChecked(); } bool isGenerateCurves() { return myCreateTable->isChecked() && myCurvesCheck->isChecked(); } @@ -115,7 +118,7 @@ private: QCheckBox* myPreviewCheck; QCheckBox* myAllCurvesInvertedCheck; - VISU::CutLines_i* myPrs; + SALOME::GenericObjPtr myPrsCopy; //jfa tmp:SUIT_ViewManager *myMgr; //jfa tmp:SUIT_ViewWindow *myStudyWnd; diff --git a/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx b/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx index 5f62ba97..c092854f 100644 --- a/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx +++ b/src/VISUGUI/VisuGUI_CutPlanesDlg.cxx @@ -35,6 +35,7 @@ #include "VisuGUI_ViewTools.h" #include "VisuGUI_InputPane.h" +#include "VISU_ColoredPrs3dFactory.hh" #include "VISU_CutPlanes_i.hh" #include "VISU_CutPlanesPL.hxx" @@ -53,6 +54,7 @@ #include "SUIT_ResourceMgr.h" #include +#include #include #include #include @@ -471,8 +473,7 @@ void VisuGUI_CutPlanesPane::onPreviewCheck (bool thePreview) Constructor */ VisuGUI_CutPlanesDlg::VisuGUI_CutPlanesDlg (SalomeApp_Module* theModule) - : QDialog(VISU::GetDesktop(theModule), "VisuGUI_CutPlanesDlg", false, - WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) + : VisuGUI_Prs3dDlg(theModule) { setCaption("Cut Planes Definition"); setSizeGripEnabled(true); @@ -529,34 +530,45 @@ VisuGUI_CutPlanesDlg::VisuGUI_CutPlanesDlg (SalomeApp_Module* theModule) // this, SLOT(onWindowActivated(SUIT_ViewWindow*))); } -void VisuGUI_CutPlanesDlg::initFromPrsObject (VISU::CutPlanes_i* thePrs) +void VisuGUI_CutPlanesDlg::initFromPrsObject (VISU::ColoredPrs3d_i* thePrs, bool theInit) { - myPrs = thePrs; - myScalarPane->initFromPrsObject(thePrs); - myCutPane->initFromPrsObject(thePrs); + if( theInit ) + myPrsCopy = VISU::TSameAsFactory().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish); + + myScalarPane->initFromPrsObject( myPrsCopy ); + + if( !theInit ) + return; - if( thePrs->IsTimeStampFixed() ) + myScalarPane->initFromPrsObject(myPrsCopy); + myCutPane->initFromPrsObject(myPrsCopy); + + if( myPrsCopy->IsTimeStampFixed() ) myTabBox->removePage( myInputPane ); else { - myInputPane->initFromPrsObject( thePrs ); + myInputPane->initFromPrsObject( myPrsCopy ); myTabBox->showPage( myInputPane ); } myTabBox->setCurrentPage( 0 ); } -int VisuGUI_CutPlanesDlg::storeToPrsObject (VISU::CutPlanes_i* thePrs) +int VisuGUI_CutPlanesDlg::storeToPrsObject (VISU::ColoredPrs3d_i* thePrs) { int ok = 1; - if( !thePrs->IsTimeStampFixed() ) + if( !myPrsCopy->IsTimeStampFixed() ) { if( !myInputPane->check() ) return 0; - ok = myInputPane->storeToPrsObject( thePrs ); + ok = myInputPane->storeToPrsObject(myPrsCopy); } - return ok && myScalarPane->storeToPrsObject(thePrs) && myCutPane->storeToPrsObject(thePrs); + ok = ok && myScalarPane->storeToPrsObject(myPrsCopy) && myCutPane->storeToPrsObject(myPrsCopy); + + VISU::TSameAsFactory().Copy(thePrs, myPrsCopy); + + return ok; } void VisuGUI_CutPlanesDlg::accept() diff --git a/src/VISUGUI/VisuGUI_CutPlanesDlg.h b/src/VISUGUI/VisuGUI_CutPlanesDlg.h index 2cd58c97..872a267a 100644 --- a/src/VISUGUI/VisuGUI_CutPlanesDlg.h +++ b/src/VISUGUI/VisuGUI_CutPlanesDlg.h @@ -29,25 +29,26 @@ #ifndef VISUGUI_CUTPLANESDLG_H #define VISUGUI_CUTPLANESDLG_H -#include "VisuGUI_ScalarBarDlg.h" +#include "VisuGUI_Prs3dDlg.h" #include "VISU_CutPlanes_i.hh" #include +#include #include #include #include +#include + #include "SALOMEconfig.h" #include CORBA_CLIENT_HEADER(VISU_Gen) -class QtxDblSpinBox; class SUIT_ViewWindow; class SUIT_ViewManager; class SalomeApp_Module; class VisuGUI_InputPane; - class VisuGUI_CutPlanesPane : public QFrame { Q_OBJECT @@ -102,7 +103,7 @@ private slots: }; -class VisuGUI_CutPlanesDlg : public QDialog +class VisuGUI_CutPlanesDlg : public VisuGUI_Prs3dDlg { Q_OBJECT @@ -110,8 +111,8 @@ public: VisuGUI_CutPlanesDlg (SalomeApp_Module* theModule); ~VisuGUI_CutPlanesDlg() {}; - void initFromPrsObject (VISU::CutPlanes_i* thePrs); - int storeToPrsObject (VISU::CutPlanes_i* thePrs); + virtual void initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit = true); + virtual int storeToPrsObject(VISU::ColoredPrs3d_i* thePrs); private: void keyPressEvent( QKeyEvent* e ); @@ -128,6 +129,7 @@ private: VisuGUI_ScalarBarPane* myScalarPane; VisuGUI_InputPane* myInputPane; VISU::CutPlanes_i* myPrs; + SALOME::GenericObjPtr myPrsCopy; }; diff --git a/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx b/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx index e45d8dad..3cd3a6f2 100644 --- a/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx +++ b/src/VISUGUI/VisuGUI_DeformedShapeDlg.cxx @@ -32,6 +32,7 @@ #include "VisuGUI_Tools.h" #include "VisuGUI_InputPane.h" +#include "VISU_ColoredPrs3dFactory.hh" #include "VISU_DeformedShape_i.hh" #include "SalomeApp_Module.h" @@ -50,8 +51,7 @@ using namespace std; * Constructor */ VisuGUI_DeformedShapeDlg::VisuGUI_DeformedShapeDlg (SalomeApp_Module* theModule) - : QDialog(VISU::GetDesktop(theModule), "VisuGUI_DeformedShapeDlg", false, - WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) + : VisuGUI_Prs3dDlg(theModule) { setCaption(tr("DLG_TITLE")); setSizeGripEnabled(TRUE); @@ -135,35 +135,44 @@ VisuGUI_DeformedShapeDlg::VisuGUI_DeformedShapeDlg (SalomeApp_Module* theModule) connect(buttonHelp, SIGNAL(clicked()), this, SLOT(onHelp())); } -void VisuGUI_DeformedShapeDlg::initFromPrsObject (VISU::DeformedShape_i* thePrs) +void VisuGUI_DeformedShapeDlg::initFromPrsObject (VISU::ColoredPrs3d_i* thePrs, bool theInit) { - myScalarPane->initFromPrsObject(thePrs); + if( theInit ) + myPrsCopy = VISU::TSameAsFactory().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish); - if( thePrs->IsTimeStampFixed() ) + myScalarPane->initFromPrsObject( myPrsCopy ); + + setFactor(myPrsCopy->GetScale()); + UseMagn->setChecked(myPrsCopy->IsColored()); + + if( !theInit ) + return; + + if( myPrsCopy->IsTimeStampFixed() ) myTabBox->removePage( myInputPane ); else { - myInputPane->initFromPrsObject( thePrs ); + myInputPane->initFromPrsObject( myPrsCopy ); myTabBox->showPage( myInputPane ); } myTabBox->setCurrentPage( 0 ); - - setFactor(thePrs->GetScale()); - UseMagn->setChecked(thePrs->IsColored()); } -int VisuGUI_DeformedShapeDlg::storeToPrsObject(VISU::DeformedShape_i* thePrs) { - myScalarPane->storeToPrsObject(thePrs); +int VisuGUI_DeformedShapeDlg::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) { + myScalarPane->storeToPrsObject(myPrsCopy); - if( !thePrs->IsTimeStampFixed() ) + if( !myPrsCopy->IsTimeStampFixed() ) { if( !myInputPane->check() ) return 0; - myInputPane->storeToPrsObject( thePrs ); + myInputPane->storeToPrsObject( myPrsCopy ); } - thePrs->SetScale(getFactor()); - thePrs->ShowColored(isColored()); + myPrsCopy->SetScale(getFactor()); + myPrsCopy->ShowColored(isColored()); + + VISU::TSameAsFactory().Copy(thePrs, myPrsCopy); + return 1; } diff --git a/src/VISUGUI/VisuGUI_DeformedShapeDlg.h b/src/VISUGUI/VisuGUI_DeformedShapeDlg.h index f23aa192..5d77bf71 100644 --- a/src/VISUGUI/VisuGUI_DeformedShapeDlg.h +++ b/src/VISUGUI/VisuGUI_DeformedShapeDlg.h @@ -29,7 +29,7 @@ #ifndef VISUGUI_DEFORMEDSHAPEDLS_H #define VISUGUI_DEFORMEDSHAPEDLS_H -#include "VisuGUI_ScalarBarDlg.h" +#include "VisuGUI_Prs3dDlg.h" #include "QtxDblSpinBox.h" @@ -47,7 +47,7 @@ namespace VISU{ class DeformedShape_i; } -class VisuGUI_DeformedShapeDlg : public QDialog +class VisuGUI_DeformedShapeDlg : public VisuGUI_Prs3dDlg { Q_OBJECT @@ -63,8 +63,8 @@ public: bool isColored() { return UseMagn->isChecked(); } - void initFromPrsObject(VISU::DeformedShape_i* thePrs); - int storeToPrsObject(VISU::DeformedShape_i* thePrs); + virtual void initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit = true); + virtual int storeToPrsObject(VISU::ColoredPrs3d_i* thePrs); private: void keyPressEvent( QKeyEvent* e ); @@ -80,6 +80,7 @@ protected slots: QTabWidget* myTabBox; VisuGUI_ScalarBarPane* myScalarPane; VisuGUI_InputPane* myInputPane; + SALOME::GenericObjPtr myPrsCopy; }; #endif // VISUGUI_DEFORMEDSHAPEDLS_H diff --git a/src/VISUGUI/VisuGUI_FieldFilter.cxx b/src/VISUGUI/VisuGUI_FieldFilter.cxx index 88c3e3b5..3dd45bb1 100644 --- a/src/VISUGUI/VisuGUI_FieldFilter.cxx +++ b/src/VISUGUI/VisuGUI_FieldFilter.cxx @@ -39,10 +39,8 @@ using namespace VISU; -VisuGUI_FieldFilter::VisuGUI_FieldFilter( VISU::VISUType theType, - const QString& thePrs3dEntry ) : - myType( theType ), - myPrs3dEntry( thePrs3dEntry ) +VisuGUI_FieldFilter::VisuGUI_FieldFilter( VISU::VISUType theType ) : + myType( theType ) { } @@ -50,6 +48,11 @@ VisuGUI_FieldFilter::~VisuGUI_FieldFilter() { } +void VisuGUI_FieldFilter::setPrs3dEntry( const QString& theEntry ) +{ + myPrs3dEntry = theEntry; +} + bool VisuGUI_FieldFilter::isOk( const SUIT_DataOwner* theDataOwner ) const { const LightApp_DataOwner* anOwner = diff --git a/src/VISUGUI/VisuGUI_FieldFilter.h b/src/VISUGUI/VisuGUI_FieldFilter.h index 21e21aa6..faec6f00 100644 --- a/src/VISUGUI/VisuGUI_FieldFilter.h +++ b/src/VISUGUI/VisuGUI_FieldFilter.h @@ -33,12 +33,14 @@ class SUIT_DataOwner; class VisuGUI_FieldFilter : public SUIT_SelectionFilter { public: - VisuGUI_FieldFilter( VISU::VISUType theType, - const QString& thePrs3dEntry ); + VisuGUI_FieldFilter( VISU::VISUType theType ); ~VisuGUI_FieldFilter(); +public: virtual bool isOk( const SUIT_DataOwner* ) const; + void setPrs3dEntry( const QString& theEntry ); + private: VISU::VISUType myType; QString myPrs3dEntry; diff --git a/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx b/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx index 17f0d172..ce78dfa5 100644 --- a/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx +++ b/src/VISUGUI/VisuGUI_GaussPointsDlg.cxx @@ -32,6 +32,7 @@ #include "VisuGUI_Tools.h" #include "VisuGUI_InputPane.h" +#include "VISU_ColoredPrs3dFactory.hh" #include "VISU_GaussPoints_i.hh" #include "VISU_GaussPointsPL.hxx" #include "VISU_OpenGLPointSpriteMapper.hxx" @@ -48,6 +49,8 @@ #include "SUIT_MessageBox.h" #include "SVTK_FontWidget.h" +#include "QtxDblSpinBox.h" + #include #include #include @@ -55,6 +58,15 @@ #include #include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include @@ -488,7 +500,7 @@ void VisuGUI_GaussScalarBarPane::setScalarBarData( int colors, int labels ) /*! Gets orientation */ -int VisuGUI_GaussScalarBarPane::getOrientation() +int VisuGUI_GaussScalarBarPane::getOrientation() { if (RBvert->isChecked() ) return 1; @@ -496,6 +508,36 @@ int VisuGUI_GaussScalarBarPane::getOrientation() return 0; } +/*! + Sets and gets parameters +*/ +double VisuGUI_GaussScalarBarPane::getX() { + return XSpin->value(); +} + +double VisuGUI_GaussScalarBarPane::getY() { + return YSpin->value(); +} + +double VisuGUI_GaussScalarBarPane::getWidth() { + return WidthSpin->value(); +} + +double VisuGUI_GaussScalarBarPane::getHeight() { + return HeightSpin->value(); +} + +int VisuGUI_GaussScalarBarPane::getNbColors() { + return ColorSpin->value(); +} + +int VisuGUI_GaussScalarBarPane::getNbLabels() { + return LabelSpin->value(); +} + +bool VisuGUI_GaussScalarBarPane::isToSave() { + return CBSave ? CBSave->isChecked() : false; +} void VisuGUI_GaussScalarBarPane::onTextPref() { @@ -507,10 +549,7 @@ void VisuGUI_GaussScalarBarPane::onTextPref() * Constructor */ VisuGUI_GaussPointsDlg::VisuGUI_GaussPointsDlg(SalomeApp_Module* theModule, bool SetPref): - QDialog(VISU::GetDesktop(theModule), - "VisuGUI_GaussPointsDlg", false, - WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu), - myPrs(NULL) + VisuGUI_Prs3dDlg(theModule) { setName("VisuGUI_ScalarBarDlg"); setCaption(SetPref ? tr("DLG_PREF_TITLE") : tr("DLG_PROP_TITLE")); @@ -611,98 +650,105 @@ VisuGUI_GaussPointsDlg::VisuGUI_GaussPointsDlg(SalomeApp_Module* theModule, bool connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( onHelp() ) ); } -void VisuGUI_GaussPointsDlg::initFromPrsObject( VISU::GaussPoints_i* thePrs ) +void VisuGUI_GaussPointsDlg::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit) { - bool isDeformed = thePrs->GetIsDeformed(); - myScaleSpinBox->setValue( thePrs->GetScaleFactor() ); + if( theInit ) + myPrsCopy = VISU::TSameAsFactory().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish); + + myScalarPane->initFromPrsObject( myPrsCopy ); + + bool isDeformed = myPrsCopy->GetIsDeformed(); + myScaleSpinBox->setValue( myPrsCopy->GetScaleFactor() ); myDefShapeButton->setChecked( isDeformed ); - myDefShapeButton->setEnabled( thePrs->GetField()->myNbComp > 1 ); + myDefShapeButton->setEnabled( myPrsCopy->GetField()->myNbComp > 1 ); onToggleDefShape( isDeformed ); - bool isResults = thePrs->GetIsColored(); + bool isResults = myPrsCopy->GetIsColored(); myResultsButton->setChecked( isResults && !isDeformed ); myGeometryButton->setChecked( !isResults && !isDeformed ); - myPrimitiveBox->setPrimitiveType( thePrs->GetPrimitiveType() ); - myPrimitiveBox->setClampMaximum( thePrs->GetMaximumSupportedSize() ); - myPrimitiveBox->setClamp( thePrs->GetClamp() ); - myPrimitiveBox->setMainTexture( thePrs->GetMainTexture() ); - myPrimitiveBox->setAlphaTexture( thePrs->GetAlphaTexture() ); - myPrimitiveBox->setAlphaThreshold( thePrs->GetAlphaThreshold() ); - myPrimitiveBox->setResolution( thePrs->GetResolution() ); - myPrimitiveBox->setFaceLimit( thePrs->GetFaceLimit() ); + myPrimitiveBox->setPrimitiveType( myPrsCopy->GetPrimitiveType() ); + myPrimitiveBox->setClampMaximum( myPrsCopy->GetMaximumSupportedSize() ); + myPrimitiveBox->setClamp( myPrsCopy->GetClamp() ); + myPrimitiveBox->setMainTexture( myPrsCopy->GetMainTexture() ); + myPrimitiveBox->setAlphaTexture( myPrsCopy->GetAlphaTexture() ); + myPrimitiveBox->setAlphaThreshold( myPrsCopy->GetAlphaThreshold() ); + myPrimitiveBox->setResolution( myPrsCopy->GetResolution() ); + myPrimitiveBox->setFaceLimit( myPrsCopy->GetFaceLimit() ); mySizeBox->setType( isResults || isDeformed ? VVTK_SizeBox::Results : VVTK_SizeBox::Geometry ); - mySizeBox->setGeomSize( thePrs->GetGeomSize() ); - mySizeBox->setMinSize( thePrs->GetMinSize() ); - mySizeBox->setMaxSize( thePrs->GetMaxSize() ); - mySizeBox->setMagnification( thePrs->GetMagnification() ); - mySizeBox->setIncrement( thePrs->GetMagnificationIncrement() ); - mySizeBox->setColor( thePrs->GetColor() ); - - myScalarPane->initFromPrsObject(thePrs); + mySizeBox->setGeomSize( myPrsCopy->GetGeomSize() ); + mySizeBox->setMinSize( myPrsCopy->GetMinSize() ); + mySizeBox->setMaxSize( myPrsCopy->GetMaxSize() ); + mySizeBox->setMagnification( myPrsCopy->GetMagnification() ); + mySizeBox->setIncrement( myPrsCopy->GetMagnificationIncrement() ); + mySizeBox->setColor( myPrsCopy->GetColor() ); + + if( !theInit ) + return; - if( thePrs->IsTimeStampFixed() ) + if( myPrsCopy->IsTimeStampFixed() ) myTabBox->removePage( myInputPane ); else { - myInputPane->initFromPrsObject( thePrs ); + myInputPane->initFromPrsObject( myPrsCopy ); myTabBox->showPage( myInputPane ); } myTabBox->setCurrentPage( 0 ); - - myPrs = thePrs; } -int VisuGUI_GaussPointsDlg::storeToPrsObject( VISU::GaussPoints_i* thePrs ) +int VisuGUI_GaussPointsDlg::storeToPrsObject( VISU::ColoredPrs3d_i* thePrs ) { - thePrs->SetIsDeformed( myDefShapeButton->isChecked() ); - thePrs->SetScaleFactor( myScaleSpinBox->value() ); + myPrsCopy->SetIsDeformed( myDefShapeButton->isChecked() ); + myPrsCopy->SetScaleFactor( myScaleSpinBox->value() ); - thePrs->SetPrimitiveType( myPrimitiveBox->getPrimitiveType() ); + myPrsCopy->SetPrimitiveType( myPrimitiveBox->getPrimitiveType() ); - thePrs->SetClamp( myPrimitiveBox->getClamp() ); + myPrsCopy->SetClamp( myPrimitiveBox->getClamp() ); QString aMainTexture = myPrimitiveBox->getMainTexture(); QString anAlphaTexture = myPrimitiveBox->getAlphaTexture(); - aMainTexture = aMainTexture.isNull() ? thePrs->GetMainTexture() : aMainTexture; - anAlphaTexture = anAlphaTexture.isNull() ? thePrs->GetAlphaTexture() : anAlphaTexture; + aMainTexture = aMainTexture.isNull() ? myPrsCopy->GetMainTexture() : aMainTexture; + anAlphaTexture = anAlphaTexture.isNull() ? myPrsCopy->GetAlphaTexture() : anAlphaTexture; - thePrs->SetTextures( aMainTexture, anAlphaTexture ); + myPrsCopy->SetTextures( aMainTexture, anAlphaTexture ); - thePrs->SetAlphaThreshold( myPrimitiveBox->getAlphaThreshold() ); + myPrsCopy->SetAlphaThreshold( myPrimitiveBox->getAlphaThreshold() ); - thePrs->SetResolution( myPrimitiveBox->getResolution() ); - thePrs->SetFaceLimit( myPrimitiveBox->getFaceLimit() ); + myPrsCopy->SetResolution( myPrimitiveBox->getResolution() ); + myPrsCopy->SetFaceLimit( myPrimitiveBox->getFaceLimit() ); bool isColored = !myGeometryButton->isChecked(); if( isColored ) { - thePrs->SetIsColored( true ); - thePrs->SetMinSize( mySizeBox->getMinSize() ); - thePrs->SetMaxSize( mySizeBox->getMaxSize() ); + myPrsCopy->SetIsColored( true ); + myPrsCopy->SetMinSize( mySizeBox->getMinSize() ); + myPrsCopy->SetMaxSize( mySizeBox->getMaxSize() ); } else { - thePrs->SetIsColored( false ); - thePrs->SetColor( mySizeBox->getColor() ); - thePrs->SetGeomSize( mySizeBox->getGeomSize() ); + myPrsCopy->SetIsColored( false ); + myPrsCopy->SetColor( mySizeBox->getColor() ); + myPrsCopy->SetGeomSize( mySizeBox->getGeomSize() ); } - thePrs->SetMagnification( mySizeBox->getMagnification() ); - thePrs->SetMagnificationIncrement( mySizeBox->getIncrement() ); + myPrsCopy->SetMagnification( mySizeBox->getMagnification() ); + myPrsCopy->SetMagnificationIncrement( mySizeBox->getIncrement() ); int ok = 1; - if( !thePrs->IsTimeStampFixed() ) + if( !myPrsCopy->IsTimeStampFixed() ) { if( !myInputPane->check() ) return 0; - ok = myInputPane->storeToPrsObject( thePrs ); + ok = myInputPane->storeToPrsObject( myPrsCopy ); } + ok = ok && myScalarPane->storeToPrsObject( myPrsCopy ); + + VISU::TSameAsFactory().Copy(thePrs, myPrsCopy); - return ok && myScalarPane->storeToPrsObject(thePrs); + return ok; } void VisuGUI_GaussPointsDlg::onToggleDefShape( bool on ) @@ -718,10 +764,10 @@ void VisuGUI_GaussPointsDlg::onToggleDefShape( bool on ) void VisuGUI_GaussPointsDlg::accept() { - if( myPrs && myPrimitiveBox->getPrimitiveType() == VISU_OpenGLPointSpriteMapper::GeomSphere ) + if( myPrsCopy && myPrimitiveBox->getPrimitiveType() == VISU_OpenGLPointSpriteMapper::GeomSphere ) { int aNumberOfFaces = myPrimitiveBox->getFaceNumber(); - int aNumberOfPoints = ( (vtkPolyData*)myPrs->GetSpecificPL()->GetInput() )->GetNumberOfCells(); + int aNumberOfPoints = ( (vtkPolyData*)myPrsCopy->GetSpecificPL()->GetInput() )->GetNumberOfCells(); if( aNumberOfFaces * aNumberOfPoints > myPrimitiveBox->getFaceLimit() ) { diff --git a/src/VISUGUI/VisuGUI_GaussPointsDlg.h b/src/VISUGUI/VisuGUI_GaussPointsDlg.h index 44d16e86..592ac66f 100644 --- a/src/VISUGUI/VisuGUI_GaussPointsDlg.h +++ b/src/VISUGUI/VisuGUI_GaussPointsDlg.h @@ -28,21 +28,11 @@ #ifndef VISUGUI_GAUSSPOINTSDLS_H #define VISUGUI_GAUSSPOINTSDLS_H -#include "VisuGUI_ScalarBarDlg.h" +#include "VisuGUI_Prs3dDlg.h" #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include + +class QtxDblSpinBox; class SalomeApp_Module; class VVTK_PrimitiveBox; @@ -67,14 +57,14 @@ class VisuGUI_GaussScalarBarPane : public QVBox int getOrientation(); void setPosAndSize( double x, double y, double w, double h, bool vert ); - double getX() {return XSpin->value();} - double getY() {return YSpin->value();} - double getWidth() {return WidthSpin->value();} - double getHeight() {return HeightSpin->value();} void setScalarBarData( int colors, int labels ); - int getNbColors() {return ColorSpin->value();} - int getNbLabels() {return LabelSpin->value();} - bool isToSave() {return CBSave ? CBSave->isChecked() : false;} + double getX(); + double getY(); + double getWidth(); + double getHeight(); + int getNbColors(); + int getNbLabels(); + bool isToSave(); void initFromPrsObject(VISU::GaussPoints_i* thePrs); int storeToPrsObject(VISU::GaussPoints_i* thePrs); @@ -127,7 +117,7 @@ class VisuGUI_GaussScalarBarPane : public QVBox * Uses for set up initial parameters of the Gauss Points * presentation and edit them interactively. */ -class VisuGUI_GaussPointsDlg : public QDialog +class VisuGUI_GaussPointsDlg : public VisuGUI_Prs3dDlg { Q_OBJECT @@ -136,10 +126,10 @@ public: ~VisuGUI_GaussPointsDlg() {} //! Initializing dialog from the Gauss Points presentation. - void initFromPrsObject(VISU::GaussPoints_i* thePrs); + virtual void initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit = true); //! Update Gauss Points presentation using parameters from the dialog. - int storeToPrsObject(VISU::GaussPoints_i* thePrs); + virtual int storeToPrsObject(VISU::ColoredPrs3d_i* thePrs); private: void keyPressEvent( QKeyEvent* e ); @@ -151,8 +141,6 @@ protected slots: void accept(); private: - VISU::GaussPoints_i* myPrs; - QTabWidget* myTabBox; VisuGUI_GaussScalarBarPane* myScalarPane; VisuGUI_InputPane* myInputPane; @@ -166,6 +154,8 @@ private: QGroupBox* myDefShapeBox; QtxDblSpinBox* myScaleSpinBox; + + SALOME::GenericObjPtr myPrsCopy; }; #endif // VISUGUI_GAUSSPOINTSDLS_H diff --git a/src/VISUGUI/VisuGUI_InputPane.cxx b/src/VISUGUI/VisuGUI_InputPane.cxx index db400a6d..589a0d2e 100644 --- a/src/VISUGUI/VisuGUI_InputPane.cxx +++ b/src/VISUGUI/VisuGUI_InputPane.cxx @@ -27,6 +27,7 @@ #include "VisuGUI_InputPane.h" +#include "VisuGUI_Prs3dDlg.h" #include "VisuGUI_FieldFilter.h" #include "VisuGUI_Tools.h" @@ -45,6 +46,7 @@ #include "SALOMEDSClient_AttributeComment.hxx" #include "SALOMEDSClient_AttributeName.hxx" +#include #include #include #include @@ -52,42 +54,53 @@ using namespace VISU; -VisuGUI_InputPane::VisuGUI_InputPane( VISU::VISUType theType, SalomeApp_Module* theModule, QWidget* parent ) : - QGroupBox( 2, Qt::Horizontal, parent ), - myModule( theModule ) +VisuGUI_InputPane::VisuGUI_InputPane( VISU::VISUType theType, + SalomeApp_Module* theModule, + VisuGUI_Prs3dDlg* theDialog ) : + QGroupBox( 2, Qt::Horizontal, theDialog ), + myModule( theModule ), + myDialog( theDialog ), + myPrs( NULL ) { setFrameStyle( QFrame::Box | QFrame::Sunken ); connect( GetSelectionMgr( theModule ), SIGNAL( selectionChanged() ), SLOT( onSelectionChanged() ) ); - new QLabel( "Med File : ", this ); + new QLabel( tr( "MED_FILE" ), this ); myMedFile = new QLineEdit( this ); myMedFile->setReadOnly( true ); myMedFile->setEnabled( false ); myMedFile->setPaletteForegroundColor( Qt::black ); - new QLabel( "Mesh : ", this ); + new QLabel( tr( "MESH" ), this ); myMeshName = new QLineEdit( this ); myMeshName->setReadOnly( true ); myMeshName->setEnabled( false ); myMeshName->setPaletteForegroundColor( Qt::black ); - new QLabel( "Entity : ", this ); + new QLabel( tr( "ENTITY" ), this ); myEntityName = new QLineEdit( this ); myEntityName->setReadOnly( true ); myEntityName->setEnabled( false ); myEntityName->setPaletteForegroundColor( Qt::black ); - new QLabel( "Field : ", this ); + new QLabel( tr( "FIELD" ), this ); myFieldName = new QLineEdit( this ); myFieldName->setReadOnly( true ); - new QLabel( "Time Stamp : ", this ); + new QLabel( tr( "TIME_STAMP" ), this ); myTimeStamps = new QComboBox( this ); - myFieldFilter = 0; + myReInit = new QCheckBox( tr( "REINITIALIZE" ), this ); + myReInit->setChecked( true ); + + connect( myReInit, SIGNAL( toggled( bool ) ), SLOT( onReInitialize( bool ) ) ); + onSelectionChanged(); + myFieldFilter = new VisuGUI_FieldFilter( theType ); + GetSelectionMgr( myModule )->installFilter( myFieldFilter ); + hide(); } @@ -187,13 +200,33 @@ void VisuGUI_InputPane::onSelectionChanged() myEntityName->setText( anEntityName ); myFieldName->setText( aFieldName ); myTimeStamps->setCurrentItem( 0 ); + + if( myReInit->isChecked() && myPrs ) + { + myPrs->SetResultObject( myResult ); + myPrs->SetMeshName( aMeshName.latin1() ); + myPrs->SetEntity( VISU::Entity( myEntity ) ); + myPrs->SetFieldName( aFieldName.latin1() ); + myPrs->SetTimeStampNumber( myPrs->GetTimeStampNumberByIndex( 0 ) ); + myPrs->Apply( true ); + + myDialog->initFromPrsObject( myPrs, false ); + } } } +void VisuGUI_InputPane::onReInitialize( bool on ) +{ + if( on ) + onSelectionChanged(); +} + void VisuGUI_InputPane::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs ) { - myFieldFilter = new VisuGUI_FieldFilter( thePrs->GetType(), thePrs->GetHolderEntry() ); - GetSelectionMgr( myModule )->installFilter( myFieldFilter ); + if( myPrs == thePrs ) + return; + + myPrs = thePrs; clear(); @@ -228,6 +261,8 @@ void VisuGUI_InputPane::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs ) myMeshName->setText( thePrs->GetMeshName() ); myFieldName->setText( thePrs->GetFieldName() ); myTimeStamps->setCurrentItem( thePrs->GetTimeStampIndexByNumber( aTimeStampNumber ) ); + + myFieldFilter->setPrs3dEntry( thePrs->GetHolderEntry() ); } int VisuGUI_InputPane::storeToPrsObject( VISU::ColoredPrs3d_i* thePrs ) @@ -238,5 +273,5 @@ int VisuGUI_InputPane::storeToPrsObject( VISU::ColoredPrs3d_i* thePrs ) thePrs->SetEntity( VISU::Entity( myEntity ) ); thePrs->SetFieldName( myFieldName->text().latin1() ); thePrs->SetTimeStampNumber( thePrs->GetTimeStampNumberByIndex( myTimeStamps->currentItem() ) ); - return ( int )thePrs->Apply(); + return ( int )thePrs->Apply( false ); } diff --git a/src/VISUGUI/VisuGUI_InputPane.h b/src/VISUGUI/VisuGUI_InputPane.h index 6b257a23..279ff14f 100644 --- a/src/VISUGUI/VisuGUI_InputPane.h +++ b/src/VISUGUI/VisuGUI_InputPane.h @@ -32,12 +32,14 @@ #include +class QCheckBox; class QComboBox; class QLineEdit; class SalomeApp_Module; class LightApp_SelectionMgr; +class VisuGUI_Prs3dDlg; class VisuGUI_FieldFilter; namespace VISU @@ -51,7 +53,9 @@ class VisuGUI_InputPane : public QGroupBox Q_OBJECT public: - VisuGUI_InputPane( VISU::VISUType theType, SalomeApp_Module* theModule, QWidget* parent ); + VisuGUI_InputPane( VISU::VISUType theType, + SalomeApp_Module* theModule, + VisuGUI_Prs3dDlg* theDialog ); virtual ~VisuGUI_InputPane(); public: @@ -63,15 +67,19 @@ public: public slots: virtual void onSelectionChanged(); + virtual void onReInitialize( bool ); private: SalomeApp_Module* myModule; + VisuGUI_Prs3dDlg* myDialog; + VISU::ColoredPrs3d_i* myPrs; QLineEdit* myMedFile; QLineEdit* myMeshName; QLineEdit* myEntityName; QLineEdit* myFieldName; QComboBox* myTimeStamps; + QCheckBox* myReInit; VISU::Result_var myResult; int myEntity; diff --git a/src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx b/src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx index 3df24940..8f218955 100644 --- a/src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx +++ b/src/VISUGUI/VisuGUI_IsoSurfacesDlg.cxx @@ -32,6 +32,8 @@ #include "VisuGUI_Tools.h" #include "VisuGUI_InputPane.h" +#include "VISU_ColoredPrs3dFactory.hh" + #include "LightApp_Application.h" #include "SUIT_Desktop.h" @@ -165,8 +167,7 @@ bool VisuGUI_IsoSurfPane::check() Constructor */ VisuGUI_IsoSurfacesDlg::VisuGUI_IsoSurfacesDlg (SalomeApp_Module* theModule) - : QDialog(VISU::GetDesktop(theModule), "VisuGUI_IsoSurfacesDlg", false, - WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) + : VisuGUI_Prs3dDlg(theModule) { setCaption(tr("DEFINE_ISOSURFACES")); setSizeGripEnabled( TRUE ); @@ -233,33 +234,43 @@ void VisuGUI_IsoSurfacesDlg::reject() QDialog::reject(); } -void VisuGUI_IsoSurfacesDlg::initFromPrsObject(VISU::IsoSurfaces_i* thePrs) +void VisuGUI_IsoSurfacesDlg::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit) { - myScalarPane->initFromPrsObject(thePrs); - myIsoPane->initFromPrsObject(thePrs); + if( theInit ) + myPrsCopy = VISU::TSameAsFactory().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish); + + myScalarPane->initFromPrsObject(myPrsCopy); + myIsoPane->initFromPrsObject(myPrsCopy); + + if( !theInit ) + return; - if( thePrs->IsTimeStampFixed() ) + if( myPrsCopy->IsTimeStampFixed() ) myTabBox->removePage( myInputPane ); else { - myInputPane->initFromPrsObject( thePrs ); + myInputPane->initFromPrsObject( myPrsCopy ); myTabBox->showPage( myInputPane ); } myTabBox->setCurrentPage( 0 ); } -int VisuGUI_IsoSurfacesDlg::storeToPrsObject(VISU::IsoSurfaces_i* thePrs) +int VisuGUI_IsoSurfacesDlg::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) { int ok = 1; - if( !thePrs->IsTimeStampFixed() ) + if( !myPrsCopy->IsTimeStampFixed() ) { if( !myInputPane->check() ) return 0; - ok = myInputPane->storeToPrsObject( thePrs ); + ok = myInputPane->storeToPrsObject( myPrsCopy ); } - return ok && myScalarPane->storeToPrsObject(thePrs) && myIsoPane->storeToPrsObject(thePrs); + ok = ok && myScalarPane->storeToPrsObject( myPrsCopy ) && myIsoPane->storeToPrsObject(myPrsCopy); + + VISU::TSameAsFactory().Copy(thePrs, myPrsCopy); + + return ok; } void VisuGUI_IsoSurfacesDlg::onHelp() diff --git a/src/VISUGUI/VisuGUI_IsoSurfacesDlg.h b/src/VISUGUI/VisuGUI_IsoSurfacesDlg.h index e97cae7a..82c37109 100644 --- a/src/VISUGUI/VisuGUI_IsoSurfacesDlg.h +++ b/src/VISUGUI/VisuGUI_IsoSurfacesDlg.h @@ -29,7 +29,7 @@ #ifndef VISUGUI_ISOSURFACESDLG_H #define VISUGUI_ISOSURFACESDLG_H -#include "VisuGUI_ScalarBarDlg.h" +#include "VisuGUI_Prs3dDlg.h" #include "VISU_IsoSurfaces_i.hh" #include @@ -71,7 +71,7 @@ class VisuGUI_IsoSurfPane : public QVBox }; -class VisuGUI_IsoSurfacesDlg : public QDialog +class VisuGUI_IsoSurfacesDlg : public VisuGUI_Prs3dDlg { Q_OBJECT; @@ -79,8 +79,8 @@ class VisuGUI_IsoSurfacesDlg : public QDialog VisuGUI_IsoSurfacesDlg (SalomeApp_Module* theModule); ~VisuGUI_IsoSurfacesDlg() {}; - void initFromPrsObject(VISU::IsoSurfaces_i* thePrs); - int storeToPrsObject(VISU::IsoSurfaces_i* thePrs); + virtual void initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit = true); + virtual int storeToPrsObject(VISU::ColoredPrs3d_i* thePrs); private: void keyPressEvent( QKeyEvent* e ); @@ -95,6 +95,8 @@ class VisuGUI_IsoSurfacesDlg : public QDialog VisuGUI_IsoSurfPane* myIsoPane; VisuGUI_ScalarBarPane* myScalarPane; VisuGUI_InputPane* myInputPane; + + SALOME::GenericObjPtr myPrsCopy; }; #endif // VISUGUI_ISOSURFACESDLG_H diff --git a/src/VISUGUI/VisuGUI_Plot3DDlg.cxx b/src/VISUGUI/VisuGUI_Plot3DDlg.cxx index 3c4ae0e9..c6a47d3d 100644 --- a/src/VISUGUI/VisuGUI_Plot3DDlg.cxx +++ b/src/VISUGUI/VisuGUI_Plot3DDlg.cxx @@ -33,6 +33,7 @@ #include "VisuGUI_ViewTools.h" #include "VisuGUI_InputPane.h" +#include "VISU_ColoredPrs3dFactory.hh" #include "VISU_ViewManager_i.hh" #include "VISU_Plot3DPL.hxx" @@ -45,9 +46,14 @@ #include "SUIT_ResourceMgr.h" #include "LightApp_Application.h" +#include "QtxDblSpinBox.h" + #include #include #include +#include +#include +#include #include #include @@ -543,8 +549,7 @@ void VisuGUI_Plot3DPane::setPlane(int theOrientation, double theXRotation, doubl //purpose : //======================================================================= VisuGUI_Plot3DDlg::VisuGUI_Plot3DDlg (SalomeApp_Module* theModule) - : QDialog(VISU::GetDesktop(theModule), "VisuGUI_Plot3DDlg", false, WStyle_Customize | - WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) + : VisuGUI_Prs3dDlg(theModule) { setCaption(tr("TITLE")); setSizeGripEnabled(TRUE); @@ -624,16 +629,22 @@ void VisuGUI_Plot3DDlg::reject() //function : initFromPrsObject //purpose : //======================================================================= -void VisuGUI_Plot3DDlg::initFromPrsObject (VISU::Plot3D_i* thePrs) +void VisuGUI_Plot3DDlg::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit) { - myScalarPane->initFromPrsObject(thePrs); - myIsoPane->initFromPrsObject(thePrs); + if( theInit ) + myPrsCopy = VISU::TSameAsFactory().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish); + + myScalarPane->initFromPrsObject(myPrsCopy); + myIsoPane->initFromPrsObject(myPrsCopy); - if( thePrs->IsTimeStampFixed() ) + if( !theInit ) + return; + + if( myPrsCopy->IsTimeStampFixed() ) myTabBox->removePage( myInputPane ); else { - myInputPane->initFromPrsObject( thePrs ); + myInputPane->initFromPrsObject( myPrsCopy ); myTabBox->showPage( myInputPane ); } myTabBox->setCurrentPage( 0 ); @@ -643,18 +654,21 @@ void VisuGUI_Plot3DDlg::initFromPrsObject (VISU::Plot3D_i* thePrs) //function : storeToPrsObject //purpose : //======================================================================= -int VisuGUI_Plot3DDlg::storeToPrsObject (VISU::Plot3D_i* thePrs) +int VisuGUI_Plot3DDlg::storeToPrsObject (VISU::ColoredPrs3d_i* thePrs) { int ok = 1; - if( !thePrs->IsTimeStampFixed() ) + if( !myPrsCopy->IsTimeStampFixed() ) { if( !myInputPane->check() ) return 0; - ok = myInputPane->storeToPrsObject( thePrs ); + ok = myInputPane->storeToPrsObject( myPrsCopy ); } + ok = ok && myScalarPane->storeToPrsObject(myPrsCopy) && myIsoPane->storeToPrsObject(myPrsCopy); + + VISU::TSameAsFactory().Copy(thePrs, myPrsCopy); - return ok && myScalarPane->storeToPrsObject(thePrs) && myIsoPane->storeToPrsObject(thePrs); + return ok; } //======================================================================= diff --git a/src/VISUGUI/VisuGUI_Plot3DDlg.h b/src/VISUGUI/VisuGUI_Plot3DDlg.h index 980ef980..bd49e03c 100644 --- a/src/VISUGUI/VisuGUI_Plot3DDlg.h +++ b/src/VISUGUI/VisuGUI_Plot3DDlg.h @@ -29,7 +29,7 @@ #ifndef VISUGUI_PLOT3D_H #define VISUGUI_PLOT3D_H -#include "VisuGUI_ScalarBarDlg.h" +#include "VisuGUI_Prs3dDlg.h" #include "VISU_Plot3D_i.hh" @@ -97,7 +97,7 @@ class VisuGUI_Plot3DPane : public QVBox }; -class VisuGUI_Plot3DDlg : public QDialog +class VisuGUI_Plot3DDlg : public VisuGUI_Prs3dDlg { Q_OBJECT @@ -105,8 +105,8 @@ class VisuGUI_Plot3DDlg : public QDialog VisuGUI_Plot3DDlg (SalomeApp_Module* theModule); ~VisuGUI_Plot3DDlg() {}; - void initFromPrsObject (VISU::Plot3D_i* thePrs); - int storeToPrsObject (VISU::Plot3D_i* thePrs); + virtual void initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit = true); + virtual int storeToPrsObject(VISU::ColoredPrs3d_i* thePrs); void setPlane(int theOrientation, double theXRotation, double theYRotation, double thePlanePos); @@ -123,6 +123,8 @@ class VisuGUI_Plot3DDlg : public QDialog VisuGUI_Plot3DPane* myIsoPane; VisuGUI_ScalarBarPane* myScalarPane; VisuGUI_InputPane* myInputPane; + + SALOME::GenericObjPtr myPrsCopy; }; #endif // VISUGUI_PLOT3D_H diff --git a/src/VISUGUI/VisuGUI_Prs3dDlg.cxx b/src/VISUGUI/VisuGUI_Prs3dDlg.cxx new file mode 100644 index 00000000..ad12a031 --- /dev/null +++ b/src/VISUGUI/VisuGUI_Prs3dDlg.cxx @@ -0,0 +1,1307 @@ +// 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_Prs3dDlg.cxx +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU + +#include "VisuGUI_Prs3dDlg.h" + +#include "VisuGUI.h" +#include "VisuGUI_Tools.h" +#include "VisuGUI_ViewTools.h" +#include "VisuGUI_InputPane.h" + +#include "SVTK_ViewWindow.h" +#include "SVTK_FontWidget.h" + +#include "VISUConfig.hh" +#include "VISU_Convertor.hxx" +#include "VISU_ScalarMapPL.hxx" +#include "VISU_ScalarMapAct.h" +#include "VISU_ScalarMap_i.hh" +#include "VISU_Result_i.hh" + +#include "LightApp_Application.h" + +#include "SUIT_Session.h" +#include "SUIT_MessageBox.h" +#include "SUIT_ResourceMgr.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "QtxDblSpinBox.h" + +#include + +#include + +using namespace std; + +//----------------------------------------------------------------------- +// Text Preferences Dialog +//----------------------------------------------------------------------- + +/*! + Constructor +*/ +VisuGUI_TextPrefDlg::VisuGUI_TextPrefDlg (QWidget* parent) + : QDialog(parent, 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) +{ + setName("VisuGUI_TextPrefDlg"); + setCaption(tr("TIT_TEXT_PREF")); + setSizeGripEnabled(TRUE); + + QVBoxLayout* TopLayout = new QVBoxLayout(this); + TopLayout->setSpacing(6); + TopLayout->setMargin(11); + + // "Title" grp + QGroupBox* aTitleGrp = new QGroupBox (2, Qt::Vertical, tr("LBL_TITLE"), this); + + // edit line + myTitleEdt = new QLineEdit (aTitleGrp); + + // font + QHBox* aHBox = new QHBox (aTitleGrp); + aHBox->setSpacing(5); + myTitleFont = new SVTK_FontWidget (aHBox); + + TopLayout->addWidget(aTitleGrp); + + // "Labels" grp + QGroupBox* aLabelsGrp = new QGroupBox (1, Qt::Vertical, tr("LBL_LABELS"), this); + + // font + aHBox = new QHBox (aLabelsGrp); + aHBox->setSpacing(5); + myLabelFont = new SVTK_FontWidget (aHBox); + + TopLayout->addWidget(aLabelsGrp); + + // Common buttons =========================================================== + QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); + GroupButtons->setColumnLayout(0, Qt::Vertical ); + GroupButtons->layout()->setSpacing( 0 ); + GroupButtons->layout()->setMargin( 0 ); + QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); + GroupButtonsLayout->setAlignment( Qt::AlignTop ); + GroupButtonsLayout->setSpacing( 6 ); + GroupButtonsLayout->setMargin( 11 ); + + QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" ); + buttonOk->setAutoDefault( TRUE ); + buttonOk->setDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); + GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); + + QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" ); + buttonCancel->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonCancel, 0, 2 ); + + QPushButton* buttonHelp = new QPushButton( tr( "&Help" ) , GroupButtons, "buttonHelp" ); + buttonHelp->setAutoDefault( TRUE ); + GroupButtonsLayout->addWidget( buttonHelp, 0, 3 ); + + TopLayout->addWidget( GroupButtons ); + + connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept())); + connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject())); + connect(buttonHelp, SIGNAL(clicked()), this, SLOT(onHelp())); +} + +QString VisuGUI_TextPrefDlg::getTitleText() +{ + return myTitleEdt->text(); +} + +void VisuGUI_TextPrefDlg::setTitleText(QString theText) +{ + myTitleEdt->setText(theText); +} + +void VisuGUI_TextPrefDlg::setTitleVisible(bool isVisible) +{ + if(isVisible) + myTitleEdt->show(); + else + myTitleEdt->hide(); +} + +void VisuGUI_TextPrefDlg::onHelp() +{ + QString aHelpFileName = "/files/scalar_map_presentation.htm"; + LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication()); + if (app) { + VisuGUI* aVisuGUI = dynamic_cast( app->activeModule() ); + app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName); + } + else { + SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"), + QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). + arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(aHelpFileName), + QObject::tr("BUT_OK")); + } +} + +void VisuGUI_TextPrefDlg::storeBeginValues() +{ + myTitle = myTitleEdt->text(); + myTitleFont->GetData(myColors[0], myComboVals[0], myCheckVals[0], myCheckVals[1], myCheckVals[2]); + myLabelFont->GetData(myColors[1], myComboVals[1], myCheckVals[3], myCheckVals[4], myCheckVals[5]); +} + +/*! + Called when button is clicked, restore begin values +*/ +void VisuGUI_TextPrefDlg::reject() +{ + myTitleEdt->setText(myTitle); + myTitleFont->SetData(myColors[0], myComboVals[0], myCheckVals[0], myCheckVals[1], myCheckVals[2]); + myLabelFont->SetData(myColors[1], myComboVals[1], myCheckVals[3], myCheckVals[4], myCheckVals[5]); + + QDialog::reject(); +} +/*! + Called when button is clicked, store begin values +*/ +void VisuGUI_TextPrefDlg::accept() +{ + storeBeginValues(); + + QDialog::accept(); +} + +/*! + Provides help on F1 button click +*/ +void VisuGUI_TextPrefDlg::keyPressEvent( QKeyEvent* e ) +{ + QDialog::keyPressEvent( e ); + if ( e->isAccepted() ) + return; + + if ( e->key() == Key_F1 ) + { + e->accept(); + onHelp(); + } +} + +//----------------------------------------------------------------------- +// Scalar Bar Pane +//----------------------------------------------------------------------- + +/*! + Constructor +*/ +VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane (QWidget * parent, bool SetPref): + QVBox(parent), myPreviewActor(0) +{ + SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); + QString propertyName; + propertyName = QString("scalar_bar_vertical_"); + myVerX = aResourceMgr->doubleValue("VISU", propertyName + "x", 0.); + myVerY = aResourceMgr->doubleValue("VISU", propertyName + "y", 0.); + myVerW = aResourceMgr->doubleValue("VISU", propertyName + "width", 0.); + myVerH = aResourceMgr->doubleValue("VISU", propertyName + "height",0.); + + propertyName = QString("scalar_bar_horizontal_"); + myHorX = aResourceMgr->doubleValue("VISU", propertyName + "x", 0.); + myHorY = aResourceMgr->doubleValue("VISU", propertyName + "y", 0.); + myHorW = aResourceMgr->doubleValue("VISU", propertyName + "width", 0.); + myHorH = aResourceMgr->doubleValue("VISU", propertyName + "height",0.); + + Imin = 0.0; Imax = 0.0; /*Fmin = 0.0; Fmax = 0.0;*/ Rmin = 0.0; Rmax = 0.0; + myRangeMode = -1; + + setSpacing(6); + //setMargin(11); + + // Range ============================================================ + RangeGroup = new QButtonGroup (tr("SCALAR_RANGE_GRP"), this, "RangeGroup"); + RangeGroup->setColumnLayout(0, Qt::Vertical ); + RangeGroup->layout()->setSpacing( 0 ); + RangeGroup->layout()->setMargin( 0 ); + QGridLayout* RangeGroupLayout = new QGridLayout( RangeGroup->layout() ); + RangeGroupLayout->setAlignment( Qt::AlignTop ); + RangeGroupLayout->setSpacing( 6 ); + RangeGroupLayout->setMargin( 11 ); + + myModeLbl = new QLabel("Scalar Mode", RangeGroup); + + myModeCombo = new QComboBox(RangeGroup); + + CBLog = new QCheckBox (tr("LOGARITHMIC_SCALING"), RangeGroup); + CBLog->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + + RBFrange = new QRadioButton (tr("FIELD_RANGE_BTN"), RangeGroup, "RBFrange"); + RBIrange = new QRadioButton (tr("IMPOSED_RANGE_BTN"), RangeGroup, "RBIrange"); + RBFrange->setChecked( true ); + + 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("LBL_MIN"), RangeGroup, "MinLabel"); + MinLabel->setBuddy(MinEdit); + + 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("LBL_MAX"), RangeGroup, "MaxLabel"); + MaxLabel->setBuddy(MaxEdit); + + RangeGroupLayout->addWidget( myModeLbl, 0, 0 ); + RangeGroupLayout->addMultiCellWidget( myModeCombo, 0, 0, 1, 3); + RangeGroupLayout->addMultiCellWidget( CBLog, 1, 1, 0, 3); + RangeGroupLayout->addMultiCellWidget( RBFrange, 2, 2, 0, 1); + RangeGroupLayout->addMultiCellWidget( RBIrange, 2, 2, 2, 3); + RangeGroupLayout->addWidget( MinLabel, 3, 0 ); + RangeGroupLayout->addWidget( MinEdit, 3, 1 ); + RangeGroupLayout->addWidget( MaxLabel, 3, 2 ); + RangeGroupLayout->addWidget( MaxEdit, 3, 3 ); + + //TopLayout->addWidget( RangeGroup ); + + // Colors and Labels ======================================================== + QGroupBox* ColLabGroup = new QGroupBox (tr("COLORS_LABELS_GRP"), this, "ColLabGroup"); + ColLabGroup->setColumnLayout(0, Qt::Vertical ); + ColLabGroup->layout()->setSpacing( 0 ); + ColLabGroup->layout()->setMargin( 0 ); + QGridLayout* ColLabGroupLayout = new QGridLayout( ColLabGroup->layout() ); + ColLabGroupLayout->setAlignment( Qt::AlignTop ); + ColLabGroupLayout->setSpacing( 6 ); + ColLabGroupLayout->setMargin( 11 ); + + QLabel* ColorLabel = new QLabel (tr("LBL_NB_COLORS"), ColLabGroup, "ColorLabel"); + ColorSpin = new QSpinBox( 2, 256, 1, ColLabGroup ); + ColorSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + ColorSpin->setMinimumWidth( 70 ); + ColorSpin->setValue( 64 ); + + QLabel* LabelLabel = new QLabel (tr("LBL_NB_LABELS"), ColLabGroup, "LabelLabel"); + LabelSpin = new QSpinBox( 2, 65, 1, ColLabGroup ); + LabelSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + LabelSpin->setMinimumWidth( 70 ); + LabelSpin->setValue( 5 ); + + ColLabGroupLayout->addWidget( ColorLabel, 0, 0); + ColLabGroupLayout->addWidget( ColorSpin, 0, 1); + ColLabGroupLayout->addWidget( LabelLabel, 0, 2); + ColLabGroupLayout->addWidget( LabelSpin, 0, 3); + + //TopLayout->addWidget( ColLabGroup ); + + // Orientation ========================================================== + QButtonGroup* OrientGroup = new QButtonGroup (tr("ORIENTATION_GRP"), this, "OrientGroup"); + OrientGroup->setColumnLayout(0, Qt::Vertical ); + OrientGroup->layout()->setSpacing( 0 ); + OrientGroup->layout()->setMargin( 0 ); + QGridLayout* OrientGroupLayout = new QGridLayout( OrientGroup->layout() ); + OrientGroupLayout->setAlignment( Qt::AlignTop ); + OrientGroupLayout->setSpacing( 6 ); + OrientGroupLayout->setMargin( 11 ); + + RBvert = new QRadioButton (tr("VERTICAL_BTN"), OrientGroup, "RBvert"); + RBvert->setChecked( true ); + RBhori = new QRadioButton (tr("HORIZONTAL_BTN"), OrientGroup, "RBhori"); + OrientGroupLayout->addWidget( RBvert, 0, 0 ); + OrientGroupLayout->addWidget( RBhori, 0, 1 ); + + // TopLayout->addWidget( OrientGroup ); + + // Origin =============================================================== + QGroupBox* OriginGroup = new QGroupBox (tr("ORIGIN_GRP"), this, "OriginGroup"); + OriginGroup->setColumnLayout(0, Qt::Vertical ); + OriginGroup->layout()->setSpacing( 0 ); + OriginGroup->layout()->setMargin( 0 ); + QGridLayout* OriginGroupLayout = new QGridLayout( OriginGroup->layout() ); + OriginGroupLayout->setAlignment( Qt::AlignTop ); + OriginGroupLayout->setSpacing( 6 ); + OriginGroupLayout->setMargin( 11 ); + + QLabel* XLabel = new QLabel (tr("LBL_X"), OriginGroup, "XLabel"); + XSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, OriginGroup ); + XSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + XSpin->setMinimumWidth( 70 ); + XSpin->setValue( 0.01 ); + + QLabel* YLabel = new QLabel (tr("LBL_Y"), OriginGroup, "YLabel"); + YSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, OriginGroup ); + YSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + YSpin->setMinimumWidth( 70 ); + YSpin->setValue( 0.01 ); + + OriginGroupLayout->addWidget( XLabel, 0, 0); + OriginGroupLayout->addWidget( XSpin, 0, 1); + OriginGroupLayout->addWidget( YLabel, 0, 2); + OriginGroupLayout->addWidget( YSpin, 0, 3); + + //TopLayout->addWidget( OriginGroup ); + + // Dimensions ========================================================= + QGroupBox* DimGroup = new QGroupBox (tr("DIMENSIONS_GRP"), this, "DimGroup"); + DimGroup->setColumnLayout(0, Qt::Vertical ); + DimGroup->layout()->setSpacing( 0 ); + DimGroup->layout()->setMargin( 0 ); + QGridLayout* DimGroupLayout = new QGridLayout( DimGroup->layout() ); + DimGroupLayout->setAlignment( Qt::AlignTop ); + DimGroupLayout->setSpacing( 6 ); + DimGroupLayout->setMargin( 11 ); + + QLabel* WidthLabel = new QLabel (tr("LBL_WIDTH"), DimGroup, "WidthLabel"); + WidthSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, DimGroup ); + WidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + WidthSpin->setMinimumWidth( 70 ); + WidthSpin->setValue( 0.1 ); + + QLabel* HeightLabel = new QLabel (tr("LBL_HEIGHT"), DimGroup, "HeightLabel"); + HeightSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, DimGroup ); + HeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); + HeightSpin->setMinimumWidth( 70 ); + HeightSpin->setValue( 0.8 ); + + DimGroupLayout->addWidget( WidthLabel, 0, 0); + DimGroupLayout->addWidget( WidthSpin, 0, 1); + DimGroupLayout->addWidget( HeightLabel, 0, 2); + DimGroupLayout->addWidget( HeightSpin, 0, 3); + + //TopLayout->addWidget( DimGroup ); + + // Save check box =========================================================== + QHBox* aSaveBox = new QHBox(this); + if (!SetPref) { + CBSave = new QCheckBox (tr("SAVE_DEFAULT_CHK"), aSaveBox, "CBSave"); + //TopLayout->addWidget(CBSave); + } + else { + CBSave = 0; + } + myTextBtn = new QPushButton("Text properties...", aSaveBox); + myTextDlg = new VisuGUI_TextPrefDlg(this); + myTextDlg->setTitleVisible(!SetPref); + + QGroupBox* CheckGroup = new QGroupBox("", this, "CheckGroup"); + CheckGroup->setColumnLayout(0, Qt::Vertical ); + CheckGroup->layout()->setSpacing( 0 ); + CheckGroup->layout()->setMargin( 0 ); + QGridLayout* CheckGroupLayout = new QGridLayout( CheckGroup->layout() ); + + myPreviewCheck = new QCheckBox(tr("LBL_SHOW_PREVIEW"), CheckGroup); + myPreviewCheck->setChecked(false); + CheckGroupLayout->addWidget(myPreviewCheck , 0, 0 ); + + // signals and slots connections =========================================== + connect( RangeGroup, SIGNAL( clicked( int ) ), this, SLOT( changeRange( int ) ) ); + connect( myModeCombo, SIGNAL( activated( int ) ), this, SLOT( changeScalarMode( int ) ) ); + connect( OrientGroup, SIGNAL( clicked( int ) ), this, SLOT( changeDefaults( int ) ) ); + connect( XSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) ); + connect( YSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) ); + connect( myTextBtn, SIGNAL( clicked() ), this, SLOT( onTextPref() ) ); + connect( myPreviewCheck, SIGNAL( toggled( bool )), this, SLOT( onPreviewCheck( bool ) ) ); + connect( ColorSpin, SIGNAL( valueChanged( int ) ), this, SLOT( updatePreview() )); + connect( LabelSpin, SIGNAL( valueChanged( int ) ), this, SLOT( updatePreview() )); + connect( WidthSpin, SIGNAL( valueChanged( double ) ), this, SLOT( updatePreview() )); + connect( HeightSpin, SIGNAL( valueChanged( double ) ), this, SLOT( updatePreview() )); + connect( CBLog, SIGNAL( toggled( bool ) ), this, SLOT( updatePreview() )); + changeRange( 0 ); + changeDefaults( 0 ); + myIsStoreTextProp = false; + myBusy = false; +} + +/** + * Initializes dialog box values from resources + */ +void VisuGUI_ScalarBarPane::initFromResources() { + int sbCol=64,sbLab=5,orient=0; + float sbX1=0.01,sbY1=0.1,sbW=0.1,sbH=0.8; + float sbVmin=0., sbVmax=0.; + bool sbRange=false; + QString aString; + + SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); + + bool anIsArrangeBar = aResourceMgr->booleanValue("VISU", "scalar_bars_default_position", 0); + int aPlace = 1; + if (anIsArrangeBar){ + aPlace = aResourceMgr->integerValue("VISU", "scalar_bar_position_num",0); + } + + int aScalarMode = aResourceMgr->integerValue("VISU", "scalar_bar_mode", 0); + myModeCombo->setCurrentItem(aScalarMode); + + orient = aResourceMgr->integerValue("VISU", "scalar_bar_orientation", orient); + if(orient != 0){ + orient=1; + sbX1=0.2; + sbY1=0.01; + sbW=0.6; + sbH=0.12; + } + + QString propertyName = QString( "scalar_bar_%1_" ).arg( orient == 0 ? "vertical" : "horizontal" ); + + sbX1 = aResourceMgr->doubleValue("VISU", propertyName + "x", sbX1); + sbY1 = aResourceMgr->doubleValue("VISU", propertyName + "y", sbY1); + + sbW = aResourceMgr->doubleValue("VISU", propertyName + "width", sbW); + sbH = aResourceMgr->doubleValue("VISU", propertyName + "height",sbH); + + if(orient){ + sbY1 += sbH*(aPlace-1); + } else { + sbX1 += sbW*(aPlace-1); + } + sbCol = aResourceMgr->integerValue("VISU" ,"scalar_bar_num_colors", sbCol); + sbLab = aResourceMgr->integerValue("VISU", "scalar_bar_num_labels", sbLab); + + int rangeType = aResourceMgr->integerValue("VISU" , "scalar_range_type", 0); + if (rangeType == 1) sbRange = true; + sbVmin = aResourceMgr->doubleValue("VISU", "scalar_range_min", sbVmin); + sbVmax = aResourceMgr->doubleValue("VISU", "scalar_range_max", sbVmax); + + bool isLog = aResourceMgr->booleanValue("VISU", "scalar_bar_logarithmic", false); + setLogarithmic(isLog); + + if((sbX1 < 0.) || (sbY1 < 0.) || + ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) { + if(orient == 0) { + sbX1=0.01; + sbY1=0.1; + sbW=0.1; + sbH=0.8; + } else { + sbX1=0.2; + sbY1=0.01; + sbW=0.6; + sbH=0.12; + } + } + if(sbCol < 2) sbCol=2; + if(sbCol > 64) sbCol=64; + if(sbLab < 2) sbLab=2; + if(sbLab > 65) sbLab=65; + + if(sbVmin > sbVmax) { + sbVmin=0.; + sbVmax=0.; + } + + setRange( sbVmin, sbVmax, /*0.0, 0.0,*/ sbRange ); + setPosAndSize( sbX1, sbY1, sbW, sbH, orient == 0); + setScalarBarData( sbCol, sbLab ); + + // "Title" + bool isBold = false, isItalic = false, isShadow = false; + int aFontFamily = VTK_ARIAL; + + if ( aResourceMgr->hasValue( "VISU", "scalar_bar_title_font" ) ) + { + QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_title_font" ); + + if ( f.family() == "Arial" ) + aFontFamily = VTK_ARIAL; + else if ( f.family() == "Courier" ) + aFontFamily = VTK_COURIER; + else if ( f.family() == "Times" ) + aFontFamily = VTK_TIMES; + + isBold = f.bold(); + isItalic = f.italic(); + isShadow = f.underline(); + } + + QColor aTextColor = aResourceMgr->colorValue( "VISU", "scalar_bar_title_color", QColor( 255, 255, 255 ) ); + + myTextDlg->myTitleFont->SetData(aTextColor, aFontFamily, isBold, isItalic, isShadow); + + // "Labels" + isBold = isItalic = isShadow = false; + aFontFamily = VTK_ARIAL; + + if ( aResourceMgr->hasValue( "VISU", "scalar_bar_label_font" ) ) + { + QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_label_font" ); + + if ( f.family() == "Arial" ) + aFontFamily = VTK_ARIAL; + else if ( f.family() == "Courier" ) + aFontFamily = VTK_COURIER; + else if ( f.family() == "Times" ) + aFontFamily = VTK_TIMES; + + isBold = f.bold(); + isItalic = f.italic(); + isShadow = f.underline(); + } + + aTextColor = aResourceMgr->colorValue( "VISU", "scalar_bar_label_color", QColor( 255, 255, 255 ) ); + + myTextDlg->myLabelFont->SetData(aTextColor, aFontFamily, isBold, isItalic, isShadow); +} + +/** + * Stores dialog values to resources + */ +void VisuGUI_ScalarBarPane::storeToResources() { + int orient = (RBvert->isChecked())? 0 : 1; + float sbX1 = XSpin->value(); + float sbY1 = YSpin->value(); + float sbW = WidthSpin->value(); + float sbH = HeightSpin->value(); + int sbCol = ColorSpin->value(); + int sbLab = LabelSpin->value(); + + if((sbX1 < 0.) || (sbY1 < 0.) || ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) { + if(orient == 0) { + sbX1=0.01; + sbY1=0.1; + sbW=0.17; + sbH=0.8; + } else { + sbX1=0.2; + sbY1=0.01; + sbW=0.6; + sbH=0.12; + } + } + + bool sbRange = RBIrange->isChecked(); + float sbVmin = (float)(MinEdit->text().toDouble()); + float sbVmax = (float)(MaxEdit->text().toDouble()); + + if(sbVmin > sbVmax) { + sbVmin=0.; + sbVmax=0.; + } + + SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); + + aResourceMgr->setValue("VISU", "scalar_bar_orientation", orient); + + QString propertyName = QString( "scalar_bar_%1_" ).arg( orient == 0 ? "vertical" : "horizontal" ); + + aResourceMgr->setValue("VISU", propertyName + "x", sbX1); + aResourceMgr->setValue("VISU", propertyName + "y", sbY1); + aResourceMgr->setValue("VISU", propertyName + "width", sbW); + aResourceMgr->setValue("VISU", propertyName + "height", sbH); + + aResourceMgr->setValue("VISU", "scalar_bar_num_colors", sbCol); + aResourceMgr->setValue("VISU", "scalar_bar_num_labels", sbLab); + + if(sbRange) + { + aResourceMgr->setValue("VISU", "scalar_range_type", 1); + aResourceMgr->setValue("VISU", "scalar_range_min" ,sbVmin); + aResourceMgr->setValue("VISU", "scalar_range_max" ,sbVmax); + } + else + aResourceMgr->setValue("VISU", "scalar_range_type", 0); + + aResourceMgr->setValue("VISU", "scalar_bar_logarithmic", isLogarithmic()); + + //// + + if (myIsStoreTextProp) { + // "Title" + QColor aTitleColor (255, 255, 255); + int aTitleFontFamily = VTK_ARIAL; + bool isTitleBold = false; + bool isTitleItalic = false; + bool isTitleShadow = false; + + myTextDlg->myTitleFont->GetData(aTitleColor, aTitleFontFamily, + isTitleBold, isTitleItalic, isTitleShadow); + + QFont aTitleFont; + + aTitleFont.setBold(isTitleBold); + aTitleFont.setItalic(isTitleItalic); + aTitleFont.setUnderline(isTitleShadow); + + QString titleFontFamily; + switch (aTitleFontFamily) { + case VTK_ARIAL: + titleFontFamily = "Arial"; + break; + case VTK_COURIER: + titleFontFamily = "Courier"; + break; + case VTK_TIMES: + titleFontFamily = "Times"; + break; + } + aTitleFont.setFamily(titleFontFamily); + + aResourceMgr->setValue("VISU", "scalar_bar_title_font", aTitleFont); + + aResourceMgr->setValue("VISU", "scalar_bar_title_color", aTitleColor); + + // "Label" + QColor aLabelColor (255, 255, 255); + int aLabelFontFamily = VTK_ARIAL; + bool isLabelBold = false; + bool isLabelItalic = false; + bool isLabelShadow = false; + + myTextDlg->myLabelFont->GetData(aLabelColor, aLabelFontFamily, + isLabelBold, isLabelItalic, isLabelShadow); + + + QFont aLabelFont; + + aLabelFont.setBold(isLabelBold); + aLabelFont.setItalic(isLabelItalic); + aLabelFont.setUnderline(isLabelShadow); + + QString labelFontFamily; + switch (aLabelFontFamily) { + case VTK_ARIAL: + labelFontFamily = "Arial"; + break; + case VTK_COURIER: + labelFontFamily = "Courier"; + break; + case VTK_TIMES: + labelFontFamily = "Times"; + break; + } + + aLabelFont.setFamily(labelFontFamily); + + aResourceMgr->setValue("VISU", "scalar_bar_label_font", aLabelFont); + + aResourceMgr->setValue("VISU", "scalar_bar_label_color", aLabelColor); + } +} + +/** + * Initialise dialog box from presentation object + */ +void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs) +{ + initFromResources(); + myScalarMap = dynamic_cast(thePrs); + if( !myScalarMap ) + return; + + myTitle = myScalarMap->GetTitle(); + setPosAndSize( myScalarMap->GetPosX(), + myScalarMap->GetPosY(), + myScalarMap->GetWidth(), + myScalarMap->GetHeight(), + myScalarMap->GetBarOrientation()); + switch(myScalarMap->GetScaling()){ + case VISU::LOGARITHMIC : + setLogarithmic(true); + break; + default: + setLogarithmic(false); + } + CORBA::Double aRange[2] = {myScalarMap->GetSourceMin(), myScalarMap->GetSourceMax()}; + Rmin = aRange[0]; Rmax = aRange[1]; + setRange( myScalarMap->GetMin(), myScalarMap->GetMax(), + /*0.0, 0.0,*/ myScalarMap->IsRangeFixed() ); + setScalarBarData( myScalarMap->GetNbColors(), myScalarMap->GetLabels() ); + + // Update myModeCombo + int aNbComp = myScalarMap->GetField()->myNbComp; + bool isScalarMode = (aNbComp > 1); + myModeCombo->clear(); + myModeCombo->insertItem(""); + const VISU::PField& aField = myScalarMap->GetField(); + const VISU::TNames& aCompNames = aField->myCompNames; + const VISU::TNames& aUnitNames = aField->myUnitNames; + for(int i = 0; i < aNbComp; i++){ + QString aComponent = QString(aCompNames[i].c_str()).simplifyWhiteSpace(); + if(aComponent.isNull() || aComponent == "") + aComponent = "Component " + QString::number(i+1); + else + aComponent = "[" + QString::number(i+1) + "] " + aComponent; + + QString anUnit = QString(aUnitNames[i].c_str()).simplifyWhiteSpace(); + if(anUnit.isNull() || anUnit == "") + anUnit = "-"; + + aComponent = aComponent + ", " + anUnit; + + myModeCombo->insertItem(aComponent); + } + // + myModeCombo->setCurrentItem(myScalarMap->GetScalarMode()); + if (aNbComp==1){ + myModeCombo->setCurrentItem(1); + } + // + myModeLbl->setEnabled(isScalarMode); + myModeCombo->setEnabled(isScalarMode); + + // "Title" + myTextDlg->setTitleText(QString(myScalarMap->GetTitle())); + + vtkFloatingPointType R, G, B; + myScalarMap->GetTitleColor(&R, &G, &B); + + myTextDlg->myTitleFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)), + myScalarMap->GetTitFontType(), + myScalarMap->IsBoldTitle(), + myScalarMap->IsItalicTitle(), + myScalarMap->IsShadowTitle()); + + // "Labels" + myScalarMap->GetLabelColor(&R, &G, &B); + + myTextDlg->myLabelFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)), + myScalarMap->GetLblFontType(), + myScalarMap->IsBoldLabel(), + myScalarMap->IsItalicLabel(), + myScalarMap->IsShadowLabel()); + + // Draw Preview + if (myPreviewCheck->isChecked()) { + createScalarBar(); + updatePreview(); + } + +} +/*! Slot update preview of scalar bar, if preview is checked + */ +void VisuGUI_ScalarBarPane::updatePreview() +{ + if (myPreviewCheck->isChecked()) { + if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow()) { + deleteScalarBar(); + createScalarBar(); + vf->Repaint(); + } + } +} + +/*! Creating preview scalar bar + */ +void VisuGUI_ScalarBarPane::createScalarBar() +{ + if (VISU::GetActiveViewWindow() == NULL) return; + if (myPreviewActor != 0) return; + if (myScalarMap == NULL) return; + + if (!check()) return; + myScalarMapPL = VISU_ScalarMapPL::New(); + if(myScalarMap->GetSpecificPL()) + myScalarMapPL->ShallowCopy(myScalarMap->GetSpecificPL()); + + if ( myBusy ) return; + + myBusy = true; + + int sbCol,sbLab; + sbCol = getNbColors(); + sbLab = getNbLabels(); + if(sbCol < 2) sbCol=2; + if(sbCol > 64) sbCol=64; + if(sbLab < 2) sbLab=2; + if(sbLab > 65) sbLab=65; + myPreviewActor = VISU_ScalarMapAct::New(); + VISU_ScalarBarActor* aScalarBarActor = myPreviewActor->GetScalarBar(); + myPreviewActor->GetScalarBar()->VisibilityOn(); + myPreviewActor->PickableOff(); + + myScalarMapPL->SetScalarMode(myModeCombo->currentItem()); + if(isLogarithmic()) + myScalarMapPL->SetScaling(VISU::LOGARITHMIC); + else + myScalarMapPL->SetScaling(VISU::LINEAR); + vtkFloatingPointType theRange[2]; + theRange[0] = (vtkFloatingPointType)MinEdit->text().toDouble(); + theRange[1] = (vtkFloatingPointType)MaxEdit->text().toDouble(); + myScalarMapPL->SetScalarRange(theRange); + myScalarMapPL->SetNbColors(sbCol); + + myScalarMapPL->Update(); + + aScalarBarActor->SetLookupTable(myScalarMapPL->GetBarTable()); + + if (myTextDlg->getTitleText().latin1() != "") + aScalarBarActor->SetTitle(myTextDlg->getTitleText().latin1()); + else + aScalarBarActor->SetTitle(myTitle.c_str()); + aScalarBarActor->SetOrientation(getOrientation()); + aScalarBarActor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport(); + aScalarBarActor->GetPositionCoordinate()->SetValue(getX(),getY()); + aScalarBarActor->SetWidth(getWidth()); + aScalarBarActor->SetHeight(getHeight()); + aScalarBarActor->SetNumberOfLabels(sbLab); + aScalarBarActor->SetMaximumNumberOfColors(sbCol); + + // title text property + QColor aTitleColor; + int aTitleFontFamily; + bool isTitleBold; + bool isTitleItalic; + bool isTitleShadow; + myTextDlg->myTitleFont->GetData(aTitleColor,aTitleFontFamily, + isTitleBold,isTitleItalic,isTitleShadow); + vtkTextProperty* aTitleProp = aScalarBarActor->GetTitleTextProperty(); + aTitleProp->SetFontFamily(aTitleFontFamily); + aTitleProp->SetColor(vtkFloatingPointType(aTitleColor.red())/255., + vtkFloatingPointType(aTitleColor.green())/255., + vtkFloatingPointType(aTitleColor.blue())/255.); + (isTitleBold)? aTitleProp->BoldOn() : aTitleProp->BoldOff(); + (isTitleItalic)? aTitleProp->ItalicOn() : aTitleProp->ItalicOff(); + (isTitleShadow)? aTitleProp->ShadowOn() : aTitleProp->ShadowOff(); + + // label text property + QColor aLabelColor; + int aLabelFontFamily; + bool isLabelBold; + bool isLabelItalic; + bool isLabelShadow; + myTextDlg->myLabelFont->GetData(aLabelColor, aLabelFontFamily, + isLabelBold, isLabelItalic, isLabelShadow); + vtkTextProperty* aLabelProp = aScalarBarActor->GetLabelTextProperty(); + aLabelProp->SetFontFamily(aLabelFontFamily); + aLabelProp->SetColor(vtkFloatingPointType(aLabelColor.red())/255., + vtkFloatingPointType(aLabelColor.green())/255., + vtkFloatingPointType(aLabelColor.blue())/255.); + (isLabelBold)? aLabelProp->BoldOn() : aLabelProp->BoldOff(); + (isLabelItalic)? aLabelProp->ItalicOn() : aLabelProp->ItalicOff(); + (isLabelShadow)? aLabelProp->ShadowOn() : aLabelProp->ShadowOff(); + + aScalarBarActor->Modified(); + + VISU::GetActiveViewWindow()->AddActor(myPreviewActor); + + myBusy = false; +} +/*! Deleting preview scalar bar + */ +void VisuGUI_ScalarBarPane::deleteScalarBar() +{ + if ( myBusy ) return; + + if (myPreviewActor == 0) return; + vtkRenderer* aRend = myPreviewActor->GetRenderer(); + vtkRenderWindow* aWnd = aRend->GetRenderWindow(); + if(aRend && aWnd) + myPreviewActor->RemoveFromRender(aRend); + myPreviewActor->GetScalarBar()->VisibilityOff(); + myPreviewActor->Delete(); + myPreviewActor = 0; + + if (myScalarMapPL){ + myScalarMapPL->Delete(); + myScalarMapPL = 0; + } +} +/*! public: Deleting preview scalar bar + */ +void VisuGUI_ScalarBarPane::deletePreview() +{ + deleteScalarBar(); + if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow()) + vf->Repaint(); +} +/** + * Store values to presentation object + */ +int VisuGUI_ScalarBarPane::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) { + if( !myScalarMap ) + return 0; + + myScalarMap->SetScalarMode(myModeCombo->currentItem()); + myScalarMap->SetPosition(XSpin->value(), YSpin->value()); + myScalarMap->SetSize(WidthSpin->value(), HeightSpin->value()); + myScalarMap->SetBarOrientation((RBvert->isChecked())? VISU::ScalarMap::VERTICAL : VISU::ScalarMap::HORIZONTAL); + if(isLogarithmic()) + myScalarMap->SetScaling(VISU::LOGARITHMIC); + else + myScalarMap->SetScaling(VISU::LINEAR); + + if (RBFrange->isChecked()) { + myScalarMap->SetSourceRange(); + } else { + myScalarMap->SetRange(MinEdit->text().toDouble(), MaxEdit->text().toDouble()); + } + myScalarMap->SetNbColors(ColorSpin->value()); + myScalarMap->SetLabels(LabelSpin->value()); + + if (isToSave()) storeToResources(); + + if (myIsStoreTextProp) { + // "Title" + myScalarMap->SetTitle(myTextDlg->getTitleText().latin1()); + + QColor aTitColor (255, 255, 255); + int aTitleFontFamily = VTK_ARIAL; + bool isTitleBold = false; + bool isTitleItalic = false; + bool isTitleShadow = false; + + myTextDlg->myTitleFont->GetData(aTitColor, aTitleFontFamily, + isTitleBold, isTitleItalic, isTitleShadow); + + myScalarMap->SetBoldTitle(isTitleBold); + myScalarMap->SetItalicTitle(isTitleItalic); + myScalarMap->SetShadowTitle(isTitleShadow); + myScalarMap->SetTitFontType(aTitleFontFamily); + myScalarMap->SetTitleColor(aTitColor.red()/255., + aTitColor.green()/255., + aTitColor.blue()/255.); + + // "Label" + QColor aLblColor (255, 255, 255); + int aLabelFontFamily = VTK_ARIAL; + bool isLabelBold = false; + bool isLabelItalic = false; + bool isLabelShadow = false; + + myTextDlg->myLabelFont->GetData(aLblColor, aLabelFontFamily, + isLabelBold, isLabelItalic, isLabelShadow); + + myScalarMap->SetBoldLabel(isLabelBold); + myScalarMap->SetItalicLabel(isLabelItalic); + myScalarMap->SetShadowLabel(isLabelShadow); + myScalarMap->SetLblFontType(aLabelFontFamily); + myScalarMap->SetLabelColor(aLblColor.red()/255., + aLblColor.green()/255., + aLblColor.blue()/255.); + myIsStoreTextProp = false; + } + + return 1; +} + +/*! + Called when orientation is changed +*/ +void VisuGUI_ScalarBarPane::changeDefaults( int ) +{ + if ( RBvert->isChecked() ) { + XSpin->setValue( myVerX ); + YSpin->setValue( myVerY ); + WidthSpin->setValue( myVerW ); + HeightSpin->setValue( myVerH ); + } + else { + XSpin->setValue( myHorX ); + YSpin->setValue( myHorY ); + WidthSpin->setValue( myHorW ); + HeightSpin->setValue( myHorH ); + } + updatePreview(); +} + +/*! + Called when Range mode is changed +*/ +void VisuGUI_ScalarBarPane::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 ); + MinEdit->setEnabled( false ); + //MaxLabel->setEnabled( false ); + 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 ); + MinEdit->setEnabled( true ); + //MaxLabel->setEnabled( true ); + MaxEdit->setEnabled( true ); + MinEdit->setText( QString::number( Imin ) ); + MaxEdit->setText( QString::number( Imax ) ); + } + myRangeMode = mode; + updatePreview(); +} + +/*! + Called when X,Y position is changed +*/ +void VisuGUI_ScalarBarPane::XYChanged( double ) +{ + QtxDblSpinBox* snd = (QtxDblSpinBox*)sender(); + if ( snd == XSpin ) { + WidthSpin->setMaxValue( 1.0 - XSpin->value() ); + } + if ( snd == YSpin ) { + HeightSpin->setMaxValue( 1.0 - YSpin->value() ); + } + updatePreview(); +} + +/*! + Called when scalar mode is changed +*/ +void VisuGUI_ScalarBarPane::changeScalarMode( int theMode ) +{ + if ( myScalarMap ) { + if ( RBFrange->isChecked() ) { + int aMode = myScalarMap->GetScalarMode(); + myScalarMap->SetScalarMode(theMode); + CORBA::Double aRange[2] = {myScalarMap->GetSourceMin(), myScalarMap->GetSourceMax()}; + MinEdit->setText( QString::number( aRange[0] ) ); + MaxEdit->setText( QString::number( aRange[1] ) ); + myScalarMap->SetScalarMode(aMode); + } + } + updatePreview(); +} + +/*! + Sets default values and range mode +*/ +void VisuGUI_ScalarBarPane::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 + RBFrange->setChecked( true ); + changeRange( 0 ); +} + +/*! + Sets default values and range mode +*/ +void VisuGUI_ScalarBarPane::setDefaultRange(double imin, double imax){ + Rmin = imin; + Rmax = imax; +} + +/*! + Sets and gets parameters +*/ +bool VisuGUI_ScalarBarPane::isIRange() { + return RBIrange->isChecked(); +} + +double VisuGUI_ScalarBarPane::getMin() { + return MinEdit->text().toDouble(); +} + +double VisuGUI_ScalarBarPane::getMax() { + return MaxEdit->text().toDouble(); +} + +double VisuGUI_ScalarBarPane::getX() { + return XSpin->value(); +} + +double VisuGUI_ScalarBarPane::getY() { + return YSpin->value(); +} + +double VisuGUI_ScalarBarPane::getWidth() { + return WidthSpin->value(); +} + +double VisuGUI_ScalarBarPane::getHeight() { + return HeightSpin->value(); +} + +int VisuGUI_ScalarBarPane::getNbColors() { + return ColorSpin->value(); +} + +int VisuGUI_ScalarBarPane::getNbLabels() { + return LabelSpin->value(); +} + +bool VisuGUI_ScalarBarPane::isLogarithmic() { + return CBLog->isChecked(); +} + +void VisuGUI_ScalarBarPane::setLogarithmic( bool on ) { + CBLog->setChecked( on ); +} + +bool VisuGUI_ScalarBarPane::isToSave() { + return CBSave ? CBSave->isChecked() : false; +} + +/*! + Sets size and position +*/ +void VisuGUI_ScalarBarPane::setPosAndSize( double x, double y, double w, double h, bool vert ) +{ + if ( vert ) { + myVerX = x; + myVerY = y; + myVerW = w; + myVerH = h; + RBvert->setChecked( true ); + } + else { + myHorX = x; + myHorY = y; + myHorW = w; + myHorH = h; + RBhori->setChecked( true ); + } + changeDefaults( 0 ); +} + +/*! + Sets colors and labels number +*/ +void VisuGUI_ScalarBarPane::setScalarBarData( int colors, int labels ) +{ + ColorSpin->setValue( colors ); + LabelSpin->setValue( labels ); +} + +/*! + Gets orientation +*/ +int VisuGUI_ScalarBarPane::getOrientation() +{ + if (RBvert->isChecked() ) + return 1; + else + return 0; +} + +/*! + Called when button is clicked, validates data and closes dialog +*/ +bool VisuGUI_ScalarBarPane::check() +{ + double minVal = MinEdit->text().toDouble(); + double maxVal = MaxEdit->text().toDouble(); + if ( RBIrange->isChecked() ) { + if (minVal >= maxVal) { + SUIT_MessageBox::warn1( this,tr("WRN_VISU"), + tr("MSG_MINMAX_VALUES"), + tr("BUT_OK")); + return false; + } + } + // 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 { + SUIT_MessageBox::warn1( this, + tr("WRN_VISU"), + tr("WRN_LOGARITHMIC_RANGE"), + tr("BUT_OK")); + return false; + } + } + else { + if ( Rmin > 0 && Rmax > 0 ) { + // nothing to do + } + else { + SUIT_MessageBox::warn1( this, + tr("WRN_VISU"), + tr("WRN_LOGARITHMIC_FIELD_RANGE"), + tr("BUT_OK")); + RBIrange->setChecked(1); + changeRange(1); + //MinEdit->setText( QString::number( Rmin ) ); + //MaxEdit->setText( QString::number( Rmax ) ); + return false; + } + } + } + return true; +} + +void VisuGUI_ScalarBarPane::onTextPref() +{ + myTextDlg->storeBeginValues(); + myIsStoreTextProp = myTextDlg->exec() || myIsStoreTextProp; + updatePreview(); +} + +void VisuGUI_ScalarBarPane::onPreviewCheck (bool thePreview) +{ + if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow()) { + if (thePreview) { + createScalarBar(); + } else { + deleteScalarBar(); + } + vf->Repaint(); + } +} + +VisuGUI_Prs3dDlg::VisuGUI_Prs3dDlg( SalomeApp_Module* theModule ) + : QDialog( VISU::GetDesktop( theModule ), 0, false, + WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu ) +{ +} + +void VisuGUI_Prs3dDlg::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs, bool theInit ) +{ +} + +int VisuGUI_Prs3dDlg::storeToPrsObject( VISU::ColoredPrs3d_i* thePrs ) +{ + return 1; +} diff --git a/src/VISUGUI/VisuGUI_Prs3dDlg.h b/src/VISUGUI/VisuGUI_Prs3dDlg.h new file mode 100644 index 00000000..5f6541f7 --- /dev/null +++ b/src/VISUGUI/VisuGUI_Prs3dDlg.h @@ -0,0 +1,198 @@ +// 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_Prs3dDlg.h +// Author : Laurent CORNABE & Hubert ROLLAND +// Module : VISU + +#ifndef VISUGUI_PRS3DDLG_H +#define VISUGUI_PRS3DDLG_H + +#include +#include + +#include "SALOME_GenericObjPointer.hh" + +class QButtonGroup; +class QGroupBox; +class QLabel; +class QCheckBox; +class QPushButton; +class QRadioButton; +class QSpinBox; +class QLineEdit; +class QComboBox; +class QToolButton; +class QTabWidget; + +class QtxDblSpinBox; + +class SalomeApp_Module; +class SVTK_FontWidget; +class VISU_ScalarMapAct; +class VISU_ScalarMapPL; + +namespace VISU +{ + class ColoredPrs3d_i; + class ScalarMap_i; +} + +class VisuGUI_TextPrefDlg: public QDialog +{ + Q_OBJECT; + + public: + VisuGUI_TextPrefDlg (QWidget* parent); + ~VisuGUI_TextPrefDlg() {}; + + QString getTitleText(); + void setTitleText(QString theText); + + void setTitleVisible(bool isVisible); + + void storeBeginValues(); + + private: + void keyPressEvent( QKeyEvent* e ); + + public: + SVTK_FontWidget* myTitleFont; + SVTK_FontWidget* myLabelFont; + + protected slots: + void accept(); + void reject(); + void onHelp(); + + private: + QLineEdit* myTitleEdt; + QString myTitle; + QColor myColors[2]; + int myComboVals[2]; + bool myCheckVals[6]; +}; + + +class VisuGUI_ScalarBarPane : public QVBox +{ + Q_OBJECT; + + public: + VisuGUI_ScalarBarPane(QWidget* parent, bool SetPref); + ~VisuGUI_ScalarBarPane() {}; + + void setRange( double imin, double imax, /*double fmin, double fmax,*/ bool sbRange ); + void setDefaultRange(double imin, double imax); + int getOrientation(); + void setPosAndSize( double x, double y, double w, double h, bool vert ); + void setScalarBarData( int colors, int labels ); + bool isIRange(); + double getMin(); + double getMax(); + double getX(); + double getY(); + double getWidth(); + double getHeight(); + int getNbColors(); + int getNbLabels(); + bool isLogarithmic(); + void setLogarithmic( bool on ); + bool isToSave(); + + void initFromResources(); + void storeToResources(); + + void initFromPrsObject(VISU::ColoredPrs3d_i* thePrs); + int storeToPrsObject(VISU::ColoredPrs3d_i* thePrs); + + bool check(); + void deletePreview(); + + protected: + QButtonGroup* RangeGroup; + QRadioButton* RBFrange; + QRadioButton* RBIrange; + QLineEdit* MinEdit; + QLineEdit* MaxEdit; + + QRadioButton* RBhori; + QRadioButton* RBvert; + + QtxDblSpinBox* XSpin; + QtxDblSpinBox* YSpin; + + QtxDblSpinBox* WidthSpin; + QtxDblSpinBox* HeightSpin; + + QSpinBox* ColorSpin; + QSpinBox* LabelSpin; + + QCheckBox* CBSave; + QCheckBox* CBLog; + QLabel* myModeLbl; + QComboBox* myModeCombo; + QPushButton* myTextBtn; + VisuGUI_TextPrefDlg* myTextDlg; + + double Imin, Imax, /* Fmin, Fmax,*/ Rmin, Rmax; + double myHorX, myHorY, myHorW, myHorH; + double myVerX, myVerY, myVerW, myVerH; + int myRangeMode; + bool myIsStoreTextProp; + + private slots: + void changeDefaults( int ); + void changeRange( int ); + void XYChanged( double ); + void changeScalarMode( int ); + void onTextPref(); + void onPreviewCheck(bool thePreview); + void updatePreview(); + + private: + void createScalarBar(); + void deleteScalarBar(); + + QCheckBox* myPreviewCheck; + VISU_ScalarMapAct* myPreviewActor; + VISU::ScalarMap_i* myScalarMap; + VISU_ScalarMapPL* myScalarMapPL; + std::string myTitle; + + bool myBusy; +}; + +class VisuGUI_Prs3dDlg : public QDialog +{ + Q_OBJECT; + + public: + VisuGUI_Prs3dDlg( SalomeApp_Module* theModule ); + ~VisuGUI_Prs3dDlg() {} + + virtual void initFromPrsObject( VISU::ColoredPrs3d_i* thePrs, bool theInit = true ); + virtual int storeToPrsObject( VISU::ColoredPrs3d_i* thePrs ); +}; + +#endif diff --git a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx index d3b90db7..fac87810 100644 --- a/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx +++ b/src/VISUGUI/VisuGUI_ScalarBarDlg.cxx @@ -44,6 +44,7 @@ #include "VISU_ScalarMapAct.h" #include "VISU_Result_i.hh" +#include "VISU_ColoredPrs3dFactory.hh" #include "LightApp_Application.h" @@ -60,1020 +61,11 @@ using namespace std; - -VisuGUI_ScalarBarPane::VisuGUI_ScalarBarPane (QWidget * parent, bool SetPref): - QVBox(parent), myPreviewActor(0) -{ - SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); - QString propertyName; - propertyName = QString("scalar_bar_vertical_"); - myVerX = aResourceMgr->doubleValue("VISU", propertyName + "x", 0.); - myVerY = aResourceMgr->doubleValue("VISU", propertyName + "y", 0.); - myVerW = aResourceMgr->doubleValue("VISU", propertyName + "width", 0.); - myVerH = aResourceMgr->doubleValue("VISU", propertyName + "height",0.); - - propertyName = QString("scalar_bar_horizontal_"); - myHorX = aResourceMgr->doubleValue("VISU", propertyName + "x", 0.); - myHorY = aResourceMgr->doubleValue("VISU", propertyName + "y", 0.); - myHorW = aResourceMgr->doubleValue("VISU", propertyName + "width", 0.); - myHorH = aResourceMgr->doubleValue("VISU", propertyName + "height",0.); - - Imin = 0.0; Imax = 0.0; /*Fmin = 0.0; Fmax = 0.0;*/ Rmin = 0.0; Rmax = 0.0; - myRangeMode = -1; - - setSpacing(6); - //setMargin(11); - - // Range ============================================================ - RangeGroup = new QButtonGroup (tr("SCALAR_RANGE_GRP"), this, "RangeGroup"); - RangeGroup->setColumnLayout(0, Qt::Vertical ); - RangeGroup->layout()->setSpacing( 0 ); - RangeGroup->layout()->setMargin( 0 ); - QGridLayout* RangeGroupLayout = new QGridLayout( RangeGroup->layout() ); - RangeGroupLayout->setAlignment( Qt::AlignTop ); - RangeGroupLayout->setSpacing( 6 ); - RangeGroupLayout->setMargin( 11 ); - - myModeLbl = new QLabel("Scalar Mode", RangeGroup); - - myModeCombo = new QComboBox(RangeGroup); - - CBLog = new QCheckBox (tr("LOGARITHMIC_SCALING"), RangeGroup); - CBLog->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - - RBFrange = new QRadioButton (tr("FIELD_RANGE_BTN"), RangeGroup, "RBFrange"); - RBIrange = new QRadioButton (tr("IMPOSED_RANGE_BTN"), RangeGroup, "RBIrange"); - RBFrange->setChecked( true ); - - 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("LBL_MIN"), RangeGroup, "MinLabel"); - MinLabel->setBuddy(MinEdit); - - 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("LBL_MAX"), RangeGroup, "MaxLabel"); - MaxLabel->setBuddy(MaxEdit); - - RangeGroupLayout->addWidget( myModeLbl, 0, 0 ); - RangeGroupLayout->addMultiCellWidget( myModeCombo, 0, 0, 1, 3); - RangeGroupLayout->addMultiCellWidget( CBLog, 1, 1, 0, 3); - RangeGroupLayout->addMultiCellWidget( RBFrange, 2, 2, 0, 1); - RangeGroupLayout->addMultiCellWidget( RBIrange, 2, 2, 2, 3); - RangeGroupLayout->addWidget( MinLabel, 3, 0 ); - RangeGroupLayout->addWidget( MinEdit, 3, 1 ); - RangeGroupLayout->addWidget( MaxLabel, 3, 2 ); - RangeGroupLayout->addWidget( MaxEdit, 3, 3 ); - - //TopLayout->addWidget( RangeGroup ); - - // Colors and Labels ======================================================== - QGroupBox* ColLabGroup = new QGroupBox (tr("COLORS_LABELS_GRP"), this, "ColLabGroup"); - ColLabGroup->setColumnLayout(0, Qt::Vertical ); - ColLabGroup->layout()->setSpacing( 0 ); - ColLabGroup->layout()->setMargin( 0 ); - QGridLayout* ColLabGroupLayout = new QGridLayout( ColLabGroup->layout() ); - ColLabGroupLayout->setAlignment( Qt::AlignTop ); - ColLabGroupLayout->setSpacing( 6 ); - ColLabGroupLayout->setMargin( 11 ); - - QLabel* ColorLabel = new QLabel (tr("LBL_NB_COLORS"), ColLabGroup, "ColorLabel"); - ColorSpin = new QSpinBox( 2, 256, 1, ColLabGroup ); - ColorSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - ColorSpin->setMinimumWidth( 70 ); - ColorSpin->setValue( 64 ); - - QLabel* LabelLabel = new QLabel (tr("LBL_NB_LABELS"), ColLabGroup, "LabelLabel"); - LabelSpin = new QSpinBox( 2, 65, 1, ColLabGroup ); - LabelSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - LabelSpin->setMinimumWidth( 70 ); - LabelSpin->setValue( 5 ); - - ColLabGroupLayout->addWidget( ColorLabel, 0, 0); - ColLabGroupLayout->addWidget( ColorSpin, 0, 1); - ColLabGroupLayout->addWidget( LabelLabel, 0, 2); - ColLabGroupLayout->addWidget( LabelSpin, 0, 3); - - //TopLayout->addWidget( ColLabGroup ); - - // Orientation ========================================================== - QButtonGroup* OrientGroup = new QButtonGroup (tr("ORIENTATION_GRP"), this, "OrientGroup"); - OrientGroup->setColumnLayout(0, Qt::Vertical ); - OrientGroup->layout()->setSpacing( 0 ); - OrientGroup->layout()->setMargin( 0 ); - QGridLayout* OrientGroupLayout = new QGridLayout( OrientGroup->layout() ); - OrientGroupLayout->setAlignment( Qt::AlignTop ); - OrientGroupLayout->setSpacing( 6 ); - OrientGroupLayout->setMargin( 11 ); - - RBvert = new QRadioButton (tr("VERTICAL_BTN"), OrientGroup, "RBvert"); - RBvert->setChecked( true ); - RBhori = new QRadioButton (tr("HORIZONTAL_BTN"), OrientGroup, "RBhori"); - OrientGroupLayout->addWidget( RBvert, 0, 0 ); - OrientGroupLayout->addWidget( RBhori, 0, 1 ); - - // TopLayout->addWidget( OrientGroup ); - - // Origin =============================================================== - QGroupBox* OriginGroup = new QGroupBox (tr("ORIGIN_GRP"), this, "OriginGroup"); - OriginGroup->setColumnLayout(0, Qt::Vertical ); - OriginGroup->layout()->setSpacing( 0 ); - OriginGroup->layout()->setMargin( 0 ); - QGridLayout* OriginGroupLayout = new QGridLayout( OriginGroup->layout() ); - OriginGroupLayout->setAlignment( Qt::AlignTop ); - OriginGroupLayout->setSpacing( 6 ); - OriginGroupLayout->setMargin( 11 ); - - QLabel* XLabel = new QLabel (tr("LBL_X"), OriginGroup, "XLabel"); - XSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, OriginGroup ); - XSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - XSpin->setMinimumWidth( 70 ); - XSpin->setValue( 0.01 ); - - QLabel* YLabel = new QLabel (tr("LBL_Y"), OriginGroup, "YLabel"); - YSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, OriginGroup ); - YSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - YSpin->setMinimumWidth( 70 ); - YSpin->setValue( 0.01 ); - - OriginGroupLayout->addWidget( XLabel, 0, 0); - OriginGroupLayout->addWidget( XSpin, 0, 1); - OriginGroupLayout->addWidget( YLabel, 0, 2); - OriginGroupLayout->addWidget( YSpin, 0, 3); - - //TopLayout->addWidget( OriginGroup ); - - // Dimensions ========================================================= - QGroupBox* DimGroup = new QGroupBox (tr("DIMENSIONS_GRP"), this, "DimGroup"); - DimGroup->setColumnLayout(0, Qt::Vertical ); - DimGroup->layout()->setSpacing( 0 ); - DimGroup->layout()->setMargin( 0 ); - QGridLayout* DimGroupLayout = new QGridLayout( DimGroup->layout() ); - DimGroupLayout->setAlignment( Qt::AlignTop ); - DimGroupLayout->setSpacing( 6 ); - DimGroupLayout->setMargin( 11 ); - - QLabel* WidthLabel = new QLabel (tr("LBL_WIDTH"), DimGroup, "WidthLabel"); - WidthSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, DimGroup ); - WidthSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - WidthSpin->setMinimumWidth( 70 ); - WidthSpin->setValue( 0.1 ); - - QLabel* HeightLabel = new QLabel (tr("LBL_HEIGHT"), DimGroup, "HeightLabel"); - HeightSpin = new QtxDblSpinBox( 0.0, 1.0, 0.1, DimGroup ); - HeightSpin->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); - HeightSpin->setMinimumWidth( 70 ); - HeightSpin->setValue( 0.8 ); - - DimGroupLayout->addWidget( WidthLabel, 0, 0); - DimGroupLayout->addWidget( WidthSpin, 0, 1); - DimGroupLayout->addWidget( HeightLabel, 0, 2); - DimGroupLayout->addWidget( HeightSpin, 0, 3); - - //TopLayout->addWidget( DimGroup ); - - // Save check box =========================================================== - QHBox* aSaveBox = new QHBox(this); - if (!SetPref) { - CBSave = new QCheckBox (tr("SAVE_DEFAULT_CHK"), aSaveBox, "CBSave"); - //TopLayout->addWidget(CBSave); - } - else { - CBSave = 0; - } - myTextBtn = new QPushButton("Text properties...", aSaveBox); - myTextDlg = new VisuGUI_TextPrefDlg(this); - myTextDlg->setTitleVisible(!SetPref); - - QGroupBox* CheckGroup = new QGroupBox("", this, "CheckGroup"); - CheckGroup->setColumnLayout(0, Qt::Vertical ); - CheckGroup->layout()->setSpacing( 0 ); - CheckGroup->layout()->setMargin( 0 ); - QGridLayout* CheckGroupLayout = new QGridLayout( CheckGroup->layout() ); - - myPreviewCheck = new QCheckBox(tr("LBL_SHOW_PREVIEW"), CheckGroup); - myPreviewCheck->setChecked(false); - CheckGroupLayout->addWidget(myPreviewCheck , 0, 0 ); - - // signals and slots connections =========================================== - connect( RangeGroup, SIGNAL( clicked( int ) ), this, SLOT( changeRange( int ) ) ); - connect( myModeCombo, SIGNAL( activated( int ) ), this, SLOT( changeScalarMode( int ) ) ); - connect( OrientGroup, SIGNAL( clicked( int ) ), this, SLOT( changeDefaults( int ) ) ); - connect( XSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) ); - connect( YSpin, SIGNAL( valueChanged( double ) ), this, SLOT( XYChanged( double ) ) ); - connect( myTextBtn, SIGNAL( clicked() ), this, SLOT( onTextPref() ) ); - connect( myPreviewCheck, SIGNAL( toggled( bool )), this, SLOT( onPreviewCheck( bool ) ) ); - connect( ColorSpin, SIGNAL( valueChanged( int ) ), this, SLOT( updatePreview() )); - connect( LabelSpin, SIGNAL( valueChanged( int ) ), this, SLOT( updatePreview() )); - connect( WidthSpin, SIGNAL( valueChanged( double ) ), this, SLOT( updatePreview() )); - connect( HeightSpin, SIGNAL( valueChanged( double ) ), this, SLOT( updatePreview() )); - connect( CBLog, SIGNAL( toggled( bool ) ), this, SLOT( updatePreview() )); - changeRange( 0 ); - changeDefaults( 0 ); - myIsStoreTextProp = false; - myBusy = false; -} - -/** - * Initializes dialog box values from resources - */ -void VisuGUI_ScalarBarPane::initFromResources() { - int sbCol=64,sbLab=5,orient=0; - float sbX1=0.01,sbY1=0.1,sbW=0.1,sbH=0.8; - float sbVmin=0., sbVmax=0.; - bool sbRange=false; - QString aString; - - SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); - - bool anIsArrangeBar = aResourceMgr->booleanValue("VISU", "scalar_bars_default_position", 0); - int aPlace = 1; - if (anIsArrangeBar){ - aPlace = aResourceMgr->integerValue("VISU", "scalar_bar_position_num",0); - } - - int aScalarMode = aResourceMgr->integerValue("VISU", "scalar_bar_mode", 0); - myModeCombo->setCurrentItem(aScalarMode); - - orient = aResourceMgr->integerValue("VISU", "scalar_bar_orientation", orient); - if(orient != 0){ - orient=1; - sbX1=0.2; - sbY1=0.01; - sbW=0.6; - sbH=0.12; - } - - QString propertyName = QString( "scalar_bar_%1_" ).arg( orient == 0 ? "vertical" : "horizontal" ); - - sbX1 = aResourceMgr->doubleValue("VISU", propertyName + "x", sbX1); - sbY1 = aResourceMgr->doubleValue("VISU", propertyName + "y", sbY1); - - sbW = aResourceMgr->doubleValue("VISU", propertyName + "width", sbW); - sbH = aResourceMgr->doubleValue("VISU", propertyName + "height",sbH); - - if(orient){ - sbY1 += sbH*(aPlace-1); - } else { - sbX1 += sbW*(aPlace-1); - } - sbCol = aResourceMgr->integerValue("VISU" ,"scalar_bar_num_colors", sbCol); - sbLab = aResourceMgr->integerValue("VISU", "scalar_bar_num_labels", sbLab); - - int rangeType = aResourceMgr->integerValue("VISU" , "scalar_range_type", 0); - if (rangeType == 1) sbRange = true; - sbVmin = aResourceMgr->doubleValue("VISU", "scalar_range_min", sbVmin); - sbVmax = aResourceMgr->doubleValue("VISU", "scalar_range_max", sbVmax); - - bool isLog = aResourceMgr->booleanValue("VISU", "scalar_bar_logarithmic", false); - setLogarithmic(isLog); - - if((sbX1 < 0.) || (sbY1 < 0.) || - ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) { - if(orient == 0) { - sbX1=0.01; - sbY1=0.1; - sbW=0.1; - sbH=0.8; - } else { - sbX1=0.2; - sbY1=0.01; - sbW=0.6; - sbH=0.12; - } - } - if(sbCol < 2) sbCol=2; - if(sbCol > 64) sbCol=64; - if(sbLab < 2) sbLab=2; - if(sbLab > 65) sbLab=65; - - if(sbVmin > sbVmax) { - sbVmin=0.; - sbVmax=0.; - } - - setRange( sbVmin, sbVmax, /*0.0, 0.0,*/ sbRange ); - setPosAndSize( sbX1, sbY1, sbW, sbH, orient == 0); - setScalarBarData( sbCol, sbLab ); - - // "Title" - bool isBold = false, isItalic = false, isShadow = false; - int aFontFamily = VTK_ARIAL; - - if ( aResourceMgr->hasValue( "VISU", "scalar_bar_title_font" ) ) - { - QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_title_font" ); - - if ( f.family() == "Arial" ) - aFontFamily = VTK_ARIAL; - else if ( f.family() == "Courier" ) - aFontFamily = VTK_COURIER; - else if ( f.family() == "Times" ) - aFontFamily = VTK_TIMES; - - isBold = f.bold(); - isItalic = f.italic(); - isShadow = f.underline(); - } - - QColor aTextColor = aResourceMgr->colorValue( "VISU", "scalar_bar_title_color", QColor( 255, 255, 255 ) ); - - myTextDlg->myTitleFont->SetData(aTextColor, aFontFamily, isBold, isItalic, isShadow); - - // "Labels" - isBold = isItalic = isShadow = false; - aFontFamily = VTK_ARIAL; - - if ( aResourceMgr->hasValue( "VISU", "scalar_bar_label_font" ) ) - { - QFont f = aResourceMgr->fontValue( "VISU", "scalar_bar_label_font" ); - - if ( f.family() == "Arial" ) - aFontFamily = VTK_ARIAL; - else if ( f.family() == "Courier" ) - aFontFamily = VTK_COURIER; - else if ( f.family() == "Times" ) - aFontFamily = VTK_TIMES; - - isBold = f.bold(); - isItalic = f.italic(); - isShadow = f.underline(); - } - - aTextColor = aResourceMgr->colorValue( "VISU", "scalar_bar_label_color", QColor( 255, 255, 255 ) ); - - myTextDlg->myLabelFont->SetData(aTextColor, aFontFamily, isBold, isItalic, isShadow); -} - -/** - * Stores dialog values to resources - */ -void VisuGUI_ScalarBarPane::storeToResources() { - int orient = (RBvert->isChecked())? 0 : 1; - float sbX1 = XSpin->value(); - float sbY1 = YSpin->value(); - float sbW = WidthSpin->value(); - float sbH = HeightSpin->value(); - int sbCol = ColorSpin->value(); - int sbLab = LabelSpin->value(); - - if((sbX1 < 0.) || (sbY1 < 0.) || ((sbX1+sbW) > 1.) || ((sbY1+sbH) > 1.)) { - if(orient == 0) { - sbX1=0.01; - sbY1=0.1; - sbW=0.17; - sbH=0.8; - } else { - sbX1=0.2; - sbY1=0.01; - sbW=0.6; - sbH=0.12; - } - } - - bool sbRange = RBIrange->isChecked(); - float sbVmin = (float)(MinEdit->text().toDouble()); - float sbVmax = (float)(MaxEdit->text().toDouble()); - - if(sbVmin > sbVmax) { - sbVmin=0.; - sbVmax=0.; - } - - SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); - - aResourceMgr->setValue("VISU", "scalar_bar_orientation", orient); - - QString propertyName = QString( "scalar_bar_%1_" ).arg( orient == 0 ? "vertical" : "horizontal" ); - - aResourceMgr->setValue("VISU", propertyName + "x", sbX1); - aResourceMgr->setValue("VISU", propertyName + "y", sbY1); - aResourceMgr->setValue("VISU", propertyName + "width", sbW); - aResourceMgr->setValue("VISU", propertyName + "height", sbH); - - aResourceMgr->setValue("VISU", "scalar_bar_num_colors", sbCol); - aResourceMgr->setValue("VISU", "scalar_bar_num_labels", sbLab); - - if(sbRange) - { - aResourceMgr->setValue("VISU", "scalar_range_type", 1); - aResourceMgr->setValue("VISU", "scalar_range_min" ,sbVmin); - aResourceMgr->setValue("VISU", "scalar_range_max" ,sbVmax); - } - else - aResourceMgr->setValue("VISU", "scalar_range_type", 0); - - aResourceMgr->setValue("VISU", "scalar_bar_logarithmic", isLogarithmic()); - - //// - - if (myIsStoreTextProp) { - // "Title" - QColor aTitleColor (255, 255, 255); - int aTitleFontFamily = VTK_ARIAL; - bool isTitleBold = false; - bool isTitleItalic = false; - bool isTitleShadow = false; - - myTextDlg->myTitleFont->GetData(aTitleColor, aTitleFontFamily, - isTitleBold, isTitleItalic, isTitleShadow); - - QFont aTitleFont; - - aTitleFont.setBold(isTitleBold); - aTitleFont.setItalic(isTitleItalic); - aTitleFont.setUnderline(isTitleShadow); - - QString titleFontFamily; - switch (aTitleFontFamily) { - case VTK_ARIAL: - titleFontFamily = "Arial"; - break; - case VTK_COURIER: - titleFontFamily = "Courier"; - break; - case VTK_TIMES: - titleFontFamily = "Times"; - break; - } - aTitleFont.setFamily(titleFontFamily); - - aResourceMgr->setValue("VISU", "scalar_bar_title_font", aTitleFont); - - aResourceMgr->setValue("VISU", "scalar_bar_title_color", aTitleColor); - - // "Label" - QColor aLabelColor (255, 255, 255); - int aLabelFontFamily = VTK_ARIAL; - bool isLabelBold = false; - bool isLabelItalic = false; - bool isLabelShadow = false; - - myTextDlg->myLabelFont->GetData(aLabelColor, aLabelFontFamily, - isLabelBold, isLabelItalic, isLabelShadow); - - - QFont aLabelFont; - - aLabelFont.setBold(isLabelBold); - aLabelFont.setItalic(isLabelItalic); - aLabelFont.setUnderline(isLabelShadow); - - QString labelFontFamily; - switch (aLabelFontFamily) { - case VTK_ARIAL: - labelFontFamily = "Arial"; - break; - case VTK_COURIER: - labelFontFamily = "Courier"; - break; - case VTK_TIMES: - labelFontFamily = "Times"; - break; - } - - aLabelFont.setFamily(labelFontFamily); - - aResourceMgr->setValue("VISU", "scalar_bar_label_font", aLabelFont); - - aResourceMgr->setValue("VISU", "scalar_bar_label_color", aLabelColor); - } -} - -/** - * Initialise dialog box from presentation object - */ -void VisuGUI_ScalarBarPane::initFromPrsObject(VISU::ScalarMap_i* thePrs) { - initFromResources(); - myScalarMap = thePrs; - myTitle = thePrs->GetTitle(); - setPosAndSize( thePrs->GetPosX(), - thePrs->GetPosY(), - thePrs->GetWidth(), - thePrs->GetHeight(), - thePrs->GetBarOrientation()); - switch(thePrs->GetScaling()){ - case VISU::LOGARITHMIC : - setLogarithmic(true); - break; - default: - setLogarithmic(false); - } - CORBA::Double aRange[2] = {thePrs->GetSourceMin(), thePrs->GetSourceMax()}; - Rmin = aRange[0]; Rmax = aRange[1]; - setRange( thePrs->GetMin(), thePrs->GetMax(), - /*0.0, 0.0,*/ thePrs->IsRangeFixed() ); - setScalarBarData( thePrs->GetNbColors(), thePrs->GetLabels() ); - - // Update myModeCombo - int aNbComp = thePrs->GetField()->myNbComp; - bool isScalarMode = (aNbComp > 1); - myModeCombo->clear(); - myModeCombo->insertItem(""); - const VISU::PField& aField = thePrs->GetField(); - const VISU::TNames& aCompNames = aField->myCompNames; - const VISU::TNames& aUnitNames = aField->myUnitNames; - for(int i = 0; i < aNbComp; i++){ - QString aComponent = QString(aCompNames[i].c_str()).simplifyWhiteSpace(); - if(aComponent.isNull() || aComponent == "") - aComponent = "Component " + QString::number(i+1); - else - aComponent = "[" + QString::number(i+1) + "] " + aComponent; - - QString anUnit = QString(aUnitNames[i].c_str()).simplifyWhiteSpace(); - if(anUnit.isNull() || anUnit == "") - anUnit = "-"; - - aComponent = aComponent + ", " + anUnit; - - myModeCombo->insertItem(aComponent); - } - // - myModeCombo->setCurrentItem(thePrs->GetScalarMode()); - if (aNbComp==1){ - myModeCombo->setCurrentItem(1); - } - // - myModeLbl->setEnabled(isScalarMode); - myModeCombo->setEnabled(isScalarMode); - - // "Title" - myTextDlg->setTitleText(QString(thePrs->GetTitle())); - - vtkFloatingPointType R, G, B; - thePrs->GetTitleColor(&R, &G, &B); - - myTextDlg->myTitleFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)), - thePrs->GetTitFontType(), - thePrs->IsBoldTitle(), - thePrs->IsItalicTitle(), - thePrs->IsShadowTitle()); - - // "Labels" - thePrs->GetLabelColor(&R, &G, &B); - - myTextDlg->myLabelFont->SetData(QColor((int)(R*255.), (int)(G*255.), (int)(B*255.)), - thePrs->GetLblFontType(), - thePrs->IsBoldLabel(), - thePrs->IsItalicLabel(), - thePrs->IsShadowLabel()); - - // Draw Preview - if (myPreviewCheck->isChecked()) { - createScalarBar(); - updatePreview(); - } - -} -/*! Slot update preview of scalar bar, if preview is checked - */ -void VisuGUI_ScalarBarPane::updatePreview() -{ - if (myPreviewCheck->isChecked()) { - if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow()) { - deleteScalarBar(); - createScalarBar(); - vf->Repaint(); - } - } -} - -/*! Creating preview scalar bar - */ -void VisuGUI_ScalarBarPane::createScalarBar() -{ - if (VISU::GetActiveViewWindow() == NULL) return; - if (myPreviewActor != 0) return; - if (myScalarMap == NULL) return; - - if (!check()) return; - myScalarMapPL = VISU_ScalarMapPL::New(); - if(myScalarMap->GetSpecificPL()) - myScalarMapPL->ShallowCopy(myScalarMap->GetSpecificPL()); - - if ( myBusy ) return; - - myBusy = true; - - int sbCol,sbLab; - sbCol = getNbColors(); - sbLab = getNbLabels(); - if(sbCol < 2) sbCol=2; - if(sbCol > 64) sbCol=64; - if(sbLab < 2) sbLab=2; - if(sbLab > 65) sbLab=65; - myPreviewActor = VISU_ScalarMapAct::New(); - VISU_ScalarBarActor* aScalarBarActor = myPreviewActor->GetScalarBar(); - myPreviewActor->GetScalarBar()->VisibilityOn(); - myPreviewActor->PickableOff(); - - myScalarMapPL->SetScalarMode(myModeCombo->currentItem()); - if(isLogarithmic()) - myScalarMapPL->SetScaling(VISU::LOGARITHMIC); - else - myScalarMapPL->SetScaling(VISU::LINEAR); - vtkFloatingPointType theRange[2]; - theRange[0] = (vtkFloatingPointType)MinEdit->text().toDouble(); - theRange[1] = (vtkFloatingPointType)MaxEdit->text().toDouble(); - myScalarMapPL->SetScalarRange(theRange); - myScalarMapPL->SetNbColors(sbCol); - - myScalarMapPL->Update(); - - aScalarBarActor->SetLookupTable(myScalarMapPL->GetBarTable()); - - if (myTextDlg->getTitleText().latin1() != "") - aScalarBarActor->SetTitle(myTextDlg->getTitleText().latin1()); - else - aScalarBarActor->SetTitle(myTitle.c_str()); - aScalarBarActor->SetOrientation(getOrientation()); - aScalarBarActor->GetPositionCoordinate()->SetCoordinateSystemToNormalizedViewport(); - aScalarBarActor->GetPositionCoordinate()->SetValue(getX(),getY()); - aScalarBarActor->SetWidth(getWidth()); - aScalarBarActor->SetHeight(getHeight()); - aScalarBarActor->SetNumberOfLabels(sbLab); - aScalarBarActor->SetMaximumNumberOfColors(sbCol); - - // title text property - QColor aTitleColor; - int aTitleFontFamily; - bool isTitleBold; - bool isTitleItalic; - bool isTitleShadow; - myTextDlg->myTitleFont->GetData(aTitleColor,aTitleFontFamily, - isTitleBold,isTitleItalic,isTitleShadow); - vtkTextProperty* aTitleProp = aScalarBarActor->GetTitleTextProperty(); - aTitleProp->SetFontFamily(aTitleFontFamily); - aTitleProp->SetColor(vtkFloatingPointType(aTitleColor.red())/255., - vtkFloatingPointType(aTitleColor.green())/255., - vtkFloatingPointType(aTitleColor.blue())/255.); - (isTitleBold)? aTitleProp->BoldOn() : aTitleProp->BoldOff(); - (isTitleItalic)? aTitleProp->ItalicOn() : aTitleProp->ItalicOff(); - (isTitleShadow)? aTitleProp->ShadowOn() : aTitleProp->ShadowOff(); - - // label text property - QColor aLabelColor; - int aLabelFontFamily; - bool isLabelBold; - bool isLabelItalic; - bool isLabelShadow; - myTextDlg->myLabelFont->GetData(aLabelColor, aLabelFontFamily, - isLabelBold, isLabelItalic, isLabelShadow); - vtkTextProperty* aLabelProp = aScalarBarActor->GetLabelTextProperty(); - aLabelProp->SetFontFamily(aLabelFontFamily); - aLabelProp->SetColor(vtkFloatingPointType(aLabelColor.red())/255., - vtkFloatingPointType(aLabelColor.green())/255., - vtkFloatingPointType(aLabelColor.blue())/255.); - (isLabelBold)? aLabelProp->BoldOn() : aLabelProp->BoldOff(); - (isLabelItalic)? aLabelProp->ItalicOn() : aLabelProp->ItalicOff(); - (isLabelShadow)? aLabelProp->ShadowOn() : aLabelProp->ShadowOff(); - - aScalarBarActor->Modified(); - - VISU::GetActiveViewWindow()->AddActor(myPreviewActor); - - myBusy = false; -} -/*! Deleting preview scalar bar - */ -void VisuGUI_ScalarBarPane::deleteScalarBar() -{ - if ( myBusy ) return; - - if (myPreviewActor == 0) return; - vtkRenderer* aRend = myPreviewActor->GetRenderer(); - vtkRenderWindow* aWnd = aRend->GetRenderWindow(); - if(aRend && aWnd) - myPreviewActor->RemoveFromRender(aRend); - myPreviewActor->GetScalarBar()->VisibilityOff(); - myPreviewActor->Delete(); - myPreviewActor = 0; - - if (myScalarMapPL){ - myScalarMapPL->Delete(); - myScalarMapPL = 0; - } -} -/*! public: Deleting preview scalar bar - */ -void VisuGUI_ScalarBarPane::deletePreview() -{ - deleteScalarBar(); - if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow()) - vf->Repaint(); -} -/** - * Store values to presentation object - */ -int VisuGUI_ScalarBarPane::storeToPrsObject(VISU::ScalarMap_i* thePrs) { - thePrs->SetScalarMode(myModeCombo->currentItem()); - thePrs->SetPosition(XSpin->value(), YSpin->value()); - thePrs->SetSize(WidthSpin->value(), HeightSpin->value()); - thePrs->SetBarOrientation((RBvert->isChecked())? VISU::ScalarMap::VERTICAL : VISU::ScalarMap::HORIZONTAL); - if(isLogarithmic()) - thePrs->SetScaling(VISU::LOGARITHMIC); - else - thePrs->SetScaling(VISU::LINEAR); - - if (RBFrange->isChecked()) { - thePrs->SetSourceRange(); - } else { - thePrs->SetRange(MinEdit->text().toDouble(), MaxEdit->text().toDouble()); - } - thePrs->SetNbColors(ColorSpin->value()); - thePrs->SetLabels(LabelSpin->value()); - - if (isToSave()) storeToResources(); - - if (myIsStoreTextProp) { - // "Title" - thePrs->SetTitle(myTextDlg->getTitleText().latin1()); - - QColor aTitColor (255, 255, 255); - int aTitleFontFamily = VTK_ARIAL; - bool isTitleBold = false; - bool isTitleItalic = false; - bool isTitleShadow = false; - - myTextDlg->myTitleFont->GetData(aTitColor, aTitleFontFamily, - isTitleBold, isTitleItalic, isTitleShadow); - - thePrs->SetBoldTitle(isTitleBold); - thePrs->SetItalicTitle(isTitleItalic); - thePrs->SetShadowTitle(isTitleShadow); - thePrs->SetTitFontType(aTitleFontFamily); - thePrs->SetTitleColor(aTitColor.red()/255., - aTitColor.green()/255., - aTitColor.blue()/255.); - - // "Label" - QColor aLblColor (255, 255, 255); - int aLabelFontFamily = VTK_ARIAL; - bool isLabelBold = false; - bool isLabelItalic = false; - bool isLabelShadow = false; - - myTextDlg->myLabelFont->GetData(aLblColor, aLabelFontFamily, - isLabelBold, isLabelItalic, isLabelShadow); - - thePrs->SetBoldLabel(isLabelBold); - thePrs->SetItalicLabel(isLabelItalic); - thePrs->SetShadowLabel(isLabelShadow); - thePrs->SetLblFontType(aLabelFontFamily); - thePrs->SetLabelColor(aLblColor.red()/255., - aLblColor.green()/255., - aLblColor.blue()/255.); - myIsStoreTextProp = false; - } - - return 1; -} - -/*! - Called when orientation is changed -*/ -void VisuGUI_ScalarBarPane::changeDefaults( int ) -{ - if ( RBvert->isChecked() ) { - XSpin->setValue( myVerX ); - YSpin->setValue( myVerY ); - WidthSpin->setValue( myVerW ); - HeightSpin->setValue( myVerH ); - } - else { - XSpin->setValue( myHorX ); - YSpin->setValue( myHorY ); - WidthSpin->setValue( myHorW ); - HeightSpin->setValue( myHorH ); - } - updatePreview(); -} - -/*! - Called when Range mode is changed -*/ -void VisuGUI_ScalarBarPane::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 ); - MinEdit->setEnabled( false ); - //MaxLabel->setEnabled( false ); - 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 ); - MinEdit->setEnabled( true ); - //MaxLabel->setEnabled( true ); - MaxEdit->setEnabled( true ); - MinEdit->setText( QString::number( Imin ) ); - MaxEdit->setText( QString::number( Imax ) ); - } - myRangeMode = mode; - updatePreview(); -} - -/*! - Called when X,Y position is changed -*/ -void VisuGUI_ScalarBarPane::XYChanged( double ) -{ - QtxDblSpinBox* snd = (QtxDblSpinBox*)sender(); - if ( snd == XSpin ) { - WidthSpin->setMaxValue( 1.0 - XSpin->value() ); - } - if ( snd == YSpin ) { - HeightSpin->setMaxValue( 1.0 - YSpin->value() ); - } - updatePreview(); -} - -/*! - Called when scalar mode is changed -*/ -void VisuGUI_ScalarBarPane::changeScalarMode( int theMode ) -{ - if ( myScalarMap ) { - if ( RBFrange->isChecked() ) { - int aMode = myScalarMap->GetScalarMode(); - myScalarMap->SetScalarMode(theMode); - CORBA::Double aRange[2] = {myScalarMap->GetSourceMin(), myScalarMap->GetSourceMax()}; - MinEdit->setText( QString::number( aRange[0] ) ); - MaxEdit->setText( QString::number( aRange[1] ) ); - myScalarMap->SetScalarMode(aMode); - } - } - updatePreview(); -} - -/*! - Sets default values and range mode -*/ -void VisuGUI_ScalarBarPane::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 - RBFrange->setChecked( true ); - changeRange( 0 ); -} - -/*! - Sets default values and range mode -*/ -void VisuGUI_ScalarBarPane::setDefaultRange(double imin, double imax){ - Rmin = imin; - Rmax = imax; -} - -/*! - Sets size and position -*/ -void VisuGUI_ScalarBarPane::setPosAndSize( double x, double y, double w, double h, bool vert ) -{ - if ( vert ) { - myVerX = x; - myVerY = y; - myVerW = w; - myVerH = h; - RBvert->setChecked( true ); - } - else { - myHorX = x; - myHorY = y; - myHorW = w; - myHorH = h; - RBhori->setChecked( true ); - } - changeDefaults( 0 ); -} - -/*! - Sets colors and labels number -*/ -void VisuGUI_ScalarBarPane::setScalarBarData( int colors, int labels ) -{ - ColorSpin->setValue( colors ); - LabelSpin->setValue( labels ); -} - -/*! - Gets orientation -*/ -int VisuGUI_ScalarBarPane::getOrientation() -{ - if (RBvert->isChecked() ) - return 1; - else - return 0; -} - -/*! - Called when button is clicked, validates data and closes dialog -*/ -bool VisuGUI_ScalarBarPane::check() -{ - double minVal = MinEdit->text().toDouble(); - double maxVal = MaxEdit->text().toDouble(); - if ( RBIrange->isChecked() ) { - if (minVal >= maxVal) { - SUIT_MessageBox::warn1( this,tr("WRN_VISU"), - tr("MSG_MINMAX_VALUES"), - tr("BUT_OK")); - return false; - } - } - // 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 { - SUIT_MessageBox::warn1( this, - tr("WRN_VISU"), - tr("WRN_LOGARITHMIC_RANGE"), - tr("BUT_OK")); - return false; - } - } - else { - if ( Rmin > 0 && Rmax > 0 ) { - // nothing to do - } - else { - SUIT_MessageBox::warn1( this, - tr("WRN_VISU"), - tr("WRN_LOGARITHMIC_FIELD_RANGE"), - tr("BUT_OK")); - RBIrange->setChecked(1); - changeRange(1); - //MinEdit->setText( QString::number( Rmin ) ); - //MaxEdit->setText( QString::number( Rmax ) ); - return false; - } - } - } - return true; -} - -void VisuGUI_ScalarBarPane::onTextPref() -{ - myTextDlg->storeBeginValues(); - myIsStoreTextProp = myTextDlg->exec() || myIsStoreTextProp; - updatePreview(); -} - -void VisuGUI_ScalarBarPane::onPreviewCheck (bool thePreview) -{ - if (SVTK_ViewWindow* vf = VISU::GetActiveViewWindow()) { - if (thePreview) { - createScalarBar(); - } else { - deleteScalarBar(); - } - vf->Repaint(); - } -} - -//####################################################################################### - /*! Constructor */ VisuGUI_ScalarBarDlg::VisuGUI_ScalarBarDlg (SalomeApp_Module* theModule, bool SetPref) - : QDialog(VISU::GetDesktop(theModule), 0, false, - WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) + : VisuGUI_Prs3dDlg(theModule) { setName("VisuGUI_ScalarBarDlg"); setCaption(SetPref ? tr("DLG_PREF_TITLE") : tr("DLG_PROP_TITLE")); @@ -1166,15 +158,21 @@ void VisuGUI_ScalarBarDlg::onHelp() /*! Initialize dialog from the presentation */ -void VisuGUI_ScalarBarDlg::initFromPrsObject(VISU::ScalarMap_i* thePrs) +void VisuGUI_ScalarBarDlg::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit) { - myScalarPane->initFromPrsObject( thePrs ); + if( theInit ) + myPrsCopy = VISU::TSameAsFactory().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish); + + myScalarPane->initFromPrsObject( myPrsCopy ); - if( thePrs->IsTimeStampFixed() ) + if( !theInit ) + return; + + if( myPrsCopy->IsTimeStampFixed() ) myTabBox->removePage( myInputPane ); else { - myInputPane->initFromPrsObject( thePrs ); + myInputPane->initFromPrsObject( myPrsCopy ); myTabBox->showPage( myInputPane ); } myTabBox->setCurrentPage( 0 ); @@ -1183,150 +181,28 @@ void VisuGUI_ScalarBarDlg::initFromPrsObject(VISU::ScalarMap_i* thePrs) /*! Store dialog to the presentation */ -int VisuGUI_ScalarBarDlg::storeToPrsObject(VISU::ScalarMap_i* thePrs) +int VisuGUI_ScalarBarDlg::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) { int ok = 1; - if( !thePrs->IsTimeStampFixed() ) + if( !myPrsCopy->IsTimeStampFixed() ) { if( !myInputPane->check() ) return 0; - ok = myInputPane->storeToPrsObject( thePrs ); + ok = myInputPane->storeToPrsObject( myPrsCopy ); } - return ok && myScalarPane->storeToPrsObject(thePrs); -} + ok = ok && myScalarPane->storeToPrsObject( myPrsCopy ); -/*! - Provides help on F1 button click -*/ -void VisuGUI_ScalarBarDlg::keyPressEvent( QKeyEvent* e ) -{ - QDialog::keyPressEvent( e ); - if ( e->isAccepted() ) - return; + VISU::TSameAsFactory().Copy(thePrs, myPrsCopy); - if ( e->key() == Key_F1 ) - { - e->accept(); - onHelp(); - } -} - -//####################################################################################### -VisuGUI_TextPrefDlg::VisuGUI_TextPrefDlg (QWidget* parent) - : QDialog(parent, 0, true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) -{ - setName("VisuGUI_TextPrefDlg"); - setCaption(tr("TIT_TEXT_PREF")); - setSizeGripEnabled(TRUE); - - QVBoxLayout* TopLayout = new QVBoxLayout(this); - TopLayout->setSpacing(6); - TopLayout->setMargin(11); - - // "Title" grp - QGroupBox* aTitleGrp = new QGroupBox (2, Qt::Vertical, tr("LBL_TITLE"), this); - - // edit line - myTitleEdt = new QLineEdit (aTitleGrp); - - // font - QHBox* aHBox = new QHBox (aTitleGrp); - aHBox->setSpacing(5); - myTitleFont = new SVTK_FontWidget (aHBox); - - TopLayout->addWidget(aTitleGrp); - - // "Labels" grp - QGroupBox* aLabelsGrp = new QGroupBox (1, Qt::Vertical, tr("LBL_LABELS"), this); - - // font - aHBox = new QHBox (aLabelsGrp); - aHBox->setSpacing(5); - myLabelFont = new SVTK_FontWidget (aHBox); - - TopLayout->addWidget(aLabelsGrp); - - // Common buttons =========================================================== - QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" ); - GroupButtons->setColumnLayout(0, Qt::Vertical ); - GroupButtons->layout()->setSpacing( 0 ); - GroupButtons->layout()->setMargin( 0 ); - QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() ); - GroupButtonsLayout->setAlignment( Qt::AlignTop ); - GroupButtonsLayout->setSpacing( 6 ); - GroupButtonsLayout->setMargin( 11 ); - - QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" ); - buttonOk->setAutoDefault( TRUE ); - buttonOk->setDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonOk, 0, 0 ); - GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 ); - - QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" ); - buttonCancel->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonCancel, 0, 2 ); - - QPushButton* buttonHelp = new QPushButton( tr( "&Help" ) , GroupButtons, "buttonHelp" ); - buttonHelp->setAutoDefault( TRUE ); - GroupButtonsLayout->addWidget( buttonHelp, 0, 3 ); - - TopLayout->addWidget( GroupButtons ); - - connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept())); - connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject())); - connect(buttonHelp, SIGNAL(clicked()), this, SLOT(onHelp())); -} - -void VisuGUI_TextPrefDlg::onHelp() -{ - QString aHelpFileName = "/files/scalar_map_presentation.htm"; - LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication()); - if (app) { - VisuGUI* aVisuGUI = dynamic_cast( app->activeModule() ); - app->onHelpContextModule(aVisuGUI ? app->moduleName(aVisuGUI->moduleName()) : QString(""), aHelpFileName); - } - else { - SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"), - QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). - arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(aHelpFileName), - QObject::tr("BUT_OK")); - } -} - -void VisuGUI_TextPrefDlg::storeBeginValues() -{ - myTitle = myTitleEdt->text(); - myTitleFont->GetData(myColors[0], myComboVals[0], myCheckVals[0], myCheckVals[1], myCheckVals[2]); - myLabelFont->GetData(myColors[1], myComboVals[1], myCheckVals[3], myCheckVals[4], myCheckVals[5]); -} - -/*! - Called when button is clicked, restore begin values -*/ -void VisuGUI_TextPrefDlg::reject() -{ - myTitleEdt->setText(myTitle); - myTitleFont->SetData(myColors[0], myComboVals[0], myCheckVals[0], myCheckVals[1], myCheckVals[2]); - myLabelFont->SetData(myColors[1], myComboVals[1], myCheckVals[3], myCheckVals[4], myCheckVals[5]); - - QDialog::reject(); -} -/*! - Called when button is clicked, store begin values -*/ -void VisuGUI_TextPrefDlg::accept() -{ - storeBeginValues(); - - QDialog::accept(); + return ok; } /*! Provides help on F1 button click */ -void VisuGUI_TextPrefDlg::keyPressEvent( QKeyEvent* e ) +void VisuGUI_ScalarBarDlg::keyPressEvent( QKeyEvent* e ) { QDialog::keyPressEvent( e ); if ( e->isAccepted() ) diff --git a/src/VISUGUI/VisuGUI_ScalarBarDlg.h b/src/VISUGUI/VisuGUI_ScalarBarDlg.h index 10fe93af..f05ee589 100644 --- a/src/VISUGUI/VisuGUI_ScalarBarDlg.h +++ b/src/VISUGUI/VisuGUI_ScalarBarDlg.h @@ -29,7 +29,8 @@ #ifndef VISUGUI_SCALARBARDLG_H #define VISUGUI_SCALARBARDLG_H -#include +#include "VisuGUI_Prs3dDlg.h" + #include #include #include @@ -40,159 +41,14 @@ #include #include #include -#include #include "QtxDblSpinBox.h" #include "VISU_ScalarMap_i.hh" -class QButtonGroup; -class QGroupBox; -class QLabel; -class QRadioButton; -class QCheckBox; -class QPushButton; -class QSpinBox; -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 -{ - Q_OBJECT; - - public: - VisuGUI_TextPrefDlg (QWidget* parent); - ~VisuGUI_TextPrefDlg() {}; - - QString getTitleText() { return myTitleEdt->text(); } - void setTitleText(QString theText) { myTitleEdt->setText(theText); } - - void setTitleVisible (bool isVisible) - { (isVisible)? myTitleEdt->show() : myTitleEdt->hide(); } - - void storeBeginValues(); - - private: - void keyPressEvent( QKeyEvent* e ); - - public: - SVTK_FontWidget* myTitleFont; - SVTK_FontWidget* myLabelFont; - - protected slots: - void accept(); - void reject(); - void onHelp(); - - private: - QLineEdit* myTitleEdt; - QString myTitle; - QColor myColors[2]; - int myComboVals[2]; - bool myCheckVals[6]; -}; - - -class VisuGUI_ScalarBarPane : public QVBox -{ - Q_OBJECT; - - public: - VisuGUI_ScalarBarPane(QWidget* parent, bool SetPref); - ~VisuGUI_ScalarBarPane() {}; - - void setRange( double imin, double imax, /*double fmin, double fmax,*/ bool sbRange ); - void setDefaultRange(double imin, double imax); - bool isIRange() {return RBIrange->isChecked();} - double getMin() {return MinEdit->text().toDouble();} - double getMax() {return MaxEdit->text().toDouble();} - int getOrientation(); - void setPosAndSize( double x, double y, double w, double h, bool vert ); - double getX() {return XSpin->value();} - double getY() {return YSpin->value();} - double getWidth() {return WidthSpin->value();} - double getHeight() {return HeightSpin->value();} - void setScalarBarData( int colors, int labels ); - int getNbColors() {return ColorSpin->value();} - int getNbLabels() {return LabelSpin->value();} - bool isLogarithmic() {return CBLog->isChecked();} - void setLogarithmic( bool on ) {CBLog->setChecked( on );} - bool isToSave() {return CBSave ? CBSave->isChecked() : false;} - - void initFromResources(); - void storeToResources(); - - void initFromPrsObject(VISU::ScalarMap_i* thePrs); - int storeToPrsObject(VISU::ScalarMap_i* thePrs); - - bool check(); - void deletePreview(); - - protected: - QButtonGroup* RangeGroup; - QRadioButton* RBFrange; - QRadioButton* RBIrange; - QLineEdit* MinEdit; - QLineEdit* MaxEdit; - - QRadioButton* RBhori; - QRadioButton* RBvert; - - QtxDblSpinBox* XSpin; - QtxDblSpinBox* YSpin; - - QtxDblSpinBox* WidthSpin; - QtxDblSpinBox* HeightSpin; - - QSpinBox* ColorSpin; - QSpinBox* LabelSpin; - - QCheckBox* CBSave; - QCheckBox* CBLog; - QLabel* myModeLbl; - QComboBox* myModeCombo; - QPushButton* myTextBtn; - VisuGUI_TextPrefDlg* myTextDlg; - - double Imin, Imax, /* Fmin, Fmax,*/ Rmin, Rmax; - double myHorX, myHorY, myHorW, myHorH; - double myVerX, myVerY, myVerW, myVerH; - int myRangeMode; - bool myIsStoreTextProp; - - private slots: - void changeDefaults( int ); - void changeRange( int ); - void XYChanged( double ); - void changeScalarMode( int ); - void onTextPref(); - void onPreviewCheck(bool thePreview); - void updatePreview(); - - private: - void createScalarBar(); - void deleteScalarBar(); - - QCheckBox* myPreviewCheck; - VISU_ScalarMapAct* myPreviewActor; - VISU::ScalarMap_i* myScalarMap; - VISU_ScalarMapPL* myScalarMapPL; - std::string myTitle; - - bool myBusy; -}; - - -class VisuGUI_ScalarBarDlg : public QDialog +class VisuGUI_ScalarBarDlg : public VisuGUI_Prs3dDlg { Q_OBJECT; @@ -205,8 +61,8 @@ class VisuGUI_ScalarBarDlg : public QDialog void initFromResources() {myScalarPane->initFromResources();} void storeToResources() {myScalarPane->storeToResources();} - void initFromPrsObject(VISU::ScalarMap_i* thePrs); - int storeToPrsObject(VISU::ScalarMap_i* thePrs); + virtual void initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit = true); + virtual int storeToPrsObject(VISU::ColoredPrs3d_i* thePrs); private: void keyPressEvent( QKeyEvent* e ); @@ -220,6 +76,8 @@ class VisuGUI_ScalarBarDlg : public QDialog VisuGUI_ScalarBarPane* myScalarPane; VisuGUI_InputPane* myInputPane; QTabWidget* myTabBox; + + SALOME::GenericObjPtr myPrsCopy; }; #endif // VISUGUI_SCALARBARDLG_H diff --git a/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx b/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx index 1d4abdd6..17bfa7bd 100644 --- a/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx +++ b/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.cxx @@ -32,6 +32,7 @@ #include "VISU_Result_i.hh" #include "VISU_ScalarMapOnDeformedShape_i.hh" +#include "VISU_ColoredPrs3dFactory.hh" #include "VISU_ScalarMapPL.hxx" #include "VISU_ScalarMapOnDeformedShapePL.hxx" @@ -62,12 +63,12 @@ using namespace std; * Constructor */ VisuGUI_ScalarMapOnDeformedShapeDlg::VisuGUI_ScalarMapOnDeformedShapeDlg (SalomeApp_Module* theModule) - : QDialog(VISU::GetDesktop(theModule), "VisuGUI_ScalarMapOnDeformedShapeDlg", false, - WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu), - myIsAnimation(false), - myVisuGUI(theModule) + : VisuGUI_Prs3dDlg(theModule), + myIsAnimation(false), + myUpdateScalars(true), + myIteration(1), + myVisuGUI(theModule) { - myPrs = NULL; setCaption(tr("DLG_TITLE")); setSizeGripEnabled(TRUE); @@ -162,22 +163,22 @@ VisuGUI_ScalarMapOnDeformedShapeDlg::VisuGUI_ScalarMapOnDeformedShapeDlg (Salome connect(myTimeStampsCombo, SIGNAL(activated(int)), this, SLOT(onTimeStampChanged(int))); } -void VisuGUI_ScalarMapOnDeformedShapeDlg::initFromPrsObject - (VISU::ScalarMapOnDeformedShape_i* thePrs, bool isAnim) +void VisuGUI_ScalarMapOnDeformedShapeDlg::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit) { - myIsAnimation = isAnim; - myPrs = thePrs; + if( theInit ) + myPrsCopy = VISU::TSameAsFactory().Create(thePrs, + VISU::ColoredPrs3d_i::EDoNotPublish); - setFactor(myPrs->GetScale()); - myTimeStampsCombo->setDisabled(isAnim); - myCurrMeshName = thePrs->GetCMeshName(); + setFactor(myPrsCopy->GetScale()); + myTimeStampsCombo->setDisabled(myIsAnimation); + myCurrMeshName = myPrsCopy->GetCMeshName(); - QString aFieldName(myPrs->GetScalarFieldName().c_str()); - CORBA::String_var aMeshName = myPrs->GetMeshName(); + QString aFieldName(myPrsCopy->GetScalarFieldName().c_str()); + CORBA::String_var aMeshName = myPrsCopy->GetMeshName(); float aIterFloat = GetFloatValueOfTimeStamp(aMeshName.in(), - myPrs->GetScalarFieldName().c_str(), - myPrs->GetScalarIteration(), - myPrs->GetScalarEntity()); + myPrsCopy->GetScalarFieldName().c_str(), + myPrsCopy->GetScalarIteration(), + myPrsCopy->GetScalarEntity()); QString aIteration(QString("%1").arg(aIterFloat)); if (myMeshFieldsTimes.size() == 0) @@ -264,7 +265,7 @@ void VisuGUI_ScalarMapOnDeformedShapeDlg::initFromPrsObject if (aChildSObj->FindAttribute(anAttr, "AttributeName")) { _PTR(AttributeName) aNameAttr(anAttr); QString aMeshName = VISU::getValue(aChildSObj, "myMeshName"); - CORBA::String_var aName = myPrs->GetMeshName(); + CORBA::String_var aName = myPrsCopy->GetMeshName(); if (aMeshName != aName.in()) continue; myCurrMeshName = aMeshName; @@ -299,48 +300,50 @@ void VisuGUI_ScalarMapOnDeformedShapeDlg::initFromPrsObject myTimeStampsCombo->setCurrentText(aIteration); SetScalarField( false ); - myScalarPane->initFromPrsObject(myPrs); + myScalarPane->initFromPrsObject(myPrsCopy); - if( thePrs->IsTimeStampFixed() ) + if( !theInit ) + return; + + if( myPrsCopy->IsTimeStampFixed() ) myTabBox->removePage( myInputPane ); else { - myInputPane->initFromPrsObject( thePrs ); + myInputPane->initFromPrsObject( myPrsCopy ); myTabBox->showPage( myInputPane ); } myTabBox->setCurrentPage( 0 ); } -int VisuGUI_ScalarMapOnDeformedShapeDlg::storeToPrsObject - (VISU::ScalarMapOnDeformedShape_i* thePrs, bool theUpdateScalars, int theIter) +int VisuGUI_ScalarMapOnDeformedShapeDlg::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) { - thePrs->SetScale(getFactor()); + myPrsCopy->SetScale(getFactor()); if (myIsAnimation) - thePrs->SetCScalarField(myPrs->GetScalarMeshName().c_str(), - getCurrentScalarFieldName().latin1(), - theIter, - myPrs->GetScalarEntity()); + myPrsCopy->SetCScalarField(myPrsCopy->GetScalarMeshName().c_str(), + getCurrentScalarFieldName().latin1(), + myIteration, + myPrsCopy->GetScalarEntity()); else - thePrs->SetCScalarField(myPrs->GetScalarMeshName().c_str(), - getCurrentScalarFieldName().latin1(), - myTimeStampsCombo->currentItem() + 1, - myPrs->GetScalarEntity()); + myPrsCopy->SetCScalarField(myPrsCopy->GetScalarMeshName().c_str(), + getCurrentScalarFieldName().latin1(), + myTimeStampsCombo->currentItem() + 1, + myPrsCopy->GetScalarEntity()); - if (theUpdateScalars) SetScalarField( false ); + if (myUpdateScalars) SetScalarField( false ); - thePrs->ShowColored(true); + myPrsCopy->ShowColored(true); - myScalarPane->storeToPrsObject(thePrs); + myScalarPane->storeToPrsObject(myPrsCopy); - if( !thePrs->IsTimeStampFixed() ) + if( !myPrsCopy->IsTimeStampFixed() ) { if( !myInputPane->check() ) return 0; - myInputPane->storeToPrsObject( thePrs ); + myInputPane->storeToPrsObject( myPrsCopy ); } - myPrs = thePrs; + VISU::TSameAsFactory().Copy(thePrs, myPrsCopy); return 1; } @@ -384,14 +387,14 @@ void VisuGUI_ScalarMapOnDeformedShapeDlg::SetScalarField(int theIter,QString the VISU::TEntity anEntity = getCurrentScalarEntity(); - myPrs->SetCScalarField(myCurrMeshName.latin1(), + myPrsCopy->SetCScalarField(myCurrMeshName.latin1(), aFieldName.latin1(), theIter, anEntity); if( save_scalar_pane ) { - myScalarPane->storeToPrsObject(myPrs); + myScalarPane->storeToPrsObject(myPrsCopy); UpdateScalarField(); } } @@ -465,15 +468,15 @@ void VisuGUI_ScalarMapOnDeformedShapeDlg::onTimeStampChanged(int){ } void VisuGUI_ScalarMapOnDeformedShapeDlg::UpdateScalarField(){ - myPrs->SetScale(getFactor()); + myPrsCopy->SetScale(getFactor()); vtkFloatingPointType aRange[2]; - myPrs->GetSpecificPL()->Build(); - myPrs->GetSpecificPL()->Update(); - myPrs->GetSpecificPL()->GetSourceRange(aRange); + myPrsCopy->GetSpecificPL()->Build(); + myPrsCopy->GetSpecificPL()->Update(); + myPrsCopy->GetSpecificPL()->GetSourceRange(aRange); double aDoubleRange[2]; aDoubleRange[0] = double(aRange[0]); aDoubleRange[1] = double(aRange[1]); - myScalarPane->initFromPrsObject(myPrs); + myScalarPane->initFromPrsObject(myPrsCopy); myScalarPane->setRange(aDoubleRange[0],aDoubleRange[1],myScalarPane->isIRange()); } @@ -482,7 +485,7 @@ float VisuGUI_ScalarMapOnDeformedShapeDlg::GetFloatValueOfTimeStamp(const char* const int theIter, const VISU::TEntity theEntity){ float ret=1; - VISU::Result_i* theResult = myPrs->GetCResult(); + VISU::Result_i* theResult = myPrsCopy->GetCResult(); VISU::PField aField = theResult->GetInput()->GetField(theMeshName,theEntity,theFieldName); if(!aField) return ret; VISU::TValField& aValField = aField->myValField; diff --git a/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.h b/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.h index cb7c9c6f..b12c706f 100644 --- a/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.h +++ b/src/VISUGUI/VisuGUI_ScalarMapOnDeformedShapeDlg.h @@ -28,13 +28,17 @@ #ifndef VISUGUI_SCALARMAPONDEFORMEDSHAPEDLS_H #define VISUGUI_SCALARMAPONDEFORMEDSHAPEDLS_H -#include "VisuGUI_ScalarBarDlg.h" +#include "VisuGUI_Prs3dDlg.h" + +#include "VISUConfig.hh" +#include "VISU_Convertor.hxx" #include "QtxDblSpinBox.h" #include #include #include +#include #include #include #include @@ -43,14 +47,12 @@ class SalomeApp_Module; class VisuGUI_InputPane; -class QComboBox; -class QString; namespace VISU{ class ScalarMapOnDeformedShape_i; } -class VisuGUI_ScalarMapOnDeformedShapeDlg : public QDialog +class VisuGUI_ScalarMapOnDeformedShapeDlg : public VisuGUI_Prs3dDlg { Q_OBJECT @@ -63,9 +65,12 @@ public: void setFactor(double theFactor) { ScalFact->setValue(theFactor); } + void setAnimation( bool on ) { myIsAnimation = on; } + void setUpdateScalars( bool on ) { myUpdateScalars = on; } + void setIteration( int value ) { myIteration = value; } - void initFromPrsObject(VISU::ScalarMapOnDeformedShape_i* thePrs,bool isAnim=false); - int storeToPrsObject(VISU::ScalarMapOnDeformedShape_i* thePrs,bool theUpdateScalars=true,int theIter=1); + virtual void initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit = true); + virtual int storeToPrsObject(VISU::ColoredPrs3d_i* thePrs); int getCurrentScalarFieldNamePos(); QString getCurrentScalarFieldName(); @@ -102,9 +107,11 @@ private: QString myCurrMeshName; int myCurrScalarIter; bool myIsAnimation; + bool myUpdateScalars; + int myIteration; _PTR(SObject) mySelectionObj; - VISU::ScalarMapOnDeformedShape_i* myPrs; + SALOME::GenericObjPtr myPrsCopy; SalomeApp_Module* myVisuGUI; protected: diff --git a/src/VISUGUI/VisuGUI_StreamLinesDlg.cxx b/src/VISUGUI/VisuGUI_StreamLinesDlg.cxx index fd98bf6a..c63ae9d9 100644 --- a/src/VISUGUI/VisuGUI_StreamLinesDlg.cxx +++ b/src/VISUGUI/VisuGUI_StreamLinesDlg.cxx @@ -30,6 +30,7 @@ #include "VISU_Mesh_i.hh" #include "VISU_Gen_i.hh" #include "VISU_StreamLines_i.hh" +#include "VISU_ColoredPrs3dFactory.hh" #include "VISU_StreamLinesPL.hxx" #include "VISU_Actor.h" @@ -48,20 +49,22 @@ #include +#include "QtxDblSpinBox.h" + #include #include +#include #include #include #include +#include using namespace std; VisuGUI_StreamLinesDlg::VisuGUI_StreamLinesDlg (SalomeApp_Module* theModule) - : QDialog(VISU::GetDesktop(theModule), "VisuGUI_StreamLinesDlg", false, - WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu), - myVisuGUI(theModule) + : VisuGUI_Prs3dDlg(theModule), + myVisuGUI(theModule) { - myPrs = NULL; setCaption(tr("DLG_TITLE")); setSizeGripEnabled(TRUE); @@ -310,22 +313,15 @@ VisuGUI_StreamLinesDlg::VisuGUI_StreamLinesDlg (SalomeApp_Module* theModule) } -void VisuGUI_StreamLinesDlg::initFromPrsObject (VISU::StreamLines_i* thePrs) +void VisuGUI_StreamLinesDlg::initFromPrsObject (VISU::ColoredPrs3d_i* thePrs, bool theInit) { - myScalarPane->initFromPrsObject(thePrs); + if( theInit ) + myPrsCopy = VISU::TSameAsFactory().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish); - if( thePrs->IsTimeStampFixed() ) - myTabBox->removePage( myInputPane ); - else - { - myInputPane->initFromPrsObject( thePrs ); - myTabBox->showPage( myInputPane ); - } - myTabBox->setCurrentPage( 0 ); + myScalarPane->initFromPrsObject( myPrsCopy ); - myPrs = thePrs; static int aNbOfSteps = 30; - VISU_StreamLinesPL* aStreamLinesPL = thePrs->GetSpecificPL(); + VISU_StreamLinesPL* aStreamLinesPL = myPrsCopy->GetSpecificPL(); float aMin, aMax; aMin = aStreamLinesPL->GetMinPropagationTime(); aMax = aStreamLinesPL->GetMaxPropagationTime(); @@ -345,7 +341,7 @@ void VisuGUI_StreamLinesDlg::initFromPrsObject (VISU::StreamLines_i* thePrs) myIntegStepLen->setValue(aStreamLinesPL->GetIntegrationStep()); myIntegStepLen->setLineStep((aMax-aMin)/aNbOfSteps); - switch (thePrs->GetDirection()) { + switch (myPrsCopy->GetDirection()) { case VISU::StreamLines::FORWARD: myDirCombo->setCurrentItem(0); break; @@ -355,13 +351,13 @@ void VisuGUI_StreamLinesDlg::initFromPrsObject (VISU::StreamLines_i* thePrs) case VISU::StreamLines::BOTH: myDirCombo->setCurrentItem(2); } - myUseScalar->setChecked(thePrs->IsColored()); - myPntPercent->setValue(thePrs->GetUsedPoints()); + myUseScalar->setChecked(myPrsCopy->IsColored()); + myPntPercent->setValue(myPrsCopy->GetUsedPoints()); mySrcCombo->setEnabled(false); - QString aSrcEntry = thePrs->GetSourceEntry(); + QString aSrcEntry = myPrsCopy->GetSourceEntry(); - SALOMEDS::Color anOldColor = thePrs->GetColor(); + SALOMEDS::Color anOldColor = myPrsCopy->GetColor(); QColor aColor = QColor(int(255*anOldColor.R),int(255*anOldColor.G),int(255*anOldColor.B)); setColor(aColor); enableSetColor(); @@ -386,27 +382,40 @@ void VisuGUI_StreamLinesDlg::initFromPrsObject (VISU::StreamLines_i* thePrs) INITPRS(myPrsList, 4); } #undef INITPRS + + if( !theInit ) + return; + + if( myPrsCopy->IsTimeStampFixed() ) + myTabBox->removePage( myInputPane ); + else + { + myInputPane->initFromPrsObject( myPrsCopy ); + myTabBox->showPage( myInputPane ); + } + myTabBox->setCurrentPage( 0 ); + } -int VisuGUI_StreamLinesDlg::storeToPrsObject (VISU::StreamLines_i* thePrs) +int VisuGUI_StreamLinesDlg::storeToPrsObject (VISU::ColoredPrs3d_i* thePrs) { - bool isAccepted = myScalarPane->storeToPrsObject(thePrs); + bool isAccepted = myScalarPane->storeToPrsObject(myPrsCopy); - if( isAccepted && !thePrs->IsTimeStampFixed() ) + if( isAccepted && !myPrsCopy->IsTimeStampFixed() ) { if( !myInputPane->check() ) return 0; - isAccepted = myInputPane->storeToPrsObject( thePrs ); + isAccepted = myInputPane->storeToPrsObject( myPrsCopy ); } if (isAccepted) { - thePrs->ShowColored(myUseScalar->isChecked()); - if (!thePrs->IsColored()) { + myPrsCopy->ShowColored(myUseScalar->isChecked()); + if (!myPrsCopy->IsColored()) { SALOMEDS::Color aColor; aColor.R = myColor.red()/255.; aColor.G = myColor.green()/255.; aColor.B = myColor.blue()/255.; - thePrs->SetColor(aColor); + myPrsCopy->SetColor(aColor); } VISU::StreamLines::Direction aDirection = VISU::StreamLines::BOTH; @@ -451,7 +460,7 @@ int VisuGUI_StreamLinesDlg::storeToPrsObject (VISU::StreamLines_i* thePrs) aPrs = createMesh(aType, aName); } } - isAccepted = thePrs->SetParams(myIntegStepLen->value(), + isAccepted = myPrsCopy->SetParams(myIntegStepLen->value(), myPropTime->value(), myStepLen->value(), aPrs, @@ -462,6 +471,9 @@ int VisuGUI_StreamLinesDlg::storeToPrsObject (VISU::StreamLines_i* thePrs) // SUIT_MessageBox::warn1(VisuGUI::application()->desktop(), tr("WRN_VISU"), // tr("ERR_CANT_BUILD_PRESENTATION"), // tr("BUT_OK")); + + VISU::TSameAsFactory().Copy(thePrs, myPrsCopy); + return isAccepted; } diff --git a/src/VISUGUI/VisuGUI_StreamLinesDlg.h b/src/VISUGUI/VisuGUI_StreamLinesDlg.h index f40a16f5..11b68a37 100644 --- a/src/VISUGUI/VisuGUI_StreamLinesDlg.h +++ b/src/VISUGUI/VisuGUI_StreamLinesDlg.h @@ -24,14 +24,16 @@ #ifndef VISUGUI_STREAMLINESDLG_H #define VISUGUI_STREAMLINESDLG_H -#include "VisuGUI_ScalarBarDlg.h" +#include "VisuGUI_Prs3dDlg.h" -#include +#include #include #include #include #include +#include "VISUConfig.hh" + class SalomeApp_Module; class VisuGUI_InputPane; class QtxDblSpinBox; @@ -40,15 +42,16 @@ namespace VISU{ class StreamLines_i; } -class VisuGUI_StreamLinesDlg: public QDialog +class VisuGUI_StreamLinesDlg: public VisuGUI_Prs3dDlg { Q_OBJECT public: VisuGUI_StreamLinesDlg (SalomeApp_Module* theModule); ~VisuGUI_StreamLinesDlg() {}; - void initFromPrsObject(VISU::StreamLines_i* thePrs); - int storeToPrsObject(VISU::StreamLines_i* thePrs); + virtual void initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit = true); + virtual int storeToPrsObject(VISU::ColoredPrs3d_i* thePrs); + void setColor( QColor color ); void enableMagnColor( bool enable ); @@ -96,7 +99,7 @@ private: QStringList myPrsLst; _PTR(SObject) mySelectionObj; - VISU::StreamLines_i* myPrs; + SALOME::GenericObjPtr myPrsCopy; SalomeApp_Module* myVisuGUI; private slots: diff --git a/src/VISUGUI/VisuGUI_TimeAnimation.cxx b/src/VISUGUI/VisuGUI_TimeAnimation.cxx index baee6873..70f7fc77 100644 --- a/src/VISUGUI/VisuGUI_TimeAnimation.cxx +++ b/src/VISUGUI/VisuGUI_TimeAnimation.cxx @@ -26,6 +26,7 @@ #include "VisuGUI.h" #include "VisuGUI_Tools.h" #include "VisuGUI_ViewTools.h" +#include "VisuGUI_ScalarBarDlg.h" #include "VisuGUI_DeformedShapeDlg.h" #include "VisuGUI_CutPlanesDlg.h" #include "VisuGUI_CutLinesDlg.h" @@ -80,6 +81,7 @@ #include #include #include +#include #define MAXVAL 1e10 @@ -796,7 +798,8 @@ void SetupDlg::onPreferencesDlg() typedef VisuGUI_ScalarMapOnDeformedShapeDlg DLG; typedef VISU::ScalarMapOnDeformedShape_i TYPE; DLG* aDlg = new DLG (myModule); - aDlg->initFromPrsObject(dynamic_cast(aData.myPrs[0]),true); + aDlg->setAnimation( true ); + aDlg->initFromPrsObject(dynamic_cast(aData.myPrs[0])); if (aDlg->exec()) { int anbFrames=aDlg->getCurrentScalarNbIterations(); @@ -806,7 +809,9 @@ void SetupDlg::onPreferencesDlg() aIter = i+1; if(i+1 > anbFrames) aIter=anbFrames; - aDlg->storeToPrsObject(aCurrPrs_i,false,aIter); + aDlg->setUpdateScalars(false); + aDlg->setIteration(aIter); + aDlg->storeToPrsObject(aCurrPrs_i); } } delete aDlg; diff --git a/src/VISUGUI/VisuGUI_VectorsDlg.cxx b/src/VISUGUI/VisuGUI_VectorsDlg.cxx index 37614b16..03323bff 100644 --- a/src/VISUGUI/VisuGUI_VectorsDlg.cxx +++ b/src/VISUGUI/VisuGUI_VectorsDlg.cxx @@ -29,10 +29,10 @@ #include "VisuGUI_VectorsDlg.h" #include "VisuGUI.h" -//#include "VisuGUI_Selection.h" #include "VisuGUI_Tools.h" #include "VisuGUI_InputPane.h" +#include "VISU_ColoredPrs3dFactory.hh" #include "VISU_Vectors_i.hh" #include "LightApp_Application.h" #include "SalomeApp_Module.h" @@ -52,8 +52,7 @@ using namespace std; Constructor */ VisuGUI_VectorsDlg::VisuGUI_VectorsDlg (SalomeApp_Module* theModule) - : QDialog(VISU::GetDesktop(theModule), "VisuGUI_VectorsDlg", false, - WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) + : VisuGUI_Prs3dDlg(theModule) { setCaption(tr("DLG_TITLE")); setSizeGripEnabled(TRUE); @@ -202,57 +201,68 @@ VisuGUI_VectorsDlg::VisuGUI_VectorsDlg (SalomeApp_Module* theModule) -void VisuGUI_VectorsDlg::initFromPrsObject(VISU::Vectors_i* thePrs) { - myScalarPane->initFromPrsObject(thePrs); - if( thePrs->IsTimeStampFixed() ) - myTabBox->removePage( myInputPane ); - else - { - myInputPane->initFromPrsObject( thePrs ); - myTabBox->showPage( myInputPane ); - } - myTabBox->setCurrentPage( 0 ); - setScaleFactor(thePrs->GetScale()); - setLineWidth((int)thePrs->GetLineWidth()); - setUseMagnColor(thePrs->IsColored()); - SALOMEDS::Color anOldColor = thePrs->GetColor(); +void VisuGUI_VectorsDlg::initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit) { + if( theInit ) + myPrsCopy = VISU::TSameAsFactory().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish); + + myScalarPane->initFromPrsObject( myPrsCopy ); + + setScaleFactor(myPrsCopy->GetScale()); + setLineWidth((int)myPrsCopy->GetLineWidth()); + setUseMagnColor(myPrsCopy->IsColored()); + SALOMEDS::Color anOldColor = myPrsCopy->GetColor(); QColor aColor = QColor(int(255*anOldColor.R),int(255*anOldColor.G),int(255*anOldColor.B)); setColor(aColor); - if (thePrs->GetGlyphType() != VISU::Vectors::NONE) { + if (myPrsCopy->GetGlyphType() != VISU::Vectors::NONE) { setUseGlyphs(true); - setGlyphType(thePrs->GetGlyphType()); - setGlyphPos(thePrs->GetGlyphPos()); + setGlyphType(myPrsCopy->GetGlyphType()); + setGlyphPos(myPrsCopy->GetGlyphPos()); } else setUseGlyphs(false); enableSetColor(); + + if( !theInit ) + return; + + if( myPrsCopy->IsTimeStampFixed() ) + myTabBox->removePage( myInputPane ); + else + { + myInputPane->initFromPrsObject( myPrsCopy ); + myTabBox->showPage( myInputPane ); + } + myTabBox->setCurrentPage( 0 ); } -int VisuGUI_VectorsDlg::storeToPrsObject(VISU::Vectors_i* thePrs) { - myScalarPane->storeToPrsObject(thePrs); - if( !thePrs->IsTimeStampFixed() ) +int VisuGUI_VectorsDlg::storeToPrsObject(VISU::ColoredPrs3d_i* thePrs) { + myScalarPane->storeToPrsObject(myPrsCopy); + if( !myPrsCopy->IsTimeStampFixed() ) { if( !myInputPane->check() ) return 0; - myInputPane->storeToPrsObject( thePrs ); + myInputPane->storeToPrsObject( myPrsCopy ); } - thePrs->SetScale(getScaleFactor()); - thePrs->SetLineWidth(getLineWidth()); - thePrs->ShowColored(getUseMagnColor()); - if(!thePrs->IsColored()){ + myPrsCopy->SetScale(getScaleFactor()); + myPrsCopy->SetLineWidth(getLineWidth()); + myPrsCopy->ShowColored(getUseMagnColor()); + if(!myPrsCopy->IsColored()){ SALOMEDS::Color aColor; aColor.R = myColor.red()/255.; aColor.G = myColor.green()/255.; aColor.B = myColor.blue()/255.; - thePrs->SetColor(aColor); + myPrsCopy->SetColor(aColor); } if (getUseGlyphs()) { - thePrs->SetGlyphPos(getGlyphPos()); - thePrs->SetGlyphType(getGlyphType()); + myPrsCopy->SetGlyphPos(getGlyphPos()); + myPrsCopy->SetGlyphType(getGlyphType()); } else - thePrs->SetGlyphType(VISU::Vectors::NONE); + myPrsCopy->SetGlyphType(VISU::Vectors::NONE); + + VISU::TSameAsFactory().Copy(thePrs, myPrsCopy); + return 1; } diff --git a/src/VISUGUI/VisuGUI_VectorsDlg.h b/src/VISUGUI/VisuGUI_VectorsDlg.h index 437538f8..916eea75 100644 --- a/src/VISUGUI/VisuGUI_VectorsDlg.h +++ b/src/VISUGUI/VisuGUI_VectorsDlg.h @@ -29,7 +29,7 @@ #ifndef VISUGUI_VECTORSDLG_H #define VISUGUI_VECTORSDLG_H -#include "VisuGUI_ScalarBarDlg.h" +#include "VisuGUI_Prs3dDlg.h" #include "QtxDblSpinBox.h" #include @@ -52,7 +52,7 @@ namespace VISU{ class Vectors_i; } -class VisuGUI_VectorsDlg : public QDialog +class VisuGUI_VectorsDlg : public VisuGUI_Prs3dDlg { Q_OBJECT @@ -78,8 +78,8 @@ public: VISU::Vectors::GlyphPos getGlyphPos(); void enableMagnColor( bool enable ); - void initFromPrsObject(VISU::Vectors_i* thePrs); - int storeToPrsObject(VISU::Vectors_i* thePrs); + virtual void initFromPrsObject(VISU::ColoredPrs3d_i* thePrs, bool theInit = true); + virtual int storeToPrsObject(VISU::ColoredPrs3d_i* thePrs); private: void keyPressEvent( QKeyEvent* e ); @@ -119,6 +119,8 @@ private: VisuGUI_ScalarBarPane* myScalarPane; VisuGUI_InputPane* myInputPane; + SALOME::GenericObjPtr myPrsCopy; + private slots: void enableGlyphType(); void setVColor(); diff --git a/src/VISU_I/VISU_ColoredPrs3dCache_i.cc b/src/VISU_I/VISU_ColoredPrs3dCache_i.cc index 9e82c868..7dde86de 100644 --- a/src/VISU_I/VISU_ColoredPrs3dCache_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3dCache_i.cc @@ -273,7 +273,7 @@ VISU::ColoredPrs3dCache_i aPrs3d->SetEntity( theInput.myEntity ); aPrs3d->SetFieldName( theInput.myFieldName ); aPrs3d->SetTimeStampNumber( theInput.myTimeStampNumber ); - aPrs3d->Apply(); + aPrs3d->Apply( false ); return aPrs3d; } diff --git a/src/VISU_I/VISU_ColoredPrs3dFactory.cc b/src/VISU_I/VISU_ColoredPrs3dFactory.cc index cd6e5148..e1129b81 100644 --- a/src/VISU_I/VISU_ColoredPrs3dFactory.cc +++ b/src/VISU_I/VISU_ColoredPrs3dFactory.cc @@ -72,7 +72,7 @@ namespace VISU theColoredPrs3d->SetEntity(theEntity); theColoredPrs3d->SetFieldName(theFieldName.c_str()); theColoredPrs3d->SetTimeStampNumber(theIteration); - if(theColoredPrs3d->Apply()) + if(theColoredPrs3d->Apply(false)) return true; #ifndef _DEXCEPT_ #ifdef NO_CAS_CATCH diff --git a/src/VISU_I/VISU_ColoredPrs3dFactory.hh b/src/VISU_I/VISU_ColoredPrs3dFactory.hh index 1dfda5aa..9bc14a38 100644 --- a/src/VISU_I/VISU_ColoredPrs3dFactory.hh +++ b/src/VISU_I/VISU_ColoredPrs3dFactory.hh @@ -285,17 +285,23 @@ namespace VISU { typedef typename TL::TColoredEnum2Type::TResult TColoredPrs3d; + void + Copy(ColoredPrs3d_i* theColoredPrs3dTo, ColoredPrs3d_i* theColoredPrs3dFrom) + { + theColoredPrs3dTo->SetCResult(theColoredPrs3dFrom->GetCResult()); + theColoredPrs3dTo->SetMeshName(theColoredPrs3dFrom->GetCMeshName().c_str()); + theColoredPrs3dTo->SetEntity(theColoredPrs3dFrom->GetEntity()); + theColoredPrs3dTo->SetFieldName(theColoredPrs3dFrom->GetCFieldName().c_str()); + theColoredPrs3dTo->SetTimeStampNumber(theColoredPrs3dFrom->GetTimeStampNumber()); + theColoredPrs3dTo->SameAs(theColoredPrs3dFrom); + } + TColoredPrs3d* Create(ColoredPrs3d_i* theColoredPrs3d, ColoredPrs3d_i::EPublishInStudyMode thePublishInStudyMode) { TColoredPrs3d* aSameColoredPrs3d = new TColoredPrs3d(thePublishInStudyMode); - aSameColoredPrs3d->SetCResult(theColoredPrs3d->GetCResult()); - aSameColoredPrs3d->SetMeshName(theColoredPrs3d->GetCMeshName().c_str()); - aSameColoredPrs3d->SetEntity(theColoredPrs3d->GetEntity()); - aSameColoredPrs3d->SetFieldName(theColoredPrs3d->GetCFieldName().c_str()); - aSameColoredPrs3d->SetTimeStampNumber(theColoredPrs3d->GetTimeStampNumber()); - aSameColoredPrs3d->SameAs(theColoredPrs3d); + Copy(aSameColoredPrs3d, theColoredPrs3d); return aSameColoredPrs3d; } }; diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.cc b/src/VISU_I/VISU_ColoredPrs3d_i.cc index c9d6c83e..ba7a4eec 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3d_i.cc @@ -104,12 +104,12 @@ VISU::ColoredPrs3d_i //--------------------------------------------------------------- bool VISU::ColoredPrs3d_i -::SetInput() +::SetInput(bool theReInit) { try{ - if(TSuperClass::SetInput()){ + if(TSuperClass::SetInput(theReInit)){ if(CheckIsPossible()){ - if(OnSetInput()){ + if(OnSetInput(theReInit)){ if(Create(GetCMeshName(),GetEntity(),GetCFieldName(),GetTimeStampNumber())) return true; }else @@ -138,7 +138,7 @@ VISU::ColoredPrs3d_i //--------------------------------------------------------------- bool VISU::ColoredPrs3d_i -::OnSetInput() +::OnSetInput(bool theReInit) { myPreviousEntity = myEntity; myPreviousFieldName = myFieldName; @@ -148,7 +148,7 @@ VISU::ColoredPrs3d_i if(anIsCreatNew) CreatePipeLine(NULL); // to create proper pipeline - DoSetInput(anIsCreatNew); + DoSetInput(anIsCreatNew, theReInit); // To update title according to the new input SetTitle(GetCTitle().c_str()); @@ -428,13 +428,19 @@ VISU::ColoredPrs3d_i if(const ColoredPrs3d_i* aPrs3d = dynamic_cast(theOrigin)){ ColoredPrs3d_i* anOrigin = const_cast(aPrs3d); - bool anIsCreatNew = OnSetInput(); + bool anIsCreatNew = OnSetInput(false); if(anIsCreatNew) Build(ESameAs); TSuperClass::SameAs(theOrigin); - SetScalarMode(anOrigin->GetScalarMode()); + CORBA::Long aNbComp = GetField()->myNbComp; + CORBA::Long anOriginNbComp = anOrigin->GetField()->myNbComp; + if(anOriginNbComp < aNbComp) + SetScalarMode(0); + else + SetScalarMode(anOrigin->GetScalarMode()); + SetNbColors(anOrigin->GetNbColors()); SetBarOrientation(anOrigin->GetBarOrientation()); @@ -458,6 +464,9 @@ VISU::ColoredPrs3d_i SetLblFontType(anOrigin->GetLblFontType()); anOrigin->GetLabelColor(&r,&g,&b); SetLabelColor(r,g,b); + + UseFixedRange( anOrigin->IsRangeFixed() ); + myIsTimeStampFixed = anOrigin->IsTimeStampFixed(); } } @@ -474,6 +483,14 @@ void VISU::ColoredPrs3d_i ::SetScalarMode(CORBA::Long theScalarMode) { + CORBA::Long aNbComp = GetField()->myNbComp; + if(aNbComp == 1) + theScalarMode = 1; + else if(theScalarMode > aNbComp) + theScalarMode = 0; + + //cout << "VISU::ColoredPrs3d_i::SetScalarMode - " << theScalarMode << endl; + myScalarMapPL->SetScalarMode(theScalarMode); } @@ -905,6 +922,7 @@ void VISU::ColoredPrs3d_i ::UseFixedRange(bool theUseFixedRange) { + //cout << "UseFixedRange(" << (int)theUseFixedRange << ") for " << this << endl; myIsFixedRange = theUseFixedRange; } @@ -931,7 +949,7 @@ VISU::ColoredPrs3d_i SetEntity(theEntity); SetFieldName(theFieldName.c_str()); SetTimeStampNumber(theTimeStampNumber); - OnSetInput(); + OnSetInput(false); Build(ECreateNew); // to get corresponding input from result and initilize the pipeline @@ -1043,7 +1061,7 @@ VISU::ColoredPrs3d_i SetFieldName(VISU::Storable::FindValue(theMap,"myFieldName").latin1()); SetTimeStampNumber(VISU::Storable::FindValue(theMap,"myIteration").toInt()); myIsTimeStampFixed = VISU::Storable::FindValue(theMap,"myIsTimeStampFixed").toInt(); - OnSetInput(); + OnSetInput(false); SetHolderEntry(VISU::Storable::FindValue(theMap,"myHolderEntry").latin1()); diff --git a/src/VISU_I/VISU_ColoredPrs3d_i.hh b/src/VISU_I/VISU_ColoredPrs3d_i.hh index 885429bf..c8254076 100644 --- a/src/VISU_I/VISU_ColoredPrs3d_i.hh +++ b/src/VISU_I/VISU_ColoredPrs3d_i.hh @@ -374,7 +374,7 @@ namespace VISU */ virtual bool - SetInput(); + SetInput(bool theReInit); //! Restore input parameters if Apply function fails (redefines Prs3d::OnRestoreInput) virtual @@ -404,7 +404,7 @@ namespace VISU */ virtual bool - OnSetInput(); + OnSetInput(bool theReInit); /*! Sets input data set according to basic input parameters - @@ -412,7 +412,7 @@ namespace VISU */ virtual void - DoSetInput(bool theIsInitilizePipe) = 0; + DoSetInput(bool theIsInitilizePipe, bool theReInit) = 0; /*! The enumeration allow to define what mode should be used for the presentation building. diff --git a/src/VISU_I/VISU_GaussPoints_i.cc b/src/VISU_I/VISU_GaussPoints_i.cc index d5e7cec9..d8f8cf08 100644 --- a/src/VISU_I/VISU_GaussPoints_i.cc +++ b/src/VISU_I/VISU_GaussPoints_i.cc @@ -579,7 +579,7 @@ VISU::GaussPoints_i //---------------------------------------------------------------------------- void VISU::GaussPoints_i -::DoSetInput(bool theIsInitilizePipe) +::DoSetInput(bool theIsInitilizePipe, bool theReInit) { VISU::Result_i::TInput* anInput = GetCResult()->GetInput(); if(!anInput) @@ -603,7 +603,7 @@ VISU::GaussPoints_i GetCResult()->MinMaxConnect(this); // To update scalar range according to the new input - if(!IsTimeStampFixed()) + if(!IsTimeStampFixed() || theReInit) SetSourceRange(); } diff --git a/src/VISU_I/VISU_GaussPoints_i.hh b/src/VISU_I/VISU_GaussPoints_i.hh index 708c964b..3d651d34 100644 --- a/src/VISU_I/VISU_GaussPoints_i.hh +++ b/src/VISU_I/VISU_GaussPoints_i.hh @@ -269,7 +269,7 @@ namespace VISU //! Redefines VISU_ColoredPrs3d_i::DoSetInput virtual void - DoSetInput(bool theIsInitilizePipe); + DoSetInput(bool theIsInitilizePipe, bool theReInit); //! Redefines VISU_ColoredPrs3d_i::CreatePipeLine virtual diff --git a/src/VISU_I/VISU_IsoSurfaces_i.cc b/src/VISU_I/VISU_IsoSurfaces_i.cc index ac7fd08f..4e97cdd7 100644 --- a/src/VISU_I/VISU_IsoSurfaces_i.cc +++ b/src/VISU_I/VISU_IsoSurfaces_i.cc @@ -208,10 +208,10 @@ VISU::IsoSurfaces_i //---------------------------------------------------------------------------- void VISU::IsoSurfaces_i -::DoSetInput(bool theIsInitilizePipe) +::DoSetInput(bool theIsInitilizePipe, bool theReInit) { - TSuperClass::DoSetInput(theIsInitilizePipe); - if(theIsInitilizePipe || (!IsTimeStampFixed() && !IsRangeFixed())) + TSuperClass::DoSetInput(theIsInitilizePipe, theReInit); + if(theIsInitilizePipe || (!IsTimeStampFixed() && !IsRangeFixed()) || theReInit) SetSubRange(GetSourceMin(), GetSourceMax()); } diff --git a/src/VISU_I/VISU_IsoSurfaces_i.hh b/src/VISU_I/VISU_IsoSurfaces_i.hh index 93e4b8df..4723ebbc 100644 --- a/src/VISU_I/VISU_IsoSurfaces_i.hh +++ b/src/VISU_I/VISU_IsoSurfaces_i.hh @@ -95,7 +95,7 @@ namespace VISU //! Redefines VISU_ScalarMap_i::DoSetInput virtual void - DoSetInput(bool theIsInitilizePipe); + DoSetInput(bool theIsInitilizePipe, bool theReInit); //! Redefines VISU_ScalarMap_i::CheckIsPossible virtual diff --git a/src/VISU_I/VISU_Prs3d_i.cc b/src/VISU_I/VISU_Prs3d_i.cc index 9c83f499..26437f6b 100644 --- a/src/VISU_I/VISU_Prs3d_i.cc +++ b/src/VISU_I/VISU_Prs3d_i.cc @@ -107,7 +107,7 @@ VISU::Prs3d_i //---------------------------------------------------------------------------- bool VISU::Prs3d_i -::SetInput() +::SetInput(bool theReInit) { if(!myResult) return false; @@ -136,10 +136,10 @@ VISU::Prs3d_i //---------------------------------------------------------------------------- CORBA::Boolean VISU::Prs3d_i -::Apply() +::Apply(bool theReInit) { try{ - if(SetInput()){ + if(SetInput(theReInit)){ UpdateActors(); return true; } diff --git a/src/VISU_I/VISU_Prs3d_i.hh b/src/VISU_I/VISU_Prs3d_i.hh index b52c09ec..71331db5 100644 --- a/src/VISU_I/VISU_Prs3d_i.hh +++ b/src/VISU_I/VISU_Prs3d_i.hh @@ -96,7 +96,7 @@ namespace VISU //---------------------------------------------------------------------------- virtual CORBA::Boolean - Apply(); + Apply(bool theReInit); //---------------------------------------------------------------------------- void @@ -278,7 +278,7 @@ namespace VISU */ virtual bool - SetInput(); + SetInput(bool theReInit); //! Restore input parameters if Apply function fails virtual diff --git a/src/VISU_I/VISU_ScalarMap_i.cc b/src/VISU_I/VISU_ScalarMap_i.cc index 9b6a88c8..0742fb91 100644 --- a/src/VISU_I/VISU_ScalarMap_i.cc +++ b/src/VISU_I/VISU_ScalarMap_i.cc @@ -283,7 +283,7 @@ VISU::ScalarMap_i //---------------------------------------------------------------------------- void VISU::ScalarMap_i -::DoSetInput(bool theIsInitilizePipe) +::DoSetInput(bool theIsInitilizePipe, bool theReInit) { VISU::Result_i::TInput* anInput = GetCResult()->GetInput(); if(!anInput) @@ -306,7 +306,7 @@ VISU::ScalarMap_i } // To update scalar range according to the new input - if(!IsTimeStampFixed() && !IsRangeFixed()) + if(!IsTimeStampFixed() && !IsRangeFixed() || theReInit) SetSourceRange(); } diff --git a/src/VISU_I/VISU_ScalarMap_i.hh b/src/VISU_I/VISU_ScalarMap_i.hh index 069ee213..c8515e20 100644 --- a/src/VISU_I/VISU_ScalarMap_i.hh +++ b/src/VISU_I/VISU_ScalarMap_i.hh @@ -96,7 +96,7 @@ namespace VISU //! Redefines VISU_ColoredPrs3d_i::DoSetInput virtual void - DoSetInput(bool theIsInitilizePipe); + DoSetInput(bool theIsInitilizePipe, bool theReInit); //! Redefines VISU_ColoredPrs3d_i::CheckIsPossible virtual diff --git a/src/VISU_I/VISU_TimeAnimation.cxx b/src/VISU_I/VISU_TimeAnimation.cxx index 13705bc0..ee9b07ce 100644 --- a/src/VISU_I/VISU_TimeAnimation.cxx +++ b/src/VISU_I/VISU_TimeAnimation.cxx @@ -258,7 +258,7 @@ namespace CASCatch_TRY{ try{ #endif - if(aPresent->Apply()){ + if(aPresent->Apply(false)){ anIsCreated = true; theData.myPrs[aFrameId++] = aPresent; aMin = std::min(aPresent->GetMin(), aMin);