Commit Graph

31 Commits

Author SHA1 Message Date
pre-commit-ci[bot]
9fe130cd73 All: Reformat according to new standard 2025-11-11 13:49:01 +01:00
Markus Reitböck
a72a0d6405 Gui: use CMake to generate precompiled headers on all platforms
"Professional CMake" book suggest the following:

"Targets should build successfully with or without compiler support for precompiled headers. It
should be considered an optimization, not a requirement. In particular, do not explicitly include a
precompile header (e.g. stdafx.h) in the source code, let CMake force-include an automatically
generated precompile header on the compiler command line instead. This is more portable across
the major compilers and is likely to be easier to maintain. It will also avoid warnings being
generated from certain code checking tools like iwyu (include what you use)."

Therefore, removed the "#include <PreCompiled.h>" from sources, also
there is no need for the "#ifdef _PreComp_" anymore
2025-09-14 09:47:03 +02:00
tetektoza
7d4e704030 Gui: Don't use this pointer after valueChanged in EditableDatumLabel
Simple fix for such a simple error I didn't see. Basically,
`valueChanged` signal can result in EditableDatumLabel being deleted
(for example, when we are on the last OVP and all of the OVPs have been
accepted). This could result in crashes as reported in previous issues,
because just after emitting this signal we were trying to use `this` pointer,
which wasn't available anymore as we deleted EditableDatumLabel obj that
was attached to it, so in essence we were dereferencing some random
address.

Fix for that is simple - move the check for `hasFinishedEditing` flag to
check locked appearance in `validateAndFinish` lambda, as it already
does validation and this way we will avoid referencing internals (which
could be deallocated) after emitting this signal.
2025-08-19 19:33:20 -05:00
mosfet80
6503d22fe7 Clean EditableDatumLabel.cpp
removed unused variable
2025-06-28 19:05:06 -05:00
tetektoza
625458f119 Sketcher: Make TAB clear the field if user hasn't valid input 2025-06-23 19:25:57 +02:00
tetektoza
b330a9399f Sketcher: Make TAB lock the label if user has typed previously 2025-06-21 13:48:12 +02:00
tetektoza
de966ae5be Sketcher: Initialize lock icon only once 2025-06-21 12:46:27 +02:00
tetektoza
cc207edb1a Sketcher: Change enter behavior on OVP to put OVP in lock state only
This patch adds/changes a couple of things:
* if you press enter on a label now, it moves you to another label and
  adds the label and lock on the previous label, instead of previous behavior
  where it was accepting whole dimension
* if you press enter and have lock state on both labels then you move to
  next stage
* if you press ctrl+enter it's as is if you'd press enter on both labels
  (the object becomes constrained with whatever dimensions that were in
  both labels)
* tab still works the same way
* you can remove "Lock" state from the label by typing something
  additional or removing the dimension at all
2025-06-21 12:46:27 +02:00
tetektoza
2933eaf819 Sketcher: Allow user to reset OVP state using backspace key
Currently if user tries to reset OVP, they can only do that by entering
"0" for example, and then the parameters will get unset in
unsetOnViewParameter. But that will only happen if user types a value
that's under confusion point (typically 1e^-7). In my opinion, it would
be cool to reset that state if user deletes all content in the label, to
allow them to specify coordinates with mouse once again.

