#include <XGUI_Workshop.h>
#include <XGUI_OperationMgr.h>
#include <XGUI_Displayer.h>
-#include <XGUI_ViewerPrs.h>
#include <XGUI_ViewerProxy.h>
-#include <PartSet_OperationSketchLine.h>
-#include <PartSet_Presentation.h>
+#include <PartSet_Tools.h>
+#include <PartSet_OperationSketchBase.h>
+#include <ModuleBase_ViewerPrs.h>
#include <ModelAPI_Feature.h>
#include <SketchPlugin_Line.h>
#include <ModelAPI_Document.h>
static double myTestDelta;
-static boost::shared_ptr<ModelAPI_Feature> myTestFeature;
+static ResultPtr myTestObject;
#include <AIS_InteractiveContext.hxx>
#include <AIS_Shape.hxx>
void PartSet_TestOCC::testSelection(XGUI_Workshop* theWorkshop)
{
- if (!myTestFeature) {
+ if (!myTestObject) {
PartSet_TestOCC::createTestLine(theWorkshop);
PartSet_TestOCC::moveMouse(theWorkshop->viewer()->AISContext(),
theWorkshop->viewer()->activeView());
PartSet_TestOCC::changeTestLine(theWorkshop);
}
- Handle(AIS_InteractiveObject) anIO = theWorkshop->displayer()->getAISObject(myTestFeature);
- if (!anIO.IsNull()) {
+ boost::shared_ptr<GeomAPI_AISObject> 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());
}
ModuleBase_Operation* anOperation = theWorkshop->operationMgr()->currentOperation();
PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
- boost::shared_ptr<ModelAPI_Feature> aSketch;
+ FeaturePtr aSketch;
if (aPreviewOp) {
// create a line
boost::shared_ptr<ModelAPI_Document> aDoc = ModelAPI_PluginManager::get()->rootDocument();
- boost::shared_ptr<ModelAPI_Feature> aFeature = aDoc->addFeature(
- PartSet_OperationSketchLine::Type().c_str());
+ FeaturePtr aFeature = aDoc->addFeature(SketchPlugin_Line::ID());
if (aFeature) // TODO: generate an error if feature was not created
aFeature->execute();
boost::dynamic_pointer_cast<SketchPlugin_Feature>(aPreviewOp->sketch());
aSketch->addSub(aFeature);
- PartSet_OperationSketchLine::setLinePoint(aFeature, 100, 100, LINE_ATTR_START);
- PartSet_OperationSketchLine::setLinePoint(aFeature, 150, 300, LINE_ATTR_END);
+ PartSet_Tools::setFeaturePoint(aFeature, 100, 100, SketchPlugin_Line::START_ID());
+ PartSet_Tools::setFeaturePoint(aFeature, 150, 300, SketchPlugin_Line::END_ID());
- boost::shared_ptr<GeomAPI_Shape> aPreview = PartSet_OperationSketchLine::preview(aFeature);
+ boost::shared_ptr<GeomAPI_Shape> aPreview = PartSet_OperationSketchBase::preview(aFeature);
XGUI_Displayer* aDisplayer = theWorkshop->displayer();
- Handle(AIS_InteractiveObject) anAIS = PartSet_Presentation::createPresentation(
- aFeature, aSketch,
- aPreview ? aPreview->impl<TopoDS_Shape>() : TopoDS_Shape(), NULL);
- if (!anAIS.IsNull())
- aDisplayer->redisplay(aFeature, anAIS, -1, false);
+ boost::shared_ptr<GeomAPI_AISObject> aPrevAIS;
+ boost::shared_ptr<SketchPlugin_Feature> aSPFeature =
+ boost::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
+ //boost::shared_ptr<GeomAPI_AISObject> anAIS = aSPFeature->getAISObject(aPrevAIS);
+ //if (!anAIS->empty())
+ aDisplayer->display(aFeature, false);
+ //aDisplayer->redisplay(aFeature->firstResult(), anAIS, false);
std::list<int> aModes;
aModes.push_back(TopAbs_VERTEX);
aModes.push_back(TopAbs_EDGE);
- aDisplayer->activateInLocalContext(aFeature, aModes, true);
+ aDisplayer->activateInLocalContext(aFeature->firstResult(), aModes, true);
// change the line
/*double aDelta = -200;
for (int i = 0; i < 20; i++) {
aDelta = aDelta - i*2;
- PartSet_OperationSketchLine::setLinePoint(aFeature, 100+aDelta, 200+aDelta, LINE_ATTR_START);
- PartSet_OperationSketchLine::setLinePoint(aFeature, 300+aDelta, 500+aDelta, LINE_ATTR_END);
+ PartSet_Tools::setFeaturePoint(aFeature, 100+aDelta, 200+aDelta, SketchPlugin_Line::START_ID());
+ PartSet_Tools::setFeaturePoint(aFeature, 300+aDelta, 500+aDelta, SketchPlugin_Line::END_ID());
- boost::shared_ptr<GeomAPI_Shape> aPreview = PartSet_OperationSketchLine::preview(aFeature);
+ boost::shared_ptr<GeomAPI_Shape> aPreview = PartSet_OperationSketchBase::preview(aFeature);
Handle(AIS_InteractiveObject) anAIS = PartSet_Presentation::createPresentation(
aFeature, aSketch,
aPreview ? aPreview->impl<TopoDS_Shape>() : TopoDS_Shape(), NULL);
if (!anAIS.IsNull())
- aDisplayer->redisplay(aFeature, anAIS, -1, true);
+ aDisplayer->redisplay(aFeature, anAIS, true);
int aVal = 90;
for (int j = 0; j < 10000000; j++)
//aModes.push_back(TopAbs_VERTEX);
//aModes.push_back(TopAbs_EDGE);
//aDisplayer->activateInLocalContext(aFeature, aModes, true);
- myTestFeature = aFeature;
+ myTestObject = aFeature->firstResult();
- std::list<XGUI_ViewerPrs> aPrs;
- aPrs.push_back(XGUI_ViewerPrs(myTestFeature, TopoDS_Shape(), NULL));
- aDisplayer->setSelected(aPrs, true);
+ QResultList aFeatureList;
+ aFeatureList.append(myTestObject);
+ aDisplayer->setSelected(aFeatureList, true);
}
}
void PartSet_TestOCC::changeTestLine(XGUI_Workshop* theWorkshop)
{
// change the line
- if (!myTestFeature)
+ if (!myTestObject)
return;
- boost::shared_ptr<ModelAPI_Feature> aFeature = myTestFeature;
+ ResultPtr aFeature = myTestObject;
myTestDelta = myTestDelta - 50;
double aDelta = myTestDelta;
- PartSet_OperationSketchLine::setLinePoint(aFeature, -100/*aDelta*/, -100/*aDelta*/, LINE_ATTR_START);
- PartSet_OperationSketchLine::setLinePoint(aFeature, 200/*aDelta*2*/, 200/*aDelta*2*/, LINE_ATTR_END);
- boost::shared_ptr<GeomAPI_Shape> aPreview = PartSet_OperationSketchLine::preview(aFeature);
-
- Handle(AIS_InteractiveObject) aPrevAIS;
- boost::shared_ptr<ModelAPI_Feature> aSketch;//NULL
- Handle(AIS_InteractiveObject) anAIS = PartSet_Presentation::createPresentation(
- aFeature, aSketch,
- aPreview ? aPreview->impl<TopoDS_Shape>() : TopoDS_Shape(),
- aPrevAIS);
- if (!anAIS.IsNull())
- theWorkshop->displayer()->redisplay(aFeature, anAIS, -1, true);
+ // 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);
+ //boost::shared_ptr<GeomAPI_Shape> aPreview = PartSet_OperationSketchBase::preview(aFeature);
+
+ boost::shared_ptr<GeomAPI_AISObject> aPrevAIS;
+ boost::shared_ptr<SketchPlugin_Feature> aSPFeature =
+ boost::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
+ //boost::shared_ptr<GeomAPI_AISObject> anAIS = aSPFeature->getAISObject(aPrevAIS);
+ //if (!anAIS->empty())
+ theWorkshop->displayer()->display(aFeature, true);
+ // theWorkshop->displayer()->redisplay(aFeature, anAIS, true);
//std::list<int> aModes;
//aModes.clear();
//aModes.push_back(TopAbs_VERTEX);
//aModes.push_back(TopAbs_EDGE);
//aDisplayer->activateInLocalContext(aFeature, aModes, true);
- /*std::list<XGUI_ViewerPrs> aPrs;
- aPrs.push_back(XGUI_ViewerPrs(myTestFeature, TopoDS_Shape()));
- theWorkshop->displayer()->setSelected(aPrs, true);*/
+ /*QFeatureList aFeatureList;
+ aFeatureList.append(myTestObject);
+ theWorkshop->displayer()->setSelected(aFeatureList, true);*/
theWorkshop->displayer()->updateViewer();
}
{
theContext->MoveTo(10, 10, theView);
theContext->Select();
-}
\ No newline at end of file
+}