Back to index

salome-geom  6.5.0
Public Member Functions | Static Public Member Functions
EntityGUI Class Reference

#include <EntityGUI.h>

List of all members.

Public Member Functions

 EntityGUI (GeometryGUI *)
 ~EntityGUI ()
bool OnGUIEvent (int, SUIT_Desktop *)
bool OnMousePress (QMouseEvent *pe, SUIT_Desktop *parent, SUIT_ViewWindow *theViewWindow)
bool OnMouseMove (QMouseEvent *pe, SUIT_Desktop *parent, SUIT_ViewWindow *theViewWindow)
bool OnMouseRelease (QMouseEvent *pe, SUIT_Desktop *parent, SUIT_ViewWindow *theViewWindow)
void DisplaySimulationShape (const TopoDS_Shape &, const TopoDS_Shape &)
void EraseSimulationShape ()
bool SObjectExist (const _PTR(SObject)&, const char *)
 Handle (AIS_Shape) mySimulationShape1
 Handle (AIS_Shape) mySimulationShape2

Static Public Member Functions

static gp_Pnt ConvertClickToPoint (int x, int y, Handle(V3d_View) aView)

Detailed Description

Definition at line 44 of file EntityGUI.h.


Constructor & Destructor Documentation

EntityGUI::EntityGUI ( GeometryGUI *  parent)

Definition at line 61 of file EntityGUI.cxx.

                                          :  GEOMGUI( parent )
{
  mySimulationShape1 = new AIS_Shape( TopoDS_Shape() );
  mySimulationShape2 = new AIS_Shape( TopoDS_Shape() );
}

Definition at line 71 of file EntityGUI.cxx.

{
}

Member Function Documentation

gp_Pnt EntityGUI::ConvertClickToPoint ( int  x,
int  y,
Handle(V3d_View)  aView 
) [static]

Definition at line 258 of file EntityGUI.cxx.

{
  V3d_Coordinate XEye, YEye, ZEye, XAt, YAt, ZAt;
  aView->Eye( XEye, YEye, ZEye );

  aView->At( XAt, YAt, ZAt );
  gp_Pnt EyePoint( XEye, YEye, ZEye );
  gp_Pnt AtPoint( XAt, YAt, ZAt );

  gp_Vec EyeVector( EyePoint, AtPoint );
  gp_Dir EyeDir( EyeVector );

  gp_Pln PlaneOfTheView = gp_Pln( AtPoint, EyeDir );
  Standard_Real X, Y, Z;
  aView->Convert( x, y, X, Y, Z );
  gp_Pnt ConvertedPoint( X, Y, Z );

  gp_Pnt2d ConvertedPointOnPlane = ProjLib::Project( PlaneOfTheView, ConvertedPoint );
  gp_Pnt ResultPoint = ElSLib::Value( ConvertedPointOnPlane.X(), ConvertedPointOnPlane.Y(), PlaneOfTheView );
  return ResultPoint;
}

Here is the caller graph for this function:

void EntityGUI::DisplaySimulationShape ( const TopoDS_Shape &  S1,
const TopoDS_Shape &  S2 
)

Definition at line 284 of file EntityGUI.cxx.

