#include <XGUI_SelectionMgr.h>
#include <XGUI_ActionsMgr.h>
-#include <SketchPlugin_Feature.h>
-#include <SketchPlugin_Sketch.h>
#include <SketchPlugin_ConstraintAngle.h>
#include <SketchPlugin_ConstraintLength.h>
#include <SketchPlugin_ConstraintDistance.h>
#include <SketchPlugin_ConstraintParallel.h>
#include <SketchPlugin_ConstraintPerpendicular.h>
#include <SketchPlugin_ConstraintRadius.h>
+#include <SketchPlugin_Feature.h>
+#include <SketchPlugin_Projection.h>
+#include <SketchPlugin_Sketch.h>
#include <SketcherPrs_SymbolPrs.h>
#include <SketcherPrs_Coincident.h>
{
Handle(AIS_InteractiveObject) anAIS = theAIS->impl<Handle(AIS_InteractiveObject)>();
if (!anAIS.IsNull()) {
+ bool aToUseZLayer = false;
+ FeaturePtr aFeature = ModelAPI_Feature::feature(theObject);
+ if (aFeature.get() && PartSet_Tools::findRefsToMeFeature(aFeature,
+ SketchPlugin_Projection::ID()))
+ aToUseZLayer = true;
Handle(AIS_InteractiveContext) aCtx = anAIS->GetContext();
Handle(AIS_Dimension) aDim = Handle(AIS_Dimension)::DownCast(anAIS);
if (!aDim.IsNull()) {
- aCtx->SetZLayer(aDim, myVisualLayerId);
+ aToUseZLayer = true;
} else {
Handle(SketcherPrs_SymbolPrs) aCons = Handle(SketcherPrs_SymbolPrs)::DownCast(anAIS);
if (!aCons.IsNull())
- aCtx->SetZLayer(aCons, myVisualLayerId);
+ aToUseZLayer = true;
}
+ aCtx->SetZLayer(anAIS, myVisualLayerId);
}
}
#include <SketchPlugin_SketchEntity.h>
PartSet_PreviewSketchPlane::PartSet_PreviewSketchPlane()
- : myPreviewIsDisplayed(false)
+ : myPreviewIsDisplayed(false), mySizeOfView(0), myIsUseSizeOfView(false)
{
}
// selected linear face parameters
AttributeSelectionPtr aSelAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
(theSketch->data()->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
- if (aSelAttr)
+ if (aSelAttr) {
myShape = aSelAttr->value();
-
+ // this case is needed by constructing sketch on a plane, where result shape is equal
+ // to context result, therefore value() returns NULL and we should use shape of context.
+ if (!myShape.get() && aSelAttr->context().get())
+ myShape = aSelAttr->context()->shape();
+ }
if (!myShape.get()) {
// Create Preview for default planes
std::shared_ptr<GeomDataAPI_Point> anOrigin = std::dynamic_pointer_cast<GeomDataAPI_Point>(
theSketch->data()->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
std::shared_ptr<GeomDataAPI_Dir> aNormal = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
theSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID()));
- myShape = GeomAlgoAPI_FaceBuilder::squareFace(anOrigin->pnt(), aNormal->dir(),
- Config_PropManager::integer(SKETCH_TAB_NAME, "planes_size"));
+
+ double aFaceSize = myIsUseSizeOfView ? mySizeOfView
+ : Config_PropManager::integer(SKETCH_TAB_NAME, "planes_size");
+ myShape = GeomAlgoAPI_FaceBuilder::squareFace(anOrigin->pnt(), aNormal->dir(), aFaceSize);
}
myPlane = createPreviewPlane();
}
myPreviewIsDisplayed = true;
}
+void PartSet_PreviewSketchPlane::setSizeOfView(double theSizeOfView, bool isUseSizeOfView)
+{
+ mySizeOfView = theSizeOfView;
+ myIsUseSizeOfView = isUseSizeOfView;
+}
+
AISObjectPtr PartSet_PreviewSketchPlane::createPreviewPlane()
{
if (myPlane.get()) {
void createSketchPlane(const std::shared_ptr<ModelAPI_CompositeFeature>& theSketch,
ModuleBase_IWorkshop* theWorkshop);
+ /// Returns whether custom size of view is set
+ /// \return boolean value
+ bool isUseSizeOfView() const { return myIsUseSizeOfView; }
+
+ /// Sets the size of default created face
+ /// \param theSizeOfView value
+ /// \param isUseSizeOfView state whether the size should be used
+ void setSizeOfView(double theSizeOfView, bool isUseSizeOfView);
+
private:
/// Create a square face by parameters
std::shared_ptr<GeomAPI_AISObject> createPreviewPlane();
bool myPreviewIsDisplayed;
std::shared_ptr<GeomAPI_AISObject> myPlane; //! visualized presentation
std::shared_ptr<GeomAPI_Shape> myShape; //! current shape to be displayed
+
+ double mySizeOfView; //! size that should be used by creating a default face
+ bool myIsUseSizeOfView; //! state if the size is custom or from preferences
};
#endif
\ No newline at end of file
void PartSet_WidgetSketchCreator::activateSelectionControl()
{
+ // reset previously set size of view needed on restart extrusion after Sketch
+ if (myModule->sketchMgr()->previewSketchPlane()->isUseSizeOfView())
+ myModule->sketchMgr()->previewSketchPlane()->setSizeOfView(0, false);
+
// we need to call activate here as the widget has no focus accepted controls
// if these controls are added here, activate will happens automatically after focusIn()
XGUI_Workshop* aWorkshop = XGUI_Tools::workshop(myModule->workshop());
// Set View size if a plane is selected
if (myPreviewPlanes->isPreviewDisplayed() &&
myPreviewPlanes->isPreviewShape(aValue->shape())) {
+ // set default plane size
+ bool isSetSizeOfView = false;
+ double aSizeOfView = 0;
QString aSizeOfViewStr = mySizeOfView->text();
if (!aSizeOfViewStr.isEmpty()) {
- bool isOk;
- double aSizeOfView = aSizeOfViewStr.toDouble(&isOk);
- if (isOk && aSizeOfView > 0) {
- Handle(V3d_View) aView3d = myWorkshop->viewer()->activeView();
- if (!aView3d.IsNull()) {
- Bnd_Box aBndBox;
- double aHalfSize = aSizeOfView/2.0;
- aBndBox.Update(-aHalfSize, -aHalfSize, -aHalfSize, aHalfSize, aHalfSize, aHalfSize);
- aView3d->FitAll(aBndBox, 0.01, false);
- }
+ aSizeOfView = aSizeOfViewStr.toDouble(&isSetSizeOfView);
+ if (isSetSizeOfView && aSizeOfView <= 0) {
+ isSetSizeOfView = false;
}
}
+ if (isSetSizeOfView)
+ myModule->sketchMgr()->previewSketchPlane()->setSizeOfView(aSizeOfView, true);
}
// manually deactivation because the widget was not activated as has no focus acceptin controls
deactivate();
PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
if (aModule) {
CompositeFeaturePtr aSketch = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
+ bool isSetSizeOfView = false;
+ double aSizeOfView = 0;
+ QString aSizeOfViewStr = mySizeOfView->text();
+ if (!aSizeOfViewStr.isEmpty()) {
+ aSizeOfView = aSizeOfViewStr.toDouble(&isSetSizeOfView);
+ if (isSetSizeOfView && aSizeOfView <= 0) {
+ isSetSizeOfView = false;
+ }
+ }
+ if (isSetSizeOfView)
+ aModule->sketchMgr()->previewSketchPlane()->setSizeOfView(aSizeOfView, true);
aModule->sketchMgr()->previewSketchPlane()->createSketchPlane(aSketch, myWorkshop);
+ if (isSetSizeOfView)
+ aModule->sketchMgr()->previewSketchPlane()->setSizeOfView(aSizeOfView, false);
}
// 2. if the planes were displayed, change the view projection
const GeomShapePtr& aShape = thePrs->shape();
if (aRotate) {
myWorkshop->viewer()->setViewProjection(aXYZ.X(), aXYZ.Y(), aXYZ.Z(), aTwist);
}
- QString aSizeOfViewStr = mySizeOfView->text();
- if (!aSizeOfViewStr.isEmpty()) {
- bool isOk;
- double aSizeOfView = aSizeOfViewStr.toDouble(&isOk);
- if (isOk && aSizeOfView > 0) {
- Handle(V3d_View) aView3d = myWorkshop->viewer()->activeView();
- if (!aView3d.IsNull()) {
- Bnd_Box aBndBox;
- double aHalfSize = aSizeOfView/2.0;
- aBndBox.Update(-aHalfSize, -aHalfSize, -aHalfSize, aHalfSize, aHalfSize, aHalfSize);
- aView3d->FitAll(aBndBox, 0.01, false);
- }
- }
- }
PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
if (aModule)
aModule->onViewTransformed();
TestSignedDistancePointLine.py
Test2273.py
Test2280.py
+ Test2287.py
)
if(${SKETCHER_CHANGE_RADIUS_WHEN_MOVE})
if (aResult) {
aResult->setShape(aProjection->lastResult()->shape());
setResult(aResult);
- aProjection->selection(EXTERNAL_ID())->setValue(lastResult(), lastResult()->shape());
+ GeomShapePtr anEmptyVal;
+ aProjection->selection(EXTERNAL_ID())->setValue(lastResult(), anEmptyVal);
}
}
}
--- /dev/null
+## Copyright (C) 2014-2017 CEA/DEN, EDF R&D
+##
+## This library is free software; you can redistribute it and/or
+## modify it under the terms of the GNU Lesser General Public
+## License as published by the Free Software Foundation; either
+## version 2.1 of the License, or (at your option) any later version.
+##
+## This library is distributed in the hope that it will be useful,
+## but WITHOUT ANY WARRANTY; without even the implied warranty of
+## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+## Lesser General Public License for more details.
+##
+## You should have received a copy of the GNU Lesser General Public
+## License along with this library; if not, write to the Free Software
+## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+##
+## See http:##www.salome-platform.org/ or
+## email : webmaster.salome@opencascade.com<mailto:webmaster.salome@opencascade.com>
+##
+
+from salome.shaper import model
+
+model.begin()
+partSet = model.moduleDocument()
+Part_1 = model.addPart(partSet)
+Part_1_doc = Part_1.document()
+Sketch_1 = model.addSketch(Part_1_doc, model.defaultPlane("XOZ"))
+SketchLine_1 = Sketch_1.addLine(-20, -62, 81, 60)
+model.do()
+Sketch_2 = model.addSketch(Part_1_doc, model.defaultPlane("YOZ"))
+SketchProjection_1 = Sketch_2.addProjection(model.selection("EDGE", "Sketch_1/Edge-SketchLine_1"), True)
+SketchLine_2 = SketchProjection_1.createdFeature()
+model.do()
+Edge_1 = model.addEdge(Part_1_doc, [model.selection("EDGE", "Sketch_2/Edge-SketchProjection_1")])
+model.end()
+
+# before bug fix it was "Sketch_2"
+assert(Edge_1.baseObjects().value(0).namingName() == "Sketch_2/Edge-SketchProjection_1")
+
+assert(model.checkPythonDump())
(myConstraint->data()->attribute(SketchPlugin_ConstraintAngle::LOCATION_TYPE_ID()));
SketcherPrs_Tools::LocationType aLocationType = aLocAttr->isInitialized() ?
(SketcherPrs_Tools::LocationType)(aLocAttr->value()) : SketcherPrs_Tools::LOCATION_AUTOMATIC;
- updateArrows(myAspect, GetValue(), aTextSize, aLocationType);
+
+ double aRadius = myCenterPoint.Translated(
+ gp_Vec(myCenterPoint, myFirstPoint).Normalized()*aDist).Distance(myCenterPoint);
+ double anAngleValue = myValue.myDoubleValue;
+ double anAngleCircleLength = aRadius * anAngleValue * PI / 180.;
+
+ updateArrows(myAspect, anAngleCircleLength, aTextSize, aLocationType);
AIS_AngleDimension::Compute(thePresentationManager, thePresentation, theMode);
#include <SketchPlugin_ConstraintTangent.h>
#include <SketchPlugin_ConstraintPerpendicular.h>
-#include <BRepExtrema_ExtPC.hxx>
#include <TopoDS_Vertex.hxx>
#include <Geom_Curve.hxx>
+#include <GeomAPI_ProjectPointOnCurve.hxx>
#include <TColGeom_SequenceOfCurve.hxx>
#include <gp_Dir.hxx>
std::shared_ptr<GeomAPI_Curve>(new GeomAPI_Curve(aShape));
if (aCurve->isCircle()) {
- GeomEdgePtr aEdgePtr(new GeomAPI_Edge(aShape));
- GeomVertexPtr aVertexPtr(new GeomAPI_Vertex(theP.X(), theP.Y(), theP.Z()));
- BRepExtrema_ExtPC aExtrema(aVertexPtr->impl<TopoDS_Vertex>(),
- aEdgePtr->impl<TopoDS_Edge>());
- int aNb = aExtrema.NbExt();
- if (aNb > 0) {
- for (int i = 1; i <= aNb; i++) {
- if (aExtrema.IsMin(i)) {
- double aParam = aExtrema.Parameter(i);
- Handle(Geom_Curve) aCurv = aCurve->impl<Handle_Geom_Curve>();
- gp_Pnt aP;
- aCurv->D1(aParam, aP, aVec);
- break;
- }
- }
- }
+ Handle(Geom_Curve) aCurv = aCurve->impl<Handle_Geom_Curve>();
+ GeomAPI_ProjectPointOnCurve anExtr(theP, aCurv);
+ double aParam = anExtr.LowerDistanceParameter();
+ gp_Pnt aP;
+ aCurv->D1(aParam, aP, aVec);
} else {
GeomPointPtr aPnt1 = aCurve->getPoint(aCurve->endParam());
GeomPointPtr aPnt2 = aCurve->getPoint(aCurve->startParam());
#include <TColStd_MapIteratorOfMapOfTransient.hxx>
#ifdef TINSPECTOR
-#include <VInspectorAPI_CallBack.hxx>
+#include <inspector/VInspectorAPI_CallBack.hxx>
#endif
#include <Events_Loop.h>
/// \param theParent the parent to be deleted when the parent is deleted
/// \param theOperationMgr the class to perform deletion
XGUI_ShortCutListener(QObject* theParent, XGUI_OperationMgr* theOperationMgr)
- : QObject(theParent), myOperationMgr(theOperationMgr)
+ : QObject(theParent), myOperationMgr(theOperationMgr), myIsActive(false)
{
qApp->installEventFilter(this);
}
#include <SelectMgr_ListIteratorOfListOfFilter.hxx>
#ifdef TINSPECTOR
-#include <VInspectorAPI_CallBack.hxx>
+#include <inspector/VInspectorAPI_CallBack.hxx>
#endif
XGUI_SelectionMgr::XGUI_SelectionMgr(XGUI_Workshop* theParent)
#ifdef TINSPECTOR
#include <CDF_Session.hxx>
#include <CDF_Application.hxx>
-#include <TInspector_Communicator.hxx>
-#include <VInspector_CallBack.hxx>
+#include <inspector/TInspector_Communicator.hxx>
+#include <inspector/VInspector_CallBack.hxx>
static TInspector_Communicator* MyTCommunicator;
static Handle(VInspector_CallBack) MyVCallBack;