geom/src/BasicGUI/BasicGUI.cxx

182 lines
6.2 KiB
C++
Raw Normal View History

2020-04-15 18:11:00 +05:00
// Copyright (C) 2007-2020 CEA/DEN, EDF R&D, OPEN CASCADE
2004-01-07 20:46:21 +05:00
//
2012-08-09 13:58:02 +06:00
// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
//
2012-08-09 13:58:02 +06:00
// 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
2014-02-18 12:44:41 +06:00
// version 2.1 of the License, or (at your option) any later version.
//
2012-08-09 13:58:02 +06:00
// 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.
//
2012-08-09 13:58:02 +06:00
// 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
//
2012-08-09 13:58:02 +06:00
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
2004-01-07 20:46:21 +05:00
//
2012-08-09 13:58:02 +06:00
2009-02-13 17:16:39 +05:00
// GEOM GEOMGUI : GUI for Geometry component
// File : BasicGUI.cxx
// Author : Damien COQUERET, Open CASCADE S.A.S.
2004-01-07 20:46:21 +05:00
//
#include "BasicGUI.h"
#include "BasicGUI_PointDlg.h" // Method POINT
#include "BasicGUI_LineDlg.h" // Method LINE
#include "BasicGUI_CircleDlg.h" // Method CIRCLE
#include "BasicGUI_EllipseDlg.h" // Method ELLIPSE
#include "BasicGUI_ArcDlg.h" // Method ARC
2004-12-01 15:39:14 +05:00
#include "BasicGUI_CurveDlg.h" // Method CURVE
2004-01-07 20:46:21 +05:00
#include "BasicGUI_VectorDlg.h" // Method VECTOR
#include "BasicGUI_PlaneDlg.h" // Method PLANE
2012-08-09 13:58:02 +06:00
#include "BasicGUI_MarkerDlg.h" // Method LOCAL COORDINATE SYSTEM
2004-12-01 15:39:14 +05:00
2013-10-30 22:50:50 +06:00
#include "GeometryGUI.h"
2012-08-09 13:58:02 +06:00
#include "GeometryGUI_Operations.h"
2013-10-30 22:50:50 +06:00
#include "GEOMUtils.hxx"
2009-02-13 17:16:39 +05:00
#include <SUIT_Session.h>
#include <SUIT_Desktop.h>
#include <SUIT_ViewWindow.h>
#include <OCCViewer_ViewWindow.h>
#include <OCCViewer_ViewModel.h>
#include <OCCViewer_ViewManager.h>
#include <OCCViewer_ViewPort3d.h>
#include <BRep_Tool.hxx>
#include <ProjLib.hxx>
#include <ElSLib.hxx>
#include <TopoDS.hxx>
#include <QMouseEvent>
2005-08-19 17:51:38 +06:00
2004-01-07 20:46:21 +05:00
//=======================================================================
// function : BasicGUI()
// purpose : Constructor
//=======================================================================
2009-02-13 17:16:39 +05:00
BasicGUI::BasicGUI( GeometryGUI* parent )
: GEOMGUI( parent )
2004-01-07 20:46:21 +05:00
{
}
//=======================================================================
// function : ~BasicGUI()
// purpose : Destructor
//=======================================================================
BasicGUI::~BasicGUI()
{
}
//=======================================================================
// function : OnGUIEvent()
// purpose :
//=======================================================================
2009-02-13 17:16:39 +05:00
bool BasicGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent )
2004-01-07 20:46:21 +05:00
{
getGeometryGUI()->EmitSignalDeactivateDialog();
2004-12-01 15:39:14 +05:00
QDialog* aDlg = NULL;
2004-01-07 20:46:21 +05:00
2009-02-13 17:16:39 +05:00
switch ( theCommandID ) {
2012-08-09 13:58:02 +06:00
case GEOMOp::OpPoint: // POINT
2009-02-13 17:16:39 +05:00
aDlg = new BasicGUI_PointDlg( getGeometryGUI(), parent );
break;
2012-08-09 13:58:02 +06:00
case GEOMOp::OpLine: // LINE
2009-02-13 17:16:39 +05:00
aDlg = new BasicGUI_LineDlg( getGeometryGUI(), parent );
break;
2012-08-09 13:58:02 +06:00
case GEOMOp::OpCircle: // CIRCLE
2009-02-13 17:16:39 +05:00
aDlg = new BasicGUI_CircleDlg( getGeometryGUI(), parent );
break;
2012-08-09 13:58:02 +06:00
case GEOMOp::OpEllipse: // ELLIPSE
2009-02-13 17:16:39 +05:00
aDlg = new BasicGUI_EllipseDlg( getGeometryGUI(), parent );
break;
2012-08-09 13:58:02 +06:00
case GEOMOp::OpArc: // ARC
2009-02-13 17:16:39 +05:00
aDlg = new BasicGUI_ArcDlg( getGeometryGUI(), parent );
break ;
2012-08-09 13:58:02 +06:00
case GEOMOp::OpVector: // VECTOR
2009-02-13 17:16:39 +05:00
aDlg = new BasicGUI_VectorDlg( getGeometryGUI(), parent );
break;
2012-08-09 13:58:02 +06:00
case GEOMOp::OpPlane: // PLANE
2009-02-13 17:16:39 +05:00
aDlg = new BasicGUI_PlaneDlg( getGeometryGUI(), parent );
break;
2012-08-09 13:58:02 +06:00
case GEOMOp::OpCurve: // CURVE
2009-02-13 17:16:39 +05:00
aDlg = new BasicGUI_CurveDlg( getGeometryGUI(), parent );
break;
2012-08-09 13:58:02 +06:00
case GEOMOp::OpLCS: // LOCAL COORDINATE SYSTEM
2009-02-13 17:16:39 +05:00
aDlg = new BasicGUI_MarkerDlg( getGeometryGUI(), parent );
break;
default:
SUIT_Session::session()->activeApplication()->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) );
break;
}
2004-12-01 15:39:14 +05:00
if ( aDlg != NULL )
aDlg->show();
2009-02-13 17:16:39 +05:00
2004-01-07 20:46:21 +05:00
return true;
}
//=================================================================================
// function : 0nMousePress()
// purpose : [static] manage mouse events
//=================================================================================
2020-08-19 12:06:02 +05:00
bool BasicGUI::OnMousePress( QMouseEvent* pe, SUIT_Desktop* /*parent*/, SUIT_ViewWindow* theViewWindow )
2004-01-07 20:46:21 +05:00
{
QDialog* aDlg = getGeometryGUI()->GetActiveDialogBox();
2004-12-01 15:39:14 +05:00
// Create Point dialog, OCC viewer
2009-02-13 17:16:39 +05:00
if ( aDlg && ( QString( aDlg->metaObject()->className() ).compare( "BasicGUI_PointDlg" ) == 0 ) &&
theViewWindow->getViewManager()->getType() == OCCViewer_Viewer::Type() &&
2009-02-13 17:16:39 +05:00
pe->modifiers() != Qt::ControlModifier ) {
2004-12-01 15:39:14 +05:00
BasicGUI_PointDlg* aPntDlg = (BasicGUI_PointDlg*) aDlg;
2009-02-13 17:16:39 +05:00
if ( aPntDlg->acceptMouseEvent() ) {
OCCViewer_Viewer* anOCCViewer =
2009-02-13 17:16:39 +05:00
( (OCCViewer_ViewManager*)( theViewWindow->getViewManager() ) )->getOCCViewer();
Handle(AIS_InteractiveContext) ic = anOCCViewer->getAISContext();
gp_Pnt aPnt;
ic->InitSelected();
2009-02-13 17:16:39 +05:00
if ( pe->modifiers() == Qt::ShiftModifier )
2017-02-10 18:38:51 +05:00
ic->ShiftSelect( Standard_True ); // Append selection
else
2017-02-10 18:38:51 +05:00
ic->Select( Standard_True ); // New selection
ic->InitSelected();
2009-02-13 17:16:39 +05:00
if ( ic->MoreSelected() ) {
TopoDS_Shape aShape = ic->SelectedShape();
if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX )
aPnt = BRep_Tool::Pnt( TopoDS::Vertex( ic->SelectedShape() ) );
}
2009-02-13 17:16:39 +05:00
else {
OCCViewer_ViewPort3d* vp = ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort();
2013-10-30 22:50:50 +06:00
aPnt = GEOMUtils::ConvertClickToPoint( pe->x(), pe->y(), vp->getView() );
}
aPntDlg->OnPointSelected( aPnt ); // "feed" the point to point construction dialog
} // acceptMouseEvent()
}
2004-01-07 20:46:21 +05:00
return false;
}
//=====================================================================================
// EXPORTED METHODS
//=====================================================================================
extern "C"
{
2009-02-13 17:16:39 +05:00
#ifdef WIN32
__declspec( dllexport )
#endif
GEOMGUI* GetLibGUI( GeometryGUI* parent )
2004-12-01 15:39:14 +05:00
{
return new BasicGUI( parent );
2004-12-01 15:39:14 +05:00
}
2004-01-07 20:46:21 +05:00
}