Commit Graph

161 Commits

Author SHA1 Message Date
Benjamin Nauck
ea5bfc4d32 Measure: Use constant for Type::BadType instead Type::badType() 2025-02-24 08:30:18 +01:00
Joao Matos
aace8f7bee CMake: Modernize build files using outdated Python variables. 2025-02-16 10:21:26 -06:00
GS-GOAT
afe122738f Measurement: save 'Show Delta' state between commands #19204 (#19430)
* Measurement: save 'Show Delta' state between commands #19204

When users set Show Delta option to off in the Measure tool, the setting
was not being preserved when the tool was invoked again. This was due to    
using an uninitialized value as the default when loading the preference.  

Changes staged in: FreeCAD\src\Mod\Measure\Gui\TaskMeasure.cpp 

Fixed by:
- Using explicit 'true' as default value when loading Show Delta
preference 
- Maintains existing save functionality
- Ensures consistent behavior on first use
Fixes #19204

* Changed few things to ensure the delta state is saved #19204

added changes:-
1. settings.endGroup()
When we call beginGroup(), it creates a prefix for all subsequent settings operations, All settings will be stored under the "TaskMeasure" group.
endGroup() is needed to close this grouping scope
Without it, subsequent settings operations would still use the "TaskMeasure" prefix

2. settings.sync()
By default, QSettings caches changes in memory and writes them to disk later
sync() makes an immediate write to the settings file
This ensures the setting is saved right away rather than waiting for Qt to decide when to save.
Makes the setting change immediately available for future commands.

-Fixes Measurement: save 'Show Delta' state between commands #19204

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Added proposed changes to autoSaveChanged() and newMeasurementBehaviourChanged() functions #19204 #19430

Added settings.endGroup() to the following functions:-
1.autoSaveChanged()
2.newMeasurementBehaviourChanged() 
Each beginGroup() should be followed by endGroup().

No need for explicitily calling sync() as it is called automatically from QSettings's destructor and by the event loop at regular intervals.(Refer documentation for more info)

-Fixes Measurement: save 'Show Delta' state between commands #19204 #19430

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2025-02-11 13:10:53 -06:00
Chris Hennes
a3004c2c0a Merge pull request #19142 from hyarion/refactor/add-template-addobject
Add new addObject<T>() function
2025-02-11 09:42:47 -06:00
Benjamin Nauck
edb4817872 Mod: Use new addObject<T>(...) that requires additional changes 2025-02-10 18:35:38 +01:00
Benjamin Nauck
f1ab1ee0ad Mod: Fix mistakes in type system class names 2025-02-10 18:33:00 +01:00
Benjamin Bræstrup Sayoc
b0b62f3f26 Measure: Use QStringLiteral 2025-02-10 18:32:45 +01:00
tritao
551c2e48fb Gui: Reorganize the selection files into a top Selection folder. 2025-02-03 17:56:57 +01:00
panintended
0511a4d04d QuickMeasure: display correct angle units
Add angle unit user string getter, fix typos for length unit equivalent

