X-Git-Url: http://git.salome-platform.org/gitweb/?p=modules%2Fsmesh.git;a=blobdiff_plain;f=src%2FSMESHGUI%2FSMESHGUI_ClippingDlg.cxx;h=6ec0c63bba281a0456635805bee1cc2394816e57;hp=f415162d5e45fed3f6856b009319b87f91bee996;hb=1335ea88437f94da949b901919146911db3aebcb;hpb=c38c10811a065cf5b13e8807ed71864d92ca7d80 diff --git a/src/SMESHGUI/SMESHGUI_ClippingDlg.cxx b/src/SMESHGUI/SMESHGUI_ClippingDlg.cxx index f415162d5..6ec0c63bb 100644 --- a/src/SMESHGUI/SMESHGUI_ClippingDlg.cxx +++ b/src/SMESHGUI/SMESHGUI_ClippingDlg.cxx @@ -17,7 +17,7 @@ // License along with this library; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -// See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // // // @@ -37,13 +37,14 @@ #include "SUIT_Session.h" #include "SUIT_OverrideCursor.h" +#include "SUIT_MessageBox.h" #include "SALOME_ListIO.hxx" #include "SALOME_InteractiveObject.hxx" #include "SALOME_ListIteratorOfListIO.hxx" -#include "SalomeApp_Application.h" -#include "SalomeApp_SelectionMgr.h" +#include "LightApp_Application.h" +#include "LightApp_SelectionMgr.h" #include "SVTK_Selector.h" #include "SVTK_ViewWindow.h" @@ -69,6 +70,7 @@ #include #include #include +#include // STL includes #include @@ -157,20 +159,16 @@ protected: myActor->SetInfinitive(true); myActor->SetMapper(myMapper); + vtkFloatingPointType anRGB[3]; vtkProperty* aProp = vtkProperty::New(); - float anRGB[3]; - anRGB[0] = SMESH::GetFloat("SMESH:SettingsFillColorRed", 0)/255.; - anRGB[1] = SMESH::GetFloat("SMESH:SettingsFillColorGreen", 170)/255.; - anRGB[2] = SMESH::GetFloat("SMESH:SettingsFillColorBlue", 255)/255.; + SMESH::GetColor( "SMESH", "fill_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 170, 255 ) ); aProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); aProp->SetOpacity(0.75); myActor->SetProperty(aProp); aProp->Delete(); vtkProperty* aBackProp = vtkProperty::New(); - anRGB[0] = SMESH::GetFloat("SMESH:SettingsBackFaceColorRed", 0)/255.; - anRGB[1] = SMESH::GetFloat("SMESH:SettingsBackFaceColorGreen", 0)/255.; - anRGB[2] = SMESH::GetFloat("SMESH:SettingsBackFaceColorBlue", 255)/255.; + SMESH::GetColor( "SMESH", "backface_color", anRGB[0], anRGB[1], anRGB[2], QColor( 0, 0, 255 ) ); aBackProp->SetColor(anRGB[0],anRGB[1],anRGB[2]); aBackProp->SetOpacity(0.75); myActor->SetBackfaceProperty(aBackProp); @@ -327,6 +325,10 @@ SMESHGUI_ClippingDlg::SMESHGUI_ClippingDlg (SMESHGUI* theModule, buttonOk->setAutoDefault(TRUE); buttonOk->setDefault(TRUE); GroupButtonsLayout->addWidget(buttonOk, 0, 0); + buttonHelp = new QPushButton(GroupButtons, "buttonHelp"); + buttonHelp->setText(tr("SMESH_BUT_HELP" )); + buttonHelp->setAutoDefault(TRUE); + GroupButtonsLayout->addWidget(buttonHelp, 0, 4); SMESHGUI_ClippingDlgLayout->addWidget(GroupPlanes, 0, 0); SMESHGUI_ClippingDlgLayout->addWidget(GroupParameters, 1, 0); @@ -347,6 +349,8 @@ SMESHGUI_ClippingDlg::SMESHGUI_ClippingDlg (SMESHGUI* theModule, myIsSelectPlane = false; onSelectionChanged(); + myHelpFileName = "clipping.htm"; + // signals and slots connections : connect(ComboBoxPlanes, SIGNAL(activated(int)), this, SLOT(onSelectPlane(int))); connect(buttonNew, SIGNAL(clicked()), this, SLOT(ClickOnNew())); @@ -360,15 +364,12 @@ SMESHGUI_ClippingDlg::SMESHGUI_ClippingDlg (SMESHGUI* theModule, connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonCancel, SIGNAL(clicked()), this, SLOT(ClickOnCancel())); connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); + connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp())); connect(mySMESHGUI, SIGNAL (SignalCloseAllDialogs()), this, SLOT(ClickOnOk())); connect(mySelectionMgr, SIGNAL(currentSelectionChanged()), this, SLOT(onSelectionChanged())); /* to close dialog if study frame change */ connect(mySMESHGUI, SIGNAL (SignalStudyFrameChanged()), this, SLOT(ClickOnCancel())); - /* Move widget on the botton right corner of main widget */ - int x, y; - mySMESHGUI->DefineDlgPosition(this, x, y); - this->move(x, y); this->show(); } @@ -394,6 +395,10 @@ void SMESHGUI_ClippingDlg::ClickOnApply() if (SVTK_ViewWindow* aViewWindow = SMESH::GetViewWindow(mySMESHGUI)) { SUIT_OverrideCursor wc; + + QWidget *aCurrWid = this->focusWidget(); + aCurrWid->clearFocus(); + aCurrWid->setFocus(); myActor->RemoveAllClippingPlanes(); @@ -428,6 +433,23 @@ void SMESHGUI_ClippingDlg::ClickOnCancel() close(); } +//================================================================================= +// function : ClickOnHelp() +// purpose : +//================================================================================= +void SMESHGUI_ClippingDlg::ClickOnHelp() +{ + LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication()); + if (app) + app->onHelpContextModule(mySMESHGUI ? app->moduleName(mySMESHGUI->moduleName()) : QString(""), myHelpFileName); + else { + SUIT_MessageBox::warn1(0, QObject::tr("WRN_WARNING"), + QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE"). + arg(app->resourceMgr()->stringValue("ExternalBrowser", "application")).arg(myHelpFileName), + QObject::tr("BUT_OK")); + } +} + //================================================================================= // function : onSelectionChanged() // purpose : Called when selection is changed @@ -634,18 +656,18 @@ void SMESHGUI_ClippingDlg::SetCurrentPlaneParam() OrientedPlane* aPlane = myPlanes[aCurPlaneIndex].GetPointer(); - float aNormal[3]; + vtkFloatingPointType aNormal[3]; SMESH::Orientation anOrientation; - float aDir[3][3] = {{0, 0, 0}, {0, 0, 0}}; + vtkFloatingPointType aDir[3][3] = {{0, 0, 0}, {0, 0, 0}}; { static double aCoeff = vtkMath::Pi()/180.0; - float aRot[2] = {getRotation1(), getRotation2()}; + vtkFloatingPointType aRot[2] = {getRotation1(), getRotation2()}; aPlane->myAngle[0] = aRot[0]; aPlane->myAngle[1] = aRot[1]; - float anU[2] = {cos(aCoeff*aRot[0]), cos(aCoeff*aRot[1])}; - float aV[2] = {sqrt(1.0-anU[0]*anU[0]), sqrt(1.0-anU[1]*anU[1])}; + vtkFloatingPointType anU[2] = {cos(aCoeff*aRot[0]), cos(aCoeff*aRot[1])}; + vtkFloatingPointType aV[2] = {sqrt(1.0-anU[0]*anU[0]), sqrt(1.0-anU[1]*anU[1])}; aV[0] = aRot[0] > 0? aV[0]: -aV[0]; aV[1] = aRot[1] > 0? aV[1]: -aV[1]; @@ -693,37 +715,37 @@ void SMESHGUI_ClippingDlg::SetCurrentPlaneParam() myActor->SetPlaneParam(aNormal, getDistance(), aPlane); vtkDataSet* aDataSet = myActor->GetInput(); - float *aPnt = aDataSet->GetCenter(); + vtkFloatingPointType *aPnt = aDataSet->GetCenter(); - float* anOrigin = aPlane->GetOrigin(); - float aDel = aDataSet->GetLength()/2.0; + vtkFloatingPointType* anOrigin = aPlane->GetOrigin(); + vtkFloatingPointType aDel = aDataSet->GetLength()/2.0; - float aDelta[2][3] = {{aDir[0][0]*aDel, aDir[0][1]*aDel, aDir[0][2]*aDel}, - {aDir[1][0]*aDel, aDir[1][1]*aDel, aDir[1][2]*aDel}}; - float aParam, aPnt0[3], aPnt1[3], aPnt2[3]; + vtkFloatingPointType aDelta[2][3] = {{aDir[0][0]*aDel, aDir[0][1]*aDel, aDir[0][2]*aDel}, + {aDir[1][0]*aDel, aDir[1][1]*aDel, aDir[1][2]*aDel}}; + vtkFloatingPointType aParam, aPnt0[3], aPnt1[3], aPnt2[3]; - float aPnt01[3] = {aPnt[0] - aDelta[0][0] - aDelta[1][0], - aPnt[1] - aDelta[0][1] - aDelta[1][1], - aPnt[2] - aDelta[0][2] - aDelta[1][2]}; - float aPnt02[3] = {aPnt01[0] + aNormal[0], - aPnt01[1] + aNormal[1], - aPnt01[2] + aNormal[2]}; + vtkFloatingPointType aPnt01[3] = {aPnt[0] - aDelta[0][0] - aDelta[1][0], + aPnt[1] - aDelta[0][1] - aDelta[1][1], + aPnt[2] - aDelta[0][2] - aDelta[1][2]}; + vtkFloatingPointType aPnt02[3] = {aPnt01[0] + aNormal[0], + aPnt01[1] + aNormal[1], + aPnt01[2] + aNormal[2]}; vtkPlane::IntersectWithLine(aPnt01,aPnt02,aNormal,anOrigin,aParam,aPnt0); - float aPnt11[3] = {aPnt[0] - aDelta[0][0] + aDelta[1][0], - aPnt[1] - aDelta[0][1] + aDelta[1][1], - aPnt[2] - aDelta[0][2] + aDelta[1][2]}; - float aPnt12[3] = {aPnt11[0] + aNormal[0], - aPnt11[1] + aNormal[1], - aPnt11[2] + aNormal[2]}; + vtkFloatingPointType aPnt11[3] = {aPnt[0] - aDelta[0][0] + aDelta[1][0], + aPnt[1] - aDelta[0][1] + aDelta[1][1], + aPnt[2] - aDelta[0][2] + aDelta[1][2]}; + vtkFloatingPointType aPnt12[3] = {aPnt11[0] + aNormal[0], + aPnt11[1] + aNormal[1], + aPnt11[2] + aNormal[2]}; vtkPlane::IntersectWithLine(aPnt11,aPnt12,aNormal,anOrigin,aParam,aPnt1); - float aPnt21[3] = {aPnt[0] + aDelta[0][0] - aDelta[1][0], - aPnt[1] + aDelta[0][1] - aDelta[1][1], - aPnt[2] + aDelta[0][2] - aDelta[1][2]}; - float aPnt22[3] = {aPnt21[0] + aNormal[0], - aPnt21[1] + aNormal[1], - aPnt21[2] + aNormal[2]}; + vtkFloatingPointType aPnt21[3] = {aPnt[0] + aDelta[0][0] - aDelta[1][0], + aPnt[1] + aDelta[0][1] - aDelta[1][1], + aPnt[2] + aDelta[0][2] - aDelta[1][2]}; + vtkFloatingPointType aPnt22[3] = {aPnt21[0] + aNormal[0], + aPnt21[1] + aNormal[1], + aPnt21[2] + aNormal[2]}; vtkPlane::IntersectWithLine(aPnt21,aPnt22,aNormal,anOrigin,aParam,aPnt2); vtkPlaneSource* aPlaneSource = aPlane->myPlaneSource; @@ -747,3 +769,20 @@ void SMESHGUI_ClippingDlg::OnPreviewToggle (bool theIsToggled) std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisiblity(theIsToggled)); SMESH::RenderViewWindow(SMESH::GetCurrentVtkView()); } + +//================================================================================= +// function : keyPressEvent() +// purpose : +//================================================================================= +void SMESHGUI_ClippingDlg::keyPressEvent( QKeyEvent* e ) +{ + QDialog::keyPressEvent( e ); + if ( e->isAccepted() ) + return; + + if ( e->key() == Key_F1 ) + { + e->accept(); + ClickOnHelp(); + } +}