{
  MESSAGE("EntityGUI::DisplaySimulationShape")
  SalomeApp_Application* app = getGeometryGUI()->getApp();
  if ( !app ) return;

  SUIT_ViewManager* aVM = app->desktop()->activeWindow()->getViewManager();
  if ( aVM->getType() != OCCViewer_Viewer::Type() )
    return;

  OCCViewer_Viewer* v3d = ( (OCCViewer_ViewManager*)aVM )->getOCCViewer();
  Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
  try {
    if ( !S1.IsNull() ) {
      /* erase any previous */
      ic->Erase( mySimulationShape1, Standard_True, Standard_False );
      ic->ClearPrs( mySimulationShape1 );

      mySimulationShape1 = new AIS_Shape( TopoDS_Shape() );
      mySimulationShape1->Set( S1 );
      mySimulationShape1->SetColor( Quantity_NOC_RED );

      ic->Deactivate( mySimulationShape1 );
      ic->Display( mySimulationShape1, Standard_False );
      mySimulationShape1->UnsetColor();
    }
    if ( !S2.IsNull() ) {
      ic->Erase( mySimulationShape2, Standard_True, Standard_False );
      ic->ClearPrs( mySimulationShape2 );

      mySimulationShape2 = new AIS_Shape( TopoDS_Shape() );
      mySimulationShape2->Set( S2 );
      mySimulationShape2->SetColor( Quantity_NOC_VIOLET );

      ic->Deactivate( mySimulationShape2 );
      ic->Display( mySimulationShape2, Standard_False );
      mySimulationShape2->UnsetColor();
    }
    ic->UpdateCurrentViewer();
  }
  catch( Standard_Failure ) {
    MESSAGE( "Exception catched in EntityGUI::DisplaySimulationShape" );
  } 
}

Here is the call graph for this function:

Definition at line 333 of file EntityGUI.cxx.

{
  MESSAGE("EntityGUI::EraseSimulationShape")
  SalomeApp_Application* app = getGeometryGUI()->getApp();
  if ( !app ) return;

  // get all view windows at the desktop
  QList<SUIT_ViewWindow*> aWndLst = app->desktop()->windows();
  //get all view windows, which belong to the active study
  QList<SUIT_ViewWindow*> aWndLstAS;
  SUIT_ViewWindow* vw;

  QListIterator<SUIT_ViewWindow*> itWL( aWndLst );
  while ( itWL.hasNext() && ( vw = itWL.next() ) )
    if ( vw->getViewManager()->study() == app->activeStudy() )
      aWndLstAS.append( vw );

  QListIterator<SUIT_ViewWindow*> itWLAS( aWndLstAS );
  while ( itWLAS.hasNext() && ( vw = itWLAS.next() ) ) {
    if ( vw->getViewManager()->getType() == OCCViewer_Viewer::Type() ) {
      OCCViewer_Viewer* v3d = ( (OCCViewer_ViewManager*)( vw->getViewManager() ) )->getOCCViewer();
      Handle(AIS_InteractiveContext) ic = v3d->getAISContext();
      ic->Erase( mySimulationShape1, Standard_True, Standard_False );
      ic->ClearPrs( mySimulationShape1 );
      ic->Erase( mySimulationShape2, Standard_True, Standard_False );
      ic->ClearPrs( mySimulationShape2 );
      ic->UpdateCurrentViewer();
    } 
  }
}

Here is the call graph for this function:

EntityGUI::Handle ( AIS_Shape  )

Here is the caller graph for this function:

EntityGUI::Handle ( AIS_Shape  )
bool EntityGUI::OnGUIEvent ( int  theCommandID,
SUIT_Desktop *  parent 
)

Definition at line 80 of file EntityGUI.cxx.

{
  SalomeApp_Application* app = getGeometryGUI()->getApp();
  if ( !app ) return false;

  getGeometryGUI()->EmitSignalDeactivateDialog();
  QDialog* aDlg = NULL;

  switch ( theCommandID ) {
  case GEOMOp::Op2dSketcher: // 2D SKETCHER
    getGeometryGUI()->ActiveWorkingPlane();
    aDlg = new EntityGUI_SketcherDlg( getGeometryGUI(), parent );
    break;
  case GEOMOp::Op3dSketcher: // 3D SKETCHER
    aDlg = new EntityGUI_3DSketcherDlg( getGeometryGUI(), parent );
    break;
  case GEOMOp::OpExplode:    // EXPLODE
    aDlg = new EntityGUI_SubShapeDlg( getGeometryGUI(), parent );
    break;
#ifdef WITH_OPENCV
  case GEOMOp::OpFeatureDetect:    // FEATURE DETECTION
    aDlg = new EntityGUI_FeatureDetectorDlg( getGeometryGUI(), parent );
    break;
#endif
  case GEOMOp::OpPictureImport:    // IMPORT PICTURE IN VIEWER
    aDlg = new EntityGUI_PictureImportDlg( getGeometryGUI(), parent );
    break;
  default:
    app->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) );
    break;
  }
  if ( aDlg )
    aDlg->show();
  
  return true;
}
bool EntityGUI::OnMouseMove ( QMouseEvent *  pe,
SUIT_Desktop *  parent,
SUIT_ViewWindow *  theViewWindow 
)

