Back to index

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

#include <MeasureGUI_AngleDlg.h>

Inheritance diagram for MeasureGUI_AngleDlg:
Inheritance graph
[legend]
Collaboration diagram for MeasureGUI_AngleDlg:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 MeasureGUI_AngleDlg (GeometryGUI *, QWidget *)
 ~MeasureGUI_AngleDlg ()

Protected Slots

virtual void ClickOnCancel ()
virtual void ClickOnHelp ()
virtual void DeactivateActiveDialog ()
virtual void ActivateThisDialog ()

Protected Member Functions

virtual void processObject ()
virtual SALOME_Prs * buildPrs ()
virtual void SelectionIntoArgument ()
virtual void LineEditReturnPressed ()
virtual void SetEditCurrentArgument ()
virtual bool isValid (QString &)
void enterEvent (QEvent *)
void closeEvent (QCloseEvent *)
void keyPressEvent (QKeyEvent *)
void redisplayPreview ()
GEOM_Displayer * getDisplayer ()
virtual void activateSelection ()
virtual GEOM::GEOM_IOperations_ptr createOperation ()
MeasureGUI_SkeletonBoxmainFrame () const
QWidget * centralWidget () const
QPushButton * buttonClose () const
QPushButton * buttonHelp () const

Protected Attributes

QPushButton * mySelBtn
QLineEdit * mySelEdit
GEOM::GEOM_Object_var myObj
GeometryGUI * myGeomGUI
GEOM_Displayer * myDisplayer
QString myHelpFileName
MeasureGUI_SkeletonBoxmyMainFrame

Private Member Functions

void Init ()
bool getParameters (double &)

Private Attributes

QLineEdit * myEditCurrentArgument
QLineEdit * mySelEdit2
QPushButton * mySelBtn2
MeasureGUI_2Sel1LineEditmyGrp
GEOM::GEOM_Object_var myObj2

Detailed Description

Definition at line 35 of file MeasureGUI_AngleDlg.h.


Constructor & Destructor Documentation

MeasureGUI_AngleDlg::MeasureGUI_AngleDlg ( GeometryGUI *  GUI,
QWidget *  parent 
)

Definition at line 84 of file MeasureGUI_AngleDlg.cxx.

  : MeasureGUI_Skeleton(GUI, parent)
{
  SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
  QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_ANGLE")));
  QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));

  setWindowTitle(tr("GEOM_MEASURE_ANGLE_TITLE"));

  /***************************************************************/
  mainFrame()->GroupConstructors->setTitle(tr("GEOM_MEASURE_ANGLE_ANGLE"));
  mainFrame()->RadioButton1->setIcon(image0);

  myGrp = new MeasureGUI_2Sel1LineEdit(centralWidget());
  myGrp->GroupBox1->setTitle(tr("GEOM_MEASURE_ANGLE_OBJ"));
  myGrp->TextLabel1->setText(tr("GEOM_OBJECT_I").arg("1"));
  myGrp->TextLabel2->setText(tr("GEOM_OBJECT_I").arg("2"));
  myGrp->TextLabel3->setText(tr("GEOM_MEASURE_ANGLE_IS"));
  myGrp->LineEdit3->setReadOnly(true);
  myGrp->PushButton1->setIcon(image1);
  myGrp->PushButton2->setIcon(image1);
  myGrp->LineEdit1->setReadOnly(true);
  myGrp->LineEdit2->setReadOnly(true);

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

  // Help page reference
  myHelpFileName = "using_measurement_tools_page.html#angle_anchor";

  // Initialisation
  Init();
}

Here is the call graph for this function:

Definition at line 124 of file MeasureGUI_AngleDlg.cxx.

{
}

Member Function Documentation

void MeasureGUI_Skeleton::activateSelection ( ) [protected, virtual, inherited]

Reimplemented in MeasureGUI_PropertiesDlg, and MeasureGUI_PointDlg.

Definition at line 348 of file MeasureGUI_Skeleton.cxx.

{
  globalSelection( GEOM_ALLSHAPES );
}

Here is the caller graph for this function:

void MeasureGUI_Skeleton::ActivateThisDialog ( ) [protected, virtual, slot, inherited]

Definition at line 215 of file MeasureGUI_Skeleton.cxx.

