#include <GeometryGUI.h>
#include "GeometryGUI_Operations.h"
+#include <GEOMUtils.hxx>
#include <SUIT_Session.h>
#include <SUIT_Desktop.h>
}
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
}
-//=======================================================================
-// 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
//=====================================================================================
#define BASICGUI_H
#include <GEOMGUI.h>
-#include <V3d_View.hxx>
//=================================================================================
// class : BasicGUI
bool OnGUIEvent( int, SUIT_Desktop* );
bool OnMousePress( QMouseEvent*, SUIT_Desktop*, SUIT_ViewWindow* );
-
- gp_Pnt ConvertClickToPoint( int, int, Handle(V3d_View) );
};
#endif // BASICGUI_H
-I$(srcdir)/../GEOMBase \
-I$(srcdir)/../GEOMImpl \
-I$(srcdir)/../GEOMClient \
+ -I$(srcdir)/../GEOMUtils \
-I$(top_builddir)/src/DlgRef \
-I$(top_builddir)/idl
../GEOMFiltersSelection/libGEOMFiltersSelection.la \
../GEOMBase/libGEOMBase.la \
../GEOMGUI/libGEOM.la \
+ ../GEOMUtils/libGEOMUtils.la \
$(CAS_LDFLAGS) -lTKGeomBase \
$(GUI_LDFLAGS) -lsuit \
- $(OPENCV_LIBS)
+ $(OPENCV_LIBS)
#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 );
-
- 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);
+ 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 );
+
clear();
updateTitle();
}
{
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();
}
return aCoords;
}
-void CurveCreator_NewPointDlg::onBtnClicked(QAbstractButton* theBtn )
-{
- if( myBtnBox->buttonRole(theBtn) == QDialogButtonBox::ResetRole ){
- emit addPoint();
- }
-}
-
void CurveCreator_NewPointDlg::clear()
{
initSpinBox(myX);
#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:
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;
};
#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);
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);
-
- 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 );
-
- 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(aLay);
- aMainLay->addWidget(myBtnBox);
- setLayout(aMainLay);
+ aCoordLayout->addWidget(aLbl, 2, 0);
+ aCoordLayout->addWidget(myIsClosed, 2, 1);
+
+ myBtnFrame = new QFrame( aFrame );
+ QHBoxLayout* aBtnsLayout = new QHBoxLayout( myBtnFrame );
+
+ myAddBtn = new QPushButton( tr( "ADD_BTN" ), myBtnFrame );
+ myCancelBtn = new QPushButton( tr( "CANCEL" ), myBtnFrame );
+
+ 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 )
{
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();
}
{
myName->setText(theName);
}
-
-void CurveCreator_NewSectionDlg::onBtnClicked(QAbstractButton* theBtn )
-{
- if( myBtnBox->buttonRole(theBtn) == QDialogButtonBox::ResetRole ){
- emit addSection();
- }
-}
#include "CurveCreator.hxx"
-#include <QDialog>
+#include <QDockWidget>
class CurveCreator_Curve;
class QPushButton;
class QAbstractButton;
class QDialogButtonBox;
+class QFrame;
-class CurveCreator_NewSectionDlg : public QDialog
+class CurveCreator_NewSectionDlg : public QWidget
{
Q_OBJECT
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
if( aModel ){
QModelIndex aSectIndx = aModel->sectionIndex( theSection );
rowsInserted(aSectIndx, thePoint, thePoint + thePointsCnt - 1 );
+ expand( aSectIndx );
}
}
#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>
#include <QToolBar>
#include <QAction>
#include <QMenu>
+#include <QMouseEvent>
CurveCreator_Widget::CurveCreator_Widget(QWidget* parent,
CurveCreator_Curve *theCurve,
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()));
-
- myNewSectionEditor = new CurveCreator_NewSectionDlg(this);
- connect( myNewSectionEditor, SIGNAL(addSection()), this, SLOT(onAddNewSection()));
+ 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 );
+ 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);
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()
CurveCreator::Coordinates aCoords = myNewPointEditor->getCoordinates();
myEdit->insertPoints(aCoords, mySection, myPointNum );
mySectionView->pointsAdded( mySection, myPointNum );
- myNewPointEditor->clear();
+// myNewPointEditor->clear();
myPointNum++;
onSelectionChanged();
updateUndoRedo();
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()
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,
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::onEditPoint( int theSection, int thePoint )
+void CurveCreator_Widget::onModifySection()
{
- if( !myNewPointEditor )
- return;
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 || !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()
{
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 );
+ }
+}
#include "CurveCreator_Curve.hxx"
#include <QWidget>
-
#include <QMap>
+#include <SUIT_ViewWindow.h>
+
class QAction;
class QPixmap;
class CurveCreator_CurveEditor;
signals:
void selectionChanged();
+ void subOperationStarted( QWidget* );
+ void subOperationFinished( QWidget* );
public 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();
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,
# 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
#include <GeometryGUI.h>
#include "GeometryGUI_Operations.h"
+#include <GEOMUtils.hxx>
#include <SUIT_Session.h>
#include <SUIT_Desktop.h>
}
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();
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 )
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
#include <SALOMEDSClient.hxx>
#include <AIS_Shape.hxx>
-#include <V3d_View.hxx>
class TopoDS_Shape;
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();
-I$(srcdir)/../GEOMImpl \
-I$(srcdir)/../GEOMFiltersSelection \
-I$(srcdir)/../SKETCHER \
+ -I$(srcdir)/../GEOMUtils \
-I$(ShapeRec_dir) \
-I$(srcdir)/../GEOM \
-I$(top_builddir)/src/DlgRef \
../GEOMBase/libGEOMBase.la \
../SKETCHER/libGEOMSketcher.la \
../GEOMGUI/libGEOM.la \
+ ../GEOMUtils/libGEOMUtils.la \
$(ShapeRec_la) \
$(QT_MT_LIBS) \
$(CAS_TKTopAlgo) -lTKernel \
- $(Opencv_libs)
+ $(Opencv_libs)
// 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 )
public:
GEOMBase_Helper( SUIT_Desktop* );
virtual ~GEOMBase_Helper();
+ static SUIT_ViewWindow* getActiveView();
protected:
static GEOM::GEOM_Gen_ptr getGeomEngine();
#include <gp_Pln.hxx>
#include <gp_Lin.hxx>
+#include <ProjLib.hxx>
+#include <ElSLib.hxx>
+
#include <vector>
#include <Standard_Failure.hxx>
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;
+}
#include <gp_Ax3.hxx>
#include <gp_Vec.hxx>
+#include <V3d_View.hxx>
+
#include <NCollection_DataMap.hxx>
#include <functional>
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
../ARCHIMEDE/libGEOMArchimede.la \
../SKETCHER/libGEOMSketcher.la \
$(KERNEL_LDFLAGS) -lSALOMELocalTrace -lSALOMEBasics \
- $(CAS_LDPATH) -lTKCAF -lTKFillet -lTKOffset -lTKFeat \
+ $(CAS_LDPATH) -lTKCAF -lTKFillet -lTKOffset -lTKFeat -lTKV3d \
$(STDLIB)
#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>
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);