From 10fd4c810496129dbd37830426552d265d6f72be Mon Sep 17 00:00:00 2001 From: Roy-043 Date: Wed, 29 Nov 2023 15:05:16 +0100 Subject: [PATCH 1/2] Draft: Revised preference ui files * Removed DefaultAnnoDisplayMode. This will become a fine-tuning preference. * Removed HatchPatternResolution as it was not used. * Added DefaultAnnoLineColor and DefaultAnnoLineWidth. These will be implemented in other parts of the Draft code in later PRs. --- .../Draft/Resources/ui/preferences-draft.ui | 737 +++---- .../ui/preferences-draftinterface.ui | 1787 +++++++---------- .../Resources/ui/preferences-draftsnap.ui | 1012 ++++------ .../Resources/ui/preferences-drafttexts.ui | 1179 +++++------ .../Resources/ui/preferences-draftvisual.ui | 622 ++---- 5 files changed, 2310 insertions(+), 3027 deletions(-) diff --git a/src/Mod/Draft/Resources/ui/preferences-draft.ui b/src/Mod/Draft/Resources/ui/preferences-draft.ui index 0ae8ea6b9c..6999ec4b56 100644 --- a/src/Mod/Draft/Resources/ui/preferences-draft.ui +++ b/src/Mod/Draft/Resources/ui/preferences-draft.ui @@ -11,149 +11,126 @@ - General settings + General - - 6 - - - 9 - - - 9 - - - 9 - - - 9 - - - - - 0 - 0 - - + - General Draft Settings + General - - - - - - - Default working plane - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - defaultWP - - - Mod/Draft - - - - None - - - - - XY (Top) - - - - - XZ (Front) - - - - - YZ (Side) - - - - - + + + + + Internal precision level + + - - - - - - Internal precision level - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 60 - 16777215 - - - - The number of decimals in internal coordinates operations (for ex. 3 = 0.001). Values between 6 and 8 are usually considered the best trade-off among FreeCAD users. - - - 10 - - - 6 - - - precision - - - Mod/Draft - - - - - - - + + + + + 140 + 0 + + - If this option is checked, the layers drop-down list will also show groups, allowing you to automatically add objects to groups too. + The number of decimals used in internal coordinate operations (for example 3 = 0.001). +Values between 6 and 8 are usually considered the best trade-off. + + + 10 + + + 6 + + + precision + + + Mod/Draft + + + + + + + Qt::Horizontal + + + + + + + Default working plane + + + + + + + The default working plane for new views. If set to "Automatic" the working plane +will automatically align with the current view whenever a command is started. +Additionally it will align to preselected planar faces, or when points on planar +faces are picked during commands. + + + 1 + + + defaultWP + + + Mod/Draft + + + + Automatic + + + + + XY (Top) + + + + + XZ (Front) + + + + + YZ (Side) + + + + + + + + If checked, a widget indicating the current working +plane orientation appears when picking points - Show groups in layers list drop-down button + Show working plane tracker - - false + + showPlaneTracker + + + Mod/Draft + + + + + + + If checked, the layers drop-down list also includes groups. +Objects can then automatically be added to groups as well. + + + Include groups in layer list AutogroupAddGroups @@ -167,223 +144,273 @@ - + - Draft tools options + Command options - - - 9 - - - 9 - - - 9 - - - 9 - - - - - 0 + + + + + If checked, instructions are displayed in the Report view when using Draft commands - - - - When drawing lines, set focus on Length instead of X coordinate. -This allows to point the direction and type the distance. - - - Set focus on Length instead of X coordinate - - - focusOnLength - - - Mod/Draft - - - - - - - Force Draft Tools to create Part primitives instead of Draft objects. -Note that this is not fully supported, and many object will be not editable with Draft Modifiers. - - - Use Part Primitives when available - - - UsePartPrimitives - - - Mod/Draft - - - - - - - Normally, after copying objects, the copies get selected. -If this option is checked, the base objects will be selected instead. - - - Select base objects after copying - - - selectBaseObjects - - - Mod/Draft - - - - - - - If this is checked, prompt messages will be printed -in the report view when using Draft tools, to help -knowing which action to take next. - - - Show prompts in the report view - - - ToolMessages - - - Mod/Draft - - - - + + Show prompts in the Report view + + + ToolMessages + + + Mod/Draft + + - - - - - - Prefix labels of Clones with: - - - - - - - - - - ClonePrefix - - - Mod/Draft - - - - + + + + If checked, Length input, instead of the X coordinate, will have the initial focus. +This allows to indicate a direction and then type a distance. + + + Set focus on Length instead of X coordinate + + + focusOnLength + + + Mod/Draft + + + + + + + If checked, base objects, instead of created copies, are selected after copying + + + Select base objects after copying + + + selectBaseObjects + + + Mod/Draft + + + + + + + If checked, Draft commands will create Part primitives instead of Draft objects. +Note that this is not fully supported, and many objects will not be editable with +Draft modification commands. + + + Create Part primitives if possible + + + UsePartPrimitives + + + Mod/Draft + + + + + + + If checked, Draft Downgrade and Draft Upgrade will keep face colors. +Only for the splitFaces and makeShell options. + + + Keep face colors during downgrade/upgrade + + + preserveFaceColor + + + Mod/Draft + + + + + + + If checked, Draft Downgrade and Draft Upgrade will keep face names. +Only for the splitFaces and makeShell options. + + + Keep face names during downgrade/upgrade + + + preserveFaceNames + + + Mod/Draft + + + + + + + Max. number of editable objects + + + + + + + The maximum number of objects Draft Edit is allowed to process at the same time + + + 1 + + + 25 + + + 5 + + + 10 + + + DraftEditMaxObjects + + + Mod/Draft + + + + + + + Qt::Horizontal + + + + + + + Edit node pick radius + + + + + + + The pick radius of edit nodes + + + px + + + 1 + + + 20 + + + DraftEditPickRadius + + + Mod/Draft + + + + + + + Label prefix for clones + + + + + + + + 140 + 16777215 + + + + The default prefix added to the label of new clones + + + + + + ClonePrefix + + + Mod/Draft + + + + + + + Construction group label + + + + + + + + 140 + 16777215 + + + + The default label for the construction geometry group + + + Construction + + + constructiongroupname + + + Mod/Draft + + + + + + + Construction geometry color + + + + + + + The default color for Draft objects in construction mode + + + + 44 + 125 + 255 + + + + constructioncolor + + + Mod/Draft + + - - - - 0 - 0 - - - - Construction Geometry - - - - - - - - Construction group name - - - - - - - This is the default group name for construction geometry - - - Construction - - - constructiongroupname - - - Mod/Draft - - - - - - - - - - - Construction geometry color - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - This is the default color for objects being drawn while in construction mode. - - - - 44 - 125 - 255 - - - - constructioncolor - - - Mod/Draft - - - - - - - - - - + Qt::Vertical - - - 20 - 40 - - @@ -391,34 +418,34 @@ knowing which action to take next. qPixmapFromMimeSource - - Gui::ColorButton - QPushButton -
Gui/Widgets.h
-
- - Gui::PrefSpinBox - QSpinBox -
Gui/PrefWidgets.h
-
- - Gui::PrefColorButton - Gui::ColorButton -
Gui/PrefWidgets.h
-
Gui::PrefCheckBox QCheckBox
Gui/PrefWidgets.h
+ + Gui::PrefLineEdit + QLineEdit +
Gui/PrefWidgets.h
+
Gui::PrefComboBox QComboBox
Gui/PrefWidgets.h
- Gui::PrefLineEdit - QLineEdit + Gui::PrefSpinBox + QSpinBox +
Gui/PrefWidgets.h
+
+ + Gui::ColorButton + QPushButton +
Gui/Widgets.h
+
+ + Gui::PrefColorButton + Gui::ColorButton
Gui/PrefWidgets.h
diff --git a/src/Mod/Draft/Resources/ui/preferences-draftinterface.ui b/src/Mod/Draft/Resources/ui/preferences-draftinterface.ui index 6e4aa1014b..da09ddb214 100644 --- a/src/Mod/Draft/Resources/ui/preferences-draftinterface.ui +++ b/src/Mod/Draft/Resources/ui/preferences-draftinterface.ui @@ -11,1047 +11,782 @@ - User interface settings + Interface - - 6 - - - 9 - + + + + In-command shortcuts + + + + + + Relative + + + + + + + + 25 + 16777215 + + + + R + + + 1 + + + false + + + inCommandShortcutRelative + + + Mod/Draft + + + + + + + Qt::Horizontal + + + + + + + Global + + + + + + + + 25 + 16777215 + + + + G + + + 1 + + + false + + + inCommandShortcutGlobal + + + Mod/Draft + + + + + + + Qt::Horizontal + + + + + + + Length + + + + + + + + 25 + 16777215 + + + + L + + + 1 + + + false + + + inCommandShortcutLength + + + Mod/Draft + + + + + + + Qt::Horizontal + + + + + + + Fill + + + + + + + + 25 + 16777215 + + + + F + + + 1 + + + false + + + inCommandShortcutFill + + + Mod/Draft + + + + + + + Select edge + + + + + + + + 25 + 16777215 + + + + E + + + 1 + + + false + + + inCommandShortcutSelectEdge + + + Mod/Draft + + + + + + + Subelement mode + + + + + + + + 25 + 16777215 + + + + B + + + 1 + + + false + + + inCommandShortcutSubelementMode + + + Mod/Draft + + + + + + + Copy + + + + + + + + 25 + 16777215 + + + + C + + + 1 + + + false + + + inCommandShortcutCopy + + + Mod/Draft + + + + + + + Undo + + + + + + + + 25 + 16777215 + + + + / + + + 1 + + + false + + + inCommandShortcutUndo + + + Mod/Draft + + + + + + + Wipe + + + + + + + + 25 + 16777215 + + + + W + + + 1 + + + false + + + inCommandShortcutWipe + + + Mod/Draft + + + + + + + Close + + + + + + + + 25 + 16777215 + + + + O + + + 1 + + + false + + + inCommandShortcutClose + + + Mod/Draft + + + + + + + Exit + + + + + + + + 25 + 16777215 + + + + A + + + 1 + + + false + + + inCommandShortcutExit + + + Mod/Draft + + + + + + + Continue + + + + + + + + 25 + 16777215 + + + + N + + + 1 + + + false + + + inCommandShortcutContinue + + + Mod/Draft + + + + + + + Cycle snap + + + + + + + + 25 + 16777215 + + + + ` + + + 1 + + + false + + + inCommandShortcutCycleSnap + + + Mod/Draft + + + + + + + Add hold + + + + + + + + 25 + 16777215 + + + + Q + + + 1 + + + false + + + inCommandShortcutAddHold + + + Mod/Draft + + + + + + + Set working plane + + + + + + + + 25 + 16777215 + + + + U + + + 1 + + + false + + + inCommandShortcutSetWP + + + Mod/Draft + + + + + + + Snap + + + + + + + + 25 + 16777215 + + + + S + + + 1 + + + false + + + inCommandShortcutSnap + + + Mod/Draft + + + + + + + Increase radius + + + + + + + + 25 + 16777215 + + + + P + + + 1 + + + false + + + inCommandShortcutIncreaseRadius + + + Mod/Draft + + + + + + + Decrease radius + + + + + + + + 25 + 16777215 + + + + M + + + 1 + + + false + + + inCommandShortcutDecreaseRadius + + + Mod/Draft + + + + + + + Restrict X + + + + + + + + 25 + 16777215 + + + + X + + + 1 + + + false + + + inCommandShortcutRestrictX + + + Mod/Draft + + + + + + + Restrict Y + + + + + + + + 25 + 16777215 + + + + Y + + + 1 + + + false + + + inCommandShortcutRestrictY + + + Mod/Draft + + + + + + + Restrict Z + + + + + + + + 25 + 16777215 + + + + Z + + + 1 + + + false + + + inCommandShortcutRestrictZ + + + Mod/Draft + + + + + + - In-Command Shortcuts + UI options - - - - - 0 + + + + + If checked, the Draft snap toolbar will only be visible during commands - - - - Relative - - - - - - - true - - - - 0 - 0 - - - - - 25 - 16777215 - - - - R - - - 1 - - - - - - false - - - inCommandShortcutRelative - - - Mod/Draft - - - - - - - Qt::Horizontal - - - - - - - Continue - - - - - - - true - - - - 0 - 0 - - - - - 25 - 16777215 - - - - T - - - 1 - - - - - - false - - - inCommandShortcutContinue - - - Mod/Draft - - - - - - - Qt::Horizontal - - - - - - - Close - - - - - - - true - - - - 0 - 0 - - - - - 25 - 16777215 - - - - O - - - 1 - - - - - - false - - - inCommandShortcutClose - - - Mod/Draft - - - - - - - Qt::Horizontal - - - - - - - Copy - - - - - - - true - - - - 0 - 0 - - - - - 25 - 16777215 - - - - P - - - 1 - - - - - - false - - - inCommandShortcutCopy - - - Mod/Draft - - - - - - - Subelement Mode - - - - - - - true - - - - 0 - 0 - - - - - 25 - 16777215 - - - - D - - - 1 - - - - - - false - - - inCommandShortcutSubelementMode - - - Mod/Draft - - - - - - - Fill - - - - - - - true - - - - 0 - 0 - - - - - 25 - 16777215 - - - - L - - - 1 - - - - - - false - - - inCommandShortcutFill - - - Mod/Draft - - - - - - - Exit - - - - - - - true - - - - 0 - 0 - - - - - 25 - 16777215 - - - - A - - - 1 - - - - - - false - - - inCommandShortcutExit - - - Mod/Draft - - - - - - - Select Edge - - - - - - - true - - - - 0 - 0 - - - - - 25 - 16777215 - - - - E - - - 1 - - - - - - false - - - inCommandShortcutSelectEdge - - - Mod/Draft - - - - - - - Add Hold - - - - - - - true - - - - 0 - 0 - - - - - 25 - 16777215 - - - - Q - - - 1 - - - - - - false - - - inCommandShortcutAddHold - - - Mod/Draft - - - - - - - Length - - - - - - - true - - - - 0 - 0 - - - - - 25 - 16777215 - - - - H - - - 1 - - - - - - false - - - inCommandShortcutLength - - - Mod/Draft - - - - - - - Wipe - - - - - - - true - - - - 0 - 0 - - - - - 25 - 16777215 - - - - W - - - 1 - - - - - - false - - - inCommandShortcutWipe - - - Mod/Draft - - - - - - - Set WP - - - - - - - true - - - - 0 - 0 - - - - - 25 - 16777215 - - - - U - - - 1 - - - - - - false - - - inCommandShortcutSetWP - - - Mod/Draft - - - - - - - Cycle Snap - - - - - - - true - - - - 0 - 0 - - - - - 25 - 16777215 - - - - ` - - - 1 - - - - - - false - - - inCommandShortcutCycleSnap - - - Mod/Draft - - - - - - - Global - - - - - - - true - - - - 0 - 0 - - - - - 25 - 16777215 - - - - G - - - 1 - - - - - - false - - - inCommandShortcutGlobal - - - Mod/Draft - - - - - - - Undo - - - - - - - true - - - - 0 - 0 - - - - - 25 - 16777215 - - - - / - - - 1 - - - - - - false - - - inCommandShortcutUndo - - - Mod/Draft - - - - - - - Snap - - - - - - - true - - - - 0 - 0 - - - - - 25 - 16777215 - - - - S - - - 1 - - - - - - false - - - inCommandShortcutSnap - - - Mod/Draft - - - - - - - Increase Radius - - - - - - - true - - - - 0 - 0 - - - - - 25 - 16777215 - - - - [ - - - 1 - - - - - - false - - - inCommandShortcutIncreaseRadius - - - Mod/Draft - - - - - - - Decrease Radius - - - - - - - true - - - - 0 - 0 - - - - - 25 - 16777215 - - - - ] - - - 1 - - - - - - false - - - inCommandShortcutDecreaseRadius - - - Mod/Draft - - - - - - - Restrict X - - - - - - - true - - - - 0 - 0 - - - - - 25 - 16777215 - - - - X - - - 1 - - - - - - false - - - inCommandShortcutRestrictX - - - Mod/Draft - - - - - - - Restrict Y - - - - - - - true - - - - 0 - 0 - - - - - 25 - 16777215 - - - - Y - - - 1 - - - - - - false - - - inCommandShortcutRestrictY - - - Mod/Draft - - - - - - - Restrict Z - - - - - - - true - - - - 0 - 0 - - - - - 25 - 16777215 - - - - Z - - - 1 - - - - - - false - - - RestrictZ - - - Mod/Draft - - - - + + Only show the Draft snap toolbar during commands + + + false + + + SnapBarShowOnlyDuringCommands + + + Mod/Draft + + + + + + + If checked, the Snap widget is displayed in the Draft statusbar + + + Show the Snap widget in the Draft Workbench + + + true + + + DisplayStatusbarSnapWidget + + + Mod/Draft + + + + + + + If checked, the Annotation scale widget is displayed in the Draft statusbar + + + Show the Annotation scale widget in the Draft Workbench + + + true + + + DisplayStatusbarScaleWidget + + + Mod/Draft + + - - - - 0 - 0 - - - - Draft Statusbar - - - - - - 0 - - - - - Enable snap statusbar widget - - - Draft snap widget - - - true - - - DisplayStatusbarSnapWidget - - - Mod/Draft - - - - - - - Enable draft statusbar annotation scale widget - - - Annotation scale widget - - - true - - - DisplayStatusbarScaleWidget - - - Mod/Draft - - - - - - - - - - + Qt::Vertical - - - 20 - 40 - - diff --git a/src/Mod/Draft/Resources/ui/preferences-draftsnap.ui b/src/Mod/Draft/Resources/ui/preferences-draftsnap.ui index d44e89982d..9fac2e398a 100644 --- a/src/Mod/Draft/Resources/ui/preferences-draftsnap.ui +++ b/src/Mod/Draft/Resources/ui/preferences-draftsnap.ui @@ -14,269 +14,13 @@ Grid and snapping - - 6 - - - 9 - - - 9 - - - 9 - - - 9 - - - Snapping - - - - - - - - If checked, snapping is activated without the need to press the Snap mod key - - - Always snap - - - true - - - alwaysSnap - - - Mod/Draft - - - - - - - - - - - false - - - Snap mod - - - - - - - Qt::Horizontal - - - - 40 - 0 - - - - - - - - - 140 - 0 - - - - false - - - The Snap modifier key - - - 1 - - - modsnap - - - Mod/Draft - - - - Shift - - - - - Ctrl - - - - - Alt - - - - - - - - - - - - Constrain mod - - - - - - - Qt::Horizontal - - - - 40 - 0 - - - - - - - - - 140 - 0 - - - - The Constraining modifier key - - - modconstrain - - - Mod/Draft - - - - Shift - - - - - Ctrl - - - - - Alt - - - - - - - - - - - - Alt mod - - - - - - - Qt::Horizontal - - - - 40 - 0 - - - - - - - - - 140 - 0 - - - - The Alt modifier key. The function of this key depends on the command. - - - 2 - - - modalt - - - Mod/Draft - - - - Shift - - - - - Ctrl - - - - - Alt - - - - - - - - - - - - If checked, the Snap toolbar will only be visible during commands - - - Only show the Draft snap toolbar during commands - - - false - - - SnapBarShowOnlyDuringCommands - - - Mod/Draft - - - - - - - - - - Grid - - + + If checked, the grid will always be visible in new views. @@ -296,7 +40,7 @@ Use Draft ToggleGrid to change this for the active view. - + false @@ -319,10 +63,11 @@ Use Draft ToggleGrid to change this for the active view. - + - If checked, an additional border is displayed around the grid, showing the main square size in the bottom left border + If checked, an additional border is displayed around the grid, +showing the main square size in the bottom left corner Show grid border @@ -338,14 +83,15 @@ Use Draft ToggleGrid to change this for the active view. - + true - If checked, the outline of a human figure is displayed at the bottom left corner of the grid. -This option is only effective if the BIM workbench is installed and if Show grid border is enabled. + If checked, the outline of a human figure is displayed at the bottom left +corner of the grid. Only effective if the BIM workbench is installed and +"Show grid border" is enabled. Show human figure @@ -361,10 +107,10 @@ This option is only effective if the BIM workbench is installed and if Show grid - + - If checked, the two main axes of the grid will be colored red, green or blue + If checked, the two main axes of the grid are colored red, green or blue if they match the X, Y or Z axis of the global coordinate system @@ -381,349 +127,371 @@ if they match the X, Y or Z axis of the global coordinate system - - - - - - Main lines every - - - - - - - Qt::Horizontal - - - - 40 - 0 - - - - - - - - - 140 - 0 - - - - The number of squares between main grid lines. These lines are thicker than normal grid lines. - - - 10 - - - gridEvery - - - Mod/Draft - - - - + + + + Main lines every + + - - - - - - Grid spacing - - - - - - - Qt::Horizontal - - - - 40 - 0 - - - - - - - - - 140 - 0 - - - - The distance between grid lines - - - 4 - - - 9999.989999999999782 - - - 1.000000000000000 - - - mm - - - gridSpacing - - - Mod/Draft - - - - + + + + + 140 + 0 + + + + The number of squares between main grid lines. +These lines are thicker than normal grid lines. + + + 10 + + + gridEvery + + + Mod/Draft + + - - - - - - Grid size - - - - - - - Qt::Horizontal - - - - 40 - 0 - - - - - - - - - 140 - 0 - - - - The number of horizontal and vertical lines of the grid - - - lines - - - 9999 - - - 100 - - - gridSize - - - Mod/Draft - - - - + + + + Qt::Horizontal + + - - - - - - Grid color and transparency - - - - - - - Qt::Horizontal - - - - 40 - 0 - - - - - - - - - 0 - 0 - - - - The color of the grid - - - - 50 - 50 - 75 - - - - gridColor - - - Mod/Draft - - - - - - - - 140 - 0 - - - - The overall transparency of the grid - - - 100 - - - gridTransparency - - - Mod/Draft - - - - + + + + Grid spacing + + + + + + + The distance between grid lines + + + 4 + + + 9999.989999999999782 + + + 1.000000000000000 + + + mm + + + gridSpacing + + + Mod/Draft + + + + + + + Grid size + + + + + + + The number of horizontal and vertical lines in the grid + + + lines + + + 9999 + + + 100 + + + gridSize + + + Mod/Draft + + + + + + + Grid transparency + + + + + + + The overall transparency of the grid + + + % + + + 100 + + + gridTransparency + + + Mod/Draft + + + + + + + Grid color + + + + + + + The color of the grid + + + + 50 + 50 + 75 + + + + gridColor + + + Mod/Draft + + - + - Edit + Snapping and modifier keys - - - - - - - - - - Maximum number of objects for Draft Edit - - - - - - - Qt::Horizontal - - - - 40 - 0 - - - - - - - - - 140 - 0 - - - - The maximum number of objects Draft Edit is allowed to process at the same time - - - 1 - - - 25 - - - 5 - - - 10 - - - DraftEditMaxObjects - - - Mod/Draft - - - - + + + + + Snap symbol style + + - - + + + + The style for snap symbols + + + snapStyle + + + Mod/Draft + - - - - - - Pick radius for Draft Edit - - + + Draft classic style + - - - Qt::Horizontal - - - - 40 - 0 - - - + + Bitsnpieces style + + + + + + + + Qt::Horizontal + + + + + + + Snap symbol color + + + + + + + The color for snap symbols + + + + 255 + 170 + 255 + + + + snapcolor + + + Mod/Draft + + + + + + + If checked, snapping is activated without the need to press the Snap modifier key + + + Always snap + + + true + + + alwaysSnap + + + Mod/Draft + + + + + + + false + + + Snap modifier + + + + + + + + 140 + 0 + + + + false + + + The Snap modifier key + + + 1 + + + modsnap + + + Mod/Draft + + + + Shift + - - - - 140 - 0 - - - - The pick radius (in pixels) of edit nodes - - - 1 - - - 20 - - - DraftEditPickRadius - - - Mod/Draft - - + + Ctrl + - + + + Alt + + + + + + + + Constrain modifier + + + + + + + The Constrain modifier key + + + modconstrain + + + Mod/Draft + + + + Shift + + + + + Ctrl + + + + + Alt + + + + + + + + Alt modifier + + + + + + + The Alt modifier key. The function of this key depends on the command. + + + 2 + + + modalt + + + Mod/Draft + + + + Shift + + + + + Ctrl + + + + + Alt + + + @@ -733,12 +501,6 @@ if they match the X, Y or Z axis of the global coordinate system Qt::Vertical - - - 0 - 40 - - @@ -746,21 +508,6 @@ if they match the X, Y or Z axis of the global coordinate system qPixmapFromMimeSource - - Gui::ColorButton - QPushButton -
Gui/Widgets.h
-
- - Gui::PrefSpinBox - QSpinBox -
Gui/PrefWidgets.h
-
- - Gui::PrefColorButton - Gui::ColorButton -
Gui/PrefWidgets.h
-
Gui::PrefCheckBox QCheckBox @@ -771,26 +518,29 @@ if they match the X, Y or Z axis of the global coordinate system QComboBox
Gui/PrefWidgets.h
+ + Gui::PrefSpinBox + QSpinBox +
Gui/PrefWidgets.h
+
Gui::PrefQuantitySpinBox QDoubleSpinBox
Gui/PrefWidgets.h
+ + Gui::ColorButton + QPushButton +
Gui/Widgets.h
+
+ + Gui::PrefColorButton + Gui::ColorButton +
Gui/PrefWidgets.h
+
- - checkBox_alwaysSnap - toggled(bool) - label_modsnap - setDisabled(bool) - - - checkBox_alwaysSnap - toggled(bool) - comboBox_modsnap - setDisabled(bool) - checkBox_alwaysShowGrid toggled(bool) @@ -803,5 +553,17 @@ if they match the X, Y or Z axis of the global coordinate system checkBox_gridShowHuman setEnabled(bool) + + checkBox_alwaysSnap + toggled(bool) + label_modsnap + setDisabled(bool) + + + checkBox_alwaysSnap + toggled(bool) + comboBox_modsnap + setDisabled(bool) + diff --git a/src/Mod/Draft/Resources/ui/preferences-drafttexts.ui b/src/Mod/Draft/Resources/ui/preferences-drafttexts.ui index d551a06aa1..e881b72a99 100644 --- a/src/Mod/Draft/Resources/ui/preferences-drafttexts.ui +++ b/src/Mod/Draft/Resources/ui/preferences-drafttexts.ui @@ -14,107 +14,137 @@ Texts and dimensions - - 6 - - - 9 - - - 9 - - - 9 - - - 9 - - + - Text settings + Texts - - - - - - - Font family - - - - - - - - 200 - 0 - - - - This is the default font name for all Draft texts and dimensions. -It can be a font name such as "Arial", a default style such as "sans", "serif" -or "mono", or a family such as "Arial,Helvetica,sans" or a name with a style -such as "Arial:Bold" - - - - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - Internal font - - - textfont - - - Mod/Draft - - - - + + + + + Font name or family + + - - - - - - Font size - - - - - - - - 16777215 - 16777215 - - - - Default height for texts and dimensions - - - mm - - - 9999.989999999999782 - - - 0.200000000000000 - - - textheight - - - Mod/Draft - - - - + + + + The default font for texts, dimensions and labels. It can be a font name such +as "Arial", a style such as "sans", "serif" or "mono", or a family such as +"Arial,Helvetica,sans", or a name with a style such as "Arial:Bold". + + + + + + Internal font + + + textfont + + + Mod/Draft + + + + + + + Font size + + + + + + + + 140 + 0 + + + + The default height for texts, dimension texts and label texts + + + 0.05 + + + mm + + + 0.0 + + + 3.5 + + + textheight + + + Mod/Draft + + + + + + + Qt::Horizontal + + + + + + + Line spacing factor + + + + + + + The default line spacing for multi-line texts and labels (relative to the font size) + + + 0.05 + + + 1.0 + + + LineSpacing + + + Mod/Draft + + + + + + + Text color + + + + + + + The default color for texts, dimension texts and label texts + + + + 0 + 0 + 0 + + + + DefaultTextColor + + + Mod/Draft + + @@ -122,419 +152,173 @@ such as "Arial:Bold" - Dimension settings + Lines and arrows - - - - - - - Display mode - - - - - - - - 120 - 0 - - - - DefaultAnnoDisplayMode - - - Mod/Draft - - - - World - - - - - Screen - - - - - + + + + + If checked, the dimension line is displayed by default + + + Show dimension line + + + true + + + DimShowLine + + + Mod/Draft + + - - - - - - Number of decimals - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - 8 - - - 2 - - - dimPrecision - - - Mod/Draft - - - - + + + + Line width + + - - - - - - Extension lines size - - - - - - - The default size of dimensions extension lines - - - mm - - - -9999.989999999999782 - - - 9999.989999999999782 - - - 0.300000000000000 - - - extlines - - - Mod/Draft - - - - + + + + The default line width + + + px + + + 1 + + + 2 + + + DefaultAnnoLineWidth + + + Mod/Draft + + - - - - - - Extension line overshoot - - - - - - - The default length of extension line above dimension line - - - mm - - - -9999.989999999999782 - - - 9999.989999999999782 - - - 0.000000000000000 - - - extovershoot - - - Mod/Draft - - - - + + + + Qt::Horizontal + + - - - - - - Dimension line overshoot - - - - - - - The default distance the dimension line is extended past extension lines - - - mm - - - -9999.989999999999782 - - - 9999.989999999999782 - - - 0.000000000000000 - - - dimovershoot - - - Mod/Draft - - - - + + + + Arrow type + + - - + + + + + 140 + 0 + + + + The default symbol displayed at the ends of dimension lines + + + dimsymbol + + + Mod/Draft + - - - Show the dimension line - - - true - - - DimShowLine - - - Mod/Draft - - + + Dot + - + + + Circle + + + + + Arrow + + + + + Tick + + + + + Tick-2 + + + - - - - - - Arrows style - - - - - - - dimsymbol - - - Mod/Draft - - - - Dot - - - - - Circle - - - - - Arrow - - - - - Tick - - - - - Tick-2 - - - - - + + + + Arrow size + + - - - - - - Arrows size - - - - - - - The default size of arrows - - - mm - - - 9999.989999999999782 - - - 0.100000000000000 - - - arrowsize - - - Mod/Draft - - - - + + + + The default arrow size + + + 0.05 + + + mm + + + 0.0 + + + 1.0 + + + arrowsize + + + Mod/Draft + + - - - - - - Text spacing - - - - - - - The space between the dimension line and the dimension text - - - mm - - - 9999.989999999999782 - - - 0.050000000000000 - - - dimspacing - - - Mod/Draft - - - - + + + + Line and arrow color + + - - - - - - Show the unit suffix in dimensions - - - true - - - showUnit - - - Mod/Draft - - - - - - - - - - - Override unit - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - By leaving this field blank, the dimension measurements will be shown in the current unit defined in FreeCAD. By indicating a unit here such as m or cm, you can force new dimensions to be shown in that unit. - - - overrideUnit - - - Mod/Draft - - - - - - - - - - - Feet separator - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Optional string to appear between the feet and inches values in dimensions - - - FeetSeparator - - - Mod/Draft - - - - + + + + The default color for lines and arrows + + + + 0 + 0 + 0 + + + + DefaultAnnoLineColor + + + Mod/Draft + + @@ -542,63 +326,353 @@ such as "Arial:Bold" - ShapeString settings + Units - - - - - - - Default ShapeString font file - - - - - - - - 300 - 0 - - - - Font files (*.ttf *.otf *.pfb *.TTF *.OTF *.PFB) - - - Select a font file - - - FontFile - - - Mod/Draft - - - - + + + + + If checked, a unit symbol is added to dimension texts by default + + + Show unit + + + true + + + showUnit + + + Mod/Draft + + + + + + + Unit override + + + + + + + + 140 + 16777215 + + + + The default unit override for dimensions. Enter a unit such as m +or cm, leave blank to use the current unit defined in FreeCAD. + + + overrideUnit + + + Mod/Draft + + + + + + + Qt::Horizontal + + + + + + + Number of decimals + + + + + + + The default number of decimal places for dimension texts + + + 0 + + + 8 + + + 2 + + + dimPrecision + + + Mod/Draft + + + + + + + Feet separator + + + + + + + + 140 + 16777215 + + + + The optional string inserted between the feet and inches values in dimensions + + + FeetSeparator + + + Mod/Draft + + - + + + Dimension details + + + + + + Dimension line overshoot + + + + + + + + 140 + 0 + + + + The default distance the dimension line is extended past the extension lines + + + 0.05 + + + mm + + + 0.0 + + + dimovershoot + + + Mod/Draft + + + + + + + Qt::Horizontal + + + + + + + Extension line length + + + + + + + The default length of extension lines. Use 0 for full extension lines. A negative +value defines the gap between the ends of the extension lines and the measured +points. A positive value defines the maximum length of the extension lines. Only +used for linear dimensions. + + + 0.05 + + + mm + + + -0.5 + + + extlines + + + Mod/Draft + + + + + + + Extension line overshoot + + + + + + + The default length of extension lines above the dimension line + + + 0.05 + + + mm + + + 2.0 + + + extovershoot + + + Mod/Draft + + + + + + + Text spacing + + + + + + + The default space between the dimension line and the dimension text + + + 0.05 + + + mm + + + 0.0 + + + 1.0 + + + dimspacing + + + Mod/Draft + + + + + + + + + + ShapeStrings + + + + + + Default ShapeString font file + + + + + + + Font files (*.ttf *.otf *.pfb *.TTF *.OTF *.PFB) + + + Select a font file + + + FontFile + + + Mod/Draft + + + + + + + + Qt::Vertical - - - 20 - 40 - - - + qPixmapFromMimeSource + + Gui::PrefCheckBox + QCheckBox +
Gui/PrefWidgets.h
+
+ + Gui::PrefLineEdit + QLineEdit +
Gui/PrefWidgets.h
+
+ + Gui::PrefComboBox + QComboBox +
Gui/PrefWidgets.h
+
+ + Gui::PrefSpinBox + QSpinBox +
Gui/PrefWidgets.h
+
+ + Gui::PrefDoubleSpinBox + QDoubleSpinBox +
Gui/PrefWidgets.h
+
+ + Gui::QuantitySpinBox + QWidget +
Gui/QuantitySpinBox.h
+
+ + Gui::PrefUnitSpinBox + Gui::QuantitySpinBox +
Gui/PrefWidgets.h
+
+ + Gui::ColorButton + QPushButton +
Gui/Widgets.h
+
+ + Gui::PrefColorButton + Gui::ColorButton +
Gui/PrefWidgets.h
+
Gui::FileChooser QWidget @@ -609,31 +683,6 @@ such as "Arial:Bold" Gui::FileChooser
Gui/PrefWidgets.h
- - Gui::PrefSpinBox - QSpinBox -
Gui/PrefWidgets.h
-
- - Gui::PrefCheckBox - QCheckBox -
Gui/PrefWidgets.h
-
- - Gui::PrefComboBox - QComboBox -
Gui/PrefWidgets.h
-
- - Gui::PrefLineEdit - QLineEdit -
Gui/PrefWidgets.h
-
- - Gui::PrefDoubleSpinBox - QDoubleSpinBox -
Gui/PrefWidgets.h
-
diff --git a/src/Mod/Draft/Resources/ui/preferences-draftvisual.ui b/src/Mod/Draft/Resources/ui/preferences-draftvisual.ui index 02baf29fcb..2c245e81eb 100644 --- a/src/Mod/Draft/Resources/ui/preferences-draftvisual.ui +++ b/src/Mod/Draft/Resources/ui/preferences-draftvisual.ui @@ -11,454 +11,189 @@ - Visual settings + Visual - - 6 - - - 9 - - - 9 - - - 9 - - - 9 - - + - Visual Settings + SVG patterns - - - - - - - Snap symbols style - - - - - - - - 200 - 0 - - - - snapStyle - - - Mod/Draft - - - - Draft classic style - - - - - Bitsnpieces style - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Color - - - - - - - The default color for snap symbols - - - - 255 - 255 - 255 - - - - snapcolor - - - Mod/Draft - - - - + + + + + SVG pattern size + + - - - - - - If checked, a widget indicating the current working plane orientation appears during drawing operations - - - Show Working Plane tracker - - - showPlaneTracker - - - Mod/Draft - - - - + + + + + 140 + 0 + + + + The default size for SVG patterns. A higher value results in a denser pattern. + + + 0.05 + + + 1.0 + + + HatchPatternSize + + + Mod/Draft + + - - - - - - Alternate SVG patterns location - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 300 - 0 - - - - Gui::FileChooser::Directory - - - Here you can specify a directory with custom SVG files containing <pattern> definitions to be added to the standard patterns - - - patternFile - - - Mod/Draft - - - - + + + + Qt::Horizontal + + - - - - - - SVG pattern resolution - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - The resolution to draw the patterns in. Default value is 128. Higher values give better resolutions, lower values make drawing faster - - - 512 - - - 128 - - - HatchPatternResolution - - - Mod/Draft - - - - + + + + Additional SVG pattern location + + - - - - - - SVG pattern default size - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - The default size for SVG patterns - - - 4 - - - 0.000100000000000 - - - 1.000000000000000 - - - HatchPatternSize - - - Mod/Draft - - - - - - - - - - - Check this if you want to preserve colors of faces while doing downgrade and upgrade (splitFaces and makeShell only) - - - Preserve colors of faces during downgrade/upgrade - - - preserveFaceColor - - - Mod/Draft - - - - - - - - - - - Check this if you want the face names to derive from the originating object name and vice versa while doing downgrade/upgrade (splitFaces and makeShell only) - - - Preserve names of faces during downgrade/upgrade - - - preserveFaceNames - - - Mod/Draft - - - - + + + + Gui::FileChooser::Directory + + + An optional directory with custom SVG files containing +pattern definitions to be added to the standard patterns + + + patternFile + + + Mod/Draft + + - + Drawing view line definitions - - - - - - - Dashed line definition - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - An SVG linestyle definition - - - 2,2 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - svgDashedLine - - - Mod/Draft - - - - + + + + + Dashed line definition + + - - - - - - Dashdot line definition - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - An SVG linestyle definition - - - 3,2,0.2,2 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - svgDashdotLine - - - Mod/Draft - - - - + + + + + 140 + 16777215 + + + + An SVG linestyle definition + + + 2,2 + + + svgDashedLine + + + Mod/Draft + + - - - - - - Dotted line definition - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - An SVG linestyle definition - - - 0.2,2 - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - svgDottedLine - - - Mod/Draft - - - - + + + + Qt::Horizontal + + + + + + + Dashdot line definition + + + + + + + + 140 + 16777215 + + + + An SVG linestyle definition + + + 3,2,0.2,2 + + + svgDashdotLine + + + Mod/Draft + + + + + + + Dotted line definition + + + + + + + + 140 + 16777215 + + + + An SVG linestyle definition + + + 0.2,2 + + + svgDottedLine + + + Mod/Draft + + - + Qt::Vertical - - - 20 - 40 - - @@ -466,41 +201,6 @@ qPixmapFromMimeSource - - Gui::FileChooser - QWidget -
Gui/FileDialog.h
-
- - Gui::ColorButton - QPushButton -
Gui/Widgets.h
-
- - Gui::PrefFileChooser - Gui::FileChooser -
Gui/PrefWidgets.h
-
- - Gui::PrefSpinBox - QSpinBox -
Gui/PrefWidgets.h
-
- - Gui::PrefColorButton - Gui::ColorButton -
Gui/PrefWidgets.h
-
- - Gui::PrefCheckBox - QCheckBox -
Gui/PrefWidgets.h
-
- - Gui::PrefComboBox - QComboBox -
Gui/PrefWidgets.h
-
Gui::PrefLineEdit QLineEdit @@ -511,6 +211,16 @@ QDoubleSpinBox
Gui/PrefWidgets.h
+ + Gui::FileChooser + QWidget +
Gui/FileDialog.h
+
+ + Gui::PrefFileChooser + Gui::FileChooser +
Gui/PrefWidgets.h
+
From 904b37b47d0a8362a31087bab065de365d795add Mon Sep 17 00:00:00 2001 From: Roy-043 Date: Wed, 29 Nov 2023 23:05:24 +0100 Subject: [PATCH 2/2] Draft: implement DefaultAnnoLineWidth and DefaultAnnoLineColor prefs The format_object function in gui_utils.py still requires some work (in connection with the Draft_SetStyle command). This will be done later. --- src/Mod/Draft/Draft.py | 3 +- src/Mod/Draft/draftguitools/gui_snapper.py | 42 ++---- src/Mod/Draft/draftguitools/gui_trackers.py | 17 ++- src/Mod/Draft/draftutils/gui_utils.py | 131 ++++++++---------- src/Mod/Draft/draftutils/utils.py | 65 ++++++--- .../draftviewproviders/view_dimension.py | 1 + .../view_draft_annotation.py | 3 + 7 files changed, 132 insertions(+), 130 deletions(-) diff --git a/src/Mod/Draft/Draft.py b/src/Mod/Draft/Draft.py index 6c5145049a..f8360a0aa0 100644 --- a/src/Mod/Draft/Draft.py +++ b/src/Mod/Draft/Draft.py @@ -92,7 +92,8 @@ from draftutils.utils import (string_encode_coin, get_rgb, getrgb, argb_to_rgba, - rgba_to_argb) + rgba_to_argb, + get_rgba_tuple) from draftfunctions.svg import (get_svg, getSVG) diff --git a/src/Mod/Draft/draftguitools/gui_snapper.py b/src/Mod/Draft/draftguitools/gui_snapper.py index f6233b3211..925253f81b 100644 --- a/src/Mod/Draft/draftguitools/gui_snapper.py +++ b/src/Mod/Draft/draftguitools/gui_snapper.py @@ -329,7 +329,7 @@ class Snapper: fp = self.cstr(lastpoint, constrain, point) if self.trackLine and lastpoint and (not noTracker): self.trackLine.p2(fp) - self.trackLine.color.rgb = Gui.draftToolBar.getDefaultColor("line") + self.trackLine.setColor() self.trackLine.on() # Set the arch point tracking if lastpoint: @@ -499,7 +499,7 @@ class Snapper: fp = self.cstr(lastpoint, constrain, winner[2]) if self.trackLine and lastpoint: self.trackLine.p2(fp) - self.trackLine.color.rgb = Gui.draftToolBar.getDefaultColor("line") + self.trackLine.setColor() self.trackLine.on() # set the cursor self.setCursor(winner[1]) @@ -559,7 +559,7 @@ class Snapper: if self.extLine: self.extLine.p1(tsnap[0]) self.extLine.p2(tsnap[2]) - self.extLine.color.rgb = Gui.draftToolBar.getDefaultColor("line") + self.extLine.setColor() self.extLine.on() self.setCursor(tsnap[1]) return tsnap[2], eline @@ -573,7 +573,7 @@ class Snapper: self.tracker.on() if self.extLine: self.extLine.p2(tsnap[2]) - self.extLine.color.rgb = Gui.draftToolBar.getDefaultColor("line") + self.extLine.setColor() self.extLine.on() self.setCursor(tsnap[1]) return tsnap[2], eline @@ -587,7 +587,7 @@ class Snapper: self.tracker.on() if self.extLine: self.extLine.p2(tsnap[2]) - self.extLine.color.rgb = Gui.draftToolBar.getDefaultColor("line") + self.extLine.setColor() self.extLine.on() self.setCursor(tsnap[1]) return tsnap[2], eline @@ -623,13 +623,9 @@ class Snapper: self.tracker.setMarker(self.mk['extension']) self.tracker.on() if self.extLine: - if self.snapStyle: - dv = np.sub(p0) - self.extLine.p1(p0.add(dv.multiply(0.5))) - else: - self.extLine.p1(p0) + self.extLine.p1(p0) self.extLine.p2(np) - self.extLine.color.rgb = Gui.draftToolBar.getDefaultColor("line") + self.extLine.setColor() self.extLine.on() self.setCursor('extension') ne = Part.LineSegment(p0,np).toShape() @@ -681,14 +677,10 @@ class Snapper: p0 = self.lastExtensions[1].Vertexes[0].Point else: p0 = self.lastExtensions[0].Vertexes[0].Point - if self.snapStyle: - dv = p.sub(p0) - self.extLine2.p1(p0.add(dv.multiply(0.5))) - else: - self.extLine2.p1(p0) + self.extLine2.p1(p0) self.extLine2.p2(p) self.extLine.p2(p) - self.extLine.color.rgb = Gui.draftToolBar.getDefaultColor("line") + self.extLine.setColor() self.extLine2.on() return p return None @@ -1283,10 +1275,7 @@ class Snapper: # setup trackers if needed if not self.constrainLine: - if self.snapStyle: - self.constrainLine = trackers.lineTracker(scolor=Gui.draftToolBar.getDefaultColor("snap")) - else: - self.constrainLine = trackers.lineTracker(dotted=True) + self.constrainLine = trackers.lineTracker(dotted=True) # setting basepoint if not basepoint: @@ -1612,13 +1601,8 @@ class Snapper: self.grid.show_during_command = True self.tracker = trackers.snapTracker() self.trackLine = trackers.lineTracker() - if self.snapStyle: - c = Gui.draftToolBar.getDefaultColor("snap") - self.extLine = trackers.lineTracker(scolor=c) - self.extLine2 = trackers.lineTracker(scolor=c) - else: - self.extLine = trackers.lineTracker(dotted=True) - self.extLine2 = trackers.lineTracker(dotted=True) + self.extLine = trackers.lineTracker(dotted=True) + self.extLine2 = trackers.lineTracker(dotted=True) self.radiusTracker = trackers.radiusTracker() self.dim1 = trackers.archDimTracker(mode=2) self.dim2 = trackers.archDimTracker(mode=3) @@ -1652,7 +1636,7 @@ class Snapper: if self.spoint and self.spoint not in self.holdPoints: if self.holdTracker: self.holdTracker.addCoords(self.spoint) - self.holdTracker.color.rgb = Gui.draftToolBar.getDefaultColor("line") + self.holdTracker.setColor() self.holdTracker.on() self.holdPoints.append(self.spoint) diff --git a/src/Mod/Draft/draftguitools/gui_trackers.py b/src/Mod/Draft/draftguitools/gui_trackers.py index fb9a08aa6e..016996b441 100644 --- a/src/Mod/Draft/draftguitools/gui_trackers.py +++ b/src/Mod/Draft/draftguitools/gui_trackers.py @@ -44,6 +44,7 @@ import Draft import DraftVecUtils from FreeCAD import Vector +from draftutils import utils from draftutils.todo import ToDo from draftutils.messages import _msg @@ -62,7 +63,6 @@ class Tracker: import DraftGeomUtils self.ontop = ontop self.color = coin.SoBaseColor() - self.color.rgb = scolor or FreeCADGui.draftToolBar.getDefaultColor("line") drawstyle = coin.SoDrawStyle() if swidth: drawstyle.lineWidth = swidth @@ -78,6 +78,7 @@ class Tracker: self.switch.setName(name) self.switch.addChild(node) self.switch.whichChild = -1 + self.setColor(scolor) self.Visible = False ToDo.delay(self._insertSwitch, self.switch) @@ -140,6 +141,18 @@ class Tracker: sg.removeChild(self.switch) sg.insertChild(self.switch, 0) + def setColor(self, color=None): + """Set the color.""" + if color is not None: + self.color.rgb = color + elif hasattr(FreeCAD, "activeDraftCommand") \ + and FreeCAD.activeDraftCommand is not None \ + and FreeCAD.activeDraftCommand.featureName in ("Dimension", "Label", "Text"): + color = utils.get_rgba_tuple(utils.get_param("DefaultAnnoLineColor", 255))[:3] + self.color.rgb = color + else: + self.color.rgb = FreeCADGui.draftToolBar.getDefaultColor("line") + def _get_wp(self): return FreeCAD.DraftWorkingPlane @@ -696,7 +709,7 @@ class ghostTracker(Tracker): self.children.append(rootsep) super().__init__(dotted, scolor, swidth, children=self.children, name="ghostTracker") - self.setColor() + self.setColor(scolor) def setColor(self, color=None): """Set the color.""" diff --git a/src/Mod/Draft/draftutils/gui_utils.py b/src/Mod/Draft/draftutils/gui_utils.py index 36c02b8d02..2625ce6004 100644 --- a/src/Mod/Draft/draftutils/gui_utils.py +++ b/src/Mod/Draft/draftutils/gui_utils.py @@ -436,94 +436,73 @@ def get_diffuse_color(objs): def format_object(target, origin=None): - """Apply visual properties from the Draft toolbar or another object. + """Apply visual properties to an object. - This function only works if the graphical interface is available - as the visual properties are attributes of the view provider - (`obj.ViewObject`). + This function only works if the graphical interface is available. + + If construction mode is active the `origin` argument is ignored. + The `target` is then placed in the construction group and the `constr` + color is applied to its applicable color properties: + `TextColor`, `PointColor`, `LineColor`, and `ShapeColor`. Parameters ---------- target: App::DocumentObject - Any type of scripted object. - - This object will adopt the applicable visual properties, - `FontSize`, `TextColor`, `LineWidth`, `PointColor`, `LineColor`, - and `ShapeColor`, defined in the Draft toolbar - (`Gui.draftToolBar`) or will adopt - the properties from the `origin` object. - - The `target` is also placed in the construction group - if the construction mode in the Draft toolbar is active. origin: App::DocumentObject, optional - It defaults to `None`. - If it exists, it will provide the visual properties to assign - to `target`, with the exception of `BoundingBox`, `Proxy`, - `RootNode` and `Visibility`. + Defaults to `None`. + If construction mode is not active, its visual properties are assigned + to `target`, with the exception of `BoundingBox`, `Proxy`, `RootNode` + and `Visibility`. """ if not target: return - obrep = target.ViewObject - if not obrep: + if not App.GuiUp: return - ui = None - if App.GuiUp: - if hasattr(Gui, "draftToolBar"): - ui = Gui.draftToolBar - if ui: + if not hasattr(Gui, "draftToolBar"): + return + if not hasattr(target, 'ViewObject'): + return + obrep = target.ViewObject + if Gui.draftToolBar.isConstructionMode(): doc = App.ActiveDocument - if ui.isConstructionMode(): - lcol = fcol = ui.getDefaultColor("constr") - tcol = lcol - fcol = lcol - grp = doc.getObject("Draft_Construction") - if not grp: - grp = doc.addObject("App::DocumentObjectGroup", "Draft_Construction") - grp.Label = utils.get_param("constructiongroupname", "Construction") - grp.addObject(target) - if hasattr(obrep, "Transparency"): - obrep.Transparency = 80 - else: - lcol = ui.getDefaultColor("line") - tcol = ui.getDefaultColor("text") - fcol = ui.getDefaultColor("face") - lcol = (float(lcol[0]), float(lcol[1]), float(lcol[2]), 0.0) - tcol = (float(tcol[0]), float(tcol[1]), float(tcol[2]), 0.0) - fcol = (float(fcol[0]), float(fcol[1]), float(fcol[2]), 0.0) - lw = utils.getParam("linewidth",2) - if not origin or not hasattr(origin, 'ViewObject'): - if "TextColor" in obrep.PropertiesList: - obrep.TextColor = tcol - if "LineWidth" in obrep.PropertiesList: - obrep.LineWidth = lw - if "PointColor" in obrep.PropertiesList: - obrep.PointColor = lcol - if "LineColor" in obrep.PropertiesList: - obrep.LineColor = lcol - if "ShapeColor" in obrep.PropertiesList: - obrep.ShapeColor = fcol - else: - matchrep = origin.ViewObject - for p in matchrep.PropertiesList: - if p not in ("DisplayMode", "BoundingBox", - "Proxy", "RootNode", "Visibility"): - if p in obrep.PropertiesList: - if not obrep.getEditorMode(p): - if hasattr(getattr(matchrep, p), "Value"): - val = getattr(matchrep, p).Value - else: - val = getattr(matchrep, p) - try: - setattr(obrep, p, val) - except Exception: - pass - if matchrep.DisplayMode in obrep.listDisplayModes(): - obrep.DisplayMode = matchrep.DisplayMode - if hasattr(obrep, "DiffuseColor"): - difcol = get_diffuse_color(origin) - if difcol: - obrep.DiffuseColor = difcol + col = Gui.draftToolBar.getDefaultColor("constr") + (0.0,) + grp = doc.getObject("Draft_Construction") + if not grp: + grp = doc.addObject("App::DocumentObjectGroup", "Draft_Construction") + grp.Label = utils.get_param("constructiongroupname", "Construction") + grp.addObject(target) + if "TextColor" in obrep.PropertiesList: + obrep.TextColor = col + if "PointColor" in obrep.PropertiesList: + obrep.PointColor = col + if "LineColor" in obrep.PropertiesList: + obrep.LineColor = col + if "ShapeColor" in obrep.PropertiesList: + obrep.ShapeColor = col + if hasattr(obrep, "Transparency"): + obrep.Transparency = 80 + elif origin and hasattr(origin, 'ViewObject'): + matchrep = origin.ViewObject + for p in matchrep.PropertiesList: + if p not in ("DisplayMode", "BoundingBox", + "Proxy", "RootNode", "Visibility"): + if p in obrep.PropertiesList: + if not obrep.getEditorMode(p): + if hasattr(getattr(matchrep, p), "Value"): + val = getattr(matchrep, p).Value + else: + val = getattr(matchrep, p) + try: + setattr(obrep, p, val) + except Exception: + pass + if matchrep.DisplayMode in obrep.listDisplayModes(): + obrep.DisplayMode = matchrep.DisplayMode + if hasattr(obrep, "DiffuseColor"): + difcol = get_diffuse_color(origin) + if difcol: + obrep.DiffuseColor = difcol formatObject = format_object diff --git a/src/Mod/Draft/draftutils/utils.py b/src/Mod/Draft/draftutils/utils.py index 285f0faa15..4b3580cd01 100644 --- a/src/Mod/Draft/draftutils/utils.py +++ b/src/Mod/Draft/draftutils/utils.py @@ -58,28 +58,27 @@ arrowtypes = ARROW_TYPES def get_default_annotation_style(): - param_draft = App.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft") - param_view = App.ParamGet("User parameter:BaseApp/Preferences/View") - anno_scale = param_draft.GetFloat("DraftAnnotationScale", 1) + param = App.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft") + anno_scale = param.GetFloat("DraftAnnotationScale", 1) scale_mult = 1 / anno_scale if anno_scale > 0 else 1 return { - "ArrowSize": ("float", param_draft.GetFloat("arrowsize", 20)), - "ArrowType": ("index", param_draft.GetInt("dimsymbol", 0)), - "Decimals": ("int", param_draft.GetInt("dimPrecision", 2)), - "DimOvershoot": ("float", param_draft.GetFloat("dimovershoot", 20)), - "ExtLines": ("float", param_draft.GetFloat("extlines", 300)), - "ExtOvershoot": ("float", param_draft.GetFloat("extovershoot", 20)), - "FontName": ("font", param_draft.GetString("textfont", "Sans")), - "FontSize": ("float", param_draft.GetFloat("textheight", 100)), - "LineColor": ("color", param_view.GetUnsigned("DefaultShapeLineColor", 255)), - "LineSpacing": ("float", param_draft.GetFloat("LineSpacing", 1)), - "LineWidth": ("int", param_view.GetInt("DefaultShapeLineWidth", 1)), + "ArrowSize": ("float", param.GetFloat("arrowsize", 20)), + "ArrowType": ("index", param.GetInt("dimsymbol", 0)), + "Decimals": ("int", param.GetInt("dimPrecision", 2)), + "DimOvershoot": ("float", param.GetFloat("dimovershoot", 20)), + "ExtLines": ("float", param.GetFloat("extlines", 300)), + "ExtOvershoot": ("float", param.GetFloat("extovershoot", 20)), + "FontName": ("font", param.GetString("textfont", "Sans")), + "FontSize": ("float", param.GetFloat("textheight", 100)), + "LineColor": ("color", param.GetUnsigned("DefaultAnnoLineColor", 255)), + "LineSpacing": ("float", param.GetFloat("LineSpacing", 1)), + "LineWidth": ("int", param.GetInt("DefaultAnnoLineWidth", 1)), "ScaleMultiplier": ("float", scale_mult), - "ShowLine": ("bool", param_draft.GetBool("DimShowLine", True)), - "ShowUnit": ("bool", param_draft.GetBool("showUnit", True)), - "TextColor": ("color", param_draft.GetUnsigned("DefaultTextColor", 255)), - "TextSpacing": ("float", param_draft.GetFloat("dimspacing", 20)), - "UnitOverride": ("str", param_draft.GetString("overrideUnit", "")), + "ShowLine": ("bool", param.GetBool("DimShowLine", True)), + "ShowUnit": ("bool", param.GetBool("showUnit", True)), + "TextColor": ("color", param.GetUnsigned("DefaultTextColor", 255)), + "TextSpacing": ("float", param.GetFloat("dimspacing", 20)), + "UnitOverride": ("str", param.GetString("overrideUnit", "")), } @@ -173,7 +172,8 @@ def get_param_type(param): "precision", "defaultWP", "snapRange", "gridEvery", "linewidth", "modconstrain", "modsnap", "maxSnapEdges", "modalt", "HatchPatternResolution", - "snapStyle", "DefaultAnnoDisplayMode", "gridSize", "gridTransparency"): + "snapStyle", "DefaultAnnoDisplayMode", "DefaultAnnoLineWidth", + "gridSize", "gridTransparency"): return "int" elif param in ("constructiongroupname", "textfont", "patternFile", "snapModes", @@ -192,8 +192,8 @@ def get_param_type(param): "DiscretizeEllipses", "showUnit", "coloredGridAxes", "Draft_array_fuse", "Draft_array_Link", "gridBorder"): return "bool" - elif param in ("color", "constructioncolor", - "snapcolor", "gridColor"): + elif param in ("color", "constructioncolor", "snapcolor", + "gridColor", "DefaultTextColor", "DefaultAnnoLineColor"): return "unsigned" else: return None @@ -832,6 +832,27 @@ def rgba_to_argb(color): return ((color & 0xFFFFFF00) >> 8) + ((color & 0xFF) << 24) +def get_rgba_tuple(color, typ=1.0): + """Return an RGBA tuple. + + Parameters + ---------- + color: int + RGBA integer. + typ: any float (default = 1.0) or int (use 255) + If float the values in the returned tuple are in the 0.0-1.0 range. + Else the values are in the 0-255 range. + """ + color = ((color >> 24) & 0xFF, + (color >> 16) & 0xFF, + (color >> 8) & 0xFF, + color & 0xFF) + if type(typ) == float: + return tuple([x / 255.0 for x in color]) + else: + return color + + def filter_objects_for_modifiers(objects, isCopied=False): filteredObjects = [] for obj in objects: diff --git a/src/Mod/Draft/draftviewproviders/view_dimension.py b/src/Mod/Draft/draftviewproviders/view_dimension.py index 83b9a7a271..7813d6968b 100644 --- a/src/Mod/Draft/draftviewproviders/view_dimension.py +++ b/src/Mod/Draft/draftviewproviders/view_dimension.py @@ -358,6 +358,7 @@ class ViewProviderLinearDimension(ViewProviderDimensionBase): self.onChanged(vobj, "DimOvershoot") self.onChanged(vobj, "ExtOvershoot") self.onChanged(vobj, "ShowLine") + self.onChanged(vobj, "LineWidth") def updateData(self, obj, prop): """Execute when a property from the Proxy class is changed. diff --git a/src/Mod/Draft/draftviewproviders/view_draft_annotation.py b/src/Mod/Draft/draftviewproviders/view_draft_annotation.py index 6b985ae3e6..886e1aa895 100644 --- a/src/Mod/Draft/draftviewproviders/view_draft_annotation.py +++ b/src/Mod/Draft/draftviewproviders/view_draft_annotation.py @@ -141,6 +141,7 @@ class ViewProviderDraftAnnotation(object): "TextColor", "Text", _tip) + vobj.TextColor = utils.get_param("DefaultTextColor", 255) & 0xFFFFFF00 def set_units_properties(self, vobj, properties): return @@ -153,6 +154,7 @@ class ViewProviderDraftAnnotation(object): "LineWidth", "Graphics", _tip) + vobj.LineWidth = utils.get_param("DefaultAnnoLineWidth", 2) if "LineColor" not in properties: _tip = QT_TRANSLATE_NOOP("App::Property", "Line color") @@ -160,6 +162,7 @@ class ViewProviderDraftAnnotation(object): "LineColor", "Graphics", _tip) + vobj.LineColor = utils.get_param("DefaultAnnoLineColor", 255) & 0xFFFFFF00 def dumps(self): """Return a tuple of objects to save or None."""