{
  myGeomGUI->EmitSignalDeactivateDialog();
  
  setEnabled( true );
  
  myGeomGUI->SetActiveDialogBox( ( QDialog* )this );

  LightApp_SelectionMgr* aSel = ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr();
  if ( aSel )
    connect( aSel, SIGNAL( currentSelectionChanged() ), 
             this, SLOT  ( SelectionIntoArgument() ) ) ;
  
  redisplayPreview();
  activateSelection();
}

Here is the call graph for this function:

Here is the caller graph for this function:

SALOME_Prs * MeasureGUI_AngleDlg::buildPrs ( ) [protected, virtual]

Reimplemented from MeasureGUI_Skeleton.

Definition at line 303 of file MeasureGUI_AngleDlg.cxx.

{
  double anAngle = 0.;

  SUIT_ViewWindow* vw = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();

  if (myObj->_is_nil() || myObj2->_is_nil() || !getParameters(anAngle) ||
       vw->getViewManager()->getType() != OCCViewer_Viewer::Type())
    return 0;

  if (anAngle > Precision::Angular()) {
    try {
#if OCC_VERSION_LARGE > 0x06010000
      OCC_CATCH_SIGNALS;
#endif
      TopoDS_Shape S1, S2;
      if (GEOMBase::GetShape(myObj , S1, TopAbs_EDGE) &&
           GEOMBase::GetShape(myObj2, S2, TopAbs_EDGE)) {
        TopoDS_Edge anEdge1 = TopoDS::Edge(S1);
        TopoDS_Edge anEdge2 = TopoDS::Edge(S2);

        // Build a plane for angle dimension presentation {P11, P12, P3}
        TopoDS_Vertex V11, V12, V21, V22;
        TopExp::Vertices(anEdge1, V11, V12);
        TopExp::Vertices(anEdge2, V21, V22);

        gp_Pnt aP11 = BRep_Tool::Pnt(TopExp::FirstVertex(anEdge1));
        gp_Pnt aP12 = BRep_Tool::Pnt(TopExp::LastVertex (anEdge1));

        gp_Pnt aP21 = BRep_Tool::Pnt(TopExp::FirstVertex(anEdge2));
        gp_Pnt aP22 = BRep_Tool::Pnt(TopExp::LastVertex (anEdge2));

        //        *P3
        //         \
        //          \
        //           *P22
        //          /
        //         /
        // P11    /         P12
        // *-----/----------*
        //  \   /
        //   \ /
        //    *P21
        gp_Pnt aP3 (aP22.XYZ() + aP11.XYZ() - aP21.XYZ());

        gce_MakePln gce_MP(aP11, aP12, aP3);
        Handle(Geom_Plane) aPlane = new Geom_Plane(gce_MP.Value());

        // Build the angle dimension presentation
        QString aLabel;
        aLabel.sprintf("%.1f", anAngle);

        Handle(AIS_AngleDimension) anIO = new AIS_AngleDimension
          (anEdge1, anEdge2, aPlane, anAngle * M_PI / 180.,
           TCollection_ExtendedString((Standard_CString)aLabel.toLatin1().data()));
        Handle(Geom_Line) geom_lin1,geom_lin2;
        gp_Pnt ptat11,ptat12,ptat21,ptat22;
        Standard_Boolean isInfinite1,isInfinite2;
        Handle(Geom_Curve) extCurv;
        Standard_Integer extShape;
        if (AIS::ComputeGeometry(anEdge1,
                                  anEdge2,
                                  extShape,
                                  geom_lin1,
                                  geom_lin2,
                                  ptat11,
                                  ptat12,
                                  ptat21,
                                  ptat22,
                                  extCurv,
                                  isInfinite1,
                                  isInfinite2,
                                  aPlane)) {
          Standard_Real arrSize1 = anIO->ArrowSize();
          Standard_Real arrSize2 = anIO->ArrowSize();
          if (!isInfinite1) arrSize1 = ptat11.Distance(ptat12)/10.;
          if (!isInfinite2) arrSize2 = ptat21.Distance(ptat22)/10.;
          Standard_Real arrowSize = Max(arrSize1,arrSize2);
          anIO->SetArrowSize(arrowSize);
        }

       SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
       int w = resMgr->integerValue("Geometry", "measures_line_width", 1);
  Handle(Prs3d_AngleAspect) asp = new Prs3d_AngleAspect();
  asp->LineAspect()->SetWidth(w);
       anIO->Attributes()->SetAngleAspect(asp);

        SOCC_Prs* aPrs =
          dynamic_cast<SOCC_Prs*>(((SOCC_Viewer*)(vw->getViewManager()->getViewModel()))->CreatePrs(0));

        if (aPrs)
          aPrs->AddObject(anIO);

        return aPrs;
      }
    }
    catch(Standard_Failure) {
    }
  }

  return 0;
}