Definition at line 232 of file EntityGUI.cxx.

{
  QDialog* aDlg = getGeometryGUI()->GetActiveDialogBox();
  
  if ( aDlg && QString( aDlg->metaObject()->className() ).compare( "EntityGUI_SketcherDlg" ) == 0 &&
       theViewWindow->getViewManager()->getType() == OCCViewer_Viewer::Type() ) 
  { 
    EntityGUI_SketcherDlg* aSketcherDlg = (EntityGUI_SketcherDlg*) aDlg;
    if ( aSketcherDlg->acceptMouseEvent() ) 
    {    
      OCCViewer_ViewPort3d* vp =  ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort();
      gp_Pnt aPnt = ConvertClickToPoint( pe->x(), pe->y(), vp->getView() );
  
      Qt::KeyboardModifiers modifiers = pe->modifiers();
      if (QApplication::mouseButtons() == Qt::LeftButton )
        aSketcherDlg->OnPointSelected( modifiers, aPnt, false );  // "feed" the point to point construction dialog
    }
  }
    
  return false;
}

Here is the call graph for this function:

bool EntityGUI::OnMousePress ( QMouseEvent *  pe,
SUIT_Desktop *  parent,
SUIT_ViewWindow *  theViewWindow 
)

Definition at line 121 of file EntityGUI.cxx.

{
  QDialog* aDlg = getGeometryGUI()->GetActiveDialogBox();

  // Create Point dialog, OCC viewer 
  if ( aDlg && 
       theViewWindow->getViewManager()->getType() == OCCViewer_Viewer::Type() &&
       pe->modifiers() != Qt::ControlModifier ) {
    
    gp_Pnt aPnt;
  
    if ( QString( aDlg->metaObject()->className() ).compare( "EntityGUI_SketcherDlg" ) == 0 ) 
    { 
      EntityGUI_SketcherDlg* aSketcherDlg = (EntityGUI_SketcherDlg*) aDlg;
      ((OCCViewer_ViewWindow*)theViewWindow)->setSketcherStyle(true);
      if ( aSketcherDlg->acceptMouseEvent() ) {
        OCCViewer_Viewer* anOCCViewer =
          ( (OCCViewer_ViewManager*)( theViewWindow->getViewManager() ) )->getOCCViewer();
        Handle(AIS_InteractiveContext) ic = anOCCViewer->getAISContext();
    
        ic->InitSelected();
        if ( pe->modifiers() == Qt::ShiftModifier )
          ic->ShiftSelect();  // Append selection
        else
          ic->Select();       // New selection

        ic->InitSelected();
        if ( ic->MoreSelected() ) {
          TopoDS_Shape aShape = ic->SelectedShape();
          if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX )
            aPnt = BRep_Tool::Pnt( TopoDS::Vertex( ic->SelectedShape() ) );
        }
        else {
          OCCViewer_ViewPort3d* vp =  ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort();
          aPnt = ConvertClickToPoint( pe->x(), pe->y(), vp->getView() );
        }
        
        Qt::KeyboardModifiers modifiers = pe->modifiers();
        aSketcherDlg->OnPointSelected( modifiers, aPnt );  // "feed" the point to point construction dialog
      } // acceptMouseEvent()
    }
#ifdef WITH_OPENCV
    if (  QString( aDlg->metaObject()->className() ).compare( "EntityGUI_FeatureDetectorDlg" ) == 0 ) 
    {
      EntityGUI_FeatureDetectorDlg* aCornerDlg = (EntityGUI_FeatureDetectorDlg*) aDlg;
      if ( aCornerDlg->acceptMouseEvent() ) {
        OCCViewer_Viewer* anOCCViewer =
          ( (OCCViewer_ViewManager*)( theViewWindow->getViewManager() ) )->getOCCViewer();
        Handle(AIS_InteractiveContext) ic = anOCCViewer->getAISContext();   

        ic->InitSelected();
        ic->Select();       // New selection

        ic->InitSelected();
        TopoDS_Shape aShape;
        if ( ic->MoreSelected() ) 
          aShape = ic->SelectedShape();
        if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX )
            aPnt = BRep_Tool::Pnt( TopoDS::Vertex( ic->SelectedShape() ) );
        else 
        {
          OCCViewer_ViewPort3d* vp =  ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort();
          aPnt = ConvertClickToPoint( pe->x(), pe->y(), vp->getView() );
        }
        
//         aCornerDlg->OnPointSelected( aPnt );  // "feed" the point to corner detection dialog
        
//         QPoint start = QPoint(pe->x(),pe->y());
        aCornerDlg->setStartPnt( aPnt );
      } // acceptMouseEvent()
      
    }
