-// Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2007-2023 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
double SpecificStep = 5;
initSpinBox(GroupPoints->SpinBox_DX, 0.00001, COORD_MAX, step, "length_precision" );
initSpinBox(GroupPoints->SpinBox_DY, 0.00001, COORD_MAX, step, "length_precision" );
- initSpinBox(GroupPoints->SpinBox_DZ, 0.00001, 359.99999, SpecificStep, "angle_precision" );
+ initSpinBox(GroupPoints->SpinBox_DZ, 0., 360., SpecificStep, "angle_precision" );
initSpinBox(GroupDimensions->SpinBox_DX, 0.00001, COORD_MAX, step, "length_precision" );
initSpinBox(GroupDimensions->SpinBox_DY, 0.00001, COORD_MAX, step, "length_precision" );
- initSpinBox(GroupDimensions->SpinBox_DZ, 0.00001, 359.99999, SpecificStep, "angle_precision" );
+ initSpinBox(GroupDimensions->SpinBox_DZ, 0., 360., SpecificStep, "angle_precision" );
// init variables
myEditCurrentArgument = GroupPoints->LineEdit1;
connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));
- connect(GroupPoints->checkBox, SIGNAL(toggled(bool)), this, SLOT(ActivateAngle()));
+ connect(GroupPoints->checkBox, SIGNAL(toggled(bool)), this, SLOT(ActivateAngle()));
connect(GroupDimensions->checkBox, SIGNAL(toggled(bool)), this, SLOT(ActivateAngle()));
initName(tr("GEOM_CYLINDER"));
updateGeometry();
resize(minimumSizeHint());
SelectionIntoArgument();
-
+
displayPreview(true);
}
this, SLOT(SelectionIntoArgument()));
}
}
-
displayPreview(true);
}
GroupPoints->LineEdit2->setEnabled(false);
globalSelection(GEOM_POINT); // to break previous local selection
- localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
+ localSelection(TopAbs_VERTEX);
}
else if (send == GroupPoints->PushButton2) {
myEditCurrentArgument = GroupPoints->LineEdit2;
GroupPoints->LineEdit1->setEnabled(false);
globalSelection(GEOM_LINE); // to break previous local selection
- localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
+ localSelection(TopAbs_EDGE);
}
connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
this, SLOT(SelectionIntoArgument()));
//=================================================================================
void PrimitiveGUI_CylinderDlg::ValueChangedInSpinBox()
{
+ QString msg;
+ if (!isValid(msg)) {
+ erasePreview();
+ return;
+ }
displayPreview(true);
}
//=================================================================================
GEOM::GEOM_IOperations_ptr PrimitiveGUI_CylinderDlg::createOperation()
{
- return getGeomEngine()->GetI3DPrimOperations(getStudyId());
+ return getGeomEngine()->GetI3DPrimOperations();
}
//=================================================================================
{
ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) &&
GroupPoints->SpinBox_DY->isValid( msg, !IsPreview() ) &&
- GroupPoints->SpinBox_DZ->isValid( msg, !IsPreview() ) &&
+ ( !GroupPoints->checkBox->isChecked() || GroupPoints->SpinBox_DZ->isValid( msg, !IsPreview() ) ) &&
myPoint && myDir;
+ if ( GroupPoints->checkBox->isChecked() &&
+ ( GroupPoints->SpinBox_DZ->value() <= 0. || GroupPoints->SpinBox_DZ->value() >= 360. ) ) {
+ msg += tr("GEOM_CYLINDER_ANGLE_ERR") + "\n";
+ ok = false;
+ }
}
else if( getConstructorId() == 1 )
{
ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) &&
GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() ) &&
- GroupDimensions->SpinBox_DZ->isValid( msg, !IsPreview() );
+ ( !GroupDimensions->checkBox->isChecked() || GroupDimensions->SpinBox_DZ->isValid( msg, !IsPreview() ) );
+ if ( GroupDimensions->checkBox->isChecked() &&
+ ( GroupDimensions->SpinBox_DZ->value() <= 0. || GroupDimensions->SpinBox_DZ->value() >= 360. ) ) {
+ msg += tr("GEOM_CYLINDER_ANGLE_ERR") + "\n";
+ ok = false;
+ }
}
ok = qAbs( getHeight() ) > Precision::Confusion() && ok;
ok = qAbs( getRadius() ) > Precision::Confusion() && ok;
bool PrimitiveGUI_CylinderDlg::execute (ObjectList& objects)
{
bool res = false;
- bool BAngle = false;
GEOM::GEOM_Object_var anObj;
switch (getConstructorId()) {
case 0:
- BAngle = GroupPoints->checkBox->isChecked();
if ( myPoint && myDir ) {
- if(!BAngle){
- anObj = anOper->MakeCylinderPntVecRH(myPoint.get(), myDir.get(), getRadius(), getHeight());
+ if ( GroupPoints->checkBox->isChecked() ) {
+ anObj = anOper->MakeCylinderPntVecRHA(myPoint.get(), myDir.get(), getRadius(), getHeight(), getAngle()*M_PI/180.);
if (!anObj->_is_nil() && !IsPreview())
{
QStringList aParameters;
aParameters << GroupPoints->SpinBox_DX->text();
aParameters << GroupPoints->SpinBox_DY->text();
- anObj->SetParameters(aParameters.join(":").toLatin1().constData());
+ aParameters << GroupPoints->SpinBox_DZ->text();
+ anObj->SetParameters(aParameters.join(":").toUtf8().constData());
}
res = true;
}
- else if(BAngle){
- anObj = anOper->MakeCylinderPntVecRHA(myPoint.get(), myDir.get(), getRadius(), getHeight(), getAngle()*M_PI/180.);
+ else {
+ anObj = anOper->MakeCylinderPntVecRH(myPoint.get(), myDir.get(), getRadius(), getHeight());
if (!anObj->_is_nil() && !IsPreview())
{
QStringList aParameters;
aParameters << GroupPoints->SpinBox_DX->text();
aParameters << GroupPoints->SpinBox_DY->text();
- aParameters << GroupPoints->SpinBox_DZ->text();
- anObj->SetParameters(aParameters.join(":").toLatin1().constData());
+ anObj->SetParameters(aParameters.join(":").toUtf8().constData());
}
res = true;
}
}
break;
case 1:
- BAngle = GroupDimensions->checkBox->isChecked();
- if(!BAngle){
- anObj = anOper->MakeCylinderRH(getRadius(), getHeight());
+ if ( GroupDimensions->checkBox->isChecked() ) {
+ anObj = anOper->MakeCylinderRHA(getRadius(), getHeight(), getAngle()*M_PI/180.);
if (!anObj->_is_nil() && !IsPreview())
{
QStringList aParameters;
aParameters << GroupDimensions->SpinBox_DX->text();
aParameters << GroupDimensions->SpinBox_DY->text();
- anObj->SetParameters(aParameters.join(":").toLatin1().constData());
+ aParameters << GroupDimensions->SpinBox_DZ->text();
+ anObj->SetParameters(aParameters.join(":").toUtf8().constData());
}
res = true;
}
- else if(BAngle){
- anObj = anOper->MakeCylinderRHA(getRadius(), getHeight(), getAngle()*M_PI/180.);
+ else {
+ anObj = anOper->MakeCylinderRH(getRadius(), getHeight());
if (!anObj->_is_nil() && !IsPreview())
{
QStringList aParameters;
aParameters << GroupDimensions->SpinBox_DX->text();
aParameters << GroupDimensions->SpinBox_DY->text();
- aParameters << GroupDimensions->SpinBox_DZ->text();
- anObj->SetParameters(aParameters.join(":").toLatin1().constData());
+ anObj->SetParameters(aParameters.join(":").toUtf8().constData());
}
res = true;
}
}
}
+//=================================================================================
+// function : getSourceObjects
+// purpose : virtual method to get source objects
+//=================================================================================
+QList<GEOM::GeomObjPtr> PrimitiveGUI_CylinderDlg::getSourceObjects()
+{
+ QList<GEOM::GeomObjPtr> res;
+ res << myPoint << myDir;
+ return res;
+}
+
//=================================================================================
// function : ActivateAngle()
// purpose : enable the