Here is the call graph for this function:

QPushButton * MeasureGUI_Skeleton::buttonClose ( ) const [protected, inherited]

Definition at line 408 of file MeasureGUI_Skeleton.cxx.

{
  return mainFrame()->buttonClose;
}

Here is the call graph for this function:

Here is the caller graph for this function:

QPushButton * MeasureGUI_Skeleton::buttonHelp ( ) const [protected, inherited]

Definition at line 413 of file MeasureGUI_Skeleton.cxx.

{
  return mainFrame()->buttonHelp;
}

Here is the call graph for this function:

Here is the caller graph for this function:

QWidget * MeasureGUI_Skeleton::centralWidget ( ) const [protected, inherited]

Definition at line 403 of file MeasureGUI_Skeleton.cxx.

{
  return mainFrame()->GroupMedium;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void MeasureGUI_Skeleton::ClickOnCancel ( ) [protected, virtual, slot, inherited]

Definition at line 141 of file MeasureGUI_Skeleton.cxx.

{
  close();
}

Here is the caller graph for this function:

void MeasureGUI_Skeleton::ClickOnHelp ( ) [protected, virtual, slot, inherited]

Definition at line 150 of file MeasureGUI_Skeleton.cxx.

{
  LightApp_Application* app = (LightApp_Application*)( SUIT_Session::session()->activeApplication() );
  if ( app ) {
    app->onHelpContextModule( myGeomGUI ? app->moduleName( myGeomGUI->moduleName() ) : QString( "" ), myHelpFileName );
  }
  else {
    QString platform;
#ifdef WIN32
    platform = "winapplication";
#else
    platform = "application";
#endif
    SUIT_MessageBox::warning( this, tr( "WRN_WARNING" ),
                              tr( "EXTERNAL_BROWSER_CANNOT_SHOW_PAGE" ).
                              arg( app->resourceMgr()->stringValue( "ExternalBrowser", platform ) ).arg( myHelpFileName ) );
  }
}

Here is the caller graph for this function:

void MeasureGUI_Skeleton::closeEvent ( QCloseEvent *  e) [protected, inherited]

Definition at line 286 of file MeasureGUI_Skeleton.cxx.

{
  LightApp_SelectionMgr* aSel = ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr();
  if ( aSel )
    disconnect( aSel, 0, this, 0 );
  QDialog::closeEvent( e );
}
GEOM::GEOM_IOperations_ptr MeasureGUI_Skeleton::createOperation ( ) [protected, virtual, inherited]

Definition at line 377 of file MeasureGUI_Skeleton.cxx.

{
  return getGeomEngine()->GetIMeasureOperations( getStudyId() );
}
void MeasureGUI_Skeleton::DeactivateActiveDialog ( ) [protected, virtual, slot, inherited]

Definition at line 197 of file MeasureGUI_Skeleton.cxx.

{
  setEnabled( false );
  
  LightApp_SelectionMgr* aSel = ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr();
  if ( aSel )
    disconnect( aSel, 0, this, 0 );
  
  myGeomGUI->SetActiveDialogBox( 0 );

  globalSelection();
}

Here is the caller graph for this function:

void MeasureGUI_Skeleton::enterEvent ( QEvent *  ) [protected, inherited]

Definition at line 298 of file MeasureGUI_Skeleton.cxx.

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

Here is the call graph for this function:

GEOM_Displayer * MeasureGUI_Skeleton::getDisplayer ( ) [protected, inherited]

Definition at line 366 of file MeasureGUI_Skeleton.cxx.

{
  if ( !myDisplayer )
    myDisplayer = new GEOM_Displayer( getStudy() );
  return myDisplayer;
}

Here is the caller graph for this function:

bool MeasureGUI_AngleDlg::getParameters ( double &  theAngle) [private]

Definition at line 216 of file MeasureGUI_AngleDlg.cxx.

{
  QString msg;
  if (isValid(msg)) {
    GEOM::GEOM_IMeasureOperations_var anOper = GEOM::GEOM_IMeasureOperations::_narrow( getOperation() );
    try {
      theAngle = anOper->GetAngle(myObj, myObj2);
    }
    catch(const SALOME::SALOME_Exception& e) {
      SalomeApp_Tools::QtCatchCorbaException(e);
      return false;
    }

    bool isDone = anOper->IsDone();
    if (!isDone) {
      CORBA::String_var aMsg = anOper->GetErrorCode();
      SUIT_MessageBox::warning(this,
                               QObject::tr("WRN_WARNING"),
                               QObject::tr(aMsg.in()));
    }
    return isDone;
  }

  return false;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void MeasureGUI_AngleDlg::Init ( ) [private]

Reimplemented from MeasureGUI_Skeleton.

Definition at line 132 of file MeasureGUI_AngleDlg.cxx.

{
  // init variables
  myGrp->LineEdit1->setText("");
  myGrp->LineEdit2->setText("");
  myObj = myObj2 = GEOM::GEOM_Object::_nil();

  mySelBtn   = myGrp->PushButton1;
  mySelEdit  = myGrp->LineEdit1;
  mySelBtn2  = myGrp->PushButton2;
  mySelEdit2 = myGrp->LineEdit2;

  myEditCurrentArgument = mySelEdit;

  // signals and slots connections
  connect(mySelEdit2, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
  connect(mySelBtn2,  SIGNAL(clicked()),       this, SLOT(SetEditCurrentArgument()));

  globalSelection(GEOM_LINE);
  MeasureGUI_Skeleton::Init();
}

Here is the call graph for this function:

Here is the caller graph for this function:

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

Reimplemented from MeasureGUI_Skeleton.

Definition at line 410 of file MeasureGUI_AngleDlg.cxx.

{
  return MeasureGUI_Skeleton::isValid(msg) && !myObj2->_is_nil();
}

Here is the caller graph for this function:

void MeasureGUI_Skeleton::keyPressEvent ( QKeyEvent *  e) [protected, inherited]

Definition at line 386 of file MeasureGUI_Skeleton.cxx.

{
  QDialog::keyPressEvent( e );
  if ( e->isAccepted() )
    return;

  if ( e->key() == Qt::Key_F1 ) {
    e->accept();
    ClickOnHelp();
  }
}

Here is the call graph for this function:

void MeasureGUI_AngleDlg::LineEditReturnPressed ( ) [protected, virtual]

Reimplemented from MeasureGUI_Skeleton.

Definition at line 282 of file MeasureGUI_AngleDlg.cxx.

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

  if (send == mySelEdit)
    myEditCurrentArgument = mySelEdit;
  else
    myEditCurrentArgument = mySelEdit2;

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

  if (GEOMBase::SelectionByNameInDialogs(this, mySelEdit->text(), aSelList))
    mySelEdit->setText(mySelEdit->text());
}

Here is the caller graph for this function:

MeasureGUI_SkeletonBox * MeasureGUI_Skeleton::mainFrame ( ) const [protected, inherited]

Definition at line 398 of file MeasureGUI_Skeleton.cxx.

{
  return myMainFrame;
}

Here is the caller graph for this function:

void MeasureGUI_AngleDlg::processObject ( ) [protected, virtual]

Reimplemented from MeasureGUI_Skeleton.

Definition at line 194 of file MeasureGUI_AngleDlg.cxx.

{
  myGrp->LineEdit1->setText(!myObj->_is_nil()  ? GEOMBase::GetName(myObj ) : "");
  myGrp->LineEdit2->setText(!myObj2->_is_nil() ? GEOMBase::GetName(myObj2) : "");

  double anAngle = 0.;
  if (getParameters(anAngle)) {
    SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
    int aPrecision = resMgr->integerValue( "Geometry", "angle_precision", 6 );
    myGrp->LineEdit3->setText(DlgRef::PrintDoubleValue(anAngle, aPrecision));
    redisplayPreview();
  }
  else {
    myGrp->LineEdit3->setText("");
    erasePreview();
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void MeasureGUI_Skeleton::redisplayPreview ( ) [protected, inherited]

Definition at line 319 of file MeasureGUI_Skeleton.cxx.

{
  QString aMess;
  if ( !isValid( aMess ) ) {
    erasePreview( true );
    return;
  }

  erasePreview( false );

  try {
    SUIT_OverrideCursor();

    getDisplayer()->SetColor( Quantity_NOC_VIOLET );
    getDisplayer()->SetToActivate( false );
    
    if ( SALOME_Prs* aPrs = buildPrs() )
      displayPreview( aPrs );
  }
  catch ( const SALOME::SALOME_Exception& e ) {
    SalomeApp_Tools::QtCatchCorbaException( e );
  }
  
}

Here is the call graph for this function:

Here is the caller graph for this function:

void MeasureGUI_AngleDlg::SelectionIntoArgument ( ) [protected, virtual]

Reimplemented from MeasureGUI_Skeleton.

Definition at line 158 of file MeasureGUI_AngleDlg.cxx.

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

  GEOM::GEOM_Object_var aSelectedObject = GEOM::GEOM_Object::_nil();

  if (aSelList.Extent() > 0) {
    aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
  }

  // clear selection
  disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
  myGeomGUI->getApp()->selectionMgr()->clearSelected();
  connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
          this, SLOT(SelectionIntoArgument()));

  if (myEditCurrentArgument == mySelEdit) {
    myObj = aSelectedObject;
    if (!myObj->_is_nil() && myObj2->_is_nil())
      myGrp->PushButton2->click();
  }
  else {
    myObj2 = aSelectedObject;
    if (!myObj2->_is_nil() && myObj->_is_nil())
      myGrp->PushButton1->click();
  }

  processObject();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void MeasureGUI_AngleDlg::SetEditCurrentArgument ( ) [protected, virtual]

Reimplemented from MeasureGUI_Skeleton.

Definition at line 246 of file MeasureGUI_AngleDlg.cxx.

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

  if (send == myGrp->PushButton1) {
    myEditCurrentArgument = myGrp->LineEdit1;

    myGrp->PushButton2->setDown(false);
    myGrp->LineEdit2->setEnabled(false);
  }
  else {
    myEditCurrentArgument = myGrp->LineEdit2;

    myGrp->PushButton1->setDown(false);
    myGrp->LineEdit1->setEnabled(false);
  }

  disconnect(myGeomGUI->getApp()->selectionMgr(), 0, this, 0);
  globalSelection(GEOM_LINE);
  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
  redisplayPreview();
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

GEOM_Displayer* MeasureGUI_Skeleton::myDisplayer [protected, inherited]

Definition at line 83 of file MeasureGUI_Skeleton.h.

Definition at line 57 of file MeasureGUI_AngleDlg.h.

GeometryGUI* MeasureGUI_Skeleton::myGeomGUI [protected, inherited]

Definition at line 82 of file MeasureGUI_Skeleton.h.

Definition at line 60 of file MeasureGUI_AngleDlg.h.

QString MeasureGUI_Skeleton::myHelpFileName [protected, inherited]

Definition at line 85 of file MeasureGUI_Skeleton.h.

Definition at line 86 of file MeasureGUI_Skeleton.h.

GEOM::GEOM_Object_var MeasureGUI_Skeleton::myObj [protected, inherited]

Definition at line 80 of file MeasureGUI_Skeleton.h.

GEOM::GEOM_Object_var MeasureGUI_AngleDlg::myObj2 [private]

Definition at line 62 of file MeasureGUI_AngleDlg.h.

QPushButton* MeasureGUI_Skeleton::mySelBtn [protected, inherited]

Definition at line 78 of file MeasureGUI_Skeleton.h.

QPushButton* MeasureGUI_AngleDlg::mySelBtn2 [private]

Definition at line 59 of file MeasureGUI_AngleDlg.h.

QLineEdit* MeasureGUI_Skeleton::mySelEdit [protected, inherited]

Definition at line 79 of file MeasureGUI_Skeleton.h.

QLineEdit* MeasureGUI_AngleDlg::mySelEdit2 [private]

Definition at line 58 of file MeasureGUI_AngleDlg.h.


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