mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-26 18:10:35 +05:00
Modify creation of curves: 1) using QDockWidget instead of QDialog; 2) selection of new point coordinates by click in viewer.
This commit is contained in:
parent
18247cdc08
commit
4a99ec5202
@ -38,6 +38,7 @@
|
||||
|
||||
#include <GeometryGUI.h>
|
||||
#include "GeometryGUI_Operations.h"
|
||||
#include <GEOMUtils.hxx>
|
||||
|
||||
#include <SUIT_Session.h>
|
||||
#include <SUIT_Desktop.h>
|
||||
@ -155,7 +156,7 @@ bool BasicGUI::OnMousePress( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWin
|
||||
}
|
||||
else {
|
||||
OCCViewer_ViewPort3d* vp = ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort();
|
||||
aPnt = ConvertClickToPoint( pe->x(), pe->y(), vp->getView() );
|
||||
aPnt = GEOMUtils::ConvertClickToPoint( pe->x(), pe->y(), vp->getView() );
|
||||
}
|
||||
|
||||
aPntDlg->OnPointSelected( aPnt ); // "feed" the point to point construction dialog
|
||||
@ -165,32 +166,6 @@ bool BasicGUI::OnMousePress( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWin
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
// function : ConvertClickToPoint()
|
||||
// purpose : Returns the point clicked in 3D view
|
||||
//=======================================================================
|
||||
gp_Pnt BasicGUI::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;
|
||||
}
|
||||
|
||||
//=====================================================================================
|
||||
// EXPORTED METHODS
|
||||
//=====================================================================================
|
||||
|
@ -28,7 +28,6 @@
|
||||
#define BASICGUI_H
|
||||
|
||||
#include <GEOMGUI.h>
|
||||
#include <V3d_View.hxx>
|
||||
|
||||
//=================================================================================
|
||||
// class : BasicGUI
|
||||
@ -42,8 +41,6 @@ public:
|
||||
|
||||
bool OnGUIEvent( int, SUIT_Desktop* );
|
||||
bool OnMousePress( QMouseEvent*, SUIT_Desktop*, SUIT_ViewWindow* );
|
||||
|
||||
gp_Pnt ConvertClickToPoint( int, int, Handle(V3d_View) );
|
||||
};
|
||||
|
||||
#endif // BASICGUI_H
|
||||
|
@ -101,6 +101,7 @@ libBasicGUI_la_CPPFLAGS = \
|
||||
-I$(srcdir)/../GEOMBase \
|
||||
-I$(srcdir)/../GEOMImpl \
|
||||
-I$(srcdir)/../GEOMClient \
|
||||
-I$(srcdir)/../GEOMUtils \
|
||||
-I$(top_builddir)/src/DlgRef \
|
||||
-I$(top_builddir)/idl
|
||||
|
||||
@ -109,6 +110,7 @@ libBasicGUI_la_LDFLAGS = \
|
||||
../GEOMFiltersSelection/libGEOMFiltersSelection.la \
|
||||
../GEOMBase/libGEOMBase.la \
|
||||
../GEOMGUI/libGEOM.la \
|
||||
../GEOMUtils/libGEOMUtils.la \
|
||||
$(CAS_LDFLAGS) -lTKGeomBase \
|
||||
$(GUI_LDFLAGS) -lsuit \
|
||||
$(OPENCV_LIBS)
|
||||
$(OPENCV_LIBS)
|
||||
|
@ -11,45 +11,52 @@
|
||||
#include <QLocale>
|
||||
|
||||
CurveCreator_NewPointDlg::CurveCreator_NewPointDlg(CurveCreator::Dimension theDim, QWidget *parent) :
|
||||
QDialog(parent), myX(NULL), myY(NULL), myZ(NULL), myIsEdit(false), myDim(theDim)
|
||||
QWidget(parent), myX(NULL), myY(NULL), myZ(NULL), myIsEdit(false), myDim(theDim)
|
||||
{
|
||||
QGridLayout* aCoordLay = new QGridLayout();
|
||||
|
||||
QString aTitle = QString(tr("ADD_NEW_POINT"));
|
||||
setWindowTitle(aTitle);
|
||||
|
||||
QFrame* aFrame = new QFrame( this );
|
||||
QVBoxLayout* aLayout = new QVBoxLayout( aFrame );
|
||||
|
||||
QFrame* aCoordFrame = new QFrame( aFrame );
|
||||
QGridLayout* aCoordLayout = new QGridLayout( aCoordFrame );
|
||||
|
||||
QLabel* aLbl = new QLabel( tr("X_COORD"), this);
|
||||
myX = new QDoubleSpinBox(this);
|
||||
aCoordLay->addWidget(aLbl, 0, 0);
|
||||
aCoordLay->addWidget(myX, 0, 1 );
|
||||
aCoordLayout->addWidget(aLbl, 0, 0);
|
||||
aCoordLayout->addWidget(myX, 0, 1 );
|
||||
|
||||
aLbl = new QLabel( tr("Y_COORD"), this);
|
||||
myY = new QDoubleSpinBox(this);
|
||||
aCoordLay->addWidget(aLbl, 1, 0 );
|
||||
aCoordLay->addWidget(myY, 1, 1 );
|
||||
aCoordLayout->addWidget(aLbl, 1, 0 );
|
||||
aCoordLayout->addWidget(myY, 1, 1 );
|
||||
|
||||
myZLabel = new QLabel( tr("Z_COORD"), this);
|
||||
myZ = new QDoubleSpinBox(this);
|
||||
aCoordLay->addWidget(myZLabel, 2,0 );
|
||||
aCoordLay->addWidget(myZ, 2,1 );
|
||||
aCoordLayout->addWidget(myZLabel, 2,0 );
|
||||
aCoordLayout->addWidget(myZ, 2,1 );
|
||||
|
||||
if( theDim != CurveCreator::Dim3d ){
|
||||
myZ->hide();
|
||||
myZLabel->hide();
|
||||
}
|
||||
|
||||
myBtnBox = new QDialogButtonBox(this);
|
||||
myAddBtn = myBtnBox->addButton(tr("ADD_BTN"), QDialogButtonBox::AcceptRole );
|
||||
myContBtn = myBtnBox->addButton(tr("ADD_CONTINUE_BTN"), QDialogButtonBox::ResetRole );
|
||||
myBtnBox->addButton(tr("CANCEL"), QDialogButtonBox::RejectRole );
|
||||
myBtnFrame = new QFrame( aFrame );
|
||||
QHBoxLayout* aBtnsLayout = new QHBoxLayout( myBtnFrame );
|
||||
|
||||
myAddBtn = new QPushButton( tr( "ADD_BTN" ), myBtnFrame );
|
||||
myCancelBtn = new QPushButton( tr( "CANCEL" ), myBtnFrame );
|
||||
|
||||
connect( myCancelBtn, SIGNAL( clicked() ), this, SIGNAL( cancelPoint() ) );
|
||||
|
||||
aBtnsLayout->addWidget( myAddBtn );
|
||||
aBtnsLayout->addStretch( 1 );
|
||||
aBtnsLayout->addWidget( myCancelBtn );
|
||||
|
||||
aLayout->addWidget( aCoordFrame, 0 );
|
||||
aLayout->addWidget( myBtnFrame, 1 );
|
||||
|
||||
connect( myBtnBox, SIGNAL(accepted()), this, SLOT(accept()));
|
||||
connect( myBtnBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
connect( myBtnBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(onBtnClicked(QAbstractButton*) ));
|
||||
QVBoxLayout* aMainLay = new QVBoxLayout();
|
||||
aMainLay->addLayout(aCoordLay);
|
||||
aMainLay->addWidget(myBtnBox);
|
||||
setLayout(aMainLay);
|
||||
clear();
|
||||
updateTitle();
|
||||
}
|
||||
@ -64,12 +71,14 @@ void CurveCreator_NewPointDlg::setEditMode( bool isEdit )
|
||||
{
|
||||
myIsEdit = isEdit;
|
||||
if( myIsEdit ){
|
||||
myContBtn->hide();
|
||||
myAddBtn->setText(tr("OK"));
|
||||
myAddBtn->disconnect( SIGNAL( clicked() ) );
|
||||
connect( myAddBtn, SIGNAL( clicked() ), this, SIGNAL( modifyPoint() ) );
|
||||
}
|
||||
else{
|
||||
myContBtn->show();
|
||||
myAddBtn->setText(tr("ADD_BTN"));
|
||||
myAddBtn->disconnect( SIGNAL( clicked() ) );
|
||||
connect( myAddBtn, SIGNAL( clicked() ), this, SIGNAL( addPoint() ) );
|
||||
}
|
||||
updateTitle();
|
||||
}
|
||||
@ -105,13 +114,6 @@ CurveCreator::Coordinates CurveCreator_NewPointDlg::getCoordinates() const
|
||||
return aCoords;
|
||||
}
|
||||
|
||||
void CurveCreator_NewPointDlg::onBtnClicked(QAbstractButton* theBtn )
|
||||
{
|
||||
if( myBtnBox->buttonRole(theBtn) == QDialogButtonBox::ResetRole ){
|
||||
emit addPoint();
|
||||
}
|
||||
}
|
||||
|
||||
void CurveCreator_NewPointDlg::clear()
|
||||
{
|
||||
initSpinBox(myX);
|
||||
|
@ -3,15 +3,16 @@
|
||||
|
||||
#include "CurveCreator.hxx"
|
||||
|
||||
#include <QDialog>
|
||||
#include <QDockWidget>
|
||||
|
||||
class QDoubleSpinBox;
|
||||
class QDialogButtonBox;
|
||||
class QAbstractButton;
|
||||
class QPushButton;
|
||||
class QLabel;
|
||||
class QFrame;
|
||||
|
||||
class CurveCreator_NewPointDlg : public QDialog
|
||||
class CurveCreator_NewPointDlg : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@ -24,21 +25,22 @@ public:
|
||||
void setDimension(CurveCreator::Dimension theDim);
|
||||
signals:
|
||||
void addPoint();
|
||||
void modifyPoint();
|
||||
void cancelPoint();
|
||||
public slots:
|
||||
protected slots:
|
||||
void onBtnClicked(QAbstractButton* theBtn );
|
||||
protected:
|
||||
void updateTitle();
|
||||
void initSpinBox(QDoubleSpinBox *theSpinBox);
|
||||
private:
|
||||
QDialogButtonBox* myBtnBox;
|
||||
QFrame* myBtnFrame;
|
||||
CurveCreator::Dimension myDim;
|
||||
QDoubleSpinBox* myX;
|
||||
QDoubleSpinBox* myY;
|
||||
QDoubleSpinBox* myZ;
|
||||
QLabel* myZLabel;
|
||||
QPushButton* myContBtn;
|
||||
QPushButton* myAddBtn;
|
||||
QPushButton* myCancelBtn;
|
||||
bool myIsEdit;
|
||||
QString mySectionName;
|
||||
};
|
||||
|
@ -13,14 +13,18 @@
|
||||
#include <QPushButton>
|
||||
|
||||
CurveCreator_NewSectionDlg::CurveCreator_NewSectionDlg( QWidget *parent ) :
|
||||
QDialog(parent)
|
||||
QWidget(parent)
|
||||
{
|
||||
std::string aNameStr;
|
||||
QGridLayout* aLay = new QGridLayout();
|
||||
QFrame* aFrame = new QFrame( this );
|
||||
QVBoxLayout* aLayout = new QVBoxLayout( aFrame );
|
||||
|
||||
QFrame* aCoordFrame = new QFrame( aFrame );
|
||||
QGridLayout* aCoordLayout = new QGridLayout( aCoordFrame );
|
||||
|
||||
QLabel* aLbl = new QLabel(tr("NAME"), this);
|
||||
myName = new QLineEdit(this);
|
||||
aLay->addWidget(aLbl, 0, 0);
|
||||
aLay->addWidget(myName, 0 , 1);
|
||||
aCoordLayout->addWidget(aLbl, 0, 0);
|
||||
aCoordLayout->addWidget(myName, 0 , 1);
|
||||
|
||||
aLbl = new QLabel(tr("LINE_TYPE"));
|
||||
myLineType = new QComboBox(this);
|
||||
@ -34,27 +38,29 @@ CurveCreator_NewSectionDlg::CurveCreator_NewSectionDlg( QWidget *parent ) :
|
||||
myLineType->addItem(aPolylinePixmap, tr("POLYLINE_TYPE"));
|
||||
myLineType->addItem(aSplinePixmap, tr("SPLINE_TYPE"));
|
||||
myLineType->setCurrentIndex(0);
|
||||
aLay->addWidget(aLbl, 1, 0);
|
||||
aLay->addWidget(myLineType, 1 , 1);
|
||||
aCoordLayout->addWidget(aLbl, 1, 0);
|
||||
aCoordLayout->addWidget(myLineType, 1 , 1);
|
||||
|
||||
aLbl = new QLabel(tr("LINE_CLOSED"));
|
||||
myIsClosed = new QCheckBox(this);
|
||||
aLay->addWidget(aLbl, 2, 0);
|
||||
aLay->addWidget(myIsClosed, 2, 1);
|
||||
aCoordLayout->addWidget(aLbl, 2, 0);
|
||||
aCoordLayout->addWidget(myIsClosed, 2, 1);
|
||||
|
||||
myBtnBox = new QDialogButtonBox(this);
|
||||
myAddBtn = myBtnBox->addButton(tr("ADD_BTN"), QDialogButtonBox::AcceptRole );
|
||||
myContBtn = myBtnBox->addButton(tr("ADD_CONTINUE_BTN"), QDialogButtonBox::ResetRole );
|
||||
myBtnBox->addButton(tr("CANCEL"), QDialogButtonBox::RejectRole );
|
||||
myBtnFrame = new QFrame( aFrame );
|
||||
QHBoxLayout* aBtnsLayout = new QHBoxLayout( myBtnFrame );
|
||||
|
||||
connect( myBtnBox, SIGNAL(accepted()), this, SLOT(accept()));
|
||||
connect( myBtnBox, SIGNAL(rejected()), this, SLOT(reject()));
|
||||
connect( myBtnBox, SIGNAL(clicked(QAbstractButton*)), this, SLOT(onBtnClicked(QAbstractButton*) ));
|
||||
myAddBtn = new QPushButton( tr( "ADD_BTN" ), myBtnFrame );
|
||||
myCancelBtn = new QPushButton( tr( "CANCEL" ), myBtnFrame );
|
||||
|
||||
QVBoxLayout* aMainLay = new QVBoxLayout();
|
||||
aMainLay->addLayout(aLay);
|
||||
aMainLay->addWidget(myBtnBox);
|
||||
setLayout(aMainLay);
|
||||
connect( myAddBtn, SIGNAL( clicked() ), this, SIGNAL( addSection() ) );
|
||||
connect( myCancelBtn, SIGNAL( clicked() ), this, SIGNAL( cancelSection() ) );
|
||||
|
||||
aBtnsLayout->addWidget( myAddBtn );
|
||||
aBtnsLayout->addStretch( 1 );
|
||||
aBtnsLayout->addWidget( myCancelBtn );
|
||||
|
||||
aLayout->addWidget( aCoordFrame, 0 );
|
||||
aLayout->addWidget( myBtnFrame, 1 );
|
||||
}
|
||||
|
||||
void CurveCreator_NewSectionDlg::setSectionParameters( const QString& theName, bool isClosed, CurveCreator::Type theType )
|
||||
@ -78,12 +84,14 @@ void CurveCreator_NewSectionDlg::setEditMode( bool isEdit )
|
||||
{
|
||||
myIsEdit = isEdit;
|
||||
if( myIsEdit ){
|
||||
myContBtn->hide();
|
||||
myAddBtn->setText(tr("OK"));
|
||||
myAddBtn->disconnect( SIGNAL( clicked() ) );
|
||||
connect( myAddBtn, SIGNAL( clicked() ), this, SIGNAL( modifySection() ) );
|
||||
}
|
||||
else{
|
||||
myContBtn->show();
|
||||
myAddBtn->setText(tr("ADD_BTN"));
|
||||
myAddBtn->disconnect( SIGNAL( clicked() ) );
|
||||
connect( myAddBtn, SIGNAL( clicked() ), this, SIGNAL( addSection() ) );
|
||||
}
|
||||
updateTitle();
|
||||
}
|
||||
@ -120,10 +128,3 @@ void CurveCreator_NewSectionDlg::setSectionName( const QString& theName )
|
||||
{
|
||||
myName->setText(theName);
|
||||
}
|
||||
|
||||
void CurveCreator_NewSectionDlg::onBtnClicked(QAbstractButton* theBtn )
|
||||
{
|
||||
if( myBtnBox->buttonRole(theBtn) == QDialogButtonBox::ResetRole ){
|
||||
emit addSection();
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
|
||||
#include "CurveCreator.hxx"
|
||||
|
||||
#include <QDialog>
|
||||
#include <QDockWidget>
|
||||
|
||||
class CurveCreator_Curve;
|
||||
|
||||
@ -13,8 +13,9 @@ class QCheckBox;
|
||||
class QPushButton;
|
||||
class QAbstractButton;
|
||||
class QDialogButtonBox;
|
||||
class QFrame;
|
||||
|
||||
class CurveCreator_NewSectionDlg : public QDialog
|
||||
class CurveCreator_NewSectionDlg : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
@ -31,19 +32,20 @@ public:
|
||||
|
||||
signals:
|
||||
void addSection();
|
||||
void modifySection();
|
||||
void cancelSection();
|
||||
public slots:
|
||||
protected slots:
|
||||
void onBtnClicked(QAbstractButton* theBtn );
|
||||
protected:
|
||||
void updateTitle();
|
||||
private:
|
||||
QFrame* myBtnFrame;
|
||||
QLineEdit* myName;
|
||||
QComboBox* myLineType;
|
||||
QCheckBox* myIsClosed;
|
||||
bool myIsEdit;
|
||||
QPushButton* myContBtn;
|
||||
QPushButton* myAddBtn;
|
||||
QDialogButtonBox* myBtnBox;
|
||||
QPushButton* myCancelBtn;
|
||||
};
|
||||
|
||||
#endif // CURVECREATOR_NEWSECTION_H
|
||||
|
@ -227,6 +227,7 @@ void CurveCreator_TreeView::pointsAdded( int theSection, int thePoint, int thePo
|
||||
if( aModel ){
|
||||
QModelIndex aSectIndx = aModel->sectionIndex( theSection );
|
||||
rowsInserted(aSectIndx, thePoint, thePoint + thePointsCnt - 1 );
|
||||
expand( aSectIndx );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,14 +1,24 @@
|
||||
#include "CurveCreator_Widget.h"
|
||||
#include "CurveCreator_TreeView.h"
|
||||
#include "QVBoxLayout"
|
||||
#include "CurveCreator_Curve.hxx"
|
||||
#include "CurveCreator_CurveEditor.hxx"
|
||||
#include "CurveCreator.hxx"
|
||||
#include "CurveCreator_NewPointDlg.h"
|
||||
#include "CurveCreator_NewSectionDlg.h"
|
||||
|
||||
#include <GEOMUtils.hxx>
|
||||
#include <GEOMBase_Helper.h>
|
||||
|
||||
#include <SUIT_Session.h>
|
||||
#include <SUIT_ResourceMgr.h>
|
||||
#include <SUIT_ViewManager.h>
|
||||
|
||||
#include <OCCViewer_ViewWindow.h>
|
||||
#include <OCCViewer_ViewManager.h>
|
||||
#include <OCCViewer_ViewPort3d.h>
|
||||
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
|
||||
#include <QHBoxLayout>
|
||||
#include <QVBoxLayout>
|
||||
@ -19,6 +29,7 @@
|
||||
#include <QToolBar>
|
||||
#include <QAction>
|
||||
#include <QMenu>
|
||||
#include <QMouseEvent>
|
||||
|
||||
CurveCreator_Widget::CurveCreator_Widget(QWidget* parent,
|
||||
CurveCreator_Curve *theCurve,
|
||||
@ -28,14 +39,20 @@ CurveCreator_Widget::CurveCreator_Widget(QWidget* parent,
|
||||
if( myCurve )
|
||||
myEdit = new CurveCreator_CurveEditor( myCurve );
|
||||
|
||||
CurveCreator::Dimension aDim = CurveCreator::Dim3d;
|
||||
CurveCreator::Dimension aDim = CurveCreator::Dim2d;
|
||||
if( myCurve )
|
||||
aDim = myCurve->getDimension();
|
||||
myNewPointEditor = new CurveCreator_NewPointDlg(aDim, this);
|
||||
connect( myNewPointEditor, SIGNAL(addPoint()), this, SLOT(onAddNewPoint()));
|
||||
myNewPointEditor = new CurveCreator_NewPointDlg( aDim, this );
|
||||
myNewPointEditor->hide();
|
||||
connect( myNewPointEditor, SIGNAL(addPoint()), this, SLOT(onAddNewPoint()) );
|
||||
connect( myNewPointEditor, SIGNAL(modifyPoint()), this, SLOT(onModifyPoint()) );
|
||||
connect( myNewPointEditor, SIGNAL(cancelPoint()), this, SLOT(onCancelPoint()) );
|
||||
|
||||
myNewSectionEditor = new CurveCreator_NewSectionDlg(this);
|
||||
connect( myNewSectionEditor, SIGNAL(addSection()), this, SLOT(onAddNewSection()));
|
||||
myNewSectionEditor = new CurveCreator_NewSectionDlg( this );
|
||||
myNewSectionEditor->hide();
|
||||
connect( myNewSectionEditor, SIGNAL(addSection()), this, SLOT(onAddNewSection()) );
|
||||
connect( myNewSectionEditor, SIGNAL(modifySection()), this, SLOT(onModifySection()) );
|
||||
connect( myNewSectionEditor, SIGNAL(cancelSection()), this, SLOT(onCancelSection()) );
|
||||
|
||||
QGroupBox* aSectionGroup = new QGroupBox(tr("Sections"),this);
|
||||
|
||||
@ -286,9 +303,16 @@ void CurveCreator_Widget::onNewPoint()
|
||||
myNewPointEditor->setEditMode(false);
|
||||
myNewPointEditor->setSectionName(aSectName);
|
||||
myNewPointEditor->setDimension(myCurve->getDimension());
|
||||
if( myNewPointEditor->exec() == QDialog::Accepted ){
|
||||
onAddNewPoint();
|
||||
|
||||
SUIT_ViewWindow* aViewWindow = GEOMBase_Helper::getActiveView();
|
||||
SUIT_ViewManager* aViewManager = aViewWindow->getViewManager();
|
||||
if ( aViewWindow == 0 )
|
||||
return;
|
||||
if ( aViewManager->getType() == OCCViewer_Viewer::Type() ) {
|
||||
connect( aViewManager, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
|
||||
this, SLOT( onMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) );
|
||||
}
|
||||
emit subOperationStarted( myNewPointEditor );
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onAddNewPoint()
|
||||
@ -298,7 +322,7 @@ void CurveCreator_Widget::onAddNewPoint()
|
||||
CurveCreator::Coordinates aCoords = myNewPointEditor->getCoordinates();
|
||||
myEdit->insertPoints(aCoords, mySection, myPointNum );
|
||||
mySectionView->pointsAdded( mySection, myPointNum );
|
||||
myNewPointEditor->clear();
|
||||
// myNewPointEditor->clear();
|
||||
myPointNum++;
|
||||
onSelectionChanged();
|
||||
updateUndoRedo();
|
||||
@ -312,9 +336,7 @@ void CurveCreator_Widget::onNewSection()
|
||||
myNewSectionEditor->setEditMode(false);
|
||||
QString aSectName = QString( myCurve->getUnicSectionName().c_str() );
|
||||
myNewSectionEditor->setSectionParameters(aSectName, true, CurveCreator::Polyline );
|
||||
if( myNewSectionEditor->exec() == QDialog::Accepted ){
|
||||
onAddNewSection();
|
||||
}
|
||||
emit subOperationStarted( myNewSectionEditor );
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onAddNewSection()
|
||||
@ -330,6 +352,17 @@ void CurveCreator_Widget::onAddNewSection()
|
||||
mySection++;
|
||||
onSelectionChanged();
|
||||
updateUndoRedo();
|
||||
onCancelSection();
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onCancelPoint()
|
||||
{
|
||||
emit subOperationFinished( myNewPointEditor );
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onCancelSection()
|
||||
{
|
||||
emit subOperationFinished( myNewSectionEditor );
|
||||
}
|
||||
|
||||
QAction* CurveCreator_Widget::createAction( ActionId theId, const QString& theName, const QPixmap& theImage,
|
||||
@ -362,38 +395,51 @@ void CurveCreator_Widget::onEditSection( int theSection )
|
||||
CurveCreator::Type aType = myCurve->getType(theSection);
|
||||
myNewSectionEditor->setEditMode(true);
|
||||
myNewSectionEditor->setSectionParameters( aSectName, isClosed, aType );
|
||||
if( myNewSectionEditor->exec() == QDialog::Accepted ){
|
||||
QString aName = myNewSectionEditor->getName();
|
||||
bool isClosed = myNewSectionEditor->isClosed();
|
||||
CurveCreator::Type aSectType = myNewSectionEditor->getSectionType();
|
||||
myEdit->startOperation();
|
||||
myEdit->setClosed( isClosed, mySection );
|
||||
myEdit->setName( aName.toStdString(), mySection );
|
||||
myEdit->setType( aSectType, mySection );
|
||||
myEdit->finishOperation();
|
||||
mySectionView->sectionChanged(mySection);
|
||||
updateUndoRedo();
|
||||
}
|
||||
|
||||
emit subOperationStarted( myNewSectionEditor );
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onModifySection()
|
||||
{
|
||||
if( !myEdit )
|
||||
return;
|
||||
QString aName = myNewSectionEditor->getName();
|
||||
bool isClosed = myNewSectionEditor->isClosed();
|
||||
CurveCreator::Type aSectType = myNewSectionEditor->getSectionType();
|
||||
myEdit->startOperation();
|
||||
myEdit->setClosed( isClosed, mySection );
|
||||
myEdit->setName( aName.toStdString(), mySection );
|
||||
myEdit->setType( aSectType, mySection );
|
||||
myEdit->finishOperation();
|
||||
mySectionView->sectionChanged(mySection);
|
||||
updateUndoRedo();
|
||||
onCancelSection();
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onEditPoint( int theSection, int thePoint )
|
||||
{
|
||||
if( !myNewPointEditor )
|
||||
return;
|
||||
if( !myEdit )
|
||||
if( !myNewPointEditor || !myEdit )
|
||||
return;
|
||||
mySection = theSection;
|
||||
myPointNum = thePoint;
|
||||
QString aSectName = QString::fromStdString( myCurve->getSectionName(theSection));
|
||||
myNewPointEditor->setEditMode(true);
|
||||
myNewPointEditor->setSectionName(aSectName);
|
||||
myNewPointEditor->setDimension( myCurve->getDimension() );
|
||||
CurveCreator::Coordinates aCoords = myCurve->getCoordinates(theSection,thePoint);
|
||||
myNewPointEditor->setCoordinates(aCoords);
|
||||
if( myNewPointEditor->exec() == QDialog::Accepted ){
|
||||
aCoords = myNewPointEditor->getCoordinates();
|
||||
myEdit->setCoordinates(aCoords, theSection, thePoint);
|
||||
mySectionView->pointDataChanged(theSection, thePoint );
|
||||
updateUndoRedo();
|
||||
}
|
||||
emit subOperationStarted( myNewPointEditor );
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onModifyPoint()
|
||||
{
|
||||
if( !myEdit )
|
||||
return;
|
||||
CurveCreator::Coordinates aCoords = myNewPointEditor->getCoordinates();
|
||||
myEdit->setCoordinates( aCoords, mySection, myPointNum );
|
||||
mySectionView->pointDataChanged( mySection, myPointNum );
|
||||
updateUndoRedo();
|
||||
onCancelPoint();
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onJoin()
|
||||
@ -689,3 +735,43 @@ QList< QPair< int, int > > CurveCreator_Widget::getSelectedPoints()
|
||||
{
|
||||
return mySectionView->getSelectedPoints();
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : GeometryGUI::OnMousePress()
|
||||
// purpose : Manage mouse press events [static]
|
||||
//=================================================================================
|
||||
void CurveCreator_Widget::onMousePress( SUIT_ViewWindow* theViewWindow, QMouseEvent* pe )
|
||||
{
|
||||
if ( myNewPointEditor && theViewWindow->getViewManager()->getType() == OCCViewer_Viewer::Type() &&
|
||||
pe->modifiers() != Qt::ControlModifier ) {
|
||||
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 = GEOMUtils::ConvertClickToPoint( pe->x(), pe->y(), vp->getView() );
|
||||
}
|
||||
// set the coordinates into dialog
|
||||
CurveCreator::Coordinates aCoords;
|
||||
aCoords.push_back( aPnt.X() );
|
||||
aCoords.push_back( aPnt.Y() );
|
||||
if ( myCurve->getDimension() == 3 ) {
|
||||
aCoords.push_back( aPnt.Z() );
|
||||
}
|
||||
myNewPointEditor->setCoordinates( aCoords );
|
||||
}
|
||||
}
|
||||
|
@ -4,9 +4,10 @@
|
||||
#include "CurveCreator_Curve.hxx"
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include <QMap>
|
||||
|
||||
#include <SUIT_ViewWindow.h>
|
||||
|
||||
class QAction;
|
||||
class QPixmap;
|
||||
class CurveCreator_CurveEditor;
|
||||
@ -29,6 +30,8 @@ public:
|
||||
|
||||
signals:
|
||||
void selectionChanged();
|
||||
void subOperationStarted( QWidget* );
|
||||
void subOperationFinished( QWidget* );
|
||||
|
||||
public slots:
|
||||
|
||||
@ -40,6 +43,10 @@ protected slots:
|
||||
void onAddNewSection();
|
||||
void onEditSection( int theSection );
|
||||
void onEditPoint( int theSection, int thePoint );
|
||||
void onModifyPoint();
|
||||
void onModifySection();
|
||||
void onCancelPoint();
|
||||
void onCancelSection();
|
||||
void onJoin();
|
||||
void onRemove();
|
||||
void onMoveUp();
|
||||
@ -58,6 +65,7 @@ protected slots:
|
||||
void onRedo();
|
||||
void onUndoSettings();
|
||||
void onContextMenu(QPoint thePoint);
|
||||
void onMousePress( SUIT_ViewWindow*, QMouseEvent* );
|
||||
protected:
|
||||
enum ActionId{ UNDO_ID, REDO_ID, NEW_SECTION_ID, NEW_POINT_ID, REMOVE_ID, REMOVE_ALL_ID, JOIN_ID,
|
||||
JOIN_ALL_ID, UP_ID, DOWN_ID, INSERT_SECTION_BEFORE_ID, INSERT_SECTION_AFTER_ID,
|
||||
|
@ -81,14 +81,26 @@ endif
|
||||
|
||||
# additional information to compile and link file
|
||||
|
||||
libCurveCreator_la_CPPFLAGS = \
|
||||
$(QT_INCLUDES) \
|
||||
$(CAS_CPPFLAGS) \
|
||||
$(KERNEL_CXXFLAGS) \
|
||||
$(GUI_CXXFLAGS)
|
||||
libCurveCreator_la_CPPFLAGS = \
|
||||
$(QT_INCLUDES) \
|
||||
$(CAS_CPPFLAGS) \
|
||||
$(KERNEL_CXXFLAGS) \
|
||||
$(GUI_CXXFLAGS) \
|
||||
$(CORBA_CXXFLAGS) \
|
||||
$(CORBA_INCLUDES) \
|
||||
-I$(srcdir)/../GEOMGUI \
|
||||
-I$(srcdir)/../GEOMUtils \
|
||||
-I$(srcdir)/../GEOMBase \
|
||||
-I$(top_builddir)/idl
|
||||
|
||||
libCurveCreator_la_LDFLAGS = \
|
||||
$(QT_MT_LIBS) \
|
||||
$(CAS_KERNEL) \
|
||||
$(KERNEL_LDFLAGS) \
|
||||
$(GUI_LDFLAGS) -lqtx -lsuit
|
||||
|
||||
libCurveCreator_la_LDFLAGS = \
|
||||
$(QT_MT_LIBS) \
|
||||
$(CAS_KERNEL) \
|
||||
$(CAS_VIEWER) \
|
||||
$(OCCViewer) \
|
||||
$(KERNEL_LDFLAGS) \
|
||||
$(GUI_LDFLAGS) -lqtx -lsuit \
|
||||
../GEOMUtils/libGEOM.la \
|
||||
../GEOMUtils/libGEOMUtils.la \
|
||||
../GEOMUtils/libGEOMBase.la
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
#include <GeometryGUI.h>
|
||||
#include "GeometryGUI_Operations.h"
|
||||
#include <GEOMUtils.hxx>
|
||||
|
||||
#include <SUIT_Session.h>
|
||||
#include <SUIT_Desktop.h>
|
||||
@ -152,7 +153,7 @@ bool EntityGUI::OnMousePress( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWi
|
||||
}
|
||||
else {
|
||||
OCCViewer_ViewPort3d* vp = ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort();
|
||||
aPnt = ConvertClickToPoint( pe->x(), pe->y(), vp->getView() );
|
||||
aPnt = GEOMUtils::ConvertClickToPoint( pe->x(), pe->y(), vp->getView() );
|
||||
}
|
||||
|
||||
Qt::KeyboardModifiers modifiers = pe->modifiers();
|
||||
@ -240,7 +241,7 @@ bool EntityGUI::OnMouseMove( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWin
|
||||
if ( aSketcherDlg->acceptMouseEvent() )
|
||||
{
|
||||
OCCViewer_ViewPort3d* vp = ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort();
|
||||
gp_Pnt aPnt = ConvertClickToPoint( pe->x(), pe->y(), vp->getView() );
|
||||
gp_Pnt aPnt = GEOMUtils::ConvertClickToPoint( pe->x(), pe->y(), vp->getView() );
|
||||
|
||||
Qt::KeyboardModifiers modifiers = pe->modifiers();
|
||||
if (QApplication::mouseButtons() == Qt::LeftButton )
|
||||
@ -251,32 +252,6 @@ bool EntityGUI::OnMouseMove( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWin
|
||||
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()
|
||||
// purpose : Displays 'this->mySimulationShape' a pure graphical shape from a TopoDS_Shape
|
||||
|
@ -32,7 +32,6 @@
|
||||
#include <SALOMEDSClient.hxx>
|
||||
|
||||
#include <AIS_Shape.hxx>
|
||||
#include <V3d_View.hxx>
|
||||
|
||||
class TopoDS_Shape;
|
||||
|
||||
@ -52,8 +51,6 @@ public :
|
||||
bool OnMouseMove( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWindow* theViewWindow );
|
||||
bool OnMouseRelease( QMouseEvent* pe, SUIT_Desktop* parent, SUIT_ViewWindow* theViewWindow );
|
||||
|
||||
static gp_Pnt ConvertClickToPoint( int x, int y, Handle(V3d_View) aView );
|
||||
|
||||
void DisplaySimulationShape( const TopoDS_Shape&, const TopoDS_Shape& );
|
||||
void EraseSimulationShape();
|
||||
|
||||
|
@ -112,6 +112,7 @@ libEntityGUI_la_CPPFLAGS = \
|
||||
-I$(srcdir)/../GEOMImpl \
|
||||
-I$(srcdir)/../GEOMFiltersSelection \
|
||||
-I$(srcdir)/../SKETCHER \
|
||||
-I$(srcdir)/../GEOMUtils \
|
||||
-I$(ShapeRec_dir) \
|
||||
-I$(srcdir)/../GEOM \
|
||||
-I$(top_builddir)/src/DlgRef \
|
||||
@ -123,7 +124,8 @@ libEntityGUI_la_LDFLAGS = \
|
||||
../GEOMBase/libGEOMBase.la \
|
||||
../SKETCHER/libGEOMSketcher.la \
|
||||
../GEOMGUI/libGEOM.la \
|
||||
../GEOMUtils/libGEOMUtils.la \
|
||||
$(ShapeRec_la) \
|
||||
$(QT_MT_LIBS) \
|
||||
$(CAS_TKTopAlgo) -lTKernel \
|
||||
$(Opencv_libs)
|
||||
$(Opencv_libs)
|
||||
|
@ -64,7 +64,7 @@
|
||||
// Function : getActiveView
|
||||
// Purpose : Get active view window, returns 0 if no open study frame
|
||||
//================================================================
|
||||
static SUIT_ViewWindow* getActiveView()
|
||||
SUIT_ViewWindow* GEOMBase_Helper::getActiveView()
|
||||
{
|
||||
SUIT_Study* activeStudy = SUIT_Session::session()->activeApplication()->activeStudy();
|
||||
if ( activeStudy )
|
||||
|
@ -61,6 +61,7 @@ class GEOMBASE_EXPORT GEOMBase_Helper
|
||||
public:
|
||||
GEOMBase_Helper( SUIT_Desktop* );
|
||||
virtual ~GEOMBase_Helper();
|
||||
static SUIT_ViewWindow* getActiveView();
|
||||
|
||||
protected:
|
||||
static GEOM::GEOM_Gen_ptr getGeomEngine();
|
||||
|
@ -72,6 +72,9 @@
|
||||
#include <gp_Pln.hxx>
|
||||
#include <gp_Lin.hxx>
|
||||
|
||||
#include <ProjLib.hxx>
|
||||
#include <ElSLib.hxx>
|
||||
|
||||
#include <vector>
|
||||
|
||||
#include <Standard_Failure.hxx>
|
||||
@ -600,3 +603,29 @@ TopoDS_Shape GEOMUtils::GetEdgeNearPoint (const TopoDS_Shape& theShape,
|
||||
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : ConvertClickToPoint()
|
||||
// purpose : Returns the point clicked in 3D view
|
||||
//=======================================================================
|
||||
gp_Pnt GEOMUtils::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;
|
||||
}
|
||||
|
@ -33,6 +33,8 @@
|
||||
#include <gp_Ax3.hxx>
|
||||
#include <gp_Vec.hxx>
|
||||
|
||||
#include <V3d_View.hxx>
|
||||
|
||||
#include <NCollection_DataMap.hxx>
|
||||
|
||||
#include <functional>
|
||||
@ -132,6 +134,16 @@ class GEOMUtils {
|
||||
Standard_EXPORT static TopoDS_Shape GetEdgeNearPoint (const TopoDS_Shape& theShape,
|
||||
const TopoDS_Vertex& thePoint);
|
||||
|
||||
/*!
|
||||
* \brief Returns the point clicked in 3D view.
|
||||
*
|
||||
* \param x The X coordinate in the view.
|
||||
* \param y The Y coordinate in the view.
|
||||
* \param theView View where the given point takes place.
|
||||
* \retval gp_Pnt Returns the point clicked in 3D view
|
||||
*/
|
||||
Standard_EXPORT static gp_Pnt ConvertClickToPoint( int x, int y, Handle(V3d_View) theView );
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -54,5 +54,5 @@ libGEOMUtils_la_LDFLAGS = \
|
||||
../ARCHIMEDE/libGEOMArchimede.la \
|
||||
../SKETCHER/libGEOMSketcher.la \
|
||||
$(KERNEL_LDFLAGS) -lSALOMELocalTrace -lSALOMEBasics \
|
||||
$(CAS_LDPATH) -lTKCAF -lTKFillet -lTKOffset -lTKFeat \
|
||||
$(CAS_LDPATH) -lTKCAF -lTKFillet -lTKOffset -lTKFeat -lTKV3d \
|
||||
$(STDLIB)
|
||||
|
@ -30,6 +30,8 @@
|
||||
#include <SUIT_Session.h>
|
||||
#include <SUIT_Desktop.h>
|
||||
#include <SalomeApp_Application.h>
|
||||
#include <OCCViewer_ViewWindow.h>
|
||||
#include <SUIT_ViewManager.h>
|
||||
|
||||
#include <TopTools_MapOfShape.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
@ -100,7 +102,11 @@ bool OperationGUI::OnGUIEvent (int theCommandID, SUIT_Desktop* parent)
|
||||
static CurveCreator_Curve *aStaticCurve = NULL;
|
||||
|
||||
if (aStaticCurve == NULL) {
|
||||
aStaticCurve = new CurveCreator_Curve(CurveCreator::Dim3d);
|
||||
aStaticCurve = new CurveCreator_Curve(CurveCreator::Dim2d);
|
||||
}
|
||||
if (CurveCreator::Dim2d == aStaticCurve->getDimension()) {
|
||||
OCCViewer_ViewWindow* vw = (OCCViewer_ViewWindow*)getGeometryGUI()->getApp()->activeViewManager()->getActiveView();
|
||||
vw->onTopView();
|
||||
}
|
||||
|
||||
QDialog *aDialog = new QDialog(parent);
|
||||
|
Loading…
Reference in New Issue
Block a user