From 207dcdd566eef37c71ea838b613eac2de139f129 Mon Sep 17 00:00:00 2001 From: jfa Date: Wed, 30 Dec 2009 09:28:34 +0000 Subject: [PATCH] Mantis issue 0020626: the discretisation of the circles in the OCC viewer is too rough. --- resources/SalomeApp.xml | 1 + src/GEOMGUI/GEOM_Displayer.cxx | 6 +- src/GEOMGUI/GEOM_msg_en.ts | 27 +++ src/GEOMGUI/GeometryGUI.cxx | 12 ++ src/GEOMToolsGUI/GEOMToolsGUI.cxx | 5 + src/GEOMToolsGUI/GEOMToolsGUI.h | 9 +- src/GEOMToolsGUI/GEOMToolsGUI_1.cxx | 169 +++++++++++++--- .../GEOMToolsGUI_DeflectionDlg.cxx | 184 ++++++++++++++++++ src/GEOMToolsGUI/GEOMToolsGUI_DeflectionDlg.h | 61 ++++++ src/GEOMToolsGUI/Makefile.am | 3 + 10 files changed, 444 insertions(+), 33 deletions(-) create mode 100644 src/GEOMToolsGUI/GEOMToolsGUI_DeflectionDlg.cxx create mode 100644 src/GEOMToolsGUI/GEOMToolsGUI_DeflectionDlg.h diff --git a/resources/SalomeApp.xml b/resources/SalomeApp.xml index d167c5be8..0eef8750a 100644 --- a/resources/SalomeApp.xml +++ b/resources/SalomeApp.xml @@ -42,6 +42,7 @@ + diff --git a/src/GEOMGUI/GEOM_Displayer.cxx b/src/GEOMGUI/GEOM_Displayer.cxx index 83a3c083b..6e3be0c5a 100644 --- a/src/GEOMGUI/GEOM_Displayer.cxx +++ b/src/GEOMGUI/GEOM_Displayer.cxx @@ -632,7 +632,11 @@ void GEOM_Displayer::Update( SALOME_OCCPrs* prs ) // bug [SALOME platform 0019868] // Set deviation angle. Default one is 12 degrees (Prs3d_Drawer.cxx:18) - AISShape->SetOwnDeviationAngle( 10*PI/180 ); + //AISShape->SetOwnDeviationAngle( 10*PI/180 ); + + // IMP 0020626 + double aDC = aResMgr->doubleValue("Geometry", "deflection_coeff", 0.001); + AISShape->SetOwnDeviationCoefficient(aDC); } } diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index a9ad0108a..91ead8895 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -2379,6 +2379,10 @@ Please, select face, shell or solid and try again MEN_POP_ISOS Isos + + MEN_POP_DEFLECTION + Deflection Coefficient + MEN_POP_RENAME Rename @@ -2575,6 +2579,10 @@ Please, select face, shell or solid and try again NON_GEOM_OBJECTS_SELECTED There are objects selected which do not belong to %1 component. + + PREF_DEFLECTION + Deflection coefficient + PREF_DISPLAY_MODE Default display mode @@ -2931,6 +2939,10 @@ Please, select face, shell or solid and try again STB_POP_ISOS Isolines + + STB_POP_DEFLECTION + Deflection Coefficient + STB_POP_RENAME Rename @@ -3415,6 +3427,10 @@ Please, select face, shell or solid and try again TOP_POP_ISOS Isolines + + TOP_POP_DEFLECTION + Deflection Coefficient + TOP_POP_RENAME Rename @@ -4293,6 +4309,17 @@ Would you like to continue? Delete objects + + GEOMToolsGUI_DeflectionDlg + + GEOM_DEFLECTION_TLT + Select Deflection of Shape + + + GEOM_DEFLECTION + Deflection : + + GEOMToolsGUI_MarkerDlg diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index 003480e83..5dd76283c 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -375,6 +375,7 @@ void GeometryGUI::OnGUIEvent( int id ) id == 411 || // MENU SETTINGS - ADD IN STUDY id == 412 || // MENU SETTINGS - SHADING COLOR id == 5103 || // MENU TOOLS - CHECK GEOMETRY + id == 8031 || // POPUP VIEWER - DEFLECTION COEFFICIENT id == 8032 || // POPUP VIEWER - COLOR id == 8033 || // POPUP VIEWER - TRANSPARENCY id == 8034 || // POPUP VIEWER - ISOS @@ -897,6 +898,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createGeomAction( 80311, "POP_WIREFRAME", "", 0, true ); createGeomAction( 80312, "POP_SHADING", "", 0, true ); createGeomAction( 80313, "POP_VECTORS", "", 0, true ); + createGeomAction( 8031, "POP_DEFLECTION" ); createGeomAction( 8032, "POP_COLOR" ); createGeomAction( 8033, "POP_TRANSPARENCY" ); createGeomAction( 8034, "POP_ISOS" ); @@ -1173,6 +1175,8 @@ void GeometryGUI::initialize( CAM_Application* app ) mgr->setRule( action( 8033 ), clientOCCorVTK_AndSomeVisible, QtxPopupMgr::VisibleRule ); mgr->insert( action( 8034 ), -1, -1 ); // isos mgr->setRule( action( 8034 ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible", QtxPopupMgr::VisibleRule ); + mgr->insert( action( 8031 ), -1, -1 ); // deflection + mgr->setRule( action( 8031 ), clientOCCorVTK_AndSomeVisible + " and selcount>0 and isVisible", QtxPopupMgr::VisibleRule ); mgr->insert( action( 8039 ), -1, -1 ); // point marker mgr->setRule( action( 8039 ), QString( "selcount>0 and $typeid in {%1}" ).arg( GEOM_POINT ), QtxPopupMgr::VisibleRule ); mgr->insert( separator(), -1, -1 ); // ----------- @@ -1566,6 +1570,9 @@ void GeometryGUI::createPreferences() int step = addPreference( tr( "PREF_STEP_VALUE" ), genGroup, LightApp_Preferences::IntSpin, "Geometry", "SettingsGeomStep" ); + int defl = addPreference( tr( "PREF_DEFLECTION" ), genGroup, + LightApp_Preferences::DblSpin, "Geometry", "deflection_coeff" ); + int VertexGroup = addPreference( tr( "PREF_GROUP_VERTEX" ), tabId ); setPreferenceProperty( VertexGroup, "columns", 2 ); @@ -1592,6 +1599,11 @@ void GeometryGUI::createPreferences() setPreferenceProperty( step, "max", 10000 ); setPreferenceProperty( step, "precision", 3 ); + // Set property for deflection value for spinboxes + setPreferenceProperty( defl, "min", 1.0e-07 ); + setPreferenceProperty( defl, "max", 10000.0 ); + setPreferenceProperty( defl, "step", 0.0001 ); + // Set property vertex marker type QList aMarkerTypeIndicesList; QList aMarkerTypeIconsList; diff --git a/src/GEOMToolsGUI/GEOMToolsGUI.cxx b/src/GEOMToolsGUI/GEOMToolsGUI.cxx index 3cc39b2f3..cb93e55af 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI.cxx @@ -376,6 +376,11 @@ bool GEOMToolsGUI::OnGUIEvent(int theCommandID, SUIT_Desktop* parent) OnCheckGeometry(); break; } + case 8031: // DEFLECTION ANGLE - POPUP VIEWER + { + OnDeflection(); + break; + } case 8032: // COLOR - POPUP VIEWER { OnColor(); diff --git a/src/GEOMToolsGUI/GEOMToolsGUI.h b/src/GEOMToolsGUI/GEOMToolsGUI.h index 8b0f1a4e9..d60f23484 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI.h +++ b/src/GEOMToolsGUI/GEOMToolsGUI.h @@ -19,10 +19,10 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// GEOM GEOMGUI : GUI for Geometry component -// File : GEOMToolsGUI.h -// Author : Damien COQUERET, Open CASCADE S.A.S. -// +// GEOM GEOMGUI : GUI for Geometry component +// File : GEOMToolsGUI.h +// Author : Damien COQUERET, Open CASCADE S.A.S. + #ifndef GEOMTOOLSGUI_H #define GEOMTOOLSGUI_H @@ -69,6 +69,7 @@ private: void OnColor(); void OnTransparency(); void OnNbIsos(); + void OnDeflection(); void OnOpen(); void OnSelectOnly(int mode); void OnShowHideChildren( bool ); diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx index 11e51738f..4e4ce7c9e 100644 --- a/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx +++ b/src/GEOMToolsGUI/GEOMToolsGUI_1.cxx @@ -19,15 +19,16 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // -// GEOM GEOMGUI : GUI for Geometry component -// File : GEOMToolsGUI_1.cxx -// Author : Sergey ANIKIN, Open CASCADE S.A.S. (sergey.anikin@opencascade.com) -// +// GEOM GEOMGUI : GUI for Geometry component +// File : GEOMToolsGUI_1.cxx +// Author : Sergey ANIKIN, Open CASCADE S.A.S. (sergey.anikin@opencascade.com) + #include #include "GEOMToolsGUI.h" #include "GEOMToolsGUI_TransparencyDlg.h" #include "GEOMToolsGUI_NbIsosDlg.h" +#include "GEOMToolsGUI_DeflectionDlg.h" #include "GEOMToolsGUI_MarkerDlg.h" #include @@ -54,6 +55,7 @@ #include #include #include +#include #include #include @@ -75,8 +77,15 @@ // QT Includes #include +#include #include +#include +#include +#include +#include +#include + // VTK includes #include @@ -155,7 +164,7 @@ void GEOMToolsGUI::OnRename() } } } - + app->updateActions(); //SRN: To update a Save button in the toolbar } @@ -341,7 +350,9 @@ void GEOMToolsGUI::OnColor() if ( !io.IsNull() ) { Quantity_Color aColor; io->Color( aColor ); - QColor initcolor( (int)( aColor.Red() * 255.0 ), (int)( aColor.Green() * 255.0 ), (int)( aColor.Blue() * 255.0 ) ); + QColor initcolor ((int)( aColor.Red() * 255.0 ), + (int)( aColor.Green() * 255.0 ), + (int)( aColor.Blue() * 255.0 )); QColor c = QColorDialog::getColor( initcolor, app->desktop() ); if ( c.isValid() ) { SUIT_OverrideCursor(); @@ -350,7 +361,8 @@ void GEOMToolsGUI::OnColor() io = GEOMBase::GetAIS( It.Value(), true ); if ( !io.IsNull() ) { // Set color for a point - OCCViewer_Viewer* vm = dynamic_cast( window->getViewManager()->getViewModel() ); + OCCViewer_Viewer* vm = dynamic_cast + ( window->getViewManager()->getViewModel() ); Handle (AIS_InteractiveContext) ic = vm->getAISContext(); Handle(AIS_Drawer) aCurDrawer = io->Attributes(); Handle(Prs3d_PointAspect) aCurPointAspect = aCurDrawer->PointAspect(); @@ -359,16 +371,16 @@ void GEOMToolsGUI::OnColor() Aspect_TypeOfMarker aCurTypeOfMarker; aCurPointAspect->Aspect()->Values( aCurColor, aCurTypeOfMarker, aCurScale ); if ( aCurTypeOfMarker != Aspect_TOM_USERDEFINED ) { - aCurDrawer->SetPointAspect( new Prs3d_PointAspect( aCurTypeOfMarker, aColor, aCurScale) ); + aCurDrawer->SetPointAspect(new Prs3d_PointAspect(aCurTypeOfMarker, aColor, aCurScale)); } else { Standard_Integer aWidth, aHeight; aCurPointAspect->GetTextureSize( aWidth, aHeight ); Handle(Graphic3d_HArray1OfBytes) aTexture = aCurPointAspect->GetTexture(); - aCurDrawer->SetPointAspect( new Prs3d_PointAspect( aColor, 1, aWidth, aHeight, aTexture ) ); + aCurDrawer->SetPointAspect(new Prs3d_PointAspect(aColor, 1, aWidth, aHeight, aTexture)); } ic->SetLocalAttributes(io, aCurDrawer); - + io->SetColor( aColor ); if ( io->IsKind( STANDARD_TYPE(GEOM_AISShape) ) ) Handle(GEOM_AISShape)::DownCast( io )->SetShadingColor( aColor ); @@ -395,7 +407,7 @@ void GEOMToolsGUI::OnColor() } // if ( selection not empty ) } } - + app->updateActions(); //SRN: To update a Save button in the toolbar } @@ -408,7 +420,7 @@ void GEOMToolsGUI::OnTransparency() void GEOMToolsGUI::OnNbIsos() { SUIT_ViewWindow* window = SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); - + bool isOCC = ( window && window->getViewManager()->getType() == OCCViewer_Viewer::Type() ); bool isVTK = ( window && window->getViewManager()->getType() == SVTK_Viewer::Type() ); @@ -421,28 +433,28 @@ void GEOMToolsGUI::OnNbIsos() if ( ic->MoreCurrent() ) { Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current()); Handle(AIS_Drawer) CurDrawer = CurObject->Attributes(); - + int UIso = CurDrawer->UIsoAspect()->Number(); int VIso = CurDrawer->VIsoAspect()->Number(); - + GEOMToolsGUI_NbIsosDlg * NbIsosDlg = new GEOMToolsGUI_NbIsosDlg( SUIT_Session::session()->activeApplication()->desktop() ); - + NbIsosDlg->setU( UIso ); NbIsosDlg->setV( VIso ); - + if ( NbIsosDlg->exec() ) { SUIT_OverrideCursor(); for(; ic->MoreCurrent(); ic->NextCurrent()) { CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current()); Handle(AIS_Drawer) CurDrawer = CurObject->Attributes(); - + int nbUIso = NbIsosDlg->getU(); int nbVIso = NbIsosDlg->getV(); - + CurDrawer->SetUIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5 , nbUIso) ); CurDrawer->SetVIsoAspect( new Prs3d_IsoAspect(Quantity_NOC_GRAY75, Aspect_TOL_SOLID, 0.5 , nbVIso) ); - + ic->SetLocalAttributes(CurObject, CurDrawer); ic->Redisplay(CurObject); } @@ -453,7 +465,8 @@ void GEOMToolsGUI::OnNbIsos() // // Warning. It's works incorrect. must be recheked. // - SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() ); + SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* > + ( SUIT_Session::session()->activeApplication() ); if ( !app ) return; LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); @@ -463,7 +476,7 @@ void GEOMToolsGUI::OnNbIsos() aSelMgr->selectedObjects( selected ); if ( selected.IsEmpty() ) return; - + SVTK_ViewWindow* vtkVW = dynamic_cast( window ); if ( !vtkVW ) return; @@ -471,10 +484,10 @@ void GEOMToolsGUI::OnNbIsos() SALOME_View* view = GEOM_Displayer::GetActiveView(); vtkActorCollection* aCollection = vtkActorCollection::New(); - + for ( SALOME_ListIteratorOfListIO It( selected ); It.More(); It.Next() ) { Handle(SALOME_InteractiveObject) anIObject = It.Value(); - SALOME_Prs* aPrs = view->CreatePrs( anIObject->getEntry() ); + SALOME_Prs* aPrs = view->CreatePrs( anIObject->getEntry() ); SVTK_Prs* vtkPrs = dynamic_cast( aPrs ); if ( vtkPrs ) { vtkActorCollection* anActors = vtkPrs->GetObjects(); @@ -483,21 +496,21 @@ void GEOMToolsGUI::OnNbIsos() aCollection->AddItem(anAct); } } - + if(aCollection) aCollection->InitTraversal(); else return; - + int UIso = 0; int VIso = 0; - + vtkActor* anAct = aCollection->GetNextActor(); if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)) anActor->GetNbIsos(UIso,VIso); else return; - + GEOMToolsGUI_NbIsosDlg* NbIsosDlg = new GEOMToolsGUI_NbIsosDlg( SUIT_Session::session()->activeApplication()->desktop() ); @@ -506,7 +519,7 @@ void GEOMToolsGUI::OnNbIsos() if ( NbIsosDlg->exec() ) { SUIT_OverrideCursor(); - + while( anAct!=NULL ) { if(GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)){ // There are no casting to needed actor. @@ -521,6 +534,106 @@ void GEOMToolsGUI::OnNbIsos() } // end vtkviewer } +void GEOMToolsGUI::OnDeflection() +{ + SUIT_ViewWindow* window = SUIT_Session::session()->activeApplication()->desktop()->activeWindow(); + + bool isOCC = (window && window->getViewManager()->getType() == OCCViewer_Viewer::Type()); + bool isVTK = (window && window->getViewManager()->getType() == SVTK_Viewer::Type()); + + if (isOCC) { // if is OCCViewer + OCCViewer_Viewer* vm = dynamic_cast(window->getViewManager()->getViewModel()); + Handle (AIS_InteractiveContext) ic = vm->getAISContext(); + + ic->InitCurrent(); + if (ic->MoreCurrent()) { + Handle(GEOM_AISShape) CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current()); + + Standard_Real aDC, aPrevDC; + Standard_Boolean isOwnDC = CurObject->OwnDeviationCoefficient(aDC, aPrevDC); + if (!isOwnDC) + aDC = ic->DeviationCoefficient(); + + GEOMToolsGUI_DeflectionDlg * DeflectionDlg = new GEOMToolsGUI_DeflectionDlg + (SUIT_Session::session()->activeApplication()->desktop()); + DeflectionDlg->setDC(aDC); + if (DeflectionDlg->exec()) { + SUIT_OverrideCursor(); + double aNewDC = DeflectionDlg->getDC(); + for (; ic->MoreCurrent(); ic->NextCurrent()) { + CurObject = Handle(GEOM_AISShape)::DownCast(ic->Current()); + ic->SetDeviationCoefficient(CurObject, aNewDC, Standard_True); + ic->Redisplay(CurObject); + } + } + } + } + else if (isVTK) { // if is VTKViewer + SalomeApp_Application* app = dynamic_cast + (SUIT_Session::session()->activeApplication()); + if (!app) + return; + + LightApp_SelectionMgr* aSelMgr = app->selectionMgr(); + if (!aSelMgr) + return; + + SALOME_ListIO selected; + aSelMgr->selectedObjects(selected); + if (selected.IsEmpty()) + return; + + SVTK_ViewWindow* vtkVW = dynamic_cast(window); + if (!vtkVW) + return; + + SALOME_View* view = GEOM_Displayer::GetActiveView(); + + vtkActorCollection* aCollection = vtkActorCollection::New(); + + for (SALOME_ListIteratorOfListIO It (selected); It.More(); It.Next()) { + Handle(SALOME_InteractiveObject) anIObject = It.Value(); + SALOME_Prs* aPrs = view->CreatePrs(anIObject->getEntry()); + SVTK_Prs* vtkPrs = dynamic_cast(aPrs); + if (vtkPrs) { + vtkActorCollection* anActors = vtkPrs->GetObjects(); + anActors->InitTraversal(); + vtkActor* anAct = anActors->GetNextActor(); + aCollection->AddItem(anAct); + } + } + + if (aCollection) + aCollection->InitTraversal(); + else + return; + + double aDC = 0.; + + vtkActor* anAct = aCollection->GetNextActor(); + if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)) + aDC = anActor->GetDeflection(); + else + return; + + GEOMToolsGUI_DeflectionDlg* DeflectionDlg = new GEOMToolsGUI_DeflectionDlg + (SUIT_Session::session()->activeApplication()->desktop()); + DeflectionDlg->setDC(aDC); + if (DeflectionDlg->exec()) { + SUIT_OverrideCursor(); + aDC = DeflectionDlg->getDC(); + while (anAct != NULL) { + if (GEOM_Actor* anActor = GEOM_Actor::SafeDownCast(anAct)) { + // There are no casting to needed actor. + bool isRel = anActor->GetIsRelative(); + anActor->SetDeflection(aDC, isRel); + } + anAct = aCollection->GetNextActor(); + } + } + } // end vtkviewer +} + void GEOMToolsGUI::OnOpen() { /* diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_DeflectionDlg.cxx b/src/GEOMToolsGUI/GEOMToolsGUI_DeflectionDlg.cxx new file mode 100644 index 000000000..8f4137a4d --- /dev/null +++ b/src/GEOMToolsGUI/GEOMToolsGUI_DeflectionDlg.cxx @@ -0,0 +1,184 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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 +// +// GEOM GEOMGUI : GUI for Geometry component +// File : GEOMToolsGUI_DeflectionDlg.cxx +// Author : OCC Team + +#include "GEOMToolsGUI_DeflectionDlg.h" +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +//================================================================================= +// class : GEOMToolsGUI_DeflectionDlg() +// purpose : Constructs a GEOMToolsGUI_DeflectionDlg which is a child of 'parent', with the +// name 'name' and widget flags set to 'f'. +// The dialog will by default be modeless, unless you set 'modal' to +// TRUE to construct a modal dialog. +//================================================================================= +GEOMToolsGUI_DeflectionDlg::GEOMToolsGUI_DeflectionDlg (QWidget* parent) + : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint) +{ + setObjectName("GEOMToolsGUI_DeflectionDlg"); + setModal(true); + + setWindowTitle(tr("GEOM_DEFLECTION_TLT")); + setSizeGripEnabled(TRUE); + QGridLayout* MyDialogLayout = new QGridLayout(this); + MyDialogLayout->setSpacing(6); + MyDialogLayout->setMargin(11); + + /***************************************************************/ + QGroupBox* GroupC1 = new QGroupBox (this); + GroupC1->setObjectName("GroupC1"); + QGridLayout* GroupC1Layout = new QGridLayout (GroupC1); + GroupC1Layout->setAlignment(Qt::AlignTop); + GroupC1Layout->setSpacing(6); + GroupC1Layout->setMargin(11); + + QLabel* TextLabel1 = new QLabel (GroupC1); + TextLabel1->setObjectName("TextLabel1"); + TextLabel1->setText(tr("GEOM_DEFLECTION")); + GroupC1Layout->addWidget(TextLabel1, 0, 0); + + SpinBox = new SalomeApp_DoubleSpinBox (GroupC1); + SpinBox->setObjectName("SpinBoxU"); + SpinBox->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed)); + SpinBox->setMinimum(0); + SpinBox->setValue(1); + GroupC1Layout->addWidget(SpinBox, 0, 1); + + /***************************************************************/ + QGroupBox* GroupButtons = new QGroupBox (this); + GroupButtons->setObjectName("GroupButtons"); + QGridLayout* GroupButtonsLayout = new QGridLayout (GroupButtons); + GroupButtonsLayout->setAlignment(Qt::AlignTop); + GroupButtonsLayout->setSpacing(6); + GroupButtonsLayout->setMargin(11); + + QPushButton* buttonOk = new QPushButton (GroupButtons); + buttonOk->setObjectName("buttonOk"); + buttonOk->setText(tr("GEOM_BUT_OK")); + buttonOk->setAutoDefault(TRUE); + buttonOk->setDefault(TRUE); + GroupButtonsLayout->addWidget(buttonOk, 0, 0); + + GroupButtonsLayout->addItem(new QSpacerItem (20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 1); + + QPushButton* buttonCancel = new QPushButton (GroupButtons); + buttonCancel->setObjectName("buttonCancel"); + buttonCancel->setText(tr("GEOM_BUT_CANCEL")); + buttonCancel->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonCancel, 0, 1); + + QPushButton* buttonHelp = new QPushButton (GroupButtons); + buttonHelp->setObjectName("buttonHelp"); + buttonHelp->setText(tr("GEOM_BUT_HELP")); + buttonHelp->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonHelp, 0, 2); + /***************************************************************/ + + MyDialogLayout->addWidget(GroupC1, 0, 0); + MyDialogLayout->addWidget(GroupButtons, 1, 0); + + myHelpFileName = "deflection_page.html"; + + // signals and slots connections + connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept())); + connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject())); + connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp())); + + // Move widget on the botton right corner of main widget + SUIT_Tools::centerWidget(this, parent); +} + +//================================================================================= +// function : ~GEOMToolsGUI_DeflectionDlg() +// purpose : Destroys the object and frees any allocated resources +//================================================================================= +GEOMToolsGUI_DeflectionDlg::~GEOMToolsGUI_DeflectionDlg() +{ + // no need to delete child widgets, Qt does it all for us +} + +double GEOMToolsGUI_DeflectionDlg::getDC() const +{ + return SpinBox->text().toDouble(); +} + +void GEOMToolsGUI_DeflectionDlg::setDC (const double v) +{ + SpinBox->setValue(v); +} + +//================================================================================= +// function : ClickOnHelp() +// purpose : +//================================================================================= +void GEOMToolsGUI_DeflectionDlg::ClickOnHelp() +{ + LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication()); + if (app) { + GeometryGUI* aGeomGUI = dynamic_cast(app->module("Geometry")); + app->onHelpContextModule(aGeomGUI ? app->moduleName(aGeomGUI->moduleName()) : QString(""), myHelpFileName); + } + else { + QString platform; +#ifdef WIN32 + platform = "winapplication"; +#else + platform = "application"; +#endif + SUIT_MessageBox::warning + (0, QObject::tr("WRN_WARNING"), + QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). + arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName), + QObject::tr("BUT_OK")); + } +} + +//================================================================================= +// function : keyPressEvent() +// purpose : +//================================================================================= +void GEOMToolsGUI_DeflectionDlg::keyPressEvent (QKeyEvent* e) +{ + QDialog::keyPressEvent(e); + if (e->isAccepted()) + return; + + if (e->key() == Qt::Key_F1) { + e->accept(); + ClickOnHelp(); + } +} diff --git a/src/GEOMToolsGUI/GEOMToolsGUI_DeflectionDlg.h b/src/GEOMToolsGUI/GEOMToolsGUI_DeflectionDlg.h new file mode 100644 index 000000000..30c2821cb --- /dev/null +++ b/src/GEOMToolsGUI/GEOMToolsGUI_DeflectionDlg.h @@ -0,0 +1,61 @@ +// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 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 +// +// GEOM GEOMGUI : GUI for Geometry component +// File : GEOMToolsGUI_DeflectionDlg.h +// Author : OCC Team + +#ifndef GEOMTOOLSGUI_DEFLECTIONDLG_H +#define GEOMTOOLSGUI_DEFLECTIONDLG_H + +#include "GEOM_ToolsGUI.hxx" + +#include + +class SalomeApp_DoubleSpinBox; + +//================================================================================= +// class : GEOMToolsGUI_DeflectionDlg +// purpose : +//================================================================================= +class GEOMTOOLSGUI_EXPORT GEOMToolsGUI_DeflectionDlg : public QDialog +{ + Q_OBJECT + +public: + GEOMToolsGUI_DeflectionDlg( QWidget* ); + ~GEOMToolsGUI_DeflectionDlg(); + + double getDC() const; + void setDC( const double ); + +private slots: + void ClickOnHelp(); + +private: + void keyPressEvent( QKeyEvent* ); + +private: + SalomeApp_DoubleSpinBox* SpinBox; + QString myHelpFileName; +}; + +#endif // GEOMTOOLSGUI_DEFLECTIONDLG_H diff --git a/src/GEOMToolsGUI/Makefile.am b/src/GEOMToolsGUI/Makefile.am index 1a0a919b5..34a922111 100644 --- a/src/GEOMToolsGUI/Makefile.am +++ b/src/GEOMToolsGUI/Makefile.am @@ -33,6 +33,7 @@ salomeinclude_HEADERS = \ GEOMToolsGUI.h \ GEOM_ToolsGUI.hxx \ GEOMToolsGUI_NbIsosDlg.h \ + GEOMToolsGUI_DeflectionDlg.h \ GEOMToolsGUI_TransparencyDlg.h \ GEOMToolsGUI_DeleteDlg.h \ GEOMToolsGUI_MarkerDlg.h @@ -42,12 +43,14 @@ dist_libGEOMToolsGUI_la_SOURCES = \ GEOMToolsGUI_1.cxx \ GEOMToolsGUI_TransparencyDlg.cxx \ GEOMToolsGUI_NbIsosDlg.cxx \ + GEOMToolsGUI_DeflectionDlg.cxx \ GEOMToolsGUI_DeleteDlg.cxx \ GEOMToolsGUI_MarkerDlg.cxx MOC_FILES = \ GEOMToolsGUI_TransparencyDlg_moc.cxx \ GEOMToolsGUI_NbIsosDlg_moc.cxx \ + GEOMToolsGUI_DeflectionDlg_moc.cxx \ GEOMToolsGUI_DeleteDlg_moc.cxx \ GEOMToolsGUI_MarkerDlg_moc.cxx -- 2.39.2