Also, this patch fixes a regression with backspace, where deleting stuff
from OVP was working on unix systems, but seems like on Windows it
doesn't pass the check.
2025-06-08 15:00:58 +02:00
tetektoza
d12848c2b2 Sketcher: Do not allow mouse interruption while entering dimension (#20925)
* Sketcher: Do not allow mouse interruption while entering dimensions

So, currently user has an option to enter dimensions to different
Sketcher elements like circle, line, or hexagon, whatever else. But, if
they move mouse during entering of those parameters, they are gone.

This is because we are currently allowing for constant
`QAbstractSpinBox` value change during mouse move, it stops changing
ONLY AFTER value is being set (user enters number and presses ENTER
or TAB).

So, this patch introduces one more state for `EditableDatumLabel` which
is `hasFinishedEditing` which is being triggered by ENTER or TAB key,
and still keeping old `isSet` state, which disallows mouse movement
disruption and dynamically updates the edited element on viewport.
This means, that all objects now wait for `hasFinishedEditing` state to
actually finish editing.

* Sketcher: Avoid out of boundary access by checking onViewParameters size

* Sketcher: Add missing Qt headers for CI

* Sketcher: Allow using TAB to switch between labels without accepting

* Sketcher: Change to or statement, so enter will accept both labels

* Sketcher: Apply review comments

* used casting directly in if statement and auto to keep linter happy
* added comments for flags used for describing EditableDatumLabel states
2025-06-02 22:18:42 +02:00
Kacper Donat
cf4357ed38 Gui: Fix handling - character in OVP 2025-05-12 08:55:09 -05:00
bofdahof
ba2c2ca5ad Console: rename PascalCase named methods to camelCase 2025-05-06 17:50:21 +02:00
Benjamin Nauck
b6d6c8837f Gui: Add #include <limits> where used 2025-03-31 23:50:37 +02:00
Benjamin Nauck
b625e81a3e Gui: Use std::numeric_limits and std::numbers instead of defines 2025-03-29 13:32:38 +01:00
tritao
28f18ded85 Gui: Fix invalid scene graph mutation in EditableDatumLabel.
`EditableDatumLabel` uses `activate`/`deactivate` methods for showing or
hiding its widgets in the scene.

However, `activate`/`deactivate` methods can end up being called as part
of a scene graph / Coin action (`SoAction`) handler, in the context of
`SoFCUnifiedSelection`, and this ended up in a Coin warning and eventual
crash due to the scene graph being manipulated (nodes being removed),
which Coin has checks for in debug mode:

```
Coin error in SoGroup::removeChild(): tried to remove non-existent child
0x5555579c5290 (Annotation)
```

Fix this issue by using a `SoSwitch` node instead and by controling the
child visibility using it instead.
2025-01-27 17:51:40 +01:00
Ladislav Michl
0b3adee2ab Base: Quantity: return std::string 2024-12-23 17:48:42 +01:00
Abdullah Tahiri
f56eebea64 Sketcher: Fix lints 2023-11-08 17:46:34 +01:00
Abdullah Tahiri
5a4267a58e EditableDatumLabel: Extend with function to differentiate positioning from dimensioning OVPs 2023-11-08 15:20:13 +01:00
Paddle
95e6699a3e EditableDatumLabel : Fix issue where the spinbox would get in the way of the cursor for angle. For example line angle. 2023-11-07 15:36:21 +01:00
Paddle
4e20c25839 EditableDatumLabel : make sure the spinbox that has the focus is on top. 2023-11-07 15:36:21 +01:00
Paddle
5e9edfea73 EditableDatumLabel : prevent spinbox from going out of the view. 2023-11-07 15:36:21 +01:00
Paddle
b992ebfd07 EditableDatumLabel : prevent re-activation or re-startEdit. 2023-10-24 19:27:10 +02:00
Paddle
38d5580dfe Add a 'value' double to EditableDatumLabel such that we can store the raw value of the spinbox. For the case where editStopped but we still need to access value.
Also write the value in the SoDatumLabel in case we stopEdit.
2023-10-24 19:27:10 +02:00
Paddle
20e41aea0b EditableDatumLabel : Change the 'invisibleToMouse' to 'visibleToMouse' to avoid double negation.
Also add parameter to startEdit to set this setting. Defaulting to false. So that we don't have to set manually again and again in tool settings.
2023-10-24 19:27:10 +02:00
Paddle
ecdbd69db5 EditableDatumLabel add 'isInEdit' to check if the label is in edit. 2023-10-20 11:23:33 +02:00
Paddle
6c2493799e EditableDatumLabel add support for angle labels. 2023-10-20 11:23:33 +02:00
Paddle
527ffeb3b4 EditableDatumLabel : Prevent passing the focus with tab. And small thing. 2023-10-13 19:03:45 +02:00
Paddle
ce4cb6eea7 Adds SoDatumLabel::getLabelTextCenter() to get the externalize the finding of position of text center. 2023-10-13 19:03:45 +02:00
Paddle
6741e95990 editableDatumLabel : add setSpinboxInvisibleToMouse 2023-10-13 19:03:45 +02:00
wmayer
99358cd063 Gui: fix clang-tidy warnings in EditableDatumLabel
and fix two further memory leaks
2023-09-17 19:11:31 +02:00
Paddle
620c2ce239 Introduce EditableDatumLabel. A class that handles a SoDatumLabel with a spinbox to edit its value. 2023-09-17 13:05:53 +02:00