Back to index

salome-geom  6.5.0
Public Member Functions | Protected Member Functions | Private Slots | Private Member Functions | Private Attributes
PrimitiveGUI_TorusDlg Class Reference

#include <PrimitiveGUI_TorusDlg.h>

List of all members.

Public Member Functions

 PrimitiveGUI_TorusDlg (GeometryGUI *, QWidget *=0, bool=false, Qt::WindowFlags=0)
 ~PrimitiveGUI_TorusDlg ()

Protected Member Functions

virtual GEOM::GEOM_IOperations_ptr createOperation ()
virtual bool isValid (QString &)
virtual bool execute (ObjectList &)
virtual void addSubshapesToStudy ()

Private Slots

void ClickOnOk ()
bool ClickOnApply ()
void ActivateThisDialog ()
void SelectionIntoArgument ()
void SetEditCurrentArgument ()
void ConstructorsClicked (int)
void ValueChangedInSpinBox ()
void SetDoubleSpinBoxStep (double)

Private Member Functions

void Init ()
void enterEvent (QEvent *)
double getRadius1 () const
double getRadius2 () const

Private Attributes

GEOM::GeomObjPtr myPoint
GEOM::GeomObjPtr myDir
DlgRef_2Sel2Spin * GroupPoints
DlgRef_2Spin * GroupDimensions

Detailed Description

Definition at line 40 of file PrimitiveGUI_TorusDlg.h.


Constructor & Destructor Documentation

PrimitiveGUI_TorusDlg::PrimitiveGUI_TorusDlg ( GeometryGUI *  theGeometryGUI,
QWidget *  parent = 0,
bool  modal = false,
Qt::WindowFlags  fl = 0 
)

Definition at line 55 of file PrimitiveGUI_TorusDlg.cxx.

  : GEOMBase_Skeleton(theGeometryGUI, parent, modal, fl)
{
  SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
  QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_TORUS_PV")));
  QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_TORUS_DXYZ")));
  QPixmap image2 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));

  setWindowTitle(tr("GEOM_TORUS_TITLE"));

  /***************************************************************/
  mainFrame()->GroupConstructors->setTitle(tr("GEOM_TORUS"));
  mainFrame()->RadioButton1->setIcon(image0);
  mainFrame()->RadioButton2->setIcon(image1);
  mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
  mainFrame()->RadioButton3->close();

  GroupPoints = new DlgRef_2Sel2Spin(centralWidget());
  GroupPoints->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
  GroupPoints->TextLabel1->setText(tr("GEOM_BASE_POINT"));
  GroupPoints->TextLabel2->setText(tr("GEOM_VECTOR"));
  GroupPoints->TextLabel3->setText(tr("GEOM_RADIUS_I").arg(1));
  GroupPoints->TextLabel4->setText(tr("GEOM_RADIUS_I").arg(2));
  GroupPoints->PushButton1->setIcon(image2);
  GroupPoints->PushButton2->setIcon(image2);

  GroupDimensions = new DlgRef_2Spin(centralWidget());
  GroupDimensions->GroupBox1->setTitle(tr("GEOM_BOX_OBJ"));
  GroupDimensions->TextLabel1->setText(tr("GEOM_RADIUS_I").arg(1));
  GroupDimensions->TextLabel2->setText(tr("GEOM_RADIUS_I").arg(2));

  QVBoxLayout* layout = new QVBoxLayout(centralWidget());
  layout->setMargin(0); layout->setSpacing(6);
  layout->addWidget(GroupPoints);
  layout->addWidget(GroupDimensions);
  /***************************************************************/

  setHelpFileName("create_torus_page.html");

  Init();
}

Here is the call graph for this function:

Definition at line 102 of file PrimitiveGUI_TorusDlg.cxx.

{
  // no need to delete child widgets, Qt does it all for us
}

Member Function Documentation

Definition at line 327 of file PrimitiveGUI_TorusDlg.cxx.

