mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-22 17:50:33 +05:00
rnc: In the frame of the feature EDF 1900, made possible to define a point by clicking in the 3D view when using the Sketcher
This commit is contained in:
parent
07682aac19
commit
66a0b44a07
@ -29,14 +29,23 @@
|
|||||||
#include <GeometryGUI.h>
|
#include <GeometryGUI.h>
|
||||||
#include "GeometryGUI_Operations.h"
|
#include "GeometryGUI_Operations.h"
|
||||||
|
|
||||||
|
#include <SUIT_Session.h>
|
||||||
#include <SUIT_Desktop.h>
|
#include <SUIT_Desktop.h>
|
||||||
#include <SUIT_ViewWindow.h>
|
#include <SUIT_ViewWindow.h>
|
||||||
#include <OCCViewer_ViewModel.h>
|
#include <OCCViewer_ViewModel.h>
|
||||||
#include <OCCViewer_ViewManager.h>
|
#include <OCCViewer_ViewManager.h>
|
||||||
|
#include <OCCViewer_ViewWindow.h>
|
||||||
|
#include <OCCViewer_ViewPort3d.h>
|
||||||
#include <SalomeApp_Study.h>
|
#include <SalomeApp_Study.h>
|
||||||
#include <SalomeApp_Application.h>
|
#include <SalomeApp_Application.h>
|
||||||
|
|
||||||
#include <TopoDS_Shape.hxx>
|
#include <TopoDS_Shape.hxx>
|
||||||
|
#include <TopoDS.hxx>
|
||||||
|
#include <BRep_Tool.hxx>
|
||||||
|
#include <ProjLib.hxx>
|
||||||
|
#include <ElSLib.hxx>
|
||||||
|
|
||||||
|
#include <QMouseEvent>
|
||||||
|
|
||||||
#include "EntityGUI_SketcherDlg.h" // Sketcher
|
#include "EntityGUI_SketcherDlg.h" // Sketcher
|
||||||
#include "EntityGUI_3DSketcherDlg.h" // Sketcher
|
#include "EntityGUI_3DSketcherDlg.h" // Sketcher
|
||||||
@ -94,6 +103,77 @@ bool EntityGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent )
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//=================================================================================
|
||||||
|
// function : 0nMousePress()
|
||||||
|
// purpose : [static] manage mouse events
|
||||||
|
//=================================================================================
|
||||||
|
bool EntityGUI::OnMousePress( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWindow* theViewWindow )
|
||||||
|
{
|
||||||
|
MESSAGE("EntityGUI::OnMousePress")
|
||||||
|
QDialog* aDlg = getGeometryGUI()->GetActiveDialogBox();
|
||||||
|
|
||||||
|
// Create Point dialog, OCC viewer
|
||||||
|
if ( aDlg && ( QString( aDlg->metaObject()->className() ).compare( "EntityGUI_SketcherDlg" ) == 0 ) &&
|
||||||
|
theViewWindow->getViewManager()->getType() == OCCViewer_Viewer::Type() &&
|
||||||
|
pe->modifiers() != Qt::ControlModifier ) {
|
||||||
|
MESSAGE("Premier if ok!")
|
||||||
|
EntityGUI_SketcherDlg* aPntDlg = (EntityGUI_SketcherDlg*) aDlg;
|
||||||
|
if ( aPntDlg->acceptMouseEvent() ) {
|
||||||
|
OCCViewer_Viewer* anOCCViewer =
|
||||||
|
( (OCCViewer_ViewManager*)( theViewWindow->getViewManager() ) )->getOCCViewer();
|
||||||
|
Handle(AIS_InteractiveContext) ic = anOCCViewer->getAISContext();
|
||||||
|
|
||||||
|
gp_Pnt aPnt;
|
||||||
|
|
||||||
|
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();
|
||||||
|
aPntDlg->OnPointSelected( modifiers, aPnt ); // "feed" the point to point construction dialog
|
||||||
|
} // acceptMouseEvent()
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=======================================================================
|
||||||
|
// function : ConvertClickToPoint()
|
||||||
|
// purpose : Returns the point clicked in 3D view
|
||||||
|
//=======================================================================
|
||||||
|
gp_Pnt EntityGUI::ConvertClickToPoint( int x, int y, Handle(V3d_View) aView )
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
//=====================================================================================
|
//=====================================================================================
|
||||||
// function : DisplaySimulationShape()
|
// function : DisplaySimulationShape()
|
||||||
@ -101,6 +181,7 @@ bool EntityGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent )
|
|||||||
//=====================================================================================
|
//=====================================================================================
|
||||||
void EntityGUI::DisplaySimulationShape( const TopoDS_Shape& S1, const TopoDS_Shape& S2 )
|
void EntityGUI::DisplaySimulationShape( const TopoDS_Shape& S1, const TopoDS_Shape& S2 )
|
||||||
{
|
{
|
||||||
|
MESSAGE("EntityGUI::DisplaySimulationShape")
|
||||||
SalomeApp_Application* app = getGeometryGUI()->getApp();
|
SalomeApp_Application* app = getGeometryGUI()->getApp();
|
||||||
if ( !app ) return;
|
if ( !app ) return;
|
||||||
|
|
||||||
@ -149,6 +230,7 @@ void EntityGUI::DisplaySimulationShape( const TopoDS_Shape& S1, const TopoDS_Sha
|
|||||||
//==================================================================================
|
//==================================================================================
|
||||||
void EntityGUI::EraseSimulationShape()
|
void EntityGUI::EraseSimulationShape()
|
||||||
{
|
{
|
||||||
|
MESSAGE("EntityGUI::EraseSimulationShape")
|
||||||
SalomeApp_Application* app = getGeometryGUI()->getApp();
|
SalomeApp_Application* app = getGeometryGUI()->getApp();
|
||||||
if ( !app ) return;
|
if ( !app ) return;
|
||||||
|
|
||||||
|
@ -32,9 +32,11 @@
|
|||||||
#include <SALOMEDSClient.hxx>
|
#include <SALOMEDSClient.hxx>
|
||||||
|
|
||||||
#include <AIS_Shape.hxx>
|
#include <AIS_Shape.hxx>
|
||||||
|
#include <V3d_View.hxx>
|
||||||
|
|
||||||
class TopoDS_Shape;
|
class TopoDS_Shape;
|
||||||
|
|
||||||
|
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
// class : EntityGUI
|
// class : EntityGUI
|
||||||
// purpose :
|
// purpose :
|
||||||
@ -46,6 +48,9 @@ public :
|
|||||||
~EntityGUI();
|
~EntityGUI();
|
||||||
|
|
||||||
bool OnGUIEvent( int, SUIT_Desktop* );
|
bool OnGUIEvent( int, SUIT_Desktop* );
|
||||||
|
bool OnMousePress( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWindow* theViewWindow );
|
||||||
|
|
||||||
|
gp_Pnt ConvertClickToPoint( int x, int y, Handle(V3d_View) aView );
|
||||||
|
|
||||||
void DisplaySimulationShape( const TopoDS_Shape&, const TopoDS_Shape& );
|
void DisplaySimulationShape( const TopoDS_Shape&, const TopoDS_Shape& );
|
||||||
void EraseSimulationShape();
|
void EraseSimulationShape();
|
||||||
@ -57,6 +62,7 @@ public:
|
|||||||
// AIS shape used only during topo/geom simulations
|
// AIS shape used only during topo/geom simulations
|
||||||
Handle(AIS_Shape) mySimulationShape1;
|
Handle(AIS_Shape) mySimulationShape1;
|
||||||
Handle(AIS_Shape) mySimulationShape2;
|
Handle(AIS_Shape) mySimulationShape2;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ENTITYGUI_H
|
#endif // ENTITYGUI_H
|
||||||
|
@ -1154,6 +1154,7 @@ void EntityGUI_SketcherDlg::setEnabledRedo( bool value )
|
|||||||
//=================================================================================
|
//=================================================================================
|
||||||
void EntityGUI_SketcherDlg::SelectionIntoArgument()
|
void EntityGUI_SketcherDlg::SelectionIntoArgument()
|
||||||
{
|
{
|
||||||
|
MESSAGE("EntityGUI_SketcherDlg::SelectionIntoArgument")
|
||||||
myEditCurrentArgument->setText( "" );
|
myEditCurrentArgument->setText( "" );
|
||||||
double tmpX = myX;
|
double tmpX = myX;
|
||||||
double tmpY = myY;
|
double tmpY = myY;
|
||||||
@ -1171,6 +1172,11 @@ void EntityGUI_SketcherDlg::SelectionIntoArgument()
|
|||||||
aSelMgr->selectedObjects(aSelList);
|
aSelMgr->selectedObjects(aSelList);
|
||||||
|
|
||||||
int nbSel = aSelList.Extent();
|
int nbSel = aSelList.Extent();
|
||||||
|
MESSAGE("NbSel = "<<nbSel)
|
||||||
|
if (nbSel == 0){
|
||||||
|
myX=tmpX;
|
||||||
|
myY=tmpY;
|
||||||
|
}
|
||||||
if (nbSel == 1 && myEditCurrentArgument == Group1Sel->LineEdit1) {
|
if (nbSel == 1 && myEditCurrentArgument == Group1Sel->LineEdit1) {
|
||||||
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
|
GEOM::GEOM_Object_var aSelectedObject = GEOMBase::ConvertIOinGEOMObject( aSelList.First() );
|
||||||
if ( !CORBA::is_nil(aSelectedObject) ) {
|
if ( !CORBA::is_nil(aSelectedObject) ) {
|
||||||
@ -1489,12 +1495,42 @@ void EntityGUI_SketcherDlg::enterEvent( QEvent* )
|
|||||||
//=================================================================================
|
//=================================================================================
|
||||||
void EntityGUI_SketcherDlg::closeEvent( QCloseEvent* e )
|
void EntityGUI_SketcherDlg::closeEvent( QCloseEvent* e )
|
||||||
{
|
{
|
||||||
|
MESSAGE("EntityGUI_SketcherDlg::closeEvent")
|
||||||
//myGeometryGUI->SetState( -1 );
|
//myGeometryGUI->SetState( -1 );
|
||||||
disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
|
disconnect( myGeometryGUI->getApp()->selectionMgr(), 0, this, 0 );
|
||||||
myGeometryGUI->getApp()->updateActions();
|
myGeometryGUI->getApp()->updateActions();
|
||||||
QDialog::closeEvent( e );
|
QDialog::closeEvent( e );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//rnc TODO
|
||||||
|
//=================================================================================
|
||||||
|
// function : OnPointSelected
|
||||||
|
// purpose :
|
||||||
|
//=================================================================================
|
||||||
|
void EntityGUI_SketcherDlg::OnPointSelected(Qt::KeyboardModifiers modifiers, const gp_Pnt& thePnt)
|
||||||
|
{
|
||||||
|
MESSAGE("EntityGUI_SketcherDlg::OnPointSelected")
|
||||||
|
switch (getPnt2ConstructorId()){
|
||||||
|
case 1:
|
||||||
|
Group2Spin->SpinBox_DX->setValue( thePnt.X() );
|
||||||
|
Group2Spin->SpinBox_DY->setValue( thePnt.Y() );
|
||||||
|
break;
|
||||||
|
case 0:
|
||||||
|
Group3Spin->SpinBox_DX->setValue( thePnt.X() );
|
||||||
|
Group3Spin->SpinBox_DY->setValue( thePnt.Y() );
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
if (modifiers == Qt::MetaModifier){ // Select center with Meta key
|
||||||
|
Group4Spin->SpinBox_DX->setValue( thePnt.X() );
|
||||||
|
Group4Spin->SpinBox_DY->setValue( thePnt.Y() );
|
||||||
|
}
|
||||||
|
else{ // The select end point
|
||||||
|
Group4Spin->SpinBox_DZ->setValue( thePnt.X() );
|
||||||
|
Group4Spin->SpinBox_DS->setValue( thePnt.Y() );
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
// function : ValueChangedInSpinBox()
|
// function : ValueChangedInSpinBox()
|
||||||
@ -1502,9 +1538,10 @@ void EntityGUI_SketcherDlg::closeEvent( QCloseEvent* e )
|
|||||||
//=================================================================================
|
//=================================================================================
|
||||||
void EntityGUI_SketcherDlg::ValueChangedInSpinBox( double newValue )
|
void EntityGUI_SketcherDlg::ValueChangedInSpinBox( double newValue )
|
||||||
{
|
{
|
||||||
|
MESSAGE("EntityGUI_SketcherDlg::ValueChangedInSpinBox")
|
||||||
QObject* send = (QObject*)sender();
|
QObject* send = (QObject*)sender();
|
||||||
Standard_Real vx, vy, vz, vs, minRad;
|
Standard_Real vx, vy, vz, vs, minRad, dx, dy;
|
||||||
vx = vy = vz = vs = minRad =0.0;
|
vx = vy = vz = vs = minRad = dx = dy = 0.0;
|
||||||
|
|
||||||
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
|
SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
|
||||||
int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
|
int aPrecision = resMgr->integerValue( "Geometry", "length_precision", 6 );
|
||||||
@ -1535,7 +1572,15 @@ void EntityGUI_SketcherDlg::ValueChangedInSpinBox( double newValue )
|
|||||||
vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
|
vy = Group3Spin->SpinBox_DY->value(); vyStr = Group3Spin->SpinBox_DY->text();
|
||||||
vz = Group3Spin->SpinBox_DZ->value();
|
vz = Group3Spin->SpinBox_DZ->value();
|
||||||
if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0) ) {
|
if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0) ) {
|
||||||
minRad = 0.5 * Sqrt(vx * vx + vy * vy); //Computation of the minimum acceptable radius for the arc calculation
|
if (mySketchType == PT_ABS_RADIUS){
|
||||||
|
dx = vx - myLastX1;
|
||||||
|
dy = vy - myLastY1;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
dx = vx;
|
||||||
|
dy = vy;
|
||||||
|
}
|
||||||
|
minRad = 0.5 * Sqrt(dx * dx + dy * dy); //Computation of the minimum acceptable radius for the arc calculation
|
||||||
if (aPrecision >= 0) // 'f' format in the QString
|
if (aPrecision >= 0) // 'f' format in the QString
|
||||||
LastDecimal = aPrecision;
|
LastDecimal = aPrecision;
|
||||||
else // 'g' format in the Qstring
|
else // 'g' format in the Qstring
|
||||||
@ -1555,7 +1600,15 @@ void EntityGUI_SketcherDlg::ValueChangedInSpinBox( double newValue )
|
|||||||
vy = newValue; vyStr = newValueStr;
|
vy = newValue; vyStr = newValueStr;
|
||||||
vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
|
vz = Group3Spin->SpinBox_DZ->value(); vzStr = Group3Spin->SpinBox_DZ->text();
|
||||||
if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0)){
|
if ( (mySketchType == PT_REL_RADIUS || mySketchType == PT_ABS_RADIUS) && (vx != 0 || vy != 0)){
|
||||||
minRad = 0.5 * Sqrt(vx * vx + vy * vy); //Computation of the minimum acceptable radius for the arc calculation
|
if (mySketchType == PT_ABS_RADIUS){
|
||||||
|
dx = vx - myLastX1;
|
||||||
|
dy = vy - myLastY1;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
dx = vx;
|
||||||
|
dy = vy;
|
||||||
|
}
|
||||||
|
minRad = 0.5 * Sqrt(dx * dx + dy * dy); //Computation of the minimum acceptable radius for the arc calculation
|
||||||
if (aPrecision >= 0) // 'f' format in the QString
|
if (aPrecision >= 0) // 'f' format in the QString
|
||||||
LastDecimal = aPrecision;
|
LastDecimal = aPrecision;
|
||||||
else // 'g' format in the QString
|
else // 'g' format in the QString
|
||||||
@ -2366,6 +2419,29 @@ void EntityGUI_SketcherDlg::FindLocalCS()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//rnc TODO
|
||||||
|
//=================================================================================
|
||||||
|
// function : getPnt1ConstructorId()
|
||||||
|
// purpose :
|
||||||
|
//=================================================================================
|
||||||
|
int EntityGUI_SketcherDlg::getPnt1ConstructorId() const
|
||||||
|
{
|
||||||
|
int buttonId = GroupPt->ButtonGroup->checkedId();
|
||||||
|
MESSAGE("buttonId = "<<buttonId)
|
||||||
|
return buttonId;
|
||||||
|
}
|
||||||
|
|
||||||
|
//=================================================================================
|
||||||
|
// function : getPnt2ConstructorId()
|
||||||
|
// purpose :
|
||||||
|
//=================================================================================
|
||||||
|
int EntityGUI_SketcherDlg::getPnt2ConstructorId() const
|
||||||
|
{
|
||||||
|
int buttonId = GroupPt2->ButtonGroup->checkedId();
|
||||||
|
MESSAGE("buttonId = "<<buttonId)
|
||||||
|
return buttonId;
|
||||||
|
}
|
||||||
|
|
||||||
//=================================================================================
|
//=================================================================================
|
||||||
// function : GetActiveLocalCS()
|
// function : GetActiveLocalCS()
|
||||||
// purpose : Get Working plane
|
// purpose : Get Working plane
|
||||||
|
@ -73,6 +73,9 @@ public:
|
|||||||
|
|
||||||
bool eventFilter (QObject* object, QEvent* event);
|
bool eventFilter (QObject* object, QEvent* event);
|
||||||
|
|
||||||
|
bool acceptMouseEvent() const { return ( getPnt1ConstructorId() == 1 ); } //accept mouse event only on absolute selection mode
|
||||||
|
void OnPointSelected( Qt::KeyboardModifiers, const gp_Pnt& ); // called by EntityGUI::OnMousePress()
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void initSpinBox( SalomeApp_DoubleSpinBox*,
|
void initSpinBox( SalomeApp_DoubleSpinBox*,
|
||||||
double, double, double = 0.1,
|
double, double, double = 0.1,
|
||||||
@ -106,6 +109,8 @@ private:
|
|||||||
bool createShapes( GEOM::GEOM_Object_ptr,
|
bool createShapes( GEOM::GEOM_Object_ptr,
|
||||||
TopoDS_Shape&,
|
TopoDS_Shape&,
|
||||||
TopoDS_Shape& );
|
TopoDS_Shape& );
|
||||||
|
int getPnt1ConstructorId() const;
|
||||||
|
int getPnt2ConstructorId() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int myConstructorId;
|
int myConstructorId;
|
||||||
@ -168,6 +173,8 @@ private:
|
|||||||
|
|
||||||
int myCheckFlag;
|
int myCheckFlag;
|
||||||
|
|
||||||
|
TopAbs_ShapeEnum myNeedType;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum SketchState { FIRST_POINT, NEXT_POINT };
|
enum SketchState { FIRST_POINT, NEXT_POINT };
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user