From 81104a2af888d2b1c9fa6b2070b9592466feaa2b Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 29 Jan 2015 16:21:09 +0300 Subject: [PATCH] The files are not used anymore, the OCC bugs are fixed for the tested cases. --- src/PartSet/PartSet_TestOCC.cpp | 234 -------------------------------- src/PartSet/PartSet_TestOCC.h | 60 -------- 2 files changed, 294 deletions(-) delete mode 100644 src/PartSet/PartSet_TestOCC.cpp delete mode 100644 src/PartSet/PartSet_TestOCC.h diff --git a/src/PartSet/PartSet_TestOCC.cpp b/src/PartSet/PartSet_TestOCC.cpp deleted file mode 100644 index 57a1529a6..000000000 --- a/src/PartSet/PartSet_TestOCC.cpp +++ /dev/null @@ -1,234 +0,0 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: PartSet_TestOCC.h -// Created: 28 Apr 2014 -// Author: Natalia ERMOLAEVA - -#include - -#include -#include -#include -#include -#include - -#include -#include - -#include -#include - -static double myTestDelta; -static ResultPtr myTestObject; - -#include -#include -#include -#include -#include -#include -#include -#include - -void PartSet_TestOCC::testSelection(XGUI_Workshop* theWorkshop) -{ - if (!myTestObject) { - PartSet_TestOCC::createTestLine(theWorkshop); - PartSet_TestOCC::moveMouse(theWorkshop->viewer()->AISContext(), - theWorkshop->viewer()->activeView()); - PartSet_TestOCC::changeTestLine(theWorkshop); - } - std::shared_ptr anIO = theWorkshop->displayer()->getAISObject(myTestObject); - if (!anIO->empty()) { - theWorkshop->viewer()->AISContext()->MoveTo(0, 0, theWorkshop->viewer()->activeView()); - theWorkshop->viewer()->AISContext()->Select(0, 0, 2500, 2500, - theWorkshop->viewer()->activeView()); - } -} - -void PartSet_TestOCC::local_selection_change_shape(Handle_AIS_InteractiveContext theContext, - Handle_V3d_View theView) -{ - // 1. Create shape - gp_Pnt aPnt1(100, 100, 0); - gp_Pnt aPnt2(150, 300, 0); - TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge(aPnt1, aPnt2).Edge(); - - // 2. Display shape and activate it in the local context - Handle(AIS_Shape) anAIS = new AIS_Shape(anEdge); - if (!theContext->HasOpenedContext()) { - theContext->ClearCurrents(false); - theContext->OpenLocalContext(false/*use displayed objects*/, true/*allow shape decomposition*/); - } - theContext->Display(anAIS, false); - theContext->Load(anAIS, -1, true/*allow decomposition*/); - theContext->Activate(anAIS, AIS_Shape::SelectionMode(TopAbs_VERTEX)); - theContext->Activate(anAIS, AIS_Shape::SelectionMode(TopAbs_EDGE)); - - // 3. Change selection in the viewer - // emulate rectangle selection in the viewer - theContext->Select(0, 0, 2500, 2500, theView); - - // 3. Change the shape of AIS presentation - gp_Pnt aPnt3(-100, -100, 0); - gp_Pnt aPnt4(200, 200, 0); - TopoDS_Edge anEdge2 = BRepBuilderAPI_MakeEdge(aPnt3, aPnt4).Edge(); - anAIS->Set(anEdge2); - anAIS->Redisplay(Standard_True); - theContext->RecomputeSelectionOnly(anAIS); - - // 4. Check the current viewer selection - Handle(AIS_InteractiveContext) aContext = theContext; - bool isFirstLinePoint = false; - bool isShapeSelected = false; - for (aContext->InitSelected(); aContext->MoreSelected(); aContext->NextSelected()) { - TopoDS_Shape aShape = aContext->SelectedShape(); - if (aShape.ShapeType() == TopAbs_VERTEX) { - const TopoDS_Vertex& aVertex = TopoDS::Vertex(aShape); - if (!aVertex.IsNull()) { - gp_Pnt aPoint = BRep_Tool::Pnt(aVertex); - double aD_1 = aPoint.Distance(aPnt1); - double aD_2 = aPoint.Distance(aPnt2); - isFirstLinePoint = aD_1 < Precision::Confusion() || aD_2 < Precision::Confusion(); - } - } - } - if (isFirstLinePoint) - std::cout << "Error: The point of the first line should not be selected." << std::endl; -} - -void PartSet_TestOCC::local_selection_erase(Handle_AIS_InteractiveContext theContext, - Handle_V3d_View theView) -{ - // 1. Create shape - gp_Pnt aPnt1(100, 100, 0); - gp_Pnt aPnt2(150, 300, 0); - TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge(aPnt1, aPnt2).Edge(); - - // 2. Display shape and activate it in the local context - Handle(AIS_Shape) anAIS = new AIS_Shape(anEdge); - if (!theContext->HasOpenedContext()) { - theContext->ClearCurrents(false); - theContext->OpenLocalContext(false/*use displayed objects*/, true/*allow shape decomposition*/); - } - theContext->Display(anAIS, false); - theContext->Load(anAIS, -1, true/*allow decomposition*/); - theContext->Activate(anAIS, AIS_Shape::SelectionMode(TopAbs_VERTEX)); - theContext->Activate(anAIS, AIS_Shape::SelectionMode(TopAbs_EDGE)); - - // 3. Change selection in the viewer - // emulate rectangle selection in the viewer - theContext->Select(0, 0, 2500, 2500, theView); - - theContext->Erase(anAIS); -} - -void PartSet_TestOCC::createTestLine(XGUI_Workshop* theWorkshop) -{ - myTestDelta = 80; - - ModuleBase_Operation* anOperation = theWorkshop->operationMgr()->currentOperation(); - PartSet_OperationSketchBase* aPreviewOp = dynamic_cast(anOperation); - FeaturePtr aSketch; - - if (aPreviewOp) { - // create a line - std::shared_ptr aDoc = ModelAPI_Session::get()->moduleDocument(); - FeaturePtr aFeature = aDoc->addFeature(SketchPlugin_Line::ID()); - if (aFeature) // TODO: generate an error if feature was not created - aFeature->execute(); - - std::shared_ptr aSketch = std::dynamic_pointer_cast< - SketchPlugin_Feature>(aPreviewOp->sketch()); - aSketch->addSub(aFeature); - - PartSet_Tools::setFeaturePoint(aFeature, 100, 100, SketchPlugin_Line::START_ID()); - PartSet_Tools::setFeaturePoint(aFeature, 150, 300, SketchPlugin_Line::END_ID()); - - std::shared_ptr aPreview = PartSet_OperationSketchBase::preview(aFeature); - - XGUI_Displayer* aDisplayer = theWorkshop->displayer(); - - std::shared_ptr aPrevAIS; - std::shared_ptr aSPFeature = std::dynamic_pointer_cast< - SketchPlugin_Feature>(aFeature); - //std::shared_ptr anAIS = aSPFeature->getAISObject(aPrevAIS); - //if (!anAIS->empty()) - aDisplayer->display(aFeature, false); - //aDisplayer->redisplay(aFeature->firstResult(), anAIS, false); - - std::list aModes; - aModes.push_back(TopAbs_VERTEX); - aModes.push_back(TopAbs_EDGE); - aDisplayer->activateInLocalContext(aFeature->firstResult(), aModes, true); - - // change the line - /*double aDelta = -200; - for (int i = 0; i < 20; i++) { - aDelta = aDelta - i*2; - PartSet_Tools::setFeaturePoint(aFeature, 100+aDelta, 200+aDelta, SketchPlugin_Line::START_ID()); - PartSet_Tools::setFeaturePoint(aFeature, 300+aDelta, 500+aDelta, SketchPlugin_Line::END_ID()); - - std::shared_ptr aPreview = PartSet_OperationSketchBase::preview(aFeature); - Handle(AIS_InteractiveObject) anAIS = PartSet_Presentation::createPresentation( - aFeature, aSketch, - aPreview ? aPreview->impl() : TopoDS_Shape(), NULL); - if (!anAIS.IsNull()) - aDisplayer->redisplay(aFeature, anAIS, true); - - int aVal = 90; - for (int j = 0; j < 10000000; j++) - aVal = aVal/aVal+aVal*2; - }*/ - //std::list aModes; - //aModes.clear(); - //aModes.push_back(TopAbs_VERTEX); - //aModes.push_back(TopAbs_EDGE); - //aDisplayer->activateInLocalContext(aFeature, aModes, true); - myTestObject = aFeature->firstResult(); - - QList aFeatureList; - aFeatureList.append(myTestObject); - aDisplayer->setSelected(aFeatureList, true); - } -} - -void PartSet_TestOCC::changeTestLine(XGUI_Workshop* theWorkshop) -{ - // change the line - if (!myTestObject) - return; - ResultPtr aFeature = myTestObject; - - myTestDelta = myTestDelta - 50; - double aDelta = myTestDelta; - // TODO - //PartSet_Tools::setFeaturePoint(aFeature, -100/*aDelta*/, -100/*aDelta*/, LINE_ATTR_START); - //PartSet_Tools::setFeaturePoint(aFeature, 200/*aDelta*2*/, 200/*aDelta*2*/, LINE_ATTR_END); - //std::shared_ptr aPreview = PartSet_OperationSketchBase::preview(aFeature); - - std::shared_ptr aPrevAIS; - std::shared_ptr aSPFeature = std::dynamic_pointer_cast< - SketchPlugin_Feature>(aFeature); - //std::shared_ptr anAIS = aSPFeature->getAISObject(aPrevAIS); - //if (!anAIS->empty()) - theWorkshop->displayer()->display(aFeature, true); - // theWorkshop->displayer()->redisplay(aFeature, anAIS, true); - //std::list aModes; - //aModes.clear(); - //aModes.push_back(TopAbs_VERTEX); - //aModes.push_back(TopAbs_EDGE); - //aDisplayer->activateInLocalContext(aFeature, aModes, true); - - /*QFeatureList aFeatureList; - aFeatureList.append(myTestObject); - theWorkshop->displayer()->setSelected(aFeatureList, true);*/ - - theWorkshop->displayer()->updateViewer(); -} - -void PartSet_TestOCC::moveMouse(Handle(AIS_InteractiveContext) theContext, Handle(V3d_View) theView) -{ - theContext->MoveTo(10, 10, theView); - theContext->Select(); -} diff --git a/src/PartSet/PartSet_TestOCC.h b/src/PartSet/PartSet_TestOCC.h deleted file mode 100644 index 0b656eaca..000000000 --- a/src/PartSet/PartSet_TestOCC.h +++ /dev/null @@ -1,60 +0,0 @@ -// Copyright (C) 2014-20xx CEA/DEN, EDF R&D - -// File: PartSet_TestOCC.h -// Created: 28 Apr 2014 -// Author: Natalia ERMOLAEVA - -#ifndef PartSet_TestOCC_H -#define PartSet_TestOCC_H - -#include "PartSet.h" - -class XGUI_Workshop; -class Handle_AIS_InteractiveContext; -class Handle_V3d_View; - -/*! - \class PartSet_TestOCC - * \brief The operation to test OCC viewer work - */ -class PARTSET_EXPORT PartSet_TestOCC -{ - public: - PartSet_TestOCC() - { - } - ; - - /// Creates a line feature, select it, modify the line. Check whether the highlight is correct. - /// \param the workshop to provide an access to the application information - static void testSelection(XGUI_Workshop* theWorkshop); - - /// Creates row OCC presentation, activate in the local context, modify it and check selection - /// BUG: The result contains the selection from the first presentation - /// \param theContext a viewer interactive context - /// \param theContext a view - static void local_selection_change_shape(Handle_AIS_InteractiveContext theContext, - Handle_V3d_View theView); - - /// Creates row OCC presentation, activate in the local context, select it, erase the presentation - /// BUG: The selected shape are in the viewer even after erase - /// \param theContext a viewer interactive context - /// \param theContext a view - static void local_selection_erase(Handle_AIS_InteractiveContext theContext, - Handle_V3d_View theView); - - private: - - /// Creates a temporary line - /// \param the workshop to get the operation manager and the displayer - static void createTestLine(XGUI_Workshop* theWorkshop); - - /// Changes a temporary line - /// \param the workshop to get the operation manager and the displayer - static void changeTestLine(XGUI_Workshop* theWorkshop); - - /// Emulates the mouse moving in the viewer - static void moveMouse(Handle_AIS_InteractiveContext theContext, Handle_V3d_View theView); -}; - -#endif -- 2.39.2