{
  GEOMBase_Skeleton::ActivateThisDialog();

  connect( myGeomGUI->getApp()->selectionMgr(), SIGNAL( currentSelectionChanged() ),
           this, SLOT( SelectionIntoArgument() ) );
  
  ConstructorsClicked( getConstructorId() );
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PrimitiveGUI_TorusDlg::addSubshapesToStudy ( ) [protected, virtual]

Definition at line 463 of file PrimitiveGUI_TorusDlg.cxx.

{
  if ( getConstructorId() == 0 ) {
    GEOMBase::PublishSubObject( myPoint.get() );
    GEOMBase::PublishSubObject( myDir.get() );
  }
}

Here is the call graph for this function:

bool PrimitiveGUI_TorusDlg::ClickOnApply ( ) [private, slot]

Definition at line 221 of file PrimitiveGUI_TorusDlg.cxx.

{
  if (!onAccept())
    return false;

  initName();
  // activate selection and connect selection manager
  ConstructorsClicked(getConstructorId());
  return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PrimitiveGUI_TorusDlg::ClickOnOk ( ) [private, slot]

Definition at line 210 of file PrimitiveGUI_TorusDlg.cxx.

{
  setIsApplyAndClose( true );
  if (ClickOnApply())
    ClickOnCancel();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PrimitiveGUI_TorusDlg::ConstructorsClicked ( int  constructorId) [private, slot]

Definition at line 175 of file PrimitiveGUI_TorusDlg.cxx.

{
  disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);

  switch (constructorId) {
  case 0:
    {
      GroupDimensions->hide();
      GroupPoints->show();

      GroupPoints->PushButton1->click();
      break;
    }
  case 1:
    {
      GroupPoints->hide();
      GroupDimensions->show();
      disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
      globalSelection(); // close local contexts, if any
      break;
    }
  }

  qApp->processEvents();
  updateGeometry();
  resize(minimumSizeHint());
  SelectionIntoArgument();

  displayPreview(true);
}

Here is the call graph for this function:

Here is the caller graph for this function:

GEOM::GEOM_IOperations_ptr PrimitiveGUI_TorusDlg::createOperation ( ) [protected, virtual]

Definition at line 360 of file PrimitiveGUI_TorusDlg.cxx.

{
  return getGeomEngine()->GetI3DPrimOperations(getStudyId());
}
void PrimitiveGUI_TorusDlg::enterEvent ( QEvent *  ) [private]

Definition at line 341 of file PrimitiveGUI_TorusDlg.cxx.

{
  if (!mainFrame()->GroupConstructors->isEnabled())
    ActivateThisDialog();
}

Here is the call graph for this function:

bool PrimitiveGUI_TorusDlg::execute ( ObjectList objects) [protected, virtual]

Definition at line 390 of file PrimitiveGUI_TorusDlg.cxx.

{
  bool res = false;

  GEOM::GEOM_Object_var anObj;

  GEOM::GEOM_I3DPrimOperations_var anOper = GEOM::GEOM_I3DPrimOperations::_narrow(getOperation());

  switch (getConstructorId()) {
  case 0:
    if ( myPoint && myDir ) {
      anObj = anOper->MakeTorusPntVecRR(myPoint.get(), myDir.get(), getRadius1(), getRadius2());
      if (!anObj->_is_nil() && !IsPreview())
      {
        QStringList aParameters;
        aParameters << GroupPoints->SpinBox_DX->text();
        aParameters << GroupPoints->SpinBox_DY->text();
        anObj->SetParameters(aParameters.join(":").toLatin1().constData());
      }
      res = true;
    }
    break;
  case 1:
    anObj = anOper->MakeTorusRR(getRadius1(), getRadius2());
    if (!anObj->_is_nil() && !IsPreview())
    {
      QStringList aParameters;
      aParameters << GroupDimensions->SpinBox_DX->text();
      aParameters << GroupDimensions->SpinBox_DY->text();
      anObj->SetParameters(aParameters.join(":").toLatin1().constData());
    }
    res = true;
    break;
  }

  if (!anObj->_is_nil())
    objects.push_back(anObj._retn());

  return res;
}

Here is the call graph for this function:

double PrimitiveGUI_TorusDlg::getRadius1 ( ) const [private]

Definition at line 435 of file PrimitiveGUI_TorusDlg.cxx.

{
  int aConstructorId = getConstructorId();
  if (aConstructorId == 0)
    return GroupPoints->SpinBox_DX->value();
  else if (aConstructorId == 1)
    return GroupDimensions->SpinBox_DX->value();
  return 0;
}

Here is the caller graph for this function:

double PrimitiveGUI_TorusDlg::getRadius2 ( ) const [private]

Definition at line 449 of file PrimitiveGUI_TorusDlg.cxx.

{
  int aConstructorId = getConstructorId();
  if (aConstructorId == 0)
    return GroupPoints->SpinBox_DY->value();
  else if (aConstructorId == 1)
    return GroupDimensions->SpinBox_DY->value();
  return 0;
}

Here is the caller graph for this function:

void PrimitiveGUI_TorusDlg::Init ( ) [private]

Definition at line 111 of file PrimitiveGUI_TorusDlg.cxx.

{
  // Get setting of step value from file configuration
  SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
  double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);

  // min, max, step and decimals for spin boxes & initial values
  initSpinBox(GroupPoints->SpinBox_DX, 0.000001, COORD_MAX, step, "length_precision" );
  initSpinBox(GroupPoints->SpinBox_DY, 0.000001, COORD_MAX, step, "length_precision" );
  initSpinBox(GroupDimensions->SpinBox_DX, 0.000001, COORD_MAX, step, "length_precision" );
  initSpinBox(GroupDimensions->SpinBox_DY, 0.000001, COORD_MAX, step, "length_precision" );

  // init variables
  GroupPoints->LineEdit1->setReadOnly(true);
  GroupPoints->LineEdit2->setReadOnly(true);

  GroupPoints->LineEdit1->setText("");
  GroupPoints->LineEdit2->setText("");
  myPoint.nullify();
  myDir.nullify();

  GroupPoints->SpinBox_DX->setValue(300.0);
  GroupPoints->SpinBox_DY->setValue(100.0);
  GroupDimensions->SpinBox_DX->setValue(300.0);
  GroupDimensions->SpinBox_DY->setValue(100.0);

  // signals and slots connections
  connect(buttonOk(),    SIGNAL(clicked()), this, SLOT(ClickOnOk()));
  connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));

  connect(this, SIGNAL(constructorsClicked(int)), this, SLOT(ConstructorsClicked(int)));

  connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
  connect(GroupPoints->PushButton2, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));

  connect(GroupPoints->SpinBox_DX,     SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
  connect(GroupPoints->SpinBox_DY,     SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
  connect(GroupDimensions->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
  connect(GroupDimensions->SpinBox_DY, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));

  connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)), this, SLOT(SetDoubleSpinBoxStep(double)));

  initName(tr("GEOM_TORUS"));

  setConstructorId(1); // simplest constructor
  ConstructorsClicked(1);
}

