From dd4eeef09743cafa61afc1b7afe7a5c6bdfe3ec7 Mon Sep 17 00:00:00 2001 From: azv Date: Wed, 20 Sep 2017 14:19:39 +0300 Subject: [PATCH] Sketcher: Avoid changing radius of circular edges while moving --- CMakeLists.txt | 3 +++ src/SketchPlugin/CMakeLists.txt | 15 ++++++++++----- src/SketchSolver/PlaneGCSSolver/CMakeLists.txt | 4 ++++ .../SketchSolver_ConstraintMovement.cpp | 6 ++++++ 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b7dbabea..4c423b4d4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,6 +82,9 @@ ELSE(${HAVE_SALOME}) SET(SHAPER_INSTALL_TUI_DOC doc CACHE INTERNAL "" FORCE) ENDIF(${HAVE_SALOME}) +# Sketcher: Change radius of circular edges while dragging a point on the edge +SET(SKETCHER_CHANGE_RADIUS_WHEN_MOVE FALSE) + ADD_SUBDIRECTORY (src/Config) ADD_SUBDIRECTORY (src/Events) ADD_SUBDIRECTORY (src/Model) diff --git a/src/SketchPlugin/CMakeLists.txt b/src/SketchPlugin/CMakeLists.txt index c22dad503..e5b9bc0ca 100644 --- a/src/SketchPlugin/CMakeLists.txt +++ b/src/SketchPlugin/CMakeLists.txt @@ -212,11 +212,6 @@ ADD_UNIT_TESTS(TestSketchPointLine.py TestTrimCircleAndArc01.py TestTrimLine01.py TestTrimLine02.py - TestMovePoint.py - TestMoveLine.py - TestMoveCircle.py - TestMoveArc.py - TestMovementComplex.py TestDistanceSignedVsUnsigned01.py TestDistanceSignedVsUnsigned02.py TestDistanceSignedVsUnsigned03.py @@ -225,3 +220,13 @@ ADD_UNIT_TESTS(TestSketchPointLine.py TestSignedDistancePointPoint.py TestSignedDistancePointLine.py ) + +if(${SKETCHER_CHANGE_RADIUS_WHEN_MOVE}) + ADD_UNIT_TESTS( + TestMovePoint.py + TestMoveLine.py + TestMoveCircle.py + TestMoveArc.py + TestMovementComplex.py + ) +endif() \ No newline at end of file diff --git a/src/SketchSolver/PlaneGCSSolver/CMakeLists.txt b/src/SketchSolver/PlaneGCSSolver/CMakeLists.txt index 081f3425c..722d0ed24 100644 --- a/src/SketchSolver/PlaneGCSSolver/CMakeLists.txt +++ b/src/SketchSolver/PlaneGCSSolver/CMakeLists.txt @@ -112,6 +112,10 @@ SET(PROJECT_SOURCES ${SKETCHSOLVER_CONSTRAINT_SOURCES} ) +if(${SKETCHER_CHANGE_RADIUS_WHEN_MOVE}) + ADD_DEFINITIONS(-DCHANGE_RADIUS_WHILE_MOVE) +endif() + ADD_LIBRARY(PlaneGCSSolver MODULE ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${SKETCHSOLVER_TEXT_RESOURCES}) TARGET_LINK_LIBRARIES(PlaneGCSSolver ${PROJECT_LIBRARIES} ${SKETCHSOLVER_LIBRARIES}) INSTALL(TARGETS PlaneGCSSolver DESTINATION ${SHAPER_INSTALL_PLUGIN_FILES}) diff --git a/src/SketchSolver/SketchSolver_ConstraintMovement.cpp b/src/SketchSolver/SketchSolver_ConstraintMovement.cpp index 94c6d7af1..f5d6df055 100644 --- a/src/SketchSolver/SketchSolver_ConstraintMovement.cpp +++ b/src/SketchSolver/SketchSolver_ConstraintMovement.cpp @@ -78,12 +78,14 @@ void SketchSolver_ConstraintMovement::process() static bool isSimpleMove(FeaturePtr theMovedFeature, AttributePtr theDraggedPoint) { bool isSimple = true; +#ifdef CHANGE_RADIUS_WHILE_MOVE if (theMovedFeature->getKind() == SketchPlugin_Circle::ID()) isSimple = (theDraggedPoint.get() != 0); else if (theMovedFeature->getKind() == SketchPlugin_Arc::ID()) { isSimple = (theDraggedPoint.get() != 0 && theDraggedPoint->id() == SketchPlugin_Arc::CENTER_ID()); } +#endif return isSimple; } @@ -213,7 +215,11 @@ void SketchSolver_ConstraintMovement::moveTo( double aDelta[2] = { theDestinationPoint->x() - myStartPoint->x(), theDestinationPoint->y() - myStartPoint->y() }; +#ifdef CHANGE_RADIUS_WHILE_MOVE int aMaxSize = mySimpleMove ? (int)myFixedValues.size() : 2; +#else + int aMaxSize = myMovedFeature->getKind() == SketchPlugin_Line::ID() && !myDraggedPoint ? 4 : 2; +#endif for (int i = 0; i < aMaxSize; ++i) myFixedValues[i] += aDelta[i % 2]; } -- 2.39.2