#endif
  }

  return false;
}

Here is the call graph for this function:

bool EntityGUI::OnMouseRelease ( QMouseEvent *  pe,
SUIT_Desktop *  parent,
SUIT_ViewWindow *  theViewWindow 
)

Definition at line 203 of file EntityGUI.cxx.

{
  ((OCCViewer_ViewWindow*)theViewWindow)->setSketcherStyle(false);
  QDialog* aDlg = getGeometryGUI()->GetActiveDialogBox();
#ifdef WITH_OPENCV
  if ( aDlg && ( QString( aDlg->metaObject()->className() ).compare( "EntityGUI_FeatureDetectorDlg" ) == 0 ) &&
       theViewWindow->getViewManager()->getType() == OCCViewer_Viewer::Type() &&
       pe->modifiers() != Qt::ControlModifier ) 
  {   
    EntityGUI_FeatureDetectorDlg* aCornerDlg = (EntityGUI_FeatureDetectorDlg*) aDlg;
   
    gp_Pnt aPnt; 
      
    if ( aCornerDlg->acceptMouseEvent() )
    {
//       QPoint end = QPoint(pe->x(),pe->y());
      OCCViewer_ViewPort3d* vp =  ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort();
      aPnt = ConvertClickToPoint( pe->x(), pe->y(), vp->getView() );
      aCornerDlg->setEndPnt( aPnt );
    }    
  }
#endif
  return false;
}

Here is the call graph for this function:

bool EntityGUI::SObjectExist ( const _PTR(SObject)&  theFatherObject,
const char *  IOR 
)

Definition at line 368 of file EntityGUI.cxx.

{
  SalomeApp_Application* app = getGeometryGUI()->getApp();
  if ( !app ) return false;
  SalomeApp_Study* appStudy = dynamic_cast<SalomeApp_Study*>( app->activeStudy() );
  if ( !appStudy ) return false;

  _PTR(Study) aStudy = appStudy->studyDS();
  _PTR(ChildIterator) it ( aStudy->NewChildIterator( theFatherObject ) );
  _PTR(SObject) RefSO;
  _PTR(GenericAttribute) anAttr;
  for ( ; it->More();it->Next() ) {
    _PTR(SObject) SO ( it->Value() );
    if ( SO->FindAttribute( anAttr, "AttributeIOR" ) ) {
      _PTR(AttributeIOR) anIOR ( anAttr  );
      if ( strcmp( anIOR->Value().c_str(), IOR ) == 0 )
        return true;
    }
    if ( SO->ReferencedObject( RefSO ) ) {
      if ( RefSO->FindAttribute( anAttr, "AttributeIOR" ) ) {
        _PTR(AttributeIOR) anIOR ( anAttr );
        if ( strcmp( anIOR->Value().c_str(), IOR ) == 0 )
          return true;
      }
    }
  }
  return false;
}

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