Here is the call graph for this function:

Here is the caller graph for this function:

bool PrimitiveGUI_TorusDlg::isValid ( QString &  msg) [protected, virtual]

Definition at line 369 of file PrimitiveGUI_TorusDlg.cxx.

{
  bool ok = false;
  if( getConstructorId() == 0 )
  {
    ok = GroupPoints->SpinBox_DX->isValid( msg, !IsPreview() ) &&
         GroupPoints->SpinBox_DY->isValid( msg, !IsPreview() ) &&
         myPoint && myDir;
  }
  else if( getConstructorId() == 1 )
  {
    ok = GroupDimensions->SpinBox_DX->isValid( msg, !IsPreview() ) &&
         GroupDimensions->SpinBox_DY->isValid( msg, !IsPreview() );
  }
  return ok;
}

Definition at line 236 of file PrimitiveGUI_TorusDlg.cxx.

{
  if (getConstructorId() != 0)
    return;

  erasePreview();
  myEditCurrentArgument->setText("");

  LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
  SALOME_ListIO aSelList;
  aSelMgr->selectedObjects(aSelList);

  if (aSelList.Extent() != 1) {
    if      (myEditCurrentArgument == GroupPoints->LineEdit1) myPoint.nullify();
    else if (myEditCurrentArgument == GroupPoints->LineEdit2) myDir.nullify();
    return;
  }

  TopAbs_ShapeEnum aNeedType = myEditCurrentArgument == GroupPoints->LineEdit2 ? TopAbs_EDGE : TopAbs_VERTEX;
  GEOM::GeomObjPtr aSelectedObject = getSelected( aNeedType );
  TopoDS_Shape aShape;
  if ( aSelectedObject && GEOMBase::GetShape( aSelectedObject.get(), aShape ) && !aShape.IsNull() ) {
    QString aName = GEOMBase::GetName( aSelectedObject.get() );

    myEditCurrentArgument->setText(aName);
    
    // clear selection
    disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
    myGeomGUI->getApp()->selectionMgr()->clearSelected();
    connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
           this, SLOT(SelectionIntoArgument()));
    
    if (myEditCurrentArgument == GroupPoints->LineEdit1) {
      myPoint = aSelectedObject;
      if (myPoint && !myDir)
       GroupPoints->PushButton2->click();
    }
    else if (myEditCurrentArgument == GroupPoints->LineEdit2) {
      myDir = aSelectedObject;
      if (myDir && !myPoint)
       GroupPoints->PushButton1->click();
    }
  }

  displayPreview(true);
}

