Skip to content

Commit

Permalink
Draft: add new viewprovider icon for radius dimension
Browse files Browse the repository at this point in the history
If it is a linear dimension show the older icon;
if it is a radius or diameter dimension show a new icon.

These three modes use the same Proxy class
and the same viewprovider class. Depending on the linked geometry
one icon or the other will be shown.
  • Loading branch information
vocx-fc authored and yorikvanhavre committed Mar 12, 2020
1 parent 3e3ed47 commit e41915e
Show file tree
Hide file tree
Showing 3 changed files with 415 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/Mod/Draft/Draft.py
Expand Up @@ -46,6 +46,7 @@
"""The Draft module offers a range of tools to create and manipulate basic 2D objects"""

import FreeCAD, math, sys, os, DraftVecUtils, WorkingPlane
import DraftGeomUtils
import draftutils.translate
from FreeCAD import Vector
from PySide.QtCore import QT_TRANSLATE_NOOP
Expand Down Expand Up @@ -3864,7 +3865,21 @@ def getDefaultDisplayMode(self):
def setDisplayMode(self,mode):
return mode

def is_linked_to_circle(self):
_obj = self.Object
if _obj.LinkedGeometry and len(_obj.LinkedGeometry) == 1:
lobj = _obj.LinkedGeometry[0][0]
lsub = _obj.LinkedGeometry[0][1]
if len(lsub) == 1 and "Edge" in lsub[0]:
n = int(lsub[0][4:]) - 1
edge = lobj.Shape.Edges[n]
if DraftGeomUtils.geomType(edge) == "Circle":
return True
return False

def getIcon(self):
if self.is_linked_to_circle():
return ":/icons/Draft_DimensionRadius.svg"
return ":/icons/Draft_Dimension_Tree.svg"

def __getstate__(self):
Expand Down
1 change: 1 addition & 0 deletions src/Mod/Draft/Resources/Draft.qrc
Expand Up @@ -25,6 +25,7 @@
<file>icons/Draft_Dimension.svg</file>
<file>icons/Draft_Dimension_Tree.svg</file>
<file>icons/Draft_DimensionAngular.svg</file>
<file>icons/Draft_DimensionRadius.svg</file>
<file>icons/Draft_Dot.svg</file>
<file>icons/Draft_Downgrade.svg</file>
<file>icons/Draft_Draft.svg</file>
Expand Down

0 comments on commit e41915e

Please sign in to comment.