-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2012 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
+// 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 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.
+// 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
+// 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
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
// GEOM GEOMGUI : GUI for Geometry component
// File : TransformationGUI_ScaleDlg.cxx
// Author : Lucien PIGNOLONI, Open CASCADE S.A.S.
CheckBoxCopy->hide();
// Activate Create a Copy mode
- CreateCopyModeChanged(true);
+ CreateCopyModeChanged();
// Allowed inheritance of children and visual properties by the scaling result
mainFrame()->GroupBoxPublish->show();
double aFactor = 2.0;
double SpecificStep = 0.5;
- initSpinBox(SpinBox_FX, COORD_MIN, COORD_MAX, SpecificStep, DBL_DIGITS_DISPLAY);
- initSpinBox(SpinBox_FY, COORD_MIN, COORD_MAX, SpecificStep, DBL_DIGITS_DISPLAY);
- initSpinBox(SpinBox_FZ, COORD_MIN, COORD_MAX, SpecificStep, DBL_DIGITS_DISPLAY);
+ initSpinBox(SpinBox_FX, COORD_MIN, COORD_MAX, SpecificStep, "parametric_precision" );
+ initSpinBox(SpinBox_FY, COORD_MIN, COORD_MAX, SpecificStep, "parametric_precision" );
+ initSpinBox(SpinBox_FZ, COORD_MIN, COORD_MAX, SpecificStep, "parametric_precision" );
SpinBox_FX->setValue(aFactor);
SpinBox_FY->setValue(aFactor);
SpinBox_FZ->setValue(aFactor);
LineEdit1->setText("");
LineEdit2->setText("");
- myPoint = GEOM::GEOM_Object::_nil();
+ myObjects.clear();
+ myPoint.nullify();
// Signals and slots connections
connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
connect(PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
connect(PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
- connect(LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
- connect(LineEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
-
connect(SpinBox_FX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect(SpinBox_FY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
connect(SpinBox_FZ, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
+
+ // san : Commented so as not to override specific step settings
+ //connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
- connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
-
- connect(CheckBoxCopy, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged(bool)));
+ connect(CheckBoxCopy, SIGNAL(toggled(bool)), this, SLOT(CreateCopyModeChanged()));
initName(tr("GEOM_SCALE"));
{
disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
+ myPoint.nullify();
+ LineEdit2->clear();
+
switch (constructorId) {
case 0: // translation an object by dx, dy, dz
TextLabel3->setText(tr("GEOM_SCALE_FACTOR"));
SelectionIntoArgument();
}
else {
- displayPreview();
+ processPreview();
}
}
//=================================================================================
void TransformationGUI_ScaleDlg::ClickOnOk()
{
+ setIsApplyAndClose( true );
if (ClickOnApply())
ClickOnCancel();
}
return false;
initName(tr("GEOM_SCALE"));
+
// activate selection and connect selection manager
ConstructorsClicked(getConstructorId());
+ SelectionIntoArgument();
+
return true;
}
void TransformationGUI_ScaleDlg::SelectionIntoArgument()
{
erasePreview();
- myEditCurrentArgument->setText("");
-
- if (myEditCurrentArgument == LineEdit1)
- myObjects.length(0);
- else if (myEditCurrentArgument == LineEdit2)
- myPoint = GEOM::GEOM_Object::_nil();
- LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
- SALOME_ListIO aSelList;
- aSelMgr->selectedObjects(aSelList);
-
- QString aName;
-
- if (myEditCurrentArgument == LineEdit1)
- {
- int aNbSel = GEOMBase::GetNameOfSelectedIObjects(aSelList, aName);
- if (aNbSel < 1)
- return;
-
- GEOMBase::ConvertListOfIOInListOfGO(aSelList, myObjects);
- if (!myObjects.length())
- return;
- else
- myEditCurrentArgument->setText(aName);
+ if ( myEditCurrentArgument == LineEdit1 ) {
+ myObjects = getSelected( TopAbs_SHAPE, -1 );
+ if ( !myObjects.isEmpty() ) {
+ QString aName = myObjects.count() > 1 ? QString( "%1_objects").arg( myObjects.count() ) : GEOMBase::GetName( myObjects[0].get() );
+ myEditCurrentArgument->setText( aName );
+ }
+ else {
+ myEditCurrentArgument->setText("");
+ }
}
- else if (myEditCurrentArgument == LineEdit2)
- {
- GEOM::GEOM_Object_var aSelectedObject = GEOM::GEOM_Object::_nil();
- if (aSelList.Extent() == 1)
- {
- Standard_Boolean testResult = Standard_False;
- aSelectedObject = GEOMBase::ConvertIOinGEOMObject(aSelList.First(), testResult);
- if (testResult)
- {
- aName = GEOMBase::GetName(aSelectedObject);
-
- TopoDS_Shape aShape;
- if (GEOMBase::GetShape(aSelectedObject, aShape, TopAbs_SHAPE) && !aShape.IsNull())
- {
- TColStd_IndexedMapOfInteger aMap;
- aSelMgr->GetIndexes(aSelList.First(), aMap);
- if (aMap.Extent() == 1)
- {
- int anIndex = aMap(1);
- aName += QString(":vertex_%1").arg(anIndex);
-
- //Find SubShape Object in Father
- GEOM::GEOM_Object_var aFindedObject = findObjectInFather(aSelectedObject, aName);
-
- if (aFindedObject == GEOM::GEOM_Object::_nil()) { // Object not found in study
- GEOM::GEOM_IShapesOperations_var aShapesOp =
- getGeomEngine()->GetIShapesOperations(getStudyId());
- aSelectedObject = aShapesOp->GetSubShape(aSelectedObject, anIndex);
- }
- else
- aSelectedObject = aFindedObject; // get Object from study
- }
- else // Global Selection
- {
- if (aShape.ShapeType() != TopAbs_VERTEX) {
- aSelectedObject = GEOM::GEOM_Object::_nil();
- aName = "";
- }
- }
- }
- }
+ else {
+ GEOM::GeomObjPtr aSelectedObject = getSelected( TopAbs_VERTEX );
+ TopoDS_Shape aShape;
+ if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
+ QString aName = GEOMBase::GetName( aSelectedObject.get() );
+ myEditCurrentArgument->setText( aName );
+ myPoint = aSelectedObject;
+ if ( myObjects.isEmpty() )
+ PushButton1->click();
+ }
+ else {
+ myPoint.nullify();
+ myEditCurrentArgument->setText("");
}
-
- myPoint = aSelectedObject;
- myEditCurrentArgument->setText(aName);
-
- if (!myPoint->_is_nil() && !myObjects.length())
- PushButton1->click();
}
- // clear selection
- /* disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
- myGeomGUI->getApp()->selectionMgr()->clearSelected();
- connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
- this, SLOT(SelectionIntoArgument()));*/
- // here commented, because multiple objects can be selected IPAL 21437
-
- displayPreview();
+ processPreview();
}
//=================================================================================
send->setDown(true);
// seems we need it only to avoid preview disappearing, caused by selection mode change
- displayPreview();
-}
-
-//=================================================================================
-// function : LineEditReturnPressed()
-// purpose :
-//=================================================================================
-void TransformationGUI_ScaleDlg::LineEditReturnPressed()
-{
- QLineEdit* send = (QLineEdit*)sender();
- if (send == LineEdit1 || send == LineEdit2)
- {
- myEditCurrentArgument = send;
- GEOMBase_Skeleton::LineEditReturnPressed();
- }
+ processPreview();
}
//=================================================================================
//=================================================================================
void TransformationGUI_ScaleDlg::ValueChangedInSpinBox()
{
- displayPreview();
+ processPreview();
}
//=================================================================================
//=================================================================================
bool TransformationGUI_ScaleDlg::isValid (QString& msg)
{
- // && !myPoint->_is_nil()
- if (getConstructorId() == 0) {
- bool ok = SpinBox_FX->isValid( msg, !IsPreview() );
- return myObjects.length() > 0 && fabs(SpinBox_FX->value()) > 0.00001 && ok;
+ bool ok = false;
+ if ( getConstructorId() == 0 ) {
+ ok = SpinBox_FX->isValid( msg, !IsPreview() ) &&
+ !myObjects.isEmpty() &&
+ qAbs( SpinBox_FX->value() ) > 0.00001;
}
-
- bool ok = true;
- ok = SpinBox_FX->isValid( msg, !IsPreview() ) && ok;
- ok = SpinBox_FY->isValid( msg, !IsPreview() ) && ok;
- ok = SpinBox_FZ->isValid( msg, !IsPreview() ) && ok;
- return myObjects.length() > 0 &&
- fabs(SpinBox_FX->value()) > 0.00001 &&
- fabs(SpinBox_FY->value()) > 0.00001 &&
- fabs(SpinBox_FZ->value()) > 0.00001 && ok;
+ else {
+ ok = SpinBox_FX->isValid( msg, !IsPreview() ) &&
+ SpinBox_FY->isValid( msg, !IsPreview() ) &&
+ SpinBox_FZ->isValid( msg, !IsPreview() ) &&
+ !myObjects.isEmpty() &&
+ qAbs( SpinBox_FX->value() ) > 0.00001 &&
+ qAbs( SpinBox_FY->value() ) > 0.00001 &&
+ qAbs( SpinBox_FZ->value() ) > 0.00001;
+ }
+ return ok;
}
//=================================================================================
{
if (toCreateCopy)
{
- for (int i = 0; i < myObjects.length(); i++)
+ for (int i = 0; i < myObjects.count(); i++)
{
- anObj = anOper->ScaleShapeCopy(myObjects[i], myPoint, SpinBox_FX->value());
+ anObj = anOper->ScaleShapeCopy(myObjects[i].get(), myPoint.get(), SpinBox_FX->value());
if (!anObj->_is_nil()) {
if(!IsPreview())
anObj->SetParameters(SpinBox_FX->text().toLatin1().constData());
}
else
{
- for (int i = 0; i < myObjects.length(); i++)
+ for (int i = 0; i < myObjects.count(); i++)
{
- anObj = anOper->ScaleShape(myObjects[i], myPoint, SpinBox_FX->value());
+ anObj = anOper->ScaleShape(myObjects[i].get(), myPoint.get(), SpinBox_FX->value());
if (!anObj->_is_nil())
objects.push_back(anObj._retn());
}
{
if (toCreateCopy)
{
- for (int i = 0; i < myObjects.length(); i++)
+ for (int i = 0; i < myObjects.count(); i++)
{
- anObj = anOper->ScaleShapeAlongAxesCopy(myObjects[i], myPoint, SpinBox_FX->value(),
+ anObj = anOper->ScaleShapeAlongAxesCopy(myObjects[i].get(), myPoint.get(), SpinBox_FX->value(),
SpinBox_FY->value(), SpinBox_FZ->value());
if (!anObj->_is_nil())
if(!IsPreview()) {
}
else
{
- for (int i = 0; i < myObjects.length(); i++)
+ for (int i = 0; i < myObjects.count(); i++)
{
- anObj = anOper->ScaleShapeAlongAxes(myObjects[i], myPoint, SpinBox_FX->value(),
+ anObj = anOper->ScaleShapeAlongAxes(myObjects[i].get(), myPoint.get(), SpinBox_FX->value(),
SpinBox_FY->value(), SpinBox_FZ->value());
if (!anObj->_is_nil())
objects.push_back(anObj._retn());
// empty list of arguments means that all arguments should be restored
getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(),
/*theFindMethod=*/GEOM::FSM_Transformed,
- /*theInheritFirstArg=*/true);
+ /*theInheritFirstArg=*/true,
+ mainFrame()->CheckBoxAddPrefix->isChecked());
}
}
// function : CreateCopyModeChanged()
// purpose :
//=================================================================================
-void TransformationGUI_ScaleDlg::CreateCopyModeChanged (bool isCreateCopy)
+void TransformationGUI_ScaleDlg::CreateCopyModeChanged()
{
- mainFrame()->GroupBoxName->setEnabled(isCreateCopy);
+ mainFrame()->GroupBoxName->setEnabled(CheckBoxCopy->isChecked());
}
//=================================================================================
bool toCreateCopy = IsPreview() || CheckBoxCopy->isChecked();
if (toCreateCopy)
{
- if (!myPoint->_is_nil())
- {
- QMap<QString, GEOM::GEOM_Object_var> objMap;
- objMap[LineEdit2->text()] = myPoint;
- addSubshapesToFather(objMap);
- }
+ GEOMBase::PublishSubObject( myPoint.get() );
}
}