Here is the call graph for this function:

Here is the caller graph for this function:

void PrimitiveGUI_TorusDlg::SetDoubleSpinBoxStep ( double  step) [private, slot]

Definition at line 163 of file PrimitiveGUI_TorusDlg.cxx.

{
  GroupPoints->SpinBox_DX->setSingleStep(step);
  GroupPoints->SpinBox_DY->setSingleStep(step);
  GroupDimensions->SpinBox_DX->setSingleStep(step);
  GroupDimensions->SpinBox_DY->setSingleStep(step);
}

Here is the caller graph for this function:

Definition at line 287 of file PrimitiveGUI_TorusDlg.cxx.

{
  QPushButton* send = (QPushButton*)sender();

  disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
  if (send == GroupPoints->PushButton1) {
    myEditCurrentArgument = GroupPoints->LineEdit1;

    GroupPoints->PushButton2->setDown(false);
    GroupPoints->LineEdit2->setEnabled(false);

    globalSelection(GEOM_POINT); // to break previous local selection
    localSelection(GEOM::GEOM_Object::_nil(), TopAbs_VERTEX);
  }
  else if (send == GroupPoints->PushButton2) {
    myEditCurrentArgument = GroupPoints->LineEdit2;

    GroupPoints->PushButton1->setDown(false);
    GroupPoints->LineEdit1->setEnabled(false);

    globalSelection(GEOM_LINE);  // to break previous local selection
    localSelection(GEOM::GEOM_Object::_nil(), TopAbs_EDGE);
  }
  connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
          this, SLOT(SelectionIntoArgument()));

  // enable line edit
  myEditCurrentArgument->setEnabled(true);
  myEditCurrentArgument->setFocus();
  // after setFocus(), because it will be setDown(false) when loses focus
  send->setDown(true);

  // seems we need it only to avoid preview disappearing, caused by selection mode change
  displayPreview(true);
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 351 of file PrimitiveGUI_TorusDlg.cxx.

{
  displayPreview(true);
}

Here is the caller graph for this function:


Member Data Documentation

DlgRef_2Spin* PrimitiveGUI_TorusDlg::GroupDimensions [private]

Definition at line 65 of file PrimitiveGUI_TorusDlg.h.

DlgRef_2Sel2Spin* PrimitiveGUI_TorusDlg::GroupPoints [private]

Definition at line 64 of file PrimitiveGUI_TorusDlg.h.

Definition at line 62 of file PrimitiveGUI_TorusDlg.h.

Definition at line 62 of file PrimitiveGUI_TorusDlg.h.


The documentation for this class was generated from the following files: