return myOCCViewer;
}
+/**
+ * Returns OCC viewer context
+ */
+Handle(AIS_InteractiveContext) CurveCreator_Widget::getAISContext()
+{
+ OCCViewer_Viewer* aViewer = getOCCViewer();
+ return aViewer ? aViewer->getAISContext() : 0;
+}
+
+/**
+ * Returns OCC viewer view port
+ */
+OCCViewer_ViewPort3d* CurveCreator_Widget::getViewPort()
+{
+ OCCViewer_ViewPort3d* aViewPort = 0;
+ OCCViewer_Viewer* aViewer = getOCCViewer();
+ if ( aViewer )
+ aViewPort = ((OCCViewer_ViewWindow*)aViewer->getViewManager()->getActiveView())->getViewPort();
+
+ return aViewPort;
+}
+
+/**
+ * Set interaction style in the OCC viewer
+ * \param theStyle a new style
+ * \return the previous style
+ */
+int CurveCreator_Widget::changeInteractionStyle( int theStyle )
+{
+ OCCViewer_Viewer* aViewer = getOCCViewer();
+ if ( !aViewer )
+ return -1;
+
+ int aPrevStyle = aViewer->interactionStyle();
+ aViewer->setInteractionStyle( theStyle );
+
+ return aPrevStyle;
+}
+
+/**
+ * Set interaction style in the OCC viewer
+ * \param theStyle a new style
+ * \return the previous style
+ */
+void CurveCreator_Widget::setObjectsSelected(const AIS_ListOfInteractive& theList)
+{
+ OCCViewer_Viewer* aViewer = getOCCViewer();
+ if ( aViewer )
+ aViewer->setObjectsSelected(theList);
+}
+
//=======================================================================
// function: getUniqSectionName
// purpose: return unique section name
void CurveCreator_Widget::onAdditionMode(bool checked)
{
- OCCViewer_Viewer* aViewer = getOCCViewer();
- if( !myCurve || !aViewer )
+ if (!checked)
return;
- Handle(AIS_InteractiveContext) aContext = aViewer->getAISContext();
- OCCViewer_ViewManager* aViewManager = dynamic_cast<OCCViewer_ViewManager*>
- (aViewer->getViewManager());
-// if ( aViewManager->getType() == OCCViewer_Viewer::Type() ) {
- if( aViewer ) {
- if (checked) {
-/* myGuiState = aViewWindow->saveState();
- aViewer->enableMultiselection(false);
- aViewer->enableSelection(false);*/
- } else {
-/* aViewer->enableMultiselection(true);
- aViewer->enableSelection(true);
- aViewWindow->restoreState( myGuiState );*/
- return;
- }
- }
+ Handle(AIS_InteractiveContext) aContext = getAISContext();
+ if( !myCurve || !aContext )
+ return;
mySection= -1;
myPointNum = -1;
return;
if ( pe->modifiers() != Qt::ControlModifier ) {
- OCCViewer_Viewer* aViewer = getOCCViewer();
- if ( !aViewer )
- return;
- Handle(AIS_InteractiveContext) ic = aViewer->getAISContext();
+ Handle(AIS_InteractiveContext) ic = getAISContext();
+ if ( !ic )
+ return;
gp_Pnt aPnt;
aPnt = BRep_Tool::Pnt( TopoDS::Vertex( ic->SelectedShape() ) );
else*/
{
- OCCViewer_ViewPort3d* vp =
- ((OCCViewer_ViewWindow*)aViewer->getViewManager()->getActiveView())->getViewPort();
+ OCCViewer_ViewPort3d* vp = getViewPort();
aPnt = CurveCreator_Utils::ConvertClickToPoint( pe->x(), pe->y(), vp->getView() );
}
// set the coordinates into dialog
void CurveCreator_Widget::insertPointToSelectedSegment( const int theX,
const int theY )
{
- OCCViewer_Viewer* aViewer = getOCCViewer();
- if ( !aViewer )
+ Handle(AIS_InteractiveContext) aContext = getAISContext();
+ if ( !aContext )
return;
-
gp_Pnt aPoint;
gp_Pnt aPoint1, aPoint2;
bool isFoundPoint = false;
- Handle(AIS_InteractiveContext) aContext = aViewer->getAISContext();
+
for ( aContext->InitSelected(); aContext->MoreSelected() && !isFoundPoint;
aContext->NextSelected() ) {
TopoDS_Shape aTShape = aContext->SelectedShape();
void CurveCreator_Widget::moveSelectedPoints( const int theXPosition,
const int theYPosition )
{
- OCCViewer_Viewer* aViewer = getOCCViewer();
- if ( !aViewer )
+ OCCViewer_ViewPort3d* aViewPort = getViewPort();
+ if ( !aViewPort )
return;
SectionToPointList aPoints;
startCurveModification( aPoints, false );
- OCCViewer_ViewWindow* aWindow =
- (OCCViewer_ViewWindow*)aViewer->getViewManager()->getActiveView();
gp_Pnt aStartPnt = CurveCreator_Utils::ConvertClickToPoint( myDragStartPosition.x(),
- myDragStartPosition.y(),
- aWindow->getViewPort()->getView() );
+ myDragStartPosition.y(),
+ aViewPort->getView() );
gp_Pnt anEndPnt = CurveCreator_Utils::ConvertClickToPoint( theXPosition, theYPosition,
- aWindow->getViewPort()->getView() );
+ aViewPort->getView() );
double aXDelta = aStartPnt.X() - anEndPnt.X();
double anYDelta = aStartPnt.Y() - anEndPnt.Y();
void CurveCreator_Widget::updateLocalPointView()
{
- OCCViewer_Viewer* aViewer = getOCCViewer();
- if ( !aViewer )
+ Handle(AIS_InteractiveContext) aContext = getAISContext();
+ if ( !aContext )
return;
- Handle(AIS_InteractiveContext) aContext = aViewer->getAISContext();
bool isBlocked = myLocalPointView->blockSignals(true);
gp_Pnt aPnt;
*/
void CurveCreator_Widget::setLocalPointContext( const bool theOpen, const bool isUpdateTable )
{
- OCCViewer_Viewer* aViewer = getOCCViewer();
- if ( !aViewer )
+ Handle(AIS_InteractiveContext) ic = getAISContext();
+ if ( !ic )
return;
- Handle(AIS_InteractiveContext) ic = aViewer->getAISContext();
if ( theOpen ) {
// Open local context if there is no one
*/
void CurveCreator_Widget::setDragStarted( const bool theState, const QPoint& thePoint )
{
- OCCViewer_Viewer* aViewer = getOCCViewer();
if ( theState ) {
getSelectedPonts( myDragPoints );
myDragStarted = myDragPoints.size();
myDragStartPosition = thePoint;
- if ( aViewer && myDragStarted ) {
+ if ( myDragStarted ) {
// change a viewer interaction style in order to avoid a select rectangle build
- myDragInteractionStyle = aViewer->interactionStyle();
- aViewer->setInteractionStyle(SUIT_ViewModel::KEY_FREE);
+ myDragInteractionStyle = changeInteractionStyle( SUIT_ViewModel::KEY_FREE );
}
}
else {
- if ( aViewer && myDragStarted )
- aViewer->setInteractionStyle( myDragInteractionStyle );
+ if ( myDragStarted )
+ changeInteractionStyle( myDragInteractionStyle );
myDragStarted = false;
myDragPoints.clear();
}
void CurveCreator_Widget::setSelectedPonts( const CurveCreator_Widget::SectionToPointList& thePoints )
{
- OCCViewer_Viewer* aViewer = getOCCViewer();
- if ( !aViewer )
+ Handle(AIS_InteractiveContext) ic = getAISContext();
+ if ( !ic || !ic->HasOpenedContext() )
return;
AIS_ListOfInteractive aListToSelect;
-
- Handle(AIS_InteractiveContext) ic = aViewer->getAISContext();
- if ( !ic->HasOpenedContext() )
- return;
-
AIS_ListOfInteractive aDisplayedList;
ic->DisplayedObjects( aDisplayedList );
}
ic->ClearSelected( Standard_False );
- aViewer->setObjectsSelected( aListToSelect );
+ setObjectsSelected( aListToSelect );
updateLocalPointView();
}
{
bool isFound = false;
- OCCViewer_Viewer* aViewer = getOCCViewer();
- if ( theObject.IsNull() || !aViewer )
+ Handle(AIS_InteractiveContext) aContext = getAISContext();
+ if ( theObject.IsNull() || !aContext )
return isFound;
gp_Pnt aPoint;
Standard_Real& theParameter )
{
bool isFound = false;
- OCCViewer_Viewer* aViewer = getOCCViewer();
- if ( !aViewer )
+ OCCViewer_ViewPort3d* aViewPort = getViewPort();
+ if ( !aViewPort )
return isFound;
- OCCViewer_ViewWindow* aWindow =
- (OCCViewer_ViewWindow*)aViewer->getViewManager()->getActiveView();
- Handle(V3d_View) aView = aWindow->getViewPort()->getView();
+ Handle(V3d_View) aView = aViewPort->getView();
gp_Pnt aPoint = CurveCreator_Utils::ConvertClickToPoint( theX, theY, aView );
GeomAPI_ProjectPointOnCurve aProj( aPoint, theCurve );