diff --git a/samples/CSharp/OCCTProxy/OCCTProxy.cpp b/samples/CSharp/OCCTProxy/OCCTProxy.cpp index 933355b3a8..91d43646fe 100644 --- a/samples/CSharp/OCCTProxy/OCCTProxy.cpp +++ b/samples/CSharp/OCCTProxy/OCCTProxy.cpp @@ -133,6 +133,7 @@ public: if (!myView().IsNull()) { myView()->SetComputedMode (Standard_False); + myView()->Redraw(); } } @@ -144,6 +145,7 @@ public: if (!myView().IsNull()) { myView()->SetComputedMode (Standard_True); + myView()->Redraw(); } } diff --git a/samples/CSharp/OCCTProxy_D3D/OCCTProxyD3D.cpp b/samples/CSharp/OCCTProxy_D3D/OCCTProxyD3D.cpp index 165c705a71..413674ee9f 100644 --- a/samples/CSharp/OCCTProxy_D3D/OCCTProxyD3D.cpp +++ b/samples/CSharp/OCCTProxy_D3D/OCCTProxyD3D.cpp @@ -148,6 +148,7 @@ public: if (!myView().IsNull()) { myView()->SetComputedMode (Standard_False); + myView()->Redraw(); } } @@ -159,6 +160,7 @@ public: if (!myView().IsNull()) { myView()->SetComputedMode (Standard_True); + myView()->Redraw(); } } diff --git a/samples/mfc/occtdemo/Common/WNT/OCCDemoView.cpp b/samples/mfc/occtdemo/Common/WNT/OCCDemoView.cpp index 56ca7b6d65..d46d6b0f01 100755 --- a/samples/mfc/occtdemo/Common/WNT/OCCDemoView.cpp +++ b/samples/mfc/occtdemo/Common/WNT/OCCDemoView.cpp @@ -278,6 +278,7 @@ void COCCDemoView::OnLButtonUp(UINT nFlags, CPoint point) { SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); myView->SetComputedMode(Standard_True); + myView->Redraw(); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); } myCurrentMode = CurAction3d_Nothing; @@ -301,6 +302,7 @@ void COCCDemoView::OnRButtonUp(UINT nFlags, CPoint point) { SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); myView->SetComputedMode(Standard_True); + myView->Redraw(); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); } } @@ -497,14 +499,17 @@ void COCCDemoView::RedrawVisMode() case VIS_WIREFRAME: GetDocument()->GetAISContext()->SetDisplayMode(AIS_WireFrame); myView->SetComputedMode (Standard_False); + myView->Redraw(); break; case VIS_SHADE: GetDocument()->GetAISContext()->SetDisplayMode(AIS_Shaded); myView->SetComputedMode (Standard_False); + myView->Redraw(); break; case VIS_HLR: SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); myView->SetComputedMode (Standard_True); + myView->Redraw(); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); GetDocument()->GetAISContext()->SetDisplayMode(AIS_WireFrame); break; diff --git a/samples/mfc/standard/04_Viewer3d/src/Viewer3dView.cpp b/samples/mfc/standard/04_Viewer3d/src/Viewer3dView.cpp index d4cda7536d..9be1e1a001 100755 --- a/samples/mfc/standard/04_Viewer3d/src/Viewer3dView.cpp +++ b/samples/mfc/standard/04_Viewer3d/src/Viewer3dView.cpp @@ -306,6 +306,7 @@ void CViewer3dView::OnBUTTONHlrOff() { myHlrModeIsOn = Standard_False; myView->SetComputedMode (myHlrModeIsOn); + myView->Redraw(); TCollection_AsciiString aMsg ("myView->SetComputedMode (Standard_False);\n" " "); @@ -319,6 +320,7 @@ void CViewer3dView::OnBUTTONHlrOn() SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); myHlrModeIsOn = Standard_True; myView->SetComputedMode (myHlrModeIsOn); + myView->Redraw(); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); TCollection_AsciiString aMsg ("myView->SetComputedMode (Standard_True);\n" @@ -616,7 +618,11 @@ void CViewer3dView::OnRButtonDown(UINT nFlags, CPoint point) void CViewer3dView::OnRButtonUp(UINT /*nFlags*/, CPoint /*point*/) { SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); - myView->SetComputedMode (myHlrModeIsOn); + if (myHlrModeIsOn) + { + myView->SetComputedMode (myHlrModeIsOn); + myView->Redraw(); + } SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); } @@ -1177,14 +1183,17 @@ void CViewer3dView::RedrawVisMode() case VIS_WIREFRAME: GetDocument()->GetAISContext()->SetDisplayMode (AIS_WireFrame, Standard_True); myView->SetComputedMode (Standard_False); + myView->Redraw(); break; case VIS_SHADE: GetDocument()->GetAISContext()->SetDisplayMode (AIS_Shaded, Standard_True); myView->SetComputedMode (Standard_False); + myView->Redraw(); break; case VIS_HLR: SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); myView->SetComputedMode (Standard_True); + myView->Redraw(); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); GetDocument()->GetAISContext()->SetDisplayMode (AIS_WireFrame, Standard_True); break; diff --git a/samples/mfc/standard/08_HLR/src/SelectionDialog.cpp b/samples/mfc/standard/08_HLR/src/SelectionDialog.cpp index 6ef0c98c69..54f8d38567 100644 --- a/samples/mfc/standard/08_HLR/src/SelectionDialog.cpp +++ b/samples/mfc/standard/08_HLR/src/SelectionDialog.cpp @@ -435,11 +435,13 @@ void CSelectionDialog::OnHlrMode() if (!m_HlrModeIsOn) { myActiveView->SetComputedMode (m_HlrModeIsOn != 0); + myActiveView->Redraw(); } else { SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); myActiveView->SetComputedMode (m_HlrModeIsOn != 0); + myActiveView->Redraw(); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); } OnDisplay(false); @@ -500,7 +502,11 @@ void CSelectionDialog::OnRButtonUp(UINT nFlags, CPoint point) SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); // reset the good HLR mode according to the stored one // --> dynamic rotation may have change it - myActiveView->SetComputedMode (m_HlrModeIsOn != 0); + if (m_HlrModeIsOn != 0) + { + myActiveView->SetComputedMode (true); + myActiveView->Redraw(); + } OnDisplay(false); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); } diff --git a/samples/mfc/standard/09_Animation/src/AnimationView3D.cpp b/samples/mfc/standard/09_Animation/src/AnimationView3D.cpp index 7f57898389..0ffae373b0 100755 --- a/samples/mfc/standard/09_Animation/src/AnimationView3D.cpp +++ b/samples/mfc/standard/09_Animation/src/AnimationView3D.cpp @@ -258,6 +258,7 @@ void CAnimationView3D::OnBUTTONHlrOff() { myHlrModeIsOn = Standard_False; myView->SetComputedMode (myHlrModeIsOn); + myView->Redraw(); } void CAnimationView3D::OnBUTTONHlrOn() @@ -265,6 +266,7 @@ void CAnimationView3D::OnBUTTONHlrOn() SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); myHlrModeIsOn = Standard_True; myView->SetComputedMode (myHlrModeIsOn); + myView->Redraw(); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); } @@ -470,7 +472,11 @@ void CAnimationView3D::OnRButtonDown(UINT nFlags, CPoint point) void CAnimationView3D::OnRButtonUp(UINT /*nFlags*/, CPoint /*point*/) { SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); - myView->SetComputedMode (myHlrModeIsOn); + if (myHlrModeIsOn) + { + myView->SetComputedMode (myHlrModeIsOn); + myView->Redraw(); + } SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); } diff --git a/samples/mfc/standard/10_Convert/src/WNT/OCCDemoView.cpp b/samples/mfc/standard/10_Convert/src/WNT/OCCDemoView.cpp index 93c67d86ec..2c8dd369bc 100755 --- a/samples/mfc/standard/10_Convert/src/WNT/OCCDemoView.cpp +++ b/samples/mfc/standard/10_Convert/src/WNT/OCCDemoView.cpp @@ -277,6 +277,7 @@ void COCCDemoView::OnLButtonUp(UINT nFlags, CPoint point) { SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); myView->SetComputedMode(Standard_True); + myView->Redraw(); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); } myCurrentMode = CurAction3d_Nothing; @@ -300,6 +301,7 @@ void COCCDemoView::OnRButtonUp(UINT /*nFlags*/, CPoint /*point*/) { SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); myView->SetComputedMode(Standard_True); + myView->Redraw(); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); } } @@ -496,14 +498,17 @@ void COCCDemoView::RedrawVisMode() case VIS_WIREFRAME: GetDocument()->GetAISContext()->SetDisplayMode (AIS_WireFrame, Standard_True); myView->SetComputedMode (Standard_False); + myView->Redraw(); break; case VIS_SHADE: GetDocument()->GetAISContext()->SetDisplayMode (AIS_Shaded, Standard_True); myView->SetComputedMode (Standard_False); + myView->Redraw(); break; case VIS_HLR: SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); myView->SetComputedMode (Standard_True); + myView->Redraw(); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); GetDocument()->GetAISContext()->SetDisplayMode (AIS_WireFrame, Standard_True); break; diff --git a/samples/mfc/standard/Common/OCC_3dView.cpp b/samples/mfc/standard/Common/OCC_3dView.cpp index ec8ddbf50f..1222c2f7f3 100755 --- a/samples/mfc/standard/Common/OCC_3dView.cpp +++ b/samples/mfc/standard/Common/OCC_3dView.cpp @@ -216,6 +216,7 @@ void OCC_3dView::OnBUTTONHlrOff() { myHlrModeIsOn = Standard_False; myView->SetComputedMode (myHlrModeIsOn); + myView->Redraw(); } void OCC_3dView::OnBUTTONHlrOn() @@ -223,6 +224,7 @@ void OCC_3dView::OnBUTTONHlrOn() SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); myHlrModeIsOn = Standard_True; myView->SetComputedMode (myHlrModeIsOn); + myView->Redraw(); SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); } @@ -365,6 +367,7 @@ void OCC_3dView::OnLButtonUp(UINT nFlags, CPoint point) { CWaitCursor aWaitCursor; myView->SetComputedMode (myHlrModeIsOn); + myView->Redraw(); } else { @@ -415,7 +418,11 @@ void OCC_3dView::OnRButtonDown(UINT nFlags, CPoint point) void OCC_3dView::OnRButtonUp(UINT /*nFlags*/, CPoint /*point*/) { SetCursor(AfxGetApp()->LoadStandardCursor(IDC_WAIT)); - myView->SetComputedMode (myHlrModeIsOn); + if (myHlrModeIsOn) + { + myView->SetComputedMode (myHlrModeIsOn); + myView->Redraw(); + } SetCursor(AfxGetApp()->LoadStandardCursor(IDC_ARROW)); } diff --git a/samples/qt/Common/src/View.cxx b/samples/qt/Common/src/View.cxx index ae31db26ba..9cc8adaea2 100755 --- a/samples/qt/Common/src/View.cxx +++ b/samples/qt/Common/src/View.cxx @@ -204,6 +204,7 @@ void View::hlrOff() QApplication::setOverrideCursor( Qt::WaitCursor ); myHlrModeIsOn = Standard_False; myView->SetComputedMode (myHlrModeIsOn); + myView->Redraw(); QApplication::restoreOverrideCursor(); } @@ -212,6 +213,7 @@ void View::hlrOn() QApplication::setOverrideCursor( Qt::WaitCursor ); myHlrModeIsOn = Standard_True; myView->SetComputedMode (myHlrModeIsOn); + myView->Redraw(); QApplication::restoreOverrideCursor(); } @@ -742,7 +744,11 @@ void View::onRButtonUp( Qt::MouseButtons /*nFlags*/, const QPoint point ) QApplication::setOverrideCursor( Qt::WaitCursor ); // reset tyhe good Degenerated mode according to the strored one // --> dynamic rotation may have change it - myView->SetComputedMode (myHlrModeIsOn); + if (myHlrModeIsOn) + { + myView->SetComputedMode (myHlrModeIsOn); + myView->Redraw(); + } QApplication::restoreOverrideCursor(); myCurrentMode = CurAction3d_Nothing; } diff --git a/src/Graphic3d/Graphic3d_CView.cxx b/src/Graphic3d/Graphic3d_CView.cxx index bb63a602b5..2a0e8032ac 100644 --- a/src/Graphic3d/Graphic3d_CView.cxx +++ b/src/Graphic3d/Graphic3d_CView.cxx @@ -258,6 +258,7 @@ void Graphic3d_CView::SetComputedMode (const Standard_Boolean theMode) myStructsComputed .Append (aCompStruct); } + aCompStruct->CalculateBoundBox(); eraseStructure (aStruct->CStructure()); displayStructure (aCompStruct->CStructure(), aStruct->DisplayPriority()); } @@ -306,6 +307,7 @@ void Graphic3d_CView::ReCompute (const Handle(Graphic3d_Structure)& theStruct) theStruct->IsTransformed() ? theStruct->Compute (this, theStruct->Transformation(), aCompStruct) : theStruct->Compute (this, aCompStruct); aCompStruct->SetHLRValidation (Standard_True); + aCompStruct->CalculateBoundBox(); // of which type will be the computed? const Standard_Boolean toComputeWireframe = myVisualization == Graphic3d_TOV_WIREFRAME diff --git a/src/PrsMgr/PrsMgr_Presentation.cxx b/src/PrsMgr/PrsMgr_Presentation.cxx index 75e8bc49c8..17ff1c225e 100644 --- a/src/PrsMgr/PrsMgr_Presentation.cxx +++ b/src/PrsMgr/PrsMgr_Presentation.cxx @@ -287,31 +287,7 @@ Handle(Graphic3d_Structure) PrsMgr_Presentation::Compute (const Handle(Graphic3d const Handle(Geom_Transformation)& theTrsf) { Handle(Prs3d_Presentation) aPrs3d = new Prs3d_Presentation (myPresentationManager->StructureManager()); - if (theTrsf->Form() == gp_Translation) - { - myPresentableObject->Compute (Projector (theProjector), aPrs3d); - aPrs3d->SetTransformation (theTrsf); - return aPrs3d; - } - - // waiting that something is done in gp_Trsf...rob - for (Standard_Integer i = 1; i <= 3; ++i) - { - for (Standard_Integer j = 1; j <= 3; ++j) - { - if (i != j) - { - if (Abs (theTrsf->Value (i, j)) > Precision::Confusion()) - { - myPresentableObject->Compute (Projector (theProjector), theTrsf, aPrs3d); - return aPrs3d; - } - } - } - } - - myPresentableObject->Compute (Projector (theProjector), aPrs3d); - aPrs3d->SetTransformation (theTrsf); + myPresentableObject->Compute (Projector (theProjector), theTrsf, aPrs3d); return aPrs3d; } diff --git a/src/StdPrs/StdPrs_HLRPolyShape.cxx b/src/StdPrs/StdPrs_HLRPolyShape.cxx index fb2e13693a..4ade3a16cf 100644 --- a/src/StdPrs/StdPrs_HLRPolyShape.cxx +++ b/src/StdPrs/StdPrs_HLRPolyShape.cxx @@ -14,9 +14,10 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. +#include #include -#include +#include #include #include #include @@ -27,7 +28,6 @@ #include #include #include -#include #include #include #include @@ -64,9 +64,6 @@ void StdPrs_HLRPolyShape::Add(const Handle (Prs3d_Presentation)& aPresentation, } } - TColgp_SequenceOfPnt HiddenPnts; - TColgp_SequenceOfPnt SeenPnts; - if (aDrawer->IsAutoTriangulation()) { const Standard_Boolean aRel = aDrawer->TypeOfDeflection() == Aspect_TOD_RELATIVE; @@ -121,48 +118,64 @@ void StdPrs_HLRPolyShape::Add(const Handle (Prs3d_Presentation)& aPresentation, S,reg1,regn,outl,intl)); } } - - // storage in the group: - HLRBRep_ListIteratorOfListOfBPoint ItB; - if (aDrawer->DrawHiddenLine()) { - for (ItB.Initialize(BiPntHid); ItB.More(); ItB.Next()) { - const HLRBRep_BiPoint& BP = ItB.Value(); - if (!BP.RgNLine() || BP.OutLine()) { - HiddenPnts.Append(BP.P1()); - HiddenPnts.Append(BP.P2()); + // storage in the group + if (aDrawer->DrawHiddenLine()) + { + Standard_Integer aNbHiddenSegments = 0; + for (HLRBRep_ListIteratorOfListOfBPoint aBPntHidIter (BiPntHid); aBPntHidIter.More(); aBPntHidIter.Next()) + { + const HLRBRep_BiPoint& aBPnt = aBPntHidIter.Value(); + if (!aBPnt.RgNLine() + || aBPnt.OutLine()) + { + ++aNbHiddenSegments; } } - } + if (aNbHiddenSegments > 0) + { + Handle(Graphic3d_ArrayOfSegments) aHiddenArray = new Graphic3d_ArrayOfSegments (aNbHiddenSegments * 2); + for (HLRBRep_ListIteratorOfListOfBPoint aBPntHidIter (BiPntHid); aBPntHidIter.More(); aBPntHidIter.Next()) + { + const HLRBRep_BiPoint& aBPnt = aBPntHidIter.Value(); + if (!aBPnt.RgNLine() + || aBPnt.OutLine()) + { + aHiddenArray->AddVertex (aBPnt.P1()); + aHiddenArray->AddVertex (aBPnt.P2()); + } + } - for (ItB.Initialize(BiPntVis); ItB.More(); ItB.Next()) { - const HLRBRep_BiPoint& BP = ItB.Value(); - if (!BP.RgNLine() || BP.OutLine()) { - SeenPnts.Append(BP.P1()); - SeenPnts.Append(BP.P2()); + aGroup->SetPrimitivesAspect (aDrawer->HiddenLineAspect()->Aspect()); + aGroup->AddPrimitiveArray (aHiddenArray); } } - - Standard_Integer nbVertices = HiddenPnts.Length(); - if(nbVertices > 0) { - Handle(Graphic3d_ArrayOfPolylines) HiddenArray = new Graphic3d_ArrayOfPolylines(nbVertices, (Standard_Integer)nbVertices/2); - for(int i=1; i<=nbVertices; i+=2) { - HiddenArray->AddBound(2); - HiddenArray->AddVertex(HiddenPnts.Value(i)); - HiddenArray->AddVertex(HiddenPnts.Value(i+1)); + { + Standard_Integer aNbSeenSegments = 0; + for (HLRBRep_ListIteratorOfListOfBPoint aBPntVisIter (BiPntVis); aBPntVisIter.More(); aBPntVisIter.Next()) + { + const HLRBRep_BiPoint& aBPnt = aBPntVisIter.Value(); + if (!aBPnt.RgNLine() + || aBPnt.OutLine()) + { + ++aNbSeenSegments; + } } - aGroup->SetPrimitivesAspect(aDrawer->HiddenLineAspect()->Aspect()); - aGroup->AddPrimitiveArray(HiddenArray); - } - nbVertices = SeenPnts.Length(); - if(nbVertices > 0) { - Handle(Graphic3d_ArrayOfPolylines) SeenArray = new Graphic3d_ArrayOfPolylines(nbVertices, (Standard_Integer)nbVertices/2); - for(int i=1; i<=nbVertices; i+=2) { - SeenArray->AddBound(2); - SeenArray->AddVertex(SeenPnts.Value(i)); - SeenArray->AddVertex(SeenPnts.Value(i+1)); + if (aNbSeenSegments > 0) + { + Handle(Graphic3d_ArrayOfSegments) aSeenArray = new Graphic3d_ArrayOfSegments (aNbSeenSegments * 2); + for (HLRBRep_ListIteratorOfListOfBPoint aBPntVisIter (BiPntVis); aBPntVisIter.More(); aBPntVisIter.Next()) + { + const HLRBRep_BiPoint& aBPnt = aBPntVisIter.Value(); + if (!aBPnt.RgNLine() + || aBPnt.OutLine()) + { + aSeenArray->AddVertex (aBPnt.P1()); + aSeenArray->AddVertex (aBPnt.P2()); + } + } + aGroup->SetPrimitivesAspect (aDrawer->SeenLineAspect()->Aspect()); + aGroup->AddPrimitiveArray (aSeenArray); } - aGroup->SetPrimitivesAspect(aDrawer->SeenLineAspect()->Aspect()); - aGroup->AddPrimitiveArray(SeenArray); } } diff --git a/src/V3d/V3d_View.cxx b/src/V3d/V3d_View.cxx index acf06ef4db..9b1c9143db 100644 --- a/src/V3d/V3d_View.cxx +++ b/src/V3d/V3d_View.cxx @@ -2710,13 +2710,11 @@ void V3d_View::SetComputedMode (const Standard_Boolean theMode) if (myComputedMode) { myView->SetComputedMode (Standard_True); - Update(); } } else { myView->SetComputedMode (Standard_False); - Update(); } } diff --git a/src/ViewerTest/ViewerTest_ViewerCommands.cxx b/src/ViewerTest/ViewerTest_ViewerCommands.cxx index 02c113be66..20b1ed0c21 100644 --- a/src/ViewerTest/ViewerTest_ViewerCommands.cxx +++ b/src/ViewerTest/ViewerTest_ViewerCommands.cxx @@ -163,8 +163,6 @@ Aspect_Handle GetWindowHandle(const Handle(Aspect_Window)& theWindow) } #endif -static Standard_Boolean MyHLRIsOn = Standard_False; - NCollection_DoubleMap ViewerTest_myViews; static NCollection_DoubleMap ViewerTest_myContexts; static NCollection_DoubleMap ViewerTest_myDrivers; @@ -185,6 +183,7 @@ static struct //============================================================================== static int Start_Rot = 0; +Standard_Boolean HasHlrOnBeforeRotation = Standard_False; int X_Motion = 0; // Current cursor position int Y_Motion = 0; int X_ButtonPress = 0; // Last ButtonPress position @@ -717,7 +716,6 @@ TCollection_AsciiString ViewerTest::ViewerInit (const Standard_Integer thePxLeft // Set parameters for V3d_View and V3d_Viewer const Handle (V3d_View) aV3dView = ViewerTest::CurrentView(); aV3dView->SetComputedMode(Standard_False); - MyHLRIsOn = aV3dView->ComputedMode(); a3DViewer->SetDefaultBackgroundColor(Quantity_NOC_BLACK); if (toCreateViewer) @@ -850,76 +848,142 @@ static int VInit (Draw_Interpretor& theDi, Standard_Integer theArgsNb, const cha return 0; } +//! Parse HLR algo type. +static Standard_Boolean parseHlrAlgoType (const char* theName, + Prs3d_TypeOfHLR& theType) +{ + TCollection_AsciiString aName (theName); + aName.LowerCase(); + if (aName == "polyalgo") + { + theType = Prs3d_TOH_PolyAlgo; + } + else if (aName == "algo") + { + theType = Prs3d_TOH_Algo; + } + else + { + return Standard_False; + } + return Standard_True; +} + //============================================================================== //function : VHLR //purpose : hidden lines removal algorithm -//draw args: vhlr is_enabled={on|off} [show_hidden={1|0}] //============================================================================== static int VHLR (Draw_Interpretor& di, Standard_Integer argc, const char** argv) { - if (ViewerTest::CurrentView().IsNull()) + const Handle(V3d_View) aView = ViewerTest::CurrentView(); + const Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext(); + if (aView.IsNull()) { - di << argv[0] << ": Call vinit before this command, please.\n"; + std::cerr << "Error: No opened viewer!\n"; return 1; } - if (argc < 2) + Standard_Boolean hasHlrOnArg = Standard_False; + Standard_Boolean hasShowHiddenArg = Standard_False; + Standard_Boolean isHLROn = Standard_False; + Standard_Boolean toShowHidden = aCtx->DefaultDrawer()->DrawHiddenLine(); + Prs3d_TypeOfHLR aTypeOfHLR = Prs3d_TOH_NotSet; + ViewerTest_AutoUpdater anUpdateTool (Handle(AIS_InteractiveContext)(), aView); + for (Standard_Integer anArgIter = 1; anArgIter < argc; ++anArgIter) { - di << argv[0] << ": Wrong number of command arguments.\n" - << "Type help " << argv[0] << " for more information.\n"; - return 1; - } - - // Enable or disable HLR mode. - Standard_Boolean isHLROn = - (!strcasecmp (argv[1], "on")) ? Standard_True : Standard_False; - - if (isHLROn != MyHLRIsOn) - { - MyHLRIsOn = isHLROn; - ViewerTest::CurrentView()->SetComputedMode (MyHLRIsOn); - } - - // Show or hide hidden lines in HLR mode. - Standard_Boolean isCurrentShowHidden - = ViewerTest::GetAISContext()->DefaultDrawer()->DrawHiddenLine(); - - Standard_Boolean isShowHidden = - (argc == 3) ? (atoi(argv[2]) == 1 ? Standard_True : Standard_False) - : isCurrentShowHidden; - - - if (isShowHidden != isCurrentShowHidden) - { - if (isShowHidden) + TCollection_AsciiString anArg (argv[anArgIter]); + anArg.LowerCase(); + if (anUpdateTool.parseRedrawMode (anArg)) { - ViewerTest::GetAISContext()->DefaultDrawer()->EnableDrawHiddenLine(); + continue; + } + else if (anArg == "-showhidden" + && anArgIter + 1 < argc + && ViewerTest::ParseOnOff (argv[anArgIter + 1], toShowHidden)) + { + ++anArgIter; + hasShowHiddenArg = Standard_True; + continue; + } + else if ((anArg == "-type" + || anArg == "-algo" + || anArg == "-algotype") + && anArgIter + 1 < argc + && parseHlrAlgoType (argv[anArgIter + 1], aTypeOfHLR)) + { + ++anArgIter; + continue; + } + else if (!hasHlrOnArg + && ViewerTest::ParseOnOff (argv[anArgIter], isHLROn)) + { + hasHlrOnArg = Standard_True; + continue; + } + // old syntax + else if (!hasShowHiddenArg + && ViewerTest::ParseOnOff(argv[anArgIter], toShowHidden)) + { + hasShowHiddenArg = Standard_True; + continue; } else { - ViewerTest::GetAISContext()->DefaultDrawer()->DisableDrawHiddenLine(); + std::cout << "Syntax error at '" << argv[anArgIter] << "'\n"; + return 1; } - - // Redisplay shapes. - if (MyHLRIsOn) + } + if (!hasHlrOnArg) + { + di << "HLR: " << aView->ComputedMode() << "\n"; + di << "HiddenLine: " << aCtx->DefaultDrawer()->DrawHiddenLine() << "\n"; + di << "HlrAlgo: "; + switch (aCtx->DefaultDrawer()->TypeOfHLR()) { - AIS_ListOfInteractive aListOfShapes; - ViewerTest::GetAISContext()->DisplayedObjects (aListOfShapes); + case Prs3d_TOH_NotSet: di << "NotSet\n"; break; + case Prs3d_TOH_PolyAlgo: di << "PolyAlgo\n"; break; + case Prs3d_TOH_Algo: di << "Algo\n"; break; + } + anUpdateTool.Invalidate(); + return 0; + } - for (AIS_ListIteratorOfListOfInteractive anIter(aListOfShapes); anIter.More(); anIter.Next()) + Standard_Boolean toRecompute = Standard_False; + if (aTypeOfHLR != Prs3d_TOH_NotSet + && aTypeOfHLR != aCtx->DefaultDrawer()->TypeOfHLR()) + { + toRecompute = Standard_True; + aCtx->DefaultDrawer()->SetTypeOfHLR (aTypeOfHLR); + } + if (toShowHidden != aCtx->DefaultDrawer()->DrawHiddenLine()) + { + toRecompute = Standard_True; + if (toShowHidden) + { + aCtx->DefaultDrawer()->EnableDrawHiddenLine(); + } + else + { + aCtx->DefaultDrawer()->DisableDrawHiddenLine(); + } + } + + // redisplay shapes + if (aView->ComputedMode() && isHLROn && toRecompute) + { + AIS_ListOfInteractive aListOfShapes; + aCtx->DisplayedObjects (aListOfShapes); + for (AIS_ListIteratorOfListOfInteractive anIter (aListOfShapes); anIter.More(); anIter.Next()) + { + if (Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(anIter.Value())) { - Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (anIter.Value()); - if (aShape.IsNull()) - { - continue; - } - ViewerTest::GetAISContext()->Redisplay (aShape, Standard_False); + aCtx->Redisplay (aShape, Standard_False); } } } - ViewerTest::CurrentView()->Update(); + aView->SetComputedMode (isHLROn); return 0; } @@ -928,66 +992,95 @@ static int VHLR (Draw_Interpretor& di, Standard_Integer argc, const char** argv) //purpose : change type of using HLR algorithm //============================================================================== -static int VHLRType (Draw_Interpretor& di, Standard_Integer argc, const char** argv) +static int VHLRType (Draw_Interpretor& , Standard_Integer argc, const char** argv) { - if (ViewerTest::CurrentView().IsNull()) + const Handle(V3d_View) aView = ViewerTest::CurrentView(); + const Handle(AIS_InteractiveContext) aCtx = ViewerTest::GetAISContext(); + if (aView.IsNull()) { - di << argv[0] << ": Call vinit before this command, please.\n"; + std::cerr << "Error: No opened viewer!\n"; return 1; } - if (argc < 2) + Prs3d_TypeOfHLR aTypeOfHLR = Prs3d_TOH_NotSet; + ViewerTest_AutoUpdater anUpdateTool (Handle(AIS_InteractiveContext)(), aView); + AIS_ListOfInteractive aListOfShapes; + for (Standard_Integer anArgIter = 1; anArgIter < argc; ++anArgIter) { - di << argv[0] << ": Wrong number of command arguments.\n" - << "Type help " << argv[0] << " for more information.\n"; - return 1; - } - - Prs3d_TypeOfHLR aTypeOfHLR = - (!strcasecmp (argv[1], "algo")) ? Prs3d_TOH_Algo : Prs3d_TOH_PolyAlgo; - - if (argc == 2) - { - AIS_ListOfInteractive aListOfShapes; - ViewerTest::GetAISContext()->DisplayedObjects (aListOfShapes); - ViewerTest::GetAISContext()->DefaultDrawer()->SetTypeOfHLR(aTypeOfHLR); - for (AIS_ListIteratorOfListOfInteractive anIter(aListOfShapes); - anIter.More(); anIter.Next()) + TCollection_AsciiString anArg (argv[anArgIter]); + anArg.LowerCase(); + if (anUpdateTool.parseRedrawMode (anArg)) { - Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(anIter.Value()); - if (aShape.IsNull()) - continue; - if (aShape->TypeOfHLR() != aTypeOfHLR) - aShape->SetTypeOfHLR (aTypeOfHLR); - if (MyHLRIsOn) - ViewerTest::GetAISContext()->Redisplay (aShape, Standard_False); + continue; } - ViewerTest::CurrentView()->Update(); - return 0; - } - else - { - for (Standard_Integer i = 2; i < argc; ++i) + else if ((anArg == "-type" + || anArg == "-algo" + || anArg == "-algotype") + && anArgIter + 1 < argc + && parseHlrAlgoType (argv[anArgIter + 1], aTypeOfHLR)) + { + ++anArgIter; + continue; + } + // old syntax + else if (aTypeOfHLR == Prs3d_TOH_NotSet + && parseHlrAlgoType (argv[anArgIter], aTypeOfHLR)) + { + continue; + } + else { ViewerTest_DoubleMapOfInteractiveAndName& aMap = GetMapOfAIS(); - TCollection_AsciiString aName (argv[i]); - + TCollection_AsciiString aName (argv[anArgIter]); if (!aMap.IsBound2 (aName)) { - di << argv[0] << ": Wrong shape name:" << aName.ToCString() << ".\n"; - continue; + std::cout << "Syntax error: Wrong shape name '" << aName << "'.\n"; + return 1; } - Handle(AIS_Shape) anAISObject = - Handle(AIS_Shape)::DownCast (aMap.Find2(aName)); - if (anAISObject.IsNull()) - continue; - anAISObject->SetTypeOfHLR (aTypeOfHLR); - if (MyHLRIsOn) - ViewerTest::GetAISContext()->Redisplay (anAISObject, Standard_False); + + Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast (aMap.Find2 (aName)); + if (aShape.IsNull()) + { + std::cout << "Syntax error: '" << aName << "' is not a shape presentation.\n"; + return 1; + } + aListOfShapes.Append (aShape); + continue; } - ViewerTest::CurrentView()->Update(); + } + if (aTypeOfHLR == Prs3d_TOH_NotSet) + { + std::cout << "Syntax error: wrong number of arguments!\n"; + return 1; } + const Standard_Boolean isGlobal = aListOfShapes.IsEmpty(); + if (isGlobal) + { + aCtx->DisplayedObjects (aListOfShapes); + aCtx->DefaultDrawer()->SetTypeOfHLR (aTypeOfHLR); + } + + for (AIS_ListIteratorOfListOfInteractive anIter(aListOfShapes); anIter.More(); anIter.Next()) + { + Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast(anIter.Value()); + if (aShape.IsNull()) + { + continue; + } + + const bool toUpdateShape = aShape->TypeOfHLR() != aTypeOfHLR + && aView->ComputedMode(); + if (!isGlobal + || aShape->TypeOfHLR() != aTypeOfHLR) + { + aShape->SetTypeOfHLR (aTypeOfHLR); + } + if (toUpdateShape) + { + aCtx->Redisplay (aShape, Standard_False); + } + } return 0; } @@ -1030,13 +1123,10 @@ void ActivateView (const TCollection_AsciiString& theViewName) } ViewerTest::CurrentView (aView); - // Update degenerate mode - MyHLRIsOn = ViewerTest::CurrentView()->ComputedMode(); ViewerTest::SetAISContext (anAISContext); - TCollection_AsciiString aTitle = TCollection_AsciiString("3D View - "); - aTitle = aTitle + theViewName + "(*)"; + TCollection_AsciiString aTitle = TCollection_AsciiString("3D View - ") + theViewName + "(*)"; SetWindowTitle (ViewerTest::CurrentView()->Window(), aTitle.ToCString()); -#if defined(_WIN32) || defined(__WIN32__) +#if defined(_WIN32) VT_GetWindow() = Handle(WNT_Window)::DownCast(ViewerTest::CurrentView()->Window()); #elif defined(__APPLE__) && !defined(MACOSX_USE_GLX) VT_GetWindow() = Handle(Cocoa_Window)::DownCast(ViewerTest::CurrentView()->Window()); @@ -1390,9 +1480,9 @@ void VT_ProcessKeyPress (const char* buf_ret) else if (!strcasecmp (buf_ret, "H")) { // HLR - cout << "HLR" << endl; + std::cout << "HLR" << std::endl; aView->SetComputedMode (!aView->ComputedMode()); - MyHLRIsOn = aView->ComputedMode(); + aView->Redraw(); } else if (!strcasecmp (buf_ret, "P")) { @@ -1638,7 +1728,8 @@ void VT_ProcessButton1Release (Standard_Boolean theIsShift) void VT_ProcessButton3Press() { Start_Rot = 1; - if (MyHLRIsOn) + HasHlrOnBeforeRotation = ViewerTest::CurrentView()->ComputedMode(); + if (HasHlrOnBeforeRotation) { ViewerTest::CurrentView()->SetComputedMode (Standard_False); } @@ -1654,9 +1745,11 @@ void VT_ProcessButton3Release() if (Start_Rot) { Start_Rot = 0; - if (MyHLRIsOn) + if (HasHlrOnBeforeRotation) { + HasHlrOnBeforeRotation = Standard_False; ViewerTest::CurrentView()->SetComputedMode (Standard_True); + ViewerTest::CurrentView()->Redraw(); } } } @@ -11152,19 +11245,18 @@ void ViewerTest::ViewerCommands(Draw_Interpretor& theCommands) " ts, tt - translation for s and t texture coordinates\n" " rot - texture rotation angle in degrees", __FILE__, VTextureEnv, group); - theCommands.Add("vhlr" , - "is_enabled={on|off} [show_hidden={1|0}]" - " - Hidden line removal algorithm:" - " - is_enabled: if is on HLR algorithm is applied\n" - " - show_hidden: if equals to 1, hidden lines are drawn as dotted ones.\n", + theCommands.Add("vhlr", + "vhlr {on|off} [-showHidden={1|0}] [-algoType={algo|polyAlgo}] [-noupdate]" + "\n\t\t: Hidden Line Removal algorithm." + "\n\t\t: -showHidden if set ON, hidden lines are drawn as dotted ones" + "\n\t\t: -algoType type of HLR algorithm.\n", __FILE__,VHLR,group); - theCommands.Add("vhlrtype" , - "algo_type={algo|polyalgo} [shape_1 ... shape_n]" - " - Changes the type of HLR algorithm using for shapes." - " - algo_type: if equals to algo, exact HLR algorithm is applied;\n" - " if equals to polyalgo, polygonal HLR algorithm is applied." - "If shapes are not given HLR algoithm of given type is applied" - " to all shapes in the view\n", + theCommands.Add("vhlrtype", + "vhlrtype {algo|polyAlgo} [shape_1 ... shape_n] [-noupdate]" + "\n\t\t: Changes the type of HLR algorithm using for shapes:" + "\n\t\t: 'algo' - exact HLR algorithm is applied" + "\n\t\t: 'polyAlgo' - polygonal HLR algorithm is applied" + "\n\t\t: If shapes are not given - option is applied to all shapes in the view", __FILE__,VHLRType,group); theCommands.Add("vclipplane", "vclipplane planeName [{0|1}]" diff --git a/tests/bugs/vis/bug24388_1 b/tests/bugs/vis/bug24388_1 index 31458faf7c..9b0cbdae4e 100644 --- a/tests/bugs/vis/bug24388_1 +++ b/tests/bugs/vis/bug24388_1 @@ -13,7 +13,7 @@ vdisplay b vrotate 35 0 0 vfit vhlr on 1 -vhlrtype algo a +vhlrtype algo b vmoveto 76 304