HYDROGUI_TwoImagesOp.h
HYDROGUI_UpdateFlags.h
HYDROGUI_VisualStateOp.h
+ HYDROGUI_AISCurve.h
)
QT4_WRAP_CPP(PROJECT_HEADERS_MOC ${PROJECT_HEADERS})
HYDROGUI_TwoImagesDlg.cxx
HYDROGUI_TwoImagesOp.cxx
HYDROGUI_VisualStateOp.cxx
+ HYDROGUI_AISCurve.cxx
)
add_definitions(
--- /dev/null
+#include "HYDROGUI_AISCurve.h"\r
+#include "CurveCreator_Curve.hxx"\r
+\r
+#include <AIS_Point.hxx>\r
+#include <AIS_Line.hxx>\r
+#include <gp_Pnt.hxx>\r
+#include <gp_Lin.hxx>\r
+#include <Geom_CartesianPoint.hxx>\r
+\r
+HYDROGUI_AISCurveSection::HYDROGUI_AISCurveSection( Handle_AIS_InteractiveContext theContext, \r
+ CurveCreator_Curve* theCurve, int theSection) :\r
+ myCurve(theCurve), mySection(theSection), myContext(theContext), myIsHL(false)\r
+{\r
+ buildSection();\r
+}\r
+\r
+HYDROGUI_AISCurveSection::~HYDROGUI_AISCurveSection()\r
+{\r
+ Erase();\r
+ for( int i = 0 ; i < myObjects.size() ; i++ ){\r
+ myObjects[i].Nullify();\r
+ }\r
+ myObjects.clear();\r
+}\r
+\r
+Quantity_Color HYDROGUI_AISCurveSection::getActiveColor()\r
+{\r
+ if( myIsHL ){\r
+ return Quantity_Color( 1., 0., 0., Quantity_TOC_RGB );\r
+ }\r
+ return Quantity_Color( 0., 1., 0., Quantity_TOC_RGB );\r
+}\r
+\r
+void HYDROGUI_AISCurveSection::highlight( bool isHL )\r
+{\r
+ myIsHL = isHL;\r
+ Quantity_Color aColor = getActiveColor();\r
+ for( int i = 0 ; i < myObjects.size() ; i++ ){\r
+ myObjects[i]->SetColor(aColor);\r
+ myContext->Display(myObjects[i]);\r
+ }\r
+}\r
+\r
+void HYDROGUI_AISCurveSection::Display()\r
+{\r
+ for( int i = 0 ; i < myObjects.size() ; i++ ){\r
+ myContext->Display(myObjects[i]);\r
+ }\r
+}\r
+\r
+void HYDROGUI_AISCurveSection::Erase()\r
+{\r
+ for( int i = 0 ; i < myObjects.size() ; i++ ){\r
+ myContext->Erase(myObjects[i]);\r
+ }\r
+}\r
+\r
+void HYDROGUI_AISCurveSection::buildSection()\r
+{\r
+ int aSectSize = myCurve->getNbPoints( mySection );\r
+ double anX;\r
+ double anY;\r
+ double aZ;\r
+ int i = 0; \r
+ for( ; i < ( aSectSize - 1 ) ; i++ ){\r
+ Handle_AIS_Point anAISPnt = getAISPoint(i);\r
+ myObjects.push_back( anAISPnt );\r
+ Handle_AIS_Line aLine = getAISLine( i, i+1 );\r
+ myObjects.push_back( aLine );\r
+ }\r
+ if( aSectSize != 0 ){\r
+ Handle_AIS_Point anAISPnt = getAISPoint(i); \r
+ myObjects.push_back( anAISPnt );\r
+ if( myCurve->isClosed(mySection) && ( aSectSize > 1 ) ){\r
+ Handle_AIS_Line aLine = getAISLine( i, 0 );\r
+ myObjects.push_back( aLine );\r
+ }\r
+ }\r
+}\r
+\r
+Handle_AIS_Point HYDROGUI_AISCurveSection::getAISPoint( int theIndx )\r
+{\r
+ double anX;\r
+ double anY;\r
+ double aZ;\r
+ getPoint( theIndx, anX, anY, aZ );\r
+ gp_Pnt aPoint( anX, anY, aZ);\r
+ AIS_Point* aPnt = new AIS_Point( new Geom_CartesianPoint(aPoint));\r
+ return aPnt;\r
+}\r
+\r
+Handle_AIS_Line HYDROGUI_AISCurveSection::getAISLine( int theIndx1, int theIndx2 )\r
+{\r
+ double anX;\r
+ double anY;\r
+ double aZ;\r
+ getPoint( theIndx1, anX, anY, aZ );\r
+ gp_Pnt aPoint1( anX, anY, aZ);\r
+ double anX2;\r
+ double anY2;\r
+ double aZ2;\r
+ getPoint( theIndx2, anX2, anY2, aZ2 );\r
+//MTN to avoid crash during line construction\r
+ if( ( anX == anX2 ) && ( anY == anY2 ) && (aZ == aZ2 ) ){\r
+ aZ2 += 1e-7;\r
+ }\r
+ gp_Pnt aPoint2( anX2, anY2, aZ2 );\r
+ AIS_Line* aLine = new AIS_Line( new Geom_CartesianPoint(aPoint1), new Geom_CartesianPoint(aPoint2) );\r
+ return aLine;\r
+}\r
+\r
+void HYDROGUI_AISCurveSection::getPoint( int theIndx, double& theX, double& theY, double& theZ )\r
+{\r
+ CurveCreator::Dimension aDim = myCurve->getDimension();\r
+ CurveCreator::Coordinates aCoords = myCurve->getCoordinates( mySection, theIndx );\r
+ theX = aCoords[0];\r
+ theY = aCoords[1];\r
+ theZ = 0.;\r
+ if( aDim == CurveCreator::Dim3d ){\r
+ theZ = aCoords[2];\r
+ }\r
+}\r
+\r
+/******************************* HYDROGUI_AISCurve ********************************************/\r
+HYDROGUI_AISCurve::HYDROGUI_AISCurve( CurveCreator_Curve* theCurve, Handle_AIS_InteractiveContext theContext ) :\r
+ CurveCreator_Listener(), myCurve(theCurve), myContext( theContext )\r
+{\r
+ myCurve->setListener(this);\r
+ buildCurve();\r
+}\r
+\r
+HYDROGUI_AISCurve::~HYDROGUI_AISCurve(void)\r
+{\r
+}\r
+\r
+void HYDROGUI_AISCurve::setCurve( CurveCreator_Curve* theCurve )\r
+{\r
+ myCurve = theCurve;\r
+ buildCurve();\r
+}\r
+\r
+void HYDROGUI_AISCurve::Display()\r
+{\r
+ for( int i = 0 ; i < myCurveRepresentation.size() ; i++ ){\r
+ myCurveRepresentation[i]->Display();\r
+ }\r
+}\r
+\r
+void HYDROGUI_AISCurve::buildCurve()\r
+{\r
+ for( int i = 0 ; i < myCurveRepresentation.size() ; i++ ){\r
+ myCurveRepresentation[i]->Erase();\r
+ delete myCurveRepresentation[i];\r
+ }\r
+ myCurveRepresentation.clear();\r
+ for( int i = 0 ; i < myCurve->getNbSections() ; i++ ){\r
+ HYDROGUI_AISCurveSection* aSection = new HYDROGUI_AISCurveSection( myContext, myCurve, i);\r
+ myCurveRepresentation.push_back( aSection );\r
+ myCurveRepresentation[i]->Display();\r
+ }\r
+}\r
+\r
+void HYDROGUI_AISCurve::pointInserted( int theSection, int theIndx )\r
+{\r
+ buildCurve();\r
+}\r
+\r
+void HYDROGUI_AISCurve::highlightSection( int theSection, bool isHL )\r
+{\r
+ if( theSection >= myCurveRepresentation.size() )\r
+ return;\r
+ myCurveRepresentation[theSection]->highlight(isHL);\r
+}\r
--- /dev/null
+#ifndef HYDROGUI_AIS_CURVE_H\r
+#define HYDROGUI_AIS_CURVE_H\r
+\r
+#include <vector>\r
+#include <list>\r
+\r
+#include <AIS_InteractiveContext.hxx>\r
+#include <AIS_Point.hxx>\r
+#include <AIS_Line.hxx>\r
+#include <CurveCreator_Listener.hxx>\r
+\r
+class CurveCreator_Curve;\r
+class AIS_InteractiveObject;\r
+class AIS_Point;\r
+class AIS_Line;\r
+\r
+class HYDROGUI_AISCurveSection\r
+{\r
+public:\r
+ HYDROGUI_AISCurveSection( Handle_AIS_InteractiveContext theContext, \r
+ CurveCreator_Curve* theCurve, int theSection );\r
+ virtual ~HYDROGUI_AISCurveSection();\r
+\r
+ void Display();\r
+ void Erase();\r
+\r
+ void highlight( bool isHL );\r
+protected:\r
+ virtual void buildSection();\r
+ void getPoint( int theIndx, double& theX, double& theY, double& theZ );\r
+ Handle_AIS_Point getAISPoint( int theIndx );\r
+ Handle_AIS_Line getAISLine( int theIndx1, int theIndx2 );\r
+ Quantity_Color getActiveColor();\r
+\r
+private:\r
+ CurveCreator_Curve* myCurve;\r
+ int mySection;\r
+ std::vector< Handle_AIS_InteractiveObject > myObjects;\r
+ Handle_AIS_InteractiveContext myContext;\r
+ bool myIsHighlight;\r
+ bool myIsHL;\r
+};\r
+\r
+class HYDROGUI_AISCurve : public CurveCreator_Listener\r
+{\r
+public:\r
+ HYDROGUI_AISCurve(CurveCreator_Curve* theCurve, Handle_AIS_InteractiveContext theContext );\r
+ ~HYDROGUI_AISCurve(void);\r
+\r
+ void setCurve( CurveCreator_Curve* theCurve );\r
+\r
+ void Display();\r
+\r
+ virtual void pointInserted( int theSection, int theIndx );\r
+\r
+ void highlightSection( int theSection, bool isHL );\r
+ void clearSelection();\r
+\r
+protected:\r
+ virtual void buildCurve();\r
+ Quantity_Color getActiveColor();\r
+\r
+private:\r
+ CurveCreator_Curve* myCurve;\r
+ Handle_AIS_InteractiveContext myContext;\r
+ std::vector< HYDROGUI_AISCurveSection* > myCurveRepresentation; \r
+};\r
+\r
+#endif
\ No newline at end of file
new CurveCreator_Widget( this, NULL);
addWidget( myEditorWidget );
+
+ connect( myEditorWidget, SIGNAL( selectionChanged() ), this, SIGNAL( selectionChanged() ) );
}
HYDROGUI_PolylineDlg::~HYDROGUI_PolylineDlg()
{
myEditorWidget->setCurve( theCurve );
}
+
+QList<int> HYDROGUI_PolylineDlg::getSelectedSections()
+{
+ return myEditorWidget->getSelectedSections();
+}
+
+QList< QPair< int, int > > HYDROGUI_PolylineDlg::getSelectedPoints()
+{
+ return myEditorWidget->getSelectedPoints();
+}
void setCurve( CurveCreator_Curve* theCurve );
void reset();
+
+ QList<int> getSelectedSections();
+ QList< QPair< int, int > > getSelectedPoints();
+
protected slots:
signals:
- void createPreview( QString );
-
+ void createPreview( QString );
+ void selectionChanged();
private:
QLineEdit* myName;
CurveCreator_Widget* myEditorWidget;
#include "HYDROGUI_PolylineOp.h"
#include "HYDROGUI_PolylineDlg.h"
#include "HYDROGUI_Tool.h"
+#include "CurveCreator.hxx"
+#include "CurveCreator_Curve.hxx"
+#include "CurveCreator_CurveEditor.hxx"
+#include "HYDROGUI_AISCurve.h"
#include <HYDROData_Document.h>
#include <HYDROData_Polyline.h>
#include <CurveCreator_CurveEditor.hxx>
#include <LightApp_Application.h>
+#include <LightApp_SelectionMgr.h>
#include <LightApp_UpdateFlags.h>
+#include <OCCViewer_ViewManager.h>
+#include <OCCViewer_ViewModel.h>
+
+#include <OCCViewer_AISSelector.h>
HYDROGUI_PolylineOp::HYDROGUI_PolylineOp( HYDROGUI_Module* theModule, bool theIsEdit )
-: HYDROGUI_Operation( theModule ), myIsEdit(theIsEdit), myCurve(NULL)
+: HYDROGUI_Operation( theModule ), myIsEdit(theIsEdit), myCurve(NULL),
+ myActiveViewManager(NULL), myPreviewViewManager(NULL), myAISCurve(NULL)
{
setName( theIsEdit ? tr( "EDIT_POLYLINE" ) : tr( "CREATE_POLYLINE" ) );
}
HYDROGUI_InputPanel* HYDROGUI_PolylineOp::createInputPanel() const
{
- return new HYDROGUI_PolylineDlg( module(), getName() );
+ HYDROGUI_PolylineDlg* aDlg = new HYDROGUI_PolylineDlg( module(), getName() );
+ connect( aDlg ,SIGNAL( selectionChanged() ), this, SLOT( onEditorSelectionChanged() ) );
+ return aDlg;
}
bool HYDROGUI_PolylineOp::processApply( int& theUpdateFlags,
return true;
}
+void HYDROGUI_PolylineOp::onCreatePreview()
+{
+ LightApp_Application* anApp = module()->getApp();
+
+ myActiveViewManager = anApp->activeViewManager();
+
+ myPreviewViewManager =
+ dynamic_cast<OCCViewer_ViewManager*>( anApp->createViewManager( OCCViewer_Viewer::Type() ) );
+ if( myPreviewViewManager )
+ {
+ anApp->selectionMgr()->setEnabled(false);
+ myPreviewViewManager->setTitle( tr( "CREATE_CURVE" ) );
+ OCCViewer_Viewer* aViewer = myPreviewViewManager->getOCCViewer();
+ aViewer->enableSelection(true);
+ aViewer->enableMultiselection(true);
+ Handle_AIS_InteractiveContext aCtx = aViewer->getAISContext();
+
+ myAISCurve = new HYDROGUI_AISCurve(myCurve, aCtx);
+
+ myAISCurve->Display();
+ }
+}
+
void HYDROGUI_PolylineOp::startOperation()
{
CurveCreator_Curve* anOldCurve = myCurve;
aPanel->setPolylineName(aNewName);
}
aPanel->setCurve(myCurve);
+ if( myAISCurve )
+ myAISCurve->setCurve(myCurve);
if( anOldCurve )
delete anOldCurve;
+ onCreatePreview();
+}
+
+void HYDROGUI_PolylineOp::onEditorSelectionChanged()
+{
+ HYDROGUI_PolylineDlg* aPanel = (HYDROGUI_PolylineDlg*)inputPanel();
+ if( !aPanel )
+ return;
+ if( !myCurve )
+ return;
+ if( !myAISCurve )
+ return;
+ QList<int> aSelSections = aPanel->getSelectedSections();
+ for( int i = 0 ; i < myCurve->getNbSections() ; i++ ){
+ bool aIsHl = false;
+ if( aSelSections.contains(i) ){
+ myAISCurve->highlightSection(i, aIsHl);
+ }
+ }
}
#include <HYDROData_Polyline.h>
class CurveCreator_Curve;
+class SUIT_ViewManager;
+class OCCViewer_ViewManager;
+class HYDROGUI_AISCurve;
class HYDROGUI_PolylineOp : public HYDROGUI_Operation
{
virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg );
virtual void startOperation();
+
+ void onCreatePreview();
+
+protected slots:
+ void onEditorSelectionChanged();
private:
+ SUIT_ViewManager* myActiveViewManager;
+
+ OCCViewer_ViewManager* myPreviewViewManager;
+
bool myIsEdit;
Handle(HYDROData_Polyline) myEditedObject;
CurveCreator_Curve* myCurve;
+ HYDROGUI_AISCurve* myAISCurve;
};
#endif