Fixes #19307
2025-01-30 15:48:30 +01:00
luzpaz
d982743b70 Fix typos
Found via codespell
2025-01-29 08:31:01 +01:00
Benjamin Nauck
97bf3c5e33 Manual changes to improve isDerivedFrom usage 2025-01-27 16:08:19 +01:00
Benjamin Nauck
6f535f19fb Prefer to use BaseClass's isDerivedFrom<T> over non template or Base::Type's
Regex based changes, manually verified
2025-01-27 16:08:18 +01:00
Chris Hennes
8c3bb779fb Merge pull request #19019 from hyarion/refactor/countObjectsOfType
Refactor countObjectsOfType in selection and document
2025-01-14 16:05:12 -06:00
Benjamin Nauck
08fe94ef25 Add template based Document::countObjectsOfType
Also convert code to use this new method
2025-01-14 14:23:46 +01:00
wandererfan
dc77ba60b1 [TD]use transformShape instead of transformGeometry 2025-01-13 21:14:10 -06:00
WandererFan
f144a87539 [TD]Long and link dim refs (fix #13375) (#18641)
* [Meas]Changes for TD dimension refs for links

* [TD]App changes for dim refs to links

* [TD]Gui changes for dim refs to links

* [TD]fix 2 lint messages

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-12-23 17:36:22 -05:00
Chris Hennes
bca4b4f743 Measure: Pass empty arg to QStringLiteral macro
Silences compiler warning about missing expected macro argument (MSVC warning C4003).
2024-12-23 17:55:15 +01:00
Ladislav Michl
0b3adee2ab Base: Quantity: return std::string 2024-12-23 17:48:42 +01:00
Ladislav Michl
379d7ea9d5 Base: Units: return std::string 2024-12-23 17:48:42 +01:00
luzpaz
b0a29fde31 Fix various typos 2024-12-22 08:47:13 -05:00
Murmele
037a46ec70 Add possiblity to autosave current measurement and restarting new measurement (#17717)
* initial commit to implement more interactive measurement functionality

Files: TaskMeasure.cpp and TaskMeasure.h

* Enable artifacts for easy download

Files: sub_buildWindows.yml

* clearSelection before setting new selection

Files: TaskMeasure.cpp

* No need for mSkipSelectionChange

Reason/Description: Because the next onSelectionChanged will be triggered asynchronly
Files: TaskMeasure.cpp and TaskMeasure.h

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* block selection

* Block selection must be done on the taskMeasure, because it is the signal observer

* Set autosave to false by default

Reason/Description: Because the measurement tool is intended to be a temporary tool
Files: TaskMeasure.cpp and TaskMeasure.h

* Add tooltip

Files: TaskMeasure.cpp

* No need to set the selection style

Reason: Because it was changed to normal, so no need to re set it
Files: TaskMeasure.cpp

* No need to clear and reset the selection

Reason/Description: Because it will be done directly in the application. It was required with greedy selection, but now it is anymore required
Files: TaskMeasure.cpp

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Revert "Enable artifacts for easy download"

This reverts commit 8118323ab4104ada1fb89eebbe72965c5f2f2b67.

* Move autosave and selection mode into a group box and add a possibility to hide those options

Files: TaskMeasure.cpp and TaskMeasure.h

* Use toolbutton with a normal menu instead of a normal QPushButton

Reason/Description: Because it integrates much better
Files: TaskMeasure.cpp and TaskMeasure.h

* QAction uses a bool for the checkstate

Files: TaskMeasure.cpp and TaskMeasure.h

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fix compile warnings

Reason/Description: cleanup and fix warnings
Files: TaskMeasure.cpp and TaskMeasure.h

* Add better tool tip

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* fix typo

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-12-09 11:08:02 -06:00
luzpaz
a633be7342 Fix various typos
Found via codespell.
2024-11-15 20:18:46 +01:00
PaddleStroke
96c1e86e5d Measure: Fix quickmeasure problem with Part::Line objects 2024-11-11 18:17:36 +01:00
wmayer
4e1023cda1 Measure: When measuring the distance between circles then use the center points as reference
See forum: https://forum.freecad.org/viewtopic.php?t=91570
2024-10-23 21:52:37 +02:00
pre-commit-ci[bot]
bec354d602 [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2024-10-22 22:37:01 -05:00
wmayer
c2a923a027 Measure: Use Base::toDegrees to convert radian to degree 2024-10-22 22:37:01 -05:00
hlorus
bae847a18d MeasureGui: Revert temporary measure object creation (#17109)
* MeasureGui: Revert temporary measure object creation

Reverts the temporary creation of measurement objects that was added in #15122

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* MeasureGui: Adress review comments

- Remove _mDocument and _mGuiDocument
- Replace c-style casts with dynamic_cast
- Add file guard
- Remove leftover canAnnotate method

* MeasureGui: Fix crash when selecting elements from different documents

* MeasureGui: Add additional type check in ensureGroup

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-10-14 17:54:13 +02:00
Eric Price
29a4f08ed3 Changed QuickMeasurement to be conservative (#17060)
* Changed QuickMeasurement to be conservative

QuickMeasurement should not measure while tool dialogs are open
this includes but is not limited to editing sketches
also changed several other sanity checks to be opt-in vs opt-out, as discussed.

* move the test if it is safe to measure to when the measurement actually happens - avoids any potential race conditions
2024-10-07 08:33:31 -05:00
PaddleStroke
c6e4f8a946 QuickMeasure: Prevent crash by limiting selection to Part::Features (#16921)
* QuickMeasure: Prevent crash by limiting selection to Part::Features

* chennes' fix

Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org>

---------

Co-authored-by: Chris Hennes <chennes@pioneerlibrarysystem.org>
2024-10-03 09:49:09 -05:00
Benjamin Nauck
dbeeb1534a Fix macos crashes when unhandled exceptions reaches qt 2024-10-02 21:11:41 -06:00
hlorus
299c27ab12 MeasureGui: Also hide delta measurements 2024-09-30 18:24:19 +02:00
hlorus
d186909f20 MeasureGui: Remove leftover reset of _mMeasureObject
This was introduced in af9097ce87 due to a faulty resolve of a merge conflict
2024-09-30 18:22:58 +02:00
Eric Price
dc6799fb7c Measurement: Avoid null shapes to be returned in all code branches (Fix #16820)
Returning a null shape would have triggered an exception in the bottom branch but not in the top one - which later leads to a segfault - solution - raise an exception. OOC doesn't like null shapes.
2024-09-25 12:29:48 -05:00
Eric Price
2ef683e56f Measurement: Correctly handle unknown selections to avoid segfaults (Fix 16794)
The measurement code did not handle mixed selections of known and unknown types correctly. Although a unknown selected object would leave the type at Invalid, selecting both known and unknown objects would have the type determined by the known object type and treat the unknown as the same. This causes exceptions and - worst case a segmentation fault.

This fix introduces a new category "other" which - if present in a selection always forces type to Invalid. This should be forward compatible in case new types are introduced in the future.
2024-09-25 07:48:56 -05:00
hlorus
fd83f98c26 MeasureGui: Move _mMeasureType member to local variable
Fixes #16565
2024-09-22 20:34:45 -05:00
PaddleStroke
81d3690397 Measure: Fix quickmeasure globalplacement. 2024-09-19 08:47:57 -05:00
hlorus
8fb03c0583 MeasureGui: Auto close task on document deletion 2024-09-18 13:03:56 -05:00
Benjamin Bræstrup Sayoc
a76143b4ca Revert "[Measure] Fix redundant variable assignment"
Fixes #16564. This reverts commit a7831eee4b.

Co-authored-by: Murmele <Murmele@users.noreply.github.com>
2024-09-18 08:36:22 -05:00
Benjamin Bræstrup Sayoc
b0928cf115 [Measure] Redirect enter key press to apply button
Fixes #16401. Now call of the save function is dependent on whether the apply button is enabled. The button is only enabled if valid objects to save.
2024-09-12 16:23:17 +02:00
Benjamin Bræstrup Sayoc
b64cd15535 [Measure] Fix redundant variable assignment 2024-09-12 16:17:29 +02:00
Murmele
f7d5d9f0d8 Measure: Show delta option also in interactive mode (#16379)
* Initial commit to apply delta also for interactive measurement
* Not required special logic to check if possible, it can be easily checked if the property exists
* remember setting so it is not required to turn it always on
2024-09-09 21:39:27 -05:00
Syres916
1fc508651b [Measure] Disable QuickMeasure for TechDraw, Spreadsheet, Part Container and Origin objects (#16225)
* [Measure] Disable QuickMeasure for TechDraw objects
* [Measure] Add spreadsheet, Part containers and origins to the exemptions
2024-09-08 16:50:26 -05:00
hlorus
b07b257542 Measure: Fix crash when removing referenced element
Also improve error messages
Fixes #16183
2024-09-02 12:39:05 -04:00
mosfet80
66878494a8 clean Measurement.cpp
clean Measurement.cpp
2024-09-02 18:04:24 +02:00
hlorus
979ca3bbd1 [MeasureGui] Use temporary measure object creation (#15122)
* MeasureGui: Store measure type in TaskMeasure

* MeasureGui: Avoid adding measurement to document during command interaction

* [Gui] Add check for document in VPDocumentObject::getActiveView

* MeasureGui: Track the document when adding objects

* MeasureGui: Cleanup python measurement creation

* [Gui] Add isAnnotationViewProvider method

* [Gui] Check if viewprovider is added as an annotation in getActiveView

* [Gui] Add takeAnnotationViewprovider method to Gui::Document

* [Gui] Make addViewProvider public

* [MeasureGui] Add existing view provider to document when storing measurement

* [MeasureGui] Fix invocation of initial label placement

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-09-02 11:54:05 -04:00
pre-commit-ci[bot]
010e6872be [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2024-08-26 23:55:17 +02:00
pre-commit-ci[bot]
7c6b8cc9ab [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
2024-08-25 11:42:43 +00:00
wmayer
7cf6c4f5df Measure: Prepare for clang-format 2024-08-25 13:39:38 +02:00
luzpaz
b2f549f114 Measure: fix linting TaskMeasure.cpp
Adds missing whitespace before opening brackets (observed in #15907)
2024-08-22 18:54:45 -05:00
hlorus
5d38aed6e8 MeasureGui: Return the relative label offset for the initial position 2024-08-19 12:25:05 -04:00