From 0983ef9e784945f5d1a369cffcae95ad1652769f Mon Sep 17 00:00:00 2001 From: epa Date: Fri, 20 Oct 2006 06:56:46 +0000 Subject: [PATCH] PAL13555: CutLines; Option to see the length as abscissa --- idl/VISU_Gen.idl | 19 +++++ resources/SalomeApp.xml | 5 ++ src/VISUGUI/VISU_msg_en.po | 8 +- src/VISUGUI/VisuGUI.cxx | 10 +++ src/VISUGUI/VisuGUI_CutLinesDlg.cxx | 109 +++++----------------------- src/VISUGUI/VisuGUI_CutLinesDlg.h | 1 + src/VISU_I/VISU_CutLines_i.cc | 44 +++++++++-- src/VISU_I/VISU_CutLines_i.hh | 5 ++ 8 files changed, 102 insertions(+), 99 deletions(-) diff --git a/idl/VISU_Gen.idl b/idl/VISU_Gen.idl index 2f1d27f9..6939b008 100644 --- a/idl/VISU_Gen.idl +++ b/idl/VISU_Gen.idl @@ -964,6 +964,25 @@ module VISU { * Gets the number of cut lines. */ long GetNbLines(); + + /*! Invert all curves of corresponding table + * \param theInvert - Invert all curves, if value is TRUE, else not. + */ + void SetAllCurvesInverted(in boolean theInvert); + + /*! Checks the orientation of all curves + * \retval TRUE - if all curves are inverted, else FALSE + */ + boolean IsAllCurvesInverted(); + + /*! Sets values which cutlines would be shown: aboslute or relative values + * \param theAbsLength - boolean value, TRUE or false. + */ + void SetUseAbsoluteLength(in boolean theAbsLength); + + /*! Checks values of cutlines: using aboslute or relative values + */ + boolean IsUseAbsoluteLength(); }; /*! \brief Interface of the stream lines representation diff --git a/resources/SalomeApp.xml b/resources/SalomeApp.xml index 5488527c..53be7b25 100644 --- a/resources/SalomeApp.xml +++ b/resources/SalomeApp.xml @@ -4,6 +4,11 @@ + + + + + diff --git a/src/VISUGUI/VISU_msg_en.po b/src/VISUGUI/VISU_msg_en.po index 2cc01cee..b51fcdea 100644 --- a/src/VISUGUI/VISU_msg_en.po +++ b/src/VISUGUI/VISU_msg_en.po @@ -174,6 +174,9 @@ msgstr "Number of cycles" msgid "VISU_NB_STEPS" msgstr "Number of steps" +msgid "VISU_CUTLINE_PREF" +msgstr "CutLine preferences" + msgid "VISU_PREF_MED_IMPORT" msgstr "MED files import" @@ -478,6 +481,9 @@ msgstr "minimal and maximal" msgid "VisuGUI_CutLinesDlg::LBL_INVERT_CURVES" msgstr "Invert all curves" +msgid "VisuGUI_CutLinesDlg::LBL_ABSOLUTE_LENGTH" +msgstr "Use absolute length" + msgid "VisuGUI_CutLinesDlg::LBL_GENERATE_CURVES" msgstr "Generate Curves" @@ -2117,4 +2123,4 @@ msgid "VISU_PLOT3D" msgstr "Plot3D" msgid "VISU_SCALAR_MAP_ON_DEFORMED_SHAPE" -msgstr "Scalar Map on Def. Shape" \ No newline at end of file +msgstr "Scalar Map on Def. Shape" diff --git a/src/VISUGUI/VisuGUI.cxx b/src/VISUGUI/VisuGUI.cxx index aadd869d..df34877d 100644 --- a/src/VISUGUI/VisuGUI.cxx +++ b/src/VISUGUI/VisuGUI.cxx @@ -3071,6 +3071,16 @@ void VisuGUI::createPreferences() setPreferenceProperty( nbcycles, "max", 100 ); setPreferenceProperty( nbsteps, "max", 200 ); + // group: "CutLines preferences" + int cutLineTab = addPreference( tr( "CutLines" ) ); + int cutLineGr = addPreference( tr( "VISU_CUTLINE_PREF" ), cutLineTab ); + setPreferenceProperty( cutLineGr, "columns", 1 ); + addPreference( tr( "Show preview" ), cutLineGr, LightApp_Preferences::Bool, "VISU", "show_preview" ); + addPreference( tr( "Invert all curves" ), cutLineGr, LightApp_Preferences::Bool, "VISU", "invert_all_curves" ); + addPreference( tr( "Use absolute length" ), cutLineGr, LightApp_Preferences::Bool, "VISU", "use_absolute_length" ); + addPreference( tr( "Generate data table" ), cutLineGr, LightApp_Preferences::Bool, "VISU", "generate_data_table" ); + addPreference( tr( "Generate curves" ), cutLineGr, LightApp_Preferences::Bool, "VISU", "generate_curves" ); + // group: "MED files import" int importGr = addPreference( tr( "MED files import" ), srangeTab ); setPreferenceProperty( importGr, "columns", 1 ); diff --git a/src/VISUGUI/VisuGUI_CutLinesDlg.cxx b/src/VISUGUI/VisuGUI_CutLinesDlg.cxx index d189683f..39a0c9fc 100644 --- a/src/VISUGUI/VisuGUI_CutLinesDlg.cxx +++ b/src/VISUGUI/VisuGUI_CutLinesDlg.cxx @@ -62,9 +62,6 @@ using namespace std; -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), @@ -135,8 +132,12 @@ VisuGUI_CutLinesDlg::VisuGUI_CutLinesDlg (SalomeApp_Module* theModule) myAllCurvesInvertedCheck->setChecked(false); aPlaneLayout->addWidget(myAllCurvesInvertedCheck); + myUseAbsoluteLengthCheck = new QCheckBox(tr("LBL_ABSOLUTE_LENGTH"), aPlanePane); + myUseAbsoluteLengthCheck->setChecked(false); + aPlaneLayout->addWidget(myUseAbsoluteLengthCheck); + myCreateTable = new QCheckBox (tr("LBL_GENERATE_TABLE"), aPlanePane); - myCreateTable->setChecked(MYGenerateTable); + myCreateTable->setChecked(true); aPlaneLayout->addWidget( myCreateTable ); QHBox* aCheckPane = new QHBox(aPlanePane); @@ -144,8 +145,8 @@ VisuGUI_CutLinesDlg::VisuGUI_CutLinesDlg (SalomeApp_Module* theModule) aCheckPane->setStretchFactor(aLbl, 0); myCurvesCheck = new QCheckBox(tr("LBL_GENERATE_CURVES"), aCheckPane); aCheckPane->setStretchFactor(aCheckPane, 0); - myCurvesCheck->setChecked(MYGenerateCurve); - myCurvesCheck->setEnabled(MYGenerateTable); + myCurvesCheck->setChecked(true); + myCurvesCheck->setEnabled(true); QLabel* aLbl2 = new QLabel(" ", aCheckPane); aCheckPane->setStretchFactor(aLbl2, 1); aPlaneLayout->addWidget( aCheckPane ); @@ -289,6 +290,12 @@ void VisuGUI_CutLinesDlg::initFromPrsObject (VISU::CutLines_i* thePrs) myPrs = thePrs; myScalarPane->initFromPrsObject(thePrs); + SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); + myPreviewCheck->setChecked( aResourceMgr->booleanValue("VISU", "show_preview", false) ); + myCreateTable->setChecked( aResourceMgr->booleanValue("VISU", "generate_data_table", true) ); + myCurvesCheck->setChecked( aResourceMgr->booleanValue("VISU", "generate_curves", true) ); + myCurvesCheck->setEnabled( aResourceMgr->booleanValue("VISU", "generate_curves", true) ); + myRotXSpn->setValue(thePrs->GetRotateX()*180./PI); myRotYSpn->setValue(thePrs->GetRotateY()*180./PI); myPosSpn->setValue(thePrs->GetDisplacement()); @@ -303,8 +310,8 @@ void VisuGUI_CutLinesDlg::initFromPrsObject (VISU::CutLines_i* thePrs) hasInit = true; myCutLines = new VISU::CutLines_i(thePrs->GetResult(),false); myCutLines->SameAs(thePrs); - myCutLines->CopyCurvesInverted(thePrs->GetCurvesInverted()); - if (myCutLines->IsAllCurvesInverted()) myAllCurvesInvertedCheck->setChecked(true); + myAllCurvesInvertedCheck->setChecked(myCutLines->IsAllCurvesInverted()); + myUseAbsoluteLengthCheck->setChecked(myCutLines->IsUseAbsoluteLength()); myBasePlanePos->setText( QString::number(myCutLines->GetBasePlanePosition()) ); myCBSetDef->setChecked(thePrs->IsDefault()); DrawTable(); @@ -342,6 +349,8 @@ int VisuGUI_CutLinesDlg::storeToPrsObject (VISU::CutLines_i* thePrs) } if (myAllCurvesInvertedCheck->isChecked()) thePrs->SetAllCurvesInverted(true); + + thePrs->SetUseAbsoluteLength(myUseAbsoluteLengthCheck->isChecked()); return 1; } @@ -751,93 +760,9 @@ void VisuGUI_CutLinesDlg::onValueChanged (int theRow, int theCol) void VisuGUI_CutLinesDlg::accept() { - //if ( !VisuGUI::CheckActiveStudyLock() ) { - // reject(); - // return; - //} - MYGenerateTable = myCreateTable->isChecked(); - MYGenerateCurve = myCurvesCheck->isChecked(); - // if (myScalarPane->check()) { - /*jfa tmp:((QWidget*)sender())->setDisabled(true); - storeToPrsObject(myPrs); - if (myIsCreation) { - if (isGenerateTable()) { - visuGUI->GetVisuGen()->CreateTable(myPrs->GetEntry()); - if (isGenerateCurves()) { - SALOMEDSClient_Study* aStudy = study()->studyDS(); - SALOMEDSClient_SObject* aSObject = aStudy->FindObjectID(myPrs->GetEntry()); - if( aSObject ) { - SALOMEDSClient_ChildIterator* aIter = aStudy->NewChildIterator( aSObject ); - SALOMEDSClient_StudyBuilder* aBuilder = aStudy->NewBuilder(); - for ( ;aIter->More(); aIter->Next()) { - SALOMEDSClient_SObject* aTblObj = aIter->Value(); - if ( aTblObj ) { - SALOMEDSClient_GenericAttribute* anAttr; - if (aTblObj->FindAttribute(anAttr, "AttributeName")) { - visuGUI->CreatePlot(aTblObj); - } - } - } - } - } - } - if (GET_VTK_VIEWWINDOW(myMgr)) { - try { - visuGUI->CreateActor(myPrs); - } catch (...) { - reject(); - return; - } - GET_VTK_VIEWWINDOW(myMgr)->onFitAll(); - } - } else { - visuGUI->RecreateActor(myPrs); - if (VTKViewer_ViewWindow* vf = GET_VTK_VIEWWINDOW(myMgr)) { - if (vf->getRenderer()->GetActors()->GetNumberOfItems() > 0) { - vf->getRenderer()->ResetCameraClippingRange(); - vf->Repaint(); - } - } - // Remove old Table - SALOMEDSClient_Study* aStudy = study()->studyDS(); - SALOMEDSClient_SObject* aSObject = aStudy->FindObjectID(myPrs->GetEntry()); - if( aSObject ) { - SALOMEDSClient_ChildIterator* aIter = aStudy->NewChildIterator( aSObject ); - SALOMEDSClient_StudyBuilder* aBuilder = aStudy->NewBuilder(); - for ( ;aIter->More(); aIter->Next()) { - SALOMEDSClient_SObject* aTblObj = aIter->Value(); - if ( aTblObj ) { - SALOMEDSClient_GenericAttribute* anAttr; - if (aTblObj->FindAttribute(anAttr, "AttributeName")) { - aBuilder->RemoveObjectWithChildren(aIter->Value()); // We should have only one child - break; - } - } - } - if (isGenerateTable()) { - visuGUI->GetVisuGen()->CreateTable(aSObject->GetID().c_str()); - if (isGenerateCurves()) { - SALOMEDSClient_Study* aStudy = study()->studyDS(); - SALOMEDSClient_ChildIterator* aIter = aStudy->NewChildIterator( aSObject ); - SALOMEDSClient_StudyBuilder* aBuilder = aStudy->NewBuilder(); - for ( ;aIter->More(); aIter->Next()) { - SALOMEDSClient_SObject* aTblObj = aIter->Value(); - if ( aTblObj ) { - SALOMEDSClient_GenericAttribute* anAttr; - if (aTblObj->FindAttribute(anAttr, "AttributeName")) { - visuGUI->CreatePlot(aTblObj); - } - } - } - } - } - } - } - VisuGUI::application()->objectBrowser()->updateTree();*/ myScalarPane->deletePreview(); deletePlanes(); QDialog::accept(); - // } } void VisuGUI_CutLinesDlg::reject() diff --git a/src/VISUGUI/VisuGUI_CutLinesDlg.h b/src/VISUGUI/VisuGUI_CutLinesDlg.h index 8b0e1da4..85139515 100644 --- a/src/VISUGUI/VisuGUI_CutLinesDlg.h +++ b/src/VISUGUI/VisuGUI_CutLinesDlg.h @@ -110,6 +110,7 @@ private: SALOME_Actor* myPreviewActorGlyphs; QCheckBox* myPreviewCheck; QCheckBox* myAllCurvesInvertedCheck; + QCheckBox* myUseAbsoluteLengthCheck; VISU::CutLines_i* myPrs; diff --git a/src/VISU_I/VISU_CutLines_i.cc b/src/VISU_I/VISU_CutLines_i.cc index a44b5216..e650bda0 100644 --- a/src/VISU_I/VISU_CutLines_i.cc +++ b/src/VISU_I/VISU_CutLines_i.cc @@ -67,7 +67,8 @@ CutLines_i(Result_i* theResult, Prs3d_i(theResult,theAddToStudy), ColoredPrs3d_i(theResult,theAddToStudy), ScalarMap_i(theResult,theAddToStudy), - myCutLinesPL(NULL) + myCutLinesPL(NULL), + myUseAbsLength(false) {} @@ -78,7 +79,8 @@ CutLines_i(Result_i* theResult, Prs3d_i(theResult,theSObject), ColoredPrs3d_i(theResult,theSObject), ScalarMap_i(theResult,theSObject), - myCutLinesPL(NULL) + myCutLinesPL(NULL), + myUseAbsLength(false) { } @@ -93,7 +95,12 @@ void VISU::CutLines_i::CopyCurvesInverted(const TCurvesInv& theCurves){ VISU::Storable* VISU::CutLines_i::Create(const char* theMeshName, VISU::Entity theEntity, const char* theFieldName, int theIteration) { - return ScalarMap_i::Create(theMeshName,theEntity,theFieldName,theIteration); + TSuperClass::Create(theMeshName,theEntity,theFieldName,theIteration); + SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr(); + SetAllCurvesInverted( aResourceMgr->booleanValue("VISU", "invert_all_curves", false) ); + SetUseAbsoluteLength( aResourceMgr->booleanValue("VISU", "use_absolute_length", false) ); + + return this; } @@ -110,6 +117,8 @@ VISU::Storable* VISU::CutLines_i::Restore(const Storable::TRestoringMap& theMap) SetOrientation2(CutPlanes::Orientation(VISU::Storable::FindValue(theMap,"myBasePlane[1]").toInt()), Storable::FindValue(theMap,"aRot[1][0]").toDouble(), Storable::FindValue(theMap,"aRot[1][1]").toDouble()); + SetUseAbsoluteLength(VISU::Storable::FindValue(theMap,"myUseAbsLength").toInt()); + if (VISU::Storable::FindValue(theMap,"myBasePlaneCondition").toInt()) SetDefault(); else @@ -161,8 +170,10 @@ void VISU::CutLines_i::ToStream(std::ostringstream& theStr){ aStrPos.append(QString::number(GetLinePosition(i)) + "|"); aStrCon.append(QString::number(IsDefaultPosition(i)) + "|"); } + Storable::DataToStream( theStr, "myLinePosition", aStrPos.latin1()); Storable::DataToStream( theStr, "myLineCondition", aStrCon.latin1()); + Storable::DataToStream( theStr,"myUseAbsLength", IsUseAbsoluteLength()); // Storing the map - \a myMapCurvesInverted QString aStrCurvesInverted; @@ -284,6 +295,13 @@ void VISU::CutLines_i::SetCurveInverted(CORBA::Long theCurveNumber,CORBA::Boolea myMapCurvesInverted[theCurveNumber] = theInvert; } +/*! It control the way the length of cutlines is shown: using aboslute or relative values +* \param theAbsLength - boolean value, TRUE or false. +*/ +void VISU::CutLines_i::SetUseAbsoluteLength(CORBA::Boolean theAbsLength){ + myUseAbsLength = theAbsLength; +} + /*! Checks orientation of curve. * \param theCurveNumber - integer value, number of cut line. * \retval TRUE - if line in the table is inverted, else FALSE. @@ -369,7 +387,11 @@ void VISU::CutLines_i::BuildTableOfReal(SALOMEDS::SObject_ptr theSObject){ if(MYDEBUG) MESSAGE("CutPlanes_i::BuildTableOfReal iLine = "<(theOrigin)){ + CutLines_i* anOrigin = const_cast(aPrs3d); + myUseAbsLength = anOrigin->IsUseAbsoluteLength(); + CopyCurvesInverted(anOrigin->GetCurvesInverted()); + } +} + diff --git a/src/VISU_I/VISU_CutLines_i.hh b/src/VISU_I/VISU_CutLines_i.hh index 6464d210..92b74b9b 100644 --- a/src/VISU_I/VISU_CutLines_i.hh +++ b/src/VISU_I/VISU_CutLines_i.hh @@ -89,6 +89,9 @@ namespace VISU{ virtual void SetCurveInverted(CORBA::Long theCurveNumber,CORBA::Boolean theInvert); virtual CORBA::Boolean IsCurveInverted(CORBA::Long theCurveNumber); + virtual void SetUseAbsoluteLength(CORBA::Boolean theAbsLength); + virtual CORBA::Boolean IsUseAbsoluteLength() {return myUseAbsLength;} + virtual void SetNbLines(CORBA::Long theNb); virtual CORBA::Long GetNbLines(); typedef VISU::CutLines TInterface; @@ -103,6 +106,7 @@ namespace VISU{ VISU_CutLinesPL *myCutLinesPL; TCurvesInv myMapCurvesInverted; + CORBA::Boolean myUseAbsLength; public: static int IsPossible(Result_i* theResult, const char* theMeshName, VISU::Entity theEntity, @@ -113,6 +117,7 @@ namespace VISU{ virtual void ToStream(std::ostringstream& theStr); virtual Storable* Restore(const Storable::TRestoringMap& theMap); + virtual void SameAs( const Prs3d_i* Origin ); virtual VISU_Actor* -- 2.39.2