// GEOM GEOMGUI : GUI for Geometry 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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org // // // // File : RepairGUI_SewingDlg.cxx // Author : Lucien PIGNOLONI // Module : GEOM // $Header$ using namespace std; #include "RepairGUI_SewingDlg.h" #include "QAD_Config.h" //================================================================================= // class : RepairGUI_SewingDlg() // purpose : Constructs a RepairGUI_SewingDlg 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. //================================================================================= RepairGUI_SewingDlg::RepairGUI_SewingDlg(QWidget* parent, const char* name, RepairGUI* theRepairGUI, SALOME_Selection* Sel, bool modal, WFlags fl) :GEOMBase_Skeleton(parent, name, Sel, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu) { QPixmap image0(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_DLG_SEWING"))); QPixmap image1(QAD_Desktop::getResourceManager()->loadPixmap("GEOM",tr("ICON_SELECT"))); setCaption(tr("GEOM_SEWING_TITLE")); /***************************************************************/ GroupConstructors->setTitle(tr("GEOM_SEWING")); RadioButton1->setPixmap(image0); RadioButton2->close(TRUE); RadioButton3->close(TRUE); GroupPoints = new DlgRef_1Sel1Spin(this, "GroupPoints"); GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS")); GroupPoints->TextLabel1->setText(tr("GEOM_OBJECTS")); GroupPoints->TextLabel2->setText(tr("GEOM_PRECISION")); GroupPoints->PushButton1->setPixmap(image1); Layout1->addWidget(GroupPoints, 1, 0); /***************************************************************/ /* Initialisations */ myRepairGUI = theRepairGUI; Init(); } //================================================================================= // function : ~RepairGUI_SewingDlg() // purpose : Destroys the object and frees any allocated resources //================================================================================= RepairGUI_SewingDlg::~RepairGUI_SewingDlg() { // no need to delete child widgets, Qt does it all for us } //================================================================================= // function : Init() // purpose : //================================================================================= void RepairGUI_SewingDlg::Init() { /* init variables */ myEditCurrentArgument = GroupPoints->LineEdit1; myOkListShapes = false; myPrecision = 0.00001; /* Get setting of step value from file configuration */ QString St = QAD_CONFIG->getSetting("Geometry:SettingsGeomStep"); step = St.toDouble(); /* min, max, step and decimals for spin boxes */ GroupPoints->SpinBox_DX->RangeStepAndValidator(0.00001, 999.99999, step, 5); GroupPoints->SpinBox_DX->SetValue(myPrecision); /* signals and slots connections */ connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply())); connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(GroupPoints->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox(double))); connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), GroupPoints->SpinBox_DX, SLOT(SetStep(double))); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); /* displays Dialog */ GroupPoints->show(); this->show(); return; } //================================================================================= // function : ClickOnOk() // purpose : //================================================================================= void RepairGUI_SewingDlg::ClickOnOk() { this->ClickOnApply(); ClickOnCancel(); return; } //================================================================================= // function : ClickOnApply() // purpose : //================================================================================= void RepairGUI_SewingDlg::ClickOnApply() { buttonApply->setFocus(); QAD_Application::getDesktop()->putInfo(tr("")); if(myOkListShapes) myRepairGUI->MakeSewingAndDisplay(myListShapes, myPrecision); return; } //================================================================================= // function : SelectionIntoArgument() // purpose : Called when selection as changed or other case //================================================================================= void RepairGUI_SewingDlg::SelectionIntoArgument() { myEditCurrentArgument->setText(""); QString aString = ""; /* name of selection */ myOkListShapes = false; int nbSel = myGeomBase->GetNameOfSelectedIObjects(mySelection, aString); if(nbSel < 2) return; myGeomBase->ConvertListOfIOInListOfIOR(mySelection->StoredIObjects(), myListShapes); myEditCurrentArgument->setText(aString); myOkListShapes = true; /* no simulation */ return; } //================================================================================= // function : SetEditCurrentArgument() // purpose : //================================================================================= void RepairGUI_SewingDlg::SetEditCurrentArgument() { QPushButton* send = (QPushButton*)sender(); if(send == GroupPoints->PushButton1) { GroupPoints->LineEdit1->setFocus(); myEditCurrentArgument = GroupPoints->LineEdit1; this->SelectionIntoArgument(); } return; } //================================================================================= // function : ActivateThisDialog() // purpose : //================================================================================= void RepairGUI_SewingDlg::ActivateThisDialog() { GEOMBase_Skeleton::ActivateThisDialog(); connect(mySelection, SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); return; } //================================================================================= // function : enterEvent() // purpose : //================================================================================= void RepairGUI_SewingDlg::enterEvent(QEvent* e) { if(GroupConstructors->isEnabled()) return; this->ActivateThisDialog(); return; } //================================================================================= // function : ValueChangedInSpinBox() // purpose : //================================================================================= void RepairGUI_SewingDlg::ValueChangedInSpinBox(double newValue) { myPrecision = newValue; return; }