Merge branch 'master' into master

This commit is contained in:
Schildkroet
2019-08-23 15:01:34 +02:00
committed by GitHub
98 changed files with 6897 additions and 341 deletions

View File

@@ -135,6 +135,22 @@ void PrefWidget::onRestore()
restorePreferences();
}
void PrefWidget::failedToSave(const QString& name) const
{
QByteArray objname = name.toLatin1();
if (objname.isEmpty())
objname = "Undefined";
Console().Warning("Cannot save %s (%s)\n", typeid(*this).name(), objname.constData());
}
void PrefWidget::failedToRestore(const QString& name) const
{
QByteArray objname = name.toLatin1();
if (objname.isEmpty())
objname = "Undefined";
Console().Warning("Cannot restore %s (%s)\n", typeid(*this).name(), objname.constData());
}
// --------------------------------------------------------------------
PrefSpinBox::PrefSpinBox ( QWidget * parent )
@@ -150,7 +166,7 @@ void PrefSpinBox::restorePreferences()
{
if ( getWindowParameter().isNull() )
{
Console().Warning("Cannot restore!\n");
failedToRestore(objectName());
return;
}
@@ -162,7 +178,7 @@ void PrefSpinBox::savePreferences()
{
if (getWindowParameter().isNull())
{
Console().Warning("Cannot save!\n");
failedToSave(objectName());
return;
}
@@ -184,7 +200,7 @@ void PrefDoubleSpinBox::restorePreferences()
{
if ( getWindowParameter().isNull() )
{
Console().Warning("Cannot restore!\n");
failedToRestore(objectName());
return;
}
@@ -196,7 +212,7 @@ void PrefDoubleSpinBox::savePreferences()
{
if (getWindowParameter().isNull())
{
Console().Warning("Cannot save!\n");
failedToSave(objectName());
return;
}
@@ -218,7 +234,7 @@ void PrefLineEdit::restorePreferences()
{
if (getWindowParameter().isNull())
{
Console().Warning("Cannot restore!\n");
failedToRestore(objectName());
return;
}
@@ -231,7 +247,7 @@ void PrefLineEdit::savePreferences()
{
if (getWindowParameter().isNull())
{
Console().Warning("Cannot save!\n");
failedToSave(objectName());
return;
}
@@ -253,7 +269,7 @@ void PrefFileChooser::restorePreferences()
{
if (getWindowParameter().isNull())
{
Console().Warning("Cannot restore!\n");
failedToRestore(objectName());
return;
}
@@ -265,7 +281,7 @@ void PrefFileChooser::savePreferences()
{
if (getWindowParameter().isNull())
{
Console().Warning("Cannot save!\n");
failedToSave(objectName());
return;
}
@@ -287,7 +303,7 @@ void PrefComboBox::restorePreferences()
{
if (getWindowParameter().isNull())
{
Console().Warning("Cannot restore!\n");
failedToRestore(objectName());
return;
}
@@ -299,7 +315,7 @@ void PrefComboBox::savePreferences()
{
if (getWindowParameter().isNull())
{
Console().Warning("Cannot save!\n");
failedToSave(objectName());
return;
}
@@ -321,7 +337,7 @@ void PrefCheckBox::restorePreferences()
{
if (getWindowParameter().isNull())
{
Console().Warning("Cannot restore!\n");
failedToRestore(objectName());
return;
}
@@ -333,7 +349,7 @@ void PrefCheckBox::savePreferences()
{
if (getWindowParameter().isNull())
{
Console().Warning("Cannot save!\n");
failedToSave(objectName());
return;
}
@@ -355,7 +371,7 @@ void PrefRadioButton::restorePreferences()
{
if (getWindowParameter().isNull())
{
Console().Warning("Cannot restore!\n");
failedToRestore(objectName());
return;
}
@@ -367,7 +383,7 @@ void PrefRadioButton::savePreferences()
{
if (getWindowParameter().isNull())
{
Console().Warning("Cannot save!\n");
failedToSave(objectName());
return;
}
@@ -389,7 +405,7 @@ void PrefSlider::restorePreferences()
{
if ( getWindowParameter().isNull() )
{
Console().Warning("Cannot restore!\n");
failedToRestore(objectName());
return;
}
@@ -401,7 +417,7 @@ void PrefSlider::savePreferences()
{
if (getWindowParameter().isNull())
{
Console().Warning("Cannot save!\n");
failedToSave(objectName());
return;
}
@@ -423,7 +439,7 @@ void PrefColorButton::restorePreferences()
{
if (getWindowParameter().isNull())
{
Console().Warning("Cannot restore!\n");
failedToRestore(objectName());
return;
}
@@ -445,7 +461,7 @@ void PrefColorButton::savePreferences()
{
if (getWindowParameter().isNull())
{
Console().Warning("Cannot save!\n");
failedToSave(objectName());
return;
}
@@ -470,7 +486,7 @@ PrefUnitSpinBox::~PrefUnitSpinBox()
void PrefUnitSpinBox::restorePreferences()
{
if (getWindowParameter().isNull()) {
Console().Warning("Cannot restore!\n");
failedToRestore(objectName());
return;
}
@@ -481,7 +497,7 @@ void PrefUnitSpinBox::restorePreferences()
void PrefUnitSpinBox::savePreferences()
{
if (getWindowParameter().isNull()) {
Console().Warning("Cannot save!\n");
failedToSave(objectName());
return;
}
@@ -689,7 +705,7 @@ void PrefFontBox::restorePreferences()
{
if ( getWindowParameter().isNull() )
{
Console().Warning("Cannot restore!\n");
failedToRestore(objectName());
return;
}
@@ -706,7 +722,7 @@ void PrefFontBox::savePreferences()
{
if (getWindowParameter().isNull())
{
Console().Warning("Cannot save!\n");
failedToSave(objectName());
return;
}

View File

@@ -76,6 +76,12 @@ protected:
* Must be reimplemented in any subclasses.
*/
virtual void savePreferences() = 0;
/** Print warning that saving failed.
*/
void failedToSave(const QString&) const;
/** Print warning that restoring failed.
*/
void failedToRestore(const QString&) const;
PrefWidget();
virtual ~PrefWidget();

View File

@@ -587,4 +587,13 @@ class CommandAddonManager:
pref.SetBool("AutoCheck",self.config.checkUpdates.isChecked())
pref.SetString("CustomRepositories",self.config.customRepositories.toPlainText())
def check_updates(addon_name,callback):
"""Checks for updates for a given addon"""
oname = "update_checker_"+addon_name
setattr(FreeCAD,oname,CheckSingleWorker(addon_name))
getattr(FreeCAD,oname).updateAvailable.connect(callback)
getattr(FreeCAD,oname).start()
## @}

View File

@@ -713,3 +713,36 @@ class InstallWorker(QtCore.QThread):
if bakdir:
shutil.rmtree(bakdir)
return translate("AddonsInstaller", "Successfully installed") + " " + zipurl
class CheckSingleWorker(QtCore.QThread):
"""Worker to check for updates for a single addon"""
updateAvailable = QtCore.Signal(bool)
def __init__(self, name):
QtCore.QThread.__init__(self)
self.name = name
def run(self):
try:
import git
except:
return
FreeCAD.Console.PrintLog("Checking for available updates of the "+name+" addon\n")
addondir = os.path.join(FreeCAD.getUserAppDataDir(),"Mod",name)
if os.path.exists(addondir):
if os.path.exists(addondir + os.sep + '.git'):
gitrepo = git.Git(addondir)
try:
gitrepo.fetch()
if "git pull" in gitrepo.status():
self.updateAvailable.emit(True)
return
except:
# can fail for any number of reasons, ex. not being online
pass
self.updateAvailable.emit(False)

View File

@@ -1085,11 +1085,10 @@ class _Window(ArchComponent.Component):
e = obj.Base.Shape.Edges[hinge]
ev1 = e.Vertexes[0].Point
ev2 = e.Vertexes[-1].Point
if (ev2.z - ev1.z) < 0.1**Draft.precision():
if ev2.y < ev1.y:
ev1,ev2 = ev2,ev1
elif ev2.z < ev1.z:
# choose the one with lowest z to draw the symbol
if ev2.z < ev1.z:
ev1,ev2 = ev2,ev1
# find the point most distant from the hinge
p = None
d = 0
for v in shape.Vertexes:
@@ -1098,13 +1097,16 @@ class _Window(ArchComponent.Component):
d = dist
p = v.Point
if p:
# bring that point to the level of ev1 if needed
chord = p.sub(ev1)
enorm = ev2.sub(ev1)
proj = DraftVecUtils.project(chord,enorm)
v1 = ev1
if proj.Length > 0:
chord = p.sub(ev1.add(proj))
p = v1.add(chord)
#chord = p.sub(ev1.add(proj))
#p = v1.add(chord)
p = p.add(proj.negative())
# calculate symbols
v4 = p.add(DraftVecUtils.scale(enorm,0.5))
if omode == 1: # Arc 90
v2 = v1.add(DraftVecUtils.rotate(chord,math.pi/4,enorm))

View File

@@ -228,6 +228,12 @@
<property name="checked">
<bool>true</bool>
</property>
<property name="prefEntry" stdset="0">
<cstring>UseMaterialColor</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>Mod/Arch</cstring>
</property>
</widget>
</item>
<item>

View File

@@ -144,42 +144,35 @@ def getPreferences():
"""retrieves IFC preferences"""
global DEBUG, PREFIX_NUMBERS, SKIP, SEPARATE_OPENINGS
global ROOT_ELEMENT, GET_EXTRUSIONS, MERGE_MATERIALS
global MERGE_MODE_ARCH, MERGE_MODE_STRUCT, CREATE_CLONES
global FORCE_BREP, IMPORT_PROPERTIES, STORE_UID, SERIALIZE
global SPLIT_LAYERS, EXPORT_2D, FULL_PARAMETRIC, FITVIEW_ONIMPORT
global ADD_DEFAULT_SITE, ADD_DEFAULT_STOREY, ADD_DEFAULT_BUILDING
p = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch")
if FreeCAD.GuiUp and p.GetBool("ifcShowDialog",False):
import FreeCADGui
FreeCADGui.showPreferences("Import-Export",0)
DEBUG = p.GetBool("ifcDebug",False)
PREFIX_NUMBERS = p.GetBool("ifcPrefixNumbers",False)
SKIP = p.GetString("ifcSkip","").split(",")
SEPARATE_OPENINGS = p.GetBool("ifcSeparateOpenings",False)
ROOT_ELEMENT = p.GetString("ifcRootElement","IfcProduct")
GET_EXTRUSIONS = p.GetBool("ifcGetExtrusions",False)
MERGE_MATERIALS = p.GetBool("ifcMergeMaterials",False)
MERGE_MODE_ARCH = p.GetInt("ifcImportModeArch",0)
MERGE_MODE_STRUCT = p.GetInt("ifcImportModeStruct",1)
if MERGE_MODE_ARCH > 0:
SEPARATE_OPENINGS = False
GET_EXTRUSIONS = False
if not SEPARATE_OPENINGS:
SKIP.append("IfcOpeningElement")
CREATE_CLONES = p.GetBool("ifcCreateClones",True)
FORCE_BREP = p.GetBool("ifcExportAsBrep",False)
IMPORT_PROPERTIES = p.GetBool("ifcImportProperties",False)
STORE_UID = p.GetBool("ifcStoreUid",True)
SERIALIZE = p.GetBool("ifcSerialize",False)
SPLIT_LAYERS = p.GetBool("ifcSplitLayers",False)
EXPORT_2D = p.GetBool("ifcExport2D",True)
FULL_PARAMETRIC = p.GetBool("IfcExportFreeCADProperties",False)
FITVIEW_ONIMPORT = p.GetBool("ifcFitViewOnImport",False)
ADD_DEFAULT_SITE = p.GetBool("IfcAddDefaultSite",False)
ADD_DEFAULT_STOREY = p.GetBool("IfcAddDefaultStorey",False)
ADD_DEFAULT_BUILDING = p.GetBool("IfcAddDefaultBuilding",True)
preferences = {
'DEBUG': p.GetBool("ifcDebug",False),
'PREFIX_NUMBERS': p.GetBool("ifcPrefixNumbers",False),
'SKIP': p.GetString("ifcSkip","").split(","),
'SEPARATE_OPENINGS': p.GetBool("ifcSeparateOpenings",False),
'ROOT_ELEMENT': p.GetString("ifcRootElement","IfcProduct"),
'GET_EXTRUSIONS': p.GetBool("ifcGetExtrusions",False),
'MERGE_MATERIALS': p.GetBool("ifcMergeMaterials",False),
'MERGE_MODE_ARCH': p.GetInt("ifcImportModeArch",0),
'MERGE_MODE_STRUCT': p.GetInt("ifcImportModeStruct",1),
'CREATE_CLONES': p.GetBool("ifcCreateClones",True),
'IMPORT_PROPERTIES': p.GetBool("ifcImportProperties",False),
'SPLIT_LAYERS': p.GetBool("ifcSplitLayers",False),
'FITVIEW_ONIMPORT': p.GetBool("ifcFitViewOnImport",False)
}
if preferences['MERGE_MODE_ARCH'] > 0:
preferences['SEPARATE_OPENINGS'] = False
preferences['GET_EXTRUSIONS'] = False
if not preferences['SEPARATE_OPENINGS']:
preferences['SKIP'].append("IfcOpeningElement")
return preferences
# ************************************************************************************************
@@ -197,7 +190,7 @@ def open(filename,skip=[],only=[],root=None):
return doc
def insert(filename,docname,skip=[],only=[],root=None):
def insert(filename,docname,skip=[],only=[],root=None,preferences=None):
"""insert(filename,docname,skip=[],only=[],root=None): imports the contents of an IFC file.
skip can contain a list of ids of objects to be skipped, only can restrict the import to
@@ -205,7 +198,8 @@ def insert(filename,docname,skip=[],only=[],root=None):
import only the derivates of a certain element type (default = ifcProduct)."""
# read preference settings
getPreferences()
if preferences is None:
preferences = getPreferences()
try:
import ifcopenshell
@@ -213,19 +207,19 @@ def insert(filename,docname,skip=[],only=[],root=None):
FreeCAD.Console.PrintError("IfcOpenShell was not found on this system. IFC support is disabled\n")
return
if DEBUG: print("Opening ",filename,"...",end="")
if preferences['DEBUG']: print("Opening ",filename,"...",end="")
try:
doc = FreeCAD.getDocument(docname)
except:
doc = FreeCAD.newDocument(docname)
FreeCAD.ActiveDocument = doc
if DEBUG: print("done.")
if preferences['DEBUG']: print("done.")
global ROOT_ELEMENT, parametrics
global parametrics
# allow to override the root element
if root:
ROOT_ELEMENT = root
preferences['ROOT_ELEMENT'] = root
# keeping global variable for debugging purposes
# global ifcfile
@@ -249,20 +243,20 @@ def insert(filename,docname,skip=[],only=[],root=None):
settings.set(settings.USE_BREP_DATA,True)
settings.set(settings.SEW_SHELLS,True)
settings.set(settings.USE_WORLD_COORDS,True)
if SEPARATE_OPENINGS:
if preferences['SEPARATE_OPENINGS']:
settings.set(settings.DISABLE_OPENING_SUBTRACTIONS,True)
if SPLIT_LAYERS and hasattr(settings,"APPLY_LAYERSETS"):
if preferences['SPLIT_LAYERS'] and hasattr(settings,"APPLY_LAYERSETS"):
settings.set(settings.APPLY_LAYERSETS,True)
# build all needed tables
if DEBUG: print("Building types and relationships table...",end="")
if preferences['DEBUG']: print("Building types and relationships table...",end="")
# type tables
sites = ifcfile.by_type("IfcSite")
buildings = ifcfile.by_type("IfcBuilding")
floors = ifcfile.by_type("IfcBuildingStorey")
openings = ifcfile.by_type("IfcOpeningElement")
materials = ifcfile.by_type("IfcMaterial")
products, annotations = importIFCHelper.buildRelProductsAnnotations(ifcfile, ROOT_ELEMENT)
products, annotations = importIFCHelper.buildRelProductsAnnotations(ifcfile, preferences['ROOT_ELEMENT'])
# empty relation tables
objects = {} # { id:object, ... }
shapes = {} # { id:shaoe } only used for merge mode
@@ -279,7 +273,7 @@ def insert(filename,docname,skip=[],only=[],root=None):
subtractions = importIFCHelper.buildRelSubtractions(ifcfile)
mattable = importIFCHelper.buildRelMattable(ifcfile)
colors, style_material_id = importIFCHelper.buildRelColors(ifcfile, prodrepr)
if DEBUG: print("done.")
if preferences['DEBUG']: print("done.")
# only import a list of IDs and their children, if defined
if only:
@@ -296,10 +290,10 @@ def insert(filename,docname,skip=[],only=[],root=None):
from FreeCAD import Base
progressbar = Base.ProgressIndicator()
progressbar.start("Importing IFC objects...",len(products))
if DEBUG: print("Parsing",len(products),"BIM objects...")
if preferences['DEBUG']: print("Parsing",len(products),"BIM objects...")
# Prepare the 3D view if applicable
if FITVIEW_ONIMPORT and FreeCAD.GuiUp:
if preferences['FITVIEW_ONIMPORT'] and FreeCAD.GuiUp:
overallboundbox = None
import FreeCADGui
FreeCADGui.ActiveDocument.activeView().viewAxonometric()
@@ -317,7 +311,7 @@ def insert(filename,docname,skip=[],only=[],root=None):
pid = product.id()
guid = product.GlobalId
ptype = product.is_a()
if DEBUG: print(count,"/",len(products),"object #"+str(pid),":",ptype,end="")
if preferences['DEBUG']: print(count,"/",len(products),"object #"+str(pid),":",ptype,end="")
# build list of related property sets
psets = importIFCHelper.getIfcPropertySets(ifcfile, pid)
@@ -325,14 +319,14 @@ def insert(filename,docname,skip=[],only=[],root=None):
# checking for full FreeCAD parametric definition, overriding everything else
if psets and FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch").GetBool("IfcImportFreeCADProperties",False):
if "FreeCADPropertySet" in [ifcfile[pset].Name for pset in psets.keys()]:
if DEBUG: print(" restoring from parametric definition...",end="")
if preferences['DEBUG']: print(" restoring from parametric definition...",end="")
obj = createFromProperties(psets,ifcfile)
if obj:
objects[pid] = obj
if DEBUG: print("done")
if preferences['DEBUG']: print("done")
continue
else:
if DEBUG: print("failed")
if preferences['DEBUG']: print("failed")
# no parametric data, we go the good old way
name = str(ptype[3:])
@@ -340,7 +334,7 @@ def insert(filename,docname,skip=[],only=[],root=None):
name = product.Name
if six.PY2:
name = name.encode("utf8")
if PREFIX_NUMBERS:
if preferences['PREFIX_NUMBERS']:
name = "ID" + str(pid) + " " + name
obj = None
baseobj = None
@@ -353,20 +347,20 @@ def insert(filename,docname,skip=[],only=[],root=None):
if ptype in structuralifcobjects:
archobj = False
structobj = True
if DEBUG: print(" (struct)",end="")
if preferences['DEBUG']: print(" (struct)",end="")
else:
if DEBUG: print(" (arch)",end="")
if MERGE_MODE_ARCH == 4 and archobj:
if DEBUG: print(" skipped.")
if preferences['DEBUG']: print(" (arch)",end="")
if preferences['MERGE_MODE_ARCH'] == 4 and archobj:
if preferences['DEBUG']: print(" skipped.")
continue
if MERGE_MODE_STRUCT == 3 and not archobj:
if DEBUG: print(" skipped.")
if preferences['MERGE_MODE_STRUCT'] == 3 and not archobj:
if preferences['DEBUG']: print(" skipped.")
continue
if pid in skip: # user given id skip list
if DEBUG: print(" skipped.")
if preferences['DEBUG']: print(" skipped.")
continue
if ptype in SKIP: # preferences-set type skip list
if DEBUG: print(" skipped.")
if ptype in preferences['SKIP']: # preferences-set type skip list
if preferences['DEBUG']: print(" skipped.")
continue
# check if this object is sharing its shape (mapped representation)
@@ -376,8 +370,8 @@ def insert(filename,docname,skip=[],only=[],root=None):
try:
prepr = product.Representation
except:
if DEBUG: print(" ERROR unable to get object representation",end="")
if prepr and (MERGE_MODE_ARCH == 0) and archobj and CREATE_CLONES:
if preferences['DEBUG']: print(" ERROR unable to get object representation",end="")
if prepr and (preferences['MERGE_MODE_ARCH'] == 0) and archobj and preferences['CREATE_CLONES']:
for r in prepr.Representations:
if r.RepresentationIdentifier.upper() == "BODY":
if r.Items[0].is_a("IfcMappedItem"):
@@ -402,7 +396,7 @@ def insert(filename,docname,skip=[],only=[],root=None):
# from now on we have a brep string
if brep:
if DEBUG: print(" "+str(int(len(brep)/1000))+"k ",end="")
if preferences['DEBUG']: print(" "+str(int(len(brep)/1000))+"k ",end="")
# create a Part shape
shape = Part.Shape()
@@ -410,19 +404,19 @@ def insert(filename,docname,skip=[],only=[],root=None):
shape.scale(1000.0) # IfcOpenShell always outputs in meters, we convert to mm, the freecad internal unit
if shape.isNull():
if DEBUG: print("null shape ",end="")
if preferences['DEBUG']: print("null shape ",end="")
elif not shape.isValid():
if DEBUG: print("invalid shape ",end="")
if preferences['DEBUG']: print("invalid shape ",end="")
else:
# add to the global boundbox if applicable
if FITVIEW_ONIMPORT and FreeCAD.GuiUp:
if preferences['FITVIEW_ONIMPORT'] and FreeCAD.GuiUp:
try:
bb = shape.BoundBox
# if DEBUG: print(' ' + str(bb),end="")
# if preferences['DEBUG']: print(' ' + str(bb),end="")
except:
bb = None
if DEBUG: print(' BB could not be computed',end="")
if preferences['DEBUG']: print(' BB could not be computed',end="")
if bb and bb.isValid():
if not overallboundbox:
overallboundbox = bb
@@ -430,27 +424,27 @@ def insert(filename,docname,skip=[],only=[],root=None):
FreeCADGui.SendMsgToActiveView("ViewFit")
overallboundbox.add(bb)
if (MERGE_MODE_ARCH > 0 and archobj) or structobj:
if (preferences['MERGE_MODE_ARCH'] > 0 and archobj) or structobj:
# we are not using Arch objects
# additional tweaks to set when not using Arch objects
if ptype == "IfcSpace": # do not add spaces to compounds
if DEBUG: print("skipping space ",pid,end="")
if preferences['DEBUG']: print("skipping space ",pid,end="")
elif structobj:
structshapes[pid] = shape
if DEBUG: print(len(shape.Solids),"solids ",end="")
if preferences['DEBUG']: print(len(shape.Solids),"solids ",end="")
baseobj = shape
else:
shapes[pid] = shape
if DEBUG: print(len(shape.Solids),"solids ",end="")
if preferences['DEBUG']: print(len(shape.Solids),"solids ",end="")
baseobj = shape
else:
# create base shape object
if clone:
if DEBUG: print("clone ",end="")
if preferences['DEBUG']: print("clone ",end="")
else:
if GET_EXTRUSIONS and (MERGE_MODE_ARCH != 1):
if preferences['GET_EXTRUSIONS'] and (preferences['MERGE_MODE_ARCH'] != 1):
# recompose extrusions from a shape
if ptype in ["IfcWall","IfcWallStandardCase","IfcSpace"]:
@@ -528,11 +522,11 @@ def insert(filename,docname,skip=[],only=[],root=None):
baseobj.Shape = shape
else:
# this object has no shape (storeys, etc...)
if DEBUG: print(" no brep ",end="")
if preferences['DEBUG']: print(" no brep ",end="")
# we now have the shape, we create the final object
if MERGE_MODE_ARCH == 0 and archobj:
if preferences['MERGE_MODE_ARCH'] == 0 and archobj:
# full Arch objects
@@ -598,7 +592,7 @@ def insert(filename,docname,skip=[],only=[],root=None):
# set additional properties
obj.Label = name
if DEBUG: print(": "+obj.Label+" ",end="")
if preferences['DEBUG']: print(": "+obj.Label+" ",end="")
if hasattr(obj,"Description") and hasattr(product,"Description"):
if product.Description:
obj.Description = product.Description
@@ -638,7 +632,7 @@ def insert(filename,docname,skip=[],only=[],root=None):
if obj:
# print number of solids
if DEBUG:
if preferences['DEBUG']:
s = ""
if hasattr(obj,"Shape"):
if obj.Shape.Solids:
@@ -646,7 +640,7 @@ def insert(filename,docname,skip=[],only=[],root=None):
print(s,end="")
objects[pid] = obj
elif (MERGE_MODE_ARCH == 1 and archobj) or (MERGE_MODE_STRUCT == 0 and not archobj):
elif (preferences['MERGE_MODE_ARCH'] == 1 and archobj) or (preferences['MERGE_MODE_STRUCT'] == 0 and not archobj):
# non-parametric Arch objects (just Arch components with a shape)
@@ -660,7 +654,7 @@ def insert(filename,docname,skip=[],only=[],root=None):
elif baseobj:
obj = Arch.makeComponent(baseobj,name=name,delete=True)
obj.Label = name
if DEBUG: print(": "+obj.Label+" ",end="")
if preferences['DEBUG']: print(": "+obj.Label+" ",end="")
if hasattr(obj,"Description") and hasattr(product,"Description"):
if product.Description:
obj.Description = product.Description
@@ -674,7 +668,7 @@ def insert(filename,docname,skip=[],only=[],root=None):
a["IfcUID"] = str(guid)
obj.IfcData = a
elif (MERGE_MODE_ARCH == 2 and archobj) or (MERGE_MODE_STRUCT == 1 and not archobj):
elif (preferences['MERGE_MODE_ARCH'] == 2 and archobj) or (preferences['MERGE_MODE_STRUCT'] == 1 and not archobj):
# Part shapes
@@ -689,7 +683,7 @@ def insert(filename,docname,skip=[],only=[],root=None):
obj = FreeCAD.ActiveDocument.addObject("Part::Feature",name)
obj.Shape = shape
if DEBUG: print("") # newline for debug prints, print for a new object should be on a new line
if preferences['DEBUG']: print("") # newline for debug prints, print for a new object should be on a new line
if obj:
@@ -700,7 +694,7 @@ def insert(filename,docname,skip=[],only=[],root=None):
if psets:
if IMPORT_PROPERTIES and hasattr(obj,"IfcProperties"):
if preferences['IMPORT_PROPERTIES'] and hasattr(obj,"IfcProperties"):
# treat as spreadsheet (pref option)
@@ -715,13 +709,13 @@ def insert(filename,docname,skip=[],only=[],root=None):
n = 2
for c in psets.keys():
o = ifcfile[c]
if DEBUG: print("propertyset Name",o.Name,type(o.Name))
if preferences['DEBUG']: print("propertyset Name",o.Name,type(o.Name))
catname = o.Name
for p in psets[c]:
l = ifcfile[p]
lname = l.Name
if l.is_a("IfcPropertySingleValue"):
if DEBUG:
if preferences['DEBUG']:
print("property name",l.Name,type(l.Name))
if six.PY2:
catname = catname.encode("utf8")
@@ -729,7 +723,7 @@ def insert(filename,docname,skip=[],only=[],root=None):
ifc_spreadsheet.set(str('A'+str(n)), catname)
ifc_spreadsheet.set(str('B'+str(n)), lname)
if l.NominalValue:
if DEBUG:
if preferences['DEBUG']:
print("property NominalValue",l.NominalValue.is_a(),type(l.NominalValue.is_a()))
print("property NominalValue.wrappedValue",l.NominalValue.wrappedValue,type(l.NominalValue.wrappedValue))
#print("l.NominalValue.Unit",l.NominalValue.Unit,type(l.NominalValue.Unit))
@@ -768,11 +762,11 @@ def insert(filename,docname,skip=[],only=[],root=None):
# color
if FreeCAD.GuiUp and (pid in colors) and hasattr(obj.ViewObject,"ShapeColor"):
#if DEBUG: print(" setting color: ",int(colors[pid][0]*255),"/",int(colors[pid][1]*255),"/",int(colors[pid][2]*255))
#if preferences['DEBUG']: print(" setting color: ",int(colors[pid][0]*255),"/",int(colors[pid][1]*255),"/",int(colors[pid][2]*255))
obj.ViewObject.ShapeColor = colors[pid]
# if DEBUG is on, recompute after each shape
if DEBUG: FreeCAD.ActiveDocument.recompute()
# if preferences['DEBUG'] is on, recompute after each shape
if preferences['DEBUG']: FreeCAD.ActiveDocument.recompute()
# attached 2D elements
@@ -820,9 +814,9 @@ def insert(filename,docname,skip=[],only=[],root=None):
progressbar.stop()
FreeCAD.ActiveDocument.recompute()
if MERGE_MODE_STRUCT == 2:
if preferences['MERGE_MODE_STRUCT'] == 2:
if DEBUG: print("Joining Structural shapes...",end="")
if preferences['DEBUG']: print("Joining Structural shapes...",end="")
for host,children in groups.items(): # Structural
if ifcfile[host].is_a("IfcStructuralAnalysisModel"):
@@ -833,7 +827,7 @@ def insert(filename,docname,skip=[],only=[],root=None):
del structshapes[c]
if compound:
name = ifcfile[host].Name or "AnalysisModel"
if PREFIX_NUMBERS: name = "ID" + str(host) + " " + name
if preferences['PREFIX_NUMBERS']: name = "ID" + str(host) + " " + name
obj = FreeCAD.ActiveDocument.addObject("Part::Feature",name)
obj.Label = name
obj.Shape = Part.makeCompound(compound)
@@ -841,11 +835,11 @@ def insert(filename,docname,skip=[],only=[],root=None):
obj = FreeCAD.ActiveDocument.addObject("Part::Feature","UnclaimedStruct")
obj.Shape = Part.makeCompound(structshapes.values())
if DEBUG: print("done")
if preferences['DEBUG']: print("done")
else:
if DEBUG: print("Processing Struct relationships...",end="")
if preferences['DEBUG']: print("Processing Struct relationships...",end="")
# groups
@@ -864,13 +858,13 @@ def insert(filename,docname,skip=[],only=[],root=None):
for c in childs_to_delete:
children.remove(c) # to not process the child again in remaining groups
if cobs:
if DEBUG: print("adding ",len(cobs), " object(s) to ", objects[host].Label)
if preferences['DEBUG']: print("adding ",len(cobs), " object(s) to ", objects[host].Label)
Arch.addComponents(cobs,objects[host])
if DEBUG: FreeCAD.ActiveDocument.recompute()
if preferences['DEBUG']: FreeCAD.ActiveDocument.recompute()
if DEBUG: print("done")
if preferences['DEBUG']: print("done")
if MERGE_MODE_ARCH > 2: # if ArchObj is compound or ArchObj not imported
if preferences['MERGE_MODE_ARCH'] > 2: # if ArchObj is compound or ArchObj not imported
FreeCAD.ActiveDocument.recompute()
# cleaning bad shapes
@@ -888,7 +882,7 @@ def insert(filename,docname,skip=[],only=[],root=None):
if ifcfile[host].Name:
grp_name = ifcfile[host].Name
else:
if DEBUG: print("no group name specified for entity: #", ifcfile[host].id(), ", entity type is used!")
if preferences['DEBUG']: print("no group name specified for entity: #", ifcfile[host].id(), ", entity type is used!")
grp_name = ifcfile[host].is_a() + "_" + str(ifcfile[host].id())
if six.PY2:
grp_name = grp_name.encode("utf8")
@@ -902,11 +896,11 @@ def insert(filename,docname,skip=[],only=[],root=None):
else:
remaining[child] = grp
if MERGE_MODE_ARCH == 3:
if preferences['MERGE_MODE_ARCH'] == 3:
# One compound per storey
if DEBUG: print("Joining Arch shapes...",end="")
if preferences['DEBUG']: print("Joining Arch shapes...",end="")
for host,children in additions.items(): # Arch
if ifcfile[host].is_a("IfcBuildingStorey"):
@@ -922,7 +916,7 @@ def insert(filename,docname,skip=[],only=[],root=None):
del shapes[c2]
if compound:
name = ifcfile[host].Name or "Floor"
if PREFIX_NUMBERS: name = "ID" + str(host) + " " + name
if preferences['PREFIX_NUMBERS']: name = "ID" + str(host) + " " + name
obj = FreeCAD.ActiveDocument.addObject("Part::Feature",name)
obj.Label = name
obj.Shape = Part.makeCompound(compound)
@@ -930,24 +924,24 @@ def insert(filename,docname,skip=[],only=[],root=None):
obj = FreeCAD.ActiveDocument.addObject("Part::Feature","UnclaimedArch")
obj.Shape = Part.makeCompound(shapes.values())
if DEBUG: print("done")
if preferences['DEBUG']: print("done")
else:
if DEBUG: print("Processing Arch relationships...",end="")
if preferences['DEBUG']: print("Processing Arch relationships...",end="")
first = True
# subtractions
if SEPARATE_OPENINGS:
if preferences['SEPARATE_OPENINGS']:
for subtraction in subtractions:
if (subtraction[0] in objects.keys()) and (subtraction[1] in objects.keys()):
if DEBUG and first:
if preferences['DEBUG'] and first:
print("")
first = False
if DEBUG: print(" subtracting",objects[subtraction[0]].Label, "from", objects[subtraction[1]].Label)
if preferences['DEBUG']: print(" subtracting",objects[subtraction[0]].Label, "from", objects[subtraction[1]].Label)
Arch.removeComponents(objects[subtraction[0]],objects[subtraction[1]])
if DEBUG: FreeCAD.ActiveDocument.recompute()
if preferences['DEBUG']: FreeCAD.ActiveDocument.recompute()
# additions
@@ -961,18 +955,18 @@ def insert(filename,docname,skip=[],only=[],root=None):
cobs.append(objects[child])
if not cobs:
continue
if DEBUG and first:
if preferences['DEBUG'] and first:
print("")
first = False
if DEBUG and (len(cobs) > 10) and (not(Draft.getType(objects[host]) in ["Site","Building","Floor","BuildingPart","Project"])):
if preferences['DEBUG'] and (len(cobs) > 10) and (not(Draft.getType(objects[host]) in ["Site","Building","Floor","BuildingPart","Project"])):
# avoid huge fusions
print("more than 10 shapes to add: skipping.")
else:
if DEBUG: print(" adding",len(cobs), "object(s) to", objects[host].Label)
if preferences['DEBUG']: print(" adding",len(cobs), "object(s) to", objects[host].Label)
Arch.addComponents(cobs,objects[host])
if DEBUG: FreeCAD.ActiveDocument.recompute()
if preferences['DEBUG']: FreeCAD.ActiveDocument.recompute()
if DEBUG and first: print("done.")
if preferences['DEBUG'] and first: print("done.")
FreeCAD.ActiveDocument.recompute()
@@ -987,7 +981,7 @@ def insert(filename,docname,skip=[],only=[],root=None):
# 2D elements
if DEBUG and annotations:
if preferences['DEBUG'] and annotations:
print("Processing",len(annotations),"2D objects...")
prodcount = count
count = 0
@@ -998,11 +992,11 @@ def insert(filename,docname,skip=[],only=[],root=None):
aid = annotation.id()
count += 1
if DEBUG: print(count,"/",len(annotations),"object #"+str(aid),":",annotation.is_a(),end="")
if preferences['DEBUG']: print(count,"/",len(annotations),"object #"+str(aid),":",annotation.is_a(),end="")
if aid in skip:
continue # user given id skip list
if annotation.is_a() in SKIP:
if annotation.is_a() in preferences['SKIP']:
continue # preferences-set type skip list
if annotation.is_a("IfcGrid"):
axes = []
@@ -1033,7 +1027,7 @@ def insert(filename,docname,skip=[],only=[],root=None):
name = annotation.Name
if six.PY2:
name = name.encode("utf8")
if PREFIX_NUMBERS:
if preferences['PREFIX_NUMBERS']:
name = "ID" + str(aid) + " " + name
anno = Arch.makeAxisSystem(axes,name)
print(" axis")
@@ -1045,7 +1039,7 @@ def insert(filename,docname,skip=[],only=[],root=None):
name = name.encode("utf8")
if "annotation" not in name.lower():
name = "Annotation " + name
if PREFIX_NUMBERS: name = "ID" + str(aid) + " " + name
if preferences['PREFIX_NUMBERS']: name = "ID" + str(aid) + " " + name
shapes2d = []
for rep in annotation.Representation.Representations:
if rep.RepresentationIdentifier in ["Annotation","FootPrint","Axis"]:
@@ -1057,14 +1051,14 @@ def insert(filename,docname,skip=[],only=[],root=None):
shapes2d.extend(sh)
if shapes2d:
sh = Part.makeCompound(shapes2d)
if DEBUG: print(" shape")
if preferences['DEBUG']: print(" shape")
anno = FreeCAD.ActiveDocument.addObject("Part::Feature",name)
anno.Shape = sh
p = importIFCHelper.getPlacement(annotation.ObjectPlacement,ifcscale)
if p: # and annotation.is_a("IfcAnnotation"):
anno.Placement = p
else:
if DEBUG: print(" no shape")
if preferences['DEBUG']: print(" no shape")
# placing in container if needed
@@ -1080,7 +1074,7 @@ def insert(filename,docname,skip=[],only=[],root=None):
# Materials
if DEBUG and materials: print("Creating materials...",end="")
if preferences['DEBUG'] and materials: print("Creating materials...",end="")
#print("mattable:",mattable)
#print("materials:",materials)
fcmats = {}
@@ -1102,7 +1096,7 @@ def insert(filename,docname,skip=[],only=[],root=None):
mdict["DiffuseColor"] = str(colors[o])
# merge materials with same name and color if setting in prefs is True
add_material = True
if MERGE_MATERIALS:
if preferences['MERGE_MATERIALS']:
for key in list(fcmats.keys()):
if key.startswith(name) \
and "DiffuseColor" in mdict and "DiffuseColor" in fcmats[key].Material \
@@ -1145,7 +1139,7 @@ def insert(filename,docname,skip=[],only=[],root=None):
# print(" ", o, ": ", colors[o])
# print(" ", m, ": ", colors[m])
if DEBUG and materials: print("done")
if preferences['DEBUG'] and materials: print("done")
# restore links from full parametric definitions
for p in parametrics:

View File

@@ -195,7 +195,7 @@ int ChainIkSolverPos_LMA::CartToJnt(const KDL::JntArray& q_init, const KDL::Fram
svd.compute(jac);
original_Aii = svd.singularValues();
for (unsigned int j=0;j<original_Aii.rows();++j) {
for (Eigen::Index j=0;j<original_Aii.rows();++j) {
original_Aii(j) = original_Aii(j)/( original_Aii(j)*original_Aii(j)+lambda);
}

View File

@@ -83,7 +83,7 @@ namespace KDL
}
void Jacobian::changeRefPoint(const Vector& base_AB){
for(unsigned int i=0;i<data.cols();i++)
for(Eigen::Index i=0;i<data.cols();i++)
this->setColumn(i,this->getColumn(i).RefPoint(base_AB));
}
@@ -97,7 +97,7 @@ namespace KDL
}
void Jacobian::changeBase(const Rotation& rot){
for(unsigned int i=0;i<data.cols();i++)
for(Eigen::Index i=0;i<data.cols();i++)
this->setColumn(i,rot*this->getColumn(i));;
}
@@ -111,7 +111,7 @@ namespace KDL
}
void Jacobian::changeRefFrame(const Frame& frame){
for(unsigned int i=0;i<data.cols();i++)
for(Eigen::Index i=0;i<data.cols();i++)
this->setColumn(i,frame*this->getColumn(i));
}

View File

@@ -89,9 +89,9 @@ namespace KDL {
Wq_V.noalias() = Wq * V;
// tmp = (Si*Wy*U'*y),
for (unsigned int i = 0; i < J.cols(); i++) {
for (Eigen::Index i = 0; i < J.cols(); i++) {
double sum = 0.0;
for (unsigned int j = 0; j < J.rows(); j++) {
for (Eigen::Index j = 0; j < J.rows(); j++) {
if (i < Wy_t.rows())
sum += U(j, i) * Wy_t(j);
else

View File

@@ -70,8 +70,8 @@ namespace KDL
rotate=false;
rotations=0;
//Perform rotations between columns of B
for(unsigned int i=0;i<B.cols();i++){
for(unsigned int j=i+1;j<B.cols();j++){
for(Eigen::Index i=0;i<B.cols();i++){
for(Eigen::Index j=i+1;j<B.cols();j++){
//calculate plane rotation
double p = B.col(i).dot(B.col(j));
double qi =B.col(i).dot(B.col(i));
@@ -111,7 +111,7 @@ namespace KDL
}
//Only calculate new U and S if there were any rotations
if(rotations!=0){
for(unsigned int i=0;i<U.rows();i++) {
for(Eigen::Index i=0;i<U.rows();i++) {
if(i<B.cols()){
double si=sqrt(B.col(i).dot(B.col(i)));
if(si==0)
@@ -134,8 +134,8 @@ namespace KDL
rotate=false;
rotations=0;
//Perform rotations between rows of B
for(unsigned int i=0;i<B.cols();i++){
for(unsigned int j=i+1;j<B.cols();j++){
for(Eigen::Index i=0;i<B.cols();i++){
for(Eigen::Index j=i+1;j<B.cols();j++){
//calculate plane rotation
double p = B.row(i).dot(B.row(j));
double qi = B.row(i).dot(B.row(i));
@@ -179,7 +179,7 @@ namespace KDL
//Only calculate new U and S if there were any rotations
if(rotations!=0){
for(unsigned int i=0;i<V.rows();i++) {
for(Eigen::Index i=0;i<V.rows();i++) {
double si=sqrt(B.row(i).dot(B.row(i)));
if(si==0)
V.col(i) = B.row(i);

View File

@@ -42,6 +42,9 @@
#include "DrawViewBalloon.h"
#include "DrawLeaderLine.h"
#include "DrawRichAnno.h"
#include "DrawTile.h"
#include "DrawTileWeld.h"
#include "DrawWeldSymbol.h"
#include "Cosmetic.h"
#include "PropertyGeomFormatList.h"
#include "PropertyCenterLineList.h"
@@ -100,6 +103,9 @@ PyMOD_INIT_FUNC(TechDraw)
TechDraw::DrawViewDraft ::init();
TechDraw::DrawViewArch ::init();
TechDraw::DrawViewImage ::init();
TechDraw::DrawTile ::init();
TechDraw::DrawTileWeld ::init();
TechDraw::DrawWeldSymbol ::init();
TechDraw::PropertyGeomFormatList::init();
TechDraw::GeomFormat ::init();
@@ -119,5 +125,8 @@ PyMOD_INIT_FUNC(TechDraw)
TechDraw::DrawViewSymbolPython::init();
TechDraw::DrawLeaderLinePython::init();
TechDraw::DrawRichAnnoPython ::init();
TechDraw::DrawTilePython ::init();
TechDraw::DrawTileWeldPython ::init();
TechDraw::DrawWeldSymbolPython::init();
PyMOD_Return(mod);
}

View File

@@ -63,6 +63,9 @@ generate_from_xml(GeomFormatPy)
generate_from_xml(CenterLinePy)
generate_from_xml(CosmeticEdgePy)
generate_from_xml(CosmeticVertexPy)
generate_from_xml(DrawTilePy)
generate_from_xml(DrawTileWeldPy)
generate_from_xml(DrawWeldSymbolPy)
SET(Draw_SRCS
DrawPage.cpp
@@ -117,6 +120,12 @@ SET(Draw_SRCS
DrawRichAnno.h
QDomNodeModel.cpp
QDomNodeModel.h
DrawTile.cpp
DrawTile.h
DrawTileWeld.cpp
DrawTileWeld.h
DrawWeldSymbol.cpp
DrawWeldSymbol.h
)
SET(TechDraw_SRCS
@@ -196,6 +205,12 @@ SET(Python_SRCS
CosmeticEdgePyImp.cpp
CosmeticVertexPy.xml
CosmeticVertexPyImp.cpp
DrawTilePy.xml
DrawTilePyImp.cpp
DrawTileWeldPy.xml
DrawTileWeldPyImp.cpp
DrawWeldSymbolPy.xml
DrawWeldSymbolPyImp.cpp
)
SOURCE_GROUP("Mod" FILES ${TechDraw_SRCS})
@@ -225,6 +240,13 @@ ADD_CUSTOM_COMMAND(TARGET TechDraw
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/src/Mod/TechDraw/Templates
${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_DATADIR}/Mod/TechDraw/Templates
)
ADD_CUSTOM_COMMAND(TARGET TechDraw
POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/src/Mod/TechDraw/Symbols
${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_DATADIR}/Mod/TechDraw/Symbols
)
SET_BIN_DIR(TechDraw TechDraw /Mod/TechDraw)

View File

@@ -36,5 +36,11 @@
<UserDocu>returns the appearance attributes of this CenterLine. returns tuple(style, color, weight, visible).</UserDocu>
</Documentation>
</Methode>
<Attribute Name="Tag" ReadOnly="true">
<Documentation>
<UserDocu>Gives the tag of the CenterLine as string.</UserDocu>
</Documentation>
<Parameter Name="Tag" Type="String"/>
</Attribute>
</PythonExport>
</GenerateModel>

View File

@@ -24,7 +24,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
//# include <boost/uuid/uuid_io.hpp>
# include <boost/uuid/uuid_io.hpp>
#endif
#include "DrawUtil.h"
@@ -167,6 +167,12 @@ PyObject* CenterLinePy::getFormat(PyObject *args)
return result;
}
Py::String CenterLinePy::getTag(void) const
{
std::string tmp = boost::uuids::to_string(getCenterLinePtr()->getTag());
return Py::String(tmp);
}
PyObject *CenterLinePy::getCustomAttributes(const char* /*attr*/) const
{
return 0;

View File

@@ -145,6 +145,8 @@ CosmeticVertex::CosmeticVertex() : TechDraw::Vertex()
size = 3.0;
style = 1;
visible = true;
createNewTag();
}
CosmeticVertex::CosmeticVertex(const TechDraw::CosmeticVertex* cv) : TechDraw::Vertex(cv)
@@ -154,6 +156,8 @@ CosmeticVertex::CosmeticVertex(const TechDraw::CosmeticVertex* cv) : TechDraw::V
size = cv->size;
style = cv->style;
visible = cv->visible;
createNewTag();
}
CosmeticVertex::CosmeticVertex(Base::Vector3d loc) : TechDraw::Vertex(loc)
@@ -169,6 +173,9 @@ CosmeticVertex::CosmeticVertex(Base::Vector3d loc) : TechDraw::Vertex(loc)
size = 30.0;
style = 1; //TODO: implement styled vertexes
visible = true;
createNewTag();
}
std::string CosmeticVertex::toString(void) const
@@ -219,6 +226,40 @@ void CosmeticVertex::Restore(Base::XMLReader &reader)
visible = (int)reader.getAttributeAsInteger("value")==0?false:true;
}
boost::uuids::uuid CosmeticVertex::getTag() const
{
return tag;
}
std::string CosmeticVertex::getTagAsString(void) const
{
std::string tmp = boost::uuids::to_string(getTag());
return tmp;
}
void CosmeticVertex::createNewTag()
{
// Initialize a random number generator, to avoid Valgrind false positives.
static boost::mt19937 ran;
static bool seeded = false;
if (!seeded) {
ran.seed(static_cast<unsigned int>(std::time(0)));
seeded = true;
}
static boost::uuids::basic_random_generator<boost::mt19937> gen(&ran);
tag = gen();
}
void CosmeticVertex::assignTag(const TechDraw::CosmeticVertex * cv)
{
if(cv->getTypeId() == this->getTypeId())
this->tag = cv->tag;
else
throw Base::TypeError("CosmeticVertex tag can not be assigned as types do not match.");
}
CosmeticVertex* CosmeticVertex::copy(void) const
{
// Base::Console().Message("CV::copy()\n");
@@ -230,6 +271,7 @@ CosmeticVertex* CosmeticVertex::clone(void) const
{
// Base::Console().Message("CV::clone()\n");
CosmeticVertex* cpy = this->copy();
cpy->tag = this->tag;
return cpy;
}
@@ -304,6 +346,9 @@ void CosmeticEdge::initialize(void)
m_geometry->classOfEdge = ecHARD;
m_geometry->visible = true;
m_geometry->cosmetic = true;
createNewTag();
}
TechDraw::BaseGeom* CosmeticEdge::scaledGeometry(double scale)
@@ -402,6 +447,34 @@ void CosmeticEdge::Restore(Base::XMLReader &reader)
}
}
boost::uuids::uuid CosmeticEdge::getTag() const
{
return tag;
}
void CosmeticEdge::createNewTag()
{
// Initialize a random number generator, to avoid Valgrind false positives.
static boost::mt19937 ran;
static bool seeded = false;
if (!seeded) {
ran.seed(static_cast<unsigned int>(std::time(0)));
seeded = true;
}
static boost::uuids::basic_random_generator<boost::mt19937> gen(&ran);
tag = gen();
}
void CosmeticEdge::assignTag(const TechDraw::CosmeticEdge * ce)
{
if(ce->getTypeId() == this->getTypeId())
this->tag = ce->tag;
else
throw Base::TypeError("CosmeticEdge tag can not be assigned as types do not match.");
}
CosmeticEdge* CosmeticEdge::copy(void) const
{
// Base::Console().Message("CE::copy()\n");
@@ -416,6 +489,7 @@ CosmeticEdge* CosmeticEdge::clone(void) const
{
// Base::Console().Message("CE::clone()\n");
CosmeticEdge* cpy = this->copy();
cpy->tag = this->tag;
return cpy;
}
@@ -440,6 +514,7 @@ CenterLine::CenterLine(void)
m_type = CLTYPE::FACE;
m_flip2Line = false;
createNewTag();
}
CenterLine::CenterLine(CenterLine* cl)
@@ -457,6 +532,8 @@ CenterLine::CenterLine(CenterLine* cl)
m_flip2Line = cl->m_flip2Line;
m_edges = cl->m_edges;
m_verts = cl->m_verts;
createNewTag();
}
CenterLine::CenterLine(Base::Vector3d p1, Base::Vector3d p2)
@@ -470,6 +547,8 @@ CenterLine::CenterLine(Base::Vector3d p1, Base::Vector3d p2)
m_extendBy = 0.0;
m_type = CLTYPE::FACE;
m_flip2Line = false;
createNewTag();
}
CenterLine::CenterLine(Base::Vector3d p1, Base::Vector3d p2,
@@ -488,6 +567,8 @@ CenterLine::CenterLine(Base::Vector3d p1, Base::Vector3d p2,
m_extendBy = x;
m_type = CLTYPE::FACE;
m_flip2Line = false;
createNewTag();
}
CenterLine::~CenterLine()
@@ -1102,9 +1183,39 @@ CenterLine* CenterLine::copy(void) const
return newCL;
}
CenterLine* CenterLine::clone(void) const
boost::uuids::uuid CenterLine::getTag() const
{
return tag;
}
void CenterLine::createNewTag()
{
// Initialize a random number generator, to avoid Valgrind false positives.
static boost::mt19937 ran;
static bool seeded = false;
if (!seeded) {
ran.seed(static_cast<unsigned int>(std::time(0)));
seeded = true;
}
static boost::uuids::basic_random_generator<boost::mt19937> gen(&ran);
tag = gen();
}
void CenterLine::assignTag(const TechDraw::CenterLine * ce)
{
if(ce->getTypeId() == this->getTypeId())
this->tag = ce->tag;
else
throw Base::TypeError("CenterLine tag can not be assigned as types do not match.");
}
CenterLine *CenterLine::clone(void) const
{
CenterLine* cpy = this->copy();
cpy->tag = this->tag;
return cpy;
}
@@ -1169,6 +1280,8 @@ GeomFormat::GeomFormat() :
m_format.m_weight = LineFormat::getDefEdgeWidth();
m_format.m_color = LineFormat::getDefEdgeColor();
m_format.m_visible = true;
createNewTag();
}
GeomFormat::GeomFormat(GeomFormat* gf)
@@ -1178,6 +1291,8 @@ GeomFormat::GeomFormat(GeomFormat* gf)
m_format.m_weight = gf->m_format.m_weight;
m_format.m_color = gf->m_format.m_color;
m_format.m_visible = gf->m_format.m_visible;
createNewTag();
}
GeomFormat::GeomFormat(int idx,
@@ -1189,6 +1304,7 @@ GeomFormat::GeomFormat(int idx,
m_format.m_color = fmt.m_color;
m_format.m_visible = fmt.m_visible;
createNewTag();
}
GeomFormat::~GeomFormat()
@@ -1243,6 +1359,42 @@ void GeomFormat::Restore(Base::XMLReader &reader)
m_format.m_visible = (int)reader.getAttributeAsInteger("value")==0?false:true;
}
boost::uuids::uuid GeomFormat::getTag() const
{
return tag;
}
void GeomFormat::createNewTag()
{
// Initialize a random number generator, to avoid Valgrind false positives.
static boost::mt19937 ran;
static bool seeded = false;
if (!seeded) {
ran.seed(static_cast<unsigned int>(std::time(0)));
seeded = true;
}
static boost::uuids::basic_random_generator<boost::mt19937> gen(&ran);
tag = gen();
}
void GeomFormat::assignTag(const TechDraw::GeomFormat * ce)
{
if(ce->getTypeId() == this->getTypeId())
this->tag = ce->tag;
else
throw Base::TypeError("GeomFormat tag can not be assigned as types do not match.");
}
GeomFormat *GeomFormat::clone(void) const
{
GeomFormat* cpy = this->copy();
cpy->tag = this->tag;
return cpy;
}
GeomFormat* GeomFormat::copy(void) const
{
GeomFormat* newFmt = new GeomFormat();
@@ -1254,15 +1406,8 @@ GeomFormat* GeomFormat::copy(void) const
return newFmt;
}
GeomFormat* GeomFormat::clone(void) const
{
GeomFormat* cpy = this->copy();
return cpy;
}
PyObject* GeomFormat::getPyObject(void)
{
return new GeomFormatPy(new GeomFormat(this->copy()));
}

View File

@@ -23,6 +23,11 @@
#ifndef TECHDRAW_COSMETIC_H
#define TECHDRAW_COSMETIC_H
# include <boost/uuid/uuid_io.hpp>
#include <boost/uuid/uuid.hpp>
#include <boost/uuid/uuid_generators.hpp>
#include <App/FeaturePython.h>
#include <Base/Persistence.h>
@@ -57,7 +62,6 @@ public:
void dump(char* title);
std::string toString() const;
/* bool fromCSV(std::string& lineSpec);*/
};
class TechDrawExport CosmeticVertex: public Base::Persistence, public TechDraw::Vertex
@@ -89,7 +93,16 @@ public:
int style;
bool visible;
boost::uuids::uuid getTag() const;
std::string getTagAsString(void) const;
protected:
//Uniqueness
void createNewTag();
void assignTag(const TechDraw::CosmeticVertex* cv);
boost::uuids::uuid tag;
};
@@ -123,8 +136,14 @@ public:
TechDraw::BaseGeom* m_geometry;
LineFormat m_format;
protected:
boost::uuids::uuid getTag() const;
protected:
//Uniqueness
void createNewTag();
void assignTag(const TechDraw::CosmeticEdge* ce);
boost::uuids::uuid tag;
};
class TechDrawExport CenterLine: public Base::Persistence
@@ -216,7 +235,13 @@ public:
LineFormat m_format;
bool m_flip2Line;
//Uniqueness
boost::uuids::uuid getTag() const;
protected:
void createNewTag();
void assignTag(const TechDraw::CenterLine* cl);
boost::uuids::uuid tag;
};
@@ -241,14 +266,18 @@ public:
GeomFormat* clone(void) const;
std::string toString(void) const;
/* bool fromCSV(std::string& lineSpec);*/
void dump(char* title) const;
int m_geomIndex;
LineFormat m_format;
//Uniqueness
boost::uuids::uuid getTag() const;
protected:
void createNewTag();
void assignTag(const TechDraw::GeomFormat* gf);
boost::uuids::uuid tag;
};
} //end namespace TechDraw

View File

@@ -36,5 +36,11 @@
<UserDocu>returns the appearance attributes of this CometicEdge. returns tuple(style, color, weight, visible).</UserDocu>
</Documentation>
</Methode>
<Attribute Name="Tag" ReadOnly="true">
<Documentation>
<UserDocu>Gives the tag of the CosmeticEdge as string.</UserDocu>
</Documentation>
<Parameter Name="Tag" Type="String"/>
</Attribute>
</PythonExport>
</GenerateModel>

View File

@@ -24,6 +24,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <boost/uuid/uuid_io.hpp>
#endif
#include <App/Material.h>
@@ -169,6 +170,11 @@ PyObject* CosmeticEdgePy::getFormat(PyObject *args)
return result;
}
Py::String CosmeticEdgePy::getTag(void) const
{
std::string tmp = boost::uuids::to_string(getCosmeticEdgePtr()->getTag());
return Py::String(tmp);
}
PyObject *CosmeticEdgePy::getCustomAttributes(const char* /*attr*/) const
{

View File

@@ -25,5 +25,11 @@
<UserDocu>Create a copy of this CosmeticVertex</UserDocu>
</Documentation>
</Methode>
<Attribute Name="Tag" ReadOnly="true">
<Documentation>
<UserDocu>Gives the tag of the CosmeticVertex as string.</UserDocu>
</Documentation>
<Parameter Name="Tag" Type="String"/>
</Attribute>
</PythonExport>
</GenerateModel>

View File

@@ -24,6 +24,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <boost/uuid/uuid_io.hpp>
#endif
#include "Cosmetic.h"
@@ -108,6 +109,12 @@ PyObject* CosmeticVertexPy::copy(PyObject *args)
return cpy;
}
Py::String CosmeticVertexPy::getTag(void) const
{
std::string tmp = boost::uuids::to_string(getCosmeticVertexPtr()->getTag());
return Py::String(tmp);
}
PyObject *CosmeticVertexPy::getCustomAttributes(const char* /*attr*/) const
{
return 0;

View File

@@ -187,6 +187,52 @@ void DrawLeaderLine::adjustLastSegment(void)
WayPoints.setValues(wp);
}
//middle of last line segment
Base::Vector3d DrawLeaderLine::getTileOrigin(void) const
{
Base::Vector3d result;
std::vector<Base::Vector3d> wp = WayPoints.getValues();
if (wp.size() > 1) {
Base::Vector3d last = wp.rbegin()[0];
Base::Vector3d second = wp.rbegin()[1];
result = (last + second) / 2.0;
} else {
Base::Console().Warning("DLL::getTileOrigin - no waypoints\n");
}
return result;
}
//start of last line segment
Base::Vector3d DrawLeaderLine::getKinkPoint(void) const
{
Base::Vector3d result;
std::vector<Base::Vector3d> wp = WayPoints.getValues();
if (wp.size() > 1) {
Base::Vector3d second = wp.rbegin()[1];
result = second;
} else {
Base::Console().Warning("DLL::getKinkPoint - no waypoints\n");
}
return result;
}
//end of last line segment
Base::Vector3d DrawLeaderLine::getTailPoint(void) const
{
Base::Vector3d result;
std::vector<Base::Vector3d> wp = WayPoints.getValues();
if (!wp.empty()) {
Base::Vector3d last = wp.rbegin()[0];
result = last;
} else {
Base::Console().Warning("DLL::getTailPoint - no waypoints\n");
}
return result;
}
bool DrawLeaderLine::getDefAuto(void) const
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->

View File

@@ -66,6 +66,10 @@ public:
void adjustLastSegment(void);
bool getDefAuto(void) const;
Base::Vector3d getTileOrigin(void) const;
Base::Vector3d getKinkPoint(void) const;
Base::Vector3d getTailPoint(void) const;
protected:
virtual void onChanged(const App::Property* prop) override;

View File

@@ -0,0 +1,116 @@
/***************************************************************************
* Copyright (c) 2019 Wanderer Fan <wandererfan@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#endif
#include <App/Application.h>
#include <Base/Console.h>
#include <Base/Exception.h>
#include <Base/Parameter.h>
#include "DrawUtil.h"
#include <Mod/TechDraw/App/DrawTilePy.h> // generated from DrawTilePy.xml
#include "DrawTile.h"
using namespace TechDraw;
//===========================================================================
// DrawTile - attachable tile
//===========================================================================
PROPERTY_SOURCE(TechDraw::DrawTile, App::DocumentObject)
DrawTile::DrawTile(void)
{
static const char *group = "Tile";
ADD_PROPERTY_TYPE(TileParent,(0),group,(App::PropertyType)(App::Prop_None),
"Object to which this tile is attached");
ADD_PROPERTY_TYPE(TileRow, (0), group, App::Prop_None, "Row in parent");
ADD_PROPERTY_TYPE(TileColumn, (0), group, App::Prop_None, "Column in parent");
}
DrawTile::~DrawTile()
{
}
void DrawTile::onChanged(const App::Property* prop)
{
if (!isRestoring()) {
//nothing in particular
}
DocumentObject::onChanged(prop);
}
short DrawTile::mustExecute() const
{
return DocumentObject::mustExecute();
}
App::DocumentObjectExecReturn *DrawTile::execute(void)
{
// Base::Console().Message("DT::execute()\n");
return DocumentObject::execute();
}
DrawView* DrawTile::getParent(void) const
{
// Base::Console().Message("DT::getParent() - %s\n", getNameInDocument());
DrawView* result = nullptr;
App::DocumentObject* baseObj = TileParent.getValue();
if (baseObj != nullptr) {
DrawView* cast = dynamic_cast<DrawView*>(baseObj);
if (cast != nullptr) {
result = cast;
}
}
return result;
}
PyObject *DrawTile::getPyObject(void)
{
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new DrawTilePy(this),true);
}
return Py::new_reference_to(PythonObject);
}
// Python Drawing feature ---------------------------------------------------------
namespace App {
/// @cond DOXERR
PROPERTY_SOURCE_TEMPLATE(TechDraw::DrawTilePython, TechDraw::DrawTile)
template<> const char* TechDraw::DrawTilePython::getViewProviderName(void) const {
return "TechDrawGui::ViewProviderTile";
}
/// @endcond
// explicit template instantiation
template class TechDrawExport FeaturePythonT<TechDraw::DrawTile>;
}

View File

@@ -0,0 +1,65 @@
/***************************************************************************
* Copyright (c) 2019 Wanderer Fan <wandererfan@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef _TechDraw_DrawTile_h_
#define _TechDraw_DrawTile_h_
# include <App/DocumentObject.h>
# include <App/FeaturePython.h>
#include "DrawView.h"
namespace TechDraw
{
class TechDrawExport DrawTile : public App::DocumentObject
{
PROPERTY_HEADER(TechDraw::DrawTile);
public:
DrawTile();
virtual ~DrawTile();
App::PropertyLink TileParent; //eg DrawWeldSymbol
App::PropertyInteger TileRow;
App::PropertyInteger TileColumn;
/* App::PropertyVector TileOrigin; //sb call to TileParent - WeldingSymbol*/
virtual short mustExecute() const;
virtual App::DocumentObjectExecReturn *execute(void);
virtual const char* getViewProviderName(void) const {
return "TechDrawGui::ViewProviderTile";
}
virtual PyObject *getPyObject(void);
virtual DrawView* getParent(void) const;
protected:
virtual void onChanged(const App::Property* prop);
private:
};
typedef App::FeaturePythonT<DrawTile> DrawTilePython;
} //namespace TechDraw
#endif

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
<PythonExport
Father="DocumentObjectPy"
Name="DrawTilePy"
Twin="DrawTile"
TwinPointer="DrawTile"
Include="Mod/TechDraw/App/DrawTile.h"
Namespace="TechDraw"
FatherInclude="App/DocumentObjectPy.h"
FatherNamespace="App">
<Documentation>
<Author Licence="LGPL" Name="WandererFan" EMail="wandererfan@gmail.com" />
<UserDocu>Feature for adding tiles to leader lines</UserDocu>
</Documentation>
<CustomAttributes />
</PythonExport>
</GenerateModel>

View File

@@ -0,0 +1,54 @@
/***************************************************************************
* Copyright (c) 2019 WandererFan (wandererfan@gmail.com) *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#endif
#include <Base/Console.h>
#include <Base/PyObjectBase.h>
#include <Base/Vector3D.h>
#include "DrawTile.h"
// inclusion of the generated files (generated out of DrawTilePy.xml)
#include <Base/VectorPy.h>
#include <Mod/TechDraw/App/DrawTilePy.h>
#include <Mod/TechDraw/App/DrawTilePy.cpp>
using namespace TechDraw;
// returns a string which represents the object e.g. when printed in python
std::string DrawTilePy::representation(void) const
{
return std::string("<DrawTile object>");
}
PyObject *DrawTilePy::getCustomAttributes(const char* /*attr*/) const
{
return 0;
}
int DrawTilePy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
{
return 0;
}

View File

@@ -0,0 +1,103 @@
/***************************************************************************
* Copyright (c) 2019 Wanderer Fan <wandererfan@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#endif
#include <App/Application.h>
#include <Base/Console.h>
#include <Base/Exception.h>
#include <Base/Parameter.h>
#include "DrawUtil.h"
#include <Mod/TechDraw/App/DrawTileWeldPy.h> // generated from DrawTileWeldPy.xml
#include "DrawTileWeld.h"
using namespace TechDraw;
//===========================================================================
// DrawTileWeld - attachable tile
//===========================================================================
PROPERTY_SOURCE(TechDraw::DrawTileWeld, TechDraw::DrawTile)
DrawTileWeld::DrawTileWeld(void)
{
static const char *group = "TileWeld";
ADD_PROPERTY_TYPE(LeftText,(""),group,(App::PropertyType)(App::Prop_None),
"Text LHS");
ADD_PROPERTY_TYPE(RightText, (0), group, App::Prop_None, "Text RHS");
ADD_PROPERTY_TYPE(CenterText, (0), group, App::Prop_None, "Text above Symbol");
ADD_PROPERTY_TYPE(SymbolFile, (""), group, App::Prop_None, "Svg Symbol File");
}
DrawTileWeld::~DrawTileWeld()
{
}
void DrawTileWeld::onChanged(const App::Property* prop)
{
if (!isRestoring()) {
//nothing in particular
}
DrawTile::onChanged(prop);
}
short DrawTileWeld::mustExecute() const
{
return DrawTile::mustExecute();
}
App::DocumentObjectExecReturn *DrawTileWeld::execute(void)
{
// Base::Console().Message("DTW::execute()\n");
return DrawTile::execute();
}
PyObject *DrawTileWeld::getPyObject(void)
{
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new DrawTileWeldPy(this),true);
}
return Py::new_reference_to(PythonObject);
}
// Python Drawing feature ---------------------------------------------------------
namespace App {
/// @cond DOXERR
PROPERTY_SOURCE_TEMPLATE(TechDraw::DrawTileWeldPython, TechDraw::DrawTileWeld)
template<> const char* TechDraw::DrawTileWeldPython::getViewProviderName(void) const {
return "TechDrawGui::ViewProviderTile";
}
/// @endcond
// explicit template instantiation
template class TechDrawExport FeaturePythonT<TechDraw::DrawTileWeld>;
}

View File

@@ -0,0 +1,68 @@
/***************************************************************************
* Copyright (c) 2019 Wanderer Fan <wandererfan@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef _TechDraw_DrawTileWeld_h_
#define _TechDraw_DrawTileWeld_h_
#include <App/DocumentObject.h>
#include <App/FeaturePython.h>
#include <App/PropertyFile.h>
#include <App/PropertyStandard.h>
#include "DrawTile.h"
namespace TechDraw
{
class TechDrawExport DrawTileWeld : public TechDraw::DrawTile
{
PROPERTY_HEADER(TechDraw::DrawTileWeld);
public:
DrawTileWeld();
virtual ~DrawTileWeld();
App::PropertyString LeftText;
App::PropertyString RightText;
App::PropertyString CenterText;
App::PropertyFileIncluded SymbolFile;
virtual short mustExecute() const;
virtual App::DocumentObjectExecReturn *execute(void);
virtual const char* getViewProviderName(void) const {
return "TechDrawGui::ViewProviderTile";
}
virtual PyObject *getPyObject(void);
virtual QRectF getRect() const { return QRectF(0,0,1,1);}
protected:
virtual void onChanged(const App::Property* prop);
private:
};
typedef App::FeaturePythonT<DrawTileWeld> DrawTileWeldPython;
} //namespace TechDraw
#endif

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
<PythonExport
Father="DrawTilePy"
Name="DrawTileWeldPy"
Twin="DrawTileWeld"
TwinPointer="DrawTileWeld"
Include="Mod/TechDraw/App/DrawTileWeld.h"
Namespace="TechDraw"
FatherInclude="Mod/TechDraw/App/DrawTilePy.h"
FatherNamespace="TechDraw">
<Documentation>
<Author Licence="LGPL" Name="WandererFan" EMail="wandererfan@gmail.com" />
<UserDocu>Feature for adding welding tiles to leader lines</UserDocu>
</Documentation>
<CustomAttributes />
</PythonExport>
</GenerateModel>

View File

@@ -0,0 +1,54 @@
/***************************************************************************
* Copyright (c) 2019 WandererFan (wandererfan@gmail.com) *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#endif
#include <Base/Console.h>
#include <Base/PyObjectBase.h>
#include <Base/Vector3D.h>
#include "DrawTileWeld.h"
// inclusion of the generated files (generated out of DrawTileWeldPy.xml)
#include <Base/VectorPy.h>
#include <Mod/TechDraw/App/DrawTileWeldPy.h>
#include <Mod/TechDraw/App/DrawTileWeldPy.cpp>
using namespace TechDraw;
// returns a string which represents the object e.g. when printed in python
std::string DrawTileWeldPy::representation(void) const
{
return std::string("<DrawTileWeld object>");
}
PyObject *DrawTileWeldPy::getCustomAttributes(const char* /*attr*/) const
{
return 0;
}
int DrawTileWeldPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
{
return 0;
}

View File

@@ -0,0 +1,152 @@
/***************************************************************************
* Copyright (c) 2019 Wanderer Fan <wandererfan@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#endif
#include <App/Application.h>
#include <App/Document.h>
#include <App/DocumentObject.h>
#include <Base/Console.h>
#include <Base/Exception.h>
#include <Base/Parameter.h>
#include "DrawUtil.h"
#include <Mod/TechDraw/App/DrawWeldSymbolPy.h> // generated from DrawWeldSymbolPy.xml
#include "DrawLeaderLine.h"
#include "DrawTile.h"
#include "DrawTileWeld.h"
#include "DrawWeldSymbol.h"
using namespace TechDraw;
//===========================================================================
// DrawWeldSymbol - welding symbol
//===========================================================================
PROPERTY_SOURCE(TechDraw::DrawWeldSymbol, TechDraw::DrawView)
DrawWeldSymbol::DrawWeldSymbol(void)
{
static const char *group = "Weld Symbol";
ADD_PROPERTY_TYPE(Leader,(0),group,(App::PropertyType)(App::Prop_None), "Parent Leader");
ADD_PROPERTY_TYPE(AllAround, (false), group, App::Prop_None, "All Around Symbol on/off");
ADD_PROPERTY_TYPE(FieldWeld, (false), group, App::Prop_None, "Field Weld Symbol on/off");
ADD_PROPERTY_TYPE(AlternatingWeld, (false), group, App::Prop_None, "Alternating Weld true/false");
ADD_PROPERTY_TYPE(TailText, (""), group, App::Prop_None, "Text at tail of symbol");
Caption.setStatus(App::Property::Hidden,true);
Scale.setStatus(App::Property::Hidden,true);
ScaleType.setStatus(App::Property::Hidden,true);
}
DrawWeldSymbol::~DrawWeldSymbol()
{
}
void DrawWeldSymbol::onChanged(const App::Property* prop)
{
if (!isRestoring()) {
//nothing in particular
}
DrawView::onChanged(prop);
}
short DrawWeldSymbol::mustExecute() const
{
return DrawView::mustExecute();
}
App::DocumentObjectExecReturn *DrawWeldSymbol::execute(void)
{
// Base::Console().Message("DWS::execute()\n");
if (!keepUpdated()) {
return App::DocumentObject::StdReturn;
}
return DrawView::execute();
}
std::vector<DrawTileWeld*> DrawWeldSymbol::getTiles(void) const
{
// Base::Console().Message("DWS::getTiles()\n");
// std::vector<App::DocumentObject*> temp;
std::vector<DrawTileWeld*> result;
std::vector<App::DocumentObject*> tiles = getInList();
if (!tiles.empty()) {
for(std::vector<App::DocumentObject *>::iterator it = tiles.begin(); it != tiles.end(); it++) {
if ((*it)->getTypeId().isDerivedFrom(TechDraw::DrawTileWeld::getClassTypeId())) {
App::DocumentObject* doTemp = (*it);
DrawTileWeld* temp = static_cast<DrawTileWeld*>(doTemp);
result.push_back(temp);
}
}
}
return result;
}
bool DrawWeldSymbol::isTailRightSide()
{
bool result = true;
App::DocumentObject* obj = Leader.getValue();
TechDraw::DrawLeaderLine* realLeader = dynamic_cast<TechDraw::DrawLeaderLine*>(obj);
if (realLeader != nullptr) {
Base::Vector3d tail = realLeader->getTailPoint();
Base::Vector3d kink = realLeader->getKinkPoint();
if (tail.x < kink.x) { //tail is to left
result = false;
}
}
return result;
}
PyObject *DrawWeldSymbol::getPyObject(void)
{
if (PythonObject.is(Py::_None())) {
// ref counter is set to 1
PythonObject = Py::Object(new DrawWeldSymbolPy(this),true);
}
return Py::new_reference_to(PythonObject);
}
// Python Drawing feature ---------------------------------------------------------
namespace App {
/// @cond DOXERR
PROPERTY_SOURCE_TEMPLATE(TechDraw::DrawWeldSymbolPython, TechDraw::DrawWeldSymbol)
template<> const char* TechDraw::DrawWeldSymbolPython::getViewProviderName(void) const {
return "TechDrawGui::ViewProviderWeld";
}
/// @endcond
// explicit template instantiation
template class TechDrawExport FeaturePythonT<TechDraw::DrawWeldSymbol>;
}

View File

@@ -0,0 +1,72 @@
/***************************************************************************
* Copyright (c) 2019 Wanderer Fan <wandererfan@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef _TechDraw_DrawWeldSymbol_h_
#define _TechDraw_DrawWeldSymbol_h_
# include <App/DocumentObject.h>
# include <App/FeaturePython.h>
#include "DrawView.h"
namespace TechDraw
{
class DrawTile;
class DrawTileWeld;
class TechDrawExport DrawWeldSymbol : public TechDraw::DrawView
{
PROPERTY_HEADER(TechDraw::DrawWeldSymbol);
public:
DrawWeldSymbol();
virtual ~DrawWeldSymbol();
App::PropertyLink Leader;
App::PropertyBool AllAround;
App::PropertyBool FieldWeld;
App::PropertyBool AlternatingWeld;
App::PropertyString TailText;
virtual short mustExecute() const;
virtual App::DocumentObjectExecReturn *execute(void);
virtual const char* getViewProviderName(void) const {
return "TechDrawGui::ViewProviderWeld";
}
virtual PyObject *getPyObject(void);
virtual QRectF getRect() const { return QRectF(0,0,1,1);}
bool isTailRightSide();
std::vector<DrawTileWeld*> getTiles(void) const;
protected:
virtual void onChanged(const App::Property* prop);
private:
};
typedef App::FeaturePythonT<DrawWeldSymbol> DrawWeldSymbolPython;
} //namespace TechDraw
#endif

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<GenerateModel xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="generateMetaModel_Module.xsd">
<PythonExport
Father="DrawViewPy"
Name="DrawWeldSymbolPy"
Twin="DrawWeldSymbol"
TwinPointer="DrawWeldSymbol"
Include="Mod/TechDraw/App/DrawWeldSymbol.h"
Namespace="TechDraw"
FatherInclude="Mod/TechDraw/App/DrawViewPy.h"
FatherNamespace="TechDraw">
<Documentation>
<Author Licence="LGPL" Name="WandererFan" EMail="wandererfan@gmail.com" />
<UserDocu>Feature for adding welding tiles to leader lines</UserDocu>
</Documentation>
<CustomAttributes />
</PythonExport>
</GenerateModel>

View File

@@ -0,0 +1,67 @@
/***************************************************************************
* Copyright (c) 2019 WandererFan (wandererfan@gmail.com) *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#endif
#include <Base/Console.h>
#include <Base/PyObjectBase.h>
#include <Base/Vector3D.h>
#include "DrawWeldSymbol.h"
// inclusion of the generated files (generated out of DrawWeldSymbolPy.xml)
#include <Base/VectorPy.h>
#include <Mod/TechDraw/App/DrawWeldSymbolPy.h>
#include <Mod/TechDraw/App/DrawWeldSymbolPy.cpp>
using namespace TechDraw;
// returns a string which represents the object e.g. when printed in python
std::string DrawWeldSymbolPy::representation(void) const
{
return std::string("<DrawWeldSymbol object>");
}
//PyObject* DrawWeldSymbolPy::getTiles(PyObject *args)
//{
// const char* fileSpec;
// PyObject* pTile
// if (!PyArg_ParseTuple(args, "O", &pTile)) {
// throw Py::TypeError("getTiles expected DrawTile");
// }
// auto dws = getDrawWeldSymbolPtr();
//// auto dt = pTile->getDrawTilePtr();
////TODO: finish this!
// Py_Return;
//}
PyObject *DrawWeldSymbolPy::getCustomAttributes(const char* /*attr*/) const
{
return 0;
}
int DrawWeldSymbolPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/)
{
return 0;
}

View File

@@ -25,5 +25,11 @@
<UserDocu>Create a copy of this geomformat</UserDocu>
</Documentation>
</Methode>
<Attribute Name="Tag" ReadOnly="true">
<Documentation>
<UserDocu>Gives the tag of the GeomFormat as string.</UserDocu>
</Documentation>
<Parameter Name="Tag" Type="String"/>
</Attribute>
</PythonExport>
</GenerateModel>

View File

@@ -23,37 +23,14 @@
#include "PreCompiled.h"
#ifndef _PreComp_
//# include <gp_Ax1.hxx>
//# include <gp_Dir.hxx>
//# include <gp_Pnt.hxx>
//# include <gp_Vec.hxx>
//# include <gp_Trsf.hxx>
//# include <Geom_GeometryFormat.hxx>
//# include <Geom_Curve.hxx>
//# include <Geom_Surface.hxx>
//# include <Precision.hxx>
//# include <Standard_Failure.hxx>
# include <boost/uuid/uuid_io.hpp>
#endif
//#include <Base/GeomFormatPyCXX.h>
//#include <Base/Matrix.h>
//#include <Base/MatrixPy.h>
//#include <Base/Vector3D.h>
//#include <Base/VectorPy.h>
//#include <Base/Rotation.h>
//#include <Base/Placement.h>
//#include <Base/PlacementPy.h>
//#include "OCCError.h"
#include "Cosmetic.h"
#include "GeomFormatPy.h"
#include "GeomFormatPy.cpp"
//#include "TopoShape.h"
//#include "TopoShapePy.h"
using namespace TechDraw;
// returns a string which represents the object e.g. when printed in python
@@ -130,6 +107,12 @@ PyObject* GeomFormatPy::copy(PyObject *args)
return cpy;
}
Py::String GeomFormatPy::getTag(void) const
{
std::string tmp = boost::uuids::to_string(getGeomFormatPtr()->getTag());
return Py::String(tmp);
}
PyObject *GeomFormatPy::getCustomAttributes(const char* /*attr*/) const
{
return 0;

View File

@@ -58,6 +58,7 @@
#include <set>
#include <bitset>
#include <boost/uuid/uuid_io.hpp>
// OpenCasCade =====================================================================================
#include <Mod/Part/App/OpenCascadeAll.h>

View File

@@ -24,7 +24,7 @@ SET(TechDraw_LineGroupFile
)
add_custom_target(TechDraw_Data ALL
SOURCES ${TechDraw_Scripts} ${TechDraw_PATFile} ${TechDraw_LineGroupFile}
SOURCES ${TechDraw_Scripts} ${TechDraw_PATFile} ${TechDraw_LineGroupFile}
)
fc_target_copy_resource(TechDraw_Data
@@ -86,6 +86,15 @@ INSTALL(
PATTERN "*.svg*"
)
INSTALL(
DIRECTORY
Symbols
DESTINATION
${CMAKE_INSTALL_DATADIR}/Mod/TechDraw
FILES_MATCHING
PATTERN "*.svg*"
)
#unit test files
SET(TDTest_SRCS

View File

@@ -58,6 +58,8 @@
#include "ViewProviderImage.h"
#include "ViewProviderRichAnno.h"
#include "ViewProviderLeader.h"
#include "ViewProviderTile.h"
#include "ViewProviderWeld.h"
// use a different name to CreateCommand()
@@ -134,6 +136,8 @@ PyMOD_INIT_FUNC(TechDrawGui)
TechDrawGui::ViewProviderImage::init();
TechDrawGui::ViewProviderLeader::init();
TechDrawGui::ViewProviderRichAnno::init();
TechDrawGui::ViewProviderTile::init();
TechDrawGui::ViewProviderWeld::init();
// register preferences pages
new Gui::PrefPageProducer<TechDrawGui::DlgPrefsTechDrawImp> ("TechDraw");

View File

@@ -55,6 +55,7 @@ set(TechDrawGui_MOC_HDRS
TaskCosVertex.h
TaskCenterLine.h
TaskLineDecor.h
TaskWeldingSymbol.h
QGEPath.h
QGTracker.h
QGILeaderLine.h
@@ -63,6 +64,8 @@ set(TechDrawGui_MOC_HDRS
mrichtextedit.h
mtextedit.h
TaskBalloon.h
QGIWeldSymbol.h
SymbolChooser.h
)
fc_wrap_cpp(TechDrawGui_MOC_SRCS ${TechDrawGui_MOC_HDRS})
@@ -91,6 +94,8 @@ set(TechDrawGui_UIC_SRCS
TaskCL2Lines.ui
TaskLineDecor.ui
TaskRestoreLines.ui
TaskWeldingSymbol.ui
SymbolChooser.ui
)
if(BUILD_QT5)
@@ -168,10 +173,16 @@ SET(TechDrawGui_SRCS
TaskLineDecor.h
TaskRestoreLines.ui
TaskCL2Lines.ui
TaskWeldingSymbol.ui
TaskWeldingSymbol.cpp
TaskWeldingSymbol.h
DrawGuiUtil.cpp
DrawGuiUtil.h
Rez.cpp
Rez.h
SymbolChooser.ui
SymbolChooser.cpp
SymbolChooser.h
)
SET(TechDrawGuiView_SRCS
@@ -261,6 +272,10 @@ SET(TechDrawGuiView_SRCS
QGIRichAnno.h
QGMText.h
QGMText.cpp
QGIWeldSymbol.h
QGIWeldSymbol.cpp
QGITile.h
QGITile.cpp
TemplateTextField.cpp
TemplateTextField.h
ZVALUE.h
@@ -302,6 +317,10 @@ SET(TechDrawGuiViewProvider_SRCS
ViewProviderLeader.h
ViewProviderRichAnno.cpp
ViewProviderRichAnno.h
ViewProviderTile.cpp
ViewProviderTile.h
ViewProviderWeld.cpp
ViewProviderWeld.h
)
SOURCE_GROUP("MRTE" FILES ${MRTE_SRCS})
@@ -323,6 +342,8 @@ SET(TechDrawGuiTaskDlgs_SRCS
TaskLineDecor.ui
TaskRestoreLines.ui
TaskCL2Lines.ui
TaskWeldingSymbol.ui
SymbolChooser.ui
)
SOURCE_GROUP("TaskDialogs" FILES ${TechDrawGuiTaskDlgs_SRCS})

View File

@@ -48,6 +48,8 @@
#include <Mod/TechDraw/App/DrawView.h>
#include <Mod/TechDraw/App/DrawViewPart.h>
#include <Mod/TechDraw/App/DrawViewAnnotation.h>
#include <Mod/TechDraw/App/DrawLeaderLine.h>
#include <Mod/TechDraw/App/DrawWeldSymbol.h>
#include <Mod/TechDraw/App/DrawPage.h>
#include <Mod/TechDraw/App/DrawUtil.h>
#include <Mod/TechDraw/App/Geometry.h>
@@ -60,6 +62,7 @@
#include "TaskCosVertex.h"
#include "TaskCenterLine.h"
#include "TaskLineDecor.h"
#include "TaskWeldingSymbol.h"
#include "ViewProviderPage.h"
#include "ViewProviderViewPart.h"
#include "QGVPage.h"
@@ -1073,6 +1076,9 @@ void CmdTechDrawCosmeticEraser::activated(int iMsg)
objFeat = static_cast<TechDraw::DrawViewPart*> ((*itSel).getObject());
SubNames = (*itSel).getSubNames();
}
std::vector<int> cv2Delete;
std::vector<int> ce2Delete;
std::vector<int> cl2Delete;
for (auto& s: SubNames) {
int idx = TechDraw::DrawUtil::getIndexFromName(s);
std::string geomType = TechDraw::DrawUtil::getGeomTypeFromName(s);
@@ -1083,24 +1089,54 @@ void CmdTechDrawCosmeticEraser::activated(int iMsg)
int source = bg->source();
int sourceIndex = bg->sourceIndex();
if (source == 1) { //this is a "CosmeticEdge"
objFeat->removeCosmeticEdge(sourceIndex);
ce2Delete.push_back(sourceIndex);
} else if (source == 2) { //this is a "CenterLine"
objFeat->removeCenterLine(sourceIndex);
cl2Delete.push_back(sourceIndex);
} else {
Base::Console().Message(
"CMD::CosmeticEraserP - edge: %d is confused - source: %d\n",idx,source);
}
}
} else if (geomType == "Vertex") {
TechDraw::CosmeticVertex* cv = objFeat->getCosmeticVertexByGeom(idx);
if (cv != nullptr) {
objFeat->removeCosmeticVertex(cv);
TechDraw::Vertex* tdv = objFeat->getProjVertexByIndex(idx);
if (tdv != nullptr) {
int delIndex = tdv->cosmeticLink;
if (!(delIndex < 0)) {
cv2Delete.push_back(delIndex);
} else {
Base::Console().Message("CMD::eraser - geom: %d has no cv\n", idx);
}
} else {
Base::Console().Message("CMD::eraser - geom: %d not found!\n", idx);
}
} else {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Unknown object type in selection"));
return;
}
}
// delete items in reverse order so as not to invalidate indices
if (!cv2Delete.empty()) {
std::sort(cv2Delete.begin(), cv2Delete.end());
auto it = cv2Delete.rbegin();
for ( ; it != cv2Delete.rend(); it++) {
objFeat->removeCosmeticVertex((*it));
}
}
if (!ce2Delete.empty()) {
std::sort(ce2Delete.begin(), ce2Delete.end());
auto itce = ce2Delete.rbegin();
for ( ; itce != ce2Delete.rend(); itce++) {
objFeat->removeCosmeticEdge((*itce));
}
}
if (!cl2Delete.empty()) {
std::sort(cl2Delete.begin(), cl2Delete.end());
auto itcl = cl2Delete.rbegin();
for ( ; itcl != cl2Delete.rend(); itcl++) {
objFeat->removeCenterLine((*itcl));
}
}
}
}
@@ -1246,6 +1282,69 @@ bool CmdTechDrawShowAll::isActive(void)
return (havePage && haveView);
}
//===========================================================================
// TechDraw_WeldSymbol
//===========================================================================
DEF_STD_CMD_A(CmdTechDrawWeldSymbol);
CmdTechDrawWeldSymbol::CmdTechDrawWeldSymbol()
: Command("TechDraw_WeldSymbol")
{
sAppModule = "TechDraw";
sGroup = QT_TR_NOOP("TechDraw");
sMenuText = QT_TR_NOOP("Add welding information to a leader");
sToolTipText = sMenuText;
sWhatsThis = "TechDraw_WeldSymbol";
sStatusTip = sToolTipText;
sPixmap = "actions/techdraw-weldsymbol";
}
void CmdTechDrawWeldSymbol::activated(int iMsg)
{
Q_UNUSED(iMsg);
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
if (dlg != nullptr) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Task In Progress"),
QObject::tr("Close active task dialog and try again."));
return;
}
TechDraw::DrawPage* page = DrawGuiUtil::findPage(this);
if (!page) {
return;
}
std::vector<App::DocumentObject*> leaders = getSelection().
getObjectsOfType(TechDraw::DrawLeaderLine::getClassTypeId());
std::vector<App::DocumentObject*> welds = getSelection().
getObjectsOfType(TechDraw::DrawWeldSymbol::getClassTypeId());
TechDraw::DrawLeaderLine* leadFeat = nullptr;
TechDraw::DrawWeldSymbol* weldFeat = nullptr;
if ( (leaders.size() != 1) &&
(welds.size() != 1) ) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Select exactly one Leader line or one Weld symbol."));
return;
}
if (!leaders.empty()) {
leadFeat = static_cast<TechDraw::DrawLeaderLine*> (leaders.front());
Gui::Control().showDialog(new TaskDlgWeldingSymbol(leadFeat));
} else if (!welds.empty()) {
weldFeat = static_cast<TechDraw::DrawWeldSymbol*> (welds.front());
Gui::Control().showDialog(new TaskDlgWeldingSymbol(weldFeat));
}
}
bool CmdTechDrawWeldSymbol::isActive(void)
{
bool havePage = DrawGuiUtil::needPage(this);
bool haveView = DrawGuiUtil::needView(this, false);
return (havePage && haveView);
}
void CreateTechDrawCommandsAnnotate(void)
{
Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager();
@@ -1264,6 +1363,7 @@ void CreateTechDrawCommandsAnnotate(void)
rcCmdMgr.addCommand(new CmdTechDrawCosmeticEraser());
rcCmdMgr.addCommand(new CmdTechDrawDecorateLine());
rcCmdMgr.addCommand(new CmdTechDrawShowAll());
rcCmdMgr.addCommand(new CmdTechDrawWeldSymbol());
}
//===========================================================================

View File

@@ -454,6 +454,23 @@
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="1">
<widget class="Gui::PrefFileChooser" name="pfc_DefTemp">
<property name="prefEntry" stdset="0">
<cstring>TemplateFile</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>/Mod/TechDraw/Files</cstring>
</property>
</widget>
</item>
<item row="4" column="0">
<widget class="QLabel" name="label_11">
<property name="text">
<string>Welding Directory</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_2">
<property name="text">
@@ -468,7 +485,7 @@
</property>
</widget>
</item>
<item row="1" column="2">
<item row="1" column="1">
<widget class="Gui::PrefFileChooser" name="pfc_DefDir">
<property name="mode">
<enum>Gui::FileChooser::Directory</enum>
@@ -495,17 +512,7 @@
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="Gui::PrefFileChooser" name="pfc_DefTemp">
<property name="prefEntry" stdset="0">
<cstring>TemplateFile</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>/Mod/TechDraw/Files</cstring>
</property>
</widget>
</item>
<item row="2" column="2">
<item row="2" column="1">
<widget class="Gui::PrefFileChooser" name="pfc_HatchFile">
<property name="toolTip">
<string>Location of default svg/png fill file</string>
@@ -518,14 +525,14 @@
</property>
</widget>
</item>
<item row="4" column="0">
<item row="5" column="0">
<widget class="QLabel" name="label_9">
<property name="text">
<string>PAT File</string>
</property>
</widget>
</item>
<item row="4" column="2">
<item row="5" column="1">
<widget class="Gui::PrefFileChooser" name="pfc_FilePattern">
<property name="toolTip">
<string>Default location for PAT file</string>
@@ -538,7 +545,7 @@
</property>
</widget>
</item>
<item row="3" column="2">
<item row="3" column="1">
<widget class="Gui::PrefFileChooser" name="pfc_LineGroup">
<property name="toolTip">
<string>Alternate Line Group file</string>
@@ -551,6 +558,22 @@
</property>
</widget>
</item>
<item row="4" column="1">
<widget class="Gui::PrefFileChooser" name="pfc_Welding">
<property name="toolTip">
<string>Default directory for welding symbols</string>
</property>
<property name="mode">
<enum>Gui::FileChooser::Directory</enum>
</property>
<property name="prefEntry" stdset="0">
<cstring>WeldingDir</cstring>
</property>
<property name="prefPath" stdset="0">
<cstring>/Mod/TechDraw/Files</cstring>
</property>
</widget>
</item>
</layout>
</item>
<item>

View File

@@ -68,6 +68,8 @@ void DlgPrefsTechDrawImp::saveSettings()
pfc_DefDir->onSave();
pfc_HatchFile->onSave();
pfc_LineGroup->onSave();
pfc_Welding->onSave();
pfc_FilePattern->onSave();
le_NamePattern->onSave();
}
@@ -97,6 +99,7 @@ void DlgPrefsTechDrawImp::loadSettings()
pfc_DefDir->onRestore();
pfc_HatchFile->onRestore();
pfc_LineGroup->onRestore();
pfc_Welding->onRestore();
pfc_FilePattern->onRestore();
le_NamePattern->onRestore();

View File

@@ -84,6 +84,9 @@
#include <Mod/TechDraw/App/DrawViewImage.h>
#include <Mod/TechDraw/App/DrawLeaderLine.h>
#include <Mod/TechDraw/App/DrawRichAnno.h>
#include <Mod/TechDraw/App/DrawWeldSymbol.h>
#include <Mod/TechDraw/App/DrawTile.h>
#include <Mod/TechDraw/App/DrawTileWeld.h>
#include "Rez.h"
#include "QGIDrawingTemplate.h"
@@ -100,6 +103,8 @@
#include "QGILeaderLine.h"
#include "QGIRichAnno.h"
#include "QGMText.h"
#include "QGIWeldSymbol.h"
#include "QGITile.h"
using namespace TechDrawGui;
@@ -365,6 +370,9 @@ bool MDIViewPage::attachView(App::DocumentObject *obj)
} else if (typeId.isDerivedFrom(TechDraw::DrawRichAnno::getClassTypeId()) ) {
qview = m_view->addRichAnno( static_cast<TechDraw::DrawRichAnno*>(obj) );
} else if (typeId.isDerivedFrom(TechDraw::DrawWeldSymbol::getClassTypeId()) ) {
qview = m_view->addWeldSymbol( static_cast<TechDraw::DrawWeldSymbol*>(obj) );
} else if (typeId.isDerivedFrom(TechDraw::DrawHatch::getClassTypeId()) ) {
//Hatch is not attached like other Views (since it isn't really a View)
return true;

View File

@@ -76,7 +76,8 @@ void QGCustomSvg::paint ( QPainter * painter, const QStyleOptionGraphicsItem * o
QStyleOptionGraphicsItem myOption(*option);
myOption.state &= ~QStyle::State_Selected;
//painter->drawRect(boundingRect()); //good for debugging
// painter->setPen(Qt::yellow);
// painter->drawRect(boundingRect()); //good for debugging
QGraphicsSvgItem::paint (painter, &myOption, widget);
}

View File

@@ -49,7 +49,8 @@
using namespace TechDrawGui;
QGCustomText::QGCustomText()
QGCustomText::QGCustomText(QGraphicsItem* parent) :
QGraphicsTextItem(parent)
{
setCacheMode(QGraphicsItem::NoCache);
setAcceptHoverEvents(false);
@@ -64,12 +65,6 @@ QGCustomText::QGCustomText()
void QGCustomText::centerAt(QPointF centerPos)
{
centerAt(centerPos.x(),centerPos.y());
// QRectF box = boundingRect();
// double width = box.width();
// double height = box.height();
// double newX = centerPos.x() - width/2.;
// double newY = centerPos.y() - height/2.;
// setPos(newX,newY);
}
void QGCustomText::centerAt(double cX, double cY)
@@ -82,8 +77,52 @@ void QGCustomText::centerAt(double cX, double cY)
setPos(newX,newY);
}
void QGCustomText::justifyLeftAt(QPointF centerPos, bool vCenter)
{
justifyLeftAt(centerPos.x(),centerPos.y(), vCenter);
}
void QGCustomText::justifyLeftAt(double cX, double cY, bool vCenter)
{
QRectF box = boundingRect();
double height = box.height();
double newY = cY - height;
if (vCenter) {
newY = cY - height/2.;
}
setPos(cX,newY);
}
void QGCustomText::justifyRightAt(QPointF centerPos, bool vCenter)
{
justifyRightAt(centerPos.x(),centerPos.y(), vCenter);
}
void QGCustomText::justifyRightAt(double cX, double cY, bool vCenter)
{
QRectF box = boundingRect();
double width = box.width();
double height = box.height();
double newX = cX - width;
double newY = cY - height;
if (vCenter) {
newY = cY - height/2.;
}
setPos(newX,newY);
}
double QGCustomText::getHeight(void)
{
return boundingRect().height();
}
double QGCustomText::getWidth(void)
{
return boundingRect().width();
}
QVariant QGCustomText::itemChange(GraphicsItemChange change, const QVariant &value)
{
// Base::Console().Message("QGCT::itemChange - this: %X change: %d\n", this, change);
if (change == ItemSelectedHasChanged && scene()) {
if(isSelected()) {
setPrettySel();
@@ -112,18 +151,20 @@ void QGCustomText::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
}
void QGCustomText::setPrettyNormal() {
// m_colCurrent = getNormalColor();
m_colCurrent = m_colNormal;
setDefaultTextColor(m_colCurrent);
update();
}
void QGCustomText::setPrettyPre() {
m_colCurrent = getPreColor();
setDefaultTextColor(m_colCurrent);
update();
}
void QGCustomText::setPrettySel() {
m_colCurrent = getSelectColor();
setDefaultTextColor(m_colCurrent);
update();
}
@@ -131,31 +172,19 @@ void QGCustomText::paint ( QPainter * painter, const QStyleOptionGraphicsItem *
QStyleOptionGraphicsItem myOption(*option);
myOption.state &= ~QStyle::State_Selected;
// painter->setPen(Qt::green);
// painter->drawRect(boundingRect()); //good for debugging
setDefaultTextColor(m_colCurrent);
QGraphicsTextItem::paint (painter, &myOption, widget);
}
QColor QGCustomText::getNormalColor()
QColor QGCustomText::getNormalColor() //preference!
{
QColor result;
QGIView *parent;
QGraphicsItem* qparent = parentItem();
if (qparent == nullptr) {
parent = nullptr;
} else {
parent = dynamic_cast<QGIView *> (qparent);
}
if (parent != nullptr) {
result = parent->getNormalColor();
} else {
Base::Reference<ParameterGrp> hGrp = getParmGroup();
App::Color fcColor;
fcColor.setPackedValue(hGrp->GetUnsigned("NormalColor", 0x00000000));
result = fcColor.asValue<QColor>();
}
Base::Reference<ParameterGrp> hGrp = getParmGroup();
App::Color fcColor;
fcColor.setPackedValue(hGrp->GetUnsigned("NormalColor", 0x00000000));
result = fcColor.asValue<QColor>();
return result;
}

View File

@@ -41,24 +41,34 @@ namespace TechDrawGui
class TechDrawGuiExport QGCustomText : public QGraphicsTextItem
{
public:
explicit QGCustomText(void);
explicit QGCustomText(QGraphicsItem* parent = nullptr);
~QGCustomText() {}
enum {Type = QGraphicsItem::UserType + 130};
int type() const { return Type;}
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 );
void setHighlighted(bool state);
virtual void setPrettyNormal();
virtual void setPrettyPre();
virtual void setPrettySel();
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 );
virtual void centerAt(QPointF centerPos);
virtual void centerAt(double cX, double cY);
virtual void justifyLeftAt(QPointF centerPos, bool vCenter = true);
virtual void justifyLeftAt(double cX, double cY, bool vCenter = true);
virtual void justifyRightAt(QPointF centerPos, bool vCenter = true);
virtual void justifyRightAt(double cX, double cY, bool vCenter = true);
virtual double getHeight(void);
virtual double getWidth(void);
virtual QColor getNormalColor(void);
virtual QColor getPreColor(void);
virtual QColor getSelectColor(void);
virtual void setColor(QColor c) { m_colNormal = c; }
virtual void setColor(QColor c) { m_colNormal = c;
setDefaultTextColor(c); }
void makeMark(double x, double y);
void makeMark(Base::Vector3d v);

View File

@@ -45,11 +45,14 @@ QGIArrow::QGIArrow() :
m_fill(Qt::SolidPattern),
m_size(5.0),
m_style(0),
m_flipped(false),
m_dirMode(false),
m_dir(Base::Vector3d(1.0,0.0,0.0))
{
setFlipped(false);
setFill(Qt::SolidPattern);
m_brush.setStyle(m_fill);
m_colDefFill = getNormalColor();
m_colNormalFill = m_colDefFill;
setCacheMode(QGraphicsItem::NoCache);
setAcceptHoverEvents(false);
@@ -60,28 +63,33 @@ QGIArrow::QGIArrow() :
void QGIArrow::draw() {
QPainterPath path;
if (m_style == 0) {
setFill(Qt::SolidPattern);
if (m_dirMode) {
path = makeFilledTriangle(getDirection(), m_size,m_size/6.0);
} else {
path = makeFilledTriangle(m_size,m_size/6.0,isFlipped()); //"arrow l/w sb 3/1" ??
}
} else if (m_style == 1) {
setFill(Qt::NoBrush);
if (m_dirMode) {
path = makeOpenArrow(getDirection(), m_size,m_size/3.0); //broad arrow?
} else {
path = makeOpenArrow(m_size,m_size/3.0,isFlipped());
}
} else if (m_style == 2) {
setFill(Qt::NoBrush);
if (m_dirMode) {
path = makeHashMark(getDirection(), m_size/2.0,m_size/2.0); //big enough?
} else {
path = makeHashMark(m_size/2.0,m_size/2.0,isFlipped()); //big enough?
}
} else if (m_style == 3) {
setFill(Qt::SolidPattern);
path = makeDot(m_size/2.0,m_size/2.0,isFlipped());
} else if (m_style == 4) {
path = makeOpenDot(m_size/2.0,m_size/2.0,isFlipped());
} else if (m_style == 5) {
setFill(Qt::NoBrush);
if (m_dirMode) {
path = makeForkArrow(getDirection(), m_size/2.0,m_size/2.0); //big enough?
} else {
@@ -111,7 +119,7 @@ QPainterPath QGIArrow::makeFilledTriangle(double length, double width, bool flip
path.lineTo(QPointF(Rez::guiX(length),Rez::guiX(-width)));
path.lineTo(QPointF(Rez::guiX(length),Rez::guiX(width)));
path.closeSubpath();
m_fill = Qt::SolidPattern;
setFill(Qt::SolidPattern);
return path;
}
@@ -130,7 +138,7 @@ QPainterPath QGIArrow::makeFilledTriangle(Base::Vector3d dir, double length, dou
path.lineTo(QPointF(Rez::guiX(barb1.x),Rez::guiX(barb1.y)));
path.lineTo(QPointF(Rez::guiX(barb2.x),Rez::guiX(barb2.y)));
path.closeSubpath();
m_fill = Qt::SolidPattern;
setFill(Qt::SolidPattern);
return path;
}

View File

@@ -83,8 +83,43 @@ void QGIDecoration::setStyle(Qt::PenStyle s)
void QGIDecoration::setColor(QColor c)
{
m_colNormal = c;
m_colCurrent = c;
m_pen.setColor(m_colCurrent);
m_brush.setColor(m_colCurrent);
}
QColor QGIDecoration::prefNormalColor()
{
QColor result;
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors");
App::Color fcColor;
fcColor.setPackedValue(hGrp->GetUnsigned("NormalColor", 0x00000000));
result = fcColor.asValue<QColor>();
return result;
}
QColor QGIDecoration::prefPreColor()
{
QColor result;
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors");
App::Color fcColor;
fcColor.setPackedValue(hGrp->GetUnsigned("PreSelectColor", 0x00000000));
result = fcColor.asValue<QColor>();
return result;
}
QColor QGIDecoration::prefSelectColor()
{
QColor result;
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors");
App::Color fcColor;
fcColor.setPackedValue(hGrp->GetUnsigned("SelectColor", 0x00000000));
result = fcColor.asValue<QColor>();
return result;
}
void QGIDecoration::makeMark(double x, double y)

View File

@@ -52,13 +52,22 @@ public:
void setWidth(double w);
void setStyle(Qt::PenStyle s);
void setColor(QColor c);
QColor getColor(void) { return m_colNormal; }
void setFill(Qt::BrushStyle bs) { m_brushCurrent = bs; }
void makeMark(double x, double y);
void makeMark(Base::Vector3d v);
protected:
void setPrettyNormal();
void setPrettyPre();
void setPrettySel();
virtual QColor prefNormalColor(void);
virtual QColor prefPreColor(void);
virtual QColor prefSelectColor(void);
QPen m_pen;
QBrush m_brush;
QColor m_colCurrent;
QColor m_colNormal;
double m_width;
Qt::PenStyle m_styleCurrent;
Qt::BrushStyle m_brushCurrent;

View File

@@ -48,6 +48,7 @@ QGIEdge::QGIEdge(int index) :
{
m_width = 1.0;
setCosmetic(isCosmetic);
setFill(Qt::NoBrush);
}
//NOTE this refers to Qt cosmetic lines

View File

@@ -62,16 +62,14 @@
#include "QGCustomSvg.h"
#include "QGCustomRect.h"
#include "QGIViewPart.h"
#include "QGIPrimPath.h"
#include "QGIFace.h"
using namespace TechDrawGui;
using namespace TechDraw;
QGIFace::QGIFace(int index) :
projIndex(index),
m_colDefFill(Qt::white),
m_styleDef(Qt::SolidPattern),
m_styleSelect(Qt::SolidPattern)
projIndex(index)
{
m_segCount = 0;
setFillMode(NoFill);
@@ -80,10 +78,6 @@ QGIFace::QGIFace(int index) :
//setStyle(Qt::NoPen); //don't draw face lines, just fill for debugging
setStyle(Qt::DashLine);
m_styleNormal = m_styleDef;
m_fillStyle = m_styleDef;
m_colNormalFill = m_colDefFill;
m_geomColor = QColor(Qt::black);
setLineWeight(0.5); //0 = cosmetic
@@ -99,6 +93,15 @@ QGIFace::QGIFace(int index) :
m_fillScale = 1.0;
getParameters();
m_styleNormal = m_styleDef;
m_fillStyle = m_styleDef;
m_fill = m_styleDef;
m_colDefFill = Qt::white;
m_colNormalFill = m_colDefFill;
m_styleDef = Qt::SolidPattern;
m_styleSelect = Qt::SolidPattern;
}
QGIFace::~QGIFace()
@@ -115,6 +118,7 @@ void QGIFace::draw()
if (!m_lineSets.empty()) {
m_brush.setTexture(QPixmap());
m_fillStyle = m_styleDef;
m_fill = m_styleDef;
m_styleNormal = m_fillStyle;
for (auto& ls: m_lineSets) {
lineSetToFillItems(ls);
@@ -130,6 +134,7 @@ void QGIFace::draw()
setFillMode(SvgFill);
m_brush.setTexture(QPixmap());
m_fillStyle = m_styleDef;
m_fill = m_styleDef;
m_styleNormal = m_fillStyle;
loadSvgHatch(m_fileSpec);
buildSvgHatch();
@@ -141,6 +146,7 @@ void QGIFace::draw()
setFillMode(BitmapFill);
toggleSvg(false);
m_fillStyle = Qt::TexturePattern;
m_fill = Qt::TexturePattern;
m_texture = textureFromBitmap(m_fileSpec);
m_brush.setTexture(m_texture);
}
@@ -154,11 +160,14 @@ void QGIFace::setPrettyNormal() {
if (isHatched() &&
(m_mode == BitmapFill) ) { //hatch with bitmap fill
m_fillStyle = Qt::TexturePattern;
m_fill = Qt::TexturePattern;
m_brush.setTexture(m_texture);
} else {
m_fillStyle = m_styleNormal;
m_fill = m_styleNormal;
m_brush.setTexture(QPixmap());
m_brush.setStyle(m_fillStyle);
// m_brush.setStyle(m_fillStyle);
m_brush.setStyle(m_fill); //???
m_fillColor = m_colNormalFill;
}
QGIPrimPath::setPrettyNormal();
@@ -167,6 +176,7 @@ void QGIFace::setPrettyNormal() {
void QGIFace::setPrettyPre() {
m_brush.setTexture(QPixmap());
m_fillStyle = m_styleSelect;
m_fill = m_styleSelect;
m_fillColor = getPreColor();
QGIPrimPath::setPrettyPre();
}
@@ -174,6 +184,7 @@ void QGIFace::setPrettyPre() {
void QGIFace::setPrettySel() {
m_brush.setTexture(QPixmap());
m_fillStyle = m_styleSelect;
m_fill = m_styleSelect;
m_fillColor = getSelectColor();
QGIPrimPath::setPrettySel();
}
@@ -595,21 +606,6 @@ QPixmap QGIFace::textureFromBitmap(std::string fileSpec)
return pix;
}
void QGIFace::setFill(QColor c, Qt::BrushStyle s) {
m_colNormalFill = c;
m_styleNormal = s;
}
void QGIFace::setFill(QBrush b) {
m_colNormalFill = b.color();
m_styleNormal = b.style();
}
void QGIFace::resetFill() {
m_colNormalFill = m_colDefFill;
m_styleNormal = m_styleDef;
}
void QGIFace::setLineWeight(double w) {
m_geomWeight = w;
}
@@ -642,9 +638,9 @@ void QGIFace::paint ( QPainter * painter, const QStyleOptionGraphicsItem * optio
myOption.state &= ~QStyle::State_Selected;
// painter->drawRect(boundingRect()); //good for debugging
m_brush.setStyle(m_fillStyle);
m_brush.setColor(m_fillColor);
setBrush(m_brush);
// m_brush.setStyle(m_fillStyle);
// m_brush.setColor(m_fillColor);
// setBrush(m_brush);
QGIPrimPath::paint (painter, &myOption, widget);
}

View File

@@ -74,9 +74,9 @@ public:
int getProjIndex() const { return projIndex; }
void draw();
void setPrettyNormal();
void setPrettyPre();
void setPrettySel();
virtual void setPrettyNormal() override;
virtual void setPrettyPre() override;
void setPrettySel() override;
void setDrawEdges(bool b);
virtual void setOutline(const QPainterPath& path);
@@ -85,10 +85,10 @@ public:
bool isHatched(void) {return m_isHatched;}
void setFillMode(fillMode m);
//plain color fill parms
void setFill(QColor c, Qt::BrushStyle s);
void setFill(QBrush b);
void resetFill();
/* //plain color fill parms*/
/* void setFill(QColor c, Qt::BrushStyle s);*/
/* void setFill(QBrush b);*/
/* void resetFill();*/
//general hatch parms & methods
void setHatchColor(App::Color c);
@@ -151,15 +151,15 @@ protected:
private:
QBrush m_brush;
Qt::BrushStyle m_fillStyle; //current fill style
QColor m_fillColor; //current fill color
/* QBrush m_brush;*/
/* Qt::BrushStyle m_fillStyle; //current fill style*/
/* QColor m_fillColor; //current fill color*/
QColor m_colDefFill; //"no color" default normal fill color
QColor m_colNormalFill; //current Normal fill color
Qt::BrushStyle m_styleDef; //default Normal fill style
Qt::BrushStyle m_styleNormal; //current Normal fill style
Qt::BrushStyle m_styleSelect; //Select/preSelect fill style
/* QColor m_colDefFill; //"no color" default normal fill color*/
/* QColor m_colNormalFill; //current Normal fill color*/
/* Qt::BrushStyle m_styleDef; //default Normal fill style*/
/* Qt::BrushStyle m_styleNormal; //current Normal fill style*/
/* Qt::BrushStyle m_styleSelect; //Select/preSelect fill style*/
QPixmap m_texture; //

View File

@@ -95,6 +95,7 @@ QGILeaderLine::QGILeaderLine(QGraphicsItem* myParent,
// m_line->setPrettyNormal();
addToGroup(m_line);
m_line->setPos(0.0, 0.0);
m_line->setFlag(QGraphicsItem::ItemIsSelectable, false);
m_line->setFlag(QGraphicsItem::ItemIsMovable, false);
setFlag(QGraphicsItem::ItemSendsScenePositionChanges, false);
@@ -102,9 +103,11 @@ QGILeaderLine::QGILeaderLine(QGraphicsItem* myParent,
m_arrow1 = new QGIArrow();
addToGroup(m_arrow1);
m_arrow1->setPos(0.0,0.0);
m_arrow1->hide();
m_arrow2 = new QGIArrow();
addToGroup(m_arrow2);
m_arrow2->setPos(0.0, 0.0);
m_arrow2->hide();
setParentItem(m_parentItem);
@@ -128,7 +131,6 @@ QGILeaderLine::QGILeaderLine(QGraphicsItem* myParent,
QObject::connect(
m_line, SIGNAL(hover(bool)),
this , SLOT (hover(bool)));
}
QVariant QGILeaderLine::itemChange(GraphicsItemChange change, const QVariant &value)
@@ -361,6 +363,7 @@ void QGILeaderLine::draw()
return;
}
m_line->setFill(Qt::NoBrush);
m_line->setStyle(m_lineStyle);
double scaler = 1.0;
m_line->setWidth(scaler * m_lineWidth);
@@ -498,6 +501,11 @@ void QGILeaderLine::abandonEdit(void)
restoreState();
}
double QGILeaderLine::getLineWidth(void)
{
return m_lineWidth;
}
TechDraw::DrawLeaderLine* QGILeaderLine::getFeature(void)
{
TechDraw::DrawLeaderLine* result =
@@ -548,6 +556,7 @@ void QGILeaderLine::paint ( QPainter * painter, const QStyleOptionGraphicsItem *
QStyleOptionGraphicsItem myOption(*option);
myOption.state &= ~QStyle::State_Selected;
// painter->setPen(Qt::blue);
// painter->drawRect(boundingRect()); //good for debugging
QGIView::paint (painter, &myOption, widget);

View File

@@ -82,6 +82,8 @@ public:
void abandonEdit(void);
void closeEdit(void);
double getLineWidth(void);
public Q_SLOTS:
void onLineEditFinished(QPointF attach, std::vector<QPointF> deltas); //QGEPath is finished editing points

View File

@@ -42,7 +42,9 @@ using namespace TechDrawGui;
QGIPrimPath::QGIPrimPath():
m_width(0),
m_capStyle(Qt::RoundCap)
m_capStyle(Qt::RoundCap),
m_fill(Qt::NoBrush)
// m_fill(Qt::SolidPattern)
{
setCacheMode(QGraphicsItem::NoCache);
setFlag(QGraphicsItem::ItemIsSelectable, true);
@@ -53,16 +55,27 @@ QGIPrimPath::QGIPrimPath():
isHighlighted = false;
m_colNormal = Qt::white;
m_colOverride = false;
m_colCurrent = getNormalColor();
m_colNormal = getNormalColor();
m_colCurrent = m_colNormal;
m_styleCurrent = Qt::SolidLine;
m_pen.setStyle(m_styleCurrent);
m_capStyle = prefCapStyle();
m_pen.setCapStyle(m_capStyle);
// m_pen.setCapStyle(Qt::FlatCap);
m_pen.setWidthF(m_width);
m_styleDef = Qt::NoBrush;
m_styleSelect = Qt::SolidPattern;
m_styleNormal = m_styleDef;
m_colDefFill = Qt::white;
// m_colDefFill = Qt::transparent;
m_fillStyle = m_styleDef;
m_fill = m_styleDef;
m_colNormalFill = m_colDefFill;
m_brush.setStyle(m_styleDef);
m_brush.setColor(m_colDefFill);
setPrettyNormal();
}
@@ -107,31 +120,24 @@ void QGIPrimPath::setHighlighted(bool b)
}
void QGIPrimPath::setPrettyNormal() {
m_colCurrent = getNormalColor();
m_colCurrent = m_colNormal;
m_fillColor = m_colNormalFill;
// m_colCurrent = getNormalColor();
update();
}
void QGIPrimPath::setPrettyPre() {
m_colCurrent = getPreColor();
m_fillColor = getPreColor();
update();
}
void QGIPrimPath::setPrettySel() {
m_colCurrent = getSelectColor();
m_fillColor = getSelectColor();
update();
}
void QGIPrimPath::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) {
QStyleOptionGraphicsItem myOption(*option);
myOption.state &= ~QStyle::State_Selected;
m_pen.setWidthF(m_width);
m_pen.setColor(m_colCurrent);
m_pen.setStyle(m_styleCurrent);
setPen(m_pen);
QGraphicsPathItem::paint (painter, &myOption, widget);
}
QColor QGIPrimPath::getNormalColor()
{
@@ -256,15 +262,56 @@ Qt::PenCapStyle QGIPrimPath::prefCapStyle()
void QGIPrimPath::mousePressEvent(QGraphicsSceneMouseEvent * event)
{
//wf: this seems a bit of a hack. does it mess up selection of QGIPP??
QGIView *parent;
QGraphicsItem* qparent = parentItem();
if (qparent != nullptr) {
parent = dynamic_cast<QGIView *> (qparent);
if (parent != nullptr) {
// Base::Console().Message("QGIPP::mousePressEvent - passing event to QGIV parent\n");
parent->mousePressEvent(event);
} else {
// qparent->mousePressEvent(event); //protected!
QGraphicsPathItem::mousePressEvent(event);
Base::Console().Log("QGIPP::mousePressEvent - no QGIView parent\n");
}
} else {
// Base::Console().Message("QGIPP::mousePressEvent - passing event to ancestor\n");
QGraphicsPathItem::mousePressEvent(event);
}
QGraphicsPathItem::mousePressEvent(event);
}
void QGIPrimPath::setFill(QColor c, Qt::BrushStyle s) {
m_colNormalFill = c;
m_styleNormal = s;
m_fill = s;
}
void QGIPrimPath::setFill(QBrush b) {
m_colNormalFill = b.color();
m_styleNormal = b.style();
m_fill = b.style();
}
void QGIPrimPath::resetFill() {
m_colNormalFill = m_colDefFill;
m_styleNormal = m_styleDef;
m_fill = m_styleDef;
}
void QGIPrimPath::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) {
QStyleOptionGraphicsItem myOption(*option);
myOption.state &= ~QStyle::State_Selected;
m_pen.setWidthF(m_width);
m_pen.setColor(m_colCurrent);
m_pen.setStyle(m_styleCurrent);
setPen(m_pen);
m_brush.setColor(m_fillColor); //pencolr
m_brush.setStyle(m_fill);
setBrush(m_brush);
QGraphicsPathItem::paint (painter, &myOption, widget);
}

View File

@@ -58,6 +58,15 @@ public:
void setStyle(int s);
virtual void setNormalColor(QColor c);
virtual void setCapStyle(Qt::PenCapStyle c);
Qt::BrushStyle getFill() { return m_fill; }
//plain color fill parms
void setFill(Qt::BrushStyle f) { m_fill = f; }
void setFill(QColor c, Qt::BrushStyle s);
void setFill(QBrush b);
void resetFill();
void setFillColor(QColor c) { m_colNormalFill = c;
m_colDefFill = c; }
protected:
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
@@ -72,6 +81,7 @@ protected:
virtual Qt::PenCapStyle prefCapStyle(void);
bool isHighlighted;
QPen m_pen;
QColor m_colCurrent;
QColor m_colNormal;
@@ -80,6 +90,18 @@ protected:
double m_width;
Qt::PenCapStyle m_capStyle;
QBrush m_brush;
Qt::BrushStyle m_fill; //current fille style
Qt::BrushStyle m_fillStyle; //current fill style*/
QColor m_fillColor; //current fill color
QColor m_colDefFill; //"no color" default normal fill color
QColor m_colNormalFill; //current Normal fill color
Qt::BrushStyle m_styleDef; //default Normal fill style
Qt::BrushStyle m_styleNormal; //current Normal fill style
Qt::BrushStyle m_styleSelect; //Select/preSelect fill style
private:
};

View File

@@ -0,0 +1,409 @@
/***************************************************************************
* Copyright (c) 2019 WandererFan <wandererfan@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <QPainter>
#include <QGraphicsItem>
#include <QStyleOptionGraphicsItem>
#include <QFile>
#include <QFileInfo>
#endif
#include <App/Application.h>
#include <App/Material.h>
#include <Base/Console.h>
#include <Base/Parameter.h>
#include <Mod/TechDraw/App/DrawUtil.h>
#include <Mod/TechDraw/App/DrawTile.h>
#include <Mod/TechDraw/App/DrawTileWeld.h>
#include <Mod/TechDraw/App/DrawWeldSymbol.h>
#include <qmath.h>
#include "Rez.h"
#include "DrawGuiUtil.h"
#include "QGIView.h"
#include "QGIWeldSymbol.h"
#include "QGITile.h"
using namespace TechDrawGui;
QGITile::QGITile() :
m_textL(QString::fromUtf8(" ")),
m_textR(QString::fromUtf8(" ")),
m_textC(QString::fromUtf8(" ")),
m_scale(1.0),
m_row(0),
m_col(0),
m_tailRight(true),
m_altWeld(false)
{
m_qgSvg = new QGCustomSvg();
addToGroup(m_qgSvg);
// m_effect = new QGraphicsColorizeEffect();
m_qgTextL = new QGCustomText();
addToGroup(m_qgTextL);
m_qgTextR = new QGCustomText();
addToGroup(m_qgTextR);
m_qgTextC = new QGCustomText();
addToGroup(m_qgTextC);
m_wide = getSymbolWidth();
m_high = prefFontSize();
m_textL = QString();
m_textR = QString();
m_textC = QString();
m_fontName = prefTextFont();
m_font = QFont(m_fontName);
#if PY_MAJOR_VERSION < 3
setHandlesChildEvents(true); //qt4 deprecated in qt5
#else
setFiltersChildEvents(true); //qt5
#endif
setAcceptHoverEvents(true);
setFlag(QGraphicsItem::ItemIsSelectable, false);
setFlag(QGraphicsItem::ItemIsMovable, false);
setFlag(QGraphicsItem::ItemSendsScenePositionChanges, false);
setFlag(QGraphicsItem::ItemSendsGeometryChanges,true);
setFlag(QGraphicsItem::ItemStacksBehindParent, true);
m_colNormal = prefNormalColor();
m_colCurrent = m_colNormal;
}
QGITile::~QGITile(void)
{
}
QVariant QGITile::itemChange(GraphicsItemChange change, const QVariant &value)
{
// Base::Console().Message("QGIT::itemChange(%d)\n", change);
return QGIDecoration::itemChange(change, value);
}
void QGITile::draw(void)
{
// Base::Console().Message("QGIT::draw()\n");
prepareGeometryChange();
m_wide = getSymbolWidth();
m_high = getSymbolHeight() * scaleToFont();
makeText();
makeSymbol();
double textWidthL = m_qgTextL->boundingRect().width();
double textWidthR = m_qgTextR->boundingRect().width();
double totalWidth = m_wide + textWidthL + textWidthR;
if (m_row == 0) { //arrowSide
double x = m_origin.x();
double y = m_origin.y() - (m_high * 0.5); //inverted y!!
setPos(x,y);
} else if (m_row == -1) { //otherSide
if (getAltWeld()) {
if (isTailRight()) {
double x = m_origin.x() + (0.5 * totalWidth); //move to right 1/2 tile width
double y = m_origin.y() + (m_high * 0.5); //inverted y!!
setPos(x,y);
} else {
double x = m_origin.x() - (0.5 * totalWidth); //move to left 1/2 tile width
double y = m_origin.y() + (m_high * 0.5); //inverted y!!
setPos(x,y);
}
} else {
double x = m_origin.x();
double y = m_origin.y() + (m_high * 0.5); //inverted y!!
setPos(x,y);
}
} else {
double x = m_origin.x() + m_col * totalWidth;
double y = m_origin.y() - (m_row * m_high) - (m_high * 0.5); //inverted y!!
setPos(x,y);
}
}
void QGITile::makeSymbol(void)
{
// Base::Console().Message("QGIT::makeSymbol()\n");
// m_effect->setColor(m_colCurrent);
if (m_svgPath.isEmpty()) {
Base::Console().Warning("QGIT::makeSymbol - no symbol file set\n");
return;
}
// m_qgSvg->setGraphicsEffect(m_effect);
QFileInfo fi(m_svgPath);
if (fi.isReadable()) {
QFile svgFile(m_svgPath);
if(svgFile.open(QIODevice::ReadOnly)) {
QByteArray qba = svgFile.readAll();
if (!m_qgSvg->load(&qba)) {
Base::Console().Error("Error - Could not load SVG renderer with **%s**\n", qPrintable(m_svgPath));
return;
}
svgFile.close();
m_qgSvg->setScale(scaleToFont());
m_qgSvg->centerAt(0.0, 0.0); //(0,0) is based on symbol size
} else {
Base::Console().Error("Error - Could not open file **%s**\n", qPrintable(m_svgPath));
}
} else {
Base::Console().Error("QGIT::makeSymbol - file: **%s** is not readable\n",qPrintable(m_svgPath));
return;
}
}
void QGITile::makeText(void)
{
// Base::Console().Message("QGIT::makeText()\n");
prepareGeometryChange();
m_font.setPixelSize(prefFontSize());
double verticalFudge = 0.10;
//(0, 0) is 1/2 up (above line symbol)!
m_qgTextL->setFont(m_font);
m_qgTextL->setPlainText(m_textL);
m_qgTextL->setColor(m_colCurrent);
double textWidth = m_qgTextL->boundingRect().width();
double charWidth = textWidth / m_textL.size(); //not good for non-ASCII chars
double hMargin = 1;
if (!m_textL.isEmpty()) {
hMargin = (m_wide / 2.0) + (charWidth / 2.0);
}
double textHeightL = m_qgTextL->boundingRect().height();
double vOffset = 0.0;
if (m_row < 0) { // below line
vOffset = textHeightL * verticalFudge;
} else {
vOffset = 0.0;
}
m_qgTextL->justifyRightAt(-hMargin, vOffset, true);
m_qgTextR->setFont(m_font);
m_qgTextR->setPlainText(m_textR);
m_qgTextR->setColor(m_colCurrent);
textWidth = m_qgTextR->boundingRect().width();
charWidth = textWidth / m_textR.size();
hMargin = 1;
if (!m_textR.isEmpty()) {
hMargin = (m_wide / 2.0) + (charWidth / 2.0);
}
double textHeightR = m_qgTextR->boundingRect().height();
if (m_row < 0) { // below line
vOffset = textHeightR * verticalFudge;
} else {
vOffset = 0.0;
}
m_qgTextR->justifyLeftAt(hMargin, vOffset, true);
m_qgTextC->setFont(m_font);
m_qgTextC->setPlainText(m_textC);
m_qgTextC->setColor(m_colCurrent);
double textHeightC = m_qgTextC->boundingRect().height();
textHeightC = textHeightC;
if (m_row < 0) { // below line
vOffset = m_high * (1 + verticalFudge);
} else {
vOffset = -0.5 * (m_high + textHeightC);
}
m_qgTextC->centerAt(0.0, vOffset);
}
void QGITile::setTilePosition(QPointF org, int r, int c)
{
m_origin = org;
m_row = r;
m_col = c;
}
void QGITile::setTileScale(double s)
{
m_scale = s;
}
void QGITile::setTileTextLeft(std::string s)
{
m_textL = QString::fromUtf8(s.c_str());
}
void QGITile::setTileTextRight(std::string s)
{
m_textR = QString::fromUtf8(s.c_str());
}
void QGITile::setTileTextCenter(std::string s)
{
m_textC = QString::fromUtf8(s.c_str());
}
//using label font and dimension font size. could change later
//void QGITile::setFont(QFont f, double fsize)
//{
// m_font = f;
// m_textSize = fsize;
//}
void QGITile::setSymbolFile(std::string s)
{
// Base::Console().Message("QGIT::setSymbolFile(%s)\n",s.c_str());
if (!s.empty()) {
m_svgPath = QString::fromUtf8(s.c_str());
}
}
void QGITile::setPrettyNormal() {
m_colCurrent = m_colNormal;
// m_effect->setColor(m_colNormal);
m_qgTextL->setColor(m_colNormal);
m_qgTextR->setColor(m_colNormal);
m_qgTextC->setColor(m_colNormal);
draw();
}
void QGITile::setPrettyPre() {
m_colCurrent = prefPreColor();
// m_effect->setColor(m_colCurrent);
m_qgTextL->setColor(m_colCurrent);
m_qgTextR->setColor(m_colCurrent);
m_qgTextC->setColor(m_colCurrent);
draw();
}
void QGITile::setPrettySel() {
m_colCurrent = prefSelectColor();
// m_effect->setColor(m_colCurrent);
m_qgTextL->setColor(m_colCurrent);
m_qgTextR->setColor(m_colCurrent);
m_qgTextC->setColor(m_colCurrent);
draw();
}
bool QGITile::isTailRight(void)
{
return m_tailRight;
}
bool QGITile::getAltWeld(void)
{
return m_altWeld;
}
//TODO: this is Pen, not Brush. sb Brush to colour background
QColor QGITile::getTileColor(void) const
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors");
App::Color fcColor = App::Color((uint32_t) hGrp->GetUnsigned("TileColor", 0x00000000));
return fcColor.asValue<QColor>();
}
double QGITile::getSymbolWidth(void) const
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions");
double w = hGrp->GetFloat("SymbolSize",64);
// symbols are only nominally 64x64. they actually have a "border" of 4 - 0.5*stroke(0.5)
// so we'll say effectively 62x62? 60 x 60
// double w = 64.0;
double fudge = 4.0; //allowance for tile border
w = w - fudge;
return w;
}
double QGITile::getSymbolHeight(void) const
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions");
double h = hGrp->GetFloat("SymbolSize",64);
double fudge = 4.0;
h = h - fudge;
// double h = 60.0;
return h;
}
double QGITile::getSymbolFactor(void) const
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations");
double s = hGrp->GetFloat("SymbolFactor",1.25);
// double s = 1.25;
return s;
}
double QGITile::prefFontSize(void) const
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions");
double sizeMM = hGrp->GetFloat("FontSize", QGIView::DefaultFontSizeInMM);
double fontSize = QGIView::calculateFontPixelSize(sizeMM);
return fontSize;
}
//factor to scale symbol to match font size
double QGITile::scaleToFont(void) const
{
double fpx = prefFontSize();
double spx = getSymbolHeight();
double factor = getSymbolFactor();
double sf = (fpx / spx) * factor;
return sf;
}
QString QGITile::prefTextFont(void) const
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Labels");
std::string fontName = hGrp->GetASCII("LabelFont", "osifont");
return QString::fromStdString(fontName);
}
void QGITile::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) {
QStyleOptionGraphicsItem myOption(*option);
myOption.state &= ~QStyle::State_Selected;
// painter->setPen(Qt::magenta);
// painter->drawRect(boundingRect()); //good for debugging
QGIDecoration::paint (painter, &myOption, widget);
}
QRectF QGITile::boundingRect() const
{
return childrenBoundingRect();
}

View File

@@ -0,0 +1,119 @@
/***************************************************************************
* Copyright (c) 2019 WandererFan <wandererfan@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef TECHDRAWGUI_QGITILE_H
#define TECHDRAWGUI_QGITILE_H
#include <QFont>
#include <QPointF>
#include <QGraphicsTextItem>
#include <QGraphicsRectItem>
#include <QGraphicsEllipseItem>
#include <QPainterPath>
#include <QColor>
#include <QGraphicsColorizeEffect>
#include <Base/Vector3D.h>
#include "QGIArrow.h"
#include "QGCustomText.h"
#include "QGCustomRect.h"
#include "QGCustomSvg.h"
#include "QGIDecoration.h"
namespace TechDraw {
class DrawTile;
class DrawTileWeld;
}
namespace TechDrawGui
{
class QGIWeldSymbol;
class TechDrawGuiExport QGITile : public QGIDecoration
{
public:
explicit QGITile();
~QGITile(void);
enum {Type = QGraphicsItem::UserType + 325};
int type(void) const { return Type;}
virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 );
virtual QRectF boundingRect() const;
void setTileTextLeft(std::string s);
void setTileTextRight(std::string s);
void setTileTextCenter(std::string s);
void setFont(QFont f, double fsize);
void setSymbolFile(std::string s);
void setTilePosition(QPointF org, int r, int c);
void setTileScale(double s);
void setTailRight(bool b) { m_tailRight = b; }
void setAltWeld(bool b) { m_altWeld = b; }
bool isTailRight(void);
virtual void draw(void);
protected:
virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value);
QColor getTileColor(void) const;
void setPrettyNormal();
void setPrettyPre();
void setPrettySel();
double getSymbolWidth(void) const;
double getSymbolHeight(void) const;
double getSymbolFactor(void) const;
QString prefTextFont(void) const;
double prefFontSize(void) const;
double scaleToFont(void) const;
void makeSymbol(void);
void makeText(void);
bool getAltWeld(void);
private:
QGCustomText* m_qgTextL;
QGCustomText* m_qgTextR;
QGCustomText* m_qgTextC;
QGCustomSvg* m_qgSvg;
QGraphicsColorizeEffect* m_effect;
QString m_svgPath;
QString m_textL;
QString m_textR;
QString m_textC;
QString m_fontName;
QFont m_font;
QPointF m_origin;
double m_wide;
double m_high;
double m_scale;
int m_row;
int m_col;
bool m_tailRight;
bool m_altWeld;
};
}
#endif // TECHDRAWGUI_QGITILE_H

View File

@@ -47,6 +47,8 @@ QGIRichAnno: 233
QGMText: 300
QGEPath: 301
QGMarker: 302
QGITile: 325
QGIWeldSymbol: 340
*/
/*

View File

@@ -35,15 +35,18 @@
#include <Base/Console.h>
//#include <Base/Parameter.h>
#include "QGIPrimPath.h"
#include "QGIVertex.h"
using namespace TechDrawGui;
QGIVertex::QGIVertex(int index) :
projIndex(index),
m_radius(2),
m_fill(Qt::SolidPattern)
m_radius(2)
{
m_colDefFill = getNormalColor();
m_colNormalFill = m_colDefFill;
m_fill = Qt::SolidPattern;
m_brush.setStyle(m_fill);
setRadius(m_radius);
@@ -62,8 +65,11 @@ void QGIVertex::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,
QStyleOptionGraphicsItem myOption(*option);
myOption.state &= ~QStyle::State_Selected;
m_brush.setColor(m_colCurrent);
m_brush.setStyle(m_fill);
setBrush(m_brush);
// painter->setPen(Qt::blue);
// painter->drawRect(boundingRect()); //good for debugging
// m_brush.setColor(m_colCurrent);
// m_brush.setStyle(m_fill);
// setBrush(m_brush);
QGIPrimPath::paint (painter, &myOption, widget);
}

View File

@@ -42,14 +42,14 @@ public:
float getRadius() { return m_radius; }
virtual void setRadius(float r);
Qt::BrushStyle getFill() { return m_fill; }
void setFill(Qt::BrushStyle f) { m_fill = f; }
/* Qt::BrushStyle getFill() { return m_fill; }*/
/* void setFill(Qt::BrushStyle f) { m_fill = f; }*/
protected:
int projIndex;
float m_radius;
QBrush m_brush;
Qt::BrushStyle m_fill;
/* QBrush m_brush;*/
/* Qt::BrushStyle m_fill;*/
private:
};

View File

@@ -82,7 +82,8 @@ QGIView::QGIView()
:QGraphicsItemGroup(),
viewObj(nullptr),
m_locked(false),
m_innerView(false)
m_innerView(false),
m_selectState(0)
{
setCacheMode(QGraphicsItem::NoCache);
setHandlesChildEvents(false);
@@ -215,8 +216,10 @@ QVariant QGIView::itemChange(GraphicsItemChange change, const QVariant &value)
if (change == ItemSelectedHasChanged && scene()) {
if(isSelected()) {
m_colCurrent = getSelectColor();
m_selectState = 2;
} else {
m_colCurrent = getNormalColor();
m_selectState = 0;
}
drawBorder();
}
@@ -257,8 +260,10 @@ void QGIView::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
// TODO don't like this but only solution at the minute (MLP)
if (isSelected()) {
m_colCurrent = getSelectColor();
m_selectState = 2;
} else {
m_colCurrent = getPreColor();
m_selectState = 1;
}
drawBorder();
}
@@ -268,8 +273,10 @@ void QGIView::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
Q_UNUSED(event);
if(isSelected()) {
m_colCurrent = getSelectColor();
m_selectState = 1;
} else {
m_colCurrent = getNormalColor();
m_selectState = 0;
}
drawBorder();
}
@@ -518,6 +525,7 @@ void QGIView::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, Q
QStyleOptionGraphicsItem myOption(*option);
myOption.state &= ~QStyle::State_Selected;
// painter->setPen(Qt::red);
// painter->drawRect(boundingRect()); //good for debugging
QGraphicsItemGroup::paint(painter, &myOption, widget);
@@ -534,8 +542,12 @@ QRectF QGIView::customChildrenBoundingRect() const
int textLeaderItemType = QGraphicsItem::UserType + 233; // TODO: Magic number warning
int editablePathItemType = QGraphicsItem::UserType + 301; // TODO: Magic number warning
int movableTextItemType = QGraphicsItem::UserType + 300;
int weldingSymbolItemType = QGraphicsItem::UserType + 340;
QRectF result;
for (QList<QGraphicsItem*>::iterator it = children.begin(); it != children.end(); ++it) {
if (!(*it)->isVisible()) {
continue;
}
if ( ((*it)->type() != dimItemType) &&
((*it)->type() != leaderItemType) &&
((*it)->type() != textLeaderItemType) &&
@@ -543,6 +555,7 @@ QRectF QGIView::customChildrenBoundingRect() const
((*it)->type() != movableTextItemType) &&
((*it)->type() != borderItemType) &&
((*it)->type() != labelItemType) &&
((*it)->type() != weldingSymbolItemType) &&
((*it)->type() != captionItemType) ) {
QRectF childRect = mapFromItem(*it,(*it)->boundingRect()).boundingRect();
result = result.united(childRect);
@@ -622,6 +635,7 @@ bool QGIView::getFrameState(void)
return result;
}
//TODO: change name to prefNormalColor()
QColor QGIView::getNormalColor()
{
Base::Reference<ParameterGrp> hGrp = getParmGroupCol();

View File

@@ -105,9 +105,12 @@ public:
void alignTo(QGraphicsItem*, const QString &alignment);
void setLocked(bool b) { m_locked = b; }
virtual QColor getNormalColor(void);
virtual QColor getPreColor(void);
virtual QColor getSelectColor(void);
virtual QColor getNormalColor(void); //preference
virtual QColor getPreColor(void); //preference
virtual QColor getSelectColor(void); //preference
virtual QColor getCurrentColor(void) { return m_colCurrent; }
virtual QColor getSettingColor(void) { return m_colSetting; }
virtual void setSettingColor(QColor c) { m_colSetting = c; }
static Gui::ViewProvider* getViewProvider(App::DocumentObject* obj);
static QGVPage* getGraphicsView(TechDraw::DrawView* dv);
@@ -156,6 +159,7 @@ protected:
QColor m_colNormal;
QColor m_colPre;
QColor m_colSel;
QColor m_colSetting;
QFont m_font;
QGCustomLabel* m_label;
QGCustomBorder* m_border;
@@ -165,6 +169,7 @@ protected:
double m_lockWidth;
double m_lockHeight;
int m_selectState;
};
} // namespace

View File

@@ -560,6 +560,7 @@ void QGIViewPart::drawViewPart()
item->setRadius(cv->size);
} else {
item->setNormalColor(vertexColor);
item->setFillColor(vertexColor);
item->setRadius(lineWidth * vertexScaleFactor);
}
addToGroup(item);

View File

@@ -0,0 +1,526 @@
/***************************************************************************
* Copyright (c) 2019 WandererFan <wandererfan@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <BRep_Builder.hxx>
#include <TopoDS_Compound.hxx>
# include <TopoDS_Shape.hxx>
# include <TopoDS_Edge.hxx>
# include <TopoDS.hxx>
# include <BRepAdaptor_Curve.hxx>
# include <Precision.hxx>
# include <QGraphicsScene>
# include <QPainter>
# include <QPaintDevice>
# include <QSvgGenerator>
# include <math.h>
#endif
#include <App/Application.h>
#include <App/Material.h>
#include <Base/Console.h>
#include <Base/Exception.h>
#include <Base/Parameter.h>
#include <Base/UnitsApi.h>
#include <Gui/Command.h>
#include <Mod/Part/App/PartFeature.h>
#include <Mod/TechDraw/App/DrawWeldSymbol.h>
#include <Mod/TechDraw/App/DrawLeaderLine.h>
#include <Mod/TechDraw/App/DrawTile.h>
#include <Mod/TechDraw/App/DrawTileWeld.h>
#include <Mod/TechDraw/App/DrawUtil.h>
#include <Mod/TechDraw/App/Geometry.h>
#include "Rez.h"
#include "ZVALUE.h"
#include "ViewProviderWeld.h"
#include "MDIViewPage.h"
#include "DrawGuiUtil.h"
#include "QGVPage.h"
#include "QGIPrimPath.h"
#include "QGITile.h"
#include "QGILeaderLine.h"
#include "QGIVertex.h"
#include "QGCustomText.h"
#include "QGIWeldSymbol.h"
using namespace TechDraw;
using namespace TechDrawGui;
//**************************************************************
QGIWeldSymbol::QGIWeldSymbol(QGILeaderLine* myParent) :
m_weldFeat(nullptr),
m_leadFeat(nullptr),
m_arrowFeat(nullptr),
m_otherFeat(nullptr),
m_qgLead(myParent),
m_blockDraw(false)
{
#if PY_MAJOR_VERSION < 3
setHandlesChildEvents(true); //qt4 deprecated in qt5
#else
setFiltersChildEvents(true); //qt5
#endif
setFlag(QGraphicsItem::ItemIsMovable, false);
setCacheMode(QGraphicsItem::NoCache);
setParentItem(m_qgLead);
m_leadFeat = m_qgLead->getFeature();
setZValue(ZVALUE::DIMENSION);
m_tailText = new QGCustomText();
m_tailText->setPlainText(
QString::fromUtf8(" "));
addToGroup(m_tailText);
m_tailText->hide();
m_tailText->setPos(0.0, 0.0); //avoid bRect issues
m_allAround = new QGIVertex(-1);
addToGroup(m_allAround);
m_allAround->setPos(0.0, 0.0);
m_allAround->setAcceptHoverEvents(false);
m_allAround->setFlag(QGraphicsItem::ItemIsSelectable, false);
m_allAround->setFlag(QGraphicsItem::ItemIsMovable, false);
m_allAround->setFlag(QGraphicsItem::ItemSendsScenePositionChanges, false);
m_allAround->setFlag(QGraphicsItem::ItemSendsGeometryChanges,true);
m_allAround->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
m_fieldFlag = new QGIPrimPath();
addToGroup(m_fieldFlag);
m_fieldFlag->setPos(0.0, 0.0);
m_fieldFlag->setAcceptHoverEvents(false);
m_fieldFlag->setFlag(QGraphicsItem::ItemIsSelectable, false);
m_fieldFlag->setFlag(QGraphicsItem::ItemIsMovable, false);
m_fieldFlag->setFlag(QGraphicsItem::ItemSendsScenePositionChanges, false);
m_fieldFlag->setFlag(QGraphicsItem::ItemSendsGeometryChanges,true);
m_fieldFlag->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
m_colCurrent = prefNormalColor();
m_colSetting = m_colCurrent;
}
QVariant QGIWeldSymbol::itemChange(GraphicsItemChange change, const QVariant &value)
{
// Base::Console().Message("QGIWS::itemChange(%d)\n", change);
if (change == ItemSelectedHasChanged && scene()) {
if(isSelected()) {
setPrettySel();
} else {
setPrettyNormal();
}
} else if(change == ItemSceneChange && scene()) {
// nothing special!
}
return QGIView::itemChange(change, value);
}
void QGIWeldSymbol::updateView(bool update)
{
// Base::Console().Message("QGIWS::updateView()\n");
Q_UNUSED(update);
auto viewWeld( dynamic_cast<TechDraw::DrawWeldSymbol*>(getViewObject()) );
if( viewWeld == nullptr ) {
return;
}
if ( getFeature() == nullptr ) {
Base::Console().Warning("QGIWS::updateView - no feature!\n");
return;
}
draw();
}
void QGIWeldSymbol::draw()
{
// Base::Console().Message("QGIWS::draw()- %s\n", getFeature()->getNameInDocument());
if (!isVisible()) {
return;
}
getTileFeats();
removeQGITiles();
if (m_arrowFeat != nullptr) {
drawTile(m_arrowFeat);
}
if (m_otherFeat != nullptr) {
drawTile(m_otherFeat);
}
drawAllAround();
drawFieldFlag();
drawTailText();
}
void QGIWeldSymbol::drawTile(TechDraw::DrawTileWeld* tileFeat)
{
// Base::Console().Message("QGIWS::drawTile() - tileFeat: %X\n", tileFeat);
if (tileFeat == nullptr) {
Base::Console().Message("QGIWS::drawTile - tile is null\n");
return;
}
double featScale = m_leadFeat->getScale();
std::string tileTextL = tileFeat->LeftText.getValue();
std::string tileTextR = tileFeat->RightText.getValue();
std::string tileTextC = tileFeat->CenterText.getValue();
std::string symbolFile = tileFeat->SymbolFile.getValue();
int row = tileFeat->TileRow.getValue();
int col = tileFeat->TileColumn.getValue();
QGITile* tile = new QGITile();
addToGroup(tile);
QPointF org = getTileOrigin();
tile->setTilePosition(org, row, col);
tile->setColor(getCurrentColor());
tile->setTileTextLeft(tileTextL);
tile->setTileTextRight(tileTextR);
tile->setTileTextCenter(tileTextC);
tile->setSymbolFile(symbolFile);
tile->setZValue(ZVALUE::DIMENSION);
tile->setTileScale(featScale);
tile->setTailRight(m_weldFeat->isTailRightSide());
tile->setAltWeld(m_weldFeat->AlternatingWeld.getValue());
tile->draw();
}
void QGIWeldSymbol::drawAllAround(void)
{
// Base::Console().Message("QGIWS::drawAllAround()\n");
if (getFeature()->AllAround.getValue()) {
m_allAround->show();
} else {
m_allAround->hide();
return;
}
m_allAround->setNormalColor(getCurrentColor());
m_allAround->setFill(Qt::NoBrush);
m_allAround->setRadius(calculateFontPixelSize(getDimFontSize()));
double width = m_qgLead->getLineWidth();
m_allAround->setWidth(width);
m_allAround->setZValue(ZVALUE::DIMENSION);
QPointF allAroundPos = getKinkPoint();
m_allAround->setPos(allAroundPos);
}
void QGIWeldSymbol::drawTailText(void)
{
// Base::Console().Message("QGIWS::drawTailText()\n");
QPointF textPos = getTailPoint();
m_tailText->setPos(textPos); //avoid messing up brect with empty item at 0,0
std::string tText = getFeature()->TailText.getValue();
if (tText.empty()) {
m_tailText->hide();
return;
} else {
m_tailText->show();
}
m_font.setFamily(getPrefFont());
m_font.setPixelSize(calculateFontPixelSize(getDimFontSize()));
m_tailText->setFont(m_font);
m_tailText->setPlainText(
QString::fromUtf8(tText.c_str()));
m_tailText->setColor(getCurrentColor());
m_tailText->setZValue(ZVALUE::DIMENSION);
double textWidth = m_tailText->boundingRect().width();
double charWidth = textWidth / tText.size();
double hMargin = charWidth + prefArrowSize();
if (getFeature()->isTailRightSide()) {
m_tailText->justifyLeftAt(textPos.x() + hMargin, textPos.y(), true);
} else {
m_tailText->justifyRightAt(textPos.x() - hMargin, textPos.y(), true);
}
}
void QGIWeldSymbol::drawFieldFlag()
{
// Base::Console().Message("QGIWS::drawFieldFlag()\n");
if (getFeature()->FieldWeld.getValue()) {
m_fieldFlag->show();
} else {
m_fieldFlag->hide();
return;
}
std::vector<QPointF> flagPoints = { QPointF(0.0, 0.0),
QPointF(0.0, -3.0),
QPointF(-2.0, -2.5),
QPointF(0.0, -2.0) };
//flag sb about 2x text?
double scale = calculateFontPixelSize(getDimFontSize()) / 2.0;
QPainterPath path;
path.moveTo(flagPoints.at(0) * scale);
int i = 1;
int stop = flagPoints.size();
for ( ; i < stop; i++) {
path.lineTo(flagPoints.at(i) * scale);
}
m_fieldFlag->setNormalColor(getCurrentColor()); //penColor
double width = m_qgLead->getLineWidth();
m_fieldFlag->setFillColor(getCurrentColor());
m_fieldFlag->setFill(Qt::SolidPattern);
m_fieldFlag->setWidth(width);
m_fieldFlag->setZValue(ZVALUE::DIMENSION);
m_fieldFlag->setPath(path);
QPointF fieldFlagPos = getKinkPoint();
m_fieldFlag->setPos(fieldFlagPos);
}
void QGIWeldSymbol::getTileFeats(void)
{
std::vector<TechDraw::DrawTileWeld*> tiles = getFeature()->getTiles();
m_arrowFeat = nullptr;
m_otherFeat = nullptr;
if (!tiles.empty()) {
TechDraw::DrawTileWeld* tempTile = tiles.at(0);
if (tempTile->TileRow.getValue() == 0) {
m_arrowFeat = tempTile;
} else {
m_otherFeat = tempTile;
}
}
if (tiles.size() > 1) {
TechDraw::DrawTileWeld* tempTile = tiles.at(1);
if (tempTile->TileRow.getValue() == 0) {
m_arrowFeat = tempTile;
} else {
m_otherFeat = tempTile;
}
}
}
void QGIWeldSymbol::removeQGITiles(void)
{
std::vector<QGITile*> tiles = getQGITiles();
for (auto t: tiles) {
QList<QGraphicsItem*> tChildren = t->childItems();
for (auto tc: tChildren) {
t->removeFromGroup(tc);
scene()->removeItem(tc);
//tc gets deleted when QGIWS gets deleted
}
removeFromGroup(t);
scene()->removeItem(t);
delete t;
}
}
std::vector<QGITile*> QGIWeldSymbol::getQGITiles(void)
{
std::vector<QGITile*> result;
QList<QGraphicsItem*> children = childItems();
for (auto& c:children) {
QGITile* tile = dynamic_cast<QGITile*>(c);
if (tile) {
result.push_back(tile);
}
}
return result;
}
void QGIWeldSymbol::hoverEnterEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
if (isSelected()) {
m_colCurrent = getSelectColor();
setPrettySel();
} else {
m_colCurrent = getPreColor();
setPrettyPre();
}
QGIView::hoverEnterEvent(event);
}
void QGIWeldSymbol::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)
{
Q_UNUSED(event);
if(isSelected()) {
m_colCurrent = getSelectColor();
setPrettySel();
} else {
m_colCurrent = m_colNormal;
setPrettyNormal();
}
QGIView::hoverLeaveEvent(event);
}
void QGIWeldSymbol::drawBorder()
{
////Weld Symbols have no border!
// QGIView::drawBorder(); //good for debugging
}
void QGIWeldSymbol::setPrettyNormal()
{
std::vector<QGITile*> tiles = getQGITiles();
for (auto t: tiles) {
t->setColor(m_colNormal);
t->draw();
}
m_colCurrent = m_colNormal;
m_fieldFlag->setNormalColor(m_colCurrent);
m_fieldFlag->setFillColor(m_colCurrent);
m_fieldFlag->setPrettyNormal();
m_allAround->setNormalColor(m_colCurrent);
m_allAround->setPrettyNormal();
m_tailText->setColor(m_colCurrent);
m_tailText->setPrettyNormal();
}
void QGIWeldSymbol::setPrettyPre()
{
std::vector<QGITile*> tiles = getQGITiles();
for (auto t: tiles) {
t->setColor(getPreColor());
t->draw();
}
m_colCurrent = getPreColor();
m_fieldFlag->setNormalColor(getPreColor());
m_fieldFlag->setFillColor(getPreColor());
m_fieldFlag->setPrettyPre();
m_allAround->setNormalColor(getPreColor());
m_allAround->setPrettyPre();
m_tailText->setColor(getPreColor());
m_tailText->setPrettyPre();
}
void QGIWeldSymbol::setPrettySel()
{
std::vector<QGITile*> tiles = getQGITiles();
for (auto t: tiles) {
t->setColor(getSelectColor());
t->draw();
}
m_colCurrent = getSelectColor();
m_fieldFlag->setNormalColor(getSelectColor());
m_fieldFlag->setFillColor(getSelectColor());
m_fieldFlag->setPrettySel();
m_allAround->setNormalColor(getSelectColor());
m_allAround->setPrettySel();
m_tailText->setColor(getSelectColor());
m_tailText->setPrettySel();
}
QPointF QGIWeldSymbol::getTileOrigin(void)
{
Base::Vector3d org = m_leadFeat->getTileOrigin();
QPointF result(org.x, org.y);
return result;
}
QPointF QGIWeldSymbol::getKinkPoint(void)
{
Base::Vector3d org = m_leadFeat->getKinkPoint();
QPointF result(org.x, org.y);
return result;
}
QPointF QGIWeldSymbol::getTailPoint(void)
{
Base::Vector3d org = m_leadFeat->getTailPoint();
QPointF result(org.x, org.y);
return result;
}
void QGIWeldSymbol::setFeature(TechDraw::DrawWeldSymbol* feat)
{
// Base::Console().Message("QGIWS::setFeature(%s)\n", feat->getNameInDocument());
m_weldFeat = feat;
m_weldFeatName = feat->getNameInDocument();
}
TechDraw::DrawWeldSymbol* QGIWeldSymbol::getFeature(void)
{
return m_weldFeat;
}
//preference
QColor QGIWeldSymbol::prefNormalColor()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()
.GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/LeaderLines");
App::Color fcColor;
fcColor.setPackedValue(hGrp->GetUnsigned("Color", 0x00000000));
m_colNormal = fcColor.asValue<QColor>();
return m_colNormal;
}
double QGIWeldSymbol::prefArrowSize()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().
GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions");
double size = Rez::guiX(hGrp->GetFloat("ArrowSize", 3.5));
return size;
}
QRectF QGIWeldSymbol::boundingRect() const
{
return childrenBoundingRect();
}
QPainterPath QGIWeldSymbol::shape() const
{
return QGraphicsItemGroup::shape();
}
void QGIWeldSymbol::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) {
QStyleOptionGraphicsItem myOption(*option);
myOption.state &= ~QStyle::State_Selected;
// painter->setPen(Qt::red);
// painter->drawRect(boundingRect()); //good for debugging
QGIView::paint (painter, &myOption, widget);
}
#include <Mod/TechDraw/Gui/moc_QGIWeldSymbol.cpp>

View File

@@ -0,0 +1,133 @@
/***************************************************************************
* Copyright (c) 2019 WandererFan <wandererfan@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef DRAWINGGUI_QGRAPHICSITEMWELDSYMBOL_H
#define DRAWINGGUI_QGRAPHICSITEMWELDSYMBOL_H
#include <QObject>
#include <QGraphicsView>
#include <QStyleOptionGraphicsItem>
#include <QGraphicsItem>
#include <QGraphicsObject>
#include <QPainterPath>
#include <QColor>
#include <QFont>
#include <QPointF>
#include <Base/Vector3D.h>
#include "QGIView.h"
namespace App {
class Document;
}
namespace TechDraw {
class DrawWeldSymbol;
class DrawTileWeld;
class DrawView;
}
namespace TechDrawGui
{
class QGIPrimPath;
class QGITile;
class QGIVertex;
class QGCustomText;
class QGILeaderLine;
//*******************************************************************
class TechDrawGuiExport QGIWeldSymbol : public QGIView
{
Q_OBJECT
public:
enum {Type = QGraphicsItem::UserType + 340};
explicit QGIWeldSymbol(QGILeaderLine* myParent = nullptr);
~QGIWeldSymbol() = default;
int type() const override { return Type;}
virtual void paint( QPainter * painter,
const QStyleOptionGraphicsItem * option,
QWidget * widget = 0 ) override;
virtual QRectF boundingRect() const override;
virtual QPainterPath shape(void) const override;
double getEdgeFuzz(void) const;
virtual void drawBorder() override;
virtual void updateView(bool update = false) override;
virtual TechDraw::DrawWeldSymbol* getFeature(void);
virtual void setFeature(TechDraw::DrawWeldSymbol* feat);
QPointF getTileOrigin(void);
QPointF getKinkPoint(void);
QPointF getTailPoint(void);
virtual void setPrettyNormal();
virtual void setPrettySel();
virtual void setPrettyPre();
void getTileFeats(void);
protected:
virtual QVariant itemChange( GraphicsItemChange change,
const QVariant &value ) override;
virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override;
virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override;
virtual void draw() override;
void drawTile(TechDraw::DrawTileWeld* tileFeat);
void drawAllAround(void);
void drawTailText(void);
void drawFieldFlag();
protected:
void removeQGITiles(void);
std::vector<QGITile*> getQGITiles(void);
virtual QColor prefNormalColor();
double prefArrowSize();
TechDraw::DrawWeldSymbol* m_weldFeat;
TechDraw::DrawLeaderLine* m_leadFeat;
TechDraw::DrawTileWeld* m_arrowFeat;
TechDraw::DrawTileWeld* m_otherFeat;
std::string m_arrowName;
std::string m_otherName;
QGILeaderLine* m_qgLead;
QGCustomText* m_tailText;
QGIPrimPath* m_fieldFlag;
QGIVertex* m_allAround;
QFont m_font;
bool m_blockDraw; //prevent redraws while updating.
std::string m_weldFeatName;
};
}
#endif // DRAWINGGUI_QGRAPHICSITEMWELDSYMBOL_H

View File

@@ -75,6 +75,9 @@
#include <Mod/TechDraw/App/DrawViewImage.h>
#include <Mod/TechDraw/App/DrawLeaderLine.h>
#include <Mod/TechDraw/App/DrawRichAnno.h>
#include <Mod/TechDraw/App/DrawWeldSymbol.h>
#include <Mod/TechDraw/App/DrawTile.h>
#include <Mod/TechDraw/App/DrawTileWeld.h>
#include <Mod/TechDraw/App/QDomNodeModel.h>
#include "Rez.h"
@@ -96,6 +99,8 @@
#include "QGIFace.h"
#include "QGILeaderLine.h"
#include "QGIRichAnno.h"
#include "QGIWeldSymbol.h"
#include "QGITile.h"
#include "ZVALUE.h"
#include "ViewProviderPage.h"
@@ -112,8 +117,6 @@ QGVPage::QGVPage(ViewProviderPage *vp, QGraphicsScene* s, QWidget *parent)
m_renderer(Native),
drawBkg(true),
m_vpPage(0)
// ,
// m_borderState(true)
{
assert(vp);
m_vpPage = vp;
@@ -545,6 +548,36 @@ QGIView * QGVPage::addRichAnno(TechDraw::DrawRichAnno* anno)
return annoGroup;
}
QGIView * QGVPage::addWeldSymbol(TechDraw::DrawWeldSymbol* weld)
{
// Base::Console().Message("QGVP::addWeldSymbol()\n");
QGIWeldSymbol* weldGroup = nullptr;
TechDraw::DrawView* parentDV = nullptr;
App::DocumentObject* parentObj = weld->Leader.getValue();
if (parentObj != nullptr) {
parentDV = dynamic_cast<TechDraw::DrawView*>(parentObj);
} else {
// Base::Console().Message("QGVP::addWeldSymbol - no parent doc obj\n");
}
if (parentDV != nullptr) {
QGIView* parentQV = findQViewForDocObj(parentObj);
QGILeaderLine* leadParent = dynamic_cast<QGILeaderLine*>(parentQV);
if (leadParent != nullptr) {
weldGroup = new QGIWeldSymbol(leadParent);
weldGroup->setFeature(weld); //for QGIWS
weldGroup->setViewFeature(weld); //for QGIV
weldGroup->updateView(true);
} else {
Base::Console().Error("QGVP::addWeldSymbol - no parent QGILL\n");
}
} else {
Base::Console().Error("QGVP::addWeldSymbol - parent is not DV!\n");
}
return weldGroup;
}
//! find the graphic for a DocumentObject
QGIView * QGVPage::findQViewForDocObj(App::DocumentObject *obj) const
{
@@ -705,8 +738,16 @@ void QGVPage::refreshViews(void)
{
// Base::Console().Message("QGVP::refreshViews()\n");
QList<QGraphicsItem*> list = scene()->items();
for (QList<QGraphicsItem*>::iterator it = list.begin(); it != list.end(); ++it) {
QGIView *itemView = dynamic_cast<QGIView *>(*it);
QList<QGraphicsItem*> qgiv;
//find only QGIV's
for (auto q: list) {
QString tileFamily = QString::fromUtf8("QGIV");
if (tileFamily == q->data(0).toString()) {
qgiv.push_back(q);
}
}
for (auto q: qgiv) {
QGIView *itemView = dynamic_cast<QGIView *>(q);
if(itemView) {
itemView->updateView(true);
}

View File

@@ -45,6 +45,7 @@ class DrawViewImage;
class DrawLeaderLine;
class DrawViewBalloon;
class DrawRichAnno;
class DrawWeldSymbol;
}
namespace TechDrawGui
@@ -56,6 +57,7 @@ class ViewProviderPage;
class QGIViewBalloon;
class QGILeaderLine;
class QGIRichAnno;
class QGITile;
class TechDrawGuiExport QGVPage : public QGraphicsView
{
@@ -84,6 +86,7 @@ public:
QGIView * addDrawViewImage(TechDraw::DrawViewImage *view);
QGIView * addViewLeader(TechDraw::DrawLeaderLine* view);
QGIView * addRichAnno(TechDraw::DrawRichAnno* anno);
QGIView * addWeldSymbol(TechDraw::DrawWeldSymbol* weld);
QGIView* findQViewForDocObj(App::DocumentObject *obj) const;
QGIView* getQGIVByName(std::string name);
@@ -93,7 +96,6 @@ public:
void addDimToParent(QGIViewDimension* dim, QGIView* parent);
void addLeaderToParent(QGILeaderLine* lead, QGIView* parent);
// const std::vector<QGIView *> & getViews() const { return views; } //only used in MDIVP
std::vector<QGIView *> getViews() const;
int addQView(QGIView * view);
@@ -101,7 +103,6 @@ public:
int removeQViewByName(const char* name);
void removeQViewFromScene(QGIView *view);
//void setViews(const std::vector<QGIView *> &view) {views = view; }
void setPageTemplate(TechDraw::DrawTemplate *pageTemplate);
QGITemplate * getTemplate() const;
@@ -117,8 +118,6 @@ public:
void saveSvg(QString filename);
void postProcessXml(QTemporaryFile& tempFile, QString filename, QString pagename);
/* int balloonIndex;*/
public Q_SLOTS:
void setHighQualityAntialiasing(bool highQualityAntialiasing);
@@ -154,7 +153,6 @@ private:
double m_zoomIncrement;
int m_reversePan;
int m_reverseScroll;
/* bool m_borderState;*/
QLabel *balloonCursor;
QPoint balloonCursorPos;
void cancelBalloonPlacing(void);

View File

@@ -73,6 +73,8 @@
<file>icons/actions/techdraw-linedecor.svg</file>
<file>icons/actions/techdraw-facedecor.svg</file>
<file>icons/actions/techdraw-showall.svg</file>
<file>icons/actions/techdraw-weldsymbol.svg</file>
<file>icons/actions/techdraw-tile.svg</file>
<file>icons/actions/section-up.svg</file>
<file>icons/actions/section-down.svg</file>
<file>icons/actions/section-left.svg</file>

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 5.2 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 5.3 KiB

View File

@@ -0,0 +1,158 @@
/***************************************************************************
* Copyright (c) 2019 Wandererfan <wandererfan@gmail.com *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#endif
#include <App/Application.h>
#include <Gui/FileDialog.h>
#include "DrawGuiStd.h"
#include "Rez.h"
#include <Mod/TechDraw/Gui/ui_SymbolChooser.h>
#include "SymbolChooser.h"
using namespace Gui;
using namespace TechDraw;
using namespace TechDrawGui;
SymbolChooser::SymbolChooser(QWidget *parent,
QString startDir,
QString source) :
QDialog(parent),
ui(new Ui_SymbolChooser),
m_symbolDir(startDir),
m_source(source)
{
ui->setupUi(this);
connect(ui->pbOK, SIGNAL(clicked(bool)),
this, SLOT(onOKClicked(bool)));
connect(ui->pbCancel, SIGNAL(clicked(bool)),
this, SLOT(onCancelClicked(bool)));
connect(ui->fcSymbolDir, SIGNAL(fileNameSelected(const QString&)),
this, SLOT(onDirectorySelected(const QString&)));
connect(ui->lwSymbols, SIGNAL(itemClicked(QListWidgetItem*)), //double click?
this, SLOT(onItemClicked(QListWidgetItem*)));
setUiPrimary();
}
void SymbolChooser::setUiPrimary()
{
// Base::Console().Message("SC::setUiPrimary()\n");
setWindowTitle(QObject::tr("Select a symbol"));
if (!m_symbolDir.isEmpty()) {
ui->fcSymbolDir->setFileName(m_symbolDir);
loadSymbolNames(m_symbolDir);
} else {
std::string resourceDir = App::Application::getResourceDir();
std::string defPath = "Mod/TechDraw/Symbols/Welding/AWS/";
resourceDir = resourceDir + defPath;
QString defDir = QString::fromUtf8(resourceDir.c_str());
ui->fcSymbolDir->setFileName(defDir);
loadSymbolNames(defDir);
m_symbolDir = defDir;
}
ui->lwSymbols->setViewMode(QListView::IconMode);
ui->lwSymbols->setFlow(QListView::LeftToRight);
ui->lwSymbols->setWrapping(true);
ui->lwSymbols->setDragEnabled(true);
ui->lwSymbols->setSelectionMode(QAbstractItemView::SingleSelection);
ui->lwSymbols->setAcceptDrops(false);
}
void SymbolChooser::onOKClicked(bool b)
{
Q_UNUSED(b);
// Base::Console().Message("SC::OnOKClicked()\n");
QListWidgetItem* sourceItem = ui->lwSymbols->currentItem();
QString targetText = sourceItem->text();
m_symbolPath = m_symbolDir +
targetText +
QString::fromUtf8(".svg");
Q_EMIT symbolSelected(m_symbolPath, m_source);
// Base::Console().Message("SC::onOKClicked - symbol; %s\n", qPrintable(m_symbolPath));
accept();
}
void SymbolChooser::onCancelClicked(bool b)
{
Q_UNUSED(b);
// Base::Console().Message("SC::OnCancelCicked()\n");
reject();
}
void SymbolChooser::onItemClicked(QListWidgetItem* item)
{
Q_UNUSED(item);
// Base::Console().Message("SCS::onItemClicked(%s)\n", qPrintable(item->text()));
//are item and currentItem() the same? should use item?
QListWidgetItem* sourceItem = ui->lwSymbols->currentItem();
QString targetText = sourceItem->text();
m_symbolPath = m_symbolDir +
targetText +
QString::fromUtf8(".svg");
Q_EMIT symbolSelected(m_symbolPath, m_source);
// Base::Console().Message("SC::onOKClicked - symbol: %s\n", qPrintable(m_symbolPath));
accept();
}
void SymbolChooser::onDirectorySelected(const QString& newDir)
{
// Base::Console().Message("SC::onDirectorySelected(%s)\n", qPrintable(newDir));
m_symbolDir = newDir + QString::fromUtf8("/");
loadSymbolNames(m_symbolDir);
}
void SymbolChooser::loadSymbolNames(QString pathToSymbols)
{
//fill selection list with names and icons
QDir symbolDir(pathToSymbols);
symbolDir.setFilter(QDir::Files);
QStringList fileNames = symbolDir.entryList();
for (auto& fn: fileNames) {
QListWidgetItem* item = new QListWidgetItem(fn, ui->lwSymbols);
QFileInfo fi(fn);
item->setText(fi.baseName());
QIcon symbolIcon(pathToSymbols + fn);
item->setIcon(symbolIcon);
ui->lwSymbols->addItem(item);
}
ui->lwSymbols->setCurrentRow(0);
ui->lwSymbols->setAcceptDrops(false); //have to do this every time you update the items
}
//QString SymbolChooser::getSymbolPath(void)
//{
// Base::Console().Message("SC::getSymbolPath returns: %s\n", qPrintable(m_symbolPath));
// return m_symbolPath;
//}
#include <Mod/TechDraw/Gui/moc_SymbolChooser.cpp>

View File

@@ -0,0 +1,65 @@
/***************************************************************************
* Copyright (c) 2019 Wandererfan <wandererfan@gmail.com *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef TECHDRAWGUI_SYMBOLCHOOSER_H
#define TECHDRAWGUI_SYMBOLCHOOSER_H
#include <QPushButton>
#include <QDialog>
#include <QListWidget>
#include <Mod/TechDraw/Gui/ui_SymbolChooser.h>
namespace TechDrawGui {
class TechDrawGuiExport SymbolChooser : public QDialog
{
Q_OBJECT
public:
SymbolChooser(QWidget *parent = 0,
QString startDir = QString(),
QString source = QString());
public Q_SLOTS:
void onOKClicked(bool b);
void onCancelClicked(bool b);
void onItemClicked(QListWidgetItem* item);
void onDirectorySelected(const QString& newDir);
Q_SIGNALS:
void symbolSelected(QString symbolPath,
QString source);
protected:
void setUiPrimary(void);
void loadSymbolNames(QString pathToSymbols);
private:
Ui_SymbolChooser* ui;
QString m_symbolDir;
QString m_symbolPath;
QString m_source;
};
}
#endif // #ifndef TECHDRAWGUI_SYMBOLCHOOSER_H

View File

@@ -0,0 +1,124 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SymbolChooser</class>
<widget class="QDialog" name="SymbolChooser">
<property name="windowModality">
<enum>Qt::WindowModal</enum>
</property>
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>394</height>
</rect>
</property>
<property name="windowTitle">
<string>SymbolChooser</string>
</property>
<property name="modal">
<bool>true</bool>
</property>
<widget class="QFrame" name="frame">
<property name="geometry">
<rect>
<x>19</x>
<y>19</y>
<width>361</width>
<height>341</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::StyledPanel</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<property name="lineWidth">
<number>2</number>
</property>
<widget class="QWidget" name="verticalLayoutWidget">
<property name="geometry">
<rect>
<x>9</x>
<y>19</y>
<width>341</width>
<height>191</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QListWidget" name="lwSymbols"/>
</item>
</layout>
</widget>
<widget class="QWidget" name="horizontalLayoutWidget">
<property name="geometry">
<rect>
<x>10</x>
<y>220</y>
<width>341</width>
<height>41</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="pbCancel">
<property name="text">
<string>Cancel</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="pbOK">
<property name="text">
<string>OK</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="horizontalLayoutWidget_2">
<property name="geometry">
<rect>
<x>10</x>
<y>280</y>
<width>341</width>
<height>35</height>
</rect>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QLabel" name="label">
<property name="text">
<string>Symbol Dir</string>
</property>
</widget>
</item>
<item>
<widget class="Gui::FileChooser" name="fcSymbolDir">
<property name="mode">
<enum>Gui::FileChooser::Directory</enum>
</property>
</widget>
</item>
</layout>
</widget>
</widget>
</widget>
<customwidgets>
<customwidget>
<class>Gui::FileChooser</class>
<extends>QWidget</extends>
<header>Gui/FileDialog.h</header>
</customwidget>
</customwidgets>
<resources/>
<connections/>
</ui>

View File

@@ -123,6 +123,7 @@ TaskLeaderLine::TaskLeaderLine(TechDrawGui::ViewProviderLeader* leadVP) :
saveState();
m_trackerMode = QGTracker::TrackerMode::Line;
m_saveContextPolicy = m_mdi->contextMenuPolicy();
}
//ctor for creation
@@ -165,6 +166,8 @@ TaskLeaderLine::TaskLeaderLine(TechDraw::DrawView* baseFeat,
ui->pbCancelEdit->setEnabled(false);
m_trackerMode = QGTracker::TrackerMode::Line;
m_saveContextPolicy = m_mdi->contextMenuPolicy();
}
TaskLeaderLine::~TaskLeaderLine()
@@ -648,12 +651,12 @@ bool TaskLeaderLine::accept()
// removeTracker();
createLeaderFeature(m_trackerPoints);
}
m_mdi->setContextMenuPolicy(m_saveContextPolicy);
m_trackerMode = QGTracker::TrackerMode::None;
removeTracker();
Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()");
m_mdi->setContextMenuPolicy(m_saveContextPolicy);
return true;
}
@@ -670,9 +673,6 @@ bool TaskLeaderLine::reject()
Gui::Document* doc = Gui::Application::Instance->getDocument(m_basePage->getDocument());
if (!doc) return false;
if (m_mdi != nullptr) {
m_mdi->setContextMenuPolicy(m_saveContextPolicy);
}
if (getCreateMode() &&
(m_lineFeat != nullptr) ) {
removeFeature();
@@ -690,6 +690,10 @@ bool TaskLeaderLine::reject()
Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().recompute()");
Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()");
if (m_mdi != nullptr) {
m_mdi->setContextMenuPolicy(m_saveContextPolicy);
}
return false;
}

View File

@@ -0,0 +1,785 @@
/***************************************************************************
* Copyright (c) 2019 Wandererfan <wandererfan@gmail.com *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#include <cmath>
#include <BRepBndLib.hxx>
#include <Bnd_Box.hxx>
#endif // #ifndef _PreComp_
#include <QApplication>
#include <QStatusBar>
#include <QGraphicsScene>
#include <Base/Console.h>
#include <Base/Tools.h>
#include <Base/UnitsApi.h>
#include <Gui/Application.h>
#include <Gui/BitmapFactory.h>
#include <Gui/Command.h>
#include <Gui/Control.h>
#include <Gui/Document.h>
#include <Gui/MainWindow.h>
#include <Gui/Selection.h>
#include <Gui/ViewProvider.h>
#include <Gui/WaitCursor.h>
#include <Mod/TechDraw/App/DrawPage.h>
#include <Mod/TechDraw/App/DrawUtil.h>
#include <Mod/TechDraw/App/DrawView.h>
#include <Mod/TechDraw/App/DrawViewPart.h>
#include <Mod/TechDraw/App/DrawLeaderLine.h>
#include <Mod/TechDraw/App/DrawWeldSymbol.h>
#include <Mod/TechDraw/App/DrawTile.h>
#include <Mod/TechDraw/App/DrawTileWeld.h>
#include <Mod/TechDraw/App/Geometry.h>
#include <Mod/TechDraw/App/Cosmetic.h>
#include <Mod/TechDraw/Gui/ui_TaskWeldingSymbol.h>
#include "DrawGuiStd.h"
#include "QGVPage.h"
#include "QGIView.h"
#include "QGIPrimPath.h"
#include "QGILeaderLine.h"
#include "MDIViewPage.h"
#include "ViewProviderPage.h"
#include "ViewProviderViewPart.h"
#include "SymbolChooser.h"
#include "Rez.h"
#include "TaskWeldingSymbol.h"
using namespace Gui;
using namespace TechDraw;
using namespace TechDrawGui;
//ctor for creation
TaskWeldingSymbol::TaskWeldingSymbol(TechDraw::DrawLeaderLine* leader) :
ui(new Ui_TaskWeldingSymbol),
m_leadFeat(leader),
m_weldFeat(nullptr),
m_arrowIn(nullptr),
m_otherIn(nullptr),
m_createMode(true),
m_arrowDirty(false),
m_otherDirty(false)
{
// Base::Console().Message("TWS::TWS() - create mode\n");
if (m_leadFeat == nullptr) {
//should be caught in CMD caller
Base::Console().Error("TaskWeldingSymbol - bad parameters. Can not proceed.\n");
return;
}
ui->setupUi(this);
connect(ui->pbArrowSymbol, SIGNAL(clicked(bool)),
this, SLOT(onArrowSymbolClicked(bool)));
connect(ui->pbOtherSymbol, SIGNAL(clicked(bool)),
this, SLOT(onOtherSymbolClicked(bool)));
connect(ui->pbOtherErase, SIGNAL(clicked(bool)),
this, SLOT(onOtherEraseClicked(bool)));
connect(ui->fcSymbolDir, SIGNAL(fileNameSelected(const QString&)),
this, SLOT(onDirectorySelected(const QString&)));
connect(ui->leArrowTextL, SIGNAL(textEdited(const QString&)),
this, SLOT(onArrowTextChanged(const QString&)));
connect(ui->leArrowTextR, SIGNAL(textEdited(const QString&)),
this, SLOT(onArrowTextChanged(const QString&)));
connect(ui->leArrowTextC, SIGNAL(textEdited(const QString&)),
this, SLOT(onArrowTextChanged(const QString&)));
connect(ui->leOtherTextL, SIGNAL(textEdited(const QString&)),
this, SLOT(onOtherTextChanged(const QString&)));
connect(ui->leOtherTextR, SIGNAL(textEdited(const QString&)),
this, SLOT(onOtherTextChanged(const QString&)));
connect(ui->leOtherTextC, SIGNAL(textEdited(const QString&)),
this, SLOT(onOtherTextChanged(const QString&)));
setUiPrimary();
}
//ctor for edit
TaskWeldingSymbol::TaskWeldingSymbol(TechDraw::DrawWeldSymbol* weld) :
ui(new Ui_TaskWeldingSymbol),
m_leadFeat(nullptr),
m_weldFeat(weld),
m_arrowIn(nullptr),
m_otherIn(nullptr),
m_createMode(false),
m_arrowDirty(false),
m_otherDirty(false)
{
// Base::Console().Message("TWS::TWS() - edit mode\n");
if (m_weldFeat == nullptr) {
//should be caught in CMD caller
Base::Console().Error("TaskWeldingSymbol - bad parameters. Can not proceed.\n");
return;
}
App::DocumentObject* obj = m_weldFeat->Leader.getValue();
if ( (obj != nullptr) &&
(obj->isDerivedFrom(TechDraw::DrawLeaderLine::getClassTypeId())) ) {
m_leadFeat = static_cast<TechDraw::DrawLeaderLine*>(obj);
} else {
Base::Console().Error("TaskWeldingSymbol - no leader for welding symbol. Can not proceed.\n");
return;
}
ui->setupUi(this);
connect(ui->pbArrowSymbol, SIGNAL(clicked(bool)),
this, SLOT(onArrowSymbolClicked(bool)));
connect(ui->pbOtherSymbol, SIGNAL(clicked(bool)),
this, SLOT(onOtherSymbolClicked(bool)));
connect(ui->pbOtherErase, SIGNAL(clicked(bool)),
this, SLOT(onOtherEraseClicked(bool)));
connect(ui->fcSymbolDir, SIGNAL(fileNameSelected(const QString&)),
this, SLOT(onDirectorySelected(const QString&)));
connect(ui->leArrowTextL, SIGNAL(textEdited(const QString&)),
this, SLOT(onArrowTextChanged(const QString&)));
connect(ui->leArrowTextR, SIGNAL(textEdited(const QString&)),
this, SLOT(onArrowTextChanged(const QString&)));
connect(ui->leArrowTextC, SIGNAL(textEdited(const QString&)),
this, SLOT(onArrowTextChanged(const QString&)));
connect(ui->leOtherTextL, SIGNAL(textEdited(const QString&)),
this, SLOT(onOtherTextChanged(const QString&)));
connect(ui->leOtherTextR, SIGNAL(textEdited(const QString&)),
this, SLOT(onOtherTextChanged(const QString&)));
connect(ui->leOtherTextC, SIGNAL(textEdited(const QString&)),
this, SLOT(onOtherTextChanged(const QString&)));
saveState();
setUiEdit();
}
TaskWeldingSymbol::~TaskWeldingSymbol()
{
delete ui;
}
void TaskWeldingSymbol::updateTask()
{
// blockUpdate = true;
// blockUpdate = false;
}
void TaskWeldingSymbol::changeEvent(QEvent *e)
{
if (e->type() == QEvent::LanguageChange) {
ui->retranslateUi(this);
}
}
void TaskWeldingSymbol::setUiPrimary()
{
// Base::Console().Message("TWS::setUiPrimary()\n");
setWindowTitle(QObject::tr("Create Welding Symbol"));
m_currDir = QString::fromUtf8(prefSymbolDir().c_str());
ui->fcSymbolDir->setFileName(m_currDir);
ui->pbArrowSymbol->setFocus();
m_arrowOut.init();
m_arrowPath = QString();
m_otherOut.init();
m_otherPath = QString();
}
void TaskWeldingSymbol::setUiEdit()
{
// Base::Console().Message("TWS::setUiEdit()\n");
setWindowTitle(QObject::tr("Edit Welding Symbol"));
m_currDir = QString::fromUtf8(prefSymbolDir().c_str()); //sb path part of 1st symbol file??
ui->fcSymbolDir->setFileName(m_currDir);
ui->cbAllAround->setChecked(m_weldFeat->AllAround.getValue());
ui->cbFieldWeld->setChecked(m_weldFeat->FieldWeld.getValue());
ui->cbAltWeld->setChecked(m_weldFeat->AlternatingWeld.getValue());
ui->leTailText->setText(QString::fromUtf8(m_weldFeat->TailText.getValue()));
//save existing tiles done in saveState
if (m_arrowIn != nullptr) {
QString qTemp = QString::fromUtf8(m_arrowIn->LeftText.getValue());
ui->leArrowTextL->setText(qTemp);
qTemp = QString::fromUtf8(m_arrowIn->RightText.getValue());
ui->leArrowTextR->setText(qTemp);
qTemp = QString::fromUtf8(m_arrowIn->CenterText.getValue());
ui->leArrowTextC->setText(qTemp);
std::string inFile = m_arrowIn->SymbolFile.getValue();
auto fi = Base::FileInfo(inFile);
if (fi.isReadable()) {
qTemp = QString::fromUtf8(m_arrowIn->SymbolFile.getValue());
QIcon targetIcon(qTemp);
QSize iconSize(32,32);
ui->pbArrowSymbol->setIcon(targetIcon);
ui->pbArrowSymbol->setIconSize(iconSize);
ui->pbArrowSymbol->setText(QString());
}
}
if (m_otherIn != nullptr) {
QString qTemp = QString::fromUtf8(m_otherIn->LeftText.getValue());
ui->leOtherTextL->setText(qTemp);
qTemp = QString::fromUtf8(m_otherIn->RightText.getValue());
ui->leOtherTextR->setText(qTemp);
qTemp = QString::fromUtf8(m_otherIn->CenterText.getValue());
ui->leOtherTextC->setText(qTemp);
std::string inFile = m_otherIn->SymbolFile.getValue();
auto fi = Base::FileInfo(inFile);
if (fi.isReadable()) {
qTemp = QString::fromUtf8(m_otherIn->SymbolFile.getValue());
QIcon targetIcon(qTemp);
QSize iconSize(32,32);
ui->pbOtherSymbol->setIcon(targetIcon);
ui->pbOtherSymbol->setIconSize(iconSize);
ui->pbOtherSymbol->setText(QString());
}
}
ui->pbArrowSymbol->setFocus();
}
void TaskWeldingSymbol::onArrowSymbolClicked(bool b)
{
// Base::Console().Message("TWS::OnArrowSymbolClicked()\n");
Q_UNUSED(b);
QString source = QString::fromUtf8("arrow");
SymbolChooser* dlg = new SymbolChooser(this, m_currDir, source);
connect(dlg, SIGNAL(symbolSelected(QString, QString)),
this, SLOT(onSymbolSelected(QString, QString)));
dlg->setAttribute(Qt::WA_DeleteOnClose);
//int rc =
dlg->exec();
}
void TaskWeldingSymbol::onOtherSymbolClicked(bool b)
{
// Base::Console().Message("TWS::OnOtherSymbolClicked()\n");
Q_UNUSED(b);
QString source = QString::fromUtf8("other");
SymbolChooser* dlg = new SymbolChooser(this, m_currDir, source);
connect(dlg, SIGNAL(symbolSelected(QString, QString)),
this, SLOT(onSymbolSelected(QString, QString)));
dlg->setAttribute(Qt::WA_DeleteOnClose);
// int rc =
dlg->exec();
}
void TaskWeldingSymbol::onOtherEraseClicked(bool b)
{
// Base::Console().Message("TWS::onOtherEraseClicked()\n");
Q_UNUSED(b);
m_otherOut.init();
ui->leOtherTextL->setText(QString());
ui->leOtherTextC->setText(QString());
ui->leOtherTextR->setText(QString());
ui->pbOtherSymbol->setIcon(QIcon());
ui->pbOtherSymbol->setText(QString::fromUtf8("Symbol"));
if ( (!m_createMode) &&
(m_otherIn != nullptr) ) {
m_toRemove.push_back(m_otherIn->getNameInDocument());
}
m_otherIn = nullptr;
}
void TaskWeldingSymbol::onArrowTextChanged(const QString& qs)
{
// Base::Console().Message("TWS::onArrowTextChanged(%s)\n", qPrintable(qs));
Q_UNUSED(qs);
m_arrowDirty = true;
}
void TaskWeldingSymbol::onOtherTextChanged(const QString& qs)
{
// Base::Console().Message("TWS::onOtherTextChanged(%s)\n", qPrintable(qs));
Q_UNUSED(qs);
m_otherDirty = true;
}
void TaskWeldingSymbol::onDirectorySelected(const QString& newDir)
{
// Base::Console().Message("TWS::onDirectorySelected(%s)\n", qPrintable(newDir));
m_currDir = newDir + QString::fromUtf8("/");
}
void TaskWeldingSymbol::onSymbolSelected(QString symbolPath,
QString source)
{
// Base::Console().Message("TWS::onSymbolSelected(%s) - source: %s\n",
// qPrintable(symbolPath), qPrintable(source));
QIcon targetIcon(symbolPath);
QSize iconSize(32,32);
QString arrow = QString::fromUtf8("arrow");
QString other = QString::fromUtf8("other");
if (source == arrow) {
m_arrowDirty = true;
ui->pbArrowSymbol->setIcon(targetIcon);
ui->pbArrowSymbol->setIconSize(iconSize);
ui->pbArrowSymbol->setText(QString());
m_arrowPath = symbolPath;
} else if (source == other) {
m_otherDirty = true;
ui->pbOtherSymbol->setIcon(targetIcon);
ui->pbOtherSymbol->setIconSize(iconSize);
ui->pbOtherSymbol->setText(QString());
m_otherPath = symbolPath;
}
}
void TaskWeldingSymbol::blockButtons(bool b)
{
Q_UNUSED(b);
}
void TaskWeldingSymbol::saveState(void)
{
std::vector<DrawTileWeld*> tiles = m_weldFeat->getTiles();
for (auto t: tiles) {
if (t->TileRow.getValue() == 0) {
m_arrowIn = t;
} else if (t->TileRow.getValue() == -1) {
m_otherIn = t;
} else {
Base::Console().Message("TWS::saveState - bad row: %d\n", t->TileRow.getValue());
}
}
}
void TaskWeldingSymbol::collectArrowData(void)
{
// Base::Console().Message("TWS::collectArrowData()\n");
m_arrowOut.toBeSaved = true;
m_arrowOut.arrowSide = false;
m_arrowOut.row = 0;
m_arrowOut.col = 0;
m_arrowOut.leftText = Base::Tools::toStdString(ui->leArrowTextL->text());
m_arrowOut.centerText = Base::Tools::toStdString(ui->leArrowTextC->text());
m_arrowOut.rightText = Base::Tools::toStdString(ui->leArrowTextR->text());
m_arrowOut.symbolPath= Base::Tools::toStdString(m_arrowPath);
m_arrowOut.tileName = "";
}
void TaskWeldingSymbol::collectOtherData(void)
{
// Base::Console().Message("TWS::collectOtherData()\n");
m_otherOut.toBeSaved = true;
m_otherOut.arrowSide = false;
m_otherOut.row = -1;
m_otherOut.col = 0;
m_otherOut.leftText = Base::Tools::toStdString(ui->leOtherTextL->text());
m_otherOut.centerText = Base::Tools::toStdString(ui->leOtherTextC->text());
m_otherOut.rightText = Base::Tools::toStdString(ui->leOtherTextR->text());
m_otherOut.symbolPath= Base::Tools::toStdString(m_otherPath);
m_otherOut.tileName = "";
}
//******************************************************************************
TechDraw::DrawWeldSymbol* TaskWeldingSymbol::createWeldingSymbol(void)
{
// Base::Console().Message("TWS::createWeldingSymbol()\n");
std::string symbolName = m_leadFeat->getDocument()->getUniqueObjectName("DrawWeldSymbol");
std::string symbolType = "TechDraw::DrawWeldSymbol";
TechDraw::DrawPage* page = m_leadFeat->findParentPage();
std::string pageName = page->getNameInDocument();
Command::doCommand(Command::Doc,"App.activeDocument().addObject('%s','%s')",
symbolType.c_str(),symbolName.c_str());
Command::doCommand(Command::Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",
pageName.c_str(), symbolName.c_str());
Command::doCommand(Command::Doc,"App.activeDocument().%s.Leader = App.activeDocument().%s",
symbolName.c_str(),m_leadFeat->getNameInDocument());
bool allAround = ui->cbAllAround->isChecked();
std::string allAroundText = allAround ? "True" : "False";
Command::doCommand(Command::Doc,"App.activeDocument().%s.AllAround = %s",
symbolName.c_str(), allAroundText.c_str());
bool fieldWeld = ui->cbFieldWeld->isChecked();
std::string fieldWeldText = fieldWeld ? "True" : "False";
Command::doCommand(Command::Doc,"App.activeDocument().%s.FieldWeld = %s",
symbolName.c_str(), fieldWeldText.c_str());
bool altWeld = ui->cbAltWeld->isChecked();
std::string altWeldText = altWeld ? "True" : "False";
Command::doCommand(Command::Doc,"App.activeDocument().%s.AlternatingWeld = %s",
symbolName.c_str(), altWeldText.c_str());
std::string tailText = Base::Tools::toStdString(ui->leTailText->text());
Command::doCommand(Command::Doc,"App.activeDocument().%s.TailText = '%s'",
symbolName.c_str(), tailText.c_str());
App::DocumentObject* newObj = m_leadFeat->getDocument()->getObject(symbolName.c_str());
TechDraw::DrawWeldSymbol* newSym = dynamic_cast<TechDraw::DrawWeldSymbol*>(newObj);
if ( (newObj == nullptr) ||
(newSym == nullptr) ) {
throw Base::RuntimeError("TaskWeldingSymbol - new symbol object not found");
}
return newSym;
}
void TaskWeldingSymbol::updateWeldingSymbol(void)
{
// Base::Console().Message("TWS::updateWeldingSymbol()\n");
std::string symbolName = m_weldFeat->getNameInDocument();
bool allAround = ui->cbAllAround->isChecked();
std::string allAroundText = allAround ? "True" : "False";
Command::doCommand(Command::Doc,"App.activeDocument().%s.AllAround = %s",
symbolName.c_str(), allAroundText.c_str());
bool fieldWeld = ui->cbFieldWeld->isChecked();
std::string fieldWeldText = fieldWeld ? "True" : "False";
Command::doCommand(Command::Doc,"App.activeDocument().%s.FieldWeld = %s",
symbolName.c_str(), fieldWeldText.c_str());
bool altWeld = ui->cbAltWeld->isChecked();
std::string altWeldText = altWeld ? "True" : "False";
Command::doCommand(Command::Doc,"App.activeDocument().%s.AlternatingWeld = %s",
symbolName.c_str(), altWeldText.c_str());
std::string tailText = Base::Tools::toStdString(ui->leTailText->text());
Command::doCommand(Command::Doc,"App.activeDocument().%s.TailText = '%s'",
symbolName.c_str(), tailText.c_str());
}
std::vector<App::DocumentObject*> TaskWeldingSymbol::createTiles(void)
{
// Base::Console().Message("TWS::createTiles()\n");
std::vector<App::DocumentObject*> tileFeats;
std::string tileType("TechDraw::DrawTileWeld");
collectArrowData();
if (m_arrowOut.toBeSaved) {
std::string tileName = m_leadFeat->getDocument()->getUniqueObjectName("DrawTileWeld");
Command::doCommand(Command::Doc,"App.activeDocument().addObject('%s','%s')",
tileType.c_str(),tileName.c_str());
Command::doCommand(Command::Doc,"App.activeDocument().%s.TileRow = %d",
tileName.c_str(), m_arrowOut.row);
Command::doCommand(Command::Doc,"App.activeDocument().%s.TileColumn = %d",
tileName.c_str(), m_arrowOut.col);
Command::doCommand(Command::Doc,"App.activeDocument().%s.SymbolFile = '%s'",
tileName.c_str(), m_arrowOut.symbolPath.c_str());
Command::doCommand(Command::Doc,"App.activeDocument().%s.LeftText = '%s'",
tileName.c_str(), m_arrowOut.leftText.c_str());
Command::doCommand(Command::Doc,"App.activeDocument().%s.RightText = '%s'",
tileName.c_str(), m_arrowOut.rightText.c_str());
Command::doCommand(Command::Doc,"App.activeDocument().%s.CenterText = '%s'",
tileName.c_str(), m_arrowOut.centerText.c_str());
App::DocumentObject* newTile = m_leadFeat->getDocument()->getObject(tileName.c_str());
if (newTile == nullptr) {
throw Base::RuntimeError("TaskWeldingSymbol - new tile object not found");
}
tileFeats.push_back(newTile);
}
if (m_otherDirty) {
collectOtherData();
if (m_otherOut.toBeSaved) {
std::string tileName = m_leadFeat->getDocument()->getUniqueObjectName("DrawTileWeld");
Command::doCommand(Command::Doc,"App.activeDocument().addObject('%s','%s')",
tileType.c_str(),tileName.c_str());
Command::doCommand(Command::Doc,"App.activeDocument().%s.TileRow = %d",
tileName.c_str(), m_otherOut.row);
Command::doCommand(Command::Doc,"App.activeDocument().%s.TileColumn = %d",
tileName.c_str(), m_otherOut.col);
if (m_otherOut.symbolPath.empty()) {
Command::doCommand(Command::Doc,"App.activeDocument().%s.SymbolFile = ''",
tileName.c_str());
} else {
Command::doCommand(Command::Doc,"App.activeDocument().%s.SymbolFile = '%s'",
tileName.c_str(), m_otherOut.symbolPath.c_str());
}
Command::doCommand(Command::Doc,"App.activeDocument().%s.LeftText = '%s'",
tileName.c_str(), m_otherOut.leftText.c_str());
Command::doCommand(Command::Doc,"App.activeDocument().%s.RightText = '%s'",
tileName.c_str(), m_otherOut.rightText.c_str());
Command::doCommand(Command::Doc,"App.activeDocument().%s.CenterText = '%s'",
tileName.c_str(), m_otherOut.centerText.c_str());
App::DocumentObject* newTile = m_leadFeat->getDocument()->getObject(tileName.c_str());
if (newTile == nullptr) {
throw Base::RuntimeError("TaskWeldingSymbol - new tile object not found");
}
tileFeats.push_back(newTile);
}
}
return tileFeats;
}
std::vector<App::DocumentObject*> TaskWeldingSymbol::updateTiles(void)
{
// Base::Console().Message("TWS::updateTiles()\n");
std::vector<App::DocumentObject*> tileFeats;
std::string tileType("TechDraw::DrawTileWeld");
std::string tileName;
collectArrowData();
if (m_arrowIn != nullptr) {
tileName = m_arrowIn->getNameInDocument();
}
if (m_arrowIn == nullptr) { // this should never happen on an update!
tileName = m_leadFeat->getDocument()->getUniqueObjectName("DrawTileWeld");
Command::doCommand(Command::Doc,"App.activeDocument().addObject('%s','%s')",
tileType.c_str(),tileName.c_str());
App::DocumentObject* newTile = m_leadFeat->getDocument()->getObject(tileName.c_str());
if (newTile == nullptr) {
throw Base::RuntimeError("TaskWeldingSymbol - new tile object not found");
}
tileFeats.push_back(newTile);
}
if (m_arrowOut.toBeSaved) {
Command::doCommand(Command::Doc,"App.activeDocument().%s.TileRow = %d",
tileName.c_str(), m_arrowOut.row);
Command::doCommand(Command::Doc,"App.activeDocument().%s.TileColumn = %d",
tileName.c_str(), m_arrowOut.col);
if (m_otherOut.symbolPath.empty()) {
Command::doCommand(Command::Doc,"App.activeDocument().%s.SymbolFile = ''",
tileName.c_str());
} else {
Command::doCommand(Command::Doc,"App.activeDocument().%s.SymbolFile = '%s'",
tileName.c_str(), m_arrowOut.symbolPath.c_str());
}
Command::doCommand(Command::Doc,"App.activeDocument().%s.LeftText = '%s'",
tileName.c_str(), m_arrowOut.leftText.c_str());
Command::doCommand(Command::Doc,"App.activeDocument().%s.RightText = '%s'",
tileName.c_str(), m_arrowOut.rightText.c_str());
Command::doCommand(Command::Doc,"App.activeDocument().%s.CenterText = '%s'",
tileName.c_str(), m_arrowOut.centerText.c_str());
}
if (m_otherDirty) {
collectOtherData();
if (m_otherIn != nullptr) {
tileName = m_otherIn->getNameInDocument();
}
if ( (m_otherIn == nullptr) && //m_otherIn can be nullptr if otherside added in edit session.
(m_otherOut.toBeSaved) ) {
tileName = m_leadFeat->getDocument()->getUniqueObjectName("DrawTileWeld");
Command::doCommand(Command::Doc,"App.activeDocument().addObject('%s','%s')",
tileType.c_str(),tileName.c_str());
App::DocumentObject* newTile = m_leadFeat->getDocument()->getObject(tileName.c_str());
if (newTile == nullptr) {
throw Base::RuntimeError("TaskWeldingSymbol - new tile object not found");
}
tileFeats.push_back(newTile);
}
if (m_otherOut.toBeSaved) {
Command::doCommand(Command::Doc,"App.activeDocument().addObject('%s','%s')",
tileType.c_str(),tileName.c_str());
Command::doCommand(Command::Doc,"App.activeDocument().%s.TileRow = %d",
tileName.c_str(), m_otherOut.row);
Command::doCommand(Command::Doc,"App.activeDocument().%s.TileColumn = %d",
tileName.c_str(), m_otherOut.col);
if (m_otherOut.symbolPath.empty()) {
Command::doCommand(Command::Doc,"App.activeDocument().%s.SymbolFile = ''",
tileName.c_str());
} else {
Command::doCommand(Command::Doc,"App.activeDocument().%s.SymbolFile = '%s'",
tileName.c_str(), m_otherOut.symbolPath.c_str());
}
Command::doCommand(Command::Doc,"App.activeDocument().%s.LeftText = '%s'",
tileName.c_str(), m_otherOut.leftText.c_str());
Command::doCommand(Command::Doc,"App.activeDocument().%s.RightText = '%s'",
tileName.c_str(), m_otherOut.rightText.c_str());
Command::doCommand(Command::Doc,"App.activeDocument().%s.CenterText = '%s'",
tileName.c_str(), m_otherOut.centerText.c_str());
}
}
return tileFeats;
}
void TaskWeldingSymbol::saveButtons(QPushButton* btnOK,
QPushButton* btnCancel)
{
m_btnOK = btnOK;
m_btnCancel = btnCancel;
}
void TaskWeldingSymbol::enableTaskButtons(bool b)
{
m_btnOK->setEnabled(b);
m_btnCancel->setEnabled(b);
}
std::string TaskWeldingSymbol::prefSymbolDir()
{
std::string defaultDir = App::Application::getResourceDir() + "Mod/TechDraw/Symbols/Welding/AWS/";
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")->
GetGroup("Preferences")->GetGroup("Mod/TechDraw/Files");
std::string symbolDir = hGrp->GetASCII("WeldingDir", defaultDir.c_str());
return symbolDir;
}
//******************************************************************************
bool TaskWeldingSymbol::accept()
{
// Base::Console().Message("TWS::accept()\n");
if (m_createMode) {
Gui::Command::openCommand("Create WeldSymbol");
m_weldFeat = createWeldingSymbol();
std::vector<App::DocumentObject*> tileFeats = createTiles();
for (auto& obj: tileFeats) {
TechDraw::DrawTileWeld* tile = dynamic_cast<TechDraw::DrawTileWeld*>(obj);
tile->TileParent.setValue(m_weldFeat);
}
Gui::Command::updateActive();
Gui::Command::commitCommand();
m_weldFeat->recomputeFeature();
// m_weldFeat->requestPaint(); //not a dv!
} else {
Gui::Command::openCommand("Edit WeldSymbol");
try {
updateWeldingSymbol();
std::vector<App::DocumentObject*> tileFeats = updateTiles();
for (auto& obj: tileFeats) { //new tiles only
TechDraw::DrawTileWeld* tile = dynamic_cast<TechDraw::DrawTileWeld*>(obj);
tile->TileParent.setValue(m_weldFeat);
}
for (auto name: m_toRemove) {
//QGIV is removed from scene by MDIVP/QGVP on objectDelete
Command::doCommand(Command::Doc,
"App.activeDocument().removeObject('%s')", name.c_str());
}
}
catch (...) {
Base::Console().Error("TWS::accept - failed to update symbol\n");
}
Gui::Command::updateActive();
Gui::Command::commitCommand();
m_weldFeat->recomputeFeature();
// m_weldFeat->requestPaint(); //not a dv!
}
Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()");
return true;
}
bool TaskWeldingSymbol::reject()
{
// Base::Console().Message("TWS::reject()\n");
//nothing to remove.
Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().recompute()");
Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()");
return false;
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
TaskDlgWeldingSymbol::TaskDlgWeldingSymbol(TechDraw::DrawLeaderLine* leader)
: TaskDialog()
{
widget = new TaskWeldingSymbol(leader);
taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-weldsymbol"),
widget->windowTitle(), true, 0);
taskbox->groupLayout()->addWidget(widget);
Content.push_back(taskbox);
}
TaskDlgWeldingSymbol::TaskDlgWeldingSymbol(TechDraw::DrawWeldSymbol* weld)
: TaskDialog()
{
widget = new TaskWeldingSymbol(weld);
taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-weldsymbol"),
widget->windowTitle(), true, 0);
taskbox->groupLayout()->addWidget(widget);
Content.push_back(taskbox);
}
TaskDlgWeldingSymbol::~TaskDlgWeldingSymbol()
{
}
void TaskDlgWeldingSymbol::update()
{
// widget->updateTask();
}
void TaskDlgWeldingSymbol::modifyStandardButtons(QDialogButtonBox* box)
{
QPushButton* btnOK = box->button(QDialogButtonBox::Ok);
QPushButton* btnCancel = box->button(QDialogButtonBox::Cancel);
widget->saveButtons(btnOK, btnCancel);
}
//==== calls from the TaskView ===============================================================
void TaskDlgWeldingSymbol::open()
{
}
void TaskDlgWeldingSymbol::clicked(int)
{
}
bool TaskDlgWeldingSymbol::accept()
{
widget->accept();
return true;
}
bool TaskDlgWeldingSymbol::reject()
{
widget->reject();
return true;
}
#include <Mod/TechDraw/Gui/moc_TaskWeldingSymbol.cpp>

View File

@@ -0,0 +1,208 @@
/***************************************************************************
* Copyright (c) 2019 WandererFan <wandererfan@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef TECHDRAWGUI_TASKWELDINGSYMBOL_H
#define TECHDRAWGUI_TASKWELDINGSYMBOL_H
#include <QPushButton>
#include <App/DocumentObject.h>
#include <Base/Vector3D.h>
#include <Gui/TaskView/TaskView.h>
#include <Gui/TaskView/TaskDialog.h>
#include <Mod/TechDraw/Gui/ui_TaskWeldingSymbol.h>
class Ui_TaskWeldingSymbol;
class Ui_TaskCL2Lines;
namespace App {
class DocumentObject;
}
namespace TechDraw
{
class DrawPage;
class DrawView;
class DrawLeaderLine;
class DrawWeldSymbol;
class DrawTileWeld;
class DrawTile;
}
namespace TechDraw
{
class Face;
}
namespace TechDrawGui
{
class QGVPage;
class QGIView;
class QGILeaderLine;
class QGIWeldSymbol;
class MDIViewPage;
//class ViewProviderWeld;
class TileImage
{
public:
TileImage() {};
~TileImage() = default;
bool toBeSaved;
bool arrowSide;
int row;
int col;
std::string leftText;
std::string centerText;
std::string rightText;
std::string symbolPath;
std::string tileName;
void init(void) {
toBeSaved = false;
arrowSide = true;
row = 0;
col = 0;
leftText = "";
centerText = "";
rightText = "";
symbolPath= "";
tileName = "";
}
};
class TechDrawGuiExport TaskWeldingSymbol : public QWidget
{
Q_OBJECT
public:
TaskWeldingSymbol(TechDraw::DrawLeaderLine* baseFeat);
TaskWeldingSymbol(TechDraw::DrawWeldSymbol* weldFeat);
~TaskWeldingSymbol();
public Q_SLOTS:
void onArrowSymbolClicked(bool b);
void onOtherSymbolClicked(bool b);
void onOtherEraseClicked(bool b);
void onArrowTextChanged(const QString& qs);
void onOtherTextChanged(const QString& qs);
void onDirectorySelected(const QString& newDir);
void onSymbolSelected(QString symbolPath, QString source);
public:
virtual bool accept();
virtual bool reject();
void updateTask();
void saveButtons(QPushButton* btnOK,
QPushButton* btnCancel);
void enableTaskButtons(bool b);
protected Q_SLOTS:
protected:
void changeEvent(QEvent *e);
void blockButtons(bool b);
void setUiPrimary(void);
void setUiEdit();
TechDraw::DrawWeldSymbol* createWeldingSymbol(void);
void updateWeldingSymbol(void);
std::vector<App::DocumentObject*> createTiles(void);
std::vector<App::DocumentObject*> updateTiles(void);
void collectArrowData(void);
void collectOtherData(void);
std::string prefSymbolDir();
void saveState(void);
QString m_currDir;
private:
Ui_TaskWeldingSymbol* ui;
TechDraw::DrawLeaderLine* m_leadFeat;
TechDraw::DrawWeldSymbol* m_weldFeat;
TechDraw::DrawTileWeld* m_arrowIn;
TechDraw::DrawTileWeld* m_otherIn;
TileImage m_arrowOut;
TileImage m_otherOut;
QString m_arrowPath;
QString m_otherPath;
std::vector<std::string> m_toRemove;
QPushButton* m_btnOK;
QPushButton* m_btnCancel;
bool m_createMode;
bool m_arrowDirty;
bool m_otherDirty;
};
class TaskDlgWeldingSymbol : public Gui::TaskView::TaskDialog
{
Q_OBJECT
public:
TaskDlgWeldingSymbol(TechDraw::DrawLeaderLine* leader);
TaskDlgWeldingSymbol(TechDraw::DrawWeldSymbol* weld);
~TaskDlgWeldingSymbol();
public:
/// is called the TaskView when the dialog is opened
virtual void open();
/// is called by the framework if an button is clicked which has no accept or reject role
virtual void clicked(int);
/// is called by the framework if the dialog is accepted (Ok)
virtual bool accept();
/// is called by the framework if the dialog is rejected (Cancel)
virtual bool reject();
/// is called by the framework if the user presses the help button
virtual void helpRequested() { return;}
virtual bool isAllowedAlterDocument(void) const
{ return false; }
void update();
void modifyStandardButtons(QDialogButtonBox* box);
protected:
private:
TaskWeldingSymbol* widget;
Gui::TaskView::TaskBox* taskbox;
};
} //namespace TechDrawGui
#endif // #ifndef TECHDRAWGUI_TASKWELDINGSYMBOL_H

View File

@@ -0,0 +1,307 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>TaskWeldingSymbol</class>
<widget class="QWidget" name="TaskWeldingSymbol">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>423</width>
<height>374</height>
</rect>
</property>
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>250</width>
<height>0</height>
</size>
</property>
<property name="windowTitle">
<string>Welding Symbol</string>
</property>
<property name="windowIcon">
<iconset resource="Resources/TechDraw.qrc">
<normaloff>:/icons/actions/techdraw-weldsymbol.svg</normaloff>:/icons/actions/techdraw-weldsymbol.svg</iconset>
</property>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QFrame" name="frame">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="frameShadow">
<enum>QFrame::Raised</enum>
</property>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<layout class="QHBoxLayout" name="hlArrowSideLayout">
<item>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<widget class="QLineEdit" name="leArrowTextL">
<property name="toolTip">
<string>Text before arrow side symbol</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLineEdit" name="leArrowTextR">
<property name="toolTip">
<string>Text after arrow side symbol</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QPushButton" name="pbArrowSymbol">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>32</height>
</size>
</property>
<property name="baseSize">
<size>
<width>0</width>
<height>32</height>
</size>
</property>
<property name="toolTip">
<string>Pick arrow side symbol</string>
</property>
<property name="statusTip">
<string/>
</property>
<property name="text">
<string>Symbol</string>
</property>
<property name="checkable">
<bool>false</bool>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="leArrowTextC">
<property name="toolTip">
<string>Text above arrow side symbol</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line">
<property name="frameShadow">
<enum>QFrame::Plain</enum>
</property>
<property name="lineWidth">
<number>5</number>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="hlOtherSideLayout">
<item>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="2">
<widget class="QLineEdit" name="leOtherTextR">
<property name="toolTip">
<string>Text after other side symbol</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QPushButton" name="pbOtherSymbol">
<property name="toolTip">
<string>Pick other side symbol</string>
</property>
<property name="text">
<string>Symbol</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLineEdit" name="leOtherTextL">
<property name="toolTip">
<string>Text before other side symbol</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="leOtherTextC">
<property name="toolTip">
<string>Text below other side symbol</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="pbOtherErase">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>60</width>
<height>30</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>60</width>
<height>30</height>
</size>
</property>
<property name="baseSize">
<size>
<width>60</width>
<height>30</height>
</size>
</property>
<property name="toolTip">
<string>Remove other side symbol</string>
</property>
<property name="text">
<string>Delete</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
</layout>
</item>
<item>
<widget class="Line" name="line_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
</widget>
</item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QGridLayout" name="gridLayout_3">
<item row="0" column="0">
<widget class="QCheckBox" name="cbFieldWeld">
<property name="text">
<string>Field Weld</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QCheckBox" name="cbAllAround">
<property name="text">
<string>All Around</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QCheckBox" name="cbAltWeld">
<property name="text">
<string>Alternating</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QFormLayout" name="formLayout_2">
<property name="fieldGrowthPolicy">
<enum>QFormLayout::AllNonFixedFieldsGrow</enum>
</property>
<item row="0" column="0">
<widget class="QLabel" name="label_5">
<property name="text">
<string>Tail Text</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="leTailText">
<property name="toolTip">
<string>Text at end of symbol</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="text">
<string>Symbol Directory</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="Gui::FileChooser" name="fcSymbolDir">
<property name="toolTip">
<string>Pick a directory of welding symbols</string>
</property>
<property name="mode">
<enum>Gui::FileChooser::Directory</enum>
</property>
<property name="filter">
<string>*.svg</string>
</property>
</widget>
</item>
</layout>
</item>
</layout>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<customwidgets>
<customwidget>
<class>Gui::FileChooser</class>
<extends>QWidget</extends>
<header>Gui/FileDialog.h</header>
</customwidget>
</customwidgets>
<resources>
<include location="Resources/TechDraw.qrc"/>
</resources>
<connections/>
</ui>

View File

@@ -88,9 +88,17 @@ void ViewProviderDrawingView::attach(App::DocumentObject *pcFeat)
connectGuiRepaint = feature->signalGuiPaint.connect(bnd);
//TODO: would be good to start the QGIV creation process here, but no guarantee we actually have
// MDIVP or QGVP yet.
// but parent page might. we may not be part of the document yet though!
// :( we're not part of the page yet either!
} else {
Base::Console().Warning("VPDV::attach has no Feature!\n");
}
// TechDraw::DrawView* view = static_cast<TechDraw::DrawView*>(pcFeat);
// TechDraw::DrawPage* page = view->findParentPage();
// TechDraw::DrawPage* page = feature->findParentPage();
// Base::Console().Message("VPDV::attach(%X) - parent: %X\n",
// pcFeat, page);
// pcFeat->getNameInDocument(), page->getNameInDocument());
}
void ViewProviderDrawingView::setDisplayMode(const char* ModeName)
@@ -232,7 +240,7 @@ MDIViewPage* ViewProviderDrawingView::getMDIViewPage() const
{
MDIViewPage* result = nullptr;
Gui::Document* guiDoc = Gui::Application::Instance->getDocument(getViewObject()->getDocument());
Gui::ViewProvider* vp = guiDoc->getViewProvider(getViewObject()->findParentPage());
Gui::ViewProvider* vp = guiDoc->getViewProvider(getViewObject()->findParentPage()); //if not in page.views, !@#$%
ViewProviderPage* dvp = dynamic_cast<ViewProviderPage*>(vp);
if (dvp) {
result = dvp->getMDIViewPage();
@@ -256,6 +264,9 @@ void ViewProviderDrawingView::onGuiRepaint(const TechDraw::DrawView* dv)
} else { //we are not part of the Gui page yet. ask page to add us.
//TODO: this bit causes trouble. Should move QGIV creation to attach?
// is MDIVP/QGVP available at attach time?
// wf: mdivp/qgvp is not necessarily directly available at attach time. It should be available
// via the parent DrawPage since the DP is created before any views.
// Base::Console().Message("VPDV::onGuiRepaint - no QGIV for: %s\n",dv->getNameInDocument());
MDIViewPage* page = getMDIViewPage();
if (page != nullptr) {
page->addView(dv);

View File

@@ -49,6 +49,7 @@
#include <Mod/TechDraw/App/LineGroup.h>
#include <Mod/TechDraw/App/DrawLeaderLine.h>
#include <Mod/TechDraw/App/DrawRichAnno.h>
#include <Mod/TechDraw/App/DrawWeldSymbol.h>
#include "MDIViewPage.h"
#include "QGVPage.h"
@@ -153,12 +154,15 @@ std::vector<App::DocumentObject*> ViewProviderLeader::claimChildren(void) const
// Collect any child Document Objects and put them in the right place in the Feature tree
// valid children of a ViewLeader are:
// - Rich Annotations
// - Weld Symbols
std::vector<App::DocumentObject*> temp;
const std::vector<App::DocumentObject *> &views = getFeature()->getInList();
try {
for(std::vector<App::DocumentObject *>::const_iterator it = views.begin(); it != views.end(); ++it) {
if ((*it)->getTypeId().isDerivedFrom(TechDraw::DrawRichAnno::getClassTypeId())) {
temp.push_back((*it));
} else if ((*it)->getTypeId().isDerivedFrom(TechDraw::DrawWeldSymbol::getClassTypeId())) {
temp.push_back((*it));
}
}
return temp;

View File

@@ -58,6 +58,7 @@
#include <Mod/TechDraw/App/DrawLeaderLine.h>
#include <Mod/TechDraw/App/DrawRichAnno.h>
#include <Mod/TechDraw/App/DrawHatch.h>
#include <Mod/TechDraw/App/DrawWeldSymbol.h>
#include <Mod/TechDraw/App/DrawUtil.h>
#include "MDIViewPage.h"
@@ -283,10 +284,11 @@ std::vector<App::DocumentObject*> ViewProviderPage::claimChildren(void) const
// for Page, valid children are any View except: DrawProjGroupItem
// DrawViewDimension
// DrawViewBalloon
// DrawLeader
// DrawRichAnno (if not a child of View)
// DrawLeaderLine
// DrawRichAnno
// any FeatuerView in a DrawViewClip
// DrawHatch
// DrawWeldSymbol
const std::vector<App::DocumentObject *> &views = getDrawPage()->Views.getValues();
@@ -312,6 +314,7 @@ std::vector<App::DocumentObject*> ViewProviderPage::claimChildren(void) const
docObj->isDerivedFrom(TechDraw::DrawViewBalloon::getClassTypeId()) ||
docObj->isDerivedFrom(TechDraw::DrawRichAnno::getClassTypeId()) ||
docObj->isDerivedFrom(TechDraw::DrawLeaderLine::getClassTypeId()) ||
docObj->isDerivedFrom(TechDraw::DrawWeldSymbol::getClassTypeId()) ||
(featView && featView->isInClip()) )
continue;
else

View File

@@ -0,0 +1,90 @@
/***************************************************************************
* Copyright (c) 2019 Wanderer Fan <wandererfan@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#endif
/// Here the FreeCAD includes sorted by Base,App,Gui......
#include <Base/Console.h>
#include <Base/Parameter.h>
#include <Base/Exception.h>
#include <Base/Sequencer.h>
#include <App/Application.h>
#include <App/Document.h>
#include <App/DocumentObject.h>
#include <Gui/SoFCSelection.h>
#include <Gui/Selection.h>
#include "ViewProviderTile.h"
using namespace TechDrawGui;
PROPERTY_SOURCE(TechDrawGui::ViewProviderTile, Gui::ViewProviderDocumentObject)
//**************************************************************************
// Construction/Destruction
ViewProviderTile::ViewProviderTile()
{
sPixmap = "actions/techdraw-tile";
}
ViewProviderTile::~ViewProviderTile()
{
}
void ViewProviderTile::attach(App::DocumentObject *pcFeat)
{
// call parent attach method
ViewProviderDocumentObject::attach(pcFeat);
}
void ViewProviderTile::setDisplayMode(const char* ModeName)
{
ViewProviderDocumentObject::setDisplayMode(ModeName);
}
std::vector<std::string> ViewProviderTile::getDisplayModes(void) const
{
// get the modes of the father
std::vector<std::string> StrList = ViewProviderDocumentObject::getDisplayModes();
return StrList;
}
void ViewProviderTile::updateData(const App::Property* prop)
{
ViewProviderDocumentObject::updateData(prop);
}
//TechDraw::DrawTile* ViewProviderTile::getViewObject() const
//{
// return dynamic_cast<TechDraw::DrawTile*>(pcObject);
//}
TechDraw::DrawTile* ViewProviderTile::getFeature() const
{
return dynamic_cast<TechDraw::DrawTile*>(pcObject);
}

View File

@@ -0,0 +1,59 @@
/***************************************************************************
* Copyright (c) 2019 Wanderer Fan <wandererfan@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef DRAWINGGUI_VIEWPROVIDERTILE_H
#define DRAWINGGUI_VIEWPROVIDERTILE_H
#include <Gui/ViewProviderDocumentObject.h>
#include <Mod/TechDraw/App/DrawTile.h>
namespace TechDrawGui {
class TechDrawGuiExport ViewProviderTile : public Gui::ViewProviderDocumentObject
{
PROPERTY_HEADER(TechDrawGui::ViewProviderTile);
public:
/// constructor
ViewProviderTile();
/// destructor
virtual ~ViewProviderTile();
virtual void attach(App::DocumentObject *);
virtual void setDisplayMode(const char* ModeName);
virtual bool useNewSelectionModel(void) const {return false;}
/// returns a list of all possible modes
virtual std::vector<std::string> getDisplayModes(void) const;
virtual void updateData(const App::Property*);
/* virtual TechDraw::DrawTile* getViewObject() const;*/
virtual TechDraw::DrawTile* getFeature() const;
};
} // namespace TechDrawGui
#endif // DRAWINGGUI_VIEWPROVIDERTILE_H

View File

@@ -43,6 +43,7 @@
#include <Mod/TechDraw/App/DrawViewMulti.h>
#include <Mod/TechDraw/App/DrawHatch.h>
#include <Mod/TechDraw/App/DrawGeomHatch.h>
#include <Mod/TechDraw/App/DrawWeldSymbol.h>
#include <Mod/TechDraw/App/LineGroup.h>
#include<Mod/TechDraw/App/DrawPage.h>

View File

@@ -0,0 +1,154 @@
/***************************************************************************
* Copyright (c) 2019 Wanderer Fan <wandererfan@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include "PreCompiled.h"
#ifndef _PreComp_
#endif
/// Here the FreeCAD includes sorted by Base,App,Gui......
#include <Base/Console.h>
#include <Base/Parameter.h>
#include <Base/Exception.h>
#include <Base/Sequencer.h>
#include <App/Application.h>
#include <App/Document.h>
#include <App/DocumentObject.h>
#include <Gui/Application.h>
#include <Gui/BitmapFactory.h>
#include <Gui/Control.h>
#include <Gui/Command.h>
#include <Gui/Document.h>
#include <Gui/MainWindow.h>
#include <Gui/Selection.h>
#include "TaskWeldingSymbol.h"
#include "ViewProviderWeld.h"
using namespace TechDrawGui;
PROPERTY_SOURCE(TechDrawGui::ViewProviderWeld, TechDrawGui::ViewProviderDrawingView)
//**************************************************************************
// Construction/Destruction
ViewProviderWeld::ViewProviderWeld()
{
sPixmap = "actions/techdraw-weldsymbol";
}
ViewProviderWeld::~ViewProviderWeld()
{
}
void ViewProviderWeld::attach(App::DocumentObject *pcFeat)
{
// call parent attach method
ViewProviderDrawingView::attach(pcFeat);
}
void ViewProviderWeld::setDisplayMode(const char* ModeName)
{
ViewProviderDrawingView::setDisplayMode(ModeName);
}
std::vector<std::string> ViewProviderWeld::getDisplayModes(void) const
{
// get the modes of the father
std::vector<std::string> StrList = ViewProviderDrawingView::getDisplayModes();
return StrList;
}
void ViewProviderWeld::updateData(const App::Property* prop)
{
ViewProviderDrawingView::updateData(prop);
}
std::vector<App::DocumentObject*> ViewProviderWeld::claimChildren(void) const
{
// Collect any child Document Objects and put them in the right place in the Feature tree
// valid children of a DrawWeldSymbol are:
// - DrawTiles
std::vector<App::DocumentObject*> temp;
const std::vector<App::DocumentObject *> &tiles = getFeature()->getInList();
try {
for(std::vector<App::DocumentObject *>::const_iterator it = tiles.begin(); it != tiles.end(); ++it) {
if ((*it)->getTypeId().isDerivedFrom(TechDraw::DrawTile::getClassTypeId())) {
temp.push_back((*it));
}
}
return temp;
} catch (...) {
std::vector<App::DocumentObject*> tmp;
return tmp;
}
}
bool ViewProviderWeld::setEdit(int ModNum)
{
// Base::Console().Message("VPW::setEdit(%d)\n",ModNum);
if (ModNum == ViewProvider::Default ) {
if (Gui::Control().activeDialog()) { //TaskPanel already open!
return false;
}
// clear the selection (convenience)
Gui::Selection().clearSelection();
Gui::Control().showDialog(new TaskDlgWeldingSymbol(getFeature()));
return true;
} else {
return ViewProviderDrawingView::setEdit(ModNum);
}
return true;
}
void ViewProviderWeld::unsetEdit(int ModNum)
{
Q_UNUSED(ModNum);
if (ModNum == ViewProvider::Default) {
Gui::Control().closeDialog();
}
else {
ViewProviderDrawingView::unsetEdit(ModNum);
}
}
bool ViewProviderWeld::doubleClicked(void)
{
// Base::Console().Message("VPW::doubleClicked()\n");
setEdit(ViewProvider::Default);
return true;
}
TechDraw::DrawWeldSymbol* ViewProviderWeld::getViewObject() const
{
return dynamic_cast<TechDraw::DrawWeldSymbol*>(pcObject);
}
TechDraw::DrawWeldSymbol* ViewProviderWeld::getFeature() const
{
return getViewObject();
}

View File

@@ -0,0 +1,66 @@
/***************************************************************************
* Copyright (c) 2019 Wanderer Fan <wandererfan@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#ifndef DRAWINGGUI_VIEWPROVIDERWELD_H
#define DRAWINGGUI_VIEWPROVIDERWELD_H
#include <Gui/ViewProviderFeature.h>
#include "ViewProviderDrawingView.h"
#include <Mod/TechDraw/App/DrawView.h>
#include <Mod/TechDraw/App/DrawWeldSymbol.h>
#include <Mod/TechDraw/App/DrawTile.h>
namespace TechDrawGui {
class TechDrawGuiExport ViewProviderWeld : public ViewProviderDrawingView
{
PROPERTY_HEADER(TechDrawGui::ViewProviderWeld);
public:
/// constructor
ViewProviderWeld();
/// destructor
virtual ~ViewProviderWeld();
virtual void attach(App::DocumentObject *);
virtual void setDisplayMode(const char* ModeName);
virtual bool useNewSelectionModel(void) const {return false;}
/// returns a list of all possible modes
virtual std::vector<std::string> getDisplayModes(void) const;
virtual void updateData(const App::Property*);
virtual std::vector<App::DocumentObject*> claimChildren(void) const;
virtual bool setEdit(int ModNum);
virtual void unsetEdit(int ModNum);
virtual bool doubleClicked(void);
virtual TechDraw::DrawWeldSymbol* getViewObject() const;
virtual TechDraw::DrawWeldSymbol* getFeature() const;
};
} // namespace TechDrawGui
#endif // DRAWINGGUI_VIEWPROVIDERWELD_H

View File

@@ -87,6 +87,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const
*draw << "TechDraw_Image";
*draw << "TechDraw_ToggleFrame";
// *decor << "TechDraw_RedrawPage";
*draw << "Separator";
*draw << "TechDraw_Annotation";
*draw << "TechDraw_LeaderLine";
*draw << "TechDraw_RichAnno";
@@ -99,7 +100,7 @@ Gui::MenuItem* Workbench::setupMenuBar() const
*draw << "TechDraw_CosmeticEraser";
*draw << "TechDraw_DecorateLine";
*draw << "TechDraw_ShowAll";
*draw << "TechDraw_WeldSymbol";
return root;
}
@@ -168,6 +169,7 @@ Gui::ToolBarItem* Workbench::setupToolBars() const
*anno << "TechDraw_CosmeticEraser";
*anno << "TechDraw_DecorateLine";
*anno << "TechDraw_ShowAll";
*anno << "TechDraw_WeldSymbol";
return root;
}
@@ -234,6 +236,7 @@ Gui::ToolBarItem* Workbench::setupCommandBars() const
*anno << "TechDraw_CosmeticEraser";
*anno << "TechDraw_DecorateLine";
*anno << "TechDraw_ShowAll";
*anno << "TechDraw_WeldSymbol";
return root;
}

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 5.6 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 5.5 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 5.2 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 5.3 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 4.8 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 4.8 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 4.7 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 4.7 KiB

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 4.7 KiB