From 193caf07f72053188326afc610f4dfecb9cf4368 Mon Sep 17 00:00:00 2001 From: three_d <75747159+three-ddd@users.noreply.github.com> Date: Thu, 21 Jan 2021 18:41:23 +0100 Subject: [PATCH 001/178] Arch: connections between stair flight and landing Added some features to allow the user to change the types of connections between the flight of stairs and landing. This issue is discussed in the forum thread: https://forum.freecadweb.org/viewtopic.php?f=22&t=53018 --- src/Mod/Arch/ArchStairs.py | 125 +++++++++++++++++++++++-------------- 1 file changed, 78 insertions(+), 47 deletions(-) diff --git a/src/Mod/Arch/ArchStairs.py b/src/Mod/Arch/ArchStairs.py index fa511ce7e9..3e5ca1f039 100644 --- a/src/Mod/Arch/ArchStairs.py +++ b/src/Mod/Arch/ArchStairs.py @@ -82,7 +82,9 @@ def makeStairs(baseobj=None,length=None,width=None,height=None,steps=None,name=" obj.NumberOfSteps = steps obj.Structure = "Massive" obj.StructureThickness = 150 - + obj.DownSlabThickness = 150 + obj.UpSlabThickness = 150 + obj.RailingOffsetLeft = 60 obj.RailingOffsetRight = 60 obj.RailingHeightLeft = 900 @@ -114,7 +116,7 @@ def makeStairs(baseobj=None,length=None,width=None,height=None,steps=None,name=" elif steps: stepsI = steps else: - stepsI = 16 + stepsI = 20 setProperty(stairs[i],None,width,height,stepsI,name) if i > 1: @@ -408,7 +410,17 @@ class _Stairs(ArchComponent.Component): obj.addProperty("App::PropertyLength","StructureOffset","Structure",QT_TRANSLATE_NOOP("App::Property","The offset between the border of the stairs and the structure")) if not "StringerOverlap" in pl: obj.addProperty("App::PropertyLength","StringerOverlap","Structure",QT_TRANSLATE_NOOP("App::Property","The overlap of the stringers above the bottom of the treads")) - + if not "DownSlabThickness" in pl: + obj.addProperty("App::PropertyLength","DownSlabThickness","Structure",QT_TRANSLATE_NOOP("App::Property","The thickness of the lower floor slab")) + if not "UpSlabThickness" in pl: + obj.addProperty("App::PropertyLength","UpSlabThickness","Structure",QT_TRANSLATE_NOOP("App::Property","The thickness of the upper floor slab")) + if not "ConnectionDownStartStairs" in pl: + obj.addProperty("App::PropertyEnumeration","ConnectionDownStartStairs","Structure",QT_TRANSLATE_NOOP("App::Property","The type of connection between the lower slab and the start of the stairs")) + obj.ConnectionDownStartStairs = ["HorizontalCut","VerticalCut","HorizontalVerticalCut"] + if not "ConnectionEndStairsUp" in pl: + obj.addProperty("App::PropertyEnumeration","ConnectionEndStairsUp","Structure",QT_TRANSLATE_NOOP("App::Property","The type of connection between the end of the stairs and the upper floor slab")) + obj.ConnectionEndStairsUp = ["toFlightThickness","toSlabThickness"] + self.Type = "Stairs" def onDocumentRestored(self,obj): @@ -935,8 +947,12 @@ class _Stairs(ArchComponent.Component): if not callByMakeStraightStairsWithLanding: vBase = self.vbaseFollowLastSegment(obj, vBase) obj.AbsTop = vBase - - vNose = DraftVecUtils.scaleTo(vLength,-abs(obj.Nosing.Value)) + + if not obj.Flight in ["HalfTurnLeft","HalfTurnRight"]: + vNose = DraftVecUtils.scaleTo(vLength,-abs(obj.Nosing.Value)) + else: + vNose = Vector(0,0,0) + h = 0 l = 0 @@ -1010,41 +1026,16 @@ class _Stairs(ArchComponent.Component): # structure lProfile = [] struct = None - p5 = None - p7 = None p1 = p1.add(DraftVecUtils.neg(vNose)) - p2 = p1.add(Vector(0,0,-fHeight)).add(Vector(0,0,-obj.StructureThickness.Value/math.cos(a))) - resheight = p1.sub(p2).Length - obj.StructureThickness.Value - reslength = resheight / math.tan(a) - p3 = p2.add(DraftVecUtils.scaleTo(vLength,reslength)).add(Vector(0,0,resheight)) - p6 = p1.add(vLength) - if obj.TreadThickness.Value: - if obj.Flight == "Straight": - p7 = p6.add(Vector(0,0,obj.TreadThickness.Value)) - reslength = fLength + (obj.StructureThickness.Value/math.sin(a)-(fHeight-obj.TreadThickness.Value)/math.tan(a)) - if p7: - p5 = p7.add(DraftVecUtils.scaleTo(vLength,reslength)) - else: - if obj.Flight == "Straight": - p5 = p6.add(DraftVecUtils.scaleTo(vLength,reslength)) - else: - p5 = None - resheight = obj.StructureThickness.Value + obj.TreadThickness.Value - reslength = resheight/math.tan(a) - if obj.Flight == "Straight": - p4 = p5.add(DraftVecUtils.scaleTo(vLength,-reslength)).add(Vector(0,0,-resheight)) - else: - p4 = p6.add(Vector(0,0,-obj.StructureThickness.Value)) + p2 = p1.add(Vector(0,0,-(abs(fHeight) - obj.TreadThickness.Value))) + p3 = p1.add(vLength) + p4 = p3.add(Vector(0,0,-(abs(fHeight) - obj.TreadThickness.Value))) + if obj.Structure == "Massive": if obj.StructureThickness.Value: - if p7: - struct = Part.Face(Part.makePolygon([p1,p2,p3,p4,p5,p7,p6,p1])) - elif p5: - struct = Part.Face(Part.makePolygon([p1,p2,p3,p4,p5,p6,p1])) - else: - struct = Part.Face(Part.makePolygon([p1,p2,p3,p4,p6,p1])) + struct = Part.Face(Part.makePolygon([p1,p2,p4,p3,p1])) evec = vWidth - mvec = FreeCAD.Vector(0.0,0) + mvec = FreeCAD.Vector(0,0,0) if obj.StructureOffset.Value: mvec = DraftVecUtils.scaleTo(vWidth,obj.StructureOffset.Value) struct.translate(mvec) @@ -1100,7 +1091,7 @@ class _Stairs(ArchComponent.Component): self.structures.append(struct) - def makeStraightStairs(self,obj,edge,numberofsteps=None): + def makeStraightStairs(self,obj,edge,s1,s2,numberofsteps=None,downstartstairs=None,endstairsup=None): "builds a simple, straight staircase from a straight edge" @@ -1116,7 +1107,12 @@ class _Stairs(ArchComponent.Component): callByMakeStraightStairsWithLanding = False else: callByMakeStraightStairsWithLanding = True - + + if not downstartstairs: + downstartstairs = obj.ConnectionDownStartStairs + if not endstairsup: + endstairsup = obj.ConnectionEndStairsUp + v = DraftGeomUtils.vec(edge) vLength = DraftVecUtils.scaleTo(v,float(edge.Length)/(numberofsteps-1)) vLength = Vector(vLength.x,vLength.y,0) @@ -1209,11 +1205,43 @@ class _Stairs(ArchComponent.Component): lProfile[-1] = lProfile[-1].add(-vRiserThickness) resHeight1 = obj.StructureThickness.Value/math.cos(a) - lProfile.append(lProfile[-1].add(Vector(0,0,-resHeight1))) - resHeight2 = ((numberofsteps-1)*vHeight.Length)-(resHeight1+obj.TreadThickness.Value) - resLength = (vLength.Length/vHeight.Length)*resHeight2 - h = DraftVecUtils.scaleTo(vLength,-resLength) - lProfile.append(lProfile[-1].add(Vector(h.x,h.y,-resHeight2))) + dh = s2 - float(h)/numberofsteps + resHeight2 = ((numberofsteps-1)*vHeight.Length) - dh + + if endstairsup == "toFlightThickness": + lProfile.append(lProfile[-1].add(Vector(0,0,-resHeight1))) + resHeight2 = ((numberofsteps-1)*vHeight.Length)-(resHeight1+obj.TreadThickness.Value) + resLength = (vLength.Length/vHeight.Length)*resHeight2 + h = DraftVecUtils.scaleTo(vLength,-resLength) + elif endstairsup == "toSlabThickness": + resLength = (vLength.Length/vHeight.Length) * resHeight2 + h = DraftVecUtils.scaleTo(vLength,-resLength) + th = (resHeight1 + obj.TreadThickness.Value) - dh + resLength2 = th / math.tan(a) + lProfile.append(lProfile[-1].add(Vector(0,0,obj.TreadThickness.Value - dh))) + lProfile.append(lProfile[-1].add(DraftVecUtils.scaleTo(vLength,resLength2))) + + if s1 > resHeight1: + downstartstairs = "VerticalCut" + + if downstartstairs == "VerticalCut": + dh = obj.DownSlabThickness.Value - resHeight1 - obj.TreadThickness.Value + resHeight2 = resHeight2 + obj.DownSlabThickness.Value - dh + resLength = (vLength.Length/vHeight.Length)*resHeight2 + lProfile.append(lProfile[-1].add(DraftVecUtils.scaleTo(vLength,-resLength)).add(Vector(0,0,-resHeight2))) + elif downstartstairs == "HorizontalVerticalCut": + temp_s1 = s1 + if obj.UpSlabThickness.Value > resHeight1: + s1 = temp_s1 + + resHeight2 = resHeight2 + s1 + resLength = (vLength.Length/vHeight.Length) * resHeight2 + th = (resHeight1 - s1) + obj.TreadThickness.Value + resLength2 = th / math.tan(a) + lProfile.append(lProfile[-1].add(DraftVecUtils.scaleTo(vLength,-resLength)).add(Vector(0,0,-resHeight2))) + lProfile.append(lProfile[-1].add(DraftVecUtils.scaleTo(vLength,-resLength2))) + else + lProfile.append(lProfile[-1].add(Vector(h.x,h.y,-resHeight2))) lProfile.append(vBase) @@ -1360,11 +1388,14 @@ class _Stairs(ArchComponent.Component): self.makeStraightLanding(obj,Part.LineSegment(p2,p3).toShape(), None, True) if obj.Flight in ["HalfTurnLeft", "HalfTurnRight"]: - self.makeStraightStairs(obj,Part.LineSegment(p3r,p4r).toShape(),obj.NumberOfSteps-landing) + self.makeStraightStairs(obj,Part.LineSegment(p3r,p4r).toShape(),obj.RiserHeight.Value,obj.UpSlabThickness.Value,obj.NumberOfSteps-landing,"HorizontalVerticalCut",None) else: - self.makeStraightStairs(obj,Part.LineSegment(p3,p4).toShape(),obj.NumberOfSteps-landing) - - self.makeStraightStairs(obj,Part.LineSegment(p1,p2).toShape(),landing) + self.makeStraightStairs(obj,Part.LineSegment(p3,p4).toShape(),obj.RiserHeight.Value,obj.UpSlabThickness.Value,obj.NumberOfSteps-landing,"HorizontalVerticalCut",None) + + self.makeStraightStairs(obj,Part.LineSegment(p1,p2).toShape(),obj.DownSlabThickness.Value,obj.RiserHeight.Value,landing,None,'toSlabThickness') + else: + self.makeStraightStairs(obj,Part.LineSegment(p1,p2).toShape(),obj.DownSlabThickness.Value,obj.UpSlabThickness.Value,landing,None,None) + print (p1, p2) if obj.Landings == "At center" and obj.Flight not in ["HalfTurnLeft", "HalfTurnRight"]: print (p3, p4) From 10ec3016ef814841bd71bbfa1dfe9af38505f8d6 Mon Sep 17 00:00:00 2001 From: three_d <75747159+three-ddd@users.noreply.github.com> Date: Fri, 22 Jan 2021 19:09:18 +0100 Subject: [PATCH 002/178] Update ArchStairs.py --- src/Mod/Arch/ArchStairs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Arch/ArchStairs.py b/src/Mod/Arch/ArchStairs.py index 3e5ca1f039..cda3b2a5ad 100644 --- a/src/Mod/Arch/ArchStairs.py +++ b/src/Mod/Arch/ArchStairs.py @@ -1240,7 +1240,7 @@ class _Stairs(ArchComponent.Component): resLength2 = th / math.tan(a) lProfile.append(lProfile[-1].add(DraftVecUtils.scaleTo(vLength,-resLength)).add(Vector(0,0,-resHeight2))) lProfile.append(lProfile[-1].add(DraftVecUtils.scaleTo(vLength,-resLength2))) - else + else: lProfile.append(lProfile[-1].add(Vector(h.x,h.y,-resHeight2))) lProfile.append(vBase) From 99af124f8019efa28451ee92c8b581358336ba42 Mon Sep 17 00:00:00 2001 From: Roy-043 <70520633+Roy-043@users.noreply.github.com> Date: Tue, 23 Feb 2021 19:58:39 +0100 Subject: [PATCH 003/178] [ARCH] Arch_Roof fix for adjust_list_len function LGTM code analysis did not like that the adjust_list_len function would mutate default list values. De function now always clones the list. See: https://forum.freecadweb.org/viewtopic.php?f=23&t=55943 --- src/Mod/Arch/ArchRoof.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Mod/Arch/ArchRoof.py b/src/Mod/Arch/ArchRoof.py index 99130d0e43..59b8eb2a6f 100644 --- a/src/Mod/Arch/ArchRoof.py +++ b/src/Mod/Arch/ArchRoof.py @@ -49,7 +49,7 @@ else: # \brief The Roof object and tools # # This module provides tools to build Roof objects. -# Roofs are build from a closed contour and a series of +# Roofs are built from a closed contour and a series of # slopes. __title__ = "FreeCAD Roof" @@ -58,13 +58,12 @@ __url__ = "https://www.freecadweb.org" def adjust_list_len (lst, newLn, val): + '''Returns a clone of lst with length newLn, val is appended if required''' ln = len(lst) if ln > newLn: return lst[0:newLn] else: - for i in range(newLn - ln): - lst.append(val) - return lst + return lst[:] + ([val] * (newLn - ln)) def find_inters (edge1, edge2, infinite1=True, infinite2=True): From b8dee20115bc27d7c4d3cab819974542efdf0702 Mon Sep 17 00:00:00 2001 From: marioalexis Date: Tue, 9 Feb 2021 18:00:36 -0300 Subject: [PATCH 004/178] Draft: Fix snap to proxy WP and BuildingParts - fixes #0004278 --- src/Mod/Draft/draftguitools/gui_snapper.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Mod/Draft/draftguitools/gui_snapper.py b/src/Mod/Draft/draftguitools/gui_snapper.py index 7f47e17c8a..93ac7f3b3c 100644 --- a/src/Mod/Draft/draftguitools/gui_snapper.py +++ b/src/Mod/Draft/draftguitools/gui_snapper.py @@ -407,6 +407,12 @@ class Snapper: # Special snapping for polygons: add the center snaps.extend(self.snapToPolygon(obj)) + elif (Draft.getType(obj) == "BuildingPart" + and self.isEnabled("Center")): + # snap to the base placement of empty BuildingParts + snaps.append([obj.Placement.Base, 'center', + self.toWP(obj.Placement.Base)]) + if (not self.maxEdges) or (len(shape.Edges) <= self.maxEdges): if "Edge" in comp: # we are snapping to an edge @@ -458,9 +464,11 @@ class Snapper: # for points we only snap to points snaps.extend(self.snapToEndpoints(obj.Points)) - elif Draft.getType(obj) in ("WorkingPlaneProxy", "BuildingPart"): - # snap to the center of WPProxies and BuildingParts - snaps.append([obj.Placement.Base, 'endpoint', + elif (Draft.getType(obj) in ("WorkingPlaneProxy", "BuildingPart") + and self.isEnabled("Center")): + # snap to the center of WPProxies or to the base + # placement of no empty BuildingParts + snaps.append([obj.Placement.Base, 'center', self.toWP(obj.Placement.Base)]) elif Draft.getType(obj) == "SectionPlane": From b44175f4fe4ef25675553c12bde5dde720ad7e70 Mon Sep 17 00:00:00 2001 From: Benjamin Nauck Date: Sat, 27 Feb 2021 12:45:48 +0100 Subject: [PATCH 005/178] Tools: updatecrowdin.py rewrite to support new api Crowdin has depreciated their old api and will shut it down completely in december 2021. What's new: * rewritten in Python 3 (drops support for discontinued Python 2) * uses Crowdin's api v2 * runs on vanilla Python 3, (no external modules) * automatically adds new translation from the src directory * supports api token to be specified in an environment variable (Makes GitHub integration easier in the future) * requires project id to be explicitly set with an environment variable (Makes testing safer) The api token can be set either in ~/.crowdin-freecad-token similar to how the old api key was set, or by specifying it in an environment variable. The later has been added to make it easier with GitHub-Crowdin integration in the future. The requirement to explicitly set CROWDIN_PROJECT_ID has been introduced to avoid accidentally using the main Crowdin project while testing the script. The script has been tested on Python versions 3.7, 3.8 and 3.9. Co-authored-by: Mattias Pierre --- src/Tools/updatecrowdin.py | 363 +++++++++++++++++++++---------------- 1 file changed, 210 insertions(+), 153 deletions(-) diff --git a/src/Tools/updatecrowdin.py b/src/Tools/updatecrowdin.py index 2ce9c30de2..a5a1b707e2 100755 --- a/src/Tools/updatecrowdin.py +++ b/src/Tools/updatecrowdin.py @@ -1,187 +1,244 @@ -#!/usr/bin/python +#!/usr/bin/env python3 +# *************************************************************************** +# * * +# * Copyright (c) 2015 Yorik van Havre * +# * Copyright (c) 2021 Benjamin Nauck * +# * Copyright (c) 2021 Mattias Pierre * +# * * +# * This program is free software; you can redistribute it and/or modify * +# * it under the terms of the GNU Library General Public License (LGPL) * +# * as published by the Free Software Foundation; either version 2 of * +# * the License, or (at your option) any later version. * +# * for detail see the LICENCE text file. * +# * * +# * This program 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 program; if not, write to the Free Software * +# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * +# * USA * +# * * +# *************************************************************************** -#*************************************************************************** -#* * -#* Copyright (c) 2015 Yorik van Havre * -#* * -#* This program is free software; you can redistribute it and/or modify * -#* it under the terms of the GNU Library General Public License (LGPL) * -#* as published by the Free Software Foundation; either version 2 of * -#* the License, or (at your option) any later version. * -#* for detail see the LICENCE text file. * -#* * -#* This program 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 program; if not, write to the Free Software * -#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * -#* USA * -#* * -#*************************************************************************** - -from __future__ import print_function - -''' +""" This utility offers several commands to interact with the FreeCAD project on crowdin. -For it to work, you need a .crowdin-freecad file in your user's folder, that contains -the API key that gives access to the crowdin FreeCAD project. +For it to work, you need a ~/.crowdin-freecad-token file in your user's folder, that contains +the API access token that gives access to the crowdin FreeCAD project. +The API token can also be specified in the CROWDIN_TOKEN environment variable. + +The CROWDIN_PROJECT_ID environment variable must be set. Usage: - updatecrowdin.py command + updatecrowdin.py [] Available commands: - status: prints a status of the translations - update: updates crowdin the current version of .ts files found in the source code - build: builds a new downloadable package on crowdin with all translated strings - download: downloads the latest build + status: prints a status of the translations + update: updates crowdin the current version of .ts files found in the source code + build: builds a new downloadable package on crowdin with all translated strings + download [build_id]: downloads build specified by 'build_id' or latest if build_id is left blank Example: ./updatecrowdin.py update -''' +Setting the project name adhoc: + + CROWDIN_PROJECT_ID=some_project ./updatecrowdin.py update +""" # See crowdin API docs at https://crowdin.com/page/api +import concurrent.futures +import glob +import json +import os +import sys +from collections import namedtuple +from functools import lru_cache +from os.path import basename, splitext +from urllib.parse import quote_plus +from urllib.request import Request +from urllib.request import urlopen +from urllib.request import urlretrieve + +TsFile = namedtuple('TsFile', ['filename', 'src_path']) + +LEGACY_NAMING_MAP = {'Draft.ts': 'draft.ts'} -import sys,os,xml.sax,pycurl,StringIO +class CrowdinUpdater: + + BASE_URL = 'https://api.crowdin.com/api/v2' + + def __init__(self, token, project_identifier, multithread=True): + self.token = token + self.project_identifier = project_identifier + self.multithread = multithread + + @lru_cache() + def _get_project_id(self): + url = f'{self.BASE_URL}/projects/' + response = self._make_api_req(url) + + for project in [p['data'] for p in response]: + if project['identifier'] == project_identifier: + return project['id'] + + raise Exception('No project identifier found!') + + def _make_project_api_req(self, project_path, *args, **kwargs): + url = f'{self.BASE_URL}/projects/{self._get_project_id()}{project_path}' + return self._make_api_req(url=url, *args, **kwargs) + + def _make_api_req(self, url, extra_headers={}, method='GET', data=None): + headers = {'Authorization': 'Bearer ' + load_token(), **extra_headers} + + if type(data) is dict: + headers['Content-Type'] = 'application/json' + data = json.dumps(data).encode('utf-8') + + request = Request(url, headers=headers, method=method, data=data) + return json.loads(urlopen(request).read())['data'] + + def _get_files_info(self): + files = self._make_project_api_req('/files?limit=250') + return {f['data']['path'].strip('/'): str(f['data']['id']) for f in files} + + def _add_storage(self, filename, fp): + response = self._make_api_req(f'{self.BASE_URL}/storages', data=fp, method='POST', extra_headers={ + 'Crowdin-API-FileName': filename, + 'Content-Type': 'application/octet-stream' + }) + return response['id'] + + def _update_file(self, project_id, ts_file, files_info): + filename = quote_plus(ts_file.filename) + + with open(ts_file.src_path, 'rb') as fp: + storage_id = self._add_storage(filename, fp) + + if filename in files_info: + file_id = files_info[filename] + self._make_project_api_req(f'/files/{file_id}', method='PUT', data={ + 'storageId': storage_id, + 'updateOption': 'keep_translations_and_approvals' + }) + print(f'{filename} updated') + else: + self._make_project_api_req('/files', data={ + 'storageId': storage_id, + 'name': filename + }) + print(f'{filename} uploaded') + + def status(self): + response = self._make_project_api_req('/languages/progress') + return [item['data'] for item in response] + + def download(self, build_id): + filename = f'{self.project_identifier}.zip' + response = self._make_project_api_req(f'/translations/builds/{build_id}/download') + urlretrieve(response['url'], filename) + print('download complete') + + def build(self): + self._make_project_api_req('/translations/builds', data={}, method='POST') + + def build_status(self): + response = self._make_project_api_req('/translations/builds') + return [item['data'] for item in response] + + def update(self, ts_files): + files_info = self._get_files_info() + futures = [] + + with concurrent.futures.ThreadPoolExecutor() as executor: + for ts_file in ts_files: + if self.multithread: + future = executor.submit(self._update_file, self.project_identifier, ts_file, files_info) + futures.append(future) + else: + self._update_file(self.project_identifier, ts_file, files_info) + + # This blocks until all futures are complete and will also throw any exception + for future in futures: + future.result() -files = [ ["AddonManager.ts", "/Mod/AddonManager/Resources/translations/AddonManager.ts"], - ["Arch.ts", "/Mod/Arch/Resources/translations/Arch.ts"], - ["Assembly.ts", "/Mod/Assembly/Gui/Resources/translations/Assembly.ts"], - ["draft.ts", "/Mod/Draft/Resources/translations/Draft.ts"], - ["Drawing.ts", "/Mod/Drawing/Gui/Resources/translations/Drawing.ts"], - ["Fem.ts", "/Mod/Fem/Gui/Resources/translations/Fem.ts"], - ["FreeCAD.ts", "/Gui/Language/FreeCAD.ts"], - ["Image.ts", "/Mod/Image/Gui/Resources/translations/Image.ts"], - ["Mesh.ts", "/Mod/Mesh/Gui/Resources/translations/Mesh.ts"], - ["MeshPart.ts", "/Mod/MeshPart/Gui/Resources/translations/MeshPart.ts"], - ["OpenSCAD.ts", "/Mod/OpenSCAD/Resources/translations/OpenSCAD.ts"], - ["Part.ts", "/Mod/Part/Gui/Resources/translations/Part.ts"], - ["PartDesign.ts", "/Mod/PartDesign/Gui/Resources/translations/PartDesign.ts"], - ["Plot.ts", "/Mod/Plot/resources/translations/Plot.ts"], - ["Points.ts", "/Mod/Points/Gui/Resources/translations/Points.ts"], - ["Raytracing.ts", "/Mod/Raytracing/Gui/Resources/translations/Raytracing.ts"], - ["ReverseEngineering.ts","/Mod/ReverseEngineering/Gui/Resources/translations/ReverseEngineering.ts"], - ["Robot.ts", "/Mod/Robot/Gui/Resources/translations/Robot.ts"], - ["Ship.ts", "/Mod/Ship/resources/translations/Ship.ts"], - ["Sketcher.ts", "/Mod/Sketcher/Gui/Resources/translations/Sketcher.ts"], - ["StartPage.ts", "/Mod/Start/Gui/Resources/translations/StartPage.ts"], - ["Test.ts", "/Mod/Test/Gui/Resources/translations/Test.ts"], - ["Web.ts", "/Mod/Web/Gui/Resources/translations/Web.ts"], - ["Spreadsheet.ts", "/Mod/Spreadsheet/Gui/Resources/translations/Spreadsheet.ts"], - ["Path.ts", "/Mod/Path/Gui/Resources/translations/Path.ts"], - ["Tux.ts", "/Mod/Tux/Resources/translations/Tux.ts"], - ["TechDraw.ts", "/Mod/TechDraw/Gui/Resources/translations/TechDraw.ts"], - ] - - -# handler for the command responses -class ResponseHandler( xml.sax.ContentHandler ): - - def __init__(self): - self.current = "" - self.data = "" - self.translated = 1 - self.total = 1 - - def startElement(self, tag, attributes): - self.current = tag - if tag == "file": - self.data += attributes["status"] - elif tag == "error": - self.data == "Error: " - - def endElement(self, tag): - if self.current in ["language","success","error"]: - self.data = "" - self.translated = 1 - self.total = 1 - self.current = "" - - def characters(self, content): - if self.current == "name": - self.data += content - elif self.current == "phrases": - self.total = int(content) - elif self.current == "translated": - self.translated = int(content) - pc = int((float(self.translated)/self.total)*100) - self.data += " : " + str(pc) + "%\n" - elif self.current == "message": - self.data += content - +def load_token(): + # load API token stored in ~/.crowdin-freecad-token + config_file = os.path.expanduser('~')+os.sep+".crowdin-freecad-token" + if os.path.exists(config_file): + with open(config_file) as file: + return file.read().strip() + return None if __name__ == "__main__": + command = None - # only one argument allowed - arg = sys.argv[1:] - if len(arg) != 1: - print(__doc__) + args = sys.argv[1:] + if args: + command = args[0] + + token = os.environ.get('CROWDIN_TOKEN', load_token()) + if command and not token: + print('Token not found') sys.exit() - arg = arg[0] - # getting API key stored in ~/.crowdin-freecad - configfile = os.path.expanduser("~")+os.sep+".crowdin-freecad" - if not os.path.exists(configfile): - print("Config file not found!") + project_identifier = os.environ.get('CROWDIN_PROJECT_ID') + if not project_identifier: + print('CROWDIN_PROJECT_ID env var must be set') sys.exit() - f = open(configfile) - url = "https://api.crowdin.com/api/project/freecad/" - key = "?key="+f.read().strip() - f.close() - if arg == "status": - c = pycurl.Curl() - c.setopt(pycurl.URL, url+"status"+key+"&xml") - b = StringIO.StringIO() - c.setopt(pycurl.WRITEFUNCTION, b.write) - c.perform() - c.close() - handler = ResponseHandler() - xml.sax.parseString(b.getvalue(),handler) - print(handler.data) + updater = CrowdinUpdater(token, project_identifier) - elif arg == "build": - print("Building (warning, this can be invoked only once per 30 minutes)...") - c = pycurl.Curl() - c.setopt(pycurl.URL, url+"export"+key) - b = StringIO.StringIO() - c.setopt(pycurl.WRITEFUNCTION, b.write) - c.perform() - c.close() - handler = ResponseHandler() - xml.sax.parseString(b.getvalue(),handler) - print(handler.data) + if command == "status": + status = updater.status() + for item in status: + print(f"language: {item['languageId']}") + print(f" translation progress: {item['translationProgress']}%") + print(f" approval progress: {item['approvalProgress']}%") - elif arg == "download": - print("Downloading all.zip in current directory...") - cmd = "wget -O freecad.zip "+url+"download/all.zip"+key - os.system(cmd) + elif command == "build-status": + for item in updater.build_status(): + print(f" id: {item['id']} progress: {item['progress']}% status: {item['status']}") - elif arg == "update": - basepath = os.path.dirname(os.path.abspath(".")) - for f in files: - print("Sending ",f[0],"...") - c = pycurl.Curl() - fields = [('files['+f[0]+']', (c.FORM_FILE, basepath+f[1]))] - c.setopt(pycurl.URL, url+"update-file"+key) - c.setopt(pycurl.HTTPPOST, fields) - b = StringIO.StringIO() - c.setopt(pycurl.WRITEFUNCTION, b.write) - c.perform() - c.close() - handler = ResponseHandler() - xml.sax.parseString(b.getvalue(),handler) - print(handler.data) + elif command == "build": + updater.build() + elif command == "download": + if len(args) == 2: + updater.download(args[1]) + else: + stat = updater.build_status() + if not stat: + print('no builds found') + elif len(stat) == 1: + updater.download(stat[0]['id']) + else: + print('available builds:') + for item in stat: + print(f" id: {item['id']} progress: {item['progress']}% status: {item['status']}") + print('please specify a build id') + + elif command == "update": + # Find all ts files. However, this contains the lang-specific files too. Let's drop those + all_ts_files = glob.glob('../**/*.ts', recursive=True) + # Remove the file extensions + ts_files_wo_ext = [splitext(f)[0] for f in all_ts_files] + # Filter out any file that has another file as a substring. E.g. Draft is a substring of Draft_en + main_ts_files = list(filter(lambda f: not [a for a in ts_files_wo_ext if a in f and f != a], ts_files_wo_ext)) + # Create tuples to map Crowdin name with local path name + names_and_path = [(f'{basename(f)}.ts', f'{f}.ts') for f in main_ts_files] + # Accomodate for legacy naming + ts_files = [TsFile(LEGACY_NAMING_MAP[a] if a in LEGACY_NAMING_MAP else a, b) for (a, b) in names_and_path] + + updater.update(ts_files) else: print(__doc__) From 2d9c9accdab6eaa1595e1dd6ce39b540c4ac7666 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Sun, 28 Feb 2021 23:11:52 -0600 Subject: [PATCH 006/178] [DRAFT] Remove unused loop variable LGTM is concerned about the unused loop variable in this algorithm. While there was nothing wrong here, to eliminate the alarm the loop was removed entirely, since Python allows the use of the multiplication operator here to achieve the same effect. --- src/Mod/Draft/draftguitools/gui_trimex.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Mod/Draft/draftguitools/gui_trimex.py b/src/Mod/Draft/draftguitools/gui_trimex.py index 88546b0716..47b449d641 100644 --- a/src/Mod/Draft/draftguitools/gui_trimex.py +++ b/src/Mod/Draft/draftguitools/gui_trimex.py @@ -120,8 +120,7 @@ class Trimex(gui_base_original.Modifier): self.extrudeMode = True self.ghost = [trackers.ghostTracker([self.obj])] self.normal = self.obj.Shape.Faces[0].normalAt(0.5, 0.5) - for v in self.obj.Shape.Vertexes: - self.ghost.append(trackers.lineTracker()) + self.ghost += [trackers.lineTracker()] * len(self.obj.Shape.Vertexes) elif len(self.obj.Shape.Faces) > 1: # face extrude mode, a new object is created ss = Gui.Selection.getSelectionEx()[0] @@ -132,8 +131,7 @@ class Trimex(gui_base_original.Modifier): self.extrudeMode = True self.ghost = [trackers.ghostTracker([self.obj])] self.normal = self.obj.Shape.Faces[0].normalAt(0.5, 0.5) - for v in self.obj.Shape.Vertexes: - self.ghost.append(trackers.lineTracker()) + self.ghost += [trackers.lineTracker()] * len(self.obj.Shape.Vertexes) else: # normal wire trimex mode self.color = self.obj.ViewObject.LineColor From 6640f13be16651e328dd19ae8a8d95177caddf4e Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Sun, 28 Feb 2021 23:42:14 -0600 Subject: [PATCH 007/178] [Arch] Refactor to eliminate unused variable LGTM complains about the unused variable in a loop that is really only using the variable to iterate a set number of times. This replaces that loop with a multiplication by the length of the array, eliminating the unused iteration variable and clarifying the intent of the code. --- src/Mod/Arch/exportIFC.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Arch/exportIFC.py b/src/Mod/Arch/exportIFC.py index 292655656a..3043103f40 100644 --- a/src/Mod/Arch/exportIFC.py +++ b/src/Mod/Arch/exportIFC.py @@ -2261,7 +2261,7 @@ def getRepresentation(ifcfile,context,obj,forcebrep=False,subtraction=False,tess diffusecolor = obj.ViewObject.DiffuseColor if shapecolor and (shapetype != "clone"): # cloned objects are already colored key = None - rgbt = [shapecolor+(transparency,) for shape in shapes] + rgbt = [shapecolor+(transparency,)] * len(shapes) if diffusecolor \ and (len(diffusecolor) == len(obj.Shape.Faces)) \ and (len(obj.Shape.Solids) == len(colorshapes)): From 784ee36121289f25b0b292c26cd8ccf0faeb124b Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Mon, 1 Mar 2021 09:19:20 -0600 Subject: [PATCH 008/178] [Draft] Eliminate unused loop iteration variables When creating arrays of colors, the color information is often created to be the same length as some array of objects. In three instances this was achieved with a loop over that list of objects, even though the objects themselves are never used. This commit eliminates those loops and creates the required number of color instances directly. Identified by LGTM. --- src/Mod/Draft/draftviewproviders/view_array.py | 3 +-- src/Mod/Draft/draftviewproviders/view_clone.py | 7 ++----- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/Mod/Draft/draftviewproviders/view_array.py b/src/Mod/Draft/draftviewproviders/view_array.py index c930768628..e73f6b6528 100644 --- a/src/Mod/Draft/draftviewproviders/view_array.py +++ b/src/Mod/Draft/draftviewproviders/view_array.py @@ -60,8 +60,7 @@ class ViewProviderDraftArray(ViewProviderDraft): else: c = vobj.Object.Base.ViewObject.ShapeColor c = (c[0],c[1],c[2],vobj.Object.Base.ViewObject.Transparency/100.0) - for f in vobj.Object.Base.Shape.Faces: - colors.append(c) + colors += [c] * len(vobj.Object.Base.Shape.Faces) if colors: n = 1 if hasattr(vobj.Object,"ArrayType"): diff --git a/src/Mod/Draft/draftviewproviders/view_clone.py b/src/Mod/Draft/draftviewproviders/view_clone.py index 0871309128..5b0c1ecaf7 100644 --- a/src/Mod/Draft/draftviewproviders/view_clone.py +++ b/src/Mod/Draft/draftviewproviders/view_clone.py @@ -61,9 +61,7 @@ class ViewProviderClone: else: c = o.ViewObject.ShapeColor c = (c[0],c[1],c[2],o.ViewObject.Transparency/100.0) - for f in o.Shape.Faces: # TODO: verify this line - colors.append(c) - + colors += [c] * len(o.Shape.Faces) # TODO: verify this line elif o.hasExtension("App::GeoFeatureGroupExtension"): for so in vobj.Object.Group: if so.isDerivedFrom("Part::Feature"): @@ -72,8 +70,7 @@ class ViewProviderClone: else: c = so.ViewObject.ShapeColor c = (c[0],c[1],c[2],so.ViewObject.Transparency/100.0) - for f in so.Shape.Faces: - colors.append(c) + colors += [c] * len(so.Shape.Faces) if colors: vobj.DiffuseColor = colors From b9421e27476630e21a75b233020be2c05f41c8d8 Mon Sep 17 00:00:00 2001 From: marioalexis Date: Tue, 16 Mar 2021 13:13:20 -0300 Subject: [PATCH 009/178] Draft: Make Edit closed wires consistent with open wires and tracker --- .../Draft/draftguitools/gui_edit_draft_objects.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Mod/Draft/draftguitools/gui_edit_draft_objects.py b/src/Mod/Draft/draftguitools/gui_edit_draft_objects.py index ba1dea3022..f09c902e46 100644 --- a/src/Mod/Draft/draftguitools/gui_edit_draft_objects.py +++ b/src/Mod/Draft/draftguitools/gui_edit_draft_objects.py @@ -91,12 +91,14 @@ class DraftWireGuiTools(GuiTools): App.Console.PrintMessage(_err + "\n") return - if obj.Closed: - # DNC: project the new point to the plane of the face if present - if hasattr(obj.Shape, "normalAt"): - normal = obj.Shape.normalAt(0,0) - point_on_plane = obj.Shape.Vertexes[0].Point - v.projectToPlane(point_on_plane, normal) + # TODO: Make consistent operation with trackers and open wires + # See: https://forum.freecadweb.org/viewtopic.php?f=23&t=56661 + #if obj.Closed: + # # DNC: project the new point to the plane of the face if present + # if hasattr(obj.Shape, "normalAt"): + # normal = obj.Shape.normalAt(0,0) + # point_on_plane = obj.Shape.Vertexes[0].Point + # v.projectToPlane(point_on_plane, normal) pts[node_idx] = v obj.Points = pts From 7c00d19a28556762623402913b7e680a1f2aa6b6 Mon Sep 17 00:00:00 2001 From: marioalexis Date: Sun, 7 Feb 2021 02:35:14 -0300 Subject: [PATCH 010/178] Draft: Call finish method if pressed Close button in dumb taskdialog --- src/Mod/Draft/DraftGui.py | 5 +++-- src/Mod/Draft/draftguitools/gui_clone.py | 2 +- src/Mod/Draft/draftguitools/gui_downgrade.py | 2 +- src/Mod/Draft/draftguitools/gui_draft2sketch.py | 2 +- src/Mod/Draft/draftguitools/gui_edit.py | 2 +- src/Mod/Draft/draftguitools/gui_facebinders.py | 2 +- src/Mod/Draft/draftguitools/gui_join.py | 2 +- src/Mod/Draft/draftguitools/gui_mirror.py | 2 +- src/Mod/Draft/draftguitools/gui_move.py | 2 +- src/Mod/Draft/draftguitools/gui_offset.py | 2 +- src/Mod/Draft/draftguitools/gui_rotate.py | 2 +- src/Mod/Draft/draftguitools/gui_scale.py | 2 +- src/Mod/Draft/draftguitools/gui_shape2dview.py | 2 +- src/Mod/Draft/draftguitools/gui_stretch.py | 2 +- src/Mod/Draft/draftguitools/gui_trimex.py | 2 +- src/Mod/Draft/draftguitools/gui_upgrade.py | 2 +- 16 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/Mod/Draft/DraftGui.py b/src/Mod/Draft/DraftGui.py index 4c9303c61a..ca162304fe 100644 --- a/src/Mod/Draft/DraftGui.py +++ b/src/Mod/Draft/DraftGui.py @@ -1184,11 +1184,12 @@ class DraftToolBar: def __init__(self,extra=None,callback=None): if extra: self.form = [extra] + self.callback=callback def getStandardButtons(self): return int(QtGui.QDialogButtonBox.Close) def reject(self): - if callback: - callback() + if self.callback: + self.callback() return True FreeCADGui.Control.closeDialog() panel = TaskPanel(extra,callback) diff --git a/src/Mod/Draft/draftguitools/gui_clone.py b/src/Mod/Draft/draftguitools/gui_clone.py index 26797cefd3..e987ef7ce2 100644 --- a/src/Mod/Draft/draftguitools/gui_clone.py +++ b/src/Mod/Draft/draftguitools/gui_clone.py @@ -75,7 +75,7 @@ class Clone(gui_base_original.Modifier): super(Clone, self).Activated(name=translate("draft","Clone")) if not Gui.Selection.getSelection(): if self.ui: - self.ui.selectUi() + self.ui.selectUi(callback=self.finish) _msg(translate("draft", "Select an object to clone")) self.call = self.view.addEventCallback( "SoEvent", diff --git a/src/Mod/Draft/draftguitools/gui_downgrade.py b/src/Mod/Draft/draftguitools/gui_downgrade.py index 015717681d..15215a2ec8 100644 --- a/src/Mod/Draft/draftguitools/gui_downgrade.py +++ b/src/Mod/Draft/draftguitools/gui_downgrade.py @@ -63,7 +63,7 @@ class Downgrade(gui_base_original.Modifier): super(Downgrade, self).Activated(name=translate("draft","Downgrade")) if self.ui: if not Gui.Selection.getSelection(): - self.ui.selectUi() + self.ui.selectUi(callback=self.finish) _msg(translate("draft", "Select an object to upgrade")) self.call = self.view.addEventCallback( "SoEvent", diff --git a/src/Mod/Draft/draftguitools/gui_draft2sketch.py b/src/Mod/Draft/draftguitools/gui_draft2sketch.py index 2759e6e0ff..7087b6d826 100644 --- a/src/Mod/Draft/draftguitools/gui_draft2sketch.py +++ b/src/Mod/Draft/draftguitools/gui_draft2sketch.py @@ -62,7 +62,7 @@ class Draft2Sketch(gui_base_original.Modifier): super(Draft2Sketch, self).Activated(name=translate("draft","Convert Draft/Sketch")) if not Gui.Selection.getSelection(): if self.ui: - self.ui.selectUi() + self.ui.selectUi(callback=self.finish) _msg(translate("draft", "Select an object to convert.")) self.call = self.view.addEventCallback( "SoEvent", diff --git a/src/Mod/Draft/draftguitools/gui_edit.py b/src/Mod/Draft/draftguitools/gui_edit.py index 5dbac65bef..4f4a6e3868 100644 --- a/src/Mod/Draft/draftguitools/gui_edit.py +++ b/src/Mod/Draft/draftguitools/gui_edit.py @@ -300,7 +300,7 @@ class Edit(gui_base_original.Modifier): if Gui.Selection.getSelection(): self.proceed() else: - self.ui.selectUi() + self.ui.selectUi(callback=self.finish) App.Console.PrintMessage(translate("draft", "Select a Draft object to edit") + "\n") diff --git a/src/Mod/Draft/draftguitools/gui_facebinders.py b/src/Mod/Draft/draftguitools/gui_facebinders.py index 7a8bf83f0c..2b71842f03 100644 --- a/src/Mod/Draft/draftguitools/gui_facebinders.py +++ b/src/Mod/Draft/draftguitools/gui_facebinders.py @@ -67,7 +67,7 @@ class Facebinder(gui_base_original.Creator): if not Gui.Selection.getSelection(): if self.ui: - self.ui.selectUi() + self.ui.selectUi(callback=self.finish) _msg(translate("draft", "Select faces from existing objects")) self.call = self.view.addEventCallback( "SoEvent", diff --git a/src/Mod/Draft/draftguitools/gui_join.py b/src/Mod/Draft/draftguitools/gui_join.py index ce2b6a4119..45372462f5 100644 --- a/src/Mod/Draft/draftguitools/gui_join.py +++ b/src/Mod/Draft/draftguitools/gui_join.py @@ -72,7 +72,7 @@ class Join(gui_base_original.Modifier): if not self.ui: return if not Gui.Selection.getSelection(): - self.ui.selectUi() + self.ui.selectUi(callback=self.finish) _msg(translate("draft", "Select an object to join")) self.call = self.view.addEventCallback( "SoEvent", diff --git a/src/Mod/Draft/draftguitools/gui_mirror.py b/src/Mod/Draft/draftguitools/gui_mirror.py index 18afa9c9f7..f3951fe256 100644 --- a/src/Mod/Draft/draftguitools/gui_mirror.py +++ b/src/Mod/Draft/draftguitools/gui_mirror.py @@ -70,7 +70,7 @@ class Mirror(gui_base_original.Modifier): self.ghost = None if self.ui: if not Gui.Selection.getSelection(): - self.ui.selectUi() + self.ui.selectUi(callback=self.finish) _msg(translate("draft", "Select an object to mirror")) self.call = \ self.view.addEventCallback("SoEvent", diff --git a/src/Mod/Draft/draftguitools/gui_move.py b/src/Mod/Draft/draftguitools/gui_move.py index ccccbd5876..f8edf8e778 100644 --- a/src/Mod/Draft/draftguitools/gui_move.py +++ b/src/Mod/Draft/draftguitools/gui_move.py @@ -78,7 +78,7 @@ class Move(gui_base_original.Modifier): """Get the object selection.""" if Gui.Selection.getSelectionEx(): return self.proceed() - self.ui.selectUi() + self.ui.selectUi(callback=self.finish) _msg(translate("draft", "Select an object to move")) self.call = \ self.view.addEventCallback("SoEvent", gui_tool_utils.selectObject) diff --git a/src/Mod/Draft/draftguitools/gui_offset.py b/src/Mod/Draft/draftguitools/gui_offset.py index 50f8c928f4..b1d34bd3f2 100644 --- a/src/Mod/Draft/draftguitools/gui_offset.py +++ b/src/Mod/Draft/draftguitools/gui_offset.py @@ -72,7 +72,7 @@ class Offset(gui_base_original.Modifier): self.arctrack = None if self.ui: if not Gui.Selection.getSelection(): - self.ui.selectUi() + self.ui.selectUi(callback=self.finish) _msg(translate("draft", "Select an object to offset")) self.call = self.view.addEventCallback( "SoEvent", diff --git a/src/Mod/Draft/draftguitools/gui_rotate.py b/src/Mod/Draft/draftguitools/gui_rotate.py index 0f55cc5449..e7f1438b54 100644 --- a/src/Mod/Draft/draftguitools/gui_rotate.py +++ b/src/Mod/Draft/draftguitools/gui_rotate.py @@ -75,7 +75,7 @@ class Rotate(gui_base_original.Modifier): """Get the object selection.""" if Gui.Selection.getSelection(): return self.proceed() - self.ui.selectUi() + self.ui.selectUi(callback=self.finish) _msg(translate("draft", "Select an object to rotate")) self.call = \ self.view.addEventCallback("SoEvent", gui_tool_utils.selectObject) diff --git a/src/Mod/Draft/draftguitools/gui_scale.py b/src/Mod/Draft/draftguitools/gui_scale.py index b4b689733a..5dc46b2411 100644 --- a/src/Mod/Draft/draftguitools/gui_scale.py +++ b/src/Mod/Draft/draftguitools/gui_scale.py @@ -84,7 +84,7 @@ class Scale(gui_base_original.Modifier): """Get object selection and proceed if successful.""" if Gui.Selection.getSelection(): return self.proceed() - self.ui.selectUi() + self.ui.selectUi(callback=self.finish) _msg(translate("draft", "Select an object to scale")) self.call = self.view.addEventCallback("SoEvent", gui_tool_utils.selectObject) diff --git a/src/Mod/Draft/draftguitools/gui_shape2dview.py b/src/Mod/Draft/draftguitools/gui_shape2dview.py index 52ea98e5bb..d5f7e1a80f 100644 --- a/src/Mod/Draft/draftguitools/gui_shape2dview.py +++ b/src/Mod/Draft/draftguitools/gui_shape2dview.py @@ -64,7 +64,7 @@ class Shape2DView(gui_base_original.Modifier): super(Shape2DView, self).Activated(name=translate("draft","Project 2D view")) if not Gui.Selection.getSelection(): if self.ui: - self.ui.selectUi() + self.ui.selectUi(callback=self.finish) _msg(translate("draft", "Select an object to project")) self.call = self.view.addEventCallback( "SoEvent", diff --git a/src/Mod/Draft/draftguitools/gui_stretch.py b/src/Mod/Draft/draftguitools/gui_stretch.py index 0139c067cf..4ac6860c6b 100644 --- a/src/Mod/Draft/draftguitools/gui_stretch.py +++ b/src/Mod/Draft/draftguitools/gui_stretch.py @@ -69,7 +69,7 @@ class Stretch(gui_base_original.Modifier): super(Stretch, self).Activated(name=translate("draft","Stretch")) if self.ui: if not Gui.Selection.getSelection(): - self.ui.selectUi() + self.ui.selectUi(callback=self.finish) _msg(translate("draft", "Select an object to stretch")) self.call = \ self.view.addEventCallback("SoEvent", diff --git a/src/Mod/Draft/draftguitools/gui_trimex.py b/src/Mod/Draft/draftguitools/gui_trimex.py index 88546b0716..6a54d24f71 100644 --- a/src/Mod/Draft/draftguitools/gui_trimex.py +++ b/src/Mod/Draft/draftguitools/gui_trimex.py @@ -87,7 +87,7 @@ class Trimex(gui_base_original.Modifier): self.width = None if self.ui: if not Gui.Selection.getSelection(): - self.ui.selectUi() + self.ui.selectUi(callback=self.finish) _msg(translate("draft", "Select objects to trim or extend")) self.call = \ self.view.addEventCallback("SoEvent", diff --git a/src/Mod/Draft/draftguitools/gui_upgrade.py b/src/Mod/Draft/draftguitools/gui_upgrade.py index fbab4fa431..9137bb99c3 100644 --- a/src/Mod/Draft/draftguitools/gui_upgrade.py +++ b/src/Mod/Draft/draftguitools/gui_upgrade.py @@ -63,7 +63,7 @@ class Upgrade(gui_base_original.Modifier): super(Upgrade, self).Activated(name=translate("draft","Upgrade")) if self.ui: if not Gui.Selection.getSelection(): - self.ui.selectUi() + self.ui.selectUi(callback=self.finish) _msg(translate("draft", "Select an object to upgrade")) self.call = self.view.addEventCallback( "SoEvent", From 7a54edb33a53250d2878c880ac2d8640b27574ab Mon Sep 17 00:00:00 2001 From: marioalexis Date: Sun, 7 Feb 2021 14:04:35 -0300 Subject: [PATCH 011/178] Draft: Set reject method for working plane task dialog --- src/Mod/Draft/draftguitools/gui_selectplane.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Mod/Draft/draftguitools/gui_selectplane.py b/src/Mod/Draft/draftguitools/gui_selectplane.py index 0f02e484c3..3c309ae928 100644 --- a/src/Mod/Draft/draftguitools/gui_selectplane.py +++ b/src/Mod/Draft/draftguitools/gui_selectplane.py @@ -91,6 +91,7 @@ class Draft_SelectPlane: # Create task panel FreeCADGui.Control.closeDialog() self.taskd = task_selectplane.SelectPlaneTaskPanel() + self.taskd.reject = self.reject # Fill values self.taskd.form.checkCenter.setChecked(self.param.GetBool("CenterPlaneOnView", False)) From 6795e0d7e6961de5f82de6c775f0ba41342ec151 Mon Sep 17 00:00:00 2001 From: marioalexis Date: Sun, 7 Feb 2021 19:50:49 -0300 Subject: [PATCH 012/178] Draft: Change selectUi and makeDumbTask argument named 'callback' to 'on_close_call' Suggested by user @carlopav --- src/Mod/Draft/DraftGui.py | 12 ++++++------ src/Mod/Draft/draftguitools/gui_clone.py | 2 +- src/Mod/Draft/draftguitools/gui_downgrade.py | 2 +- src/Mod/Draft/draftguitools/gui_draft2sketch.py | 2 +- src/Mod/Draft/draftguitools/gui_edit.py | 2 +- src/Mod/Draft/draftguitools/gui_facebinders.py | 2 +- src/Mod/Draft/draftguitools/gui_join.py | 2 +- src/Mod/Draft/draftguitools/gui_mirror.py | 2 +- src/Mod/Draft/draftguitools/gui_move.py | 2 +- src/Mod/Draft/draftguitools/gui_offset.py | 2 +- src/Mod/Draft/draftguitools/gui_rotate.py | 2 +- src/Mod/Draft/draftguitools/gui_scale.py | 2 +- src/Mod/Draft/draftguitools/gui_shape2dview.py | 2 +- src/Mod/Draft/draftguitools/gui_stretch.py | 2 +- src/Mod/Draft/draftguitools/gui_trimex.py | 2 +- src/Mod/Draft/draftguitools/gui_upgrade.py | 2 +- 16 files changed, 21 insertions(+), 21 deletions(-) diff --git a/src/Mod/Draft/DraftGui.py b/src/Mod/Draft/DraftGui.py index ca162304fe..b5ee10f571 100644 --- a/src/Mod/Draft/DraftGui.py +++ b/src/Mod/Draft/DraftGui.py @@ -1061,12 +1061,12 @@ class DraftToolBar: else: # self.taskmode == 0 Draft toolbar is obsolete and has been disabled (February 2020) self.cmdlabel.setText(title) - def selectUi(self,extra=None,callback=None): + def selectUi(self,extra=None, on_close_call=None): if not self.taskmode: # self.taskmode == 0 Draft toolbar is obsolete and has been disabled (February 2020) self.labelx.setText(translate("draft", "Pick Object")) self.labelx.show() - self.makeDumbTask(extra,callback) + self.makeDumbTask(extra, on_close_call) def editUi(self, mode=None): self.lastMode=mode @@ -1178,13 +1178,13 @@ class DraftToolBar: else: self.layout.setDirection(QtGui.QBoxLayout.LeftToRight) - def makeDumbTask(self,extra=None,callback=None): + def makeDumbTask(self, extra=None, on_close_call=None): """create a dumb taskdialog to prevent deleting the temp object""" class TaskPanel: - def __init__(self,extra=None,callback=None): + def __init__(self, extra=None, callback=None): if extra: self.form = [extra] - self.callback=callback + self.callback = callback def getStandardButtons(self): return int(QtGui.QDialogButtonBox.Close) def reject(self): @@ -1192,7 +1192,7 @@ class DraftToolBar: self.callback() return True FreeCADGui.Control.closeDialog() - panel = TaskPanel(extra,callback) + panel = TaskPanel(extra, on_close_call) FreeCADGui.Control.showDialog(panel) diff --git a/src/Mod/Draft/draftguitools/gui_clone.py b/src/Mod/Draft/draftguitools/gui_clone.py index e987ef7ce2..b65329aae0 100644 --- a/src/Mod/Draft/draftguitools/gui_clone.py +++ b/src/Mod/Draft/draftguitools/gui_clone.py @@ -75,7 +75,7 @@ class Clone(gui_base_original.Modifier): super(Clone, self).Activated(name=translate("draft","Clone")) if not Gui.Selection.getSelection(): if self.ui: - self.ui.selectUi(callback=self.finish) + self.ui.selectUi(on_close_call=self.finish) _msg(translate("draft", "Select an object to clone")) self.call = self.view.addEventCallback( "SoEvent", diff --git a/src/Mod/Draft/draftguitools/gui_downgrade.py b/src/Mod/Draft/draftguitools/gui_downgrade.py index 15215a2ec8..6cf612739a 100644 --- a/src/Mod/Draft/draftguitools/gui_downgrade.py +++ b/src/Mod/Draft/draftguitools/gui_downgrade.py @@ -63,7 +63,7 @@ class Downgrade(gui_base_original.Modifier): super(Downgrade, self).Activated(name=translate("draft","Downgrade")) if self.ui: if not Gui.Selection.getSelection(): - self.ui.selectUi(callback=self.finish) + self.ui.selectUi(on_close_call=self.finish) _msg(translate("draft", "Select an object to upgrade")) self.call = self.view.addEventCallback( "SoEvent", diff --git a/src/Mod/Draft/draftguitools/gui_draft2sketch.py b/src/Mod/Draft/draftguitools/gui_draft2sketch.py index 7087b6d826..bb8efc8855 100644 --- a/src/Mod/Draft/draftguitools/gui_draft2sketch.py +++ b/src/Mod/Draft/draftguitools/gui_draft2sketch.py @@ -62,7 +62,7 @@ class Draft2Sketch(gui_base_original.Modifier): super(Draft2Sketch, self).Activated(name=translate("draft","Convert Draft/Sketch")) if not Gui.Selection.getSelection(): if self.ui: - self.ui.selectUi(callback=self.finish) + self.ui.selectUi(on_close_call=self.finish) _msg(translate("draft", "Select an object to convert.")) self.call = self.view.addEventCallback( "SoEvent", diff --git a/src/Mod/Draft/draftguitools/gui_edit.py b/src/Mod/Draft/draftguitools/gui_edit.py index 4f4a6e3868..612d217444 100644 --- a/src/Mod/Draft/draftguitools/gui_edit.py +++ b/src/Mod/Draft/draftguitools/gui_edit.py @@ -300,7 +300,7 @@ class Edit(gui_base_original.Modifier): if Gui.Selection.getSelection(): self.proceed() else: - self.ui.selectUi(callback=self.finish) + self.ui.selectUi(on_close_call=self.finish) App.Console.PrintMessage(translate("draft", "Select a Draft object to edit") + "\n") diff --git a/src/Mod/Draft/draftguitools/gui_facebinders.py b/src/Mod/Draft/draftguitools/gui_facebinders.py index 2b71842f03..a0aa1a5ef5 100644 --- a/src/Mod/Draft/draftguitools/gui_facebinders.py +++ b/src/Mod/Draft/draftguitools/gui_facebinders.py @@ -67,7 +67,7 @@ class Facebinder(gui_base_original.Creator): if not Gui.Selection.getSelection(): if self.ui: - self.ui.selectUi(callback=self.finish) + self.ui.selectUi(on_close_call=self.finish) _msg(translate("draft", "Select faces from existing objects")) self.call = self.view.addEventCallback( "SoEvent", diff --git a/src/Mod/Draft/draftguitools/gui_join.py b/src/Mod/Draft/draftguitools/gui_join.py index 45372462f5..d9e9d716e4 100644 --- a/src/Mod/Draft/draftguitools/gui_join.py +++ b/src/Mod/Draft/draftguitools/gui_join.py @@ -72,7 +72,7 @@ class Join(gui_base_original.Modifier): if not self.ui: return if not Gui.Selection.getSelection(): - self.ui.selectUi(callback=self.finish) + self.ui.selectUi(on_close_call=self.finish) _msg(translate("draft", "Select an object to join")) self.call = self.view.addEventCallback( "SoEvent", diff --git a/src/Mod/Draft/draftguitools/gui_mirror.py b/src/Mod/Draft/draftguitools/gui_mirror.py index f3951fe256..7969bbb6a6 100644 --- a/src/Mod/Draft/draftguitools/gui_mirror.py +++ b/src/Mod/Draft/draftguitools/gui_mirror.py @@ -70,7 +70,7 @@ class Mirror(gui_base_original.Modifier): self.ghost = None if self.ui: if not Gui.Selection.getSelection(): - self.ui.selectUi(callback=self.finish) + self.ui.selectUi(on_close_call=self.finish) _msg(translate("draft", "Select an object to mirror")) self.call = \ self.view.addEventCallback("SoEvent", diff --git a/src/Mod/Draft/draftguitools/gui_move.py b/src/Mod/Draft/draftguitools/gui_move.py index f8edf8e778..7475db2d8e 100644 --- a/src/Mod/Draft/draftguitools/gui_move.py +++ b/src/Mod/Draft/draftguitools/gui_move.py @@ -78,7 +78,7 @@ class Move(gui_base_original.Modifier): """Get the object selection.""" if Gui.Selection.getSelectionEx(): return self.proceed() - self.ui.selectUi(callback=self.finish) + self.ui.selectUi(on_close_call=self.finish) _msg(translate("draft", "Select an object to move")) self.call = \ self.view.addEventCallback("SoEvent", gui_tool_utils.selectObject) diff --git a/src/Mod/Draft/draftguitools/gui_offset.py b/src/Mod/Draft/draftguitools/gui_offset.py index b1d34bd3f2..466a64b6c2 100644 --- a/src/Mod/Draft/draftguitools/gui_offset.py +++ b/src/Mod/Draft/draftguitools/gui_offset.py @@ -72,7 +72,7 @@ class Offset(gui_base_original.Modifier): self.arctrack = None if self.ui: if not Gui.Selection.getSelection(): - self.ui.selectUi(callback=self.finish) + self.ui.selectUi(on_close_call=self.finish) _msg(translate("draft", "Select an object to offset")) self.call = self.view.addEventCallback( "SoEvent", diff --git a/src/Mod/Draft/draftguitools/gui_rotate.py b/src/Mod/Draft/draftguitools/gui_rotate.py index e7f1438b54..23ad2beb73 100644 --- a/src/Mod/Draft/draftguitools/gui_rotate.py +++ b/src/Mod/Draft/draftguitools/gui_rotate.py @@ -75,7 +75,7 @@ class Rotate(gui_base_original.Modifier): """Get the object selection.""" if Gui.Selection.getSelection(): return self.proceed() - self.ui.selectUi(callback=self.finish) + self.ui.selectUi(on_close_call=self.finish) _msg(translate("draft", "Select an object to rotate")) self.call = \ self.view.addEventCallback("SoEvent", gui_tool_utils.selectObject) diff --git a/src/Mod/Draft/draftguitools/gui_scale.py b/src/Mod/Draft/draftguitools/gui_scale.py index 5dc46b2411..46402f7401 100644 --- a/src/Mod/Draft/draftguitools/gui_scale.py +++ b/src/Mod/Draft/draftguitools/gui_scale.py @@ -84,7 +84,7 @@ class Scale(gui_base_original.Modifier): """Get object selection and proceed if successful.""" if Gui.Selection.getSelection(): return self.proceed() - self.ui.selectUi(callback=self.finish) + self.ui.selectUi(on_close_call=self.finish) _msg(translate("draft", "Select an object to scale")) self.call = self.view.addEventCallback("SoEvent", gui_tool_utils.selectObject) diff --git a/src/Mod/Draft/draftguitools/gui_shape2dview.py b/src/Mod/Draft/draftguitools/gui_shape2dview.py index d5f7e1a80f..90b57b2934 100644 --- a/src/Mod/Draft/draftguitools/gui_shape2dview.py +++ b/src/Mod/Draft/draftguitools/gui_shape2dview.py @@ -64,7 +64,7 @@ class Shape2DView(gui_base_original.Modifier): super(Shape2DView, self).Activated(name=translate("draft","Project 2D view")) if not Gui.Selection.getSelection(): if self.ui: - self.ui.selectUi(callback=self.finish) + self.ui.selectUi(on_close_call=self.finish) _msg(translate("draft", "Select an object to project")) self.call = self.view.addEventCallback( "SoEvent", diff --git a/src/Mod/Draft/draftguitools/gui_stretch.py b/src/Mod/Draft/draftguitools/gui_stretch.py index 4ac6860c6b..b4fc8cdfff 100644 --- a/src/Mod/Draft/draftguitools/gui_stretch.py +++ b/src/Mod/Draft/draftguitools/gui_stretch.py @@ -69,7 +69,7 @@ class Stretch(gui_base_original.Modifier): super(Stretch, self).Activated(name=translate("draft","Stretch")) if self.ui: if not Gui.Selection.getSelection(): - self.ui.selectUi(callback=self.finish) + self.ui.selectUi(on_close_call=self.finish) _msg(translate("draft", "Select an object to stretch")) self.call = \ self.view.addEventCallback("SoEvent", diff --git a/src/Mod/Draft/draftguitools/gui_trimex.py b/src/Mod/Draft/draftguitools/gui_trimex.py index 6a54d24f71..afd2a53861 100644 --- a/src/Mod/Draft/draftguitools/gui_trimex.py +++ b/src/Mod/Draft/draftguitools/gui_trimex.py @@ -87,7 +87,7 @@ class Trimex(gui_base_original.Modifier): self.width = None if self.ui: if not Gui.Selection.getSelection(): - self.ui.selectUi(callback=self.finish) + self.ui.selectUi(on_close_call=self.finish) _msg(translate("draft", "Select objects to trim or extend")) self.call = \ self.view.addEventCallback("SoEvent", diff --git a/src/Mod/Draft/draftguitools/gui_upgrade.py b/src/Mod/Draft/draftguitools/gui_upgrade.py index 9137bb99c3..cca3e74bf2 100644 --- a/src/Mod/Draft/draftguitools/gui_upgrade.py +++ b/src/Mod/Draft/draftguitools/gui_upgrade.py @@ -63,7 +63,7 @@ class Upgrade(gui_base_original.Modifier): super(Upgrade, self).Activated(name=translate("draft","Upgrade")) if self.ui: if not Gui.Selection.getSelection(): - self.ui.selectUi(callback=self.finish) + self.ui.selectUi(on_close_call=self.finish) _msg(translate("draft", "Select an object to upgrade")) self.call = self.view.addEventCallback( "SoEvent", From b5f9a80543d851e1076d56cc1a4ab0e251da79b8 Mon Sep 17 00:00:00 2001 From: marioalexis Date: Mon, 8 Feb 2021 00:10:08 -0300 Subject: [PATCH 013/178] Draft: Clear tracker attributes when finish method is executed in gui_stretch --- src/Mod/Draft/draftguitools/gui_stretch.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Mod/Draft/draftguitools/gui_stretch.py b/src/Mod/Draft/draftguitools/gui_stretch.py index b4fc8cdfff..b44480f46e 100644 --- a/src/Mod/Draft/draftguitools/gui_stretch.py +++ b/src/Mod/Draft/draftguitools/gui_stretch.py @@ -67,6 +67,8 @@ class Stretch(gui_base_original.Modifier): def Activated(self): """Execute when the command is called.""" super(Stretch, self).Activated(name=translate("draft","Stretch")) + self.rectracker = None + self.nodetracker = None if self.ui: if not Gui.Selection.getSelection(): self.ui.selectUi(on_close_call=self.finish) @@ -251,9 +253,9 @@ class Stretch(gui_base_original.Modifier): def finish(self, closed=False): """Terminate the operation of the command. and clean up.""" - if hasattr(self, "rectracker") and self.rectracker: + if self.rectracker: self.rectracker.finalize() - if hasattr(self, "nodetracker") and self.nodetracker: + if self.nodetracker: for n in self.nodetracker: n.finalize() super(Stretch, self).finish() From acbb604a16db75710523c21cbad1a0aca83144a7 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 29 Mar 2021 16:19:13 +0200 Subject: [PATCH 014/178] App: use std::wstring_convert instead of QString to encode/decode unicode/utf-8 --- src/App/Application.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/App/Application.cpp b/src/App/Application.cpp index 206767c1ae..7f0bf983d8 100644 --- a/src/App/Application.cpp +++ b/src/App/Application.cpp @@ -47,6 +47,7 @@ #ifdef FC_OS_WIN32 # include +# include #endif #if defined(FC_OS_BSD) @@ -2852,13 +2853,12 @@ void Application::ExtractUserPath() #elif defined(FC_OS_WIN32) WCHAR szPath[MAX_PATH]; + std::wstring_convert> converter; // Get the default path where we can save our documents. It seems that // 'CSIDL_MYDOCUMENTS' doesn't work on all machines, so we use 'CSIDL_PERSONAL' // which does the same. if (SUCCEEDED(SHGetFolderPathW(NULL, CSIDL_PERSONAL, NULL, 0, szPath))) { - char dest[MAX_PATH * 3]; - WideCharToMultiByte(CP_UTF8, 0, szPath, -1,dest, 256, NULL, NULL); - mConfig["UserHomePath"] = dest; + mConfig["UserHomePath"] = converter.to_bytes(szPath); } else { mConfig["UserHomePath"] = mConfig["AppHomePath"]; @@ -2900,12 +2900,10 @@ void Application::ExtractUserPath() } } - QString dataPath = QString::fromStdWString(appData.wstring()); - mConfig["UserAppData"] = dataPath.toStdString() + PATHSEP; + mConfig["UserAppData"] = converter.to_bytes(appData.wstring()) + PATHSEP; // Create the default macro directory - QString macroPath = QString::fromStdString(getUserMacroDir()); - boost::filesystem::path macroDir = macroPath.toStdWString(); + boost::filesystem::path macroDir = converter.from_bytes(getUserMacroDir()); if (!boost::filesystem::exists(macroDir) && !Py_IsInitialized()) { try { boost::filesystem::create_directories(macroDir); From 73e4e4f339b99918df7bda173129946f00967f58 Mon Sep 17 00:00:00 2001 From: donovaly Date: Sun, 28 Mar 2021 22:22:35 +0200 Subject: [PATCH 015/178] [Part] save more icons with uniform resolution - also save them as plain SVG to get rid of sometimes deprecated Inkscape-only stuff --- .../Gui/Resources/icons/PartWorkbench.svg | 217 +++---- .../Gui/Resources/icons/Part_2D_object.svg | 257 +-------- .../Gui/Resources/icons/Part_3D_object.svg | 51 +- .../Gui/Resources/icons/Part_BoxSelection.svg | 536 +++--------------- .../Part/Gui/Resources/icons/Part_Export.svg | 55 +- .../Part/Gui/Resources/icons/Part_Feature.svg | 348 ++---------- .../Resources/icons/Part_FeatureImport.svg | 382 ++----------- .../Part/Gui/Resources/icons/Part_Import.svg | 55 +- .../icons/preferences-part_design.svg | 224 ++++---- 9 files changed, 438 insertions(+), 1687 deletions(-) diff --git a/src/Mod/Part/Gui/Resources/icons/PartWorkbench.svg b/src/Mod/Part/Gui/Resources/icons/PartWorkbench.svg index 745c93470e..c9c30713b8 100644 --- a/src/Mod/Part/Gui/Resources/icons/PartWorkbench.svg +++ b/src/Mod/Part/Gui/Resources/icons/PartWorkbench.svg @@ -1,152 +1,65 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - [triplus] - - - - 2016-02-26 - http://www.freecadweb.org/wiki/index.php?title=Artwork - - - FreeCAD - - - FreeCAD/src/Mod/Part/Gui/Resources/icons/PartWorkbench.svg - - - FreeCAD LGPL2+ - - - https://www.gnu.org/copyleft/lesser.html - - - [agryson] Alexander Gryson - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + [triplus] + + + + 2016-02-26 + http://www.freecadweb.org/wiki/index.php?title=Artwork + + + FreeCAD + + + FreeCAD/src/Mod/Part/Gui/Resources/icons/PartWorkbench.svg + + + FreeCAD LGPL2+ + + + https://www.gnu.org/copyleft/lesser.html + + + [agryson] Alexander Gryson + + + + + + + + + + + + + + diff --git a/src/Mod/Part/Gui/Resources/icons/Part_2D_object.svg b/src/Mod/Part/Gui/Resources/icons/Part_2D_object.svg index ad33c01ebb..193ca7ea19 100644 --- a/src/Mod/Part/Gui/Resources/icons/Part_2D_object.svg +++ b/src/Mod/Part/Gui/Resources/icons/Part_2D_object.svg @@ -1,210 +1,38 @@ - - - - - - - + + + + + - - - + + + - - - - + + + - - - - - - + + + + + - - - - - - - + + + + + + - + - - - - + - + image/svg+xml - + @@ -234,33 +62,10 @@ - - - - - + + + + + diff --git a/src/Mod/Part/Gui/Resources/icons/Part_3D_object.svg b/src/Mod/Part/Gui/Resources/icons/Part_3D_object.svg index 362c01bb9f..148dbdc3d2 100644 --- a/src/Mod/Part/Gui/Resources/icons/Part_3D_object.svg +++ b/src/Mod/Part/Gui/Resources/icons/Part_3D_object.svg @@ -1,37 +1,32 @@ - - + - - - + + + - - + + - - - - - + + + + - - - - + + + + - + - - - image/svg+xml - - + + [wmayer] @@ -60,11 +55,11 @@ - - - - - - + + + + + + diff --git a/src/Mod/Part/Gui/Resources/icons/Part_BoxSelection.svg b/src/Mod/Part/Gui/Resources/icons/Part_BoxSelection.svg index d643f2ede8..4fbee75378 100644 --- a/src/Mod/Part/Gui/Resources/icons/Part_BoxSelection.svg +++ b/src/Mod/Part/Gui/Resources/icons/Part_BoxSelection.svg @@ -1,481 +1,107 @@ - - - - - - + + + + - - - - - - + + + - - - + + + - - - - + + + + - - - - + + + - - - + + + - - - + + + - - - - - + + + + - - - + + + - - - + + + - - - + + + - - - + + + - - - - + + + + - - - - + + + + - - - - + + + - - - - - - + + + + - - + - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - + - + image/svg+xml - + - + Mon Oct 10 13:44:52 2011 +0000 diff --git a/src/Mod/Part/Gui/Resources/icons/Part_Export.svg b/src/Mod/Part/Gui/Resources/icons/Part_Export.svg index 0ec045bb0f..dd9b510968 100644 --- a/src/Mod/Part/Gui/Resources/icons/Part_Export.svg +++ b/src/Mod/Part/Gui/Resources/icons/Part_Export.svg @@ -1,42 +1,37 @@ - - + - - + + - - + + - - + + - - - - + + + - - + + - + - - + + - - - image/svg+xml - - + + [jmaustpc] @@ -65,16 +60,16 @@ - - + + - - - + + + - - - + + + diff --git a/src/Mod/Part/Gui/Resources/icons/Part_Feature.svg b/src/Mod/Part/Gui/Resources/icons/Part_Feature.svg index 15ce49e6ee..3c5f3700f5 100644 --- a/src/Mod/Part/Gui/Resources/icons/Part_Feature.svg +++ b/src/Mod/Part/Gui/Resources/icons/Part_Feature.svg @@ -1,282 +1,42 @@ - - - - - - - + + + + + - - - + + + - - - - + + + - - - - - - + + + + + - - - - - - - + + + + + + - - - - - - - - - + + + + + - - - - + - + image/svg+xml - + @@ -306,47 +66,13 @@ - - - - - - - + + + + + + + diff --git a/src/Mod/Part/Gui/Resources/icons/Part_FeatureImport.svg b/src/Mod/Part/Gui/Resources/icons/Part_FeatureImport.svg index 7d097e52cd..8540ddbfe0 100644 --- a/src/Mod/Part/Gui/Resources/icons/Part_FeatureImport.svg +++ b/src/Mod/Part/Gui/Resources/icons/Part_FeatureImport.svg @@ -1,282 +1,42 @@ - - - - - - - + + + + + - - - + + + - - - - + + + - - - - - - + + + + + - - - - - - - + + + + + + - - - - - - - - - + + + + + - - - - + - + image/svg+xml - + @@ -306,77 +66,17 @@ - - - - - - - - - - - + + + + + + + + + + + diff --git a/src/Mod/Part/Gui/Resources/icons/Part_Import.svg b/src/Mod/Part/Gui/Resources/icons/Part_Import.svg index c04ca1c333..df4144b471 100644 --- a/src/Mod/Part/Gui/Resources/icons/Part_Import.svg +++ b/src/Mod/Part/Gui/Resources/icons/Part_Import.svg @@ -1,47 +1,42 @@ - - + - - + + - - + + - - + + - - - - + + + - - + + - + - - + + - - - image/svg+xml - + [wmayer] - Part_Import + 2011-10-10 http://www.freecadweb.org/wiki/index.php?title=Artwork @@ -64,16 +59,16 @@ - - + + - - - + + + - - - + + + diff --git a/src/Mod/Part/Gui/Resources/icons/preferences-part_design.svg b/src/Mod/Part/Gui/Resources/icons/preferences-part_design.svg index ea4f3ee70d..fdf2390716 100644 --- a/src/Mod/Part/Gui/Resources/icons/preferences-part_design.svg +++ b/src/Mod/Part/Gui/Resources/icons/preferences-part_design.svg @@ -1,110 +1,106 @@ - - + - - - + + + - - - + + + - - - + + + - - - + + + - + - - + + - - - + + + - - + + - - + + - - - + + + - - + + - - + + - - - + + + - - - + + + - - + + - - + + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - image/svg+xml - - Video Display - + + + Jakub Steiner @@ -119,7 +115,7 @@ CRT - + http://jimmac.musichall.cz/ 2011-10-10 http://www.freecadweb.org/wiki/index.php?title=Artwork @@ -141,44 +137,44 @@ - - - - - - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From b28ec0c989db63e8e4a9cb0a0898d3bb4b379ebf Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Sun, 28 Mar 2021 19:19:51 +0200 Subject: [PATCH 016/178] Sketcher: add subnodes to the right separator --- src/Mod/Sketcher/Gui/ViewProviderSketch.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp index 5dfec0e8e8..5e0472f26d 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -6742,21 +6742,21 @@ void ViewProviderSketch::createEditInventorNodes(void) edit->EditRoot->addChild(editMarkersRoot); edit->EditMarkersMaterials = new SoMaterial; edit->EditMarkersMaterials->setName("EditMarkersMaterials"); - editCurvesRoot->addChild(edit->EditMarkersMaterials); + editMarkersRoot->addChild(edit->EditMarkersMaterials); edit->EditMarkersCoordinate = new SoCoordinate3; edit->EditMarkersCoordinate->setName("EditMarkersCoordinate"); - editCurvesRoot->addChild(edit->EditMarkersCoordinate); + editMarkersRoot->addChild(edit->EditMarkersCoordinate); edit->EditMarkersDrawStyle = new SoDrawStyle; edit->EditMarkersDrawStyle->setName("EditMarkersDrawStyle"); edit->EditMarkersDrawStyle->pointSize = 8 * edit->pixelScalingFactor; - editCurvesRoot->addChild(edit->EditMarkersDrawStyle); + editMarkersRoot->addChild(edit->EditMarkersDrawStyle); edit->EditMarkerSet = new SoMarkerSet; edit->EditMarkerSet->setName("EditMarkerSet"); edit->EditMarkerSet->markerIndex = Gui::Inventor::MarkerBitmaps::getMarkerIndex("CIRCLE_LINE", edit->MarkerSize); - editCurvesRoot->addChild(edit->EditMarkerSet); + editMarkersRoot->addChild(edit->EditMarkerSet); // stuff for the edit coordinates ++++++++++++++++++++++++++++++++++++++ SoSeparator *Coordsep = new SoSeparator(); From 85e8ad36b5ffafe6f72d9c0993450cf2fe07eced Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Sun, 28 Mar 2021 19:25:55 +0200 Subject: [PATCH 017/178] Sketcher: No vertex color update (selection/preselection) after box selection ============================================================================= The issue: https://forum.freecadweb.org/viewtopic.php?f=10&t=56550#p486554 The fix: Setting the render type to Image causes the issue, but neither do I know why it is necessary to set it to Image, nor do I understand why this is causing the issue. I only know it solves the issue. --- src/Mod/Sketcher/Gui/ViewProviderSketch.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp index 5e0472f26d..5e5bf3a35c 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -948,9 +948,6 @@ bool ViewProviderSketch::mouseButtonPressed(int Button, bool pressed, const SbVe doBoxSelection(prvCursorPos, cursorPos, viewer); rubberband->setWorking(false); - //disable framebuffer drawing in viewer - const_cast(viewer)->setRenderType(Gui::View3DInventorViewer::Native); - // a redraw is required in order to clear the rubberband draw(true,false); const_cast(viewer)->redraw(); @@ -1372,7 +1369,6 @@ bool ViewProviderSketch::mouseMove(const SbVec2s &cursorPos, Gui::View3DInventor case STATUS_SKETCH_StartRubberBand: { Mode = STATUS_SKETCH_UseRubberBand; rubberband->setWorking(true); - viewer->setRenderType(Gui::View3DInventorViewer::Image); return true; } case STATUS_SKETCH_UseRubberBand: { From 12b8f10421d9f65a94a3fb0cd4ab1269723c21f5 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 29 Mar 2021 17:05:54 +0200 Subject: [PATCH 018/178] Gui: [skip ci] expose Control::showModelView() to Python --- src/Gui/TaskView/TaskDialogPython.cpp | 9 +++++++++ src/Gui/TaskView/TaskDialogPython.h | 1 + 2 files changed, 10 insertions(+) diff --git a/src/Gui/TaskView/TaskDialogPython.cpp b/src/Gui/TaskView/TaskDialogPython.cpp index 5a9cb4b864..61a0a62def 100644 --- a/src/Gui/TaskView/TaskDialogPython.cpp +++ b/src/Gui/TaskView/TaskDialogPython.cpp @@ -70,6 +70,7 @@ void ControlPy::init_type() add_varargs_method("isAllowedAlterView",&ControlPy::isAllowedAlterView,"isAllowedAlterView()"); add_varargs_method("isAllowedAlterSelection",&ControlPy::isAllowedAlterSelection,"isAllowedAlterSelection()"); add_varargs_method("showTaskView",&ControlPy::showTaskView,"showTaskView()"); + add_varargs_method("showModelView",&ControlPy::showModelView,"showModelView()"); } ControlPy::ControlPy() @@ -178,6 +179,14 @@ Py::Object ControlPy::showTaskView(const Py::Tuple& args) return Py::None(); } +Py::Object ControlPy::showModelView(const Py::Tuple& args) +{ + if (!PyArg_ParseTuple(args.ptr(), "")) + throw Py::Exception(); + Gui::Control().showModelView(); + return Py::None(); +} + // ------------------------------------------------------------------ TaskWatcherPython::TaskWatcherPython(const Py::Object& o) diff --git a/src/Gui/TaskView/TaskDialogPython.h b/src/Gui/TaskView/TaskDialogPython.h index 7222ea0f8f..71e1da1e95 100644 --- a/src/Gui/TaskView/TaskDialogPython.h +++ b/src/Gui/TaskView/TaskDialogPython.h @@ -50,6 +50,7 @@ public: Py::Object isAllowedAlterView(const Py::Tuple&); Py::Object isAllowedAlterSelection(const Py::Tuple&); Py::Object showTaskView(const Py::Tuple&); + Py::Object showModelView(const Py::Tuple&); private: static ControlPy* instance; From 54fd82b1095371ec76284a965f58c98c518296ff Mon Sep 17 00:00:00 2001 From: donovaly Date: Sun, 21 Feb 2021 06:16:09 +0100 Subject: [PATCH 019/178] [Gui] improving NaviCube fixes bug 4495 - add missing edge faces - implement a proper rotation recipe -> rotate towards the nearest possible state - add preferences settings to turn off this new rotation behavior - get rid of transparent cube faces to avoid wrong clicks, this way also remove the backfaces - to make the edge faces fit, use triangles for the corners - expose cube size setting to preferences dialog - add new button to view backside - get rid of bitmaps because as reported in https://forum.freecadweb.org/viewtopic.php?f=3&t=52118&start=20#p481781 the x y z labels are not scaled on HiDPI screens moreover they are often "in they way" when you want to click on a corner and in principle they don't provide more info since we already have the CS with the axis labels - also fix an arithmetic overflow compiler warning - also rename 2 variables --- src/Gui/DlgSettingsNavigation.cpp | 2 + src/Gui/DlgSettingsNavigation.ui | 51 ++- src/Gui/NaviCube.cpp | 565 ++++++++++++++++++++++++------ 3 files changed, 493 insertions(+), 125 deletions(-) diff --git a/src/Gui/DlgSettingsNavigation.cpp b/src/Gui/DlgSettingsNavigation.cpp index 080f3ff65f..5a56e6c09e 100644 --- a/src/Gui/DlgSettingsNavigation.cpp +++ b/src/Gui/DlgSettingsNavigation.cpp @@ -94,6 +94,7 @@ void DlgSettingsNavigation::saveSettings() ui->CheckBox_UseAutoRotation->onSave(); ui->qspinNewDocScale->onSave(); ui->prefStepByTurn->onSave(); + ui->naviCubeToNearest->onSave(); ui->prefCubeSize->onSave(); bool showNaviCube = ui->groupBoxNaviCube->isChecked(); @@ -119,6 +120,7 @@ void DlgSettingsNavigation::loadSettings() ui->CheckBox_UseAutoRotation->onRestore(); ui->qspinNewDocScale->onRestore(); ui->prefStepByTurn->onRestore(); + ui->naviCubeToNearest->onRestore(); ui->prefCubeSize->onRestore(); ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath diff --git a/src/Gui/DlgSettingsNavigation.ui b/src/Gui/DlgSettingsNavigation.ui index cb04d56aa7..0194a5f5c9 100644 --- a/src/Gui/DlgSettingsNavigation.ui +++ b/src/Gui/DlgSettingsNavigation.ui @@ -7,14 +7,14 @@ 0 0 500 - 363 + 391 Navigation - - + + Navigation cube @@ -35,6 +35,9 @@ Number of steps by turn when using arrows (default = 8 : step angle = 360/8 = 45 deg) + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + 4 @@ -108,6 +111,25 @@ + + + + Rotates to nearest possible state when clicking a cube face + + + Rotate to nearest + + + true + + + NaviRotateToNearest + + + NaviCube + + + @@ -120,6 +142,9 @@ Size of the navigation cube + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + 10 @@ -143,7 +168,7 @@ - + true @@ -333,7 +358,7 @@ Turntable: the part will be rotated around the z-axis. - + New document scale @@ -341,7 +366,7 @@ Turntable: the part will be rotated around the z-axis. - + 120 @@ -527,12 +552,12 @@ Mouse tilting is not disabled by this setting. - + - + Qt::Vertical @@ -548,6 +573,11 @@ Mouse tilting is not disabled by this setting. + + Gui::PrefSpinBox + QSpinBox +
Gui/PrefWidgets.h
+
Gui::PrefCheckBox QCheckBox @@ -564,11 +594,6 @@ Mouse tilting is not disabled by this setting.
Gui/PrefWidgets.h
1
- - Gui::PrefSpinBox - QSpinBox -
Gui/PrefWidgets.h
-
diff --git a/src/Gui/NaviCube.cpp b/src/Gui/NaviCube.cpp index fca7e374b4..46aef1748b 100644 --- a/src/Gui/NaviCube.cpp +++ b/src/Gui/NaviCube.cpp @@ -196,14 +196,14 @@ private: void setHilite(int); void initNaviCube(QtGLWidget*); - void addFace(const Vector3f&, const Vector3f&, int, int, int, int,bool flag=false); + void addFace(const Vector3f&, const Vector3f&, int, int, int, bool flag=false); - GLuint createCubeFaceTex(QtGLWidget*, float, float, const char*); + GLuint createCubeFaceTex(QtGLWidget* gl, float gap, const char* text, int shape); GLuint createButtonTex(QtGLWidget*, int); GLuint createMenuTex(QtGLWidget*, bool); void setView(float ,float ); - void rotateView(int ,float ); + void rotateView(int axis, float rotAngle, SbVec3f customAxis = SbVec3f(0, 0, 0)); QString str(char* str); char* enum2str(int); @@ -216,9 +216,21 @@ public: TEX_BOTTOM, TEX_LEFT, TEX_RIGHT, - TEX_BACK_FACE, TEX_FRONT_FACE, TEX_CORNER_FACE, + TEX_EDGE_FACE, + TEX_FRONT_TOP, + TEX_FRONT_BOTTOM, + TEX_FRONT_LEFT, + TEX_FRONT_RIGHT, + TEX_REAR_TOP, + TEX_REAR_BOTTOM, + TEX_REAR_LEFT, + TEX_REAR_RIGHT, + TEX_TOP_LEFT, + TEX_TOP_RIGHT, + TEX_BOTTOM_LEFT, + TEX_BOTTOM_RIGHT, TEX_BOTTOM_RIGHT_REAR, TEX_BOTTOM_FRONT_RIGHT, TEX_BOTTOM_LEFT_FRONT, @@ -233,12 +245,16 @@ public: TEX_ARROW_WEST, TEX_ARROW_RIGHT, TEX_ARROW_LEFT, + TEX_DOT_BACKSIDE, TEX_VIEW_MENU_ICON, TEX_VIEW_MENU_FACE }; enum { DIR_UP,DIR_RIGHT,DIR_OUT }; + enum { + SHAPE_SQUARE, SHAPE_EDGE, SHAPE_CORNER + }; Gui::View3DInventorViewer* m_View3DInventorViewer; void drawNaviCube(bool picking); @@ -252,7 +268,6 @@ public: QColor m_HiliteColor; QColor m_ButtonColor; QColor m_FrontFaceColor; - QColor m_BackFaceColor; int m_HiliteId = 0; bool m_MouseDown = false; bool m_Dragging = false; @@ -317,7 +332,6 @@ NaviCubeImplementation::NaviCubeImplementation( OnChange(*hGrp, "TextColor"); OnChange(*hGrp, "FrontColor"); - OnChange(*hGrp, "BackColor"); OnChange(*hGrp, "HiliteColor"); OnChange(*hGrp, "ButtonColor"); OnChange(*hGrp, "CubeSize"); @@ -346,15 +360,13 @@ void NaviCubeImplementation::OnChange(ParameterGrp::SubjectType &rCaller, Parame const auto & rGrp = static_cast(rCaller); if (strcmp(reason,"TextColor") == 0) { - m_TextColor.setRgba(rGrp.GetUnsigned(reason, QColor(0,0,0,255).rgba())); + m_TextColor.setRgba(rGrp.GetUnsigned(reason, QColor(0, 0, 0, 255).rgba())); } else if (strcmp(reason,"FrontColor") == 0) { - m_FrontFaceColor.setRgba(rGrp.GetUnsigned(reason, QColor(255,255,255,128).rgba())); - } else if (strcmp(reason,"BackColor") == 0) { - m_BackFaceColor.setRgba(rGrp.GetUnsigned(reason, QColor(226,233,239,128).rgba())); + m_FrontFaceColor.setRgba(rGrp.GetUnsigned(reason, QColor(226, 233, 239, 192).rgba())); } else if (strcmp(reason,"HiliteColor") == 0) { - m_HiliteColor.setRgba(rGrp.GetUnsigned(reason, QColor(170,226,255).rgba())); + m_HiliteColor.setRgba(rGrp.GetUnsigned(reason, QColor(170, 226, 255, 255).rgba())); } else if (strcmp(reason,"ButtonColor") == 0) { - m_ButtonColor.setRgba(rGrp.GetUnsigned(reason, QColor(226,233,239,128).rgba())); + m_ButtonColor.setRgba(rGrp.GetUnsigned(reason, QColor(226, 233, 239, 128).rgba())); } else if (strcmp(reason,"CubeSize") == 0) { m_CubeWidgetSize = (rGrp.GetInt(reason, 132)); } @@ -369,9 +381,17 @@ char* NaviCubeImplementation::enum2str(int e) { case TEX_BOTTOM: return "TEX_BOTTOM"; case TEX_RIGHT : return "TEX_RIGHT"; case TEX_LEFT: return "TEX_LEFT"; - case TEX_BACK_FACE: return "TEX_BACK_FACE"; case TEX_FRONT_FACE: return "TEX_FRONT_FACE"; case TEX_CORNER_FACE: return "TEX_CORNER_FACE"; + case TEX_EDGE_FACE: return "TEX_EDGE_FACE"; + case TEX_FRONT_TOP: return "TEX_FRONT_TOP"; + case TEX_FRONT_BOTTOM: return "TEX_FRONT_BOTTOM"; + case TEX_FRONT_LEFT: return "TEX_FRONT_LEFT"; + case TEX_FRONT_RIGHT: return "TEX_FRONT_RIGHT"; + case TEX_REAR_TOP: return "TEX_REAR_TOP"; + case TEX_REAR_BOTTOM: return "TEX_REAR_BOTTOM"; + case TEX_REAR_LEFT: return "TEX_REAR_LEFT"; + case TEX_REAR_RIGHT: return "TEX_REAR_RIGHT"; case TEX_BOTTOM_RIGHT_REAR: return "TEX_BOTTOM_RIGHT_REAR"; case TEX_BOTTOM_FRONT_RIGHT: return "TEX_BOTTOM_FRONT_RIGHT"; case TEX_BOTTOM_LEFT_FRONT: return "TEX_BOTTOM_LEFT_FRONT"; @@ -386,18 +406,19 @@ char* NaviCubeImplementation::enum2str(int e) { case TEX_ARROW_WEST: return "TEX_ARROW_WEST"; case TEX_ARROW_RIGHT: return "TEX_ARROW_RIGHT"; case TEX_ARROW_LEFT: return "TEX_ARROW_LEFT"; + case TEX_DOT_BACKSIDE: return "TEX_DOT_BACKSIDE"; case TEX_VIEW_MENU_ICON : return "TEX_VIEW_MENU_ICON"; case TEX_VIEW_MENU_FACE: return "TEX_VIEW_MENU"; } } -GLuint NaviCubeImplementation::createCubeFaceTex(QtGLWidget* gl, float gap, float radius, const char* text) { +GLuint NaviCubeImplementation::createCubeFaceTex(QtGLWidget* gl, float gap, const char* text, int shape) { int texSize = m_CubeWidgetSize * m_OverSample; - int gapi = texSize * gap; - int radiusi = texSize * radius; + float gapi = texSize * gap; QImage image(texSize, texSize, QImage::Format_ARGB32); image.fill(qRgba(255, 255, 255, 0)); QPainter paint; + QPen pen(Qt::black, 10); paint.begin(&image); if (text) { @@ -423,10 +444,31 @@ GLuint NaviCubeImplementation::createCubeFaceTex(QtGLWidget* gl, float gap, floa paint.setFont(sansFont); paint.drawText(QRect(0, 0, texSize, texSize), Qt::AlignCenter,qApp->translate("Gui::NaviCube",text)); } - else { - QPainterPath path; - path.addRoundedRect(QRectF(gapi, gapi, texSize - 2 * gapi, texSize - 2 * gapi), radiusi, radiusi); - paint.fillPath(path, Qt::white); + else if (shape == SHAPE_SQUARE) { + QPainterPath pathSquare; + pathSquare.addRect(QRectF(gapi, gapi, (qreal)texSize - 2.0 * gapi, (qreal)texSize - 2.0 * gapi)); + paint.fillPath(pathSquare, Qt::white); + paint.setPen(pen); + paint.drawPath(pathSquare); + } + else if (shape == SHAPE_CORNER) { + QPainterPath pathCorner; + QRectF rectCorner = QRectF(3.46 * gapi, 3.31 * gapi, sqrt(2) * gapi, 1.3 * gapi); + pathCorner.moveTo(rectCorner.left() + (rectCorner.width() / 2), rectCorner.top()); + pathCorner.lineTo(rectCorner.bottomLeft()); + pathCorner.lineTo(rectCorner.bottomRight()); + pathCorner.lineTo(rectCorner.left() + (rectCorner.width() / 2), rectCorner.top()); + paint.fillPath(pathCorner, Qt::white); + paint.setPen(pen); + paint.drawPath(pathCorner); + } + else if (shape == SHAPE_EDGE) { + QPainterPath pathEdge; + // sice the gap is 0.12, the rect must be geometriclly shifted up with a factor + pathEdge.addRect(QRectF(gapi, 3.46 * gapi, (qreal)texSize - 2.0 * gapi, sqrt(2) * gapi)); + paint.fillPath(pathEdge, Qt::white); + paint.setPen(pen); + paint.drawPath(pathEdge); } paint.end(); @@ -527,6 +569,10 @@ GLuint NaviCubeImplementation::createButtonTex(QtGLWidget* gl, int button) { path.lineTo(-as1,-1 + as1); break; } + case TEX_DOT_BACKSIDE: { + path.arcTo(QRectF(1 - as1, -1, as1, as1), 0, 360); + break; + } } painter.fillPath(path, Qt::white); @@ -621,9 +667,7 @@ GLuint NaviCubeImplementation::createMenuTex(QtGLWidget* gl, bool forPicking) { #endif } - - -void NaviCubeImplementation::addFace(const Vector3f& x, const Vector3f& z, int frontTex, int backTex, int pickTex, int pickId,bool text) { +void NaviCubeImplementation::addFace(const Vector3f& x, const Vector3f& z, int frontTex, int pickTex, int pickId, bool text) { Vector3f y = x.cross(-z); y = y / y.norm() * x.norm(); @@ -638,12 +682,11 @@ void NaviCubeImplementation::addFace(const Vector3f& x, const Vector3f& z, int f m_VertexArray.push_back(z - x + y); m_TextureCoordArray.emplace_back(0, 1); - // TEX_TOP, TEX_BACK_FACE, TEX_FRONT_FACE, TEX_TOP + // TEX_TOP, TEX_FRONT_FACE, TEX_TOP // TEX_TOP frontTex, - // TEX_BACK_FACE backTex // TEX_FRONT_FACE pickTex, // TEX_TOP pickId - Face* ff = new Face( + Face* FaceFront = new Face( m_IndexArray.size(), 4, m_Textures[pickTex], @@ -651,10 +694,10 @@ void NaviCubeImplementation::addFace(const Vector3f& x, const Vector3f& z, int f m_Textures[pickTex], m_FrontFaceColor, 1); - m_Faces.push_back(ff); + m_Faces.push_back(FaceFront); if (text) { - Face* ft = new Face( + Face* FaceText = new Face( m_IndexArray.size(), 4, m_Textures[frontTex], @@ -662,27 +705,12 @@ void NaviCubeImplementation::addFace(const Vector3f& x, const Vector3f& z, int f m_Textures[pickTex], m_TextColor, 2); - m_Faces.push_back(ft); + m_Faces.push_back(FaceText); } for (int i = 0; i < 4; i++) m_IndexArray.push_back(t + i); - - Face* bf = new Face( - m_IndexArray.size(), - 4, - m_Textures[backTex], - pickId, - m_Textures[backTex], - m_BackFaceColor, - 0 - ); - - m_Faces.push_back(bf); - - for (int i = 0; i < 4; i++) - m_IndexArray.push_back(t + 4 - 1 - i); } void NaviCubeImplementation::initNaviCube(QtGLWidget* gl) { @@ -698,6 +726,11 @@ void NaviCubeImplementation::initNaviCube(QtGLWidget* gl) { 0, cs, -sn, 0, sn, cs; + Matrix3f r90y; + r90y << cs, 0, sn, + 0, 1, 0, + -sn, 0, cs; + Matrix3f r90z; r90z << cs, sn, 0, -sn, cs, 0, @@ -705,20 +738,19 @@ void NaviCubeImplementation::initNaviCube(QtGLWidget* gl) { cs = cos(45 * M_PI / 180); sn = sin(45 * M_PI / 180); + Matrix3f r45x; + r45x << 1, 0, 0, + 0, cs, -sn, + 0, sn, cs; + Matrix3f r45z; r45z << cs, sn, 0, -sn, cs, 0, 0, 0, 1; - cs = cos(atan(sqrt(2.0))); - sn = sin(atan(sqrt(2.0))); - Matrix3f r45x; - r45x << 1, 0, 0, - 0, cs, -sn, - 0, sn, cs; - - m_Textures[TEX_CORNER_FACE] = createCubeFaceTex(gl, 0, 0.5f, NULL); - m_Textures[TEX_BACK_FACE] = createCubeFaceTex(gl, 0.02f, 0.3f, NULL); + // first create front and backside of faces + float gap = 0.12f; + m_Textures[TEX_FRONT_FACE] = createCubeFaceTex(gl, gap, NULL, SHAPE_SQUARE); vector labels = NaviCubeImplementation::m_labels; @@ -732,81 +764,123 @@ void NaviCubeImplementation::initNaviCube(QtGLWidget* gl) { labels.push_back(hGrp->GetASCII("TextRight", "RIGHT")); labels.push_back(hGrp->GetASCII("TextLeft", "LEFT")); } + // create the main faces + m_Textures[TEX_FRONT] = createCubeFaceTex(gl, gap, labels[0].c_str(), SHAPE_SQUARE); + m_Textures[TEX_REAR] = createCubeFaceTex(gl, gap, labels[1].c_str(), SHAPE_SQUARE); + m_Textures[TEX_TOP] = createCubeFaceTex(gl, gap, labels[2].c_str(), SHAPE_SQUARE); + m_Textures[TEX_BOTTOM] = createCubeFaceTex(gl, gap, labels[3].c_str(), SHAPE_SQUARE); + m_Textures[TEX_RIGHT] = createCubeFaceTex(gl, gap, labels[4].c_str(), SHAPE_SQUARE); + m_Textures[TEX_LEFT] = createCubeFaceTex(gl, gap, labels[5].c_str(), SHAPE_SQUARE); - float gap = 0.12f; - float radius = 0.12f; - - m_Textures[TEX_FRONT] = createCubeFaceTex(gl, gap, radius, labels[0].c_str()); - m_Textures[TEX_REAR] = createCubeFaceTex(gl, gap, radius, labels[1].c_str()); - m_Textures[TEX_TOP] = createCubeFaceTex(gl, gap, radius, labels[2].c_str()); - m_Textures[TEX_BOTTOM] = createCubeFaceTex(gl, gap, radius, labels[3].c_str()); - m_Textures[TEX_RIGHT] = createCubeFaceTex(gl, gap, radius, labels[4].c_str()); - m_Textures[TEX_LEFT] = createCubeFaceTex(gl, gap, radius, labels[5].c_str()); - - m_Textures[TEX_FRONT_FACE] = createCubeFaceTex(gl, gap, radius, NULL); - + // create the arrows m_Textures[TEX_ARROW_NORTH] = createButtonTex(gl, TEX_ARROW_NORTH); m_Textures[TEX_ARROW_SOUTH] = createButtonTex(gl, TEX_ARROW_SOUTH); m_Textures[TEX_ARROW_EAST] = createButtonTex(gl, TEX_ARROW_EAST); m_Textures[TEX_ARROW_WEST] = createButtonTex(gl, TEX_ARROW_WEST); m_Textures[TEX_ARROW_LEFT] = createButtonTex(gl, TEX_ARROW_LEFT); m_Textures[TEX_ARROW_RIGHT] = createButtonTex(gl, TEX_ARROW_RIGHT); + m_Textures[TEX_DOT_BACKSIDE] = createButtonTex(gl, TEX_DOT_BACKSIDE); m_Textures[TEX_VIEW_MENU_ICON] = createMenuTex(gl, false); m_Textures[TEX_VIEW_MENU_FACE] = createMenuTex(gl, true); // front,back,pick,pickid - addFace(x, z, TEX_TOP, TEX_BACK_FACE, TEX_FRONT_FACE, TEX_TOP,true); + addFace(x, z, TEX_TOP, TEX_FRONT_FACE, TEX_TOP, true); x = r90x * x; z = r90x * z; - addFace(x, z, TEX_FRONT, TEX_BACK_FACE, TEX_FRONT_FACE, TEX_FRONT,true); + addFace(x, z, TEX_FRONT, TEX_FRONT_FACE, TEX_FRONT, true); x = r90z * x; z = r90z * z; - addFace(x, z, TEX_LEFT, TEX_BACK_FACE, TEX_FRONT_FACE, TEX_LEFT,true); + addFace(x, z, TEX_LEFT, TEX_FRONT_FACE, TEX_LEFT, true); x = r90z * x; z = r90z * z; - addFace(x, z, TEX_REAR, TEX_BACK_FACE, TEX_FRONT_FACE, TEX_REAR,true); + addFace(x, z, TEX_REAR, TEX_FRONT_FACE, TEX_REAR, true); x = r90z * x; z = r90z * z; - addFace(x, z, TEX_RIGHT, TEX_BACK_FACE, TEX_FRONT_FACE, TEX_RIGHT,true); + addFace(x, z, TEX_RIGHT, TEX_FRONT_FACE, TEX_RIGHT, true); x = r90x * r90z * x; z = r90x * r90z * z; - addFace(x, z, TEX_BOTTOM, TEX_BACK_FACE, TEX_FRONT_FACE, TEX_BOTTOM,true); + addFace(x, z, TEX_BOTTOM, TEX_FRONT_FACE, TEX_BOTTOM, true); - z = r45z * r45x * z; - x = r45z * r45x * x; + // add corner faces + m_Textures[TEX_CORNER_FACE] = createCubeFaceTex(gl, gap, NULL, SHAPE_CORNER); + // we need to rotate to the edge, thus matrix for rotation angle of 54.7 deg + cs = cos(atan(sqrt(2.0))); + sn = sin(atan(sqrt(2.0))); + Matrix3f r54x; + r54x << 1, 0, 0, + 0, cs, -sn, + 0, sn, cs; - x *= 0.23f; // corner face size - z *= 1.43f; // corner face position - - addFace(x, z, TEX_CORNER_FACE, TEX_CORNER_FACE, TEX_CORNER_FACE, TEX_BOTTOM_RIGHT_REAR); + z = r45z * r54x * z; + x = r45z * r54x * x; + z *= 1.46f; // corner face position + addFace(x, z, TEX_CORNER_FACE, TEX_CORNER_FACE, TEX_BOTTOM_RIGHT_REAR); x = r90z * x; z = r90z * z; - addFace(x, z, TEX_CORNER_FACE, TEX_CORNER_FACE, TEX_CORNER_FACE, TEX_BOTTOM_FRONT_RIGHT); - + addFace(x, z, TEX_CORNER_FACE, TEX_CORNER_FACE, TEX_BOTTOM_FRONT_RIGHT); x = r90z * x; z = r90z * z; - addFace(x, z, TEX_CORNER_FACE, TEX_CORNER_FACE, TEX_CORNER_FACE, TEX_BOTTOM_LEFT_FRONT); - + addFace(x, z, TEX_CORNER_FACE, TEX_CORNER_FACE, TEX_BOTTOM_LEFT_FRONT); x = r90z * x; z = r90z * z; - addFace(x, z, TEX_CORNER_FACE, TEX_CORNER_FACE, TEX_CORNER_FACE, TEX_BOTTOM_REAR_LEFT); - + addFace(x, z, TEX_CORNER_FACE, TEX_CORNER_FACE, TEX_BOTTOM_REAR_LEFT); x = r90x * r90x * r90z * x; z = r90x * r90x * r90z * z; - addFace(x, z, TEX_CORNER_FACE, TEX_CORNER_FACE, TEX_CORNER_FACE, TEX_TOP_RIGHT_FRONT); - + addFace(x, z, TEX_CORNER_FACE, TEX_CORNER_FACE, TEX_TOP_RIGHT_FRONT); x = r90z * x; z = r90z * z; - addFace(x, z, TEX_CORNER_FACE, TEX_CORNER_FACE, TEX_CORNER_FACE, TEX_TOP_FRONT_LEFT); - + addFace(x, z, TEX_CORNER_FACE, TEX_CORNER_FACE, TEX_TOP_FRONT_LEFT); x = r90z * x; z = r90z * z; - addFace(x, z, TEX_CORNER_FACE, TEX_CORNER_FACE, TEX_CORNER_FACE, TEX_TOP_LEFT_REAR); - + addFace(x, z, TEX_CORNER_FACE, TEX_CORNER_FACE, TEX_TOP_LEFT_REAR); x = r90z * x; z = r90z * z; - addFace(x, z, TEX_CORNER_FACE, TEX_CORNER_FACE, TEX_CORNER_FACE, TEX_TOP_REAR_RIGHT); + addFace(x, z, TEX_CORNER_FACE, TEX_CORNER_FACE, TEX_TOP_REAR_RIGHT); + + // add edge faces + m_Textures[TEX_EDGE_FACE] = createCubeFaceTex(gl, gap, NULL, SHAPE_EDGE); + // first back to top side + x[0] = 1; x[1] = 0; x[2] = 0; + z[0] = 0; z[1] = 0; z[2] = 1; + // rotate 45 degrees up + z = r45x * z; + x = r45x * x; + z *= 1.25f; // edge face position + addFace(x, z, TEX_EDGE_FACE, TEX_EDGE_FACE, TEX_FRONT_TOP); + x = r90x * x; + z = r90x * z; + addFace(x, z, TEX_EDGE_FACE, TEX_EDGE_FACE, TEX_FRONT_BOTTOM); + x = r90x * x; + z = r90x * z; + addFace(x, z, TEX_EDGE_FACE, TEX_EDGE_FACE, TEX_REAR_BOTTOM); + x = r90x * x; + z = r90x * z; + addFace(x, z, TEX_EDGE_FACE, TEX_EDGE_FACE, TEX_REAR_TOP); + x = r90y * x; + z = r90y * z; + addFace(x, z, TEX_EDGE_FACE, TEX_EDGE_FACE, TEX_REAR_RIGHT); + x = r90z * x; + z = r90z * z; + addFace(x, z, TEX_EDGE_FACE, TEX_EDGE_FACE, TEX_FRONT_RIGHT); + x = r90z * x; + z = r90z * z; + addFace(x, z, TEX_EDGE_FACE, TEX_EDGE_FACE, TEX_FRONT_LEFT); + x = r90z * x; + z = r90z * z; + addFace(x, z, TEX_EDGE_FACE, TEX_EDGE_FACE, TEX_REAR_LEFT); + x = r90x * x; + z = r90x * z; + addFace(x, z, TEX_EDGE_FACE, TEX_EDGE_FACE, TEX_TOP_LEFT); + x = r90y * x; + z = r90y * z; + addFace(x, z, TEX_EDGE_FACE, TEX_EDGE_FACE, TEX_TOP_RIGHT); + x = r90y * x; + z = r90y * z; + addFace(x, z, TEX_EDGE_FACE, TEX_EDGE_FACE, TEX_BOTTOM_RIGHT); + x = r90y * x; + z = r90y * z; + addFace(x, z, TEX_EDGE_FACE, TEX_EDGE_FACE, TEX_BOTTOM_LEFT); m_Buttons.push_back(TEX_ARROW_NORTH); m_Buttons.push_back(TEX_ARROW_SOUTH); @@ -814,6 +888,7 @@ void NaviCubeImplementation::initNaviCube(QtGLWidget* gl) { m_Buttons.push_back(TEX_ARROW_WEST); m_Buttons.push_back(TEX_ARROW_LEFT); m_Buttons.push_back(TEX_ARROW_RIGHT); + m_Buttons.push_back(TEX_DOT_BACKSIDE); m_PickingFramebuffer = new QtGLFramebufferObject(2*m_CubeWidgetSize,2* m_CubeWidgetSize, QtGLFramebufferObject::CombinedDepthStencil); } @@ -980,32 +1055,26 @@ void NaviCubeImplementation::drawNaviCube(bool pickMode) { glDisable(GL_TEXTURE_2D); float a=1.1f; - static GLubyte xbmp[] = { 0x11,0x11,0x0a,0x04,0x0a,0x11,0x11 }; glColor3f(1, 0, 0); glBegin(GL_LINES); glVertex3f(-1.1f, -1.1f, -1.1f); glVertex3f(+0.5f, -1.1f, -1.1f); glEnd(); glRasterPos3d(a, -a, -a); - glBitmap(8, 7, 0, 0, 0, 0, xbmp); - static GLubyte ybmp[] = { 0x04,0x04,0x04,0x04,0x0a,0x11,0x11 }; glColor3f(0, 1, 0); glBegin(GL_LINES); glVertex3f(-1.1f, -1.1f, -1.1f); glVertex3f(-1.1f, +0.5f, -1.1f); glEnd(); glRasterPos3d( -a, a, -a); - glBitmap(8, 7, 0, 0, 0, 0, ybmp); - static GLubyte zbmp[] = { 0x1f,0x10,0x08,0x04,0x02,0x01,0x1f }; glColor3f(0, 0, 1); glBegin(GL_LINES); glVertex3f(-1.1f, -1.1f, -1.1f); glVertex3f(-1.1f, -1.1f, +0.5f); glEnd(); glRasterPos3d( -a, -a, a); - glBitmap(8, 7, 0, 0, 0, 0, zbmp); glEnable(GL_TEXTURE_2D); } @@ -1158,25 +1227,24 @@ bool NaviCubeImplementation::mousePressed(short x, short y) { return pick != 0; } -void NaviCubeImplementation::setView(float rotZ,float rotX) { +void NaviCubeImplementation::setView(float rotZ, float rotX) { SbRotation rz, rx, t; rz.setValue(SbVec3f(0, 0, 1), rotZ * M_PI / 180); rx.setValue(SbVec3f(1, 0, 0), rotX * M_PI / 180); m_View3DInventorViewer->setCameraOrientation(rx * rz); } -void NaviCubeImplementation::rotateView(int axis,float rotAngle) { +void NaviCubeImplementation::rotateView(int axis, float rotAngle, SbVec3f customAxis) { SbRotation viewRot = m_View3DInventorViewer->getCameraOrientation(); SbVec3f up; - viewRot.multVec(SbVec3f(0,1,0),up); + viewRot.multVec(SbVec3f(0, 1, 0), up); SbVec3f out; - viewRot.multVec(SbVec3f(0,0,1),out); + viewRot.multVec(SbVec3f(0, 0, 1), out); - SbVec3f& u = up; - SbVec3f& o = out; - SbVec3f right (u[1]*o[2]-u[2]*o[1], u[2]*o[0]-u[0]*o[2], u[0]*o[1]-u[1]*o[0]); + SbVec3f right; + viewRot.multVec(SbVec3f(1, 0, 0), right); SbVec3f direction; switch (axis) { @@ -1193,7 +1261,10 @@ void NaviCubeImplementation::rotateView(int axis,float rotAngle) { break; } - SbRotation rot(direction, -rotAngle*M_PI/180.0); + if (customAxis != SbVec3f(0, 0, 0)) + direction = customAxis; + + SbRotation rot(direction, -rotAngle * M_PI / 180.0); SbRotation newViewRot = viewRot * rot; m_View3DInventorViewer->setCameraOrientation(newViewRot); @@ -1206,14 +1277,22 @@ void NaviCubeImplementation::handleMenu() { bool NaviCubeImplementation::mouseReleased(short x, short y) { setHilite(0); m_MouseDown = false; + + // get the curent view + SbMatrix ViewRotMatrix; + SbRotation CurrentViewRot = m_View3DInventorViewer->getCameraOrientation(); + CurrentViewRot.getValue(ViewRotMatrix); + if (!m_Dragging) { - float rot = 45 ; //30; - float tilt = 90-54.7356f ; //30; // 90 + deg(asin(-sqrt(1.0/3.0))) + float rot = 45; + float tilt = 90 - Base::toDegrees(atan(sqrt(2.0))); int pick = pickFace(x, y); ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View"); - long step = Base::clamp(hGrp->GetInt("NaviStepByTurn",8), 4L, 36L); - float rotStepAngle = 360.0f/step; + long step = Base::clamp(hGrp->GetInt("NaviStepByTurn", 8), 4L, 36L); + float rotStepAngle = 360.0f / step; + ParameterGrp::handle hGrpNavi = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/NaviCube"); + bool toNearest = hGrpNavi->GetBool("NaviRotateToNearest", true); switch (pick) { default: @@ -1221,45 +1300,304 @@ bool NaviCubeImplementation::mouseReleased(short x, short y) { break; case TEX_FRONT: setView(0, 90); + // we don't want to dumb rotate to the same view since depending on from where the user clicked on FRONT + // we have one of four suitable end positions. + // we use here the same rotation logic used by other programs using OCC like "CAD Assistant" + // when current matrix's 0,0 entry is larger than its |1,0| entry, we already have the final result + // otherwise rotate around y + if (toNearest) { + if (ViewRotMatrix[0][0] < 0 && abs(ViewRotMatrix[0][0]) >= abs(ViewRotMatrix[1][0])) + rotateView(2, 180); + else if (ViewRotMatrix[1][0] > 0 && abs(ViewRotMatrix[1][0]) > abs(ViewRotMatrix[0][0])) + rotateView(2, 90); + else if (ViewRotMatrix[1][0] < 0 && abs(ViewRotMatrix[1][0]) > abs(ViewRotMatrix[0][0])) + rotateView(2, -90); + } break; case TEX_REAR: setView(180, 90); + if (toNearest) { + if (ViewRotMatrix[0][0] > 0 && abs(ViewRotMatrix[0][0]) >= abs(ViewRotMatrix[1][0])) + rotateView(2, 180); + else if (ViewRotMatrix[1][0] > 0 && abs(ViewRotMatrix[1][0]) > abs(ViewRotMatrix[0][0])) + rotateView(2, -90); + else if (ViewRotMatrix[1][0] < 0 && abs(ViewRotMatrix[1][0]) > abs(ViewRotMatrix[0][0])) + rotateView(2, 90); + } break; case TEX_LEFT: - setView(270,90); + setView(270, 90); + if (toNearest) { + if (ViewRotMatrix[0][1] > 0 && abs(ViewRotMatrix[0][1]) >= abs(ViewRotMatrix[1][1])) + rotateView(2, 180); + else if (ViewRotMatrix[1][1] > 0 && abs(ViewRotMatrix[1][1]) > abs(ViewRotMatrix[0][1])) + rotateView(2, -90); + else if (ViewRotMatrix[1][1] < 0 && abs(ViewRotMatrix[1][1]) > abs(ViewRotMatrix[0][1])) + rotateView(2, 90); + } break; case TEX_RIGHT: - setView(90,90); + setView(90, 90); + if (toNearest) { + if (ViewRotMatrix[0][1] < 0 && abs(ViewRotMatrix[0][1]) >= abs(ViewRotMatrix[1][1])) + rotateView(2, 180); + else if (ViewRotMatrix[1][1] > 0 && abs(ViewRotMatrix[1][1]) > abs(ViewRotMatrix[0][1])) + rotateView(2, 90); + else if (ViewRotMatrix[1][1] < 0 && abs(ViewRotMatrix[1][1]) > abs(ViewRotMatrix[0][1])) + rotateView(2, -90); + } break; case TEX_TOP: - setView(0,0); + setView(0, 0); + if (toNearest) { + if (ViewRotMatrix[0][0] < 0 && abs(ViewRotMatrix[0][0]) >= abs(ViewRotMatrix[1][0])) + rotateView(2, 180); + else if (ViewRotMatrix[1][0] > 0 && abs(ViewRotMatrix[1][0]) > abs(ViewRotMatrix[0][0])) + rotateView(2, 90); + else if (ViewRotMatrix[1][0] < 0 && abs(ViewRotMatrix[1][0]) > abs(ViewRotMatrix[0][0])) + rotateView(2, -90); + } break; case TEX_BOTTOM: - setView(0,180); + setView(0, 180); + if (toNearest) { + if (ViewRotMatrix[0][0] < 0 && abs(ViewRotMatrix[0][0]) >= abs(ViewRotMatrix[1][0])) + rotateView(2, 180); + else if (ViewRotMatrix[1][0] > 0 && abs(ViewRotMatrix[1][0]) > abs(ViewRotMatrix[0][0])) + rotateView(2, 90); + else if (ViewRotMatrix[1][0] < 0 && abs(ViewRotMatrix[1][0]) > abs(ViewRotMatrix[0][0])) + rotateView(2, -90); + } + break; + case TEX_FRONT_TOP: + // set to FRONT then rotate + setView(0, 90); + rotateView(1, 45); + if (toNearest) { + if (ViewRotMatrix[0][0] < 0 && abs(ViewRotMatrix[0][0]) >= abs(ViewRotMatrix[1][0])) + rotateView(2, 180); + else if (ViewRotMatrix[1][0] > 0 && abs(ViewRotMatrix[1][0]) > abs(ViewRotMatrix[0][0])) + rotateView(2, 90); + else if (ViewRotMatrix[1][0] < 0 && abs(ViewRotMatrix[1][0]) > abs(ViewRotMatrix[0][0])) + rotateView(2, -90); + } + break; + case TEX_FRONT_BOTTOM: + // set to FRONT then rotate + setView(0, 90); + rotateView(1, -45); + if (toNearest) { + if (ViewRotMatrix[0][0] < 0 && abs(ViewRotMatrix[0][0]) >= abs(ViewRotMatrix[1][0])) + rotateView(2, 180); + else if (ViewRotMatrix[1][0] > 0 && abs(ViewRotMatrix[1][0]) > abs(ViewRotMatrix[0][0])) + rotateView(2, 90); + else if (ViewRotMatrix[1][0] < 0 && abs(ViewRotMatrix[1][0]) > abs(ViewRotMatrix[0][0])) + rotateView(2, -90); + } + break; + case TEX_REAR_BOTTOM: + // set to REAR then rotate + setView(180, 90); + rotateView(1, -45); + if (toNearest) { + if (ViewRotMatrix[0][0] > 0 && abs(ViewRotMatrix[0][0]) >= abs(ViewRotMatrix[1][0])) + rotateView(2, 180); + else if (ViewRotMatrix[1][0] > 0 && abs(ViewRotMatrix[1][0]) > abs(ViewRotMatrix[0][0])) + rotateView(2, -90); + else if (ViewRotMatrix[1][0] < 0 && abs(ViewRotMatrix[1][0]) > abs(ViewRotMatrix[0][0])) + rotateView(2, 90); + } + break; + case TEX_REAR_TOP: + // set to REAR then rotate + setView(180, 90); + rotateView(1, 45); + if (toNearest) { + if (ViewRotMatrix[0][0] > 0 && abs(ViewRotMatrix[0][0]) >= abs(ViewRotMatrix[1][0])) + rotateView(2, 180); + else if (ViewRotMatrix[1][0] > 0 && abs(ViewRotMatrix[1][0]) > abs(ViewRotMatrix[0][0])) + rotateView(2, -90); + else if (ViewRotMatrix[1][0] < 0 && abs(ViewRotMatrix[1][0]) > abs(ViewRotMatrix[0][0])) + rotateView(2, 90); + } + break; + case TEX_FRONT_LEFT: + // set to FRONT then rotate + setView(0, 90); + rotateView(0, 45); + if (toNearest) { + if (ViewRotMatrix[1][2] < 0 && abs(ViewRotMatrix[1][2]) >= abs(ViewRotMatrix[0][2])) + rotateView(2, 180); + else if (ViewRotMatrix[0][2] > 0 && abs(ViewRotMatrix[0][2]) > abs(ViewRotMatrix[1][2])) + rotateView(2, -90); + else if (ViewRotMatrix[0][2] < 0 && abs(ViewRotMatrix[0][2]) > abs(ViewRotMatrix[1][2])) + rotateView(2, 90); + } + break; + case TEX_FRONT_RIGHT: + // set to FRONT then rotate + setView(0, 90); + rotateView(0, -45); + if (toNearest) { + if (ViewRotMatrix[1][2] < 0 && abs(ViewRotMatrix[1][2]) >= abs(ViewRotMatrix[0][2])) + rotateView(2, 180); + else if (ViewRotMatrix[0][2] > 0 && abs(ViewRotMatrix[0][2]) > abs(ViewRotMatrix[1][2])) + rotateView(2, -90); + else if (ViewRotMatrix[0][2] < 0 && abs(ViewRotMatrix[0][2]) > abs(ViewRotMatrix[1][2])) + rotateView(2, 90); + } + break; + case TEX_REAR_RIGHT: + // set to REAR then rotate + setView(180, 90); + rotateView(0, 45); + if (toNearest) { + if (ViewRotMatrix[1][2] < 0 && abs(ViewRotMatrix[1][2]) >= abs(ViewRotMatrix[0][2])) + rotateView(2, 180); + else if (ViewRotMatrix[0][2] > 0 && abs(ViewRotMatrix[0][2]) > abs(ViewRotMatrix[1][2])) + rotateView(2, -90); + else if (ViewRotMatrix[0][2] < 0 && abs(ViewRotMatrix[0][2]) > abs(ViewRotMatrix[1][2])) + rotateView(2, 90); + } + break; + case TEX_REAR_LEFT: + // set to REAR then rotate + setView(180, 90); + rotateView(0, -45); + if (ViewRotMatrix[1][2] < 0 && abs(ViewRotMatrix[1][2]) >= abs(ViewRotMatrix[0][2])) + rotateView(2, 180); + else if (ViewRotMatrix[0][2] > 0 && abs(ViewRotMatrix[0][2]) > abs(ViewRotMatrix[1][2])) + rotateView(2, -90); + else if (ViewRotMatrix[0][2] < 0 && abs(ViewRotMatrix[0][2]) > abs(ViewRotMatrix[1][2])) + rotateView(2, 90); + break; + case TEX_TOP_LEFT: + // set to LEFT then rotate + setView(270, 90); + rotateView(1, 45); + if (toNearest) { + if (ViewRotMatrix[0][1] > 0 && abs(ViewRotMatrix[0][1]) >= abs(ViewRotMatrix[1][1])) + rotateView(2, 180); + else if (ViewRotMatrix[1][1] > 0 && abs(ViewRotMatrix[1][1]) > abs(ViewRotMatrix[0][1])) + rotateView(2, -90); + else if (ViewRotMatrix[1][1] < 0 && abs(ViewRotMatrix[1][1]) > abs(ViewRotMatrix[0][1])) + rotateView(2, 90); + } + break; + case TEX_TOP_RIGHT: + // set to RIGHT then rotate + setView(90, 90); + rotateView(1, 45); + if (toNearest) { + if (ViewRotMatrix[0][1] < 0 && abs(ViewRotMatrix[0][1]) >= abs(ViewRotMatrix[1][1])) + rotateView(2, 180); + else if (ViewRotMatrix[1][1] > 0 && abs(ViewRotMatrix[1][1]) > abs(ViewRotMatrix[0][1])) + rotateView(2, 90); + else if (ViewRotMatrix[1][1] < 0 && abs(ViewRotMatrix[1][1]) > abs(ViewRotMatrix[0][1])) + rotateView(2, -90); + } + break; + case TEX_BOTTOM_RIGHT: + // set to RIGHT then rotate + setView(90, 90); + rotateView(1, -45); + if (toNearest) { + if (ViewRotMatrix[0][1] < 0 && abs(ViewRotMatrix[0][1]) >= abs(ViewRotMatrix[1][1])) + rotateView(2, 180); + else if (ViewRotMatrix[1][1] > 0 && abs(ViewRotMatrix[1][1]) > abs(ViewRotMatrix[0][1])) + rotateView(2, 90); + else if (ViewRotMatrix[1][1] < 0 && abs(ViewRotMatrix[1][1]) > abs(ViewRotMatrix[0][1])) + rotateView(2, -90); + } + break; + case TEX_BOTTOM_LEFT: + // set to LEFT then rotate + setView(270, 90); + rotateView(1, -45); + if (toNearest) { + if (ViewRotMatrix[0][1] > 0 && abs(ViewRotMatrix[0][1]) >= abs(ViewRotMatrix[1][1])) + rotateView(2, 180); + else if (ViewRotMatrix[1][1] > 0 && abs(ViewRotMatrix[1][1]) > abs(ViewRotMatrix[0][1])) + rotateView(2, -90); + else if (ViewRotMatrix[1][1] < 0 && abs(ViewRotMatrix[1][1]) > abs(ViewRotMatrix[0][1])) + rotateView(2, 90); + } break; case TEX_BOTTOM_LEFT_FRONT: setView(rot - 90, 90 + tilt); + // we have 3 possible end states: + // - z-axis is not rotated larger than 120 ° from (0, 1, 0) -> we are already there + // - y-axis is not rotated larger than 120 ° from (0, 1, 0) + // - x-axis is not rotated larger than 120 ° from (0, 1, 0) + if (toNearest) { + if (ViewRotMatrix[1][0] > 0.4823) + rotateView(0, -120, SbVec3f(1, 1, 1)); + else if (ViewRotMatrix[1][1] > 0.4823) + rotateView(0, 120, SbVec3f(1, 1, 1)); + } break; case TEX_BOTTOM_FRONT_RIGHT: setView(90 + rot - 90, 90 + tilt); + if (toNearest) { + if (ViewRotMatrix[1][0] < -0.4823) + rotateView(0, 120, SbVec3f(-1, 1, 1)); + else if (ViewRotMatrix[1][1] > 0.4823) + rotateView(0, -120, SbVec3f(-1, 1, 1)); + } break; case TEX_BOTTOM_RIGHT_REAR: setView(180 + rot - 90, 90 + tilt); + if (toNearest) { + if (ViewRotMatrix[1][0] < -0.4823) + rotateView(0, -120, SbVec3f(-1, -1, 1)); + else if (ViewRotMatrix[1][1] < -0.4823) + rotateView(0, 120, SbVec3f(-1, -1, 1)); + } break; case TEX_BOTTOM_REAR_LEFT: setView(270 + rot - 90, 90 + tilt); + if (toNearest) { + if (ViewRotMatrix[1][0] > 0.4823) + rotateView(0, 120, SbVec3f(1, -1, 1)); + else if (ViewRotMatrix[1][1] < -0.4823) + rotateView(0, -120, SbVec3f(1, -1, 1)); + } break; case TEX_TOP_RIGHT_FRONT: setView(rot, 90 - tilt); + if (toNearest) { + if (ViewRotMatrix[1][0] > 0.4823) + rotateView(0, -120, SbVec3f(-1, 1, -1)); + else if (ViewRotMatrix[1][1] < -0.4823) + rotateView(0, 120, SbVec3f(-1, 1, -1)); + } break; case TEX_TOP_FRONT_LEFT: setView(rot - 90, 90 - tilt); + if (toNearest) { + if (ViewRotMatrix[1][0] < -0.4823) + rotateView(0, 120, SbVec3f(1, 1, -1)); + else if (ViewRotMatrix[1][1] < -0.4823) + rotateView(0, -120, SbVec3f(1, 1, -1)); + } break; case TEX_TOP_LEFT_REAR: setView(rot - 180, 90 - tilt); + if (toNearest) { + if (ViewRotMatrix[1][0] < -0.4823) + rotateView(0, -120, SbVec3f(1, -1, -1)); + else if (ViewRotMatrix[1][1] > 0.4823) + rotateView(0, 120, SbVec3f(1, -1, -1)); + } break; case TEX_TOP_REAR_RIGHT: setView(rot - 270, 90 - tilt); + if (toNearest) { + if (ViewRotMatrix[1][0] > 0.4823) + rotateView(0, 120, SbVec3f(-1, -1, -1)); + else if (ViewRotMatrix[1][1] > 0.4823) + rotateView(0, -120, SbVec3f(-1, -1, -1)); + } break; case TEX_ARROW_LEFT : rotateView(DIR_OUT,rotStepAngle); @@ -1279,6 +1617,9 @@ bool NaviCubeImplementation::mouseReleased(short x, short y) { case TEX_ARROW_SOUTH : rotateView(DIR_RIGHT,rotStepAngle); break; + case TEX_DOT_BACKSIDE: + rotateView(0, 180); + break; case TEX_VIEW_MENU_FACE : handleMenu(); break; From 8e417f96b81d2e6d26801a3c0cf882e259ab1ed1 Mon Sep 17 00:00:00 2001 From: donovaly Date: Sat, 27 Mar 2021 23:20:59 +0100 Subject: [PATCH 020/178] fix animation issue SO's auto rotation has its own rotation logic that ends at fixed positions. This collides with the "to nearest" option whose aim is to rotate to the next sensible state taking into account from what position the rotation was started. Thus the solution is to disable SO's auto rotation while the cube is rotated. --- src/Gui/NaviCube.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/Gui/NaviCube.cpp b/src/Gui/NaviCube.cpp index 46aef1748b..5ce991e9c0 100644 --- a/src/Gui/NaviCube.cpp +++ b/src/Gui/NaviCube.cpp @@ -945,9 +945,7 @@ void NaviCubeImplementation::handleResize() { m_PrevWidth = view[0]; m_PrevHeight = view[1]; m_View3DInventorViewer->getSoRenderManager()->scheduleRedraw(); - } - } void NaviCubeImplementation::drawNaviCube(bool pickMode) { @@ -1294,6 +1292,12 @@ bool NaviCubeImplementation::mouseReleased(short x, short y) { ParameterGrp::handle hGrpNavi = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/NaviCube"); bool toNearest = hGrpNavi->GetBool("NaviRotateToNearest", true); + // 3D animation (UseAutoRotatio) collides with the rotation to the nearest state + // thus when enabled, disable them temprarily for the cube rotation + bool UseAutoRotation = hGrp->GetBool("UseAutoRotation", false); + if (UseAutoRotation && toNearest) + m_View3DInventorViewer->setAnimationEnabled(false); + switch (pick) { default: return false; @@ -1624,6 +1628,10 @@ bool NaviCubeImplementation::mouseReleased(short x, short y) { handleMenu(); break; } + + // re-anable UseAutoRotation after the cube rotation was done + if (UseAutoRotation && toNearest) + m_View3DInventorViewer->setAnimationEnabled(true); } return true; } From 2887eadea735651d36ac42010f5e00418cf2f272 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 29 Mar 2021 18:29:44 +0200 Subject: [PATCH 021/178] Gui: concatenate rotations and apply the result once at the end --- src/Gui/NaviCube.cpp | 258 +++++++++++++++++++++---------------------- 1 file changed, 127 insertions(+), 131 deletions(-) diff --git a/src/Gui/NaviCube.cpp b/src/Gui/NaviCube.cpp index 5ce991e9c0..242e65164d 100644 --- a/src/Gui/NaviCube.cpp +++ b/src/Gui/NaviCube.cpp @@ -202,8 +202,9 @@ private: GLuint createButtonTex(QtGLWidget*, int); GLuint createMenuTex(QtGLWidget*, bool); - void setView(float ,float ); - void rotateView(int axis, float rotAngle, SbVec3f customAxis = SbVec3f(0, 0, 0)); + SbRotation setView(float ,float) const; + SbRotation rotateView(SbRotation, int axis, float rotAngle, SbVec3f customAxis = SbVec3f(0, 0, 0)) const; + void rotateView(const SbRotation&); QString str(char* str); char* enum2str(int); @@ -1225,16 +1226,14 @@ bool NaviCubeImplementation::mousePressed(short x, short y) { return pick != 0; } -void NaviCubeImplementation::setView(float rotZ, float rotX) { +SbRotation NaviCubeImplementation::setView(float rotZ, float rotX) const { SbRotation rz, rx, t; rz.setValue(SbVec3f(0, 0, 1), rotZ * M_PI / 180); rx.setValue(SbVec3f(1, 0, 0), rotX * M_PI / 180); - m_View3DInventorViewer->setCameraOrientation(rx * rz); + return rx * rz; } -void NaviCubeImplementation::rotateView(int axis, float rotAngle, SbVec3f customAxis) { - SbRotation viewRot = m_View3DInventorViewer->getCameraOrientation(); - +SbRotation NaviCubeImplementation::rotateView(SbRotation viewRot, int axis, float rotAngle, SbVec3f customAxis) const { SbVec3f up; viewRot.multVec(SbVec3f(0, 1, 0), up); @@ -1247,7 +1246,7 @@ void NaviCubeImplementation::rotateView(int axis, float rotAngle, SbVec3f custom SbVec3f direction; switch (axis) { default : - return; + return viewRot; case DIR_UP : direction = up; break; @@ -1264,8 +1263,11 @@ void NaviCubeImplementation::rotateView(int axis, float rotAngle, SbVec3f custom SbRotation rot(direction, -rotAngle * M_PI / 180.0); SbRotation newViewRot = viewRot * rot; - m_View3DInventorViewer->setCameraOrientation(newViewRot); + return newViewRot; +} +void NaviCubeImplementation::rotateView(const SbRotation& rot) { + m_View3DInventorViewer->setCameraOrientation(rot); } void NaviCubeImplementation::handleMenu() { @@ -1292,18 +1294,14 @@ bool NaviCubeImplementation::mouseReleased(short x, short y) { ParameterGrp::handle hGrpNavi = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/NaviCube"); bool toNearest = hGrpNavi->GetBool("NaviRotateToNearest", true); - // 3D animation (UseAutoRotatio) collides with the rotation to the nearest state - // thus when enabled, disable them temprarily for the cube rotation - bool UseAutoRotation = hGrp->GetBool("UseAutoRotation", false); - if (UseAutoRotation && toNearest) - m_View3DInventorViewer->setAnimationEnabled(false); + SbRotation viewRot = CurrentViewRot; switch (pick) { default: return false; break; case TEX_FRONT: - setView(0, 90); + viewRot = setView(0, 90); // we don't want to dumb rotate to the same view since depending on from where the user clicked on FRONT // we have one of four suitable end positions. // we use here the same rotation logic used by other programs using OCC like "CAD Assistant" @@ -1311,327 +1309,325 @@ bool NaviCubeImplementation::mouseReleased(short x, short y) { // otherwise rotate around y if (toNearest) { if (ViewRotMatrix[0][0] < 0 && abs(ViewRotMatrix[0][0]) >= abs(ViewRotMatrix[1][0])) - rotateView(2, 180); + viewRot = rotateView(viewRot, 2, 180); else if (ViewRotMatrix[1][0] > 0 && abs(ViewRotMatrix[1][0]) > abs(ViewRotMatrix[0][0])) - rotateView(2, 90); + viewRot = rotateView(viewRot, 2, 90); else if (ViewRotMatrix[1][0] < 0 && abs(ViewRotMatrix[1][0]) > abs(ViewRotMatrix[0][0])) - rotateView(2, -90); + viewRot = rotateView(viewRot, 2, -90); } break; case TEX_REAR: - setView(180, 90); + viewRot = setView(180, 90); if (toNearest) { if (ViewRotMatrix[0][0] > 0 && abs(ViewRotMatrix[0][0]) >= abs(ViewRotMatrix[1][0])) - rotateView(2, 180); + viewRot = rotateView(viewRot, 2, 180); else if (ViewRotMatrix[1][0] > 0 && abs(ViewRotMatrix[1][0]) > abs(ViewRotMatrix[0][0])) - rotateView(2, -90); + viewRot = rotateView(viewRot, 2, -90); else if (ViewRotMatrix[1][0] < 0 && abs(ViewRotMatrix[1][0]) > abs(ViewRotMatrix[0][0])) - rotateView(2, 90); + viewRot = rotateView(viewRot, 2, 90); } break; case TEX_LEFT: - setView(270, 90); + viewRot = setView(270, 90); if (toNearest) { if (ViewRotMatrix[0][1] > 0 && abs(ViewRotMatrix[0][1]) >= abs(ViewRotMatrix[1][1])) - rotateView(2, 180); + viewRot = rotateView(viewRot, 2, 180); else if (ViewRotMatrix[1][1] > 0 && abs(ViewRotMatrix[1][1]) > abs(ViewRotMatrix[0][1])) - rotateView(2, -90); + viewRot = rotateView(viewRot, 2, -90); else if (ViewRotMatrix[1][1] < 0 && abs(ViewRotMatrix[1][1]) > abs(ViewRotMatrix[0][1])) - rotateView(2, 90); + viewRot = rotateView(viewRot, 2, 90); } break; case TEX_RIGHT: - setView(90, 90); + viewRot = setView(90, 90); if (toNearest) { if (ViewRotMatrix[0][1] < 0 && abs(ViewRotMatrix[0][1]) >= abs(ViewRotMatrix[1][1])) - rotateView(2, 180); + viewRot = rotateView(viewRot, 2, 180); else if (ViewRotMatrix[1][1] > 0 && abs(ViewRotMatrix[1][1]) > abs(ViewRotMatrix[0][1])) - rotateView(2, 90); + viewRot = rotateView(viewRot, 2, 90); else if (ViewRotMatrix[1][1] < 0 && abs(ViewRotMatrix[1][1]) > abs(ViewRotMatrix[0][1])) - rotateView(2, -90); + viewRot = rotateView(viewRot, 2, -90); } break; case TEX_TOP: - setView(0, 0); + viewRot = setView(0, 0); if (toNearest) { if (ViewRotMatrix[0][0] < 0 && abs(ViewRotMatrix[0][0]) >= abs(ViewRotMatrix[1][0])) - rotateView(2, 180); + viewRot = rotateView(viewRot, 2, 180); else if (ViewRotMatrix[1][0] > 0 && abs(ViewRotMatrix[1][0]) > abs(ViewRotMatrix[0][0])) - rotateView(2, 90); + viewRot = rotateView(viewRot, 2, 90); else if (ViewRotMatrix[1][0] < 0 && abs(ViewRotMatrix[1][0]) > abs(ViewRotMatrix[0][0])) - rotateView(2, -90); + viewRot = rotateView(viewRot, 2, -90); } break; case TEX_BOTTOM: - setView(0, 180); + viewRot = setView(0, 180); if (toNearest) { if (ViewRotMatrix[0][0] < 0 && abs(ViewRotMatrix[0][0]) >= abs(ViewRotMatrix[1][0])) - rotateView(2, 180); + viewRot = rotateView(viewRot, 2, 180); else if (ViewRotMatrix[1][0] > 0 && abs(ViewRotMatrix[1][0]) > abs(ViewRotMatrix[0][0])) - rotateView(2, 90); + viewRot = rotateView(viewRot, 2, 90); else if (ViewRotMatrix[1][0] < 0 && abs(ViewRotMatrix[1][0]) > abs(ViewRotMatrix[0][0])) - rotateView(2, -90); + viewRot = rotateView(viewRot, 2, -90); } break; case TEX_FRONT_TOP: // set to FRONT then rotate - setView(0, 90); - rotateView(1, 45); + viewRot = setView(0, 90); + viewRot = rotateView(viewRot, 1, 45); if (toNearest) { if (ViewRotMatrix[0][0] < 0 && abs(ViewRotMatrix[0][0]) >= abs(ViewRotMatrix[1][0])) - rotateView(2, 180); + viewRot = rotateView(viewRot, 2, 180); else if (ViewRotMatrix[1][0] > 0 && abs(ViewRotMatrix[1][0]) > abs(ViewRotMatrix[0][0])) - rotateView(2, 90); + viewRot = rotateView(viewRot, 2, 90); else if (ViewRotMatrix[1][0] < 0 && abs(ViewRotMatrix[1][0]) > abs(ViewRotMatrix[0][0])) - rotateView(2, -90); + viewRot = rotateView(viewRot, 2, -90); } break; case TEX_FRONT_BOTTOM: // set to FRONT then rotate - setView(0, 90); - rotateView(1, -45); + viewRot = setView(0, 90); + viewRot = rotateView(viewRot, 1, -45); if (toNearest) { if (ViewRotMatrix[0][0] < 0 && abs(ViewRotMatrix[0][0]) >= abs(ViewRotMatrix[1][0])) - rotateView(2, 180); + viewRot = rotateView(viewRot, 2, 180); else if (ViewRotMatrix[1][0] > 0 && abs(ViewRotMatrix[1][0]) > abs(ViewRotMatrix[0][0])) - rotateView(2, 90); + viewRot = rotateView(viewRot, 2, 90); else if (ViewRotMatrix[1][0] < 0 && abs(ViewRotMatrix[1][0]) > abs(ViewRotMatrix[0][0])) - rotateView(2, -90); + viewRot = rotateView(viewRot, 2, -90); } break; case TEX_REAR_BOTTOM: // set to REAR then rotate - setView(180, 90); - rotateView(1, -45); + viewRot = setView(180, 90); + viewRot = rotateView(viewRot, 1, -45); if (toNearest) { if (ViewRotMatrix[0][0] > 0 && abs(ViewRotMatrix[0][0]) >= abs(ViewRotMatrix[1][0])) - rotateView(2, 180); + viewRot = rotateView(viewRot, 2, 180); else if (ViewRotMatrix[1][0] > 0 && abs(ViewRotMatrix[1][0]) > abs(ViewRotMatrix[0][0])) - rotateView(2, -90); + viewRot = rotateView(viewRot, 2, -90); else if (ViewRotMatrix[1][0] < 0 && abs(ViewRotMatrix[1][0]) > abs(ViewRotMatrix[0][0])) - rotateView(2, 90); + viewRot = rotateView(viewRot, 2, 90); } break; case TEX_REAR_TOP: // set to REAR then rotate - setView(180, 90); - rotateView(1, 45); + viewRot = setView(180, 90); + viewRot = rotateView(viewRot, 1, 45); if (toNearest) { if (ViewRotMatrix[0][0] > 0 && abs(ViewRotMatrix[0][0]) >= abs(ViewRotMatrix[1][0])) - rotateView(2, 180); + viewRot = rotateView(viewRot, 2, 180); else if (ViewRotMatrix[1][0] > 0 && abs(ViewRotMatrix[1][0]) > abs(ViewRotMatrix[0][0])) - rotateView(2, -90); + viewRot = rotateView(viewRot, 2, -90); else if (ViewRotMatrix[1][0] < 0 && abs(ViewRotMatrix[1][0]) > abs(ViewRotMatrix[0][0])) - rotateView(2, 90); + viewRot = rotateView(viewRot, 2, 90); } break; case TEX_FRONT_LEFT: // set to FRONT then rotate - setView(0, 90); - rotateView(0, 45); + viewRot = setView(0, 90); + viewRot = rotateView(viewRot, 0, 45); if (toNearest) { if (ViewRotMatrix[1][2] < 0 && abs(ViewRotMatrix[1][2]) >= abs(ViewRotMatrix[0][2])) - rotateView(2, 180); + viewRot = rotateView(viewRot, 2, 180); else if (ViewRotMatrix[0][2] > 0 && abs(ViewRotMatrix[0][2]) > abs(ViewRotMatrix[1][2])) - rotateView(2, -90); + viewRot = rotateView(viewRot, 2, -90); else if (ViewRotMatrix[0][2] < 0 && abs(ViewRotMatrix[0][2]) > abs(ViewRotMatrix[1][2])) - rotateView(2, 90); + viewRot = rotateView(viewRot, 2, 90); } break; case TEX_FRONT_RIGHT: // set to FRONT then rotate - setView(0, 90); - rotateView(0, -45); + viewRot = setView(0, 90); + viewRot = rotateView(viewRot, 0, -45); if (toNearest) { if (ViewRotMatrix[1][2] < 0 && abs(ViewRotMatrix[1][2]) >= abs(ViewRotMatrix[0][2])) - rotateView(2, 180); + viewRot = rotateView(viewRot, 2, 180); else if (ViewRotMatrix[0][2] > 0 && abs(ViewRotMatrix[0][2]) > abs(ViewRotMatrix[1][2])) - rotateView(2, -90); + viewRot = rotateView(viewRot, 2, -90); else if (ViewRotMatrix[0][2] < 0 && abs(ViewRotMatrix[0][2]) > abs(ViewRotMatrix[1][2])) - rotateView(2, 90); + viewRot = rotateView(viewRot, 2, 90); } break; case TEX_REAR_RIGHT: // set to REAR then rotate - setView(180, 90); - rotateView(0, 45); + viewRot = setView(180, 90); + viewRot = rotateView(viewRot, 0, 45); if (toNearest) { if (ViewRotMatrix[1][2] < 0 && abs(ViewRotMatrix[1][2]) >= abs(ViewRotMatrix[0][2])) - rotateView(2, 180); + viewRot = rotateView(viewRot, 2, 180); else if (ViewRotMatrix[0][2] > 0 && abs(ViewRotMatrix[0][2]) > abs(ViewRotMatrix[1][2])) - rotateView(2, -90); + viewRot = rotateView(viewRot, 2, -90); else if (ViewRotMatrix[0][2] < 0 && abs(ViewRotMatrix[0][2]) > abs(ViewRotMatrix[1][2])) - rotateView(2, 90); + viewRot = rotateView(viewRot, 2, 90); } break; case TEX_REAR_LEFT: // set to REAR then rotate - setView(180, 90); - rotateView(0, -45); + viewRot = setView(180, 90); + viewRot = rotateView(viewRot, 0, -45); if (ViewRotMatrix[1][2] < 0 && abs(ViewRotMatrix[1][2]) >= abs(ViewRotMatrix[0][2])) - rotateView(2, 180); + viewRot = rotateView(viewRot, 2, 180); else if (ViewRotMatrix[0][2] > 0 && abs(ViewRotMatrix[0][2]) > abs(ViewRotMatrix[1][2])) - rotateView(2, -90); + viewRot = rotateView(viewRot, 2, -90); else if (ViewRotMatrix[0][2] < 0 && abs(ViewRotMatrix[0][2]) > abs(ViewRotMatrix[1][2])) - rotateView(2, 90); + viewRot = rotateView(viewRot, 2, 90); break; case TEX_TOP_LEFT: // set to LEFT then rotate - setView(270, 90); - rotateView(1, 45); + viewRot = setView(270, 90); + viewRot = rotateView(viewRot, 1, 45); if (toNearest) { if (ViewRotMatrix[0][1] > 0 && abs(ViewRotMatrix[0][1]) >= abs(ViewRotMatrix[1][1])) - rotateView(2, 180); + viewRot = rotateView(viewRot, 2, 180); else if (ViewRotMatrix[1][1] > 0 && abs(ViewRotMatrix[1][1]) > abs(ViewRotMatrix[0][1])) - rotateView(2, -90); + viewRot = rotateView(viewRot, 2, -90); else if (ViewRotMatrix[1][1] < 0 && abs(ViewRotMatrix[1][1]) > abs(ViewRotMatrix[0][1])) - rotateView(2, 90); + viewRot = rotateView(viewRot, 2, 90); } break; case TEX_TOP_RIGHT: // set to RIGHT then rotate - setView(90, 90); - rotateView(1, 45); + viewRot = setView(90, 90); + viewRot = rotateView(viewRot, 1, 45); if (toNearest) { if (ViewRotMatrix[0][1] < 0 && abs(ViewRotMatrix[0][1]) >= abs(ViewRotMatrix[1][1])) - rotateView(2, 180); + viewRot = rotateView(viewRot, 2, 180); else if (ViewRotMatrix[1][1] > 0 && abs(ViewRotMatrix[1][1]) > abs(ViewRotMatrix[0][1])) - rotateView(2, 90); + viewRot = rotateView(viewRot, 2, 90); else if (ViewRotMatrix[1][1] < 0 && abs(ViewRotMatrix[1][1]) > abs(ViewRotMatrix[0][1])) - rotateView(2, -90); + viewRot = rotateView(viewRot, 2, -90); } break; case TEX_BOTTOM_RIGHT: // set to RIGHT then rotate - setView(90, 90); - rotateView(1, -45); + viewRot = setView(90, 90); + viewRot = rotateView(viewRot, 1, -45); if (toNearest) { if (ViewRotMatrix[0][1] < 0 && abs(ViewRotMatrix[0][1]) >= abs(ViewRotMatrix[1][1])) - rotateView(2, 180); + viewRot = rotateView(viewRot, 2, 180); else if (ViewRotMatrix[1][1] > 0 && abs(ViewRotMatrix[1][1]) > abs(ViewRotMatrix[0][1])) - rotateView(2, 90); + viewRot = rotateView(viewRot, 2, 90); else if (ViewRotMatrix[1][1] < 0 && abs(ViewRotMatrix[1][1]) > abs(ViewRotMatrix[0][1])) - rotateView(2, -90); + viewRot = rotateView(viewRot, 2, -90); } break; case TEX_BOTTOM_LEFT: // set to LEFT then rotate - setView(270, 90); - rotateView(1, -45); + viewRot = setView(270, 90); + viewRot = rotateView(viewRot, 1, -45); if (toNearest) { if (ViewRotMatrix[0][1] > 0 && abs(ViewRotMatrix[0][1]) >= abs(ViewRotMatrix[1][1])) - rotateView(2, 180); + viewRot = rotateView(viewRot, 2, 180); else if (ViewRotMatrix[1][1] > 0 && abs(ViewRotMatrix[1][1]) > abs(ViewRotMatrix[0][1])) - rotateView(2, -90); + viewRot = rotateView(viewRot, 2, -90); else if (ViewRotMatrix[1][1] < 0 && abs(ViewRotMatrix[1][1]) > abs(ViewRotMatrix[0][1])) - rotateView(2, 90); + viewRot = rotateView(viewRot, 2, 90); } break; case TEX_BOTTOM_LEFT_FRONT: - setView(rot - 90, 90 + tilt); + viewRot = setView(rot - 90, 90 + tilt); // we have 3 possible end states: // - z-axis is not rotated larger than 120 ° from (0, 1, 0) -> we are already there // - y-axis is not rotated larger than 120 ° from (0, 1, 0) // - x-axis is not rotated larger than 120 ° from (0, 1, 0) if (toNearest) { if (ViewRotMatrix[1][0] > 0.4823) - rotateView(0, -120, SbVec3f(1, 1, 1)); + viewRot = rotateView(viewRot, 0, -120, SbVec3f(1, 1, 1)); else if (ViewRotMatrix[1][1] > 0.4823) - rotateView(0, 120, SbVec3f(1, 1, 1)); + viewRot = rotateView(viewRot, 0, 120, SbVec3f(1, 1, 1)); } break; case TEX_BOTTOM_FRONT_RIGHT: - setView(90 + rot - 90, 90 + tilt); + viewRot = setView(90 + rot - 90, 90 + tilt); if (toNearest) { if (ViewRotMatrix[1][0] < -0.4823) - rotateView(0, 120, SbVec3f(-1, 1, 1)); + viewRot = rotateView(viewRot, 0, 120, SbVec3f(-1, 1, 1)); else if (ViewRotMatrix[1][1] > 0.4823) - rotateView(0, -120, SbVec3f(-1, 1, 1)); + viewRot = rotateView(viewRot, 0, -120, SbVec3f(-1, 1, 1)); } break; case TEX_BOTTOM_RIGHT_REAR: - setView(180 + rot - 90, 90 + tilt); + viewRot = setView(180 + rot - 90, 90 + tilt); if (toNearest) { if (ViewRotMatrix[1][0] < -0.4823) - rotateView(0, -120, SbVec3f(-1, -1, 1)); + viewRot = rotateView(viewRot, 0, -120, SbVec3f(-1, -1, 1)); else if (ViewRotMatrix[1][1] < -0.4823) - rotateView(0, 120, SbVec3f(-1, -1, 1)); + viewRot = rotateView(viewRot, 0, 120, SbVec3f(-1, -1, 1)); } break; case TEX_BOTTOM_REAR_LEFT: setView(270 + rot - 90, 90 + tilt); if (toNearest) { if (ViewRotMatrix[1][0] > 0.4823) - rotateView(0, 120, SbVec3f(1, -1, 1)); + viewRot = rotateView(viewRot, 0, 120, SbVec3f(1, -1, 1)); else if (ViewRotMatrix[1][1] < -0.4823) - rotateView(0, -120, SbVec3f(1, -1, 1)); + viewRot = rotateView(viewRot, 0, -120, SbVec3f(1, -1, 1)); } break; case TEX_TOP_RIGHT_FRONT: - setView(rot, 90 - tilt); + viewRot = setView(rot, 90 - tilt); if (toNearest) { if (ViewRotMatrix[1][0] > 0.4823) - rotateView(0, -120, SbVec3f(-1, 1, -1)); + viewRot = rotateView(viewRot, 0, -120, SbVec3f(-1, 1, -1)); else if (ViewRotMatrix[1][1] < -0.4823) - rotateView(0, 120, SbVec3f(-1, 1, -1)); + viewRot = rotateView(viewRot, 0, 120, SbVec3f(-1, 1, -1)); } break; case TEX_TOP_FRONT_LEFT: - setView(rot - 90, 90 - tilt); + viewRot = setView(rot - 90, 90 - tilt); if (toNearest) { if (ViewRotMatrix[1][0] < -0.4823) - rotateView(0, 120, SbVec3f(1, 1, -1)); + viewRot = rotateView(viewRot, 0, 120, SbVec3f(1, 1, -1)); else if (ViewRotMatrix[1][1] < -0.4823) - rotateView(0, -120, SbVec3f(1, 1, -1)); + viewRot = rotateView(viewRot, 0, -120, SbVec3f(1, 1, -1)); } break; case TEX_TOP_LEFT_REAR: - setView(rot - 180, 90 - tilt); + viewRot = setView(rot - 180, 90 - tilt); if (toNearest) { if (ViewRotMatrix[1][0] < -0.4823) - rotateView(0, -120, SbVec3f(1, -1, -1)); + viewRot = rotateView(viewRot, 0, -120, SbVec3f(1, -1, -1)); else if (ViewRotMatrix[1][1] > 0.4823) - rotateView(0, 120, SbVec3f(1, -1, -1)); + viewRot = rotateView(viewRot, 0, 120, SbVec3f(1, -1, -1)); } break; case TEX_TOP_REAR_RIGHT: - setView(rot - 270, 90 - tilt); + viewRot = setView(rot - 270, 90 - tilt); if (toNearest) { if (ViewRotMatrix[1][0] > 0.4823) - rotateView(0, 120, SbVec3f(-1, -1, -1)); + viewRot = rotateView(viewRot, 0, 120, SbVec3f(-1, -1, -1)); else if (ViewRotMatrix[1][1] > 0.4823) - rotateView(0, -120, SbVec3f(-1, -1, -1)); + viewRot = rotateView(viewRot, 0, -120, SbVec3f(-1, -1, -1)); } break; case TEX_ARROW_LEFT : - rotateView(DIR_OUT,rotStepAngle); + viewRot = rotateView(viewRot, DIR_OUT,rotStepAngle); break; case TEX_ARROW_RIGHT : - rotateView(DIR_OUT,-rotStepAngle); + viewRot = rotateView(viewRot, DIR_OUT,-rotStepAngle); break; case TEX_ARROW_WEST : - rotateView(DIR_UP,-rotStepAngle); + viewRot = rotateView(viewRot, DIR_UP,-rotStepAngle); break; case TEX_ARROW_EAST : - rotateView(DIR_UP,rotStepAngle); + viewRot = rotateView(viewRot, DIR_UP,rotStepAngle); break; case TEX_ARROW_NORTH : - rotateView(DIR_RIGHT,-rotStepAngle); + viewRot = rotateView(viewRot, DIR_RIGHT,-rotStepAngle); break; case TEX_ARROW_SOUTH : - rotateView(DIR_RIGHT,rotStepAngle); + viewRot = rotateView(viewRot, DIR_RIGHT,rotStepAngle); break; case TEX_DOT_BACKSIDE: - rotateView(0, 180); + viewRot = rotateView(viewRot, 0, 180); break; case TEX_VIEW_MENU_FACE : handleMenu(); break; } - // re-anable UseAutoRotation after the cube rotation was done - if (UseAutoRotation && toNearest) - m_View3DInventorViewer->setAnimationEnabled(true); + rotateView(viewRot); } return true; } From 46b0043b490ec99ac57b51440b50c228a5951a01 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Mon, 29 Mar 2021 13:58:52 -0500 Subject: [PATCH 022/178] [OpenSCAD] Add additional recompute() logic --- src/Mod/OpenSCAD/importCSG.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Mod/OpenSCAD/importCSG.py b/src/Mod/OpenSCAD/importCSG.py index 1cc8ad4845..315eb94d44 100644 --- a/src/Mod/OpenSCAD/importCSG.py +++ b/src/Mod/OpenSCAD/importCSG.py @@ -463,13 +463,14 @@ def p_minkowski_action(p): def p_resize_action(p): ''' resize_action : resize LPAREN keywordargument_list RPAREN OBRACE block_list EBRACE ''' - import Draft print(p[3]) new_size = p[3]['newsize'] auto = p[3]['auto'] print(new_size) print(auto) p[6][0].recompute() + if p[6][0].Shape.isNull(): + doc.recompute() old_bbox = p[6][0].Shape.BoundBox print ("Old bounding box: " + str(old_bbox)) old_size = [old_bbox.XLength, old_bbox.YLength, old_bbox.ZLength] @@ -482,7 +483,6 @@ def p_resize_action(p): # Calculate a transform matrix from the current bounding box to the new one: transform_matrix = FreeCAD.Matrix() - #new_part.Shape = part.Shape.transformGeometry(transform_matrix) scale = FreeCAD.Vector(float(new_size[0])/old_size[0], float(new_size[1])/old_size[1], @@ -978,10 +978,10 @@ def p_multmatrix_action(p): part.ViewObject.hide() else : if printverbose: print("Transform Geometry") -# Need to recompute to stop transformGeometry causing a crash - doc.recompute() + part.recompute() + if part.Shape.isNull(): + doc.recompute() new_part = doc.addObject("Part::Feature","Matrix Deformation") - # new_part.Shape = part.Base.Shape.transformGeometry(transform_matrix) new_part.Shape = part.Shape.transformGeometry(transform_matrix) if gui: part.ViewObject.hide() From 9540cf0bbdc3ef4af8d2b382f0600da069864c6d Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Mon, 29 Mar 2021 13:59:03 -0500 Subject: [PATCH 023/178] [OpenSCAD] Add piecewise helix for OCCT < 7.5 Address a hang when using older versions of OCC to create a rotated extrusion. This approximates the auxilliary spine as set of line segments formed from the helix, rather than using the helix directly. --- src/Mod/OpenSCAD/OpenSCADFeatures.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Mod/OpenSCAD/OpenSCADFeatures.py b/src/Mod/OpenSCAD/OpenSCADFeatures.py index a8cf3a5506..a3b0b306a1 100644 --- a/src/Mod/OpenSCAD/OpenSCADFeatures.py +++ b/src/Mod/OpenSCAD/OpenSCADFeatures.py @@ -431,7 +431,17 @@ class Twist: left_handed = True else: left_handed = False + auxiliary_spine = Part.makeHelix(pitch, height, radius, 0.0, left_handed) + + # OCC versions before 7.5 had a problem with using a helix as the auxilliary spine, so approximate + # it piecewise + occ_version = Part.OCC_VERSION.split(".") + if int(occ_version[0]) <= 7 and int(occ_version[1]) < 5: + num_points = int(max(3,num_revolutions * 36)) # Every ten degrees is adequate + wire = auxiliary_spine.Wires[0] + points = wire.discretize(Number=num_points) + auxiliary_spine = Part.makePolygon(points) faces = [lower_face,upper_face] for wire1,wire2 in zip(lower_face.Wires,upper_face.Wires): From 4d0d6570f07acfddafaf443a909b7e599b48c117 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Mon, 29 Mar 2021 14:11:32 -0500 Subject: [PATCH 024/178] [Start] Correct TestStart installation location --- src/Mod/Start/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Start/CMakeLists.txt b/src/Mod/Start/CMakeLists.txt index 13088ebda2..401a0ee97c 100644 --- a/src/Mod/Start/CMakeLists.txt +++ b/src/Mod/Start/CMakeLists.txt @@ -47,5 +47,5 @@ INSTALL( FILES ${Start_Tests} DESTINATION - Mod/Start/testStart + Mod/Start/TestStart ) From 1a28c4969a3a98537223ab7c8fcc926eb1830f53 Mon Sep 17 00:00:00 2001 From: donovaly Date: Tue, 30 Mar 2021 04:37:30 +0200 Subject: [PATCH 025/178] [Gui] fix a NaviCube Corner fixes a copy/paste issue of commit 7831a218d7 --- src/Gui/NaviCube.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Gui/NaviCube.cpp b/src/Gui/NaviCube.cpp index 242e65164d..eb9f927954 100644 --- a/src/Gui/NaviCube.cpp +++ b/src/Gui/NaviCube.cpp @@ -1557,7 +1557,7 @@ bool NaviCubeImplementation::mouseReleased(short x, short y) { } break; case TEX_BOTTOM_REAR_LEFT: - setView(270 + rot - 90, 90 + tilt); + viewRot = setView(270 + rot - 90, 90 + tilt); if (toNearest) { if (ViewRotMatrix[1][0] > 0.4823) viewRot = rotateView(viewRot, 0, 120, SbVec3f(1, -1, 1)); From 8e0f112aae5ce37090703ebddea7591dac9a710d Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Tue, 30 Mar 2021 12:38:31 +0200 Subject: [PATCH 026/178] Start: Fixed translated quote issue --- src/Mod/Start/Gui/Workbench.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Start/Gui/Workbench.cpp b/src/Mod/Start/Gui/Workbench.cpp index 0e73b46eb1..dd864cc1e1 100644 --- a/src/Mod/Start/Gui/Workbench.cpp +++ b/src/Mod/Start/Gui/Workbench.cpp @@ -88,7 +88,7 @@ void StartGui::Workbench::loadStartPage() str << std::endl; str << "class WebPage(object):" << std::endl; str << " def __init__(self):" << std::endl; - str << " self.browser=WebGui.openBrowserWindow(u'" << escapedstr.c_str() << "')" << std::endl; + str << " self.browser=WebGui.openBrowserWindow(u\"" << escapedstr.c_str() << "\")" << std::endl; #if defined(FC_OS_WIN32) str << " self.browser.setHtml(StartPage.handle(), App.getResourceDir() + 'Mod/Start/StartPage/')" << std::endl; #else From 4346d87c88ede7532751f88a52fa10a177f39bdb Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Mon, 29 Mar 2021 23:45:48 +0200 Subject: [PATCH 027/178] Arch: Fix displayed rotation values when adding or editing window components This ensures the rotation edge and mode GUI elements are cleared when starting to add or edit a component. Previously, when adding a new component or editing one without rotation, the GUI elements would retain the value from the previously edited component, which made it hard to check that components did not have any rotation, and would make it easy to accidentally add rotation to components that did not need it (just by clicking edit and confirming). --- src/Mod/Arch/ArchWindow.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Mod/Arch/ArchWindow.py b/src/Mod/Arch/ArchWindow.py index ac0011ba34..8326d1a3d6 100644 --- a/src/Mod/Arch/ArchWindow.py +++ b/src/Mod/Arch/ArchWindow.py @@ -1442,6 +1442,8 @@ class _ArchWindowTaskPanel: self.field3.setText('') self.field4.setText('') self.field5.setText('') + self.field6.setText(QtGui.QApplication.translate("Arch", "Get selected edge", None)) + self.field7.setCurrentIndex(0) self.addp4.setChecked(False) self.addp5.setChecked(False) self.newtitle.setVisible(True) @@ -1489,6 +1491,8 @@ class _ArchWindowTaskPanel: if self.obj: if comp in self.obj.WindowParts: ind = self.obj.WindowParts.index(comp) + self.field6.setText(QtGui.QApplication.translate("Arch", "Get selected edge", None)) + self.field7.setCurrentIndex(0) for i in range(5): f = getattr(self,"field"+str(i+1)) t = self.obj.WindowParts[ind+i] From 08b7d9d0f3abc89c853e90d0e76fdb0e27bc0948 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Tue, 30 Mar 2021 14:05:49 -0500 Subject: [PATCH 028/178] [OpenSCAD] Fix projection for OCCT7.3 OCCT 7.3 did not work well when using a very large projection plane, so this commit reduces the plane size to the minimum required for the cut operation. It also performs some minor refactoring in anticipation of the implementation of the true projection feature, and it removes the last attempted fix, which proved unnecessary. --- src/Mod/OpenSCAD/OpenSCADFeatures.py | 9 -------- src/Mod/OpenSCAD/importCSG.py | 34 +++++++++++++++------------- 2 files changed, 18 insertions(+), 25 deletions(-) diff --git a/src/Mod/OpenSCAD/OpenSCADFeatures.py b/src/Mod/OpenSCAD/OpenSCADFeatures.py index a3b0b306a1..433cf0d83f 100644 --- a/src/Mod/OpenSCAD/OpenSCADFeatures.py +++ b/src/Mod/OpenSCAD/OpenSCADFeatures.py @@ -434,15 +434,6 @@ class Twist: auxiliary_spine = Part.makeHelix(pitch, height, radius, 0.0, left_handed) - # OCC versions before 7.5 had a problem with using a helix as the auxilliary spine, so approximate - # it piecewise - occ_version = Part.OCC_VERSION.split(".") - if int(occ_version[0]) <= 7 and int(occ_version[1]) < 5: - num_points = int(max(3,num_revolutions * 36)) # Every ten degrees is adequate - wire = auxiliary_spine.Wires[0] - points = wire.discretize(Number=num_points) - auxiliary_spine = Part.makePolygon(points) - faces = [lower_face,upper_face] for wire1,wire2 in zip(lower_face.Wires,upper_face.Wires): pipe_shell = Part.BRepOffsetAPI.MakePipeShell(spine) diff --git a/src/Mod/OpenSCAD/importCSG.py b/src/Mod/OpenSCAD/importCSG.py index 315eb94d44..432a4d70a5 100644 --- a/src/Mod/OpenSCAD/importCSG.py +++ b/src/Mod/OpenSCAD/importCSG.py @@ -1322,25 +1322,27 @@ def p_polyhedron_action(p) : def p_projection_action(p) : 'projection_action : projection LPAREN keywordargument_list RPAREN OBRACE block_list EBRACE' if printverbose: print('Projection') - if p[3]['cut']=='true' : - planedim=1e9 # large but finite - #infinite planes look bad in the GUI - planename='xy_plane_used_for_project_cut' - obj=doc.addObject('Part::MultiCommon','projection_cut') - plane = doc.getObject(planename) - if not plane: - plane=doc.addObject("Part::Plane",planename) - plane.Length=planedim*2 - plane.Width=planedim*2 - plane.Placement = FreeCAD.Placement(FreeCAD.Vector(\ - -planedim,-planedim,0),FreeCAD.Rotation()) - if gui: - plane.ViewObject.hide() + + doc.recompute() + bbox = p[6][0].Shape.BoundBox + for shape in p[6]: + bbox.add(shape.Shape.BoundBox) + print (bbox) + plane = doc.addObject("Part::Plane","xy_plane_used_for_projection") + plane.Length = bbox.XLength + plane.Width = bbox.YLength + plane.Placement = FreeCAD.Placement(FreeCAD.Vector(\ + bbox.XMin,bbox.YMin,0),FreeCAD.Rotation()) + if gui: + plane.ViewObject.hide() + + if p[3]['cut'] == 'true' : + obj = doc.addObject('Part::MultiCommon','projection_cut') if (len(p[6]) > 1): subobj = [fuse(p[6],"projection_cut_implicit_group")] else: subobj = p[6] - obj.Shapes = [plane]+subobj + obj.Shapes = [plane] + subobj if gui: subobj[0].ViewObject.hide() p[0] = [obj] @@ -1348,6 +1350,6 @@ def p_projection_action(p) : if gui and not FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/OpenSCAD").\ GetBool('usePlaceholderForUnsupported'): from PySide import QtGui - QtGui.QMessageBox.critical(None, translate('OpenSCAD',"Unsupported Function")+" : "+p[1],translate('OpenSCAD',"Press OK")) + QtGui.QMessageBox.critical(None, translate('OpenSCAD',"Unsupported Function") + " : " + p[1],translate('OpenSCAD',"Press OK")) else: p[0] = [placeholder(p[1],p[6],p[3])] From f95aeb7144b21d5eae144c972ca506a2944c9c77 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 31 Mar 2021 15:35:28 +0200 Subject: [PATCH 029/178] smesh: [skip ci] build FEM & MeshPart with C++14 when using external smesh because it doesn't support C++17 yet --- src/Mod/Fem/App/CMakeLists.txt | 8 +++++++- src/Mod/Fem/Gui/CMakeLists.txt | 6 ++++++ src/Mod/MeshPart/App/CMakeLists.txt | 6 ++++++ src/Mod/MeshPart/Gui/CMakeLists.txt | 6 ++++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/src/Mod/Fem/App/CMakeLists.txt b/src/Mod/Fem/App/CMakeLists.txt index cb45f0ba19..aafd14d98a 100644 --- a/src/Mod/Fem/App/CMakeLists.txt +++ b/src/Mod/Fem/App/CMakeLists.txt @@ -176,7 +176,7 @@ SET(FemConstraints_SRCS FemConstraintContact.h FemConstraintTransform.cpp FemConstraintTransform.h - ) +) SOURCE_GROUP("Constraints" FILES ${FemConstraints_SRCS}) @@ -198,6 +198,12 @@ endif(FREECAD_USE_PCH) add_library(Fem SHARED ${Fem_SRCS}) target_link_libraries(Fem ${Fem_LIBS} ${VTK_LIBRARIES}) +# external SMESH doesn't support C++17 yet +if(FREECAD_USE_EXTERNAL_SMESH) + set_target_properties(Fem PROPERTIES CXX_STANDARD_REQUIRED ON) + set_target_properties(Fem PROPERTIES CXX_STANDARD 14) +endif() + SET_BIN_DIR(Fem Fem /Mod/Fem) SET_PYTHON_PREFIX_SUFFIX(Fem) diff --git a/src/Mod/Fem/Gui/CMakeLists.txt b/src/Mod/Fem/Gui/CMakeLists.txt index 0c9dc0b7ca..0b73d0ba66 100755 --- a/src/Mod/Fem/Gui/CMakeLists.txt +++ b/src/Mod/Fem/Gui/CMakeLists.txt @@ -394,6 +394,12 @@ SET(FemGuiIcon_SVG add_library(FemGui SHARED ${FemGui_SRCS} ${FemGuiIcon_SVG}) target_link_libraries(FemGui ${FemGui_LIBS} ${VTK_LIBRARIES}) +# external SMESH doesn't support C++17 yet +if(FREECAD_USE_EXTERNAL_SMESH) + set_target_properties(FemGui PROPERTIES CXX_STANDARD_REQUIRED ON) + set_target_properties(FemGui PROPERTIES CXX_STANDARD 14) +endif() + fc_copy_sources(FemGui "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_DATADIR}/Mod/Fem" ${FemGuiIcon_SVG}) diff --git a/src/Mod/MeshPart/App/CMakeLists.txt b/src/Mod/MeshPart/App/CMakeLists.txt index 939f566389..eb2fa0fd25 100644 --- a/src/Mod/MeshPart/App/CMakeLists.txt +++ b/src/Mod/MeshPart/App/CMakeLists.txt @@ -65,6 +65,12 @@ set(MeshPart_Scripts add_library(MeshPart SHARED ${MeshPart_SRCS} ${MeshPart_Scripts}) target_link_libraries(MeshPart ${MeshPart_LIBS}) +# external SMESH doesn't support C++17 yet +if(FREECAD_USE_EXTERNAL_SMESH) + set_target_properties(MeshPart PROPERTIES CXX_STANDARD_REQUIRED ON) + set_target_properties(MeshPart PROPERTIES CXX_STANDARD 14) +endif() + fc_target_copy_resource_flat(MeshPart ${CMAKE_CURRENT_SOURCE_DIR} diff --git a/src/Mod/MeshPart/Gui/CMakeLists.txt b/src/Mod/MeshPart/Gui/CMakeLists.txt index 92ccfdf9eb..c5bb5ddc2a 100644 --- a/src/Mod/MeshPart/Gui/CMakeLists.txt +++ b/src/Mod/MeshPart/Gui/CMakeLists.txt @@ -91,6 +91,12 @@ set(FLATMESH_PY_SRCS add_library(MeshPartGui SHARED ${MeshPartGui_SRCS} ${MeshPartGui_Scripts} ${FLATMESH_PY_SRCS}) target_link_libraries(MeshPartGui ${MeshPartGui_LIBS}) +# external SMESH doesn't support C++17 yet +if(FREECAD_USE_EXTERNAL_SMESH) + set_target_properties(MeshPartGui PROPERTIES CXX_STANDARD_REQUIRED ON) + set_target_properties(MeshPartGui PROPERTIES CXX_STANDARD 14) +endif() + SET_BIN_DIR(MeshPartGui MeshPartGui /Mod/MeshPart) SET_PYTHON_PREFIX_SUFFIX(MeshPartGui) From 136a402b7e5d2875e36fed42031528bfd89882f7 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 1 Apr 2021 13:27:03 +0200 Subject: [PATCH 030/178] Import: if in a dxf file control points and fit points are given then use the former to create the B-Spline --- src/Mod/Import/App/ImpExpDxf.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Mod/Import/App/ImpExpDxf.cpp b/src/Mod/Import/App/ImpExpDxf.cpp index 9bfc63ec9b..09827bd928 100644 --- a/src/Mod/Import/App/ImpExpDxf.cpp +++ b/src/Mod/Import/App/ImpExpDxf.cpp @@ -256,10 +256,10 @@ void ImpExpDxfRead::OnReadSpline(struct SplineData& sd) try { Handle(Geom_BSplineCurve) geom; - if (sd.fit_points > 0) - geom = getInterpolationSpline(sd); - else + if (sd.control_points > 0) geom = getSplineFromPolesAndKnots(sd); + else if (sd.fit_points > 0) + geom = getInterpolationSpline(sd); if (geom.IsNull()) throw Standard_Failure(); From 41421e0c64974205a620a6da10b0038ee0e87ba0 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 1 Apr 2021 13:41:14 +0200 Subject: [PATCH 031/178] CMake: fix possible linker error when using external SMESH --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b90d876f7f..31478ef3b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,7 +45,6 @@ if(NOT FREECAD_LIBPACK_USE OR FREECAD_LIBPACK_CHECKFILE_CLBUNDLER) SetupPython() SetupPCL() SetupPybind11() - SetupBoost() SetupXercesC() find_package(ZLIB REQUIRED) find_package(PyCXX REQUIRED) @@ -57,6 +56,7 @@ if(NOT FREECAD_LIBPACK_USE OR FREECAD_LIBPACK_CHECKFILE_CLBUNDLER) SetupOpenGL() endif(BUILD_GUI) SetupSalomeSMESH() + SetupBoost() if (BUILD_FEM_NETGEN) find_package(NETGEN) endif(BUILD_FEM_NETGEN) From f9a54c33857aa9065139fc0b078e5b471b962a73 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 1 Apr 2021 17:51:10 +0200 Subject: [PATCH 032/178] Py3: fixes #0004081: Abillity to show console output when running under Python --- src/App/Application.cpp | 10 +++++++--- src/Main/FreeCADGuiPy.cpp | 8 ++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/App/Application.cpp b/src/App/Application.cpp index 7f0bf983d8..abf721fcf8 100644 --- a/src/App/Application.cpp +++ b/src/App/Application.cpp @@ -1980,9 +1980,13 @@ void Application::initConfig(int argc, char ** argv) // Init console =========================================================== Base::PyGILStateLocker lock; - if (mConfig["LoggingConsole"] == "1") { - _pConsoleObserverStd = new ConsoleObserverStd(); - Console().AttachObserver(_pConsoleObserverStd); + _pConsoleObserverStd = new ConsoleObserverStd(); + Console().AttachObserver(_pConsoleObserverStd); + if (mConfig["LoggingConsole"] != "1") { + _pConsoleObserverStd->bMsg = false; + _pConsoleObserverStd->bLog = false; + _pConsoleObserverStd->bWrn = false; + _pConsoleObserverStd->bErr = false; } if (mConfig["Verbose"] == "Strict") Console().UnsetConsoleMode(ConsoleSingleton::Verbose); diff --git a/src/Main/FreeCADGuiPy.cpp b/src/Main/FreeCADGuiPy.cpp index f82254c5b8..4dc09165fe 100644 --- a/src/Main/FreeCADGuiPy.cpp +++ b/src/Main/FreeCADGuiPy.cpp @@ -152,6 +152,14 @@ FreeCADGui_showMainWindow(PyObject * /*self*/, PyObject *args) } } + // if successful then enable Console logger + Base::ILogger *console = Base::Console().Get("Console"); + if (console) { + console->bMsg = true; + console->bWrn = true; + console->bErr = true; + } + Py_INCREF(Py_None); return Py_None; } From 5592548e2e4d7959e8e5ceed33f5cb5ca5c90c0a Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Wed, 31 Mar 2021 10:18:58 -0500 Subject: [PATCH 033/178] [Base] Remove deprecated Qt < 5.9 code --- src/Base/TimeInfo.cpp | 10 ---------- src/Base/Tools.h | 35 ----------------------------------- src/Base/Translate.cpp | 5 ----- 3 files changed, 50 deletions(-) diff --git a/src/Base/TimeInfo.cpp b/src/Base/TimeInfo.cpp index 88c5520a08..03cbff2959 100644 --- a/src/Base/TimeInfo.cpp +++ b/src/Base/TimeInfo.cpp @@ -79,18 +79,8 @@ void TimeInfo::setTime_t (uint64_t seconds) std::string TimeInfo::currentDateTimeString() { -#if (QT_VERSION >= 0x050300) return QDateTime::currentDateTime().toTimeSpec(Qt::OffsetFromUTC) .toString(Qt::ISODate).toStdString(); -#else - QDateTime local = QDateTime::currentDateTime(); - QDateTime utc = local.toUTC(); - utc.setTimeSpec(Qt::LocalTime); - int utcOffset = utc.secsTo(local); - local.setUtcOffset(utcOffset); - QString dm = local.toString(Qt::ISODate); - return dm.toStdString(); -#endif } std::string TimeInfo::diffTime(const TimeInfo &timeStart,const TimeInfo &timeEnd ) diff --git a/src/Base/Tools.h b/src/Base/Tools.h index e0f007f1fa..6cac42a96b 100644 --- a/src/Base/Tools.h +++ b/src/Base/Tools.h @@ -34,41 +34,6 @@ #include #include -#if (QT_VERSION < 0x050300) -class QSignalBlocker -{ -public: - QSignalBlocker(QObject *object) - : object(object) - , blocked(object && object->blockSignals(true)) - , inhibited(false) - { - } - ~QSignalBlocker() - { - if (object && !inhibited) - object->blockSignals(blocked); - } - void reblock() - { - if (object) - object->blockSignals(true); - inhibited = false; - } - void unblock() - { - if (object) - object->blockSignals(blocked); - inhibited = true; - } - -private: - QObject *object; - bool blocked; - bool inhibited; -}; -#endif - // ---------------------------------------------------------------------------- namespace Base diff --git a/src/Base/Translate.cpp b/src/Base/Translate.cpp index 5aec1da677..50eeddfed5 100644 --- a/src/Base/Translate.cpp +++ b/src/Base/Translate.cpp @@ -79,12 +79,7 @@ Py::Object Translate::translate(const Py::Tuple& args) if (!PyArg_ParseTuple(args.ptr(), "ss|si", &context, &source, &disambiguation, &n)) throw Py::Exception(); -#if (QT_VERSION >= 0x050000) QString str = QCoreApplication::translate(context, source, disambiguation, n); -#else - QString str = QCoreApplication::translate(context, source, disambiguation, - QCoreApplication::UnicodeUTF8, n); -#endif return Py::asObject(PyUnicode_FromString(str.toUtf8())); } From d959bf15823cd0406cb5a8e00d4baaa0a7697ea2 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Wed, 31 Mar 2021 10:26:27 -0500 Subject: [PATCH 034/178] [Main] Remove deprecated Qt < 5.9 code --- src/Main/FreeCADGuiPy.cpp | 2 -- src/Main/MainGui.cpp | 9 --------- 2 files changed, 11 deletions(-) diff --git a/src/Main/FreeCADGuiPy.cpp b/src/Main/FreeCADGuiPy.cpp index 4dc09165fe..83ef7a2def 100644 --- a/src/Main/FreeCADGuiPy.cpp +++ b/src/Main/FreeCADGuiPy.cpp @@ -106,9 +106,7 @@ FreeCADGui_showMainWindow(PyObject * /*self*/, PyObject *args) std::thread t([]() { static int argc = 0; static char **argv = {0}; -#if (QT_VERSION >= QT_VERSION_CHECK(5, 9, 0)) QApplication::setAttribute(Qt::AA_ShareOpenGLContexts); -#endif // This only works well if the QApplication is the very first created instance // of a QObject. Otherwise the application lives in a different thread than the // main thread which will cause hazardous behaviour. diff --git a/src/Main/MainGui.cpp b/src/Main/MainGui.cpp index f468228d15..ebdfe64f7d 100644 --- a/src/Main/MainGui.cpp +++ b/src/Main/MainGui.cpp @@ -120,13 +120,6 @@ int main( int argc, char ** argv ) // Make sure to setup the Qt locale system before setting LANG and LC_ALL to C. // which is needed to use the system locale settings. (void)QLocale::system(); -#if QT_VERSION < 0x050000 - // http://www.freecadweb.org/tracker/view.php?id=399 - // Because of setting LANG=C the Qt automagic to use the correct encoding - // for file names is broken. This is a workaround to force the use of UTF-8 encoding - QFile::setEncodingFunction(myEncoderFunc); - QFile::setDecodingFunction(myDecoderFunc); -#endif // See https://forum.freecadweb.org/viewtopic.php?f=18&t=20600 // See Gui::Application::runApplication() putenv("LC_NUMERIC=C"); @@ -189,9 +182,7 @@ int main( int argc, char ** argv ) App::Application::Config()["SplashTextColor" ] = "#ffffff"; // white App::Application::Config()["SplashInfoColor" ] = "#c8c8c8"; // light grey -#if (QT_VERSION >= QT_VERSION_CHECK(5, 7, 0)) QGuiApplication::setDesktopFileName(QStringLiteral("org.freecadweb.FreeCAD.desktop")); -#endif try { // Init phase =========================================================== From 93f2166d2b59f38b9083a49c617dc704af0754b5 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Wed, 31 Mar 2021 12:41:01 -0500 Subject: [PATCH 035/178] [Test] Remove deprecated Qt < 5.9 code --- src/Mod/Test/Gui/UnitTestImp.cpp | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/Mod/Test/Gui/UnitTestImp.cpp b/src/Mod/Test/Gui/UnitTestImp.cpp index aa7f4298c5..5b34ce1988 100644 --- a/src/Mod/Test/Gui/UnitTestImp.cpp +++ b/src/Mod/Test/Gui/UnitTestImp.cpp @@ -85,11 +85,6 @@ UnitTestDialog::UnitTestDialog(QWidget* parent, Qt::WindowFlags f) , ui(new Ui_UnitTest) { ui->setupUi(this); -#if QT_VERSION < 0x050000 - // As it doesn't seem to be able to change the "Highlight" color for the active colorgroup - // we force e.g. the "Motif" style only for the progressbar to change the color to green or red. - ui->progressBar->setStyle(QStyleFactory::create(QString::fromLatin1("Motif"))); -#endif setProgressColor(QColor(40,210,43)); // a darker green ui->progressBar->setAlignment(Qt::AlignCenter); @@ -111,7 +106,6 @@ UnitTestDialog::~UnitTestDialog() */ void UnitTestDialog::setProgressColor(const QColor& col) { -#if QT_VERSION >= 0x050000 QString qss = QString::fromLatin1( "QProgressBar {\n" " border: 2px solid grey;\n" @@ -123,12 +117,6 @@ void UnitTestDialog::setProgressColor(const QColor& col) "}" ).arg(col.name()); ui->progressBar->setStyleSheet(qss); -#else - QPalette pl = ui->progressBar->palette(); - pl.setColor(QPalette::Active, QPalette::Highlight, col); - pl.setColor(QPalette::Inactive, QPalette::Highlight, col); - ui->progressBar->setPalette(pl); -#endif } /** From ee2d7651b843f7fc2a989ea86203e0d2a060c5ab Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Wed, 31 Mar 2021 11:45:29 -0500 Subject: [PATCH 036/178] [Spreadsheet] Remove deprecated Qt < 5.9 code --- src/Mod/Spreadsheet/Gui/SheetTableView.h | 4 ---- src/Mod/Spreadsheet/Gui/qtcolorpicker.cpp | 9 ++------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/src/Mod/Spreadsheet/Gui/SheetTableView.h b/src/Mod/Spreadsheet/Gui/SheetTableView.h index 8507833f58..4338fcc21e 100644 --- a/src/Mod/Spreadsheet/Gui/SheetTableView.h +++ b/src/Mod/Spreadsheet/Gui/SheetTableView.h @@ -37,11 +37,7 @@ public: SheetViewHeader(QTableView *owner, Qt::Orientation o) : QHeaderView(o),owner(owner) { -#if QT_VERSION >= 0x050000 setSectionsClickable(true); -#else - setClickable(true); -#endif } Q_SIGNALS: void resizeFinished(); diff --git a/src/Mod/Spreadsheet/Gui/qtcolorpicker.cpp b/src/Mod/Spreadsheet/Gui/qtcolorpicker.cpp index 0d2db3db0b..4372ad99cb 100644 --- a/src/Mod/Spreadsheet/Gui/qtcolorpicker.cpp +++ b/src/Mod/Spreadsheet/Gui/qtcolorpicker.cpp @@ -64,9 +64,7 @@ #include #include -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) -# include -#endif +#include #include "qtcolorpicker.h" @@ -316,11 +314,8 @@ void QtColorPicker::buttonPressed(bool toggled) if (!toggled) return; -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) const QRect desktop = QApplication::primaryScreen()->geometry(); -#else - const QRect desktop = QApplication::desktop()->geometry(); -#endif + // Make sure the popup is inside the desktop. QPoint pos = mapToGlobal(rect().bottomLeft()); if (pos.x() < desktop.left()) From e0b9f28198ad19719178a6c751f84ded331dcdae Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Wed, 31 Mar 2021 10:41:24 -0500 Subject: [PATCH 037/178] [Part] Remove deprecated Qt < 5.9 code --- src/Mod/Part/Gui/DlgFilletEdges.cpp | 6 ------ src/Mod/Part/Gui/TaskCheckGeometry.cpp | 6 ------ 2 files changed, 12 deletions(-) diff --git a/src/Mod/Part/Gui/DlgFilletEdges.cpp b/src/Mod/Part/Gui/DlgFilletEdges.cpp index cc6a072975..1b2315afac 100644 --- a/src/Mod/Part/Gui/DlgFilletEdges.cpp +++ b/src/Mod/Part/Gui/DlgFilletEdges.cpp @@ -281,15 +281,9 @@ DlgFilletEdges::DlgFilletEdges(FilletType type, Part::FilletBase* fillet, QWidge ui->treeView->setModel(model); QHeaderView* header = ui->treeView->header(); -#if QT_VERSION >= 0x050000 header->setSectionResizeMode(0, QHeaderView::Stretch); header->setDefaultAlignment(Qt::AlignLeft); header->setSectionsMovable(false); -#else - header->setResizeMode(0, QHeaderView::Stretch); - header->setDefaultAlignment(Qt::AlignLeft); - header->setMovable(false); -#endif on_filletType_activated(0); findShapes(); } diff --git a/src/Mod/Part/Gui/TaskCheckGeometry.cpp b/src/Mod/Part/Gui/TaskCheckGeometry.cpp index baf4b55f56..9e7bdf28a8 100644 --- a/src/Mod/Part/Gui/TaskCheckGeometry.cpp +++ b/src/Mod/Part/Gui/TaskCheckGeometry.cpp @@ -356,17 +356,11 @@ QVariant ResultModel::headerData(int section, Qt::Orientation orientation, int r void ResultModel::setResults(ResultEntry *resultsIn) { -#if QT_VERSION >= 0x040600 this->beginResetModel(); -#endif if (root) delete root; root = resultsIn; -#if QT_VERSION >= 0x040600 this->endResetModel(); -#else - this->reset(); -#endif } ResultEntry* ResultModel::getEntry(const QModelIndex &index) From cbf9b72bb35d4c42eb40a98a4793025569589d50 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Wed, 31 Mar 2021 11:34:30 -0500 Subject: [PATCH 038/178] [Sketcher] Remove deprecated Qt < 5.9 code --- src/Mod/Sketcher/Gui/CommandConstraints.cpp | 2 -- src/Mod/Sketcher/Gui/DrawSketchHandler.cpp | 27 ------------------- .../Sketcher/Gui/TaskSketcherConstrains.cpp | 4 --- src/Mod/Sketcher/Gui/TaskSketcherGeneral.cpp | 2 -- src/Mod/Sketcher/Gui/ViewProviderSketch.cpp | 4 --- 5 files changed, 39 deletions(-) diff --git a/src/Mod/Sketcher/Gui/CommandConstraints.cpp b/src/Mod/Sketcher/Gui/CommandConstraints.cpp index 202bbf4cf7..e6aeb20df8 100644 --- a/src/Mod/Sketcher/Gui/CommandConstraints.cpp +++ b/src/Mod/Sketcher/Gui/CommandConstraints.cpp @@ -905,14 +905,12 @@ public: cursorPainter.end(); int hotX = 8; int hotY = 8; -#if QT_VERSION >= 0x050000 cursorPixmap.setDevicePixelRatio(pixelRatio); // only X11 needs hot point coordinates to be scaled if (qGuiApp->platformName() == QLatin1String("xcb")) { hotX *= pixelRatio; hotY *= pixelRatio; } -#endif setCursor(cursorPixmap, hotX, hotY, false); } diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp b/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp index 7c057cd74e..dc571a673d 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp +++ b/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp @@ -29,9 +29,7 @@ # include # include # include -# if QT_VERSION >= 0x050000 # include -# endif # include #endif // #ifndef _PreComp_ @@ -119,23 +117,18 @@ void DrawSketchHandler::setSvgCursor(const QString & cursorName, int x, int y, c qreal defaultCursorSize = isRatioOne ? 64 : 32; qreal hotX = x; qreal hotY = y; -#if QT_VERSION >= 0x050000 #if !defined(Q_OS_WIN32) && !defined(Q_OS_MAC) if (qGuiApp->platformName() == QLatin1String("xcb")) { hotX *= pRatio; hotY *= pRatio; } -#endif #endif qreal cursorSize = defaultCursorSize * pRatio; QPixmap pointer = Gui::BitmapFactory().pixmapFromSvg(cursorName.toStdString().c_str(), QSizeF(cursorSize, cursorSize), colorMapping); if (isRatioOne) pointer = pointer.scaled(32, 32); -#if QT_VERSION >= 0x050000 pointer.setDevicePixelRatio(pRatio); -#endif - setCursor(pointer, hotX, hotY, false); } @@ -151,26 +144,18 @@ void DrawSketchHandler::setCursor(const QPixmap &p,int x,int y, bool autoScale) QPixmap p1(p); // TODO remove autoScale after all cursors are SVG-based if (autoScale) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) qreal pRatio = viewer->devicePixelRatio(); -#else - qreal pRatio = 1; -#endif int newWidth = p.width()*pRatio; int newHeight = p.height()*pRatio; p1 = p1.scaled(newWidth, newHeight, Qt::KeepAspectRatio, Qt::SmoothTransformation); -#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) p1.setDevicePixelRatio(pRatio); -#endif qreal hotX = x; qreal hotY = y; -#if QT_VERSION >= 0x050000 #if !defined(Q_OS_WIN32) && !defined(Q_OS_MAC) if (qGuiApp->platformName() == QLatin1String("xcb")) { hotX *= pRatio; hotY *= pRatio; } -#endif #endif cursor = QCursor(p1, hotX, hotY); } else { @@ -190,12 +175,8 @@ void DrawSketchHandler::addCursorTail( std::vector &pixmaps ) { Gui::MDIView* view = Gui::getMainWindow()->activeWindow(); if (view && view->isDerivedFrom(Gui::View3DInventor::getClassTypeId())) { QPixmap baseIcon = QPixmap(actCursorPixmap); -#if QT_VERSION >= 0x050000 baseIcon.setDevicePixelRatio(actCursorPixmap.devicePixelRatio()); qreal pixelRatio = baseIcon.devicePixelRatio(); -#else - qreal pixelRatio = 1; -#endif // cursor size in device independent pixels qreal baseCursorWidth = baseIcon.width(); qreal baseCursorHeight = baseIcon.height(); @@ -238,11 +219,7 @@ void DrawSketchHandler::addCursorTail( std::vector &pixmaps ) { // Create the new cursor with the icon. QPoint p=actCursor.hotSpot(); - -#if QT_VERSION >= QT_VERSION_CHECK(5, 6, 0) newIcon.setDevicePixelRatio(pixelRatio); -#endif - QCursor newCursor(newIcon, p.x(), p.y()); applyCursor(newCursor); } @@ -273,13 +250,11 @@ void DrawSketchHandler::unsetCursor(void) qreal DrawSketchHandler::devicePixelRatio() { qreal pixelRatio = 1; -# if QT_VERSION >= 0x050000 Gui::MDIView* view = Gui::getMainWindow()->activeWindow(); if (view && view->isDerivedFrom(Gui::View3DInventor::getClassTypeId())) { Gui::View3DInventorViewer* viewer = static_cast(view)->getViewer(); pixelRatio = viewer->devicePixelRatio(); } -# endif return pixelRatio; } @@ -313,13 +288,11 @@ std::vector DrawSketchHandler::suggestedConstraintsPixmaps( } if (!iconType.isEmpty()) { qreal pixelRatio = 1; -# if QT_VERSION >= 0x050000 Gui::MDIView* view = Gui::getMainWindow()->activeWindow(); if (view && view->isDerivedFrom(Gui::View3DInventor::getClassTypeId())) { Gui::View3DInventorViewer* viewer = static_cast(view)->getViewer(); pixelRatio = viewer->devicePixelRatio(); } -# endif int iconWidth = 16 * pixelRatio; QPixmap icon = Gui::BitmapFactory() .pixmapFromSvg(iconType.toStdString().c_str(), QSize(iconWidth, iconWidth)); diff --git a/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp b/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp index 1134dcce36..b55fba8077 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp +++ b/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp @@ -394,11 +394,7 @@ protected: } void paint ( QPainter * painter, const QStyleOptionViewItem & option, const QModelIndex & index ) const { -#if QT_VERSION >= 0x050000 QStyleOptionViewItem options = option; -#else - QStyleOptionViewItemV4 options = option; -#endif initStyleOption(&options, index); options.widget->style()->drawControl(QStyle::CE_ItemViewItem, &options, painter); diff --git a/src/Mod/Sketcher/Gui/TaskSketcherGeneral.cpp b/src/Mod/Sketcher/Gui/TaskSketcherGeneral.cpp index 1799bf1f2e..bebd6a5844 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherGeneral.cpp +++ b/src/Mod/Sketcher/Gui/TaskSketcherGeneral.cpp @@ -49,9 +49,7 @@ SketcherGeneralWidget::SketcherGeneralWidget(QWidget *parent) : QWidget(parent), ui(new Ui_TaskSketcherGeneral) { ui->setupUi(this); -#if QT_VERSION >= 0x050200 ui->renderingOrder->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContents); -#endif // connecting the needed signals connect(ui->checkBoxShowGrid, SIGNAL(toggled(bool)), diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp index 5e5bf3a35c..34798294e2 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -1373,11 +1373,7 @@ bool ViewProviderSketch::mouseMove(const SbVec2s &cursorPos, Gui::View3DInventor } case STATUS_SKETCH_UseRubberBand: { // Here we must use the device-pixel-ratio to compute the correct y coordinate (#0003130) -#if QT_VERSION >= 0x050600 qreal dpr = viewer->getGLWidget()->devicePixelRatioF(); -#else - qreal dpr = 1; -#endif newCursorPos = cursorPos; rubberband->setCoords(prvCursorPos.getValue()[0], viewer->getGLWidget()->height()*dpr - prvCursorPos.getValue()[1], From c7212d9c21878cdad98a801a3b87bd0cf67e4245 Mon Sep 17 00:00:00 2001 From: Benjamin Nauck Date: Tue, 30 Mar 2021 22:59:16 +0200 Subject: [PATCH 039/178] Tux: Add "_dark" suffix to dark navigation icons --- src/Mod/Tux/NavigationIndicatorGui.py | 16 ++++++++-------- src/Mod/Tux/Resources/Tux.qrc | 16 ++++++++-------- ...ionBlender.svg => NavigationBlender_dark.svg} | 0 ...{NavigationCAD.svg => NavigationCAD_dark.svg} | 0 ...ionGesture.svg => NavigationGesture_dark.svg} | 0 ...esture.svg => NavigationMayaGesture_dark.svg} | 0 ...ascade.svg => NavigationOpenCascade_dark.svg} | 0 ...entor.svg => NavigationOpenInventor_dark.svg} | 0 ...igationRevit.svg => NavigationRevit_dark.svg} | 0 ...nTouchpad.svg => NavigationTouchpad_dark.svg} | 0 10 files changed, 16 insertions(+), 16 deletions(-) rename src/Mod/Tux/Resources/icons/{NavigationBlender.svg => NavigationBlender_dark.svg} (100%) rename src/Mod/Tux/Resources/icons/{NavigationCAD.svg => NavigationCAD_dark.svg} (100%) rename src/Mod/Tux/Resources/icons/{NavigationGesture.svg => NavigationGesture_dark.svg} (100%) rename src/Mod/Tux/Resources/icons/{NavigationMayaGesture.svg => NavigationMayaGesture_dark.svg} (100%) rename src/Mod/Tux/Resources/icons/{NavigationOpenCascade.svg => NavigationOpenCascade_dark.svg} (100%) rename src/Mod/Tux/Resources/icons/{NavigationOpenInventor.svg => NavigationOpenInventor_dark.svg} (100%) rename src/Mod/Tux/Resources/icons/{NavigationRevit.svg => NavigationRevit_dark.svg} (100%) rename src/Mod/Tux/Resources/icons/{NavigationTouchpad.svg => NavigationTouchpad_dark.svg} (100%) diff --git a/src/Mod/Tux/NavigationIndicatorGui.py b/src/Mod/Tux/NavigationIndicatorGui.py index c262dda552..a468eb5fdf 100644 --- a/src/Mod/Tux/NavigationIndicatorGui.py +++ b/src/Mod/Tux/NavigationIndicatorGui.py @@ -337,49 +337,49 @@ a0.setData("Undefined") a0.setObjectName("Indicator_NavigationUndefined") a1 = QtGui.QAction(gStyle) -a1.setIcon(QtGui.QIcon(":/icons/NavigationOpenInventor.svg")) +a1.setIcon(QtGui.QIcon(":/icons/NavigationOpenInventor_dark.svg")) a1.setText("OpenInventor") a1.setData("Gui::InventorNavigationStyle") a1.setObjectName("Indicator_NavigationOpenInventor") a2 = QtGui.QAction(gStyle) -a2.setIcon(QtGui.QIcon(':/icons/NavigationCAD.svg')) +a2.setIcon(QtGui.QIcon(':/icons/NavigationCAD_dark.svg')) a2.setText("CAD") a2.setData("Gui::CADNavigationStyle") a2.setObjectName("Indicator_NavigationCAD") a3 = QtGui.QAction(gStyle) -a3.setIcon(QtGui.QIcon(":/icons/NavigationRevit.svg")) +a3.setIcon(QtGui.QIcon(":/icons/NavigationRevit_dark.svg")) a3.setText("Revit") a3.setData("Gui::RevitNavigationStyle") a3.setObjectName("Indicator_NavigationRevit") a4 = QtGui.QAction(gStyle) -a4.setIcon(QtGui.QIcon(":/icons/NavigationBlender.svg")) +a4.setIcon(QtGui.QIcon(":/icons/NavigationBlender_dark.svg")) a4.setText("Blender") a4.setData("Gui::BlenderNavigationStyle") a4.setObjectName("Indicator_NavigationBlender") a5 = QtGui.QAction(gStyle) -a5.setIcon(QtGui.QIcon(":/icons/NavigationMayaGesture.svg")) +a5.setIcon(QtGui.QIcon(":/icons/NavigationMayaGesture_dark.svg")) a5.setText("MayaGesture") a5.setData("Gui::MayaGestureNavigationStyle") a5.setObjectName("Indicator_NavigationMayaGesture") a6 = QtGui.QAction(gStyle) -a6.setIcon(QtGui.QIcon(":/icons/NavigationTouchpad.svg")) +a6.setIcon(QtGui.QIcon(":/icons/NavigationTouchpad_dark.svg")) a6.setText("Touchpad") a6.setData("Gui::TouchpadNavigationStyle") a6.setObjectName("Indicator_NavigationTouchpad") a7 = QtGui.QAction(gStyle) -a7.setIcon(QtGui.QIcon(":/icons/NavigationGesture.svg")) +a7.setIcon(QtGui.QIcon(":/icons/NavigationGesture_dark.svg")) a7.setText("Gesture") a7.setData("Gui::GestureNavigationStyle") a7.setObjectName("Indicator_NavigationGesture") a8 = QtGui.QAction(gStyle) -a8.setIcon(QtGui.QIcon(":/icons/NavigationOpenCascade.svg")) +a8.setIcon(QtGui.QIcon(":/icons/NavigationOpenCascade_dark.svg")) a8.setText("OpenCascade") a8.setData("Gui::OpenCascadeNavigationStyle") a8.setObjectName("Indicator_NavigationOpenCascade") diff --git a/src/Mod/Tux/Resources/Tux.qrc b/src/Mod/Tux/Resources/Tux.qrc index e0752531af..899f777f65 100644 --- a/src/Mod/Tux/Resources/Tux.qrc +++ b/src/Mod/Tux/Resources/Tux.qrc @@ -4,14 +4,14 @@ icons/NavigationBlender_Pan.svg icons/NavigationBlender_Rotate.svg icons/NavigationBlender_Select.svg - icons/NavigationBlender.svg + icons/NavigationBlender_dark.svg icons/NavigationBlender_Zoom.svg icons/NavigationCADAlt.svg icons/NavigationCAD_Pan.svg icons/NavigationCAD_RotateAlt.svg icons/NavigationCAD_Rotate.svg icons/NavigationCAD_Select.svg - icons/NavigationCAD.svg + icons/NavigationCAD_dark.svg icons/NavigationCAD_Zoom.svg icons/NavigationGesture_Pan.svg icons/NavigationGesture_PanTouchAlt.svg @@ -21,7 +21,7 @@ icons/NavigationGesture_RotateTouch.svg icons/NavigationGesture_Select.svg icons/NavigationGesture_SelectTouch.svg - icons/NavigationGesture.svg + icons/NavigationGesture_dark.svg icons/NavigationGesture_Tilt.svg icons/NavigationGesture_TiltTouch.svg icons/NavigationGesture_Zoom.svg @@ -33,7 +33,7 @@ icons/NavigationMayaGesture_RotateTouch.svg icons/NavigationMayaGesture_Select.svg icons/NavigationMayaGesture_SelectTouch.svg - icons/NavigationMayaGesture.svg + icons/NavigationMayaGesture_dark.svg icons/NavigationMayaGesture_Tilt.svg icons/NavigationMayaGesture_TiltTouch.svg icons/NavigationMayaGesture_ZoomAlt.svg @@ -43,18 +43,18 @@ icons/NavigationOpenCascade_Pan.svg icons/NavigationOpenCascade_Rotate.svg icons/NavigationOpenCascade_Select.svg - icons/NavigationOpenCascade.svg + icons/NavigationOpenCascade_dark.svg icons/NavigationOpenCascade_ZoomAlt.svg icons/NavigationOpenCascade_Zoom.svg icons/NavigationOpenInventor_Pan.svg icons/NavigationOpenInventor_Rotate.svg icons/NavigationOpenInventor_Select.svg - icons/NavigationOpenInventor.svg + icons/NavigationOpenInventor_dark.svg icons/NavigationOpenInventor_ZoomAlt.svg icons/NavigationOpenInventor_Zoom.svg icons/NavigationRevit_Pan.svg icons/NavigationRevit_Rotate.svg - icons/NavigationRevit.svg + icons/NavigationRevit_dark.svg icons/NavigationTouchpad_Pan.svg icons/NavigationTouchpad_PanTouch.svg icons/NavigationTouchpad_RotateAlt.svg @@ -63,7 +63,7 @@ icons/NavigationTouchpad_RotateTouch.svg icons/NavigationTouchpad_Select.svg icons/NavigationTouchpad_SelectTouch.svg - icons/NavigationTouchpad.svg + icons/NavigationTouchpad_dark.svg icons/NavigationTouchpad_ZoomAlt.svg icons/NavigationTouchpad_Zoom.svg icons/NavigationTouchpad_ZoomTouch.svg diff --git a/src/Mod/Tux/Resources/icons/NavigationBlender.svg b/src/Mod/Tux/Resources/icons/NavigationBlender_dark.svg similarity index 100% rename from src/Mod/Tux/Resources/icons/NavigationBlender.svg rename to src/Mod/Tux/Resources/icons/NavigationBlender_dark.svg diff --git a/src/Mod/Tux/Resources/icons/NavigationCAD.svg b/src/Mod/Tux/Resources/icons/NavigationCAD_dark.svg similarity index 100% rename from src/Mod/Tux/Resources/icons/NavigationCAD.svg rename to src/Mod/Tux/Resources/icons/NavigationCAD_dark.svg diff --git a/src/Mod/Tux/Resources/icons/NavigationGesture.svg b/src/Mod/Tux/Resources/icons/NavigationGesture_dark.svg similarity index 100% rename from src/Mod/Tux/Resources/icons/NavigationGesture.svg rename to src/Mod/Tux/Resources/icons/NavigationGesture_dark.svg diff --git a/src/Mod/Tux/Resources/icons/NavigationMayaGesture.svg b/src/Mod/Tux/Resources/icons/NavigationMayaGesture_dark.svg similarity index 100% rename from src/Mod/Tux/Resources/icons/NavigationMayaGesture.svg rename to src/Mod/Tux/Resources/icons/NavigationMayaGesture_dark.svg diff --git a/src/Mod/Tux/Resources/icons/NavigationOpenCascade.svg b/src/Mod/Tux/Resources/icons/NavigationOpenCascade_dark.svg similarity index 100% rename from src/Mod/Tux/Resources/icons/NavigationOpenCascade.svg rename to src/Mod/Tux/Resources/icons/NavigationOpenCascade_dark.svg diff --git a/src/Mod/Tux/Resources/icons/NavigationOpenInventor.svg b/src/Mod/Tux/Resources/icons/NavigationOpenInventor_dark.svg similarity index 100% rename from src/Mod/Tux/Resources/icons/NavigationOpenInventor.svg rename to src/Mod/Tux/Resources/icons/NavigationOpenInventor_dark.svg diff --git a/src/Mod/Tux/Resources/icons/NavigationRevit.svg b/src/Mod/Tux/Resources/icons/NavigationRevit_dark.svg similarity index 100% rename from src/Mod/Tux/Resources/icons/NavigationRevit.svg rename to src/Mod/Tux/Resources/icons/NavigationRevit_dark.svg diff --git a/src/Mod/Tux/Resources/icons/NavigationTouchpad.svg b/src/Mod/Tux/Resources/icons/NavigationTouchpad_dark.svg similarity index 100% rename from src/Mod/Tux/Resources/icons/NavigationTouchpad.svg rename to src/Mod/Tux/Resources/icons/NavigationTouchpad_dark.svg From 67bbb6110373e20b37d0b99133e556948a9984dd Mon Sep 17 00:00:00 2001 From: Benjamin Nauck Date: Tue, 30 Mar 2021 22:59:49 +0200 Subject: [PATCH 040/178] Tux: Add "_light" suffix to light navigation icons --- src/Mod/Tux/Resources/Tux.qrc | 8 ++++++ .../icons/NavigationBlender_light.svg | 28 +++++++++++++++++++ .../Resources/icons/NavigationCAD_light.svg | 16 +++++++++++ .../icons/NavigationGesture_light.svg | 21 ++++++++++++++ .../icons/NavigationMayaGesture_light.svg | 17 +++++++++++ .../icons/NavigationOpenCascade_light.svg | 17 +++++++++++ .../icons/NavigationOpenInventor_light.svg | 18 ++++++++++++ .../Resources/icons/NavigationRevit_light.svg | 21 ++++++++++++++ .../icons/NavigationTouchpad_light.svg | 8 ++++++ 9 files changed, 154 insertions(+) create mode 100644 src/Mod/Tux/Resources/icons/NavigationBlender_light.svg create mode 100644 src/Mod/Tux/Resources/icons/NavigationCAD_light.svg create mode 100644 src/Mod/Tux/Resources/icons/NavigationGesture_light.svg create mode 100644 src/Mod/Tux/Resources/icons/NavigationMayaGesture_light.svg create mode 100644 src/Mod/Tux/Resources/icons/NavigationOpenCascade_light.svg create mode 100644 src/Mod/Tux/Resources/icons/NavigationOpenInventor_light.svg create mode 100644 src/Mod/Tux/Resources/icons/NavigationRevit_light.svg create mode 100644 src/Mod/Tux/Resources/icons/NavigationTouchpad_light.svg diff --git a/src/Mod/Tux/Resources/Tux.qrc b/src/Mod/Tux/Resources/Tux.qrc index 899f777f65..20375941b1 100644 --- a/src/Mod/Tux/Resources/Tux.qrc +++ b/src/Mod/Tux/Resources/Tux.qrc @@ -4,6 +4,7 @@ icons/NavigationBlender_Pan.svg icons/NavigationBlender_Rotate.svg icons/NavigationBlender_Select.svg + icons/NavigationBlender_light.svg icons/NavigationBlender_dark.svg icons/NavigationBlender_Zoom.svg icons/NavigationCADAlt.svg @@ -11,6 +12,7 @@ icons/NavigationCAD_RotateAlt.svg icons/NavigationCAD_Rotate.svg icons/NavigationCAD_Select.svg + icons/NavigationCAD_light.svg icons/NavigationCAD_dark.svg icons/NavigationCAD_Zoom.svg icons/NavigationGesture_Pan.svg @@ -21,6 +23,7 @@ icons/NavigationGesture_RotateTouch.svg icons/NavigationGesture_Select.svg icons/NavigationGesture_SelectTouch.svg + icons/NavigationGesture_light.svg icons/NavigationGesture_dark.svg icons/NavigationGesture_Tilt.svg icons/NavigationGesture_TiltTouch.svg @@ -33,6 +36,7 @@ icons/NavigationMayaGesture_RotateTouch.svg icons/NavigationMayaGesture_Select.svg icons/NavigationMayaGesture_SelectTouch.svg + icons/NavigationMayaGesture_light.svg icons/NavigationMayaGesture_dark.svg icons/NavigationMayaGesture_Tilt.svg icons/NavigationMayaGesture_TiltTouch.svg @@ -43,17 +47,20 @@ icons/NavigationOpenCascade_Pan.svg icons/NavigationOpenCascade_Rotate.svg icons/NavigationOpenCascade_Select.svg + icons/NavigationOpenCascade_light.svg icons/NavigationOpenCascade_dark.svg icons/NavigationOpenCascade_ZoomAlt.svg icons/NavigationOpenCascade_Zoom.svg icons/NavigationOpenInventor_Pan.svg icons/NavigationOpenInventor_Rotate.svg icons/NavigationOpenInventor_Select.svg + icons/NavigationOpenInventor_light.svg icons/NavigationOpenInventor_dark.svg icons/NavigationOpenInventor_ZoomAlt.svg icons/NavigationOpenInventor_Zoom.svg icons/NavigationRevit_Pan.svg icons/NavigationRevit_Rotate.svg + icons/NavigationRevit_light.svg icons/NavigationRevit_dark.svg icons/NavigationTouchpad_Pan.svg icons/NavigationTouchpad_PanTouch.svg @@ -63,6 +70,7 @@ icons/NavigationTouchpad_RotateTouch.svg icons/NavigationTouchpad_Select.svg icons/NavigationTouchpad_SelectTouch.svg + icons/NavigationTouchpad_light.svg icons/NavigationTouchpad_dark.svg icons/NavigationTouchpad_ZoomAlt.svg icons/NavigationTouchpad_Zoom.svg diff --git a/src/Mod/Tux/Resources/icons/NavigationBlender_light.svg b/src/Mod/Tux/Resources/icons/NavigationBlender_light.svg new file mode 100644 index 0000000000..e538cdd4bf --- /dev/null +++ b/src/Mod/Tux/Resources/icons/NavigationBlender_light.svg @@ -0,0 +1,28 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Mod/Tux/Resources/icons/NavigationCAD_light.svg b/src/Mod/Tux/Resources/icons/NavigationCAD_light.svg new file mode 100644 index 0000000000..03e355cb7f --- /dev/null +++ b/src/Mod/Tux/Resources/icons/NavigationCAD_light.svg @@ -0,0 +1,16 @@ + + + + + + image/svg+xml + + + + + + + + + + diff --git a/src/Mod/Tux/Resources/icons/NavigationGesture_light.svg b/src/Mod/Tux/Resources/icons/NavigationGesture_light.svg new file mode 100644 index 0000000000..d7000f96d0 --- /dev/null +++ b/src/Mod/Tux/Resources/icons/NavigationGesture_light.svg @@ -0,0 +1,21 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + diff --git a/src/Mod/Tux/Resources/icons/NavigationMayaGesture_light.svg b/src/Mod/Tux/Resources/icons/NavigationMayaGesture_light.svg new file mode 100644 index 0000000000..53357798ca --- /dev/null +++ b/src/Mod/Tux/Resources/icons/NavigationMayaGesture_light.svg @@ -0,0 +1,17 @@ + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/src/Mod/Tux/Resources/icons/NavigationOpenCascade_light.svg b/src/Mod/Tux/Resources/icons/NavigationOpenCascade_light.svg new file mode 100644 index 0000000000..74bc3f2c07 --- /dev/null +++ b/src/Mod/Tux/Resources/icons/NavigationOpenCascade_light.svg @@ -0,0 +1,17 @@ + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/src/Mod/Tux/Resources/icons/NavigationOpenInventor_light.svg b/src/Mod/Tux/Resources/icons/NavigationOpenInventor_light.svg new file mode 100644 index 0000000000..3f4e362198 --- /dev/null +++ b/src/Mod/Tux/Resources/icons/NavigationOpenInventor_light.svg @@ -0,0 +1,18 @@ + + + + + + image/svg+xml + + + + + + + + + + + + diff --git a/src/Mod/Tux/Resources/icons/NavigationRevit_light.svg b/src/Mod/Tux/Resources/icons/NavigationRevit_light.svg new file mode 100644 index 0000000000..2716cffa05 --- /dev/null +++ b/src/Mod/Tux/Resources/icons/NavigationRevit_light.svg @@ -0,0 +1,21 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + diff --git a/src/Mod/Tux/Resources/icons/NavigationTouchpad_light.svg b/src/Mod/Tux/Resources/icons/NavigationTouchpad_light.svg new file mode 100644 index 0000000000..15c04e21c2 --- /dev/null +++ b/src/Mod/Tux/Resources/icons/NavigationTouchpad_light.svg @@ -0,0 +1,8 @@ + + + + + + + + From 098d7b9aee9cacef7e957cd46042087153d6ddd8 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Tue, 30 Mar 2021 15:38:26 -0500 Subject: [PATCH 041/178] [GUI] Remove code for Qt < 5.9 --- src/Gui/Action.cpp | 8 +- src/Gui/BitmapFactory.cpp | 105 +-------------------- src/Gui/CommandDoc.cpp | 12 --- src/Gui/CommandStd.cpp | 7 -- src/Gui/CommandView.cpp | 12 --- src/Gui/DAGView/DAGRectItem.cpp | 4 - src/Gui/DlgActionsImp.cpp | 4 - src/Gui/DlgCommandsImp.cpp | 4 - src/Gui/DlgCustomizeSpaceball.cpp | 4 - src/Gui/DlgExpressionInput.cpp | 4 - src/Gui/DlgGeneralImp.cpp | 2 - src/Gui/DlgKeyboardImp.cpp | 4 - src/Gui/DlgObjectSelection.cpp | 9 +- src/Gui/DlgParameterImp.cpp | 16 ---- src/Gui/DlgPreferencesImp.cpp | 8 +- src/Gui/DlgSettingsImageImp.cpp | 8 -- src/Gui/DlgToolbarsImp.cpp | 4 - src/Gui/DocumentRecovery.cpp | 4 - src/Gui/DownloadItem.cpp | 22 ----- src/Gui/DownloadManager.cpp | 29 ------ src/Gui/ExpressionCompleter.cpp | 17 +--- src/Gui/FileDialog.cpp | 54 ----------- src/Gui/GraphicsViewZoom.cpp | 11 --- src/Gui/GraphvizView.cpp | 24 ----- src/Gui/GuiApplication.cpp | 5 - src/Gui/GuiApplicationNativeEventAware.cpp | 7 -- src/Gui/GuiApplicationNativeEventAware.h | 3 - src/Gui/InputField.cpp | 4 - src/Gui/MDIView.cpp | 4 - src/Gui/MainWindow.cpp | 49 +--------- src/Gui/MouseSelection.cpp | 8 -- src/Gui/NavigationStyle.h | 4 - src/Gui/NetworkRetriever.cpp | 4 - src/Gui/OnlineDocumentation.cpp | 4 - src/Gui/OnlineDocumentation.h | 4 - src/Gui/ProgressBar.cpp | 7 +- src/Gui/PropertyPage.cpp | 2 - src/Gui/Qt4All.h | 14 --- src/Gui/Quarter/EventFilter.cpp | 4 - src/Gui/Quarter/Mouse.cpp | 14 --- src/Gui/Quarter/QuarterWidget.cpp | 20 ---- src/Gui/SceneInspector.cpp | 5 - src/Gui/SelectionView.cpp | 4 - src/Gui/SoFCOffscreenRenderer.cpp | 5 - src/Gui/Splashscreen.cpp | 4 - src/Gui/SyntaxHighlighter.cpp | 6 -- src/Gui/TaskView/TaskDialogPython.cpp | 2 - src/Gui/TreeView.cpp | 3 - src/Gui/View3DInventorViewer.cpp | 7 -- src/Gui/WaitCursor.cpp | 6 +- src/Gui/WidgetFactory.cpp | 98 ++----------------- src/Gui/Widgets.cpp | 8 -- src/Gui/Widgets.h | 4 - src/Gui/WinNativeGestureRecognizers.h | 8 -- src/Gui/iisTaskPanel/src/iisiconlabel.cpp | 4 - src/Gui/iisTaskPanel/src/iistaskbox.cpp | 6 -- src/Gui/iisTaskPanel/src/iistaskheader.cpp | 2 - 57 files changed, 19 insertions(+), 686 deletions(-) diff --git a/src/Gui/Action.cpp b/src/Gui/Action.cpp index b167bf0a6e..9fea44fa97 100644 --- a/src/Gui/Action.cpp +++ b/src/Gui/Action.cpp @@ -37,9 +37,7 @@ # include #endif -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) -# include -#endif +#include #include #include "Action.h" @@ -431,11 +429,7 @@ void WorkbenchComboBox::showPopup() int rows = count(); if (rows > 0) { int height = view()->sizeHintForRow(0); -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) int maxHeight = QApplication::primaryScreen()->size().height(); -#else - int maxHeight = QApplication::desktop()->height(); -#endif view()->setMinimumHeight(qMin(height * rows, maxHeight/2)); } diff --git a/src/Gui/BitmapFactory.cpp b/src/Gui/BitmapFactory.cpp index ed3023e33c..bfa5317cf1 100644 --- a/src/Gui/BitmapFactory.cpp +++ b/src/Gui/BitmapFactory.cpp @@ -37,14 +37,6 @@ # include # include #endif -#if defined (FC_OS_WIN32) && QT_VERSION < 0x050000 -#define QTWEBKIT -#endif - -#ifdef QTWEBKIT -#include -#include -#endif #include #include @@ -177,9 +169,7 @@ QStringList BitmapFactoryInst::findIconFiles() const filters << QString::fromLatin1("*.%1").arg(QString::fromLatin1(*it).toLower()); QStringList paths = QDir::searchPaths(QString::fromLatin1("icons")); -#if QT_VERSION >= 0x040500 paths.removeDuplicates(); -#endif for (QStringList::ConstIterator pt = paths.begin(); pt != paths.end(); ++pt) { QDir d(*pt); d.setNameFilters(filters); @@ -188,9 +178,7 @@ QStringList BitmapFactoryInst::findIconFiles() const files << it->absoluteFilePath(); } -#if QT_VERSION >= 0x040500 files.removeDuplicates(); -#endif return files; } @@ -334,7 +322,7 @@ QPixmap BitmapFactoryInst::pixmapFromSvg(const char* name, const QSizeF& size, } QPixmap BitmapFactoryInst::pixmapFromSvg(const QByteArray& originalContents, const QSizeF& size, - const std::map& colorMapping) const + const std::map& colorMapping) const { QString stringContents = QString::fromUtf8(originalContents); for ( const auto &colorToColor : colorMapping ) { @@ -346,91 +334,6 @@ QPixmap BitmapFactoryInst::pixmapFromSvg(const QByteArray& originalContents, con } QByteArray contents = stringContents.toUtf8(); -#ifdef QTWEBKIT - // There is a crash when using the Webkit engine in debug mode - // for a couple of SVG files. Thus, use the qsvg plugin. -#if QT_VERSION < 0x040800 || !defined(_DEBUG) - QWebView webView; - QPalette pal = webView.palette(); - pal.setColor(QPalette::Background, Qt::transparent); - webView.setPalette(pal); - webView.setContent(contents, QString::fromLatin1("image/svg+xml")); - QString node = QString::fromLatin1("document.rootElement.nodeName"); - QWebFrame* frame = webView.page()->mainFrame(); - if (!frame) { - return QPixmap(); - } - - QString root = frame->evaluateJavaScript(node).toString(); - if (root.isEmpty() || root.compare(QLatin1String("svg"), Qt::CaseInsensitive)) { - return QPixmap(); - } - - QString w = QString::fromLatin1("document.rootElement.width.baseVal.value"); - QString h = QString::fromLatin1("document.rootElement.height.baseVal.value"); - double ww = frame->evaluateJavaScript(w).toDouble(); - double hh = frame->evaluateJavaScript(h).toDouble(); - if (ww == 0.0 || hh == 0.0) - return QPixmap(); - - QImage image(size, QImage::Format_ARGB32_Premultiplied); - image.fill(0x00000000); - - QPainter p(&image); - qreal xs = size.isValid() ? size.width() / ww : 1.0; - qreal ys = size.isValid() ? size.height() / hh : 1.0; - p.scale(xs, ys); - - // the best quality - p.setRenderHint(QPainter::Antialiasing); - p.setRenderHint(QPainter::TextAntialiasing); - p.setRenderHint(QPainter::SmoothPixmapTransform); - p.setOpacity(0); // important to keep transparent background - frame->render(&p); - p.end(); - - return QPixmap::fromImage(image); -#else // QT_VERSION - QWebPage webPage; - QPalette pal = webPage.palette(); - pal.setColor(QPalette::Background, Qt::transparent); - webPage.setPalette(pal); - QWebFrame* frame = webPage.mainFrame(); - if (!frame) { - return QPixmap(); - } - frame->setContent(contents, QString::fromLatin1("image/svg+xml")); - // Important to exclude user events here because otherwise - // it may happen that an item the icon is created for gets - // deleted in the meantime. This happens e.g. dragging over - // the categories in the commands panel very quickly. - qApp->processEvents(QEventLoop::ExcludeUserInputEvents); - webPage.setViewportSize(webPage.mainFrame()->contentsSize()); - - double ww = webPage.viewportSize().width(); - double hh = webPage.viewportSize().height(); - if (ww == 0.0 || hh == 0.0) - return QPixmap(); - - QImage image(size, QImage::Format_ARGB32_Premultiplied); - image.fill(0x00000000); - - QPainter p(&image); - qreal xs = size.isValid() ? size.width() / ww : 1.0; - qreal ys = size.isValid() ? size.height() / hh : 1.0; - p.scale(xs, ys); - - // the best quality - p.setRenderHint(QPainter::Antialiasing); - p.setRenderHint(QPainter::TextAntialiasing); - p.setRenderHint(QPainter::SmoothPixmapTransform); - p.setOpacity(0); // important to keep transparent background - frame->render(&p); - p.end(); - - return QPixmap::fromImage(image); -#endif // QT_VERSION -#else //QTWEBKIT QImage image(size.toSize(), QImage::Format_ARGB32_Premultiplied); image.fill(0x00000000); @@ -443,7 +346,6 @@ QPixmap BitmapFactoryInst::pixmapFromSvg(const QByteArray& originalContents, con p.end(); return QPixmap::fromImage(image); -#endif } QStringList BitmapFactoryInst::pixmapNames() const @@ -583,13 +485,8 @@ QPixmap BitmapFactoryInst::merge(const QPixmap& p1, const QPixmap& p2, Position { // does the similar as the method above except that this method does not resize the resulting pixmap int x = 0, y = 0; -#if QT_VERSION >= 0x050000 qreal dpr1 = p1.devicePixelRatio(); qreal dpr2 = p2.devicePixelRatio(); -#else - qreal dpr1 = 1; - qreal dpr2 = 1; -#endif switch (pos) { diff --git a/src/Gui/CommandDoc.cpp b/src/Gui/CommandDoc.cpp index 67a3cc8397..066d876a17 100644 --- a/src/Gui/CommandDoc.cpp +++ b/src/Gui/CommandDoc.cpp @@ -677,9 +677,7 @@ StdCmdSaveAs::StdCmdSaveAs() sToolTipText = QT_TR_NOOP("Save the active document under a new file name"); sWhatsThis = "Std_SaveAs"; sStatusTip = QT_TR_NOOP("Save the active document under a new file name"); -#if QT_VERSION >= 0x040200 sPixmap = "document-save-as"; -#endif sAccel = keySequenceToAccel(QKeySequence::SaveAs); eType = 0; } @@ -819,9 +817,7 @@ StdCmdProjectInfo::StdCmdProjectInfo() sToolTipText = QT_TR_NOOP("Show details of the currently active project"); sWhatsThis = "Std_ProjectInfo"; sStatusTip = QT_TR_NOOP("Show details of the currently active project"); -#if QT_VERSION >= 0x040200 sPixmap = "document-properties"; -#endif } void StdCmdProjectInfo::activated(int iMsg) @@ -973,9 +969,7 @@ StdCmdQuit::StdCmdQuit() sToolTipText = QT_TR_NOOP("Quits the application"); sWhatsThis = "Std_Quit"; sStatusTip = QT_TR_NOOP("Quits the application"); -#if QT_VERSION >= 0x040200 sPixmap = "application-exit"; -#endif sAccel = "Alt+F4"; eType = NoTransaction; } @@ -1278,9 +1272,7 @@ StdCmdSelectAll::StdCmdSelectAll() sToolTipText = QT_TR_NOOP("Select all"); sWhatsThis = "Std_SelectAll"; sStatusTip = QT_TR_NOOP("Select all"); -#if QT_VERSION >= 0x040200 sPixmap = "edit-select-all"; -#endif //sAccel = "Ctrl+A"; // superseeds shortcuts for text edits } @@ -1311,9 +1303,7 @@ StdCmdDelete::StdCmdDelete() sToolTipText = QT_TR_NOOP("Deletes the selected objects"); sWhatsThis = "Std_Delete"; sStatusTip = QT_TR_NOOP("Deletes the selected objects"); -#if QT_VERSION >= 0x040200 sPixmap = "edit-delete"; -#endif sAccel = keySequenceToAccel(QKeySequence::Delete); eType = ForEdit; } @@ -1704,9 +1694,7 @@ StdCmdEdit::StdCmdEdit() sWhatsThis = "Std_Edit"; sStatusTip = QT_TR_NOOP("Activates or Deactivates the selected object's edit mode"); sAccel = ""; -#if QT_VERSION >= 0x040200 sPixmap = "edit-edit"; -#endif eType = ForEdit; } diff --git a/src/Gui/CommandStd.cpp b/src/Gui/CommandStd.cpp index 8166e27059..1259b5a3b3 100644 --- a/src/Gui/CommandStd.cpp +++ b/src/Gui/CommandStd.cpp @@ -27,11 +27,9 @@ # include # include # include -#if QT_VERSION >= 0x040200 # include # include #endif -#endif #include @@ -245,13 +243,8 @@ Action * StdCmdAbout::createAction(void) pcAction->setWhatsThis(QLatin1String(sWhatsThis)); pcAction->setIcon(QApplication::windowIcon()); pcAction->setShortcut(QString::fromLatin1(sAccel)); -#if QT_VERSION > 0x050000 // Needs to have AboutRole set to avoid duplicates if adding the about action more than once on macOS pcAction->setMenuRole(QAction::AboutRole); -#else - // With Qt 4.8, having AboutRole set causes it to disappear when readding it: issue #0001485 - pcAction->setMenuRole(QAction::ApplicationSpecificRole); -#endif return pcAction; } diff --git a/src/Gui/CommandView.cpp b/src/Gui/CommandView.cpp index 385bbe5676..2300c1e7b6 100644 --- a/src/Gui/CommandView.cpp +++ b/src/Gui/CommandView.cpp @@ -1520,9 +1520,7 @@ StdCmdViewFitSelection::StdCmdViewFitSelection() sWhatsThis = "Std_ViewFitSelection"; sStatusTip = QT_TR_NOOP("Fits the selected content on the screen"); sAccel = "V, S"; -#if QT_VERSION >= 0x040200 sPixmap = "zoom-selection"; -#endif eType = Alter3DView; } @@ -2494,9 +2492,7 @@ StdViewZoomIn::StdViewZoomIn() sToolTipText = QT_TR_NOOP("Zoom In"); sWhatsThis = "Std_ViewZoomIn"; sStatusTip = QT_TR_NOOP("Zoom In"); -#if QT_VERSION >= 0x040200 sPixmap = "zoom-in"; -#endif sAccel = keySequenceToAccel(QKeySequence::ZoomIn); eType = Alter3DView; } @@ -2529,9 +2525,7 @@ StdViewZoomOut::StdViewZoomOut() sToolTipText = QT_TR_NOOP("Zoom Out"); sWhatsThis = "Std_ViewZoomOut"; sStatusTip = QT_TR_NOOP("Zoom Out"); -#if QT_VERSION >= 0x040200 sPixmap = "zoom-out"; -#endif sAccel = keySequenceToAccel(QKeySequence::ZoomOut); eType = Alter3DView; } @@ -2564,9 +2558,7 @@ StdViewBoxZoom::StdViewBoxZoom() sToolTipText = QT_TR_NOOP("Box zoom"); sWhatsThis = "Std_ViewBoxZoom"; sStatusTip = QT_TR_NOOP("Box zoom"); -#if QT_VERSION >= 0x040200 sPixmap = "zoom-border"; -#endif sAccel = "Ctrl+B"; eType = Alter3DView; } @@ -2595,9 +2587,7 @@ StdBoxSelection::StdBoxSelection() sToolTipText = QT_TR_NOOP("Box selection"); sWhatsThis = "Std_BoxSelection"; sStatusTip = QT_TR_NOOP("Box selection"); -#if QT_VERSION >= 0x040200 sPixmap = "edit-select-box"; -#endif sAccel = "Shift+B"; eType = AlterSelection; } @@ -2819,9 +2809,7 @@ StdBoxElementSelection::StdBoxElementSelection() sToolTipText = QT_TR_NOOP("Box element selection"); sWhatsThis = "Std_BoxElementSelection"; sStatusTip = QT_TR_NOOP("Box element selection"); -#if QT_VERSION >= 0x040200 sPixmap = "edit-element-select-box"; -#endif sAccel = "Shift+E"; eType = AlterSelection; } diff --git a/src/Gui/DAGView/DAGRectItem.cpp b/src/Gui/DAGView/DAGRectItem.cpp index c4661503d6..1f024ab064 100644 --- a/src/Gui/DAGView/DAGRectItem.cpp +++ b/src/Gui/DAGView/DAGRectItem.cpp @@ -46,11 +46,7 @@ void RectItem::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, Q_UNUSED(widget); painter->save(); -#if QT_VERSION >= 0x050000 QStyleOptionViewItem styleOption; -#else - QStyleOptionViewItemV4 styleOption; -#endif styleOption.backgroundBrush = backgroundBrush; if (editing) diff --git a/src/Gui/DlgActionsImp.cpp b/src/Gui/DlgActionsImp.cpp index 9cc3de483c..35aa3b9f0b 100644 --- a/src/Gui/DlgActionsImp.cpp +++ b/src/Gui/DlgActionsImp.cpp @@ -83,11 +83,7 @@ DlgCustomActionsImp::DlgCustomActionsImp( QWidget* parent ) ui->actionListWidget->setHeaderLabels(labels); ui->actionListWidget->header()->hide(); ui->actionListWidget->setIconSize(QSize(32, 32)); -#if QT_VERSION >= 0x050000 ui->actionListWidget->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents); -#else - ui->actionListWidget->header()->setResizeMode(0, QHeaderView::ResizeToContents); -#endif showActions(); } diff --git a/src/Gui/DlgCommandsImp.cpp b/src/Gui/DlgCommandsImp.cpp index 2b43fd235b..ba478bbc97 100644 --- a/src/Gui/DlgCommandsImp.cpp +++ b/src/Gui/DlgCommandsImp.cpp @@ -118,11 +118,7 @@ DlgCustomCommandsImp::DlgCustomCommandsImp( QWidget* parent ) ui->commandTreeWidget->setHeaderLabels(labels); ui->commandTreeWidget->header()->hide(); ui->commandTreeWidget->setIconSize(QSize(32, 32)); -#if QT_VERSION >= 0x050000 ui->commandTreeWidget->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents); -#else - ui->commandTreeWidget->header()->setResizeMode(0, QHeaderView::ResizeToContents); -#endif ui->categoryTreeWidget->setCurrentItem(ui->categoryTreeWidget->topLevelItem(0)); } diff --git a/src/Gui/DlgCustomizeSpaceball.cpp b/src/Gui/DlgCustomizeSpaceball.cpp index 23c96bcb9b..ae8296d5e5 100644 --- a/src/Gui/DlgCustomizeSpaceball.cpp +++ b/src/Gui/DlgCustomizeSpaceball.cpp @@ -783,11 +783,7 @@ void DlgCustomizeSpaceball::goPrint() { QTableView *view = new QTableView(this); PrintModel *model = new PrintModel(this, buttonModel, commandModel); -#if QT_VERSION >= 0x050000 view->horizontalHeader()->setSectionResizeMode(QHeaderView::Fixed); -#else - view->horizontalHeader()->setResizeMode(QHeaderView::Fixed); -#endif view->setModel(model); view->horizontalHeader()->resizeSection(0, 150); view->horizontalHeader()->resizeSection(1, 300); diff --git a/src/Gui/DlgExpressionInput.cpp b/src/Gui/DlgExpressionInput.cpp index 2c35fcac88..a66559f341 100644 --- a/src/Gui/DlgExpressionInput.cpp +++ b/src/Gui/DlgExpressionInput.cpp @@ -65,11 +65,7 @@ DlgExpressionInput::DlgExpressionInput(const App::ObjectIdentifier & _path, } else { QVariant text = parent->property("text"); -#if QT_VERSION >= 0x050000 if (text.canConvert(QMetaType::QString)) { -#else - if (text.canConvert(QVariant::String)) { -#endif ui->expression->setText(text.toString()); } } diff --git a/src/Gui/DlgGeneralImp.cpp b/src/Gui/DlgGeneralImp.cpp index 37ebac3f3b..39075aefa9 100644 --- a/src/Gui/DlgGeneralImp.cpp +++ b/src/Gui/DlgGeneralImp.cpp @@ -193,7 +193,6 @@ void DlgGeneralImp::loadSettings() QByteArray lang = it->first.c_str(); QString langname = QString::fromLatin1(lang.constData()); -#if QT_VERSION >= 0x040800 QLocale locale(QString::fromLatin1(it->second.c_str())); QString native = locale.nativeLanguageName(); if (!native.isEmpty()) { @@ -201,7 +200,6 @@ void DlgGeneralImp::loadSettings() native[0] = native[0].toUpper(); langname = native; } -#endif ui->Languages->addItem(langname, lang); if (language == lang) { diff --git a/src/Gui/DlgKeyboardImp.cpp b/src/Gui/DlgKeyboardImp.cpp index b25581635d..e6c9403c06 100644 --- a/src/Gui/DlgKeyboardImp.cpp +++ b/src/Gui/DlgKeyboardImp.cpp @@ -109,11 +109,7 @@ DlgCustomKeyboardImp::DlgCustomKeyboardImp( QWidget* parent ) ui->commandTreeWidget->setHeaderLabels(labels); ui->commandTreeWidget->header()->hide(); ui->commandTreeWidget->setIconSize(QSize(32, 32)); -#if QT_VERSION >= 0x050000 ui->commandTreeWidget->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents); -#else - ui->commandTreeWidget->header()->setResizeMode(0, QHeaderView::ResizeToContents); -#endif ui->assignedTreeWidget->setHeaderLabels(labels); ui->assignedTreeWidget->header()->hide(); diff --git a/src/Gui/DlgObjectSelection.cpp b/src/Gui/DlgObjectSelection.cpp index a017154dea..1556b310e6 100644 --- a/src/Gui/DlgObjectSelection.cpp +++ b/src/Gui/DlgObjectSelection.cpp @@ -46,19 +46,12 @@ DlgObjectSelection::DlgObjectSelection( ui->setupUi(this); // make sure to show a horizontal scrollbar if needed -#if QT_VERSION >= 0x050000 ui->depList->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents); ui->depList->header()->setSectionResizeMode(1, QHeaderView::ResizeToContents); ui->depList->header()->setSectionResizeMode(2, QHeaderView::ResizeToContents); ui->depList->header()->setSectionResizeMode(3, QHeaderView::ResizeToContents); ui->treeWidget->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents); -#else - ui->depList->header()->setResizeMode(0, QHeaderView::ResizeToContents); - ui->depList->header()->setResizeMode(1, QHeaderView::ResizeToContents); - ui->depList->header()->setResizeMode(2, QHeaderView::ResizeToContents); - ui->depList->header()->setResizeMode(3, QHeaderView::ResizeToContents); - ui->treeWidget->header()->setResizeMode(0, QHeaderView::ResizeToContents); -#endif + ui->depList->header()->setStretchLastSection(false); ui->depList->headerItem()->setText(0, tr("Dependency")); ui->depList->headerItem()->setText(1, tr("Document")); diff --git a/src/Gui/DlgParameterImp.cpp b/src/Gui/DlgParameterImp.cpp index 8ff85d9c6a..35d8db2108 100644 --- a/src/Gui/DlgParameterImp.cpp +++ b/src/Gui/DlgParameterImp.cpp @@ -70,25 +70,19 @@ DlgParameterImp::DlgParameterImp( QWidget* parent, Qt::WindowFlags fl ) paramGroup = new ParameterGroup(ui->splitter3); paramGroup->setHeaderLabels(groupLabels); paramGroup->setRootIsDecorated(false); -#if QT_VERSION >= 0x050000 paramGroup->setSortingEnabled(true); paramGroup->sortByColumn(0, Qt::AscendingOrder); paramGroup->header()->setProperty("showSortIndicator", QVariant(true)); -#endif QStringList valueLabels; valueLabels << tr( "Name" ) << tr( "Type" ) << tr( "Value" ); paramValue = new ParameterValue(ui->splitter3); paramValue->setHeaderLabels(valueLabels); paramValue->setRootIsDecorated(false); -#if QT_VERSION >= 0x050000 paramValue->header()->setSectionResizeMode(0, QHeaderView::Stretch); paramValue->setSortingEnabled(true); paramValue->sortByColumn(0, Qt::AscendingOrder); paramValue->header()->setProperty("showSortIndicator", QVariant(true)); -#else - paramValue->header()->setResizeMode(0, QHeaderView::Stretch); -#endif QSizePolicy policy = paramValue->sizePolicy(); policy.setHorizontalStretch(3); @@ -128,9 +122,7 @@ DlgParameterImp::DlgParameterImp( QWidget* parent, Qt::WindowFlags fl ) // set a placeholder text to inform the user // (QLineEdit has no placeholderText property in Qt4) -#if QT_VERSION >= 0x050200 ui->findGroupLE->setPlaceholderText(tr("Search Group")); -#endif } /** @@ -238,7 +230,6 @@ void DlgParameterImp::changeEvent(QEvent *e) void DlgParameterImp::on_checkSort_toggled(bool on) { -#if QT_VERSION >= 0x050000 paramGroup->setSortingEnabled(on); paramGroup->sortByColumn(0, Qt::AscendingOrder); paramGroup->header()->setProperty("showSortIndicator", QVariant(on)); @@ -246,9 +237,6 @@ void DlgParameterImp::on_checkSort_toggled(bool on) paramValue->setSortingEnabled(on); paramValue->sortByColumn(0, Qt::AscendingOrder); paramValue->header()->setProperty("showSortIndicator", QVariant(on)); -#else - Q_UNUSED(on) -#endif } void DlgParameterImp::on_closeButton_clicked() @@ -733,16 +721,12 @@ void ParameterValue::keyPressEvent (QKeyEvent* event) void ParameterValue::resizeEvent(QResizeEvent* event) { -#if QT_VERSION >= 0x050000 QHeaderView* hv = header(); hv->setSectionResizeMode(QHeaderView::Stretch); -#endif QTreeWidget::resizeEvent(event); -#if QT_VERSION >= 0x050000 hv->setSectionResizeMode(QHeaderView::Interactive); -#endif } void ParameterValue::onChangeSelectedItem(QTreeWidgetItem* item, int col) diff --git a/src/Gui/DlgPreferencesImp.cpp b/src/Gui/DlgPreferencesImp.cpp index e70981521a..d547121d94 100644 --- a/src/Gui/DlgPreferencesImp.cpp +++ b/src/Gui/DlgPreferencesImp.cpp @@ -34,9 +34,7 @@ # include #endif -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) -# include -#endif +#include #include #include @@ -410,11 +408,7 @@ void DlgPreferencesImp::resizeEvent(QResizeEvent* ev) if (canEmbedScrollArea) { // embed the widget stack into a scroll area if the size is // bigger than the available desktop -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) QRect rect = QApplication::primaryScreen()->availableGeometry(); -#else - QRect rect = QApplication::desktop()->availableGeometry(); -#endif int maxHeight = rect.height() - 60; int maxWidth = rect.width(); if (height() > maxHeight || width() > maxWidth) { diff --git a/src/Gui/DlgSettingsImageImp.cpp b/src/Gui/DlgSettingsImageImp.cpp index e8a326a604..e6d271091e 100644 --- a/src/Gui/DlgSettingsImageImp.cpp +++ b/src/Gui/DlgSettingsImageImp.cpp @@ -53,9 +53,6 @@ DlgSettingsImageImp::DlgSettingsImageImp( QWidget* parent ) ui->comboMethod->addItem(tr("Offscreen (Old)"), QByteArray("CoinOffscreenRenderer")); ui->comboMethod->addItem(tr("Framebuffer (custom)"), QByteArray("FramebufferObject")); ui->comboMethod->addItem(tr("Framebuffer (as is)"), QByteArray("GrabFramebuffer")); -#if QT_VERSION < 0x050000 - ui->comboMethod->addItem(tr("Pixel buffer"), QByteArray("PixelBuffer")); -#endif } /** @@ -240,12 +237,7 @@ void DlgSettingsImageImp::setMethod(const QByteArray& m) QByteArray DlgSettingsImageImp::method() const { -#if QT_VERSION < 0x050000 - int index = ui->comboMethod->currentIndex(); - return ui->comboMethod->itemData(index).toByteArray(); -#else return ui->comboMethod->currentData().toByteArray(); -#endif } void DlgSettingsImageImp::on_comboMethod_activated(int index) diff --git a/src/Gui/DlgToolbarsImp.cpp b/src/Gui/DlgToolbarsImp.cpp index 32242b6c53..85df18d71b 100644 --- a/src/Gui/DlgToolbarsImp.cpp +++ b/src/Gui/DlgToolbarsImp.cpp @@ -135,11 +135,7 @@ DlgCustomToolbars::DlgCustomToolbars(DlgCustomToolbars::Type t, QWidget* parent) ui->commandTreeWidget->setHeaderLabels(labels); ui->commandTreeWidget->header()->hide(); ui->commandTreeWidget->setIconSize(QSize(32, 32)); -#if QT_VERSION >= 0x050000 ui->commandTreeWidget->header()->setSectionResizeMode(0, QHeaderView::ResizeToContents); -#else - ui->commandTreeWidget->header()->setResizeMode(0, QHeaderView::ResizeToContents); -#endif labels.clear(); labels << tr("Command"); ui->toolbarTreeWidget->setHeaderLabels(labels); diff --git a/src/Gui/DocumentRecovery.cpp b/src/Gui/DocumentRecovery.cpp index 446cef1070..44e7f74116 100644 --- a/src/Gui/DocumentRecovery.cpp +++ b/src/Gui/DocumentRecovery.cpp @@ -178,11 +178,7 @@ DocumentRecovery::DocumentRecovery(const QList& dirs, QWidget* parent { d_ptr->ui.setupUi(this); d_ptr->ui.buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Start Recovery")); -#if QT_VERSION >= 0x050000 d_ptr->ui.treeWidget->header()->setSectionResizeMode(QHeaderView::Stretch); -#else - d_ptr->ui.treeWidget->header()->setResizeMode(QHeaderView::Stretch); -#endif d_ptr->recovered = false; diff --git a/src/Gui/DownloadItem.cpp b/src/Gui/DownloadItem.cpp index 62760b1d86..43e59a26ba 100644 --- a/src/Gui/DownloadItem.cpp +++ b/src/Gui/DownloadItem.cpp @@ -39,9 +39,7 @@ #include #include #include -#if QT_VERSION >= 0x050000 #include -#endif #include #include @@ -171,11 +169,7 @@ NetworkAccessManager::NetworkAccessManager(QObject *parent) SLOT(proxyAuthenticationRequired(const QNetworkProxy&, QAuthenticator*))); QNetworkDiskCache *diskCache = new QNetworkDiskCache(this); -#if QT_VERSION >= 0x050000 QString location = QStandardPaths::writableLocation(QStandardPaths::CacheLocation); -#else - QString location = QDesktopServices::storageLocation(QDesktopServices::CacheLocation); -#endif diskCache->setCacheDirectory(location); setCache(diskCache); } @@ -192,11 +186,7 @@ void NetworkAccessManager::authenticationRequired(QNetworkReply *reply, QAuthent dialog.adjustSize(); QString introMessage = tr("Enter username and password for \"%1\" at %2"); -#if QT_VERSION >= 0x050000 introMessage = introMessage.arg(QString(reply->url().toString()).toHtmlEscaped(), QString(reply->url().toString()).toHtmlEscaped()); -#else - introMessage = introMessage.arg(Qt::escape(reply->url().toString()), Qt::escape(reply->url().toString())); -#endif passwordDialog.siteDescription->setText(introMessage); passwordDialog.siteDescription->setWordWrap(true); @@ -218,11 +208,7 @@ void NetworkAccessManager::proxyAuthenticationRequired(const QNetworkProxy &prox dialog.adjustSize(); QString introMessage = tr("Connect to proxy \"%1\" using:"); -#if QT_VERSION >= 0x050000 introMessage = introMessage.arg(QString(proxy.hostName()).toHtmlEscaped()); -#else - introMessage = introMessage.arg(Qt::escape(proxy.hostName())); -#endif proxyDialog.siteDescription->setText(introMessage); proxyDialog.siteDescription->setWordWrap(true); @@ -288,11 +274,7 @@ void DownloadItem::init() QString DownloadItem::getDownloadDirectory() const { QString exe = QString::fromLatin1(App::GetApplication().getExecutableName()); -#if QT_VERSION >= 0x050000 QString path = QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation); -#else - QString path = QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation); -#endif QString dirPath = QDir(path).filePath(exe); Base::Reference hPath = App::GetApplication().GetUserParameter().GetGroup("BaseApp") ->GetGroup("Preferences")->GetGroup("General"); @@ -301,11 +283,7 @@ QString DownloadItem::getDownloadDirectory() const dirPath = QString::fromUtf8(dir.c_str()); } -#if QT_VERSION >= 0x050000 if (QFileInfo::exists(dirPath) || QDir().mkpath(dirPath)) { -#else - if (QFileInfo(dirPath).exists() || QDir().mkpath(dirPath)) { -#endif return dirPath; } else { diff --git a/src/Gui/DownloadManager.cpp b/src/Gui/DownloadManager.cpp index 0cc77d3e1a..4e61eded72 100644 --- a/src/Gui/DownloadManager.cpp +++ b/src/Gui/DownloadManager.cpp @@ -33,12 +33,7 @@ #include #include #include -#if QT_VERSION < 0x050000 -#include -#endif -#if QT_VERSION >= 0x050000 #include -#endif #include "DownloadItem.h" #include "DownloadManager.h" @@ -117,7 +112,6 @@ QUrl DownloadManager::redirectUrl(const QUrl& url) const { QUrl redirectUrl = url; if (url.host() == QLatin1String("www.dropbox.com")) { -#if QT_VERSION >= 0x050000 QUrlQuery urlQuery(url); QList< QPair > query = urlQuery.queryItems(); for (QList< QPair >::iterator it = query.begin(); it != query.end(); ++it) { @@ -134,22 +128,6 @@ QUrl DownloadManager::redirectUrl(const QUrl& url) const } } redirectUrl.setQuery(urlQuery); -#else - QList< QPair > query = url.queryItems(); - for (QList< QPair >::iterator it = query.begin(); it != query.end(); ++it) { - if (it->first == QLatin1String("dl")) { - if (it->second == QLatin1String("0\r\n")) { - redirectUrl.removeQueryItem(QLatin1String("dl")); - redirectUrl.addQueryItem(QLatin1String("dl"), QLatin1String("1\r\n")); - } - else if (it->second == QLatin1String("0")) { - redirectUrl.removeQueryItem(QLatin1String("dl")); - redirectUrl.addQueryItem(QLatin1String("dl"), QLatin1String("1")); - } - break; - } - } -#endif } else { // When the url comes from drag and drop it may end with CR+LF. This may cause problems @@ -217,13 +195,6 @@ void DownloadManager::updateRow() ui->downloadsView->setRowHeight(row, item->minimumSizeHint().height()); bool remove = false; -#if QT_VERSION < 0x050000 - QWebSettings *globalSettings = QWebSettings::globalSettings(); - if (!item->downloading() - && globalSettings->testAttribute(QWebSettings::PrivateBrowsingEnabled)) - remove = true; -#endif - if (item->downloadedSuccessfully() && removePolicy() == DownloadManager::SuccessFullDownload) { remove = true; diff --git a/src/Gui/ExpressionCompleter.cpp b/src/Gui/ExpressionCompleter.cpp index 4e11528b5e..6fbe8e5be1 100644 --- a/src/Gui/ExpressionCompleter.cpp +++ b/src/Gui/ExpressionCompleter.cpp @@ -586,10 +586,8 @@ void ExpressionLineEdit::setDocumentObject(const App::DocumentObject * currentDo completer->setWidget(this); completer->setCaseSensitivity(Qt::CaseInsensitive); completer->setRequireLeadingEqualSign(requireLeadingEqualSign); -#if QT_VERSION>=QT_VERSION_CHECK(5,2,0) if (!exactMatch) completer->setFilterMode(Qt::MatchContains); -#endif connect(completer, SIGNAL(activated(QString)), this, SLOT(slotCompleteText(QString))); connect(completer, SIGNAL(highlighted(QString)), this, SLOT(slotCompleteText(QString))); connect(this, SIGNAL(textChanged2(QString,int)), completer, SLOT(slotUpdate(QString,int))); @@ -604,10 +602,9 @@ void ExpressionLineEdit::setNoProperty(bool enabled) { void ExpressionLineEdit::setExactMatch(bool enabled) { exactMatch = enabled; -#if QT_VERSION>=QT_VERSION_CHECK(5,2,0) if (completer) completer->setFilterMode(exactMatch ? Qt::MatchStartsWith : Qt::MatchContains); -#endif + } bool ExpressionLineEdit::completerActive() const @@ -649,7 +646,6 @@ void ExpressionLineEdit::keyPressEvent(QKeyEvent *e) { void ExpressionLineEdit::contextMenuEvent(QContextMenuEvent *event) { -#if QT_VERSION >= QT_VERSION_CHECK(5,2,0) QMenu *menu = createStandardContextMenu(); menu->addSeparator(); QAction* match = menu->addAction(tr("Exact match")); @@ -670,9 +666,6 @@ void ExpressionLineEdit::contextMenuEvent(QContextMenuEvent *event) } delete menu; -#else - QLineEdit::contextMenuEvent(event); -#endif } @@ -689,10 +682,8 @@ ExpressionTextEdit::ExpressionTextEdit(QWidget *parent) void ExpressionTextEdit::setExactMatch(bool enabled) { exactMatch = enabled; -#if QT_VERSION>=QT_VERSION_CHECK(5,2,0) if (completer) completer->setFilterMode(exactMatch ? Qt::MatchStartsWith : Qt::MatchContains); -#endif } void ExpressionTextEdit::setDocumentObject(const App::DocumentObject * currentDocObj) @@ -704,10 +695,8 @@ void ExpressionTextEdit::setDocumentObject(const App::DocumentObject * currentDo if (currentDocObj != nullptr) { completer = new ExpressionCompleter(currentDocObj, this); -#if QT_VERSION>=QT_VERSION_CHECK(5,2,0) if (!exactMatch) completer->setFilterMode(Qt::MatchContains); -#endif completer->setWidget(this); completer->setCaseSensitivity(Qt::CaseInsensitive); connect(completer, SIGNAL(activated(QString)), this, SLOT(slotCompleteText(QString))); @@ -756,7 +745,6 @@ void ExpressionTextEdit::keyPressEvent(QKeyEvent *e) { void ExpressionTextEdit::contextMenuEvent(QContextMenuEvent *event) { -#if QT_VERSION >= QT_VERSION_CHECK(5,2,0) QMenu *menu = createStandardContextMenu(); menu->addSeparator(); QAction* match = menu->addAction(tr("Exact match")); @@ -777,9 +765,6 @@ void ExpressionTextEdit::contextMenuEvent(QContextMenuEvent *event) } delete menu; -#else - QPlainTextEdit::contextMenuEvent(event); -#endif } /////////////////////////////////////////////////////////////////////// diff --git a/src/Gui/FileDialog.cpp b/src/Gui/FileDialog.cpp index f2ddf091e3..f4312f55fd 100644 --- a/src/Gui/FileDialog.cpp +++ b/src/Gui/FileDialog.cpp @@ -173,10 +173,6 @@ QString FileDialog::getSaveFileName (QWidget * parent, const QString & caption, if (windowTitle.isEmpty()) windowTitle = FileDialog::tr("Save as"); -#if QT_VERSION < 0x040800 && defined(FC_OS_MACOSX) - options |= QFileDialog::DontUseNativeDialog; -#endif - // NOTE: We must not change the specified file name afterwards as we may return the name of an already // existing file. Hence we must extract the first matching suffix from the filter list and append it // before showing the file dialog. @@ -184,7 +180,6 @@ QString FileDialog::getSaveFileName (QWidget * parent, const QString & caption, if (dontUseNativeDialog()) { QList urls; -#if QT_VERSION >= 0x050000 options |= QFileDialog::DontUseNativeDialog; urls << QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)); urls << QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)); @@ -192,14 +187,6 @@ QString FileDialog::getSaveFileName (QWidget * parent, const QString & caption, urls << QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::MusicLocation)); urls << QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation)); urls << QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::MoviesLocation)); -#else - urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::DesktopLocation)); - urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)); - urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); - urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::MusicLocation)); - urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::PicturesLocation)); - urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::MoviesLocation)); -#endif urls << QUrl::fromLocalFile(getWorkingDirectory()); urls << QUrl::fromLocalFile(restoreLocation()); urls << QUrl::fromLocalFile(QDir::currentPath()); @@ -228,9 +215,7 @@ QString FileDialog::getSaveFileName (QWidget * parent, const QString & caption, } else { file = QFileDialog::getSaveFileName(parent, windowTitle, dirName, filter, selectedFilter, options); -#if QT_VERSION >= 0x040600 file = QDir::fromNativeSeparators(file); -#endif } if (!file.isEmpty()) { @@ -246,9 +231,6 @@ QString FileDialog::getSaveFileName (QWidget * parent, const QString & caption, */ QString FileDialog::getExistingDirectory( QWidget * parent, const QString & caption, const QString & dir, Options options ) { -#if QT_VERSION < 0x040800 && defined(FC_OS_MACOSX) - options |= QFileDialog::DontUseNativeDialog; -#endif QString path = QFileDialog::getExistingDirectory(parent, caption, dir, options); // valid path was selected if ( !path.isEmpty() ) { @@ -275,15 +257,10 @@ QString FileDialog::getOpenFileName(QWidget * parent, const QString & caption, c if (windowTitle.isEmpty()) windowTitle = FileDialog::tr("Open"); -#if QT_VERSION < 0x040800 && defined(FC_OS_MACOSX) - options |= QFileDialog::DontUseNativeDialog; -#endif - QString file; if (dontUseNativeDialog()) { QList urls; -#if QT_VERSION >= 0x050000 options |= QFileDialog::DontUseNativeDialog; urls << QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)); urls << QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)); @@ -291,14 +268,6 @@ QString FileDialog::getOpenFileName(QWidget * parent, const QString & caption, c urls << QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::MusicLocation)); urls << QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation)); urls << QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::MoviesLocation)); -#else - urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::DesktopLocation)); - urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)); - urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); - urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::MusicLocation)); - urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::PicturesLocation)); - urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::MoviesLocation)); -#endif urls << QUrl::fromLocalFile(getWorkingDirectory()); urls << QUrl::fromLocalFile(restoreLocation()); urls << QUrl::fromLocalFile(QDir::currentPath()); @@ -323,9 +292,7 @@ QString FileDialog::getOpenFileName(QWidget * parent, const QString & caption, c } else { file = QFileDialog::getOpenFileName(parent, windowTitle, dirName, filter, selectedFilter, options); -#if QT_VERSION >= 0x040600 file = QDir::fromNativeSeparators(file); -#endif } if (!file.isEmpty()) { @@ -351,15 +318,10 @@ QStringList FileDialog::getOpenFileNames (QWidget * parent, const QString & capt if (windowTitle.isEmpty()) windowTitle = FileDialog::tr("Open"); -#if QT_VERSION < 0x040800 && defined(FC_OS_MACOSX) - options |= QFileDialog::DontUseNativeDialog; -#endif - QStringList files; if (dontUseNativeDialog()) { QList urls; -#if QT_VERSION >= 0x050000 options |= QFileDialog::DontUseNativeDialog; urls << QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::DesktopLocation)); urls << QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::DocumentsLocation)); @@ -367,14 +329,6 @@ QStringList FileDialog::getOpenFileNames (QWidget * parent, const QString & capt urls << QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::MusicLocation)); urls << QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::PicturesLocation)); urls << QUrl::fromLocalFile(QStandardPaths::writableLocation(QStandardPaths::MoviesLocation)); -#else - urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::DesktopLocation)); - urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::DocumentsLocation)); - urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::HomeLocation)); - urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::MusicLocation)); - urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::PicturesLocation)); - urls << QUrl::fromLocalFile(QDesktopServices::storageLocation(QDesktopServices::MoviesLocation)); -#endif urls << QUrl::fromLocalFile(getWorkingDirectory()); urls << QUrl::fromLocalFile(restoreLocation()); urls << QUrl::fromLocalFile(QDir::currentPath()); @@ -399,11 +353,9 @@ QStringList FileDialog::getOpenFileNames (QWidget * parent, const QString & capt } else { files = QFileDialog::getOpenFileNames(parent, windowTitle, dirName, filter, selectedFilter, options); -#if QT_VERSION >= 0x040600 for (QStringList::iterator it = files.begin(); it != files.end(); ++it) { *it = QDir::fromNativeSeparators(*it); } -#endif } if (!files.isEmpty()) { @@ -483,9 +435,7 @@ FileOptionsDialog::FileOptionsDialog( QWidget* parent, Qt::WindowFlags fl ) extensionButton = new QPushButton( this ); extensionButton->setText( tr( "Extended" ) ); -#if QT_VERSION >= 0x050000 setOption(QFileDialog::DontUseNativeDialog); -#endif // This is an alternative to add the button to the grid layout //QDialogButtonBox* box = this->findChild(); @@ -493,11 +443,7 @@ FileOptionsDialog::FileOptionsDialog( QWidget* parent, Qt::WindowFlags fl ) //search for the grid layout and add the new button QGridLayout* grid = this->findChild(); -#if QT_VERSION >= 0x040500 grid->addWidget(extensionButton, 4, 2, Qt::AlignLeft); -#else - grid->addWidget(extensionButton, 4, 5, Qt::AlignLeft); -#endif connect(extensionButton, SIGNAL(clicked()), this, SLOT(toggleExtension())); } diff --git a/src/Gui/GraphicsViewZoom.cpp b/src/Gui/GraphicsViewZoom.cpp index f41638a75e..86e112fcf1 100644 --- a/src/Gui/GraphicsViewZoom.cpp +++ b/src/Gui/GraphicsViewZoom.cpp @@ -79,7 +79,6 @@ bool GraphicsViewZoom::eventFilter(QObject *object, QEvent *event) { } else if (event->type() == QEvent::Wheel) { QWheelEvent* wheel_event = static_cast(event); if (QApplication::keyboardModifiers() == _modifiers) { -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) QPoint delta = wheel_event->angleDelta(); if (qAbs(delta.y()) > qAbs(delta.x())) { // vertical double angle = -delta.y(); @@ -89,16 +88,6 @@ bool GraphicsViewZoom::eventFilter(QObject *object, QEvent *event) { gentle_zoom(factor); return true; } -#else - if (wheel_event->orientation() == Qt::Vertical) { - double angle = -wheel_event->delta(); - if (m_invert_zoom) - angle = -angle; - double factor = qPow(_zoom_factor_base, angle); - gentle_zoom(factor); - return true; - } -#endif } } Q_UNUSED(object); diff --git a/src/Gui/GraphvizView.cpp b/src/Gui/GraphvizView.cpp index e529f06bc5..bb27280eb9 100644 --- a/src/Gui/GraphvizView.cpp +++ b/src/Gui/GraphvizView.cpp @@ -70,18 +70,12 @@ public: GraphvizWorker(QObject * parent = 0) : QThread(parent) { -#if QT_VERSION < 0x050000 - dotProc.moveToThread(this); - unflattenProc.moveToThread(this); -#endif } virtual ~GraphvizWorker() { -#if QT_VERSION >= 0x050000 dotProc.moveToThread(this); unflattenProc.moveToThread(this); -#endif } void setData(const QByteArray & data) @@ -90,7 +84,6 @@ public: } void startThread() { -#if QT_VERSION >= 0x050000 // This doesn't actually run a thread but calls the function // directly in the main thread. // This is needed because embedding a QProcess into a QThread @@ -98,9 +91,6 @@ public: run(); // Can't use the finished() signal of QThread emitFinished(); -#else - start(); -#endif } void run() { @@ -268,9 +258,7 @@ GraphvizView::GraphvizView(App::Document & _doc, QWidget* parent) // Create worker thread thread = new GraphvizWorker(this); -#if QT_VERSION >= 0x050000 connect(thread, SIGNAL(emitFinished()), this, SLOT(done())); -#endif connect(thread, SIGNAL(finished()), this, SLOT(done())); connect(thread, SIGNAL(error()), this, SLOT(error())); connect(thread, SIGNAL(svgFileRead(const QByteArray &)), this, SLOT(svgFileRead(const QByteArray &))); @@ -533,11 +521,7 @@ bool GraphvizView::onHasMsg(const char* pMsg) const void GraphvizView::print(QPrinter* printer) { QPainter p(printer); -#if QT_VERSION >= 0x050300 QRect rect = printer->pageLayout().paintRectPixels(printer->resolution()); -#else - QRect rect = printer->pageRect(); -#endif view->scene()->render(&p, rect); //QByteArray buffer = exportGraph(QString::fromLatin1("svg")); //QSvgRenderer svg(buffer); @@ -549,11 +533,7 @@ void GraphvizView::print() { QPrinter printer(QPrinter::HighResolution); printer.setFullPage(true); -#if QT_VERSION >= 0x050300 printer.setPageOrientation(QPageLayout::Landscape); -#else - printer.setOrientation(QPrinter::Landscape); -#endif QPrintDialog dlg(&printer, this); if (dlg.exec() == QDialog::Accepted) { print(&printer); @@ -583,11 +563,7 @@ void GraphvizView::printPreview() { QPrinter printer(QPrinter::HighResolution); printer.setFullPage(true); -#if QT_VERSION >= 0x050300 printer.setPageOrientation(QPageLayout::Landscape); -#else - printer.setOrientation(QPrinter::Landscape); -#endif QPrintPreviewDialog dlg(&printer, this); connect(&dlg, SIGNAL(paintRequested (QPrinter *)), diff --git a/src/Gui/GuiApplication.cpp b/src/Gui/GuiApplication.cpp index abdbf870c9..2431a5f76d 100644 --- a/src/Gui/GuiApplication.cpp +++ b/src/Gui/GuiApplication.cpp @@ -63,14 +63,9 @@ using namespace Gui; GUIApplication::GUIApplication(int & argc, char ** argv) : GUIApplicationNativeEventAware(argc, argv) { -#if QT_VERSION > 0x050000 - // In Qt 4.x 'commitData' is a virtual method connect(this, SIGNAL(commitDataRequest(QSessionManager &)), SLOT(commitData(QSessionManager &)), Qt::DirectConnection); -#endif -#if QT_VERSION >= 0x050600 setFallbackSessionManagementEnabled(false); -#endif } GUIApplication::~GUIApplication() diff --git a/src/Gui/GuiApplicationNativeEventAware.cpp b/src/Gui/GuiApplicationNativeEventAware.cpp index e3f77bde13..037ba0b3a5 100644 --- a/src/Gui/GuiApplicationNativeEventAware.cpp +++ b/src/Gui/GuiApplicationNativeEventAware.cpp @@ -306,11 +306,4 @@ void Gui::GUIApplicationNativeEventAware::importSettings(std::vector& motio } } -#if defined(SPNAV_FOUND) && defined(SPNAV_USE_X11) && QT_VERSION < 0x050000 -bool Gui::GUIApplicationNativeEventAware::x11EventFilter(XEvent *event) -{ - return nativeEvent->x11EventFilter(event); -} -#endif - #include "moc_GuiApplicationNativeEventAware.cpp" diff --git a/src/Gui/GuiApplicationNativeEventAware.h b/src/Gui/GuiApplicationNativeEventAware.h index 2265d03217..499aab5112 100644 --- a/src/Gui/GuiApplicationNativeEventAware.h +++ b/src/Gui/GuiApplicationNativeEventAware.h @@ -54,9 +54,6 @@ namespace Gui #if defined(_USE_3DCONNEXION_SDK) || defined(SPNAV_FOUND) GuiNativeEvent *nativeEvent; #endif - #if defined(SPNAV_FOUND) && defined(SPNAV_USE_X11) && QT_VERSION < 0x050000 - bool x11EventFilter(XEvent *event) override final; - #endif }; // end class GUIApplicationNativeEventAware } // end namespace Gui diff --git a/src/Gui/InputField.cpp b/src/Gui/InputField.cpp index 13de51f382..a871682183 100644 --- a/src/Gui/InputField.cpp +++ b/src/Gui/InputField.cpp @@ -692,11 +692,7 @@ void InputField::wheelEvent (QWheelEvent * event) } double factor = event->modifiers() & Qt::ControlModifier ? 10 : 1; -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) double step = event->angleDelta().y() > 0 ? StepSize : -StepSize; -#else - double step = event->delta() > 0 ? StepSize : -StepSize; -#endif double val = actUnitValue + factor * step; if (val > Maximum) val = Maximum; diff --git a/src/Gui/MDIView.cpp b/src/Gui/MDIView.cpp index a571aaccf4..c95b2dbe8f 100644 --- a/src/Gui/MDIView.cpp +++ b/src/Gui/MDIView.cpp @@ -107,10 +107,6 @@ void MDIView::deleteSelf() QWidget* parent = this->parentWidget(); if (qobject_cast(parent)) { // https://forum.freecadweb.org/viewtopic.php?f=22&t=23070 -#if QT_VERSION < 0x050000 - // With Qt5 this would lead to some annoying flickering - getMainWindow()->removeWindow(this); -#endif parent->close(); } else { diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp index c819c57797..603cbc8f83 100644 --- a/src/Gui/MainWindow.cpp +++ b/src/Gui/MainWindow.cpp @@ -47,15 +47,11 @@ # include # include # include -#if QT_VERSION >= 0x050000 # include -#endif # include #endif -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) -# include -#endif +#include // FreeCAD Base header #include @@ -196,11 +192,8 @@ public: MDITabbar( QWidget * parent = 0 ) : QTabBar(parent) { menu = new QMenu(this); - // For Qt 4.2.x the tabs might be very wide -#if QT_VERSION >= 0x040200 setDrawBase(false); setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Fixed); -#endif } ~MDITabbar() @@ -293,31 +286,20 @@ MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags f) // support for grouped dragging of dockwidgets // https://woboq.com/blog/qdockwidget-changes-in-56.html -#if QT_VERSION >= 0x050600 setDockOptions(dockOptions() | QMainWindow::GroupedDragging); -#endif // Create the layout containing the workspace and a tab bar d->mdiArea = new QMdiArea(); // Movable tabs -#if QT_VERSION >= 0x040800 d->mdiArea->setTabsMovable(true); -#endif -#if QT_VERSION >= 0x040500 d->mdiArea->setTabPosition(QTabWidget::South); d->mdiArea->setViewMode(QMdiArea::TabbedView); QTabBar* tab = d->mdiArea->findChild(); if (tab) { - // 0000636: Two documents close -#if QT_VERSION < 0x040800 - connect(tab, SIGNAL(tabCloseRequested(int)), - this, SLOT(tabCloseRequested(int))); -#endif tab->setTabsClosable(true); // The tabs might be very wide tab->setExpanding(false); } -#endif d->mdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded); d->mdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded); d->mdiArea->setOption(QMdiArea::DontMaximizeSubWindowOnActivation, false); @@ -460,15 +442,6 @@ MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags f) pDockMgr->registerDockWindow("Std_ComboView", pcComboView); } -#if QT_VERSION < 0x040500 - // Report view - if (hiddenDockWindows.find("Std_ReportView") == std::string::npos) { - Gui::DockWnd::ReportView* pcReport = new Gui::DockWnd::ReportView(this); - pcReport->setObjectName - (QString::fromLatin1(QT_TRANSLATE_NOOP("QDockWidget","Report view"))); - pDockMgr->registerDockWindow("Std_ReportView", pcReport); - } -#else // Report view (must be created before PythonConsole!) if (hiddenDockWindows.find("Std_ReportView") == std::string::npos) { ReportOutput* pcReport = new ReportOutput(this); @@ -541,7 +514,6 @@ MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags f) connect(result, SIGNAL(currentChanged(int)), l, SLOT(tabChanged())); l->unusedTabBars << result; } -#endif #endif // accept drops on the window, get handled in dropEvent, dragEnterEvent @@ -1234,16 +1206,6 @@ void MainWindow::hideEvent(QHideEvent * /*e*/) void MainWindow::showMainWindow() { - // Under certain circumstances it can happen that at startup the main window - // appears for a short moment and disappears immediately. The workaround - // starts a timer to check for the visibility of the main window and call - // ShowWindow() if needed. - // So far, this phenomena only appeared with Qt4.1.4 -#if defined(Q_OS_WIN) && (QT_VERSION == 0x040104) - WId id = this->winId(); - ShowWindow(id, SW_SHOW); - std::cout << "Force to show main window" << std::endl; -#endif } void MainWindow::processMessages(const QList & msg) @@ -1426,11 +1388,7 @@ void MainWindow::loadWindowSettings() QString qtver = QString::fromLatin1("Qt%1.%2").arg(major).arg(minor); QSettings config(vendor, application); -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) QRect rect = QApplication::primaryScreen()->availableGeometry(); -#else - QRect rect = QApplication::desktop()->availableGeometry(); -#endif int maxHeight = rect.height(); int maxWidth = rect.width(); @@ -1853,15 +1811,10 @@ void MainWindow::loadUrls(App::Document* doc, const QList& urls) //#ifndef QT_NO_OPENSSL else if (it->scheme().toLower() == QLatin1String("https")) { QUrl url = *it; -#if QT_VERSION >= 0x050000 QUrlQuery urlq(url); if (urlq.hasQueryItem(QLatin1String("sid"))) { urlq.removeAllQueryItems(QLatin1String("sid")); url.setQuery(urlq); -#else - if (it->hasEncodedQueryItem(QByteArray("sid"))) { - url.removeEncodedQueryItem(QByteArray("sid")); -#endif url.setScheme(QLatin1String("http")); } Gui::Dialog::DownloadManager* dm = Gui::Dialog::DownloadManager::getInstance(); diff --git a/src/Gui/MouseSelection.cpp b/src/Gui/MouseSelection.cpp index 5929b5e5fd..4ce967eada 100644 --- a/src/Gui/MouseSelection.cpp +++ b/src/Gui/MouseSelection.cpp @@ -390,11 +390,7 @@ int PolyPickerSelection::locationEvent(const SoLocation2Event* const, const QPoi if (polyline.isWorking()) { // check the position -#if QT_VERSION >= 0x050600 qreal dpr = _pcView3D->getGLWidget()->devicePixelRatioF(); -#else - qreal dpr = 1.0; -#endif QRect r = _pcView3D->getGLWidget()->rect(); if (dpr != 1.0) { r.setHeight(r.height()*dpr); @@ -608,11 +604,7 @@ int FreehandSelection::locationEvent(const SoLocation2Event* const e, const QPoi if (polyline.isWorking()) { // check the position -#if QT_VERSION >= 0x050600 qreal dpr = _pcView3D->getGLWidget()->devicePixelRatioF(); -#else - qreal dpr = 1.0; -#endif QRect r = _pcView3D->getGLWidget()->rect(); if (dpr != 1.0) { r.setHeight(r.height()*dpr); diff --git a/src/Gui/NavigationStyle.h b/src/Gui/NavigationStyle.h index 34c1bf52c3..2c163c708d 100644 --- a/src/Gui/NavigationStyle.h +++ b/src/Gui/NavigationStyle.h @@ -99,11 +99,7 @@ public: Trackball }; -#if QT_VERSION < 0x050000 - enum RotationCenterMode { -#else enum class RotationCenterMode { -#endif WindowCenter = 0, /**< The center of the window */ ScenePointAtCursor = 1, /**< Find the point in the scene at the cursor position. If there is no point then the focal plane is used */ FocalPointAtCursor = 2, /**< Find the point on the focal plane at the cursor position. */ diff --git a/src/Gui/NetworkRetriever.cpp b/src/Gui/NetworkRetriever.cpp index b4b4606aee..b64327bd2f 100644 --- a/src/Gui/NetworkRetriever.cpp +++ b/src/Gui/NetworkRetriever.cpp @@ -374,12 +374,8 @@ void NetworkRetriever::wgetFinished(int exitCode, QProcess::ExitStatus status) bool NetworkRetriever::testWget() { QProcess proc; -#if QT_VERSION > 0x050000 proc.setProgram(QString::fromLatin1("wget")); proc.start(); -#else - proc.start(QString::fromLatin1("wget")); -#endif bool ok = proc.state() == QProcess::Running; proc.kill(); proc.waitForFinished(); diff --git a/src/Gui/OnlineDocumentation.cpp b/src/Gui/OnlineDocumentation.cpp index 119fc6f77b..90b75c4683 100644 --- a/src/Gui/OnlineDocumentation.cpp +++ b/src/Gui/OnlineDocumentation.cpp @@ -293,11 +293,7 @@ HttpServer::HttpServer(QObject* parent) { } -#if QT_VERSION >=0x050000 void HttpServer::incomingConnection(qintptr socket) -#else -void HttpServer::incomingConnection(int socket) -#endif { if (disabled) return; diff --git a/src/Gui/OnlineDocumentation.h b/src/Gui/OnlineDocumentation.h index 8e54c9d07a..cf03358c78 100644 --- a/src/Gui/OnlineDocumentation.h +++ b/src/Gui/OnlineDocumentation.h @@ -62,11 +62,7 @@ class HttpServer : public QTcpServer public: HttpServer(QObject* parent = 0); -#if QT_VERSION >=0x050000 void incomingConnection(qintptr socket); -#else - void incomingConnection(int socket); -#endif void pause(); void resume(); diff --git a/src/Gui/ProgressBar.cpp b/src/Gui/ProgressBar.cpp index 47f22faf32..fcaff6adb5 100644 --- a/src/Gui/ProgressBar.cpp +++ b/src/Gui/ProgressBar.cpp @@ -35,9 +35,8 @@ # include #endif -#if QT_VERSION >= 0x050000 -# include -#endif +#include + #include "ProgressBar.h" #include "ProgressDialog.h" @@ -68,13 +67,11 @@ struct ProgressBarPrivate bool isModalDialog(QObject* o) const { QWidget* parent = qobject_cast(o); -#if QT_VERSION >= 0x050000 if (!parent) { QWindow* window = qobject_cast(o); if (window) parent = QWidget::find(window->winId()); } -#endif while (parent) { QMessageBox* dlg = qobject_cast(parent); if (dlg && dlg->isModal()) diff --git a/src/Gui/PropertyPage.cpp b/src/Gui/PropertyPage.cpp index 806d3aee6d..f95379dc55 100644 --- a/src/Gui/PropertyPage.cpp +++ b/src/Gui/PropertyPage.cpp @@ -116,9 +116,7 @@ PreferenceUiForm::PreferenceUiForm(const QString& fn, QWidget* parent) : PreferencePage(parent), form(0) { UiLoader loader; -#if QT_VERSION >= 0x040500 loader.setLanguageChangeEnabled(true); -#endif loader.setWorkingDirectory(QFileInfo(fn).absolutePath()); QFile file(fn); if (file.open(QFile::ReadOnly)) diff --git a/src/Gui/Qt4All.h b/src/Gui/Qt4All.h index f8cd9c8684..3dca95bd68 100644 --- a/src/Gui/Qt4All.h +++ b/src/Gui/Qt4All.h @@ -49,9 +49,7 @@ #include #include #include -#if QT_VERSION >= 0x050000 #include -#endif #include #include // QtGui @@ -69,9 +67,7 @@ #include #include #include -#if QT_VERSION >= 0x040200 #include -#endif #include #include #include @@ -103,9 +99,7 @@ #include #include #include -#if QT_VERSION >= 0x050000 #include -#endif #include #include #include @@ -167,14 +161,6 @@ #include #include -// QtWebKit -#if QT_VERSION >= 0x040400 -// Only needed in Web module -//#include -//#include -//#include -#endif - #include "qmath.h" #include #include diff --git a/src/Gui/Quarter/EventFilter.cpp b/src/Gui/Quarter/EventFilter.cpp index 557ee49358..695159ceea 100644 --- a/src/Gui/Quarter/EventFilter.cpp +++ b/src/Gui/Quarter/EventFilter.cpp @@ -48,9 +48,7 @@ #include #include -#if QT_VERSION >= 0x050000 #include -#endif namespace SIM { namespace Coin3D { namespace Quarter { @@ -78,9 +76,7 @@ public: SbVec2s mousepos(event->pos().x(), this->windowsize[1] - event->pos().y() - 1); // the following corrects for high-dpi displays (e.g. mac retina) -#if QT_VERSION >= 0x050000 mousepos *= quarterwidget->devicePixelRatio(); -#endif foreach(InputDevice * device, this->devices) { device->setMousePosition(mousepos); } diff --git a/src/Gui/Quarter/Mouse.cpp b/src/Gui/Quarter/Mouse.cpp index 9aaa8d1c95..ee832510e2 100644 --- a/src/Gui/Quarter/Mouse.cpp +++ b/src/Gui/Quarter/Mouse.cpp @@ -51,16 +51,12 @@ #include #include -#if QT_VERSION >= 0x050000 #include -#endif #include #include #include -#if QT_VERSION >= 0x050000 #include -#endif namespace SIM { namespace Coin3D { namespace Quarter { @@ -156,9 +152,7 @@ MouseP::mouseMoveEvent(QMouseEvent * event) assert(this->windowsize[1] != -1); SbVec2s pos(event->pos().x(), this->windowsize[1] - event->pos().y() - 1); // the following corrects for high-dpi displays (e.g. mac retina) -#if QT_VERSION >= 0x050000 pos *= publ->quarter->devicePixelRatio(); -#endif this->location2->setPosition(pos); this->mousebutton->setPosition(pos); return this->location2; @@ -175,9 +169,7 @@ MouseP::mouseWheelEvent(QWheelEvent * event) SbVec2s pos(event->pos().x(), PUBLIC(this)->windowsize[1] - event->pos().y() - 1); #endif // the following corrects for high-dpi displays (e.g. mac retina) -#if QT_VERSION >= 0x050000 pos *= publ->quarter->devicePixelRatio(); -#endif this->location2->setPosition(pos); //I don't know why location2 is assigned here, I assumed it important --DeepSOIC this->wheel->setPosition(pos); @@ -187,11 +179,7 @@ MouseP::mouseWheelEvent(QWheelEvent * event) // value indicates that the wheel was rotated backwards toward the // user. A typical wheel click is 120, but values coming from touchpad // can be a lot lower -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) this->wheel->setDelta(event->angleDelta().y()); -#else - this->wheel->setDelta(event->delta()); -#endif return this->wheel; } @@ -202,9 +190,7 @@ MouseP::mouseButtonEvent(QMouseEvent * event) PUBLIC(this)->setModifiers(this->mousebutton, event); SbVec2s pos(event->pos().x(), PUBLIC(this)->windowsize[1] - event->pos().y() - 1); // the following corrects for high-dpi displays (e.g. mac retina) -#if QT_VERSION >= 0x050000 pos *= publ->quarter->devicePixelRatio(); -#endif this->location2->setPosition(pos); this->mousebutton->setPosition(pos); diff --git a/src/Gui/Quarter/QuarterWidget.cpp b/src/Gui/Quarter/QuarterWidget.cpp index bb5b0ebf80..e7034760b9 100644 --- a/src/Gui/Quarter/QuarterWidget.cpp +++ b/src/Gui/Quarter/QuarterWidget.cpp @@ -99,11 +99,9 @@ #include "QuarterWidgetP.h" #include "QuarterP.h" -#if QT_VERSION >= 0x050000 #include #include #include -#endif using namespace SIM::Coin3D::Quarter; @@ -209,13 +207,11 @@ public: } void aboutToDestroyGLContext() { -#if QT_VERSION >= 0x050900 // With Qt 5.9 a signal is emitted while the QuarterWidget is being destroyed. // At this state its type is a QWidget, not a QuarterWidget any more. QuarterWidget* qw = qobject_cast(parent()); if (!qw) return; -#endif QMetaObject::invokeMethod(parent(), "aboutToDestroyGLContext", Qt::DirectConnection, QGenericReturnArgument()); @@ -835,7 +831,6 @@ QuarterWidget::seek(void) bool QuarterWidget::updateDevicePixelRatio(void) { -#if QT_VERSION >= 0x050000 qreal dev_pix_ratio = 1.0; QWidget* winwidg = window(); QWindow* win = NULL; @@ -853,7 +848,6 @@ QuarterWidget::updateDevicePixelRatio(void) { emit devicePixelRatioChanged(dev_pix_ratio); return true; } -#endif return false; } @@ -1049,19 +1043,7 @@ QuarterWidget::redraw(void) // Note that, the recursive repaint is not infinite due to setting // 'processdelayqueue = false' above. However, it does cause annoying // flickering, and actually crash on Windows. -#if 1 this->viewport()->update(); -#else - -// #if QT_VERSION >= 0x050500 && QT_VERSION < 0x050600 -#if 1 - // With Qt 5.5.x there is a major performance problem - this->viewport()->update(); -#else - this->viewport()->repaint(); -#endif - -#endif } /*! @@ -1355,9 +1337,7 @@ QuarterWidget::setNavigationModeFile(const QUrl & url) //navigation systems? - BFG 20090117 this->setStateCursor("interact", Qt::ArrowCursor); this->setStateCursor("idle", Qt::OpenHandCursor); -#if QT_VERSION >= 0x040200 this->setStateCursor("rotate", Qt::ClosedHandCursor); -#endif this->setStateCursor("pan", Qt::SizeAllCursor); this->setStateCursor("zoom", Qt::SizeVerCursor); this->setStateCursor("dolly", Qt::SizeVerCursor); diff --git a/src/Gui/SceneInspector.cpp b/src/Gui/SceneInspector.cpp index c407118e32..ee98a22abb 100644 --- a/src/Gui/SceneInspector.cpp +++ b/src/Gui/SceneInspector.cpp @@ -170,13 +170,8 @@ void DlgInspector::setNode(SoNode* node) model->setNode(node); QHeaderView* header = ui->treeView->header(); -#if QT_VERSION >= 0x050000 header->setSectionResizeMode(0, QHeaderView::Stretch); header->setSectionsMovable(false); -#else - header->setResizeMode(0, QHeaderView::Stretch); - header->setMovable(false); -#endif } void DlgInspector::setNodeNames(Gui::Document* doc) diff --git a/src/Gui/SelectionView.cpp b/src/Gui/SelectionView.cpp index 4459b02d60..ee8e5039b0 100644 --- a/src/Gui/SelectionView.cpp +++ b/src/Gui/SelectionView.cpp @@ -65,9 +65,7 @@ SelectionView::SelectionView(Gui::Document* pcDocument, QWidget *parent) vLayout->setMargin (0); QLineEdit* searchBox = new QLineEdit(this); -#if QT_VERSION >= 0x040700 searchBox->setPlaceholderText(tr("Search")); -#endif searchBox->setToolTip(tr("Searches object labels")); QHBoxLayout* hLayout = new QHBoxLayout(); hLayout->setSpacing(2); @@ -97,10 +95,8 @@ SelectionView::SelectionView(Gui::Document* pcDocument, QWidget *parent) pickList->setVisible(false); vLayout->addWidget(pickList); -#if QT_VERSION >= 0x040200 selectionView->setMouseTracking(true); // needed for itemEntered() to work pickList->setMouseTracking(true); -#endif resize(200, 200); diff --git a/src/Gui/SoFCOffscreenRenderer.cpp b/src/Gui/SoFCOffscreenRenderer.cpp index 4f86f8752b..a54220fac7 100644 --- a/src/Gui/SoFCOffscreenRenderer.cpp +++ b/src/Gui/SoFCOffscreenRenderer.cpp @@ -614,7 +614,6 @@ SoQtOffscreenRenderer::makeFrameBuffer(int width, int height, int samples) viewport.setWindowSize(width, height); -#if QT_VERSION >= 0x040600 QtGLFramebufferObjectFormat fmt; fmt.setSamples(samples); fmt.setAttachment(QtGLFramebufferObject::Depth); @@ -624,10 +623,6 @@ SoQtOffscreenRenderer::makeFrameBuffer(int width, int height, int samples) // format and in the output image search for the above color and // replaces it with the color requested by the user. fmt.setInternalTextureFormat(this->texFormat); -#else - QtGLFramebufferObject::Attachment fmt; - fmt = QtGLFramebufferObject::Depth; -#endif framebuffer = new QtGLFramebufferObject(width, height, fmt); cache_context = SoGLCacheContextElement::getUniqueCacheContext(); // unique per pixel buffer object, just to be sure diff --git a/src/Gui/Splashscreen.cpp b/src/Gui/Splashscreen.cpp index 02adf81563..00e0913052 100644 --- a/src/Gui/Splashscreen.cpp +++ b/src/Gui/Splashscreen.cpp @@ -652,7 +652,6 @@ void AboutDialog::showCollectionInformation() void AboutDialog::linkActivated(const QUrl& link) { -//#if defined(Q_OS_WIN) && QT_VERSION < 0x050602 LicenseView* licenseView = new LicenseView(); licenseView->setAttribute(Qt::WA_DeleteOnClose); licenseView->show(); @@ -665,9 +664,6 @@ void AboutDialog::linkActivated(const QUrl& link) licenseView->setWindowTitle(title); getMainWindow()->addWindow(licenseView); licenseView->setSource(link); -//#else -// QDesktopServices::openUrl(link); -//#endif } void AboutDialog::on_copyButton_clicked() diff --git a/src/Gui/SyntaxHighlighter.cpp b/src/Gui/SyntaxHighlighter.cpp index 1c3e829968..dd6c065576 100644 --- a/src/Gui/SyntaxHighlighter.cpp +++ b/src/Gui/SyntaxHighlighter.cpp @@ -159,13 +159,7 @@ void SyntaxHighlighter::colorChanged(const QString& type, const QColor& col) { Q_UNUSED(type); Q_UNUSED(col); - // rehighlight -#if QT_VERSION >= 0x040200 rehighlight(); -#else - document()->setPlainText(document()->toPlainText()); - document()->setModified(false); -#endif } int SyntaxHighlighter::maximumUserState() const diff --git a/src/Gui/TaskView/TaskDialogPython.cpp b/src/Gui/TaskView/TaskDialogPython.cpp index 61a0a62def..15d615f8d5 100644 --- a/src/Gui/TaskView/TaskDialogPython.cpp +++ b/src/Gui/TaskView/TaskDialogPython.cpp @@ -289,9 +289,7 @@ TaskDialogPython::TaskDialogPython(const Py::Object& o) : dlg(o) { if (dlg.hasAttr(std::string("ui"))) { UiLoader loader; -#if QT_VERSION >= 0x040500 loader.setLanguageChangeEnabled(true); -#endif QString fn, icon; Py::String ui(dlg.getAttr(std::string("ui"))); std::string path = (std::string)ui; diff --git a/src/Gui/TreeView.cpp b/src/Gui/TreeView.cpp index 3c708c4c97..fb27e79d8f 100644 --- a/src/Gui/TreeView.cpp +++ b/src/Gui/TreeView.cpp @@ -47,10 +47,7 @@ TreeView::TreeView(QWidget* parent) this->setDropIndicatorShown(false); this->setRootIsDecorated(false); this->setSelectionMode(QAbstractItemView::ExtendedSelection); -#if QT_VERSION >= 0x040200 - // causes unexpected drop events (possibly only with Qt4.1.x) this->setMouseTracking(true); // needed for itemEntered() to work -#endif } TreeView::~TreeView() diff --git a/src/Gui/View3DInventorViewer.cpp b/src/Gui/View3DInventorViewer.cpp index 0ecdfa6009..4dca6fc70f 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -271,13 +271,8 @@ public: // Thus, we filter out horizontal scrolling. if (event->type() == QEvent::Wheel) { QWheelEvent* we = static_cast(event); -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) if (qAbs(we->angleDelta().x()) > qAbs(we->angleDelta().y())) return true; -#else - if (we->orientation() == Qt::Horizontal) - return true; -#endif } else if (event->type() == QEvent::KeyPress) { QKeyEvent* ke = static_cast(event); @@ -601,10 +596,8 @@ void View3DInventorViewer::init() //create the cursors createStandardCursors(devicePixelRatio()); -#if (QT_VERSION >= 0x050000) connect(this, &View3DInventorViewer::devicePixelRatioChanged, this, &View3DInventorViewer::createStandardCursors); -#endif naviCube = new NaviCube(this); naviCubeEnabled = true; diff --git a/src/Gui/WaitCursor.cpp b/src/Gui/WaitCursor.cpp index b441ad8b58..62f14cdb8c 100644 --- a/src/Gui/WaitCursor.cpp +++ b/src/Gui/WaitCursor.cpp @@ -33,9 +33,7 @@ # endif #endif -#if QT_VERSION >= 0x050000 -# include -#endif +#include #include "WaitCursor.h" @@ -105,13 +103,11 @@ void WaitCursorP::setIgnoreEvents(WaitCursor::FilterEventsFlags flags) bool WaitCursorP::isModalDialog(QObject* o) const { QWidget* parent = qobject_cast(o); -#if QT_VERSION >= 0x050000 if (!parent) { QWindow* window = qobject_cast(o); if (window) parent = QWidget::find(window->winId()); } -#endif while (parent) { QMessageBox* dlg = qobject_cast(parent); if (dlg && dlg->isModal()) diff --git a/src/Gui/WidgetFactory.cpp b/src/Gui/WidgetFactory.cpp index 70f3e0f6c9..dcbdc43cb1 100644 --- a/src/Gui/WidgetFactory.cpp +++ b/src/Gui/WidgetFactory.cpp @@ -27,9 +27,7 @@ # include # include #endif -#if QT_VERSION >= 0x050200 -# include -#endif +#include // Uncomment this block to remove PySide C++ support and switch to its Python interface //#undef HAVE_SHIBOKEN @@ -178,7 +176,7 @@ PythonToCppFunc isBaseQuantity_PythonToCpp_QVariantConvertible(PyObject* obj) return 0; } -#if defined (HAVE_PYSIDE) && QT_VERSION >= 0x050200 +#if defined (HAVE_PYSIDE) Base::Quantity convertWrapperToQuantity(const PySide::PyObjectWrapper &w) { PyObject* pyIn = static_cast(w); @@ -208,7 +206,7 @@ void registerTypes() isBaseQuantity_PythonToCpp_QVariantConvertible); } -#if defined (HAVE_PYSIDE) && QT_VERSION >= 0x050200 +#if defined (HAVE_PYSIDE) QMetaType::registerConverter(&convertWrapperToQuantity); #endif } @@ -367,16 +365,11 @@ QObject* PythonWrapper::toQObject(const Py::Object& pyobject) return reinterpret_cast(cppobject); } } -#elif QT_VERSION >= 0x050000 +#else // Access shiboken2/PySide2 via Python // void* ptr = qt_getCppPointer(pyobject, "shiboken2", "getCppPointer"); return reinterpret_cast(ptr); -#else - // Access shiboken/PySide via Python - // - void* ptr = qt_getCppPointer(pyobject, "shiboken", "getCppPointer"); - return reinterpret_cast(ptr); #endif #if 0 // Unwrapping using sip/PyQt @@ -398,16 +391,11 @@ QGraphicsItem* PythonWrapper::toQGraphicsItem(PyObject* pyPtr) return reinterpret_cast(cppobject); } } -#elif QT_VERSION >= 0x050000 +#else // Access shiboken2/PySide2 via Python // void* ptr = qt_getCppPointer(Py::asObject(pyPtr), "shiboken2", "getCppPointer"); return reinterpret_cast(ptr); -#else - // Access shiboken/PySide via Python - // - void* ptr = qt_getCppPointer(Py::asObject(pyPtr), "shiboken", "getCppPointer"); - return reinterpret_cast(ptr); #endif return nullptr; } @@ -420,14 +408,10 @@ Py::Object PythonWrapper::fromQIcon(const QIcon* icon) const_cast(icon), true, false, typeName); if (pyobj) return Py::asObject(pyobj); -#elif QT_VERSION >= 0x050000 +#else // Access shiboken2/PySide2 via Python // return qt_wrapInstance(icon, "QIcon", "shiboken2", "PySide2.QtGui", "wrapInstance"); -#else - // Access shiboken/PySide via Python - // - return qt_wrapInstance(icon, "QIcon", "shiboken", "PySide.QtGui", "wrapInstance"); #endif throw Py::RuntimeError("Failed to wrap icon"); } @@ -466,24 +450,14 @@ Py::Object PythonWrapper::fromQObject(QObject* object, const char* className) return Py::asObject(pyobj); } throw Py::RuntimeError("Failed to wrap object"); - -#elif QT_VERSION >= 0x050000 +#else // Access shiboken2/PySide2 via Python // return qt_wrapInstance(object, className, "shiboken2", "PySide2.QtCore", "wrapInstance"); -#else - // Access shiboken/PySide via Python - // - return qt_wrapInstance(object, className, "shiboken", "PySide.QtCore", "wrapInstance"); #endif - #if 0 // Unwrapping using sip/PyQt Q_UNUSED(className); -#if QT_VERSION >= 0x050000 return qt_wrapInstance(object, "QObject", "sip", "PyQt5.QtCore", "wrapinstance"); -#else - return qt_wrapInstance(object, "QObject", "sip", "PyQt4.Qt", "wrapinstance"); -#endif #endif } @@ -505,23 +479,15 @@ Py::Object PythonWrapper::fromQWidget(QWidget* widget, const char* className) } throw Py::RuntimeError("Failed to wrap widget"); -#elif QT_VERSION >= 0x050000 +#else // Access shiboken2/PySide2 via Python // return qt_wrapInstance(widget, className, "shiboken2", "PySide2.QtWidgets", "wrapInstance"); -#else - // Access shiboken/PySide via Python - // - return qt_wrapInstance(widget, className, "shiboken", "PySide.QtGui", "wrapInstance"); #endif #if 0 // Unwrapping using sip/PyQt Q_UNUSED(className); -#if QT_VERSION >= 0x050000 return qt_wrapInstance(widget, "QWidget", "sip", "PyQt5.QtWidgets", "wrapinstance"); -#else - return qt_wrapInstance(widget, "QWidget", "sip", "PyQt4.Qt", "wrapinstance"); -#endif #endif } @@ -619,7 +585,7 @@ void PythonWrapper::createChildrenNameAttributes(PyObject* root, QObject* object #if defined (HAVE_SHIBOKEN) && defined(HAVE_PYSIDE) Shiboken::AutoDecRef pyChild(Shiboken::Conversions::pointerToPython(reinterpret_cast(getPyTypeObjectForTypeName()), child)); PyObject_SetAttrString(root, name.constData(), pyChild); -#elif QT_VERSION >= 0x050000 +#else const char* className = qt_identifyType(child, "PySide2.QtWidgets"); if (!className) { if (qobject_cast(child)) @@ -630,17 +596,6 @@ void PythonWrapper::createChildrenNameAttributes(PyObject* root, QObject* object Py::Object pyChild(qt_wrapInstance(child, className, "shiboken2", "PySide2.QtWidgets", "wrapInstance")); PyObject_SetAttrString(root, name.constData(), pyChild.ptr()); -#else - const char* className = qt_identifyType(child, "PySide.QtGui"); - if (!className) { - if (qobject_cast(child)) - className = "QWidget"; - else - className = "QObject"; - } - - Py::Object pyChild(qt_wrapInstance(child, className, "shiboken", "PySide.QtGui", "wrapInstance")); - PyObject_SetAttrString(root, name.constData(), pyChild.ptr()); #endif } createChildrenNameAttributes(root, child); @@ -822,7 +777,6 @@ Py::Object PySideUicModule::loadUiType(const Py::Tuple& args) QString cmd; QTextStream str(&cmd); // https://github.com/albop/dolo/blob/master/bin/load_ui.py -#if QT_VERSION >= 0x050000 str << "import pyside2uic\n" << "from PySide2 import QtCore, QtGui, QtWidgets\n" << "import xml.etree.ElementTree as xml\n" @@ -844,29 +798,6 @@ Py::Object PySideUicModule::loadUiType(const Py::Tuple& args) << " #Fetch the base_class and form class based on their type in the xml from designer\n" << " form_class = frame['Ui_%s'%form_class]\n" << " base_class = eval('QtWidgets.%s'%widget_class)\n"; -#else - str << "import pysideuic\n" - << "from PySide import QtCore, QtGui\n" - << "import xml.etree.ElementTree as xml\n" - << "try:\n" - << " from cStringIO import StringIO\n" - << "except Exception:\n" - << " from io import StringIO\n" - << "\n" - << "uiFile = \"" << file.c_str() << "\"\n" - << "parsed = xml.parse(uiFile)\n" - << "widget_class = parsed.find('widget').get('class')\n" - << "form_class = parsed.find('class').text\n" - << "with open(uiFile, 'r') as f:\n" - << " o = StringIO()\n" - << " frame = {}\n" - << " pysideuic.compileUi(f, o, indent=0)\n" - << " pyc = compile(o.getvalue(), '', 'exec')\n" - << " exec(pyc, frame)\n" - << " #Fetch the base_class and form class based on their type in the xml from designer\n" - << " form_class = frame['Ui_%s'%form_class]\n" - << " base_class = eval('QtGui.%s'%widget_class)\n"; -#endif PyObject* result = PyRun_String((const char*)cmd.toLatin1(), Py_file_input, d.ptr(), d.ptr()); if (result) { @@ -924,15 +855,8 @@ Py::Object PySideUicModule::loadUi(const Py::Tuple& args) << "loader = UiLoader(globals()[\"base_\"])\n" << "widget = loader.load(globals()[\"uiFile_\"])\n" << "\n"; -#elif QT_VERSION >= 0x050000 - str << "from PySide2 import QtCore, QtGui, QtWidgets\n" - << "import FreeCADGui" - << "\n" - << "loader = FreeCADGui.UiLoader()\n" - << "widget = loader.load(globals()[\"uiFile_\"])\n" - << "\n"; #else - str << "from PySide import QtCore, QtGui\n" + str << "from PySide2 import QtCore, QtGui, QtWidgets\n" << "import FreeCADGui" << "\n" << "loader = FreeCADGui.UiLoader()\n" @@ -1408,9 +1332,7 @@ void PyResource::load(const char* name) QWidget* w=0; try { UiLoader loader; -#if QT_VERSION >= 0x040500 loader.setLanguageChangeEnabled(true); -#endif QFile file(fn); if (file.open(QFile::ReadOnly)) w = loader.load(&file, QApplication::activeWindow()); diff --git a/src/Gui/Widgets.cpp b/src/Gui/Widgets.cpp index 55dce30d16..930d709280 100644 --- a/src/Gui/Widgets.cpp +++ b/src/Gui/Widgets.cpp @@ -759,14 +759,10 @@ void ColorButton::onChooseColor() { if (!d->allowChange) return; -#if QT_VERSION >= 0x040500 if (d->modal) { -#endif QColor currentColor = d->col; QColorDialog cd(d->col, this); -#if QT_VERSION >= 0x050000 cd.setOptions(QColorDialog::DontUseNativeDialog); -#endif if (d->autoChange) { connect(&cd, SIGNAL(currentColorChanged(const QColor &)), @@ -786,15 +782,12 @@ void ColorButton::onChooseColor() setColor(currentColor); changed(); } -#if QT_VERSION >= 0x040500 } else { if (d->cd.isNull()) { d->old = d->col; d->cd = new QColorDialog(d->col, this); -#if QT_VERSION >= 0x050000 d->cd->setOptions(QColorDialog::DontUseNativeDialog); -#endif d->cd->setAttribute(Qt::WA_DeleteOnClose); connect(d->cd, SIGNAL(rejected()), this, SLOT(onRejected())); @@ -803,7 +796,6 @@ void ColorButton::onChooseColor() } d->cd->show(); } -#endif } void ColorButton::onColorChosen(const QColor& c) diff --git a/src/Gui/Widgets.h b/src/Gui/Widgets.h index f6f3dd6402..3f868697cf 100644 --- a/src/Gui/Widgets.h +++ b/src/Gui/Widgets.h @@ -157,11 +157,7 @@ private Q_SLOTS: void updateClearButton(const QString &text); private: -#if QT_VERSION >= 0x050200 QAction *clearAction; -#else - QToolButton *clearButton; -#endif }; // ------------------------------------------------------------------------------ diff --git a/src/Gui/WinNativeGestureRecognizers.h b/src/Gui/WinNativeGestureRecognizers.h index 843081e166..6cf09fb3cc 100644 --- a/src/Gui/WinNativeGestureRecognizers.h +++ b/src/Gui/WinNativeGestureRecognizers.h @@ -32,14 +32,6 @@ #include #include -#ifdef Q_OS_WIN -#if QT_VERSION < 0x050000 -#if(WINVER >= 0x0601) // need Windows 7 -#define GESTURE_MESS -#endif -#endif // QT_VERSION < 0x050000 -#endif // Q_OS_WIN - #ifdef GESTURE_MESS /*! diff --git a/src/Gui/iisTaskPanel/src/iisiconlabel.cpp b/src/Gui/iisTaskPanel/src/iisiconlabel.cpp index e80ec302f1..eaae92a108 100644 --- a/src/Gui/iisTaskPanel/src/iisiconlabel.cpp +++ b/src/Gui/iisTaskPanel/src/iisiconlabel.cpp @@ -127,11 +127,7 @@ void iisIconLabel::paintEvent ( QPaintEvent * event ) QRect boundingRect; QFontMetrics fm(fnt); -#if QT_VERSION >= 0x040203 QString txt(fm.elidedText(myText, Qt::ElideRight, textRect.width())); -#else - QString txt = myText; -#endif p.drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, txt, &boundingRect); diff --git a/src/Gui/iisTaskPanel/src/iistaskbox.cpp b/src/Gui/iisTaskPanel/src/iistaskbox.cpp index f60e37f242..a3a95fdf0a 100644 --- a/src/Gui/iisTaskPanel/src/iistaskbox.cpp +++ b/src/Gui/iisTaskPanel/src/iistaskbox.cpp @@ -77,11 +77,7 @@ void iisTaskBox::showHide() if (m_foldStep) return; -#if QT_VERSION >= 0x050000 m_foldPixmap = myGroup->grab(myGroup->rect()); -#else - m_foldPixmap = QPixmap::grabWidget(myGroup, myGroup->rect()); -#endif if (myGroup->isVisible()) { m_tempHeight = m_fullHeight = myGroup->height(); @@ -158,12 +154,10 @@ void iisTaskBox::paintEvent ( QPaintEvent * event ) QPainter p(this); if (myDummy->isVisible()) { -#if QT_VERSION >= 0x040202 if (m_foldDirection < 0) p.setOpacity((double)m_foldStep / myScheme->groupFoldSteps); else p.setOpacity((double)(myScheme->groupFoldSteps-m_foldStep) / myScheme->groupFoldSteps); -#endif p.drawPixmap(myDummy->x(),myDummy->y(),m_foldPixmap); diff --git a/src/Gui/iisTaskPanel/src/iistaskheader.cpp b/src/Gui/iisTaskPanel/src/iistaskheader.cpp index 4d1cd42432..d037f112c7 100644 --- a/src/Gui/iisTaskPanel/src/iistaskheader.cpp +++ b/src/Gui/iisTaskPanel/src/iistaskheader.cpp @@ -100,10 +100,8 @@ void iisTaskHeader::paintEvent ( QPaintEvent * event ) Q_UNUSED(event); QPainter p(this); -#if QT_VERSION >= 0x040203 if (myScheme->headerAnimation) p.setOpacity(m_opacity+0.7); -#endif p.setPen(myScheme->headerBorder); p.setBrush(myScheme->headerBackground); From 8992084a9a8d6a0839c086d4dc5be0bd5ea96a02 Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 2 Apr 2021 11:15:04 +0200 Subject: [PATCH 042/178] Gui: [skip ci] remove MainWindow::showMainWindow() & timer --- src/Gui/MainWindow.cpp | 21 ++++----------------- src/Gui/MainWindow.h | 4 ---- 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp index 603cbc8f83..73956a16f3 100644 --- a/src/Gui/MainWindow.cpp +++ b/src/Gui/MainWindow.cpp @@ -172,7 +172,6 @@ struct MainWindowP QTimer* actionTimer; QTimer* statusTimer; QTimer* activityTimer; - QTimer* visibleTimer; QMdiArea* mdiArea; QPointer activeView; QSignalMapper* windowMapper; @@ -342,12 +341,6 @@ MainWindow::MainWindow(QWidget * parent, Qt::WindowFlags f) QClipboard *clipbd = QApplication::clipboard(); connect(clipbd, SIGNAL(dataChanged()), this, SLOT(updateEditorActions())); - // show main window timer - d->visibleTimer = new QTimer(this); - d->visibleTimer->setObjectName(QString::fromLatin1("visibleTimer")); - connect(d->visibleTimer, SIGNAL(timeout()),this, SLOT(showMainWindow())); - d->visibleTimer->setSingleShot(true); - d->windowMapper = new QSignalMapper(this); // connection between workspace, window menu and tab bar @@ -1190,22 +1183,16 @@ void MainWindow::closeEvent (QCloseEvent * e) } } -void MainWindow::showEvent(QShowEvent * /*e*/) +void MainWindow::showEvent(QShowEvent* e) { - // needed for logging std::clog << "Show main window" << std::endl; - d->visibleTimer->start(15000); + QMainWindow::showEvent(e); } -void MainWindow::hideEvent(QHideEvent * /*e*/) +void MainWindow::hideEvent(QHideEvent* e) { - // needed for logging std::clog << "Hide main window" << std::endl; - d->visibleTimer->stop(); -} - -void MainWindow::showMainWindow() -{ + QMainWindow::hideEvent(e); } void MainWindow::processMessages(const QList & msg) diff --git a/src/Gui/MainWindow.h b/src/Gui/MainWindow.h index b4c94df325..17d0eb2b94 100644 --- a/src/Gui/MainWindow.h +++ b/src/Gui/MainWindow.h @@ -297,10 +297,6 @@ private Q_SLOTS: * This method gets frequently activated and test the commands if they are still active. */ void _updateActions(); - /** - * \internal - */ - void showMainWindow(); /** * \internal */ From 37eb08380a3589f85232b11b29fe4c9c5817eb02 Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 2 Apr 2021 11:47:12 +0200 Subject: [PATCH 043/178] Gui: remove WinNativeGestureRecognizers because this was a workaround for Qt4 under Windows --- src/Gui/CMakeLists.txt | 2 - src/Gui/View3DInventorViewer.cpp | 43 ---- src/Gui/View3DInventorViewer.h | 7 - src/Gui/WinNativeGestureRecognizers.cpp | 287 ------------------------ src/Gui/WinNativeGestureRecognizers.h | 64 ------ 5 files changed, 403 deletions(-) delete mode 100644 src/Gui/WinNativeGestureRecognizers.cpp delete mode 100644 src/Gui/WinNativeGestureRecognizers.h diff --git a/src/Gui/CMakeLists.txt b/src/Gui/CMakeLists.txt index 3b6bb31bc8..03cba79384 100644 --- a/src/Gui/CMakeLists.txt +++ b/src/Gui/CMakeLists.txt @@ -1263,7 +1263,6 @@ SET(FreeCADGui_CPP_SRCS WaitCursor.cpp ManualAlignment.cpp TransactionObject.cpp - WinNativeGestureRecognizers.cpp ) SET(FreeCADGui_SRCS Application.h @@ -1296,7 +1295,6 @@ SET(FreeCADGui_SRCS WaitCursor.h ManualAlignment.h TransactionObject.h - WinNativeGestureRecognizers.h ${FreeCADGui_SDK_MOC_HDRS} ) diff --git a/src/Gui/View3DInventorViewer.cpp b/src/Gui/View3DInventorViewer.cpp index 4dca6fc70f..a39e61fbad 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -145,7 +145,6 @@ #include #include "SoTouchEvents.h" -#include "WinNativeGestureRecognizers.h" #include "Document.h" #include "ViewParams.h" @@ -237,35 +236,6 @@ public: ~ViewerEventFilter() {} bool eventFilter(QObject* obj, QEvent* event) { - -#ifdef GESTURE_MESS - if (obj->isWidgetType()) { - View3DInventorViewer* v = dynamic_cast(obj); - if(v) { - /* Internally, Qt seems to set up the gestures upon showing the - * widget (but after this event is processed), thus invalidating - * our settings. This piece takes care to retune gestures on the - * next event after the show event. - */ - if(v->winGestureTuneState == View3DInventorViewer::ewgtsNeedTuning) { - try{ - WinNativeGestureRecognizerPinch::TuneWindowsGestures(v); - v->winGestureTuneState = View3DInventorViewer::ewgtsTuned; - } catch (Base::Exception &e) { - Base::Console().Warning("Failed to TuneWindowsGestures. Error: %s\n",e.what()); - v->winGestureTuneState = View3DInventorViewer::ewgtsDisabled; - } catch (...) { - Base::Console().Warning("Failed to TuneWindowsGestures. Unknown error.\n"); - v->winGestureTuneState = View3DInventorViewer::ewgtsDisabled; - } - } - if (event->type() == QEvent::Show && v->winGestureTuneState == View3DInventorViewer::ewgtsTuned) - v->winGestureTuneState = View3DInventorViewer::ewgtsNeedTuning; - - } - } -#endif - // Bug #0000607: Some mice also support horizontal scrolling which however might // lead to some unwanted zooming when pressing the MMB for panning. // Thus, we filter out horizontal scrolling. @@ -574,20 +544,9 @@ void View3DInventorViewer::init() getEventFilter()->registerInputDevice(new SpaceNavigatorDevice); getEventFilter()->registerInputDevice(new GesturesDevice(this)); - this->winGestureTuneState = View3DInventorViewer::ewgtsDisabled; try{ this->grabGesture(Qt::PanGesture); this->grabGesture(Qt::PinchGesture); - #ifdef GESTURE_MESS - { - static WinNativeGestureRecognizerPinch* recognizer;//static to avoid creating more than one recognizer, thus causing memory leak and gradual slowdown - if(recognizer == 0){ - recognizer = new WinNativeGestureRecognizerPinch; - recognizer->registerRecognizer(recognizer); //From now on, Qt owns the pointer. - } - } - this->winGestureTuneState = View3DInventorViewer::ewgtsNeedTuning; - #endif } catch (Base::Exception &e) { Base::Console().Warning("Failed to set up gestures. Error: %s\n", e.what()); } catch (...) { @@ -1504,8 +1463,6 @@ void View3DInventorViewer::setNavigationType(Base::Type t) if (t.isBad()) return; - this->winGestureTuneState = View3DInventorViewer::ewgtsNeedTuning; //triggers enable/disable rotation gesture when preferences change - if (this->navigation && this->navigation->getTypeId() == t) return; // nothing to do diff --git a/src/Gui/View3DInventorViewer.h b/src/Gui/View3DInventorViewer.h index 97908837c8..8591f648b0 100644 --- a/src/Gui/View3DInventorViewer.h +++ b/src/Gui/View3DInventorViewer.h @@ -401,13 +401,6 @@ protected: void printDimension(); void selectAll(); - enum eWinGestureTuneState{ - ewgtsDisabled, //suppress tuning/re-tuning after errors - ewgtsNeedTuning, //gestures are to be re-tuned upon next event - ewgtsTuned - }; - eWinGestureTuneState winGestureTuneState;//See ViewerEventFilter::eventFilter function for explanation - private: static void setViewportCB(void * userdata, SoAction * action); static void clearBufferCB(void * userdata, SoAction * action); diff --git a/src/Gui/WinNativeGestureRecognizers.cpp b/src/Gui/WinNativeGestureRecognizers.cpp deleted file mode 100644 index 9a1c02b1e0..0000000000 --- a/src/Gui/WinNativeGestureRecognizers.cpp +++ /dev/null @@ -1,287 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2015 Victor Titov (DeepSOIC) * - * * - * 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 -# include -# include -# ifdef FC_OS_WIN32 -# include -# define _USE_MATH_DEFINES -# include -# endif -# include -#endif - -#include "WinNativeGestureRecognizers.h" -#ifdef GESTURE_MESS -//this implementation is a bit incompatible with Qt5, since -//nativegesture members were transformed into properties, and -//the whole event was made public - - -#include - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -#if !defined(QT_NO_NATIVE_GESTURES) - -//#include -//this include is not available on conda Qt, see https://forum.freecadweb.org/viewtopic.php?f=4&t=21405&p=167395#p167395 -//copy-pasted from this header: -class QNativeGestureEvent : public QEvent -{ -public: - enum Type { - None, - GestureBegin, - GestureEnd, - Pan, - Zoom, - Rotate, - Swipe - }; - - QNativeGestureEvent() - : QEvent(QEvent::NativeGesture), gestureType(None), percentage(0) -#ifdef Q_WS_WIN - , sequenceId(0), argument(0) -#endif - { - } - - Type gestureType; - float percentage; - QPoint position; - float angle; -#ifdef Q_WS_WIN - ulong sequenceId; - quint64 argument; -#endif -}; - - -QGesture* WinNativeGestureRecognizerPinch::create(QObject* target) -{ - if (!target) - return new QPinchGestureN; // a special case - if (!target->isWidgetType()) - return 0; - if (qobject_cast(target)) - return 0; - - //QWidget* q = static_cast(target); - /*QWidgetPrivate *d = q->d_func(); - d->nativeGesturePanEnabled = true; - d->winSetupGestures();*/ //fails to compile =(, but we can rely on this being done by grabGesture(Pan... - - return new QPinchGestureN; -} - -QGestureRecognizer::Result WinNativeGestureRecognizerPinch::recognize(QGesture *gesture, QObject *watched, QEvent *event) -{ - QPinchGestureN* q = static_cast (gesture); - //QPinchGesturePrivate* d = q->d_func();//this fails to compile =( But we can get away without it. - - QGestureRecognizer::Result result = QGestureRecognizer::Ignore; - if (event->type() == QEvent::NativeGesture) { - bool bZoom = false; - bool bRotate = false; - QNativeGestureEvent *ev = static_cast(event); - switch(ev->gestureType) { - case QNativeGestureEvent::GestureBegin: - break; - case QNativeGestureEvent::Zoom: - case QNativeGestureEvent::Rotate: - bZoom = ev->gestureType == QNativeGestureEvent::Zoom; - bRotate = ev->gestureType == QNativeGestureEvent::Rotate; - result = QGestureRecognizer::TriggerGesture; - event->accept(); - break; - case QNativeGestureEvent::GestureEnd: - if (q->state() == Qt::NoGesture) - return QGestureRecognizer::Ignore; // some other gesture has ended - result = QGestureRecognizer::FinishGesture; - break; - default: - return QGestureRecognizer::Ignore; - } - double ang = 0.0; - if (bRotate) - ang = -GID_ROTATE_ANGLE_FROM_ARGUMENT(LOWORD(ev->argument)) / M_PI * 180.0; - if (q->state() == Qt::NoGesture) { - //start of a new gesture, prefill stuff - //d->isNewSequence = true; - q->setTotalChangeFlags(0); q->setChangeFlags(0); - - q->setLastCenterPoint(QPointF()); - q->setCenterPoint( - QPointF( - qreal(ev->position.x()), - qreal(ev->position.y()) - ) - ); - q->setStartCenterPoint(q->centerPoint()); - q->setTotalRotationAngle(0.0); q->setLastRotationAngle(0.0); q->setRotationAngle(0.0); - q->setTotalScaleFactor(1.0); q->setLastScaleFactor(1.0); q->setScaleFactor(1.0); - if(bZoom) { - q->myLastFingerDistance = ev->argument; - q->myFingerDistance = ev->argument; - q->myStartFingerDistance = ev->argument; - } else if (bRotate) { - q->myLastRotationAngle = 0; - q->myRotationAngle = 0; - q->myStartAngle = 0; - } - } else {//in the middle of gesture - - //store new last values - q->setLastCenterPoint(q->centerPoint()); - q->setLastRotationAngle(q->rotationAngle()); - q->setLastScaleFactor(q->scaleFactor()); - q->myLastFingerDistance = q->myFingerDistance; - q->myLastRotationAngle = q->myRotationAngle; - - //update the current values - if (bZoom) - q->myFingerDistance = ev->argument; - if (bRotate) - q->myRotationAngle = ang; - if(ev->gestureType == QNativeGestureEvent::GestureEnd){ - q->myFingerDistance = q->myLastFingerDistance;//the end-of-gesture event holds no finger separation data, hence we are using the last value. - q->myRotationAngle = q->myLastRotationAngle; - } - if (bZoom) - q->setScaleFactor( - (qreal)(q->myFingerDistance) / (qreal)(q->myLastFingerDistance) - ); - if (bRotate) - q->setRotationAngle(q->myRotationAngle); - q->setCenterPoint( - QPointF( - qreal(ev->position.x()), - qreal(ev->position.y()) - ) - ); - - //detect changes - QPinchGesture::ChangeFlags cf = 0; - if ( q->scaleFactor() != 1.0 ) - cf |= QPinchGesture::ScaleFactorChanged; - if (q->lastCenterPoint() != q->centerPoint()) - cf |= QPinchGesture::CenterPointChanged; - if (q->rotationAngle() != q->lastRotationAngle()) - cf |= QPinchGesture::RotationAngleChanged; - q->setChangeFlags(cf); - - //update totals - q->setTotalChangeFlags (q->totalChangeFlags() | q->changeFlags()); - q->setTotalScaleFactor (q->totalScaleFactor() * q->scaleFactor()); - q->setTotalRotationAngle (q->rotationAngle()); - } - } - return result; -} - - -void WinNativeGestureRecognizerPinch::reset(QGesture* gesture) -{ - QGestureRecognizer::reset(gesture);//resets the state of the gesture, which is not write-accessible otherwise - QPinchGestureN *q = static_cast(gesture); - q->myLastFingerDistance = 0; - q->setTotalChangeFlags(0); q->setChangeFlags(0); - - q->setLastCenterPoint(QPointF()); - q->setCenterPoint( - QPointF( - 0.0, - 0.0 - ) - ); - q->setStartCenterPoint(q->centerPoint()); - q->setTotalRotationAngle(0.0); q->setLastRotationAngle(0.0); q->setRotationAngle(0.0); - q->setTotalScaleFactor(1.0); q->setLastScaleFactor(1.0); q->setScaleFactor(1.0); - q->myLastFingerDistance = 0; - q->myFingerDistance = 0; -} - -//function prototype for dymanic linking -typedef BOOL ( __stdcall * ptrSetGestureConfig) ( - HWND , // window for which configuration is specified - DWORD , // reserved, must be 0 - UINT , // count of GESTURECONFIG structures - PGESTURECONFIG , // array of GESTURECONFIG structures, dwIDs will be processed in the - // order specified and repeated occurrences will overwrite previous ones - UINT ); // sizeof(GESTURECONFIG) - -void WinNativeGestureRecognizerPinch::TuneWindowsGestures(QWidget* target) -{ - //modify windows-specific gesture options -#if WINVER >= _WIN32_WINNT_WIN7 - //dynamic linking - required to be able to run on windows pre-7 - HINSTANCE hinstLib = LoadLibraryA("user32.dll"); - if (hinstLib == 0) - throw Base::RuntimeError("LoadLibrary(user32.dll) failed. Could not tune Windows gestures."); - - ptrSetGestureConfig dllSetGestureConfig = reinterpret_cast (GetProcAddress(hinstLib,"SetGestureConfig")); - if (dllSetGestureConfig == 0) - throw Base::RuntimeError("DLL entry point for SetGestureConfig not found in user32.dll. Could not tune Windows gestures."); - - HWND w = target->winId(); - - //fill in the options - const UINT nCfg = 2; - GESTURECONFIG cfgs[nCfg]; - ZeroMemory(&cfgs, sizeof(cfgs)); - cfgs[0].dwID = GID_PAN; - cfgs[0].dwWant = GC_PAN; - cfgs[0].dwBlock = GC_PAN_WITH_GUTTER;//disables stickiness to pure vertical/pure horizontal pans - - bool enableGestureTilt = !(App::GetApplication().GetParameterGroupByPath - ("User parameter:BaseApp/Preferences/View")->GetBool("DisableTouchTilt",true)); - if(enableGestureTilt){ - cfgs[1].dwID = GID_ROTATE; - cfgs[1].dwWant = GC_ROTATE; - } else { - cfgs[1].dwID = GID_ROTATE; - cfgs[1].dwBlock = GC_ROTATE; - } - - //set the options - bool ret = dllSetGestureConfig(w, 0, nCfg, cfgs, sizeof(GESTURECONFIG)); - assert(ret); - if(!ret){ - DWORD err = GetLastError(); - QString errMsg = QString::fromLatin1("Error in SetGestureConfig. GetLastError = %1").arg(err); - throw Base::RuntimeError(errMsg.toLatin1()); - } -#endif -} - -#endif //!defined(QT_NO_NATIVE_GESTURES) - -#endif // GESTURE_MESS diff --git a/src/Gui/WinNativeGestureRecognizers.h b/src/Gui/WinNativeGestureRecognizers.h deleted file mode 100644 index 6cf09fb3cc..0000000000 --- a/src/Gui/WinNativeGestureRecognizers.h +++ /dev/null @@ -1,64 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2015 Victor Titov (DeepSOIC) * - * * - * 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 * - * * - ***************************************************************************/ - -/*! This file adds support for pinch gestures in Windows 8 to Qt4.8. I think it - * may not be necessary for Qt5. I also think this was actually not absolutely - * necessary, and it may be possible to force Qt gesture recognition from plain - * touch input. --DeepSOIC - */ - -#ifndef WINNATIVEGESTURERECOGNIZERS_H -#define WINNATIVEGESTURERECOGNIZERS_H - -#include -#include - -#ifdef GESTURE_MESS - -/*! - * \brief The QPinchGestureN class is a special version of QPinchGesture, - * containing a few extra fields for state tracking. - */ -class QPinchGestureN: public QPinchGesture -{ -public: - int myFingerDistance = 0; //distance between fingers, in pixels - int myLastFingerDistance = 0; - int myStartFingerDistance = 0; //finger distance at gesture start - double myRotationAngle = 0.0; - double myLastRotationAngle = 0.0; - double myStartAngle = 0.0; -}; - -class WinNativeGestureRecognizerPinch : public QGestureRecognizer -{ -public: - WinNativeGestureRecognizerPinch(){} - virtual QGesture* create ( QObject* target ); - virtual Result recognize ( QGesture* gesture, QObject* watched, QEvent* event ); - virtual void reset ( QGesture* gesture ); - static void TuneWindowsGestures(QWidget* target); -}; - -#endif //GESTUREMESS - -#endif // WINNATIVEGESTURERECOGNIZERS_H From bd86b4dcfe35d894a52350cc05cc50a9d23ee2cd Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Wed, 31 Mar 2021 12:03:36 -0500 Subject: [PATCH 044/178] [TD] Remove deprecated Qt < 5.9 code --- src/Mod/TechDraw/App/DrawViewDimension.cpp | 11 +- src/Mod/TechDraw/Gui/Grabber3d.cpp | 20 ---- src/Mod/TechDraw/Gui/MDIViewPage.cpp | 120 +-------------------- src/Mod/TechDraw/Gui/MDIViewPage.h | 8 -- src/Mod/TechDraw/Gui/QGVPage.cpp | 4 - src/Mod/TechDraw/Gui/TaskRichAnno.cpp | 2 - src/Mod/TechDraw/Gui/TemplateTextField.cpp | 4 - 7 files changed, 5 insertions(+), 164 deletions(-) diff --git a/src/Mod/TechDraw/App/DrawViewDimension.cpp b/src/Mod/TechDraw/App/DrawViewDimension.cpp index c7fed72f3f..690cb60486 100644 --- a/src/Mod/TechDraw/App/DrawViewDimension.cpp +++ b/src/Mod/TechDraw/App/DrawViewDimension.cpp @@ -818,12 +818,8 @@ std::string DrawViewDimension::formatValue(qreal value, QString qFormatSpec, int // we reformat the value // the user can overwrite the decimal settings, so we must in every case use the formatSpecifier // the default is: if useDecimals(), then formatSpecifier = global decimals, otherwise it is %.2f -#if QT_VERSION >= 0x050000 formattedValue = QString::asprintf(Base::Tools::toStdString(formatSpecifier).c_str(), userVal); -#else - QString qs2; - formattedValue = qs2.sprintf(Base::Tools::toStdString(formatSpecifier).c_str(), userVal); -#endif + // if abs(1 - userVal / formattedValue) > 0.1 we know that we make an error greater than 10% // then we need more digits if (abs(userVal - formattedValue.toDouble()) > 0.1 * abs(userVal)) { @@ -975,12 +971,7 @@ QStringList DrawViewDimension::getPrefixSuffixSpec(QString fSpec) int pos = 0; if ((pos = rxFormat.indexIn(fSpec, 0)) != -1) { match = rxFormat.cap(0); //entire capture of rx -//#if QT_VERSION >= 0x050000 // formatted = QString::asprintf(Base::Tools::toStdString(match).c_str(),value); -//#else -// QString qs2; -// formatted = qs2.sprintf(Base::Tools::toStdString(match).c_str(),value); -//#endif formatPrefix = fSpec.left(pos); result.append(formatPrefix); formatSuffix = fSpec.right(fSpec.size() - pos - match.size()); diff --git a/src/Mod/TechDraw/Gui/Grabber3d.cpp b/src/Mod/TechDraw/Gui/Grabber3d.cpp index 71f8a952e4..18aa32e44e 100644 --- a/src/Mod/TechDraw/Gui/Grabber3d.cpp +++ b/src/Mod/TechDraw/Gui/Grabber3d.cpp @@ -26,9 +26,7 @@ #endif -//#if QT_VERSION >= 0x050000 //#include -//#endif #include #include @@ -317,18 +315,9 @@ double Grabber3d::getViewerScale(Gui::View3DInventorViewer* viewer) //accurate dpmm for screen is not easily acquired! // double qtpxmm = 96; -//#if QT_VERSION >=050000 // QScreen *screen = QGuiApplication::primaryScreen(); // double qtppi = screen->physicalDotsPerInch(); //~111 dpi // qtpxmm = qtppi / 25.4; -//#else -//// QSize widgetSize = viewer->size(); -//// int qtDpiXLog = viewer->logicalDpiX(); -//// int qtDpiYLog = viewer->logicalDpiY(); -// int qtDpiXPhys = viewer->physicalDpiX(); -// int qtDpiYPhys = viewer->physicalDpiY(); -// qtpxmm = ((qtDpiXPhys + qtDpiYPhys) / 2.0) / 25.4; -//#endif SbViewportRegion vpRegion = viewer->getSoRenderManager()->getViewportRegion(); SbVec2s winSizePx = vpRegion.getWindowSize(); //pixel coords @@ -361,18 +350,9 @@ double Grabber3d::getPaperScale(Gui::View3DInventorViewer* viewer, //accurate dpmm for screen is not easily acquired! // double qtpxmm = 96; -//#if QT_VERSION >=050000 // QScreen *screen = QGuiApplication::primaryScreen(); // double qtppi = screen->physicalDotsPerInch(); //~111 dpi // qtpxmm = qtppi / 25.4; -//#else -//// QSize widgetSize = viewer->size(); -//// int qtDpiXLog = viewer->logicalDpiX(); -//// int qtDpiYLog = viewer->logicalDpiY(); -// int qtDpiXPhys = viewer->physicalDpiX(); -// int qtDpiYPhys = viewer->physicalDpiY(); -// qtpxmm = ((qtDpiXPhys + qtDpiYPhys) / 2.0) / 25.4; -//#endif SbViewportRegion vpRegion = viewer->getSoRenderManager()->getViewportRegion(); SbVec2s winSizePx = vpRegion.getWindowSize(); //pixel coords diff --git a/src/Mod/TechDraw/Gui/MDIViewPage.cpp b/src/Mod/TechDraw/Gui/MDIViewPage.cpp index 34d56cfcce..f0645e50c4 100644 --- a/src/Mod/TechDraw/Gui/MDIViewPage.cpp +++ b/src/Mod/TechDraw/Gui/MDIViewPage.cpp @@ -117,13 +117,8 @@ TYPESYSTEM_SOURCE_ABSTRACT(TechDrawGui::MDIViewPage, Gui::MDIView) MDIViewPage::MDIViewPage(ViewProviderPage *pageVp, Gui::Document* doc, QWidget* parent) : Gui::MDIView(doc, parent), -#if QT_VERSION >= 0x050300 m_orientation(QPageLayout::Landscape), m_paperSize(QPageSize::A4), -#else - m_orientation(QPrinter::Landscape), - m_paperSize(QPrinter::A4), -#endif pagewidth(0.0), pageheight(0.0), m_vpPage(pageVp) @@ -316,23 +311,11 @@ void MDIViewPage::attachTemplate(TechDraw::DrawTemplate *obj) m_view->setPageTemplate(obj); pagewidth = obj->Width.getValue(); pageheight = obj->Height.getValue(); -#if QT_VERSION >= 0x050300 m_paperSize = QPageSize::id(QSizeF(pagewidth, pageheight), QPageSize::Millimeter, QPageSize::FuzzyOrientationMatch); -#else - m_paperSize = getPaperSize(int(round(pagewidth)), int(round(pageheight))); -#endif if (pagewidth > pageheight) { -#if QT_VERSION >= 0x050300 m_orientation = QPageLayout::Landscape; -#else - m_orientation = QPrinter::Landscape; -#endif } else { -#if QT_VERSION >= 0x050300 m_orientation = QPageLayout::Portrait; -#else - m_orientation = QPrinter::Portrait; -#endif } } @@ -673,29 +656,16 @@ void MDIViewPage::printPdf(std::string file) printer.setFullPage(true); printer.setOutputFileName(filename); -#if QT_VERSION >= 0x050300 if (m_paperSize == QPageSize::Ledger) { printer.setPageOrientation((QPageLayout::Orientation) (1 - m_orientation)); //reverse 0/1 -#else - if (m_paperSize == QPrinter::Ledger) { - printer.setOrientation((QPrinter::Orientation) (1 - m_orientation)); //reverse 0/1 -#endif } else { -#if QT_VERSION >= 0x050300 printer.setPageOrientation(m_orientation); -#else - printer.setOrientation(m_orientation); -#endif } -#if QT_VERSION >= 0x050300 if (m_paperSize == QPageSize::Custom) { printer.setPageSize(QPageSize(QSizeF(pagewidth, pageheight), QPageSize::Millimeter)); } else { printer.setPageSize(QPageSize(m_paperSize)); } -#else - printer.setPaperSize(m_paperSize); -#endif print(&printer); } @@ -703,17 +673,13 @@ void MDIViewPage::print() { QPrinter printer(QPrinter::HighResolution); printer.setFullPage(true); -#if QT_VERSION >= 0x050300 if (m_paperSize == QPageSize::Custom) { printer.setPageSize(QPageSize(QSizeF(pagewidth, pageheight), QPageSize::Millimeter)); } else { printer.setPageSize(QPageSize(m_paperSize)); } printer.setPageOrientation(m_orientation); -#else - printer.setPaperSize(m_paperSize); - printer.setOrientation(m_orientation); -#endif + QPrintDialog dlg(&printer, this); if (dlg.exec() == QDialog::Accepted) { print(&printer); @@ -724,17 +690,12 @@ void MDIViewPage::printPreview() { QPrinter printer(QPrinter::HighResolution); printer.setFullPage(true); -#if QT_VERSION >= 0x050300 if (m_paperSize == QPageSize::Custom) { printer.setPageSize(QPageSize(QSizeF(pagewidth, pageheight), QPageSize::Millimeter)); } else { printer.setPageSize(QPageSize(m_paperSize)); } printer.setPageOrientation(m_orientation); -#else - printer.setPaperSize(m_paperSize); - printer.setOrientation(m_orientation); -#endif QPrintPreviewDialog dlg(&printer, this); connect(&dlg, SIGNAL(paintRequested (QPrinter *)), @@ -758,21 +719,13 @@ void MDIViewPage::print(QPrinter* printer) // a certain scaling effect can be observed and the content becomes smaller. QPaintEngine::Type paintType = printer->paintEngine()->type(); if (printer->outputFormat() == QPrinter::NativeFormat) { -#if QT_VERSION >= 0x050300 QPageSize::PageSizeId psPrtSetting = printer->pageLayout().pageSize().id(); -#else - QPrinter::PaperSize psPrtSetting = printer->paperSize(); -#endif // for the preview a 'Picture' paint engine is used which we don't // care if it uses wrong printer settings bool doPrint = paintType != QPaintEngine::Picture; -#if QT_VERSION >= 0x050300 if (doPrint && printer->pageLayout().orientation() != m_orientation) { -#else - if (doPrint && printer->orientation() != m_orientation) { -#endif int ret = QMessageBox::warning(this, tr("Different orientation"), tr("The printer uses a different orientation than the drawing.\n" "Do you want to continue?"), @@ -799,20 +752,15 @@ void MDIViewPage::print(QPrinter* printer) return; } -#if QT_VERSION >= 0x050300 QRect targetRect = printer->pageLayout().fullRectPixels(printer->resolution()); -#else - QRect targetRect = printer->paperRect(); -#endif + #ifdef Q_OS_WIN32 // On Windows the preview looks broken when using paperRect as render area. // Although the picture is scaled when using pageRect, it looks just fine. if (paintType == QPaintEngine::Picture) -#if QT_VERSION >= 0x050300 + // FIXME: This is unused in this context, its scope is wrong. Drop the "QRect" from the next + // line and test it. -- CH 3/31/2021 QRect targetRect = printer->pageLayout().paintRectPixels(printer->resolution()); -#else - QRect targetRect = printer->pageRect(); -#endif #endif //bool block = @@ -846,66 +794,6 @@ void MDIViewPage::print(QPrinter* printer) static_cast (blockConnection(false)); } -#if QT_VERSION < 0x050300 -QPrinter::PaperSize MDIViewPage::getPaperSize(int w, int h) const -{ - static const float paperSizes[][2] = { - {210, 297}, // A4 - {176, 250}, // B5 - {215.9f, 279.4f}, // Letter - {215.9f, 355.6f}, // Legal - {190.5f, 254}, // Executive - {841, 1189}, // A0 - {594, 841}, // A1 - {420, 594}, // A2 - {297, 420}, // A3 - {148, 210}, // A5 - {105, 148}, // A6 - {74, 105}, // A7 - {52, 74}, // A8 - {37, 52}, // A8 - {1000, 1414}, // B0 - {707, 1000}, // B1 - {31, 44}, // B10 - {500, 707}, // B2 - {353, 500}, // B3 - {250, 353}, // B4 - {125, 176}, // B6 - {88, 125}, // B7 - {62, 88}, // B8 - {33, 62}, // B9 - {163, 229}, // C5E - {105, 241}, // US Common - {110, 220}, // DLE - {210, 330}, // Folio - {431.8f, 279.4f}, // Ledger (28) note, two names for same size paper (ANSI B) - {279.4f, 431.8f} // Tabloid (29) causes trouble with orientation on PDF export - }; - - QPrinter::PaperSize ps = QPrinter::Custom; - for (int i=0; i<30; i++) { - if (std::abs(paperSizes[i][0]-w) <= 1 && - std::abs(paperSizes[i][1]-h) <= 1) { - ps = static_cast(i); - break; - } - else //handle landscape & portrait w/h - if (std::abs(paperSizes[i][0]-h) <= 1 && - std::abs(paperSizes[i][1]-w) <= 1) { - ps = static_cast(i); - break; - } - } - if (ps == QPrinter::Ledger) { //check if really Tabloid - if (w < 431) { - ps = QPrinter::Tabloid; - } - } - - return ps; -} -#endif - PyObject* MDIViewPage::getPyObject() { return Gui::MDIView::getPyObject(); diff --git a/src/Mod/TechDraw/Gui/MDIViewPage.h b/src/Mod/TechDraw/Gui/MDIViewPage.h index 1cd011562d..d402a99d3e 100644 --- a/src/Mod/TechDraw/Gui/MDIViewPage.h +++ b/src/Mod/TechDraw/Gui/MDIViewPage.h @@ -128,9 +128,6 @@ protected: void contextMenuEvent(QContextMenuEvent *event); void closeEvent(QCloseEvent*); -#if QT_VERSION < 0x050300 - QPrinter::PaperSize getPaperSize(int w, int h) const; -#endif void setDimensionGroups(void); void setBalloonGroups(void); @@ -162,13 +159,8 @@ private: QTimer *m_timer; QString m_currentPath; -#if QT_VERSION >= 0x050300 QPageLayout::Orientation m_orientation; QPageSize::PageSizeId m_paperSize; -#else - QPrinter::Orientation m_orientation; - QPrinter::PaperSize m_paperSize; -#endif qreal pagewidth, pageheight; ViewProviderPage *m_vpPage; diff --git a/src/Mod/TechDraw/Gui/QGVPage.cpp b/src/Mod/TechDraw/Gui/QGVPage.cpp index 1c01329c10..fc43dd8961 100644 --- a/src/Mod/TechDraw/Gui/QGVPage.cpp +++ b/src/Mod/TechDraw/Gui/QGVPage.cpp @@ -1027,11 +1027,7 @@ void QGVPage::wheelEvent(QWheelEvent *event) } QPointF center = mapToScene(viewport()->rect().center()); -#if QT_VERSION >= QT_VERSION_CHECK(5,0,0) int delta = event->angleDelta().y(); -#else - int delta = event->delta(); -#endif qreal factor = std::pow(mouseBase, delta / mouseAdjust); scale(factor, factor); diff --git a/src/Mod/TechDraw/Gui/TaskRichAnno.cpp b/src/Mod/TechDraw/Gui/TaskRichAnno.cpp index af7f7718d4..3d3eef2dcd 100644 --- a/src/Mod/TechDraw/Gui/TaskRichAnno.cpp +++ b/src/Mod/TechDraw/Gui/TaskRichAnno.cpp @@ -239,9 +239,7 @@ void TaskRichAnno::setUiPrimary() ui->teAnnoText->setFontPointSize(mre.getDefFontSizeNum()); // set a placeholder text to inform the user // (QTextEdit has no placeholderText property in Qt4) -#if QT_VERSION >= 0x050200 ui->teAnnoText->setPlaceholderText(tr("Input the annotation text directly or start the rich text editor")); -#endif } void TaskRichAnno::enableTextUi(bool b) diff --git a/src/Mod/TechDraw/Gui/TemplateTextField.cpp b/src/Mod/TechDraw/Gui/TemplateTextField.cpp index a141935e2f..45964a66ad 100644 --- a/src/Mod/TechDraw/Gui/TemplateTextField.cpp +++ b/src/Mod/TechDraw/Gui/TemplateTextField.cpp @@ -69,11 +69,7 @@ void TemplateTextField::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) //WF: why is this escaped? // "<" is converted elsewhere and no other characters cause problems. // escaping causes "&" to appear as "&" etc -//#if QT_VERSION >= 0x050000 // QString qsClean = ui.getFieldContent().toHtmlEscaped(); -//#else -// QString qsClean = Qt::escape( ui.getFieldContent() ); -//#endif QString qsClean = ui.getFieldContent(); std::string utf8Content = qsClean.toUtf8().constData(); tmplte->EditableTexts.setValue(fieldNameStr, utf8Content); From 0177f9b9f8640efcf7762756ee3d5891244ee10f Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 2 Apr 2021 12:06:24 +0200 Subject: [PATCH 045/178] TD: [skip ci] fix DrawingView::print/MDIViewPage::print --- src/Mod/Drawing/Gui/DrawingView.cpp | 2 +- src/Mod/TechDraw/Gui/MDIViewPage.cpp | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Mod/Drawing/Gui/DrawingView.cpp b/src/Mod/Drawing/Gui/DrawingView.cpp index 394479dedb..bca5828799 100644 --- a/src/Mod/Drawing/Gui/DrawingView.cpp +++ b/src/Mod/Drawing/Gui/DrawingView.cpp @@ -614,7 +614,7 @@ void DrawingView::print(QPrinter* printer) // On Windows the preview looks broken when using paperRect as render area. // Although the picture is scaled when using pageRect, it looks just fine. if (paintType == QPaintEngine::Picture) - QRect rect = printer->pageLayout().paintRectPixels(printer->resolution()); + rect = printer->pageLayout().paintRectPixels(printer->resolution()); #endif this->m_view->scene()->render(&p, rect); p.end(); diff --git a/src/Mod/TechDraw/Gui/MDIViewPage.cpp b/src/Mod/TechDraw/Gui/MDIViewPage.cpp index f0645e50c4..7bccf1bae6 100644 --- a/src/Mod/TechDraw/Gui/MDIViewPage.cpp +++ b/src/Mod/TechDraw/Gui/MDIViewPage.cpp @@ -758,9 +758,7 @@ void MDIViewPage::print(QPrinter* printer) // On Windows the preview looks broken when using paperRect as render area. // Although the picture is scaled when using pageRect, it looks just fine. if (paintType == QPaintEngine::Picture) - // FIXME: This is unused in this context, its scope is wrong. Drop the "QRect" from the next - // line and test it. -- CH 3/31/2021 - QRect targetRect = printer->pageLayout().paintRectPixels(printer->resolution()); + targetRect = printer->pageLayout().paintRectPixels(printer->resolution()); #endif //bool block = From 8e6c5946cdd63887108507fc32c6b18bb74d38c6 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Wed, 31 Mar 2021 13:07:06 -0500 Subject: [PATCH 046/178] [Web] Remove deprecated Qt < 5.9 code --- src/Mod/Web/App/Server.cpp | 4 --- src/Mod/Web/App/Server.h | 4 --- src/Mod/Web/Gui/BrowserView.cpp | 51 +++++++++------------------------ src/Mod/Web/Gui/BrowserView.h | 4 +-- 4 files changed, 16 insertions(+), 47 deletions(-) diff --git a/src/Mod/Web/App/Server.cpp b/src/Mod/Web/App/Server.cpp index 01624a8b6c..84b0fa11d6 100644 --- a/src/Mod/Web/App/Server.cpp +++ b/src/Mod/Web/App/Server.cpp @@ -114,11 +114,7 @@ AppServer::AppServer(QObject* parent) { } -#if QT_VERSION >=0x050000 void AppServer::incomingConnection(qintptr socket) -#else -void AppServer::incomingConnection(int socket) -#endif { QTcpSocket* s = new QTcpSocket(this); connect(s, SIGNAL(readyRead()), this, SLOT(readClient())); diff --git a/src/Mod/Web/App/Server.h b/src/Mod/Web/App/Server.h index 674d402279..e03002051c 100644 --- a/src/Mod/Web/App/Server.h +++ b/src/Mod/Web/App/Server.h @@ -85,11 +85,7 @@ public: AppServer(QObject* parent = 0); static std::string runPython(const QByteArray&); -#if QT_VERSION >=0x050000 void incomingConnection(qintptr socket); -#else - void incomingConnection(int socket); -#endif protected: void customEvent(QEvent* e); diff --git a/src/Mod/Web/Gui/BrowserView.cpp b/src/Mod/Web/Gui/BrowserView.cpp index 775a83afd9..244285e99a 100644 --- a/src/Mod/Web/Gui/BrowserView.cpp +++ b/src/Mod/Web/Gui/BrowserView.cpp @@ -52,7 +52,7 @@ #endif -#if QT_VERSION >= 0x050700 && defined(QTWEBENGINE) +#if defined(QTWEBENGINE) # include # include # include @@ -60,20 +60,16 @@ # include # include # include -# define QWEBVIEW QWebEngineView -# define QWEBPAGE QWebEnginePage -#elif QT_VERSION >= 0x040400 && defined(QTWEBKIT) +#elif defined(QTWEBKIT) # include # include # include # include -# define QWEBVIEW QWebView -# define QWEBPAGE QWebPage +using QWebEngineView = QWebView; +using QWebEnginePage = QWebPage; #endif -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) -# include -#endif +#include #include #include @@ -237,14 +233,10 @@ Py::Object BrowserViewPy::setHtml(const Py::Tuple& args) */ WebView::WebView(QWidget *parent) - : QWEBVIEW(parent) + : QWebEngineView(parent) { // Increase html font size for high DPI displays -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) QRect mainScreenSize = QApplication::primaryScreen()->geometry(); -#else - QRect mainScreenSize = QApplication::desktop()->screenGeometry(); -#endif if (mainScreenSize.width() > 1920){ setTextSizeMultiplier (mainScreenSize.width()/1920.0); } @@ -270,23 +262,19 @@ void WebView::mousePressEvent(QMouseEvent *event) return; } } - QWEBVIEW::mousePressEvent(event); + QWebEngineView::mousePressEvent(event); } #endif void WebView::wheelEvent(QWheelEvent *event) { if (QApplication::keyboardModifiers() & Qt::ControlModifier) { -#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) qreal factor = zoomFactor() + (-event->angleDelta().y() / 800.0); -#else - qreal factor = zoomFactor() + (-event->delta() / 800.0); -#endif setZoomFactor(factor); event->accept(); return; } - QWEBVIEW::wheelEvent(event); + QWebEngineView::wheelEvent(event); } void WebView::contextMenuEvent(QContextMenuEvent *event) @@ -313,12 +301,12 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) connect (newAction, SIGNAL(triggered()), signalMapper, SLOT(map())); signalMapper->setMapping(newAction, WebAction::OpenLinkInNewWindow); - menu.addAction(pageAction(QWEBPAGE::DownloadLinkToDisk)); - menu.addAction(pageAction(QWEBPAGE::CopyLinkToClipboard)); + menu.addAction(pageAction(QWebEnginePage::DownloadLinkToDisk)); + menu.addAction(pageAction(QWebEnginePage::CopyLinkToClipboard)); menu.exec(mapToGlobal(event->pos())); return; } -#if QT_VERSION >= 0x050800 && defined(QTWEBENGINE) +#if defined(QTWEBENGINE) else { // for view source // QWebEngine caches standardContextMenu, guard so we only add signalmapper once static bool firstRun = true; @@ -352,7 +340,7 @@ void WebView::contextMenuEvent(QContextMenuEvent *event) menu->exec(event->globalPos()); } #endif - QWEBVIEW::contextMenuEvent(event); + QWebEngineView::contextMenuEvent(event); } void WebView::triggerContextMenuAction(int id) @@ -445,10 +433,7 @@ BrowserView::BrowserView(QWidget* parent) #endif view->settings()->setAttribute(QWebEngineSettings::AutoLoadIconsForPage, true); - -#if QT_VERSION >= 0x050800 view->settings()->setAttribute(QWebEngineSettings::FocusOnNavigationEnabled,false); -#endif connect(view->page()->profile(), SIGNAL(downloadRequested(QWebEngineDownloadItem*)), this, SLOT(onDownloadRequested(QWebEngineDownloadItem*))); @@ -498,11 +483,7 @@ void BrowserView::onLinkClicked (const QUrl & url) // query QString q; if (url.hasQuery()) -#if QT_VERSION >= 0x050000 q = url.query(); -#else - q = QString::fromAscii(url.encodedQuery().data()); -#endif //QString fragment = url. fragment(); @@ -541,11 +522,7 @@ void BrowserView::onLinkClicked (const QUrl & url) } // Gui::Command::doCommand(Gui::Command::Gui,"execfile('%s')",(const char*) fi.absoluteFilePath(). toLocal8Bit()); QString filename = Base::Tools::escapeEncodeFilename(fi.absoluteFilePath()); -#if PY_MAJOR_VERSION < 3 - Gui::Command::doCommand(Gui::Command::Gui,"exec(open(unicode('%s', 'utf-8')).read())",(const char*) filename.toUtf8()); -#else Gui::Command::doCommand(Gui::Command::Gui,"with open('%s') as file:\n\texec(file.read())",(const char*) filename.toUtf8()); -#endif } catch (const Base::Exception& e) { QMessageBox::critical(this, tr("Error"), QString::fromUtf8(e.what())); @@ -801,9 +778,9 @@ bool BrowserView::onMsg(const char* pMsg,const char** ) bool BrowserView::onHasMsg(const char* pMsg) const { if (strcmp(pMsg,"Back")==0) - return view->page()->action(QWEBPAGE::Back)->isEnabled(); + return view->page()->action(QWebEnginePage::Back)->isEnabled(); if (strcmp(pMsg,"Next")==0) - return view->page()->action(QWEBPAGE::Forward)->isEnabled(); + return view->page()->action(QWebEnginePage::Forward)->isEnabled(); if (strcmp(pMsg,"Refresh")==0) return !isLoading; if (strcmp(pMsg,"Stop")==0) return isLoading; if (strcmp(pMsg,"ZoomIn")==0) return true; diff --git a/src/Mod/Web/Gui/BrowserView.h b/src/Mod/Web/Gui/BrowserView.h index d869ece741..55991e5d54 100644 --- a/src/Mod/Web/Gui/BrowserView.h +++ b/src/Mod/Web/Gui/BrowserView.h @@ -29,12 +29,12 @@ #include #include -#if QT_VERSION >= 0x050700 && defined(QTWEBENGINE) +#if defined(QTWEBENGINE) #include namespace WebGui { class WebEngineUrlRequestInterceptor; }; -#elif QT_VERSION >= 0x040400 && defined(QTWEBKIT) +#elif defined(QTWEBKIT) #include #endif From 8de66e134f5ea6082e502828778affa8e94dc701 Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 2 Apr 2021 14:10:02 +0200 Subject: [PATCH 047/178] Web: remove obsolete function setTextSizeMultiplier because QtWebEngine already supports HiDPI monitors --- src/Mod/Web/Gui/BrowserView.cpp | 26 +++++++------------------- src/Mod/Web/Gui/BrowserView.h | 9 +-------- 2 files changed, 8 insertions(+), 27 deletions(-) diff --git a/src/Mod/Web/Gui/BrowserView.cpp b/src/Mod/Web/Gui/BrowserView.cpp index 244285e99a..ae3e964039 100644 --- a/src/Mod/Web/Gui/BrowserView.cpp +++ b/src/Mod/Web/Gui/BrowserView.cpp @@ -235,26 +235,18 @@ Py::Object BrowserViewPy::setHtml(const Py::Tuple& args) WebView::WebView(QWidget *parent) : QWebEngineView(parent) { +#ifdef QTWEBKIT // Increase html font size for high DPI displays QRect mainScreenSize = QApplication::primaryScreen()->geometry(); if (mainScreenSize.width() > 1920){ setTextSizeMultiplier (mainScreenSize.width()/1920.0); } +#endif } -#ifdef QTWEBENGINE -// implement a custom method using font minimum size -void WebView::setTextSizeMultiplier(qreal factor) -{ - QWebEngineSettings *sett = settings(); - int fontSize = sett->fontSize(QWebEngineSettings::MinimumFontSize); - fontSize = static_cast(fontSize * factor); - sett->setFontSize(QWebEngineSettings::MinimumFontSize, fontSize); -} -#else // QTWEBKIT - void WebView::mousePressEvent(QMouseEvent *event) { +#ifdef QTWEBKIT if (event->button() == Qt::MidButton) { QWebHitTestResult r = page()->mainFrame()->hitTestContent(event->pos()); if (!r.linkUrl().isEmpty()) { @@ -262,9 +254,9 @@ void WebView::mousePressEvent(QMouseEvent *event) return; } } +#endif QWebEngineView::mousePressEvent(event); } -#endif void WebView::wheelEvent(QWheelEvent *event) { @@ -410,7 +402,7 @@ BrowserView::BrowserView(QWidget* parent) connect(view->page(), SIGNAL(linkHovered(const QString &, const QString &, const QString &)), this, SLOT(onLinkHovered(const QString &, const QString &, const QString &))); connect(view, SIGNAL(linkClicked(const QUrl &)), - this, SLOT(onLinkClicked(const QUrl &))); + this, SLOT(urlFilter(const QUrl &))); connect(view->page(), SIGNAL(downloadRequested(const QNetworkRequest &)), this, SLOT(onDownloadRequested(const QNetworkRequest &))); connect(view->page(), SIGNAL(unsupportedContent(QNetworkReply*)), @@ -465,11 +457,7 @@ BrowserView::~BrowserView() delete view; } -#ifdef QTWEBENGINE -void BrowserView::urlFilter(const QUrl &url) -#else -void BrowserView::onLinkClicked (const QUrl & url) -#endif +void BrowserView::urlFilter(const QUrl & url) { QString scheme = url.scheme(); QString host = url.host(); @@ -604,7 +592,7 @@ void BrowserView::onUnsupportedContent(QNetworkReply* reply) // Do not call handleUnsupportedContent() directly otherwise we won't get // the metaDataChanged() signal of the reply. Gui::Dialog::DownloadManager::getInstance()->download(reply->url()); - // Due to setting the policy QWebPage::DelegateAllLinks the onLinkClicked() + // Due to setting the policy QWebPage::DelegateAllLinks the urlFilter() // slot is called even when clicking on a downloadable file but the page // then fails to load. Thus, we reload the previous url. view->reload(); diff --git a/src/Mod/Web/Gui/BrowserView.h b/src/Mod/Web/Gui/BrowserView.h index 55991e5d54..67efacdceb 100644 --- a/src/Mod/Web/Gui/BrowserView.h +++ b/src/Mod/Web/Gui/BrowserView.h @@ -55,15 +55,9 @@ class WebGuiExport WebView : public QWebView public: WebView(QWidget *parent = 0); -#ifdef QTWEBENGINE - // reimplement setTextSizeMultiplier - void setTextSizeMultiplier(qreal factor); -#endif protected: -#ifdef QTWEBKIT void mousePressEvent(QMouseEvent *event); -#endif void wheelEvent(QWheelEvent *event); void contextMenuEvent(QContextMenuEvent *event); @@ -110,15 +104,14 @@ protected Q_SLOTS: void onLoadProgress(int); void onLoadFinished(bool); bool chckHostAllowed(const QString& host); + void urlFilter(const QUrl &url); #ifdef QTWEBENGINE void onDownloadRequested(QWebEngineDownloadItem *request); void setWindowIcon(const QIcon &icon); - void urlFilter(const QUrl &url); void onLinkHovered(const QString& url); #else void onDownloadRequested(const QNetworkRequest& request); void onUnsupportedContent(QNetworkReply* reply); - void onLinkClicked (const QUrl& url); void onLinkHovered(const QString& link, const QString& title, const QString& textContent); #endif void onViewSource(const QUrl &url); From b34acb8b3142619089ec7ccc4f2c370c02c021f2 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Wed, 3 Feb 2021 16:12:05 -0600 Subject: [PATCH 048/178] Add tooltip to f(x) when there is no expression As suggested by @luzpaz, this adds a tooltip to the f(x) icon of all of the widgets that use it: QuantitySpinBox, UIntSpinBox, IntSpinBox, DoubleSpinBox, and ExpLineEdit. These five classes are divided across three files, and all five classes duplicate the same basic code. In the existing code, no tooltip is shown if there is no expression. If there is an expression, it (alone) is used as the tooltip. This commit modifies that behavior to have explanatory text as the tooltip when there is no expression, and when there is, to prepend a short string to the beginning. To reduce further code duplication, this is implemented by adding a new function to ExpressionLabel allowing the text of the expression to be set. It checks that text and if it's empty, uses a preset default string as the tooltip. If there is expression text, it instead prepends another bit of text to the front and sets the entire expression+prefix as the tooltip. TODO: In the future a lot of the preexisting code duplication could be removed by making the ExpressionLabel class do more internal management of the expression. Thanks to @kisolre for the assistance tracking these down, and suggesting the default text used. --- src/Gui/QuantitySpinBox.cpp | 9 +++++---- src/Gui/QuantitySpinBox_p.h | 13 +++++++++++++ src/Gui/SpinBox.cpp | 27 +++++++++++++++------------ src/Gui/Widgets.cpp | 9 +++++---- 4 files changed, 38 insertions(+), 20 deletions(-) diff --git a/src/Gui/QuantitySpinBox.cpp b/src/Gui/QuantitySpinBox.cpp index 2606919ee3..4b8e65f4b3 100644 --- a/src/Gui/QuantitySpinBox.cpp +++ b/src/Gui/QuantitySpinBox.cpp @@ -312,6 +312,7 @@ QuantitySpinBox::QuantitySpinBox(QWidget *parent) iconLabel->setPixmap(pixmap); iconLabel->setStyleSheet(QString::fromLatin1("QLabel { border: none; padding: 0px; padding-top: %2px; width: %1px; height: %1px }").arg(iconHeight).arg(frameWidth/2)); iconLabel->hide(); + static_cast(iconLabel)->setExpressionText(QString()); lineEdit()->setStyleSheet(QString::fromLatin1("QLineEdit { padding-right: %1px } ").arg(iconHeight+frameWidth)); // When a style sheet is set the text margins for top/bottom must be set to avoid to squash the widget #ifndef Q_OS_MAC @@ -447,7 +448,7 @@ void Gui::QuantitySpinBox::onChange() p.setColor(QPalette::Text, Qt::lightGray); lineEdit()->setPalette(p); } - iconLabel->setToolTip(Base::Tools::fromStdString(getExpression()->toString())); + static_cast(iconLabel)->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); } else { setReadOnly(false); @@ -456,7 +457,7 @@ void Gui::QuantitySpinBox::onChange() QPalette p(lineEdit()->palette()); p.setColor(QPalette::Active, QPalette::Text, defaultPalette.color(QPalette::Text)); lineEdit()->setPalette(p); - iconLabel->setToolTip(QString()); + static_cast(iconLabel)->setExpressionText(QString()); } } @@ -511,7 +512,7 @@ void QuantitySpinBox::resizeEvent(QResizeEvent * event) p.setColor(QPalette::Text, Qt::lightGray); lineEdit()->setPalette(p); } - iconLabel->setToolTip(Base::Tools::fromStdString(getExpression()->toString())); + static_cast(iconLabel)->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); } else { setReadOnly(false); @@ -521,7 +522,7 @@ void QuantitySpinBox::resizeEvent(QResizeEvent * event) QPalette p(lineEdit()->palette()); p.setColor(QPalette::Active, QPalette::Text, defaultPalette.color(QPalette::Text)); lineEdit()->setPalette(p); - iconLabel->setToolTip(QString()); + static_cast(iconLabel)->setExpressionText(QString()); } } catch (const Base::Exception & e) { diff --git a/src/Gui/QuantitySpinBox_p.h b/src/Gui/QuantitySpinBox_p.h index 147d080124..e42c82348b 100644 --- a/src/Gui/QuantitySpinBox_p.h +++ b/src/Gui/QuantitySpinBox_p.h @@ -30,6 +30,14 @@ class ExpressionLabel : public QLabel Q_OBJECT public: ExpressionLabel(QWidget * parent) : QLabel(parent) { } + + void setExpressionText(const QString& text) { + if (text.isEmpty()) + this->setToolTip(genericFormulaEditorTooltip); + else + this->setToolTip(formulaEditorTooltipPrefix + text); + } + protected: void mouseReleaseEvent(QMouseEvent * event) { if (rect().contains(event->pos())) @@ -38,6 +46,11 @@ protected: Q_SIGNALS: void clicked(); + +private: + + const QString genericFormulaEditorTooltip = tr("Enter an expression..."); + const QString formulaEditorTooltipPrefix = tr("Expression: "); }; #endif // QUANTITYSPINBOX_P_H diff --git a/src/Gui/SpinBox.cpp b/src/Gui/SpinBox.cpp index 476b7c0192..e5ab44e6df 100644 --- a/src/Gui/SpinBox.cpp +++ b/src/Gui/SpinBox.cpp @@ -163,6 +163,7 @@ UIntSpinBox::UIntSpinBox (QWidget* parent) iconLabel->setPixmap(pixmap); iconLabel->setStyleSheet(QString::fromLatin1("QLabel { border: none; padding: 0px; padding-top: %2px; width: %1px; height: %1px }").arg(iconHeight).arg(frameWidth/2)); iconLabel->hide(); + static_cast(iconLabel)->setExpressionText(QString()); lineEdit()->setStyleSheet(QString::fromLatin1("QLineEdit { padding-right: %1px } ").arg(iconHeight+frameWidth)); QObject::connect(iconLabel, SIGNAL(clicked()), this, SLOT(openFormulaDialog())); @@ -295,7 +296,7 @@ void UIntSpinBox::onChange() { p.setColor(QPalette::Text, Qt::lightGray); lineEdit()->setPalette(p); } - iconLabel->setToolTip(Base::Tools::fromStdString(getExpression()->toString())); + static_cast(iconLabel)->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); } else { setReadOnly(false); @@ -303,7 +304,7 @@ void UIntSpinBox::onChange() { QPalette p(lineEdit()->palette()); p.setColor(QPalette::Active, QPalette::Text, defaultPalette.color(QPalette::Text)); lineEdit()->setPalette(p); - iconLabel->setToolTip(QString()); + static_cast(iconLabel)->setExpressionText(QString()); } } @@ -346,7 +347,7 @@ void UIntSpinBox::resizeEvent(QResizeEvent * event) p.setColor(QPalette::Text, Qt::lightGray); lineEdit()->setPalette(p); } - iconLabel->setToolTip(Base::Tools::fromStdString(getExpression()->toString())); + static_cast(iconLabel)->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); } else { setReadOnly(false); @@ -356,7 +357,7 @@ void UIntSpinBox::resizeEvent(QResizeEvent * event) QPalette p(lineEdit()->palette()); p.setColor(QPalette::Active, QPalette::Text, defaultPalette.color(QPalette::Text)); lineEdit()->setPalette(p); - iconLabel->setToolTip(QString()); + static_cast(iconLabel)->setExpressionText(QString()); } } catch (const Base::Exception & e) { @@ -443,6 +444,7 @@ IntSpinBox::IntSpinBox(QWidget* parent) : QSpinBox(parent) { iconLabel->setPixmap(pixmap); iconLabel->setStyleSheet(QString::fromLatin1("QLabel { border: none; padding: 0px; padding-top: %2px; width: %1px; height: %1px }").arg(iconHeight).arg(frameWidth/2)); iconLabel->hide(); + static_cast(iconLabel)->setExpressionText(QString()); lineEdit()->setStyleSheet(QString::fromLatin1("QLineEdit { padding-right: %1px } ").arg(iconHeight+frameWidth)); QObject::connect(iconLabel, SIGNAL(clicked()), this, SLOT(openFormulaDialog())); @@ -504,7 +506,7 @@ void IntSpinBox::onChange() { p.setColor(QPalette::Text, Qt::lightGray); lineEdit()->setPalette(p); } - iconLabel->setToolTip(Base::Tools::fromStdString(getExpression()->toString())); + static_cast(iconLabel)->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); } else { setReadOnly(false); @@ -512,7 +514,7 @@ void IntSpinBox::onChange() { QPalette p(lineEdit()->palette()); p.setColor(QPalette::Active, QPalette::Text, defaultPalette.color(QPalette::Text)); lineEdit()->setPalette(p); - iconLabel->setToolTip(QString()); + static_cast(iconLabel)->setExpressionText(QString()); } } @@ -539,7 +541,7 @@ void IntSpinBox::resizeEvent(QResizeEvent * event) p.setColor(QPalette::Text, Qt::lightGray); lineEdit()->setPalette(p); } - iconLabel->setToolTip(Base::Tools::fromStdString(getExpression()->toString())); + static_cast(iconLabel)->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); } else { setReadOnly(false); @@ -549,7 +551,7 @@ void IntSpinBox::resizeEvent(QResizeEvent * event) QPalette p(lineEdit()->palette()); p.setColor(QPalette::Active, QPalette::Text, defaultPalette.color(QPalette::Text)); lineEdit()->setPalette(p); - iconLabel->setToolTip(QString()); + static_cast(iconLabel)->setExpressionText(QString()); } } catch (const Base::Exception & e) { @@ -636,6 +638,7 @@ DoubleSpinBox::DoubleSpinBox(QWidget* parent): QDoubleSpinBox(parent) { iconLabel->setPixmap(pixmap); iconLabel->setStyleSheet(QString::fromLatin1("QLabel { border: none; padding: 0px; padding-top: %2px; width: %1px; height: %1px }").arg(iconHeight).arg(frameWidth/2)); iconLabel->hide(); + static_cast(iconLabel)->setExpressionText(QString()); lineEdit()->setStyleSheet(QString::fromLatin1("QLineEdit { padding-right: %1px } ").arg(iconHeight+frameWidth)); QObject::connect(iconLabel, SIGNAL(clicked()), this, SLOT(openFormulaDialog())); @@ -697,7 +700,7 @@ void DoubleSpinBox::onChange() { p.setColor(QPalette::Text, Qt::lightGray); lineEdit()->setPalette(p); } - iconLabel->setToolTip(Base::Tools::fromStdString(getExpression()->toString())); + static_cast(iconLabel)->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); } else { setReadOnly(false); @@ -705,7 +708,7 @@ void DoubleSpinBox::onChange() { QPalette p(lineEdit()->palette()); p.setColor(QPalette::Active, QPalette::Text, defaultPalette.color(QPalette::Text)); lineEdit()->setPalette(p); - iconLabel->setToolTip(QString()); + static_cast(iconLabel)->setExpressionText(QString()); } } @@ -732,7 +735,7 @@ void DoubleSpinBox::resizeEvent(QResizeEvent * event) p.setColor(QPalette::Text, Qt::lightGray); lineEdit()->setPalette(p); } - iconLabel->setToolTip(Base::Tools::fromStdString(getExpression()->toString())); + static_cast(iconLabel)->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); } else { setReadOnly(false); @@ -742,7 +745,7 @@ void DoubleSpinBox::resizeEvent(QResizeEvent * event) QPalette p(lineEdit()->palette()); p.setColor(QPalette::Active, QPalette::Text, defaultPalette.color(QPalette::Text)); lineEdit()->setPalette(p); - iconLabel->setToolTip(QString()); + static_cast(iconLabel)->setExpressionText(QString()); } } catch (const Base::Exception & e) { diff --git a/src/Gui/Widgets.cpp b/src/Gui/Widgets.cpp index 930d709280..366cfcdbd0 100644 --- a/src/Gui/Widgets.cpp +++ b/src/Gui/Widgets.cpp @@ -1366,6 +1366,7 @@ ExpLineEdit::ExpLineEdit(QWidget* parent, bool expressionOnly) iconLabel->setPixmap(pixmap); iconLabel->setStyleSheet(QString::fromLatin1("QLabel { border: none; padding: 0px; padding-top: %2px; width: %1px; height: %1px }").arg(iconHeight).arg(frameWidth/2)); iconLabel->hide(); + static_cast(iconLabel)->setExpressionText(QString()); setStyleSheet(QString::fromLatin1("QLineEdit { padding-right: %1px } ").arg(iconHeight+frameWidth)); QObject::connect(iconLabel, SIGNAL(clicked()), this, SLOT(openFormulaDialog())); @@ -1427,7 +1428,7 @@ void ExpLineEdit::onChange() { QPalette p(palette()); p.setColor(QPalette::Text, Qt::lightGray); setPalette(p); - iconLabel->setToolTip(Base::Tools::fromStdString(getExpression()->toString())); + static_cast(iconLabel)->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); } else { setReadOnly(false); @@ -1435,7 +1436,7 @@ void ExpLineEdit::onChange() { QPalette p(palette()); p.setColor(QPalette::Active, QPalette::Text, defaultPalette.color(QPalette::Text)); setPalette(p); - iconLabel->setToolTip(QString()); + static_cast(iconLabel)->setExpressionText(QString()); } } @@ -1457,7 +1458,7 @@ void ExpLineEdit::resizeEvent(QResizeEvent * event) QPalette p(palette()); p.setColor(QPalette::Text, Qt::lightGray); setPalette(p); - iconLabel->setToolTip(Base::Tools::fromStdString(getExpression()->toString())); + static_cast(iconLabel)->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); } else { setReadOnly(false); @@ -1467,7 +1468,7 @@ void ExpLineEdit::resizeEvent(QResizeEvent * event) QPalette p(palette()); p.setColor(QPalette::Active, QPalette::Text, defaultPalette.color(QPalette::Text)); setPalette(p); - iconLabel->setToolTip(QString()); + static_cast(iconLabel)->setExpressionText(QString()); } } catch (const Base::Exception & e) { From f5063af183f1d3d584c950fea2fb36a2e4386dec Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 2 Apr 2021 17:46:42 +0200 Subject: [PATCH 049/178] Gui: Change label type to ExpressionLabel in ExpressionBinding * Add function ExpressionBinding::makeLabel() and use it in subclasses to reduce code duplication --- src/Gui/ExpressionBinding.cpp | 21 ++++++++++ src/Gui/ExpressionBinding.h | 7 +++- src/Gui/InputField.cpp | 3 +- src/Gui/QuantitySpinBox.cpp | 22 +++------- src/Gui/QuantitySpinBox_p.h | 1 + src/Gui/SpinBox.cpp | 79 +++++++++-------------------------- src/Gui/Widgets.cpp | 29 ++++--------- 7 files changed, 62 insertions(+), 100 deletions(-) diff --git a/src/Gui/ExpressionBinding.cpp b/src/Gui/ExpressionBinding.cpp index 4ce14296e0..7c6cb24652 100644 --- a/src/Gui/ExpressionBinding.cpp +++ b/src/Gui/ExpressionBinding.cpp @@ -22,9 +22,12 @@ #include "PreCompiled.h" #ifndef _PreComp_ +# include # include +# include #endif #include "ExpressionBinding.h" +#include "QuantitySpinBox_p.h" #include "BitmapFactory.h" #include "Command.h" #include @@ -266,3 +269,21 @@ void ExpressionBinding::objectDeleted(const App::DocumentObject& obj) unbind(); } } + +void ExpressionBinding::makeLabel(QLineEdit* le) +{ + defaultPalette = le->palette(); + + /* Icon for f(x) */ + QFontMetrics fm(le->font()); + int frameWidth = le->style()->pixelMetric(QStyle::PM_SpinBoxFrameWidth); + iconHeight = fm.height() - frameWidth; + iconLabel = new ExpressionLabel(le); + iconLabel->setCursor(Qt::ArrowCursor); + QPixmap pixmap = getIcon(":/icons/bound-expression-unset.svg", QSize(iconHeight, iconHeight)); + iconLabel->setPixmap(pixmap); + iconLabel->setStyleSheet(QString::fromLatin1("QLabel { border: none; padding: 0px; padding-top: %2px; width: %1px; height: %1px }").arg(iconHeight).arg(frameWidth/2)); + iconLabel->hide(); + iconLabel->setExpressionText(QString()); + le->setStyleSheet(QString::fromLatin1("QLineEdit { padding-right: %1px } ").arg(iconHeight+frameWidth)); +} diff --git a/src/Gui/ExpressionBinding.h b/src/Gui/ExpressionBinding.h index cf57de31d9..a831abe58a 100644 --- a/src/Gui/ExpressionBinding.h +++ b/src/Gui/ExpressionBinding.h @@ -33,6 +33,9 @@ namespace App { class Expression; } +class ExpressionLabel; +class QLineEdit; + namespace Gui { class GuiExport ExpressionBinding @@ -66,12 +69,14 @@ protected: //gets called when the bound expression is changed, either by this binding or any external action virtual void onChange() {} + void makeLabel(QLineEdit* parent); + private: App::ObjectIdentifier path; std::shared_ptr lastExpression; protected: - QLabel* iconLabel; + ExpressionLabel* iconLabel; QPalette defaultPalette; int iconHeight; diff --git a/src/Gui/InputField.cpp b/src/Gui/InputField.cpp index a871682183..70922f05b6 100644 --- a/src/Gui/InputField.cpp +++ b/src/Gui/InputField.cpp @@ -40,6 +40,7 @@ #include "Command.h" #include "InputField.h" #include "BitmapFactory.h" +#include "QuantitySpinBox_p.h" #include "propertyeditor/PropertyItem.h" using namespace Gui; @@ -78,7 +79,7 @@ InputField::InputField(QWidget * parent) { setValidator(new InputValidator(this)); setFocusPolicy(Qt::WheelFocus); - iconLabel = new QLabel(this); + iconLabel = new ExpressionLabel(this); iconLabel->setCursor(Qt::ArrowCursor); QPixmap pixmap = getValidationIcon(":/icons/button_valid.svg", QSize(sizeHint().height(),sizeHint().height())); iconLabel->setPixmap(pixmap); diff --git a/src/Gui/QuantitySpinBox.cpp b/src/Gui/QuantitySpinBox.cpp index 4b8e65f4b3..52e3eb69ba 100644 --- a/src/Gui/QuantitySpinBox.cpp +++ b/src/Gui/QuantitySpinBox.cpp @@ -300,20 +300,8 @@ QuantitySpinBox::QuantitySpinBox(QWidget *parent) QObject::connect(this, SIGNAL(editingFinished()), this, SLOT(handlePendingEmit())); - defaultPalette = lineEdit()->palette(); + makeLabel(lineEdit()); - /* Icon for f(x) */ - QFontMetrics fm(lineEdit()->font()); - int frameWidth = style()->pixelMetric(QStyle::PM_SpinBoxFrameWidth); - iconHeight = fm.height() - frameWidth; - iconLabel = new ExpressionLabel(lineEdit()); - iconLabel->setCursor(Qt::ArrowCursor); - QPixmap pixmap = getIcon(":/icons/bound-expression-unset.svg", QSize(iconHeight, iconHeight)); - iconLabel->setPixmap(pixmap); - iconLabel->setStyleSheet(QString::fromLatin1("QLabel { border: none; padding: 0px; padding-top: %2px; width: %1px; height: %1px }").arg(iconHeight).arg(frameWidth/2)); - iconLabel->hide(); - static_cast(iconLabel)->setExpressionText(QString()); - lineEdit()->setStyleSheet(QString::fromLatin1("QLineEdit { padding-right: %1px } ").arg(iconHeight+frameWidth)); // When a style sheet is set the text margins for top/bottom must be set to avoid to squash the widget #ifndef Q_OS_MAC lineEdit()->setTextMargins(0, 2, 0, 2); @@ -448,7 +436,7 @@ void Gui::QuantitySpinBox::onChange() p.setColor(QPalette::Text, Qt::lightGray); lineEdit()->setPalette(p); } - static_cast(iconLabel)->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); + iconLabel->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); } else { setReadOnly(false); @@ -457,7 +445,7 @@ void Gui::QuantitySpinBox::onChange() QPalette p(lineEdit()->palette()); p.setColor(QPalette::Active, QPalette::Text, defaultPalette.color(QPalette::Text)); lineEdit()->setPalette(p); - static_cast(iconLabel)->setExpressionText(QString()); + iconLabel->setExpressionText(QString()); } } @@ -512,7 +500,7 @@ void QuantitySpinBox::resizeEvent(QResizeEvent * event) p.setColor(QPalette::Text, Qt::lightGray); lineEdit()->setPalette(p); } - static_cast(iconLabel)->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); + iconLabel->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); } else { setReadOnly(false); @@ -522,7 +510,7 @@ void QuantitySpinBox::resizeEvent(QResizeEvent * event) QPalette p(lineEdit()->palette()); p.setColor(QPalette::Active, QPalette::Text, defaultPalette.color(QPalette::Text)); lineEdit()->setPalette(p); - static_cast(iconLabel)->setExpressionText(QString()); + iconLabel->setExpressionText(QString()); } } catch (const Base::Exception & e) { diff --git a/src/Gui/QuantitySpinBox_p.h b/src/Gui/QuantitySpinBox_p.h index e42c82348b..3b1c7aa5e8 100644 --- a/src/Gui/QuantitySpinBox_p.h +++ b/src/Gui/QuantitySpinBox_p.h @@ -24,6 +24,7 @@ #define QUANTITYSPINBOX_P_H #include +#include class ExpressionLabel : public QLabel { diff --git a/src/Gui/SpinBox.cpp b/src/Gui/SpinBox.cpp index e5ab44e6df..44c38818a5 100644 --- a/src/Gui/SpinBox.cpp +++ b/src/Gui/SpinBox.cpp @@ -151,20 +151,7 @@ UIntSpinBox::UIntSpinBox (QWidget* parent) setValue(0); updateValidator(); - defaultPalette = lineEdit()->palette(); - - /* Icon for f(x) */ - QFontMetrics fm(lineEdit()->font()); - int frameWidth = style()->pixelMetric(QStyle::PM_SpinBoxFrameWidth); - iconHeight = fm.height() - frameWidth; - iconLabel = new ExpressionLabel(lineEdit()); - iconLabel->setCursor(Qt::ArrowCursor); - QPixmap pixmap = getIcon(":/icons/bound-expression-unset.svg", QSize(iconHeight, iconHeight)); - iconLabel->setPixmap(pixmap); - iconLabel->setStyleSheet(QString::fromLatin1("QLabel { border: none; padding: 0px; padding-top: %2px; width: %1px; height: %1px }").arg(iconHeight).arg(frameWidth/2)); - iconLabel->hide(); - static_cast(iconLabel)->setExpressionText(QString()); - lineEdit()->setStyleSheet(QString::fromLatin1("QLineEdit { padding-right: %1px } ").arg(iconHeight+frameWidth)); + makeLabel(lineEdit()); QObject::connect(iconLabel, SIGNAL(clicked()), this, SLOT(openFormulaDialog())); } @@ -296,7 +283,7 @@ void UIntSpinBox::onChange() { p.setColor(QPalette::Text, Qt::lightGray); lineEdit()->setPalette(p); } - static_cast(iconLabel)->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); + iconLabel->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); } else { setReadOnly(false); @@ -304,7 +291,7 @@ void UIntSpinBox::onChange() { QPalette p(lineEdit()->palette()); p.setColor(QPalette::Active, QPalette::Text, defaultPalette.color(QPalette::Text)); lineEdit()->setPalette(p); - static_cast(iconLabel)->setExpressionText(QString()); + iconLabel->setExpressionText(QString()); } } @@ -347,7 +334,7 @@ void UIntSpinBox::resizeEvent(QResizeEvent * event) p.setColor(QPalette::Text, Qt::lightGray); lineEdit()->setPalette(p); } - static_cast(iconLabel)->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); + iconLabel->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); } else { setReadOnly(false); @@ -357,7 +344,7 @@ void UIntSpinBox::resizeEvent(QResizeEvent * event) QPalette p(lineEdit()->palette()); p.setColor(QPalette::Active, QPalette::Text, defaultPalette.color(QPalette::Text)); lineEdit()->setPalette(p); - static_cast(iconLabel)->setExpressionText(QString()); + iconLabel->setExpressionText(QString()); } } catch (const Base::Exception & e) { @@ -430,23 +417,9 @@ void UIntSpinBox::paintEvent(QPaintEvent*) // ---------------------------------------------------------------------------- -IntSpinBox::IntSpinBox(QWidget* parent) : QSpinBox(parent) { - - defaultPalette = lineEdit()->palette(); - - /* Icon for f(x) */ - QFontMetrics fm(lineEdit()->font()); - int frameWidth = style()->pixelMetric(QStyle::PM_SpinBoxFrameWidth); - iconHeight = fm.height() - frameWidth; - iconLabel = new ExpressionLabel(lineEdit()); - iconLabel->setCursor(Qt::ArrowCursor); - QPixmap pixmap = getIcon(":/icons/bound-expression-unset.svg", QSize(iconHeight, iconHeight)); - iconLabel->setPixmap(pixmap); - iconLabel->setStyleSheet(QString::fromLatin1("QLabel { border: none; padding: 0px; padding-top: %2px; width: %1px; height: %1px }").arg(iconHeight).arg(frameWidth/2)); - iconLabel->hide(); - static_cast(iconLabel)->setExpressionText(QString()); - lineEdit()->setStyleSheet(QString::fromLatin1("QLineEdit { padding-right: %1px } ").arg(iconHeight+frameWidth)); - +IntSpinBox::IntSpinBox(QWidget* parent) : QSpinBox(parent) +{ + makeLabel(lineEdit()); QObject::connect(iconLabel, SIGNAL(clicked()), this, SLOT(openFormulaDialog())); } @@ -506,7 +479,7 @@ void IntSpinBox::onChange() { p.setColor(QPalette::Text, Qt::lightGray); lineEdit()->setPalette(p); } - static_cast(iconLabel)->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); + iconLabel->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); } else { setReadOnly(false); @@ -514,7 +487,7 @@ void IntSpinBox::onChange() { QPalette p(lineEdit()->palette()); p.setColor(QPalette::Active, QPalette::Text, defaultPalette.color(QPalette::Text)); lineEdit()->setPalette(p); - static_cast(iconLabel)->setExpressionText(QString()); + iconLabel->setExpressionText(QString()); } } @@ -541,7 +514,7 @@ void IntSpinBox::resizeEvent(QResizeEvent * event) p.setColor(QPalette::Text, Qt::lightGray); lineEdit()->setPalette(p); } - static_cast(iconLabel)->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); + iconLabel->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); } else { setReadOnly(false); @@ -551,7 +524,7 @@ void IntSpinBox::resizeEvent(QResizeEvent * event) QPalette p(lineEdit()->palette()); p.setColor(QPalette::Active, QPalette::Text, defaultPalette.color(QPalette::Text)); lineEdit()->setPalette(p); - static_cast(iconLabel)->setExpressionText(QString()); + iconLabel->setExpressionText(QString()); } } catch (const Base::Exception & e) { @@ -624,23 +597,9 @@ void IntSpinBox::paintEvent(QPaintEvent*) // ---------------------------------------------------------------------------- -DoubleSpinBox::DoubleSpinBox(QWidget* parent): QDoubleSpinBox(parent) { - - defaultPalette = lineEdit()->palette(); - - /* Icon for f(x) */ - QFontMetrics fm(lineEdit()->font()); - int frameWidth = style()->pixelMetric(QStyle::PM_SpinBoxFrameWidth); - iconHeight = fm.height() - frameWidth; - iconLabel = new ExpressionLabel(lineEdit()); - iconLabel->setCursor(Qt::ArrowCursor); - QPixmap pixmap = getIcon(":/icons/bound-expression-unset.svg", QSize(iconHeight, iconHeight)); - iconLabel->setPixmap(pixmap); - iconLabel->setStyleSheet(QString::fromLatin1("QLabel { border: none; padding: 0px; padding-top: %2px; width: %1px; height: %1px }").arg(iconHeight).arg(frameWidth/2)); - iconLabel->hide(); - static_cast(iconLabel)->setExpressionText(QString()); - lineEdit()->setStyleSheet(QString::fromLatin1("QLineEdit { padding-right: %1px } ").arg(iconHeight+frameWidth)); - +DoubleSpinBox::DoubleSpinBox(QWidget* parent): QDoubleSpinBox(parent) +{ + makeLabel(lineEdit()); QObject::connect(iconLabel, SIGNAL(clicked()), this, SLOT(openFormulaDialog())); } @@ -700,7 +659,7 @@ void DoubleSpinBox::onChange() { p.setColor(QPalette::Text, Qt::lightGray); lineEdit()->setPalette(p); } - static_cast(iconLabel)->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); + iconLabel->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); } else { setReadOnly(false); @@ -708,7 +667,7 @@ void DoubleSpinBox::onChange() { QPalette p(lineEdit()->palette()); p.setColor(QPalette::Active, QPalette::Text, defaultPalette.color(QPalette::Text)); lineEdit()->setPalette(p); - static_cast(iconLabel)->setExpressionText(QString()); + iconLabel->setExpressionText(QString()); } } @@ -735,7 +694,7 @@ void DoubleSpinBox::resizeEvent(QResizeEvent * event) p.setColor(QPalette::Text, Qt::lightGray); lineEdit()->setPalette(p); } - static_cast(iconLabel)->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); + iconLabel->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); } else { setReadOnly(false); @@ -745,7 +704,7 @@ void DoubleSpinBox::resizeEvent(QResizeEvent * event) QPalette p(lineEdit()->palette()); p.setColor(QPalette::Active, QPalette::Text, defaultPalette.color(QPalette::Text)); lineEdit()->setPalette(p); - static_cast(iconLabel)->setExpressionText(QString()); + iconLabel->setExpressionText(QString()); } } catch (const Base::Exception & e) { diff --git a/src/Gui/Widgets.cpp b/src/Gui/Widgets.cpp index 366cfcdbd0..a310905d3a 100644 --- a/src/Gui/Widgets.cpp +++ b/src/Gui/Widgets.cpp @@ -1354,23 +1354,10 @@ void LabelEditor::setInputType(InputType t) ExpLineEdit::ExpLineEdit(QWidget* parent, bool expressionOnly) : QLineEdit(parent), autoClose(expressionOnly) { - defaultPalette = palette(); - - /* Icon for f(x) */ - QFontMetrics fm(font()); - int frameWidth = style()->pixelMetric(QStyle::PM_SpinBoxFrameWidth); - iconHeight = fm.height() - frameWidth; - iconLabel = new ExpressionLabel(this); - iconLabel->setCursor(Qt::ArrowCursor); - QPixmap pixmap = getIcon(":/icons/bound-expression-unset.svg", QSize(iconHeight, iconHeight)); - iconLabel->setPixmap(pixmap); - iconLabel->setStyleSheet(QString::fromLatin1("QLabel { border: none; padding: 0px; padding-top: %2px; width: %1px; height: %1px }").arg(iconHeight).arg(frameWidth/2)); - iconLabel->hide(); - static_cast(iconLabel)->setExpressionText(QString()); - setStyleSheet(QString::fromLatin1("QLineEdit { padding-right: %1px } ").arg(iconHeight+frameWidth)); + makeLabel(this); QObject::connect(iconLabel, SIGNAL(clicked()), this, SLOT(openFormulaDialog())); - if(expressionOnly) + if (expressionOnly) QMetaObject::invokeMethod(this, "openFormulaDialog", Qt::QueuedConnection, QGenericReturnArgument()); } @@ -1383,8 +1370,8 @@ bool ExpLineEdit::apply(const std::string& propName) { } return true; } - else - return false; + + return false; } void ExpLineEdit::bind(const ObjectIdentifier& _path) { @@ -1428,7 +1415,7 @@ void ExpLineEdit::onChange() { QPalette p(palette()); p.setColor(QPalette::Text, Qt::lightGray); setPalette(p); - static_cast(iconLabel)->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); + iconLabel->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); } else { setReadOnly(false); @@ -1436,7 +1423,7 @@ void ExpLineEdit::onChange() { QPalette p(palette()); p.setColor(QPalette::Active, QPalette::Text, defaultPalette.color(QPalette::Text)); setPalette(p); - static_cast(iconLabel)->setExpressionText(QString()); + iconLabel->setExpressionText(QString()); } } @@ -1458,7 +1445,7 @@ void ExpLineEdit::resizeEvent(QResizeEvent * event) QPalette p(palette()); p.setColor(QPalette::Text, Qt::lightGray); setPalette(p); - static_cast(iconLabel)->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); + iconLabel->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); } else { setReadOnly(false); @@ -1468,7 +1455,7 @@ void ExpLineEdit::resizeEvent(QResizeEvent * event) QPalette p(palette()); p.setColor(QPalette::Active, QPalette::Text, defaultPalette.color(QPalette::Text)); setPalette(p); - static_cast(iconLabel)->setExpressionText(QString()); + iconLabel->setExpressionText(QString()); } } catch (const Base::Exception & e) { From 4e4a8df724ad4ecf4eb91337dc2e2897fe454920 Mon Sep 17 00:00:00 2001 From: Benjamin Nauck Date: Thu, 18 Feb 2021 01:10:46 +0100 Subject: [PATCH 050/178] Spreadsheet: Fix UI issues when trying to insert rows/cols * Add support for better translations (using pluralizations) * Add support for inserting rows/columns after the selection * Informs the user that it will insert rows/cols above/under/left/right of the selection * Informs the user how many rows/cols that will be inserted --- src/Mod/Spreadsheet/Gui/SheetTableView.cpp | 116 ++++++++++++++++++--- src/Mod/Spreadsheet/Gui/SheetTableView.h | 2 + 2 files changed, 102 insertions(+), 16 deletions(-) diff --git a/src/Mod/Spreadsheet/Gui/SheetTableView.cpp b/src/Mod/Spreadsheet/Gui/SheetTableView.cpp index 3a589d6ae1..4485847fc6 100644 --- a/src/Mod/Spreadsheet/Gui/SheetTableView.cpp +++ b/src/Mod/Spreadsheet/Gui/SheetTableView.cpp @@ -26,6 +26,7 @@ # include # include # include +# include # include # include #endif @@ -73,34 +74,91 @@ bool SheetViewHeader::viewportEvent(QEvent *e) { return QHeaderView::viewportEvent(e); } +static std::pair selectedMinMaxRows(QModelIndexList list) +{ + int min = std::numeric_limits::max(); + int max = 0; + for (const auto & item : list) { + int row = item.row(); + min = std::min(row, min); + max = std::max(row, max); + } + return {min, max}; +} + +static std::pair selectedMinMaxColumns(QModelIndexList list) +{ + int min = std::numeric_limits::max(); + int max = 0; + for (const auto & item : list) { + int column = item.column(); + min = std::min(column, min); + max = std::max(column, max); + } + return {min, max}; +} + SheetTableView::SheetTableView(QWidget *parent) : QTableView(parent) , sheet(0) { - QAction * insertRows = new QAction(tr("Insert rows"), this); - QAction * removeRows = new QAction(tr("Remove rows"), this); - QAction * insertColumns = new QAction(tr("Insert columns"), this); - QAction * removeColumns = new QAction(tr("Remove columns"), this); - setHorizontalHeader(new SheetViewHeader(this,Qt::Horizontal)); setVerticalHeader(new SheetViewHeader(this,Qt::Vertical)); setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); - horizontalHeader()->addAction(insertColumns); - horizontalHeader()->addAction(removeColumns); - horizontalHeader()->setContextMenuPolicy(Qt::ActionsContextMenu); + horizontalHeader()->setContextMenuPolicy(Qt::CustomContextMenu); + verticalHeader()->setContextMenuPolicy(Qt::CustomContextMenu); - verticalHeader()->addAction(insertRows); - verticalHeader()->addAction(removeRows); - verticalHeader()->setContextMenuPolicy(Qt::ActionsContextMenu); + connect(verticalHeader(), &QWidget::customContextMenuRequested, + [this](const QPoint &point){ + QMenu menu(this); + const auto selection = selectionModel()->selectedRows(); + const auto & [min, max] = selectedMinMaxRows(selection); + if (bool isContiguous = max - min == selection.size() - 1) { + /*: This is shown in the context menu for the vertical header in a spreadsheet. + The number refers to how many lines are selected and will be inserted. */ + auto insertBefore = menu.addAction(tr("Insert %n row(s) above", "", selection.size())); + connect(insertBefore, SIGNAL(triggered()), this, SLOT(insertRows())); + + if (max < model()->rowCount() - 1) { + auto insertAfter = menu.addAction(tr("Insert %n row(s) below", "", selection.size())); + connect(insertAfter, SIGNAL(triggered()), this, SLOT(insertRowsAfter())); + } + } else { + auto insert = menu.addAction(tr("Insert %n non-contiguous rows", "", selection.size())); + connect(insert, SIGNAL(triggered()), this, SLOT(insertRows())); + } + auto remove = menu.addAction(tr("Remove row(s)", "", selection.size())); + connect(remove, SIGNAL(triggered()), this, SLOT(removeRows())); + menu.exec(verticalHeader()->mapToGlobal(point)); + }); - connect(insertRows, SIGNAL(triggered()), this, SLOT(insertRows())); - connect(insertColumns, SIGNAL(triggered()), this, SLOT(insertColumns())); - connect(removeRows, SIGNAL(triggered()), this, SLOT(removeRows())); - connect(removeColumns, SIGNAL(triggered()), this, SLOT(removeColumns())); + connect(horizontalHeader(), &QWidget::customContextMenuRequested, + [this](const QPoint &point){ + QMenu menu(this); + const auto selection = selectionModel()->selectedColumns(); + const auto & [min, max] = selectedMinMaxColumns(selection); + if (bool isContiguous = max - min == selection.size() - 1) { + /*: This is shown in the context menu for the horizontal header in a spreadsheet. + The number refers to how many lines are selected and will be inserted. */ + auto insertAbove = menu.addAction(tr("Insert %n column(s) left", "", selection.size())); + connect(insertAbove, SIGNAL(triggered()), this, SLOT(insertColumns())); - QAction * cellProperties = new QAction(tr("Properties..."), this); + if (max < model()->columnCount() - 1) { + auto insertAfter = menu.addAction(tr("Insert %n column(s) right", "", selection.size())); + connect(insertAfter, SIGNAL(triggered()), this, SLOT(insertColumnsAfter())); + } + } else { + auto insert = menu.addAction(tr("Insert %n non-contiguous columns", "", selection.size())); + connect(insert, SIGNAL(triggered()), this, SLOT(insertColumns())); + } + auto remove = menu.addAction(tr("Remove column(s)", "", selection.size())); + connect(remove, SIGNAL(triggered()), this, SLOT(removeColumns())); + menu.exec(horizontalHeader()->mapToGlobal(point)); + }); + + auto cellProperties = new QAction(tr("Properties..."), this); addAction(cellProperties); setContextMenuPolicy(Qt::ActionsContextMenu); @@ -182,6 +240,19 @@ void SheetTableView::insertRows() Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.recompute()"); } +void SheetTableView::insertRowsAfter() +{ + assert(sheet != 0); + const auto rows = selectionModel()->selectedRows(); + const auto & [min, max] = selectedMinMaxRows(rows); + assert(max - min == rows.size() - 1); + + Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Insert rows")); + Gui::cmdAppObjectArgs(sheet, "insertRows('%s', %d)", rowName(max + 1).c_str(), rows.size()); + Gui::Command::commitCommand(); + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.recompute()"); +} + void SheetTableView::removeRows() { assert(sheet != 0); @@ -241,6 +312,19 @@ void SheetTableView::insertColumns() Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.recompute()"); } +void SheetTableView::insertColumnsAfter() +{ + assert(sheet != 0); + const auto columns = selectionModel()->selectedColumns(); + const auto & [min, max] = selectedMinMaxColumns(columns); + assert(max - min == columns.size() - 1); + + Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Insert columns")); + Gui::cmdAppObjectArgs(sheet, "insertColumns('%s', %d)", columnName(max + 1).c_str(), columns.size()); + Gui::Command::commitCommand(); + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.recompute()"); +} + void SheetTableView::removeColumns() { assert(sheet != 0); diff --git a/src/Mod/Spreadsheet/Gui/SheetTableView.h b/src/Mod/Spreadsheet/Gui/SheetTableView.h index 4338fcc21e..5dbb7b3b05 100644 --- a/src/Mod/Spreadsheet/Gui/SheetTableView.h +++ b/src/Mod/Spreadsheet/Gui/SheetTableView.h @@ -67,8 +67,10 @@ protected Q_SLOTS: void commitData(QWidget *editor); void updateCellSpan(App::CellAddress address); void insertRows(); + void insertRowsAfter(); void removeRows(); void insertColumns(); + void insertColumnsAfter(); void removeColumns(); void cellProperties(); protected: From d81e6138d191e85cc3ed3db580fb055203f71d40 Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 2 Apr 2021 21:36:29 +0200 Subject: [PATCH 051/178] Gui: add class ExpressionSpinBox to reduce code duplication --- src/Gui/SpinBox.cpp | 630 ++++++++++++++------------------------------ src/Gui/SpinBox.h | 62 +++-- 2 files changed, 231 insertions(+), 461 deletions(-) diff --git a/src/Gui/SpinBox.cpp b/src/Gui/SpinBox.cpp index 44c38818a5..974959a3b3 100644 --- a/src/Gui/SpinBox.cpp +++ b/src/Gui/SpinBox.cpp @@ -47,6 +47,167 @@ using namespace Gui; using namespace App; using namespace Base; +ExpressionSpinBox::ExpressionSpinBox(QAbstractSpinBox* sb) + : spinbox(sb) +{ + lineedit = spinbox->findChild(); + makeLabel(lineedit); + QObject::connect(iconLabel, &ExpressionLabel::clicked, [=]() { + this->openFormulaDialog(); + }); +} + +ExpressionSpinBox::~ExpressionSpinBox() +{ +} + +void ExpressionSpinBox::bind(const App::ObjectIdentifier &_path) +{ + ExpressionBinding::bind(_path); + + int frameWidth = spinbox->style()->pixelMetric(QStyle::PM_SpinBoxFrameWidth); + lineedit->setStyleSheet(QString::fromLatin1("QLineEdit { padding-right: %1px } ").arg(iconLabel->sizeHint().width() + frameWidth + 1)); + + iconLabel->show(); +} + +void ExpressionSpinBox::setExpression(std::shared_ptr expr) +{ + Q_ASSERT(isBound()); + + try { + ExpressionBinding::setExpression(expr); + } + catch (const Base::Exception & e) { + spinbox->setReadOnly(true); + QPalette p(lineedit->palette()); + p.setColor(QPalette::Active, QPalette::Text, Qt::red); + lineedit->setPalette(p); + iconLabel->setToolTip(QString::fromLatin1(e.what())); + } +} + +void ExpressionSpinBox::onChange() +{ + if (getExpression()) { + std::unique_ptr result(getExpression()->eval()); + NumberExpression * value = freecad_dynamic_cast(result.get()); + + if (value) { + setNumberExpression(value); + spinbox->setReadOnly(true); + iconLabel->setPixmap(getIcon(":/icons/bound-expression.svg", QSize(iconHeight, iconHeight))); + + QPalette p(lineedit->palette()); + p.setColor(QPalette::Text, Qt::lightGray); + lineedit->setPalette(p); + } + iconLabel->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); + } + else { + spinbox->setReadOnly(false); + iconLabel->setPixmap(getIcon(":/icons/bound-expression-unset.svg", QSize(iconHeight, iconHeight))); + QPalette p(lineedit->palette()); + p.setColor(QPalette::Active, QPalette::Text, defaultPalette.color(QPalette::Text)); + lineedit->setPalette(p); + iconLabel->setExpressionText(QString()); + } +} + +void ExpressionSpinBox::resizeWidget() +{ + int frameWidth = spinbox->style()->pixelMetric(QStyle::PM_SpinBoxFrameWidth); + + QSize sz = iconLabel->sizeHint(); + iconLabel->move(lineedit->rect().right() - frameWidth - sz.width(), 0); + + try { + if (isBound() && getExpression()) { + std::unique_ptr result(getExpression()->eval()); + NumberExpression * value = freecad_dynamic_cast(result.get()); + + if (value) { + spinbox->setReadOnly(true); + QPixmap pixmap = getIcon(":/icons/bound-expression.svg", QSize(iconHeight, iconHeight)); + iconLabel->setPixmap(pixmap); + + QPalette p(lineedit->palette()); + p.setColor(QPalette::Text, Qt::lightGray); + lineedit->setPalette(p); + } + iconLabel->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); + } + else { + spinbox->setReadOnly(false); + QPixmap pixmap = getIcon(":/icons/bound-expression-unset.svg", QSize(iconHeight, iconHeight)); + iconLabel->setPixmap(pixmap); + + QPalette p(lineedit->palette()); + p.setColor(QPalette::Active, QPalette::Text, defaultPalette.color(QPalette::Text)); + lineedit->setPalette(p); + iconLabel->setExpressionText(QString()); + } + } + catch (const Base::Exception & e) { + spinbox->setReadOnly(true); + QPalette p(lineedit->palette()); + p.setColor(QPalette::Active, QPalette::Text, Qt::red); + lineedit->setPalette(p); + iconLabel->setToolTip(QString::fromLatin1(e.what())); + } +} + +void ExpressionSpinBox::openFormulaDialog() +{ + Q_ASSERT(isBound()); + + PropertyQuantity * qprop = freecad_dynamic_cast(getPath().getProperty()); + Unit unit; + + if (qprop != 0) + unit = qprop->getUnit(); + + Gui::Dialog::DlgExpressionInput* box = new Gui::Dialog::DlgExpressionInput(getPath(), getExpression(), unit, spinbox); + QObject::connect(box, &Gui::Dialog::DlgExpressionInput::finished, [=]() { + if (box->result() == QDialog::Accepted) + setExpression(box->getExpression()); + else if (box->discardedFormula()) + setExpression(std::shared_ptr()); + + box->deleteLater(); + }); + box->show(); + + QPoint pos = spinbox->mapToGlobal(QPoint(0,0)); + box->move(pos-box->expressionPosition()); + box->setExpressionInputSize(spinbox->width(), spinbox->height()); +} + +bool ExpressionSpinBox::handleKeyEvent(const QString& text) +{ + if (text == QString::fromUtf8("=") && isBound()) { + openFormulaDialog(); + return true; + } + + return false; +} + +void ExpressionSpinBox::drawControl(QStyleOptionSpinBox& opt) +{ + if (hasExpression()) { + opt.activeSubControls &= ~QStyle::SC_SpinBoxUp; + opt.activeSubControls &= ~QStyle::SC_SpinBoxDown; + opt.state &= ~QStyle::State_Active; + opt.stepEnabled = QAbstractSpinBox::StepNone; + } + + QStylePainter p(spinbox); + p.drawComplexControl(QStyle::CC_SpinBox, opt); +} + +// ---------------------------------------------------------------------------- + UnsignedValidator::UnsignedValidator( QObject * parent ) : QValidator( parent ) { @@ -142,6 +303,7 @@ public: UIntSpinBox::UIntSpinBox (QWidget* parent) : QSpinBox (parent) + , ExpressionSpinBox(this) { d = new UIntSpinBoxPrivate; d->mValidator = new UnsignedValidator(this->minimum(), this->maximum(), this); @@ -150,10 +312,6 @@ UIntSpinBox::UIntSpinBox (QWidget* parent) setRange(0, 99); setValue(0); updateValidator(); - - makeLabel(lineEdit()); - - QObject::connect(iconLabel, SIGNAL(clicked()), this, SLOT(openFormulaDialog())); } UIntSpinBox::~UIntSpinBox() @@ -242,60 +400,6 @@ void UIntSpinBox::updateValidator() d->mValidator->setRange(this->minimum(), this->maximum()); } -void UIntSpinBox::bind(const App::ObjectIdentifier &_path) -{ - ExpressionBinding::bind(_path); - - int frameWidth = style()->pixelMetric(QStyle::PM_SpinBoxFrameWidth); - lineEdit()->setStyleSheet(QString::fromLatin1("QLineEdit { padding-right: %1px } ").arg(iconLabel->sizeHint().width() + frameWidth + 1)); - - iconLabel->show(); -} - -void UIntSpinBox::setExpression(std::shared_ptr expr) -{ - Q_ASSERT(isBound()); - - try { - ExpressionBinding::setExpression(expr); - } - catch (const Base::Exception & e) { - setReadOnly(true); - QPalette p(lineEdit()->palette()); - p.setColor(QPalette::Active, QPalette::Text, Qt::red); - lineEdit()->setPalette(p); - iconLabel->setToolTip(QString::fromLatin1(e.what())); - } -} - -void UIntSpinBox::onChange() { - - if (getExpression()) { - std::unique_ptr result(getExpression()->eval()); - NumberExpression * value = freecad_dynamic_cast(result.get()); - - if (value) { - setValue(boost::math::round(value->getValue())); - setReadOnly(true); - iconLabel->setPixmap(getIcon(":/icons/bound-expression.svg", QSize(iconHeight, iconHeight))); - - QPalette p(lineEdit()->palette()); - p.setColor(QPalette::Text, Qt::lightGray); - lineEdit()->setPalette(p); - } - iconLabel->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); - } - else { - setReadOnly(false); - iconLabel->setPixmap(getIcon(":/icons/bound-expression-unset.svg", QSize(iconHeight, iconHeight))); - QPalette p(lineEdit()->palette()); - p.setColor(QPalette::Active, QPalette::Text, defaultPalette.color(QPalette::Text)); - lineEdit()->setPalette(p); - iconLabel->setExpressionText(QString()); - } -} - - bool UIntSpinBox::apply(const std::string & propName) { if (!ExpressionBinding::apply(propName)) { @@ -306,97 +410,20 @@ bool UIntSpinBox::apply(const std::string & propName) return false; } -bool UIntSpinBox::apply() +void UIntSpinBox::setNumberExpression(App::NumberExpression* expr) { - return ExpressionBinding::apply(); + setValue(boost::math::round(expr->getValue())); } void UIntSpinBox::resizeEvent(QResizeEvent * event) { QAbstractSpinBox::resizeEvent(event); - - int frameWidth = style()->pixelMetric(QStyle::PM_SpinBoxFrameWidth); - - QSize sz = iconLabel->sizeHint(); - iconLabel->move(lineEdit()->rect().right() - frameWidth - sz.width(), 0); - - try { - if (isBound() && getExpression()) { - std::unique_ptr result(getExpression()->eval()); - NumberExpression * value = freecad_dynamic_cast(result.get()); - - if (value) { - setReadOnly(true); - QPixmap pixmap = getIcon(":/icons/bound-expression.svg", QSize(iconHeight, iconHeight)); - iconLabel->setPixmap(pixmap); - - QPalette p(lineEdit()->palette()); - p.setColor(QPalette::Text, Qt::lightGray); - lineEdit()->setPalette(p); - } - iconLabel->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); - } - else { - setReadOnly(false); - QPixmap pixmap = getIcon(":/icons/bound-expression-unset.svg", QSize(iconHeight, iconHeight)); - iconLabel->setPixmap(pixmap); - - QPalette p(lineEdit()->palette()); - p.setColor(QPalette::Active, QPalette::Text, defaultPalette.color(QPalette::Text)); - lineEdit()->setPalette(p); - iconLabel->setExpressionText(QString()); - } - } - catch (const Base::Exception & e) { - setReadOnly(true); - QPalette p(lineEdit()->palette()); - p.setColor(QPalette::Active, QPalette::Text, Qt::red); - lineEdit()->setPalette(p); - iconLabel->setToolTip(QString::fromLatin1(e.what())); - } - -} - -void UIntSpinBox::openFormulaDialog() -{ - Q_ASSERT(isBound()); - - PropertyQuantity * qprop = freecad_dynamic_cast(getPath().getProperty()); - Unit unit; - - if (qprop != 0) - unit = qprop->getUnit(); - - Gui::Dialog::DlgExpressionInput* box = new Gui::Dialog::DlgExpressionInput(getPath(), getExpression(), unit, this); - connect(box, SIGNAL(finished(int)), this, SLOT(finishFormulaDialog())); - box->show(); - - QPoint pos = mapToGlobal(QPoint(0,0)); - box->move(pos-box->expressionPosition()); - box->setExpressionInputSize(width(), height()); -} - -void UIntSpinBox::finishFormulaDialog() -{ - Gui::Dialog::DlgExpressionInput* box = qobject_cast(sender()); - if (!box) { - qWarning() << "Sender is not a Gui::Dialog::DlgExpressionInput"; - return; - } - - if (box->result() == QDialog::Accepted) - setExpression(box->getExpression()); - else if (box->discardedFormula()) - setExpression(std::shared_ptr()); - - box->deleteLater(); + resizeWidget(); } void UIntSpinBox::keyPressEvent(QKeyEvent *event) { - if (event->text() == QString::fromUtf8("=") && isBound()) - openFormulaDialog(); - else + if (!handleKeyEvent(event->text())) QAbstractSpinBox::keyPressEvent(event); } @@ -404,32 +431,24 @@ void UIntSpinBox::paintEvent(QPaintEvent*) { QStyleOptionSpinBox opt; initStyleOption(&opt); - if (hasExpression()) { - opt.activeSubControls &= ~QStyle::SC_SpinBoxUp; - opt.activeSubControls &= ~QStyle::SC_SpinBoxDown; - opt.state &= ~QStyle::State_Active; - opt.stepEnabled = StepNone; - } - - QStylePainter p(this); - p.drawComplexControl(QStyle::CC_SpinBox, opt); + drawControl(opt); } // ---------------------------------------------------------------------------- -IntSpinBox::IntSpinBox(QWidget* parent) : QSpinBox(parent) +IntSpinBox::IntSpinBox(QWidget* parent) + : QSpinBox(parent) + , ExpressionSpinBox(this) { - makeLabel(lineEdit()); - QObject::connect(iconLabel, SIGNAL(clicked()), this, SLOT(openFormulaDialog())); } -IntSpinBox::~IntSpinBox() { +IntSpinBox::~IntSpinBox() +{ } - -bool IntSpinBox::apply(const std::string& propName) { - +bool IntSpinBox::apply(const std::string& propName) +{ if (!ExpressionBinding::apply(propName)) { Gui::Command::doCommand(Gui::Command::Doc, "%s = %d", propName.c_str(), value()); return true; @@ -438,145 +457,20 @@ bool IntSpinBox::apply(const std::string& propName) { return false; } -void IntSpinBox::bind(const ObjectIdentifier& _path) { - - ExpressionBinding::bind(_path); - - int frameWidth = style()->pixelMetric(QStyle::PM_SpinBoxFrameWidth); - lineEdit()->setStyleSheet(QString::fromLatin1("QLineEdit { padding-right: %1px } ").arg(iconLabel->sizeHint().width() + frameWidth + 1)); - - iconLabel->show(); -} - -void IntSpinBox::setExpression(std::shared_ptr expr) +void IntSpinBox::setNumberExpression(App::NumberExpression* expr) { - Q_ASSERT(isBound()); - - try { - ExpressionBinding::setExpression(expr); - } - catch (const Base::Exception & e) { - setReadOnly(true); - QPalette p(lineEdit()->palette()); - p.setColor(QPalette::Active, QPalette::Text, Qt::red); - lineEdit()->setPalette(p); - iconLabel->setToolTip(QString::fromLatin1(e.what())); - } -} - -void IntSpinBox::onChange() { - - if (getExpression()) { - std::unique_ptr result(getExpression()->eval()); - NumberExpression * value = freecad_dynamic_cast(result.get()); - - if (value) { - setValue(boost::math::round(value->getValue())); - setReadOnly(true); - iconLabel->setPixmap(getIcon(":/icons/bound-expression.svg", QSize(iconHeight, iconHeight))); - - QPalette p(lineEdit()->palette()); - p.setColor(QPalette::Text, Qt::lightGray); - lineEdit()->setPalette(p); - } - iconLabel->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); - } - else { - setReadOnly(false); - iconLabel->setPixmap(getIcon(":/icons/bound-expression-unset.svg", QSize(iconHeight, iconHeight))); - QPalette p(lineEdit()->palette()); - p.setColor(QPalette::Active, QPalette::Text, defaultPalette.color(QPalette::Text)); - lineEdit()->setPalette(p); - iconLabel->setExpressionText(QString()); - } + setValue(boost::math::round(expr->getValue())); } void IntSpinBox::resizeEvent(QResizeEvent * event) { QAbstractSpinBox::resizeEvent(event); - - int frameWidth = style()->pixelMetric(QStyle::PM_SpinBoxFrameWidth); - - QSize sz = iconLabel->sizeHint(); - iconLabel->move(lineEdit()->rect().right() - frameWidth - sz.width(), 0); - - try { - if (isBound() && getExpression()) { - std::unique_ptr result(getExpression()->eval()); - NumberExpression * value = freecad_dynamic_cast(result.get()); - - if (value) { - setReadOnly(true); - QPixmap pixmap = getIcon(":/icons/bound-expression.svg", QSize(iconHeight, iconHeight)); - iconLabel->setPixmap(pixmap); - - QPalette p(lineEdit()->palette()); - p.setColor(QPalette::Text, Qt::lightGray); - lineEdit()->setPalette(p); - } - iconLabel->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); - } - else { - setReadOnly(false); - QPixmap pixmap = getIcon(":/icons/bound-expression-unset.svg", QSize(iconHeight, iconHeight)); - iconLabel->setPixmap(pixmap); - - QPalette p(lineEdit()->palette()); - p.setColor(QPalette::Active, QPalette::Text, defaultPalette.color(QPalette::Text)); - lineEdit()->setPalette(p); - iconLabel->setExpressionText(QString()); - } - } - catch (const Base::Exception & e) { - setReadOnly(true); - QPalette p(lineEdit()->palette()); - p.setColor(QPalette::Active, QPalette::Text, Qt::red); - lineEdit()->setPalette(p); - iconLabel->setToolTip(QString::fromLatin1(e.what())); - } - -} - -void IntSpinBox::openFormulaDialog() -{ - Q_ASSERT(isBound()); - - PropertyQuantity * qprop = freecad_dynamic_cast(getPath().getProperty()); - Unit unit; - - if (qprop != 0) - unit = qprop->getUnit(); - - Gui::Dialog::DlgExpressionInput* box = new Gui::Dialog::DlgExpressionInput(getPath(), getExpression(),unit, this); - connect(box, SIGNAL(finished(int)), this, SLOT(finishFormulaDialog())); - box->show(); - - QPoint pos = mapToGlobal(QPoint(0,0)); - box->move(pos-box->expressionPosition()); - box->setExpressionInputSize(width(), height()); -} - -void IntSpinBox::finishFormulaDialog() -{ - Gui::Dialog::DlgExpressionInput* box = qobject_cast(sender()); - if (!box) { - qWarning() << "Sender is not a Gui::Dialog::DlgExpressionInput"; - return; - } - - if (box->result() == QDialog::Accepted) - setExpression(box->getExpression()); - else if (box->discardedFormula()) - setExpression(std::shared_ptr()); - - box->deleteLater(); + resizeWidget(); } void IntSpinBox::keyPressEvent(QKeyEvent *event) { - if (event->text() == QString::fromUtf8("=") && isBound()) - openFormulaDialog(); - else + if (!handleKeyEvent(event->text())) QAbstractSpinBox::keyPressEvent(event); } @@ -584,32 +478,24 @@ void IntSpinBox::paintEvent(QPaintEvent*) { QStyleOptionSpinBox opt; initStyleOption(&opt); - if (hasExpression()) { - opt.activeSubControls &= ~QStyle::SC_SpinBoxUp; - opt.activeSubControls &= ~QStyle::SC_SpinBoxDown; - opt.state &= ~QStyle::State_Active; - opt.stepEnabled = StepNone; - } - - QStylePainter p(this); - p.drawComplexControl(QStyle::CC_SpinBox, opt); + drawControl(opt); } // ---------------------------------------------------------------------------- -DoubleSpinBox::DoubleSpinBox(QWidget* parent): QDoubleSpinBox(parent) +DoubleSpinBox::DoubleSpinBox(QWidget* parent) + : QDoubleSpinBox(parent) + , ExpressionSpinBox(this) { - makeLabel(lineEdit()); - QObject::connect(iconLabel, SIGNAL(clicked()), this, SLOT(openFormulaDialog())); } -DoubleSpinBox::~DoubleSpinBox() { +DoubleSpinBox::~DoubleSpinBox() +{ } - -bool DoubleSpinBox::apply(const std::string& propName) { - +bool DoubleSpinBox::apply(const std::string& propName) +{ if (!ExpressionBinding::apply(propName)) { Gui::Command::doCommand(Gui::Command::Doc, "%s = %f", propName.c_str(), value()); return true; @@ -618,160 +504,28 @@ bool DoubleSpinBox::apply(const std::string& propName) { return false; } -void DoubleSpinBox::bind(const ObjectIdentifier& _path) { - - ExpressionBinding::bind(_path); - - int frameWidth = style()->pixelMetric(QStyle::PM_SpinBoxFrameWidth); - lineEdit()->setStyleSheet(QString::fromLatin1("QLineEdit { padding-right: %1px } ").arg(iconLabel->sizeHint().width() + frameWidth + 1)); - - iconLabel->show(); -} - -void DoubleSpinBox::setExpression(std::shared_ptr expr) +void DoubleSpinBox::setNumberExpression(App::NumberExpression* expr) { - Q_ASSERT(isBound()); - - try { - ExpressionBinding::setExpression(expr); - } - catch (const Base::Exception & e) { - setReadOnly(true); - QPalette p(lineEdit()->palette()); - p.setColor(QPalette::Active, QPalette::Text, Qt::red); - lineEdit()->setPalette(p); - iconLabel->setToolTip(QString::fromLatin1(e.what())); - } -} - -void DoubleSpinBox::onChange() { - - if (getExpression()) { - std::unique_ptr result(getExpression()->eval()); - NumberExpression * value = freecad_dynamic_cast(result.get()); - - if (value) { - setValue(value->getValue()); - setReadOnly(true); - iconLabel->setPixmap(getIcon(":/icons/bound-expression.svg", QSize(iconHeight, iconHeight))); - - QPalette p(lineEdit()->palette()); - p.setColor(QPalette::Text, Qt::lightGray); - lineEdit()->setPalette(p); - } - iconLabel->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); - } - else { - setReadOnly(false); - iconLabel->setPixmap(getIcon(":/icons/bound-expression-unset.svg", QSize(iconHeight, iconHeight))); - QPalette p(lineEdit()->palette()); - p.setColor(QPalette::Active, QPalette::Text, defaultPalette.color(QPalette::Text)); - lineEdit()->setPalette(p); - iconLabel->setExpressionText(QString()); - } + setValue(expr->getValue()); } void DoubleSpinBox::resizeEvent(QResizeEvent * event) { QAbstractSpinBox::resizeEvent(event); - - int frameWidth = style()->pixelMetric(QStyle::PM_SpinBoxFrameWidth); - - QSize sz = iconLabel->sizeHint(); - iconLabel->move(lineEdit()->rect().right() - frameWidth - sz.width(), 0); - - try { - if (isBound() && getExpression()) { - std::unique_ptr result(getExpression()->eval()); - NumberExpression * value = freecad_dynamic_cast(result.get()); - - if (value) { - setReadOnly(true); - QPixmap pixmap = getIcon(":/icons/bound-expression.svg", QSize(iconHeight, iconHeight)); - iconLabel->setPixmap(pixmap); - - QPalette p(lineEdit()->palette()); - p.setColor(QPalette::Text, Qt::lightGray); - lineEdit()->setPalette(p); - } - iconLabel->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); - } - else { - setReadOnly(false); - QPixmap pixmap = getIcon(":/icons/bound-expression-unset.svg", QSize(iconHeight, iconHeight)); - iconLabel->setPixmap(pixmap); - - QPalette p(lineEdit()->palette()); - p.setColor(QPalette::Active, QPalette::Text, defaultPalette.color(QPalette::Text)); - lineEdit()->setPalette(p); - iconLabel->setExpressionText(QString()); - } - } - catch (const Base::Exception & e) { - setReadOnly(true); - QPalette p(lineEdit()->palette()); - p.setColor(QPalette::Active, QPalette::Text, Qt::red); - lineEdit()->setPalette(p); - iconLabel->setToolTip(QString::fromLatin1(e.what())); - } -} - -void DoubleSpinBox::openFormulaDialog() -{ - Q_ASSERT(isBound()); - - PropertyQuantity * qprop = freecad_dynamic_cast(getPath().getProperty()); - Unit unit; - - if (qprop != 0) - unit = qprop->getUnit(); - - Gui::Dialog::DlgExpressionInput* box = new Gui::Dialog::DlgExpressionInput(getPath(), getExpression(), unit, this); - connect(box, SIGNAL(finished(int)), this, SLOT(finishFormulaDialog())); - box->show(); - - QPoint pos = mapToGlobal(QPoint(0,0)); - box->move(pos-box->expressionPosition()); - box->setExpressionInputSize(width(), height()); -} - -void DoubleSpinBox::finishFormulaDialog() -{ - Gui::Dialog::DlgExpressionInput* box = qobject_cast(sender()); - if (!box) { - qWarning() << "Sender is not a Gui::Dialog::DlgExpressionInput"; - return; - } - - if (box->result() == QDialog::Accepted) - setExpression(box->getExpression()); - else if (box->discardedFormula()) - setExpression(std::shared_ptr()); - - box->deleteLater(); + resizeWidget(); } void DoubleSpinBox::keyPressEvent(QKeyEvent *event) { - if (event->text() == QString::fromUtf8("=") && isBound()) - openFormulaDialog(); - else - QAbstractSpinBox::keyPressEvent(event); + if (!handleKeyEvent(event->text())) + QDoubleSpinBox::keyPressEvent(event); } void DoubleSpinBox::paintEvent(QPaintEvent*) { QStyleOptionSpinBox opt; initStyleOption(&opt); - if (hasExpression()) { - opt.activeSubControls &= ~QStyle::SC_SpinBoxUp; - opt.activeSubControls &= ~QStyle::SC_SpinBoxDown; - opt.state &= ~QStyle::State_Active; - opt.stepEnabled = StepNone; - } - - QStylePainter p(this); - p.drawComplexControl(QStyle::CC_SpinBox, opt); + drawControl(opt); } #include "moc_SpinBox.cpp" diff --git a/src/Gui/SpinBox.h b/src/Gui/SpinBox.h index 0ae1f7ee4e..09e88e8fd7 100644 --- a/src/Gui/SpinBox.h +++ b/src/Gui/SpinBox.h @@ -28,8 +28,38 @@ #include #include "ExpressionBinding.h" +class QStyleOptionSpinBox; + +namespace App { +class NumberExpression; +} + namespace Gui { +class GuiExport ExpressionSpinBox : public ExpressionBinding +{ +public: + ExpressionSpinBox(QAbstractSpinBox*); + virtual ~ExpressionSpinBox(); + + void bind(const App::ObjectIdentifier &_path); + void setExpression(std::shared_ptr expr); + +protected: + void onChange(); + virtual void setNumberExpression(App::NumberExpression*) = 0; + void resizeWidget(); + + bool handleKeyEvent(const QString&); + void openFormulaDialog(); + + void drawControl(QStyleOptionSpinBox&); + +protected: + QLineEdit* lineedit; + QAbstractSpinBox* spinbox; +}; + /** * A validator that allows only input of unsigned int values in the range * from 0 to UINT_MAX. @@ -65,7 +95,7 @@ class UIntSpinBoxPrivate; * This allows to use numbers in the range of [0, UINT_MAX] * @author Werner Mayer */ -class GuiExport UIntSpinBox : public QSpinBox, public ExpressionBinding +class GuiExport UIntSpinBox : public QSpinBox, public ExpressionSpinBox { Q_OBJECT Q_OVERRIDE( uint maximum READ maximum WRITE setMaximum ) @@ -84,10 +114,8 @@ public: uint maximum() const; void setMaximum( uint value ); - void setExpression(std::shared_ptr expr); - void bind(const App::ObjectIdentifier &_path); bool apply(const std::string &propName); - bool apply(); + using ExpressionSpinBox::apply; void keyPressEvent(QKeyEvent *event); void resizeEvent(QResizeEvent *event); @@ -101,13 +129,11 @@ public Q_SLOTS: private Q_SLOTS: void valueChange( int value ); - void finishFormulaDialog(); - void openFormulaDialog(); protected: virtual QString textFromValue ( int v ) const; virtual int valueFromText ( const QString & text ) const; - virtual void onChange(); + virtual void setNumberExpression(App::NumberExpression*); private: void updateValidator(); @@ -119,7 +145,7 @@ private: * The IntSpinBox class does exactly the same as Qt's QSpinBox but has expression support * @author Stefan Tröger */ -class GuiExport IntSpinBox : public QSpinBox, public ExpressionBinding +class GuiExport IntSpinBox : public QSpinBox, public ExpressionSpinBox { Q_OBJECT @@ -127,18 +153,13 @@ public: IntSpinBox ( QWidget* parent=0 ); virtual ~IntSpinBox(); - void setExpression(std::shared_ptr expr); - void bind(const App::ObjectIdentifier &_path); bool apply(const std::string &propName); + using ExpressionSpinBox::apply; + void setNumberExpression(App::NumberExpression*); void keyPressEvent(QKeyEvent *event); void resizeEvent(QResizeEvent *event); void paintEvent(QPaintEvent *event); - -private Q_SLOTS: - void finishFormulaDialog(); - void openFormulaDialog(); - virtual void onChange(); }; /** @@ -146,7 +167,7 @@ private Q_SLOTS: * support * @author Stefan Tröger */ -class GuiExport DoubleSpinBox : public QDoubleSpinBox, public ExpressionBinding +class GuiExport DoubleSpinBox : public QDoubleSpinBox, public ExpressionSpinBox { Q_OBJECT @@ -154,18 +175,13 @@ public: DoubleSpinBox ( QWidget* parent=0 ); virtual ~DoubleSpinBox(); - void setExpression(std::shared_ptr expr); - void bind(const App::ObjectIdentifier &_path); bool apply(const std::string &propName); + using ExpressionSpinBox::apply; + void setNumberExpression(App::NumberExpression*); void keyPressEvent(QKeyEvent *event); void resizeEvent(QResizeEvent *event); void paintEvent(QPaintEvent *event); - -private Q_SLOTS: - void finishFormulaDialog(); - void openFormulaDialog(); - virtual void onChange(); }; } // namespace Gui From 6cac113ec7adc37e7da6c56b719379de0c31b36d Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 2 Apr 2021 22:22:16 +0200 Subject: [PATCH 052/178] Gui: QuantitySpinBox inherits from ExpressionSpinBox to reduce code duplication --- src/Gui/QuantitySpinBox.cpp | 144 ++++-------------------------------- src/Gui/QuantitySpinBox.h | 16 ++-- src/Gui/SpinBox.cpp | 2 + src/Gui/SpinBox.h | 2 +- 4 files changed, 24 insertions(+), 140 deletions(-) diff --git a/src/Gui/QuantitySpinBox.cpp b/src/Gui/QuantitySpinBox.cpp index 52e3eb69ba..1e8d60fd89 100644 --- a/src/Gui/QuantitySpinBox.cpp +++ b/src/Gui/QuantitySpinBox.cpp @@ -290,7 +290,7 @@ end: QuantitySpinBox::QuantitySpinBox(QWidget *parent) : QAbstractSpinBox(parent), - ExpressionBinding(), + ExpressionSpinBox(this), d_ptr(new QuantitySpinBoxPrivate()) { d_ptr->locale = locale(); @@ -300,8 +300,6 @@ QuantitySpinBox::QuantitySpinBox(QWidget *parent) QObject::connect(this, SIGNAL(editingFinished()), this, SLOT(handlePendingEmit())); - makeLabel(lineEdit()); - // When a style sheet is set the text margins for top/bottom must be set to avoid to squash the widget #ifndef Q_OS_MAC lineEdit()->setTextMargins(0, 2, 0, 2); @@ -309,8 +307,6 @@ QuantitySpinBox::QuantitySpinBox(QWidget *parent) // https://forum.freecadweb.org/viewtopic.php?f=8&t=50615 lineEdit()->setTextMargins(0, 2, 0, 0); #endif - - QObject::connect(iconLabel, SIGNAL(clicked()), this, SLOT(openFormulaDialog())); } QuantitySpinBox::~QuantitySpinBox() @@ -324,22 +320,6 @@ void QuantitySpinBox::bind(const App::ObjectIdentifier &_path) iconLabel->show(); } -void Gui::QuantitySpinBox::setExpression(std::shared_ptr expr) -{ - Q_ASSERT(isBound()); - - try { - ExpressionBinding::setExpression(expr); - } - catch (const Base::Exception & e) { - setReadOnly(true); - QPalette p(lineEdit()->palette()); - p.setColor(QPalette::Active, QPalette::Text, Qt::red); - lineEdit()->setPalette(p); - iconLabel->setToolTip(QString::fromLatin1(e.what())); - } -} - QString QuantitySpinBox::boundToName() const { if (isBound()) { @@ -412,44 +392,12 @@ QString Gui::QuantitySpinBox::expressionText() const return QString(); } - -void Gui::QuantitySpinBox::onChange() +void Gui::QuantitySpinBox::setNumberExpression(App::NumberExpression* expr) { - Q_ASSERT(isBound()); - - if (getExpression()) { - std::unique_ptr result(getExpression()->eval()); - NumberExpression * value = freecad_dynamic_cast(result.get()); - - if (value) { - std::stringstream s; - s << value->getValue(); - - lineEdit()->setText(getUserString(value->getQuantity())); - handlePendingEmit(); - - setReadOnly(true); - QPixmap pixmap = getIcon(":/icons/bound-expression.svg", QSize(iconHeight, iconHeight)); - iconLabel->setPixmap(pixmap); - - QPalette p(lineEdit()->palette()); - p.setColor(QPalette::Text, Qt::lightGray); - lineEdit()->setPalette(p); - } - iconLabel->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); - } - else { - setReadOnly(false); - QPixmap pixmap = getIcon(":/icons/bound-expression-unset.svg", QSize(iconHeight, iconHeight)); - iconLabel->setPixmap(pixmap); - QPalette p(lineEdit()->palette()); - p.setColor(QPalette::Active, QPalette::Text, defaultPalette.color(QPalette::Text)); - lineEdit()->setPalette(p); - iconLabel->setExpressionText(QString()); - } + lineEdit()->setText(getUserString(expr->getQuantity())); + handlePendingEmit(); } - bool QuantitySpinBox::apply(const std::string & propName) { if (!ExpressionBinding::apply(propName)) { @@ -480,54 +428,12 @@ bool QuantitySpinBox::apply(const std::string & propName) void QuantitySpinBox::resizeEvent(QResizeEvent * event) { QAbstractSpinBox::resizeEvent(event); - - int frameWidth = style()->pixelMetric(QStyle::PM_SpinBoxFrameWidth); - - QSize sz = iconLabel->sizeHint(); - iconLabel->move(lineEdit()->rect().right() - frameWidth - sz.width(), 0); - - try { - if (isBound() && getExpression()) { - std::unique_ptr result(getExpression()->eval()); - NumberExpression * value = freecad_dynamic_cast(result.get()); - - if (value) { - setReadOnly(true); - QPixmap pixmap = getIcon(":/icons/bound-expression.svg", QSize(iconHeight, iconHeight)); - iconLabel->setPixmap(pixmap); - - QPalette p(lineEdit()->palette()); - p.setColor(QPalette::Text, Qt::lightGray); - lineEdit()->setPalette(p); - } - iconLabel->setExpressionText(Base::Tools::fromStdString(getExpression()->toString())); - } - else { - setReadOnly(false); - QPixmap pixmap = getIcon(":/icons/bound-expression-unset.svg", QSize(iconHeight, iconHeight)); - iconLabel->setPixmap(pixmap); - - QPalette p(lineEdit()->palette()); - p.setColor(QPalette::Active, QPalette::Text, defaultPalette.color(QPalette::Text)); - lineEdit()->setPalette(p); - iconLabel->setExpressionText(QString()); - } - } - catch (const Base::Exception & e) { - setReadOnly(true); - QPalette p(lineEdit()->palette()); - p.setColor(QPalette::Active, QPalette::Text, Qt::red); - lineEdit()->setPalette(p); - iconLabel->setToolTip(QString::fromLatin1(e.what())); - } - + resizeWidget(); } void Gui::QuantitySpinBox::keyPressEvent(QKeyEvent *event) { - if (event->text() == QString::fromUtf8("=") && isBound()) - openFormulaDialog(); - else + if (!handleKeyEvent(event->text())) QAbstractSpinBox::keyPressEvent(event); } @@ -535,15 +441,7 @@ void Gui::QuantitySpinBox::paintEvent(QPaintEvent*) { QStyleOptionSpinBox opt; initStyleOption(&opt); - if (hasExpression()) { - opt.activeSubControls &= ~QStyle::SC_SpinBoxUp; - opt.activeSubControls &= ~QStyle::SC_SpinBoxDown; - opt.state &= ~QStyle::State_Active; - opt.stepEnabled = StepNone; - } - - QStylePainter p(this); - p.drawComplexControl(QStyle::CC_SpinBox, opt); + drawControl(opt); } void QuantitySpinBox::updateText(const Quantity &quant) @@ -629,7 +527,15 @@ void QuantitySpinBox::openFormulaDialog() Q_D(const QuantitySpinBox); Gui::Dialog::DlgExpressionInput* box = new Gui::Dialog::DlgExpressionInput(getPath(), getExpression(), d->unit, this); - connect(box, SIGNAL(finished(int)), this, SLOT(finishFormulaDialog())); + QObject::connect(box, &Gui::Dialog::DlgExpressionInput::finished, [=]() { + if (box->result() == QDialog::Accepted) + setExpression(box->getExpression()); + else if (box->discardedFormula()) + setExpression(std::shared_ptr()); + + box->deleteLater(); + Q_EMIT showFormulaDialog(false); + }); box->show(); QPoint pos = mapToGlobal(QPoint(0,0)); @@ -639,24 +545,6 @@ void QuantitySpinBox::openFormulaDialog() Q_EMIT showFormulaDialog(true); } -void QuantitySpinBox::finishFormulaDialog() -{ - Gui::Dialog::DlgExpressionInput* box = qobject_cast(sender()); - if (!box) { - qWarning() << "Sender is not a Gui::Dialog::DlgExpressionInput"; - return; - } - - if (box->result() == QDialog::Accepted) - setExpression(box->getExpression()); - else if (box->discardedFormula()) - setExpression(std::shared_ptr()); - - box->deleteLater(); - - Q_EMIT showFormulaDialog(false); -} - void QuantitySpinBox::handlePendingEmit() { updateFromCache(true); diff --git a/src/Gui/QuantitySpinBox.h b/src/Gui/QuantitySpinBox.h index 6a3da7b765..d0f34fa11c 100644 --- a/src/Gui/QuantitySpinBox.h +++ b/src/Gui/QuantitySpinBox.h @@ -24,10 +24,9 @@ #ifndef GUI_QUANTITYSPINBOX_H #define GUI_QUANTITYSPINBOX_H -#include #include #include -#include "ExpressionBinding.h" +#include #ifdef Q_MOC_RUN Q_DECLARE_METATYPE(Base::Quantity) @@ -36,7 +35,7 @@ Q_DECLARE_METATYPE(Base::Quantity) namespace Gui { class QuantitySpinBoxPrivate; -class GuiExport QuantitySpinBox : public QAbstractSpinBox, public ExpressionBinding +class GuiExport QuantitySpinBox : public QAbstractSpinBox, public ExpressionSpinBox { Q_OBJECT @@ -50,8 +49,6 @@ class GuiExport QuantitySpinBox : public QAbstractSpinBox, public ExpressionBind Q_PROPERTY(QString expression READ expressionText) public: - using ExpressionBinding::apply; - explicit QuantitySpinBox(QWidget *parent = 0); virtual ~QuantitySpinBox(); @@ -128,9 +125,10 @@ public: QSize minimumSizeHint() const; bool event(QEvent *event); - void setExpression(std::shared_ptr expr); + void setNumberExpression(App::NumberExpression*); void bind(const App::ObjectIdentifier &_path); bool apply(const std::string &propName); + using ExpressionSpinBox::apply; public Q_SLOTS: /// Sets the field with a quantity @@ -140,14 +138,10 @@ public Q_SLOTS: protected Q_SLOTS: void userInput(const QString & text); - void openFormulaDialog(); - void finishFormulaDialog(); void handlePendingEmit(); - //get notified on expression change - virtual void onChange(); - protected: + virtual void openFormulaDialog(); virtual StepEnabled stepEnabled() const; virtual void showEvent(QShowEvent * event); virtual void hideEvent(QHideEvent * event); diff --git a/src/Gui/SpinBox.cpp b/src/Gui/SpinBox.cpp index 974959a3b3..9866abf11d 100644 --- a/src/Gui/SpinBox.cpp +++ b/src/Gui/SpinBox.cpp @@ -89,6 +89,8 @@ void ExpressionSpinBox::setExpression(std::shared_ptr expr) void ExpressionSpinBox::onChange() { + Q_ASSERT(isBound()); + if (getExpression()) { std::unique_ptr result(getExpression()->eval()); NumberExpression * value = freecad_dynamic_cast(result.get()); diff --git a/src/Gui/SpinBox.h b/src/Gui/SpinBox.h index 09e88e8fd7..c8ca9ec3c4 100644 --- a/src/Gui/SpinBox.h +++ b/src/Gui/SpinBox.h @@ -51,7 +51,7 @@ protected: void resizeWidget(); bool handleKeyEvent(const QString&); - void openFormulaDialog(); + virtual void openFormulaDialog(); void drawControl(QStyleOptionSpinBox&); From f4e0abc9d29dba428f74efcffd61f37b58b687c0 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 3 Apr 2021 12:21:42 +0200 Subject: [PATCH 053/178] Spreadsheet: [skip ci] fix gcc warnings about unused variables --- src/Mod/Spreadsheet/Gui/SheetTableView.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Mod/Spreadsheet/Gui/SheetTableView.cpp b/src/Mod/Spreadsheet/Gui/SheetTableView.cpp index 4485847fc6..11da87b0b5 100644 --- a/src/Mod/Spreadsheet/Gui/SheetTableView.cpp +++ b/src/Mod/Spreadsheet/Gui/SheetTableView.cpp @@ -116,6 +116,7 @@ SheetTableView::SheetTableView(QWidget *parent) const auto selection = selectionModel()->selectedRows(); const auto & [min, max] = selectedMinMaxRows(selection); if (bool isContiguous = max - min == selection.size() - 1) { + Q_UNUSED(isContiguous) /*: This is shown in the context menu for the vertical header in a spreadsheet. The number refers to how many lines are selected and will be inserted. */ auto insertBefore = menu.addAction(tr("Insert %n row(s) above", "", selection.size())); @@ -140,6 +141,7 @@ SheetTableView::SheetTableView(QWidget *parent) const auto selection = selectionModel()->selectedColumns(); const auto & [min, max] = selectedMinMaxColumns(selection); if (bool isContiguous = max - min == selection.size() - 1) { + Q_UNUSED(isContiguous) /*: This is shown in the context menu for the horizontal header in a spreadsheet. The number refers to how many lines are selected and will be inserted. */ auto insertAbove = menu.addAction(tr("Insert %n column(s) left", "", selection.size())); @@ -246,6 +248,7 @@ void SheetTableView::insertRowsAfter() const auto rows = selectionModel()->selectedRows(); const auto & [min, max] = selectedMinMaxRows(rows); assert(max - min == rows.size() - 1); + Q_UNUSED(min) Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Insert rows")); Gui::cmdAppObjectArgs(sheet, "insertRows('%s', %d)", rowName(max + 1).c_str(), rows.size()); @@ -318,6 +321,7 @@ void SheetTableView::insertColumnsAfter() const auto columns = selectionModel()->selectedColumns(); const auto & [min, max] = selectedMinMaxColumns(columns); assert(max - min == columns.size() - 1); + Q_UNUSED(min) Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Insert columns")); Gui::cmdAppObjectArgs(sheet, "insertColumns('%s', %d)", columnName(max + 1).c_str(), columns.size()); From 2f0232c5f021481508f2be46599c2602461cf9aa Mon Sep 17 00:00:00 2001 From: bitacovir Date: Sat, 3 Apr 2021 10:08:34 -0300 Subject: [PATCH 054/178] [UI] Replace SVG icon of TechDraw RedrawPage --- src/Mod/TechDraw/Gui/Command.cpp | 2 +- src/Mod/TechDraw/Gui/Resources/TechDraw.qrc | 2 +- ...RedrawPage.svg => TechDraw_RedrawPage.svg} | 338 ++++++------------ 3 files changed, 116 insertions(+), 226 deletions(-) rename src/Mod/TechDraw/Gui/Resources/icons/actions/{techdraw-RedrawPage.svg => TechDraw_RedrawPage.svg} (57%) diff --git a/src/Mod/TechDraw/Gui/Command.cpp b/src/Mod/TechDraw/Gui/Command.cpp index ea9bacd75e..a461d41eff 100644 --- a/src/Mod/TechDraw/Gui/Command.cpp +++ b/src/Mod/TechDraw/Gui/Command.cpp @@ -256,7 +256,7 @@ CmdTechDrawRedrawPage::CmdTechDrawRedrawPage() sToolTipText = sMenuText; sWhatsThis = "TechDraw_RedrawPage"; sStatusTip = sToolTipText; - sPixmap = "actions/techdraw-RedrawPage"; + sPixmap = "actions/TechDraw_RedrawPage"; } void CmdTechDrawRedrawPage::activated(int iMsg) diff --git a/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc b/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc index e89df5e3bf..f2de840fb5 100644 --- a/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc +++ b/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc @@ -62,7 +62,7 @@ icons/actions/techdraw-hatch.svg icons/actions/techdraw-GeometricHatch.svg icons/actions/techdraw-toggleframe.svg - icons/actions/techdraw-RedrawPage.svg + icons/actions/TechDraw_RedrawPage.svg icons/actions/techdraw-ProjectionGroup.svg icons/actions/techdraw-SpreadsheetView.svg icons/actions/techdraw-image.svg diff --git a/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-RedrawPage.svg b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_RedrawPage.svg similarity index 57% rename from src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-RedrawPage.svg rename to src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_RedrawPage.svg index 137b24e6dd..e5bda21aad 100644 --- a/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-RedrawPage.svg +++ b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_RedrawPage.svg @@ -1,6 +1,4 @@ - - + TechDraw_RedrawPage -
- - - - - - - + y2="18.118267" + gradientTransform="matrix(-0.57654091,-0.61963683,0.61963683,-0.57654091,38.266148,42.812335)" /> + y2="20.050343" + gradientTransform="matrix(-0.57654091,-0.61963683,0.61963683,-0.57654091,38.266148,42.812335)" /> + + + + + + +
- - - @@ -493,20 +419,28 @@ rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> - Jakub Steiner + [bitacovir] - http://jimmac.musichall.cz + - + TechDraw_RedrawPage - - reload - refresh - view - + + 02-04-2021 + + + FreeCAD LGPL2+ + + + + + FreeCAD + + + http://www.freecadweb.org/wiki/index.php?title=Artwork @@ -521,121 +455,77 @@ - + + + + + + id="g1170" + transform="rotate(180,57.811382,25.502701)"> + id="path4298-5" + d="m 90.068006,19.946036 c 0,0 -6.534844,-8.078595 -13.203526,2.482874 l -6.073545,-6.527537 c 0,0 10.394152,-8.8791281 19.277071,4.044663 z" + style="color:#000000;display:block;overflow:visible;visibility:visible;fill:url(#linearGradient4306-2);fill-opacity:1;fill-rule:nonzero;stroke:url(#linearGradient4308-2);stroke-width:1.69275;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none" /> + id="path4300-5" + d="M 70.635141,16.312073 C 82.3885,-0.43914709 102.57363,10.215511 104.61129,33.981706 l 8.18527,-0.05259 -14.501586,13.34136 -11.807768,-12.716404 c 0,0 8.648608,-0.157628 8.648608,-0.157628 C 93.405169,17.959137 81.3339,6.0767929 70.635144,16.31207 Z" + style="color:#000000;display:block;overflow:visible;visibility:visible;fill:#8ae234;fill-opacity:1;fill-rule:nonzero;stroke:#172a04;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none" /> + id="g4302-3" + transform="matrix(-0.03999158,-0.76842115,-0.76765118,0.03360048,113.77303,49.969917)" + style="display:inline;fill:#73d216;fill-opacity:1;stroke:#8ae234;stroke-width:0.732809;stroke-opacity:1"> + style="color:#000000;display:block;overflow:visible;visibility:visible;fill:#73d216;fill-opacity:1;stroke:#8ae234;stroke-width:2.20149;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:21;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none" /> + id="g1178"> + style="color:#000000;display:block;overflow:visible;visibility:visible;fill:url(#linearGradient4306);fill-opacity:1;fill-rule:nonzero;stroke:url(#linearGradient4308);stroke-width:1.69275;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none" + d="m 37.856685,0.77245112 c 0,0 -6.534844,-8.07859422 -13.203526,2.48287458 l -6.073545,-6.5275374 c 0,0 10.394152,-8.8791283 19.277071,4.04466282 z" + id="path4298" /> + style="color:#000000;display:block;overflow:visible;visibility:visible;fill:#8ae234;fill-opacity:1;fill-rule:nonzero;stroke:#172a04;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;marker:none" + d="M 18.42382,-2.8615117 C 30.177179,-19.612732 50.362307,-8.958074 52.399971,14.808121 l 8.185264,-0.05259 -14.501582,13.34136 -11.807768,-12.716404 c 0,0 8.648608,-0.157628 8.648608,-0.157628 C 41.193848,-1.2144478 29.122579,-13.096792 18.423823,-2.8615143 Z" + id="path4300" /> - - - - - - - + id="path4304" /> From dac8b8ea6a7af231c4d5d872a56c97123888583e Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Mon, 8 Feb 2021 11:10:41 -0600 Subject: [PATCH 055/178] Allow different splash and about image --- src/Gui/Icons/freecadabout.png | Bin 0 -> 110266 bytes src/Gui/Icons/resource.qrc | 1 + src/Gui/MainWindow.cpp | 22 ++++++++++++++++++++++ src/Gui/MainWindow.h | 2 ++ src/Gui/Splashscreen.cpp | 9 ++++++++- src/Main/MainGui.cpp | 1 + 6 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 src/Gui/Icons/freecadabout.png diff --git a/src/Gui/Icons/freecadabout.png b/src/Gui/Icons/freecadabout.png new file mode 100644 index 0000000000000000000000000000000000000000..bfec76c2cb2d06e7d3b8deee6db77a4039cb4944 GIT binary patch literal 110266 zcmV)EK)}C=P) zaB^>EX>4U6ba`-PAZ2)IW&i+q+O3*tawNHur2pd-eFW@)9mlYV%nj!F{i%~x)%9L= zi}c7OGs(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p index 73956a16f3..0be1e91e8d 100644 --- a/src/Gui/MainWindow.cpp +++ b/src/Gui/MainWindow.cpp @@ -1456,6 +1456,28 @@ void MainWindow::stopSplasher(void) } } +QPixmap MainWindow::aboutImage() const +{ + // See if we have a custom About screen image set + QPixmap about_image; + std::string about_path = App::Application::Config()["AboutImage"]; + if (!about_path.empty()) { + QString path = QString::fromUtf8(about_path.c_str()); + if (QDir(path).isRelative()) { + QString home = QString::fromUtf8(App::GetApplication().getHomePath()); + path = QFileInfo(QDir(home), path).absoluteFilePath(); + } + about_image.load(path); + + // Now try the icon paths + if (about_image.isNull()) { + about_image = Gui::BitmapFactory().pixmap(about_path.c_str()); + } + } + + return about_image; +} + QPixmap MainWindow::splashImage() const { // search in the UserAppData dir as very first diff --git a/src/Gui/MainWindow.h b/src/Gui/MainWindow.h index 17d0eb2b94..3c864eeaf1 100644 --- a/src/Gui/MainWindow.h +++ b/src/Gui/MainWindow.h @@ -135,6 +135,8 @@ public: void startSplasher(void); /** Stops the splasher after startup. */ void stopSplasher(void); + /* The image of the About dialog, it might be empty. */ + QPixmap aboutImage() const; /* The image of the splash screen of the application. */ QPixmap splashImage() const; /** Shows the online documentation. */ diff --git a/src/Gui/Splashscreen.cpp b/src/Gui/Splashscreen.cpp index 00e0913052..6a635f03e7 100644 --- a/src/Gui/Splashscreen.cpp +++ b/src/Gui/Splashscreen.cpp @@ -228,7 +228,14 @@ AboutDialog::AboutDialog(bool showLic, QWidget* parent) ui->setupUi(this); layout()->setSizeConstraint(QLayout::SetFixedSize); QRect rect = QApplication::primaryScreen()->availableGeometry(); - QPixmap image = getMainWindow()->splashImage(); + + // See if we have a custom About screen image set + QPixmap image = getMainWindow()->aboutImage(); + + // Fallback to the splashscreen image + if (image.isNull()) { + image = getMainWindow()->splashImage(); + } // Make sure the image is not too big int denom = 2; diff --git a/src/Main/MainGui.cpp b/src/Main/MainGui.cpp index ebdfe64f7d..47e2e53a3d 100644 --- a/src/Main/MainGui.cpp +++ b/src/Main/MainGui.cpp @@ -176,6 +176,7 @@ int main( int argc, char ** argv ) App::Application::Config()["CopyrightInfo"] = sBanner; App::Application::Config()["AppIcon"] = "freecad"; App::Application::Config()["SplashScreen"] = "freecadsplash"; + App::Application::Config()["AboutImage"] = "freecadabout"; App::Application::Config()["StartWorkbench"] = "StartWorkbench"; //App::Application::Config()["HiddenDockWindow"] = "Property editor"; App::Application::Config()["SplashAlignment" ] = "Bottom|Left"; From 00fc5ae4028004a14192fbb1c0a0b688da2974d1 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 4 Apr 2021 00:12:53 +0200 Subject: [PATCH 056/178] Gui: [skip ci] support user-defined about image --- src/Gui/MainWindow.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Gui/MainWindow.cpp b/src/Gui/MainWindow.cpp index 0be1e91e8d..839bcb2c0b 100644 --- a/src/Gui/MainWindow.cpp +++ b/src/Gui/MainWindow.cpp @@ -1460,8 +1460,12 @@ QPixmap MainWindow::aboutImage() const { // See if we have a custom About screen image set QPixmap about_image; + QFileInfo fi(QString::fromLatin1("images:about_image.png")); + if (fi.isFile() && fi.exists()) + about_image.load(fi.filePath(), "PNG"); + std::string about_path = App::Application::Config()["AboutImage"]; - if (!about_path.empty()) { + if (!about_path.empty() && about_image.isNull()) { QString path = QString::fromUtf8(about_path.c_str()); if (QDir(path).isRelative()) { QString home = QString::fromUtf8(App::GetApplication().getHomePath()); From d3d9d24c610538f58b73b40f0fe5bbefd4108c87 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 4 Apr 2021 11:04:23 +0200 Subject: [PATCH 057/178] Gui: set UTF-8 encoding when reading file with contributors --- src/Gui/Splashscreen.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Gui/Splashscreen.cpp b/src/Gui/Splashscreen.cpp index 6a635f03e7..dbcd3cbd96 100644 --- a/src/Gui/Splashscreen.cpp +++ b/src/Gui/Splashscreen.cpp @@ -410,6 +410,7 @@ void AboutDialog::showCredits() creditsHTML += QString::fromLatin1("

    "); QTextStream stream(&creditsFile); + stream.setCodec("UTF-8"); QString line; while (stream.readLineInto(&line)) { if (!line.isEmpty()) { From d4acb6e48901c6db62349224fff6fbd572686dde Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Skowro=C5=84ski?= Date: Sun, 4 Apr 2021 08:56:52 +0200 Subject: [PATCH 058/178] QDockWidget:AllDockWidgetFeatures is deprecated. Use individual flags instead. --- src/Gui/Control.cpp | 4 +++- src/Gui/DockWindowManager.cpp | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Gui/Control.cpp b/src/Gui/Control.cpp index 791bd836ab..4deff44791 100644 --- a/src/Gui/Control.cpp +++ b/src/Gui/Control.cpp @@ -226,7 +226,9 @@ void ControlSingleton::closedDialog() // make sure that the combo view is shown QDockWidget* dw = qobject_cast(pcComboView->parentWidget()); if (dw) - dw->setFeatures(QDockWidget::AllDockWidgetFeatures); + dw->setFeatures(QDockWidget::DockWidgetClosable + | QDockWidget::DockWidgetMovable + | QDockWidget::DockWidgetFloatable); } bool ControlSingleton::isAllowedAlterDocument(void) const diff --git a/src/Gui/DockWindowManager.cpp b/src/Gui/DockWindowManager.cpp index 4bafc8c099..2e35a9c85c 100644 --- a/src/Gui/DockWindowManager.cpp +++ b/src/Gui/DockWindowManager.cpp @@ -155,7 +155,9 @@ QDockWidget* DockWindowManager::addDockWindow(const char* name, QWidget* widget, // set object name and window title needed for i18n stuff dw->setObjectName(QLatin1String(name)); dw->setWindowTitle(QDockWidget::tr(name)); - dw->setFeatures(QDockWidget::AllDockWidgetFeatures); + dw->setFeatures(QDockWidget::DockWidgetClosable + | QDockWidget::DockWidgetMovable + | QDockWidget::DockWidgetFloatable); d->_dockedWindows.push_back(dw); return dw; From 5032a8e31fedeec555a8dddde2917a1e4c19f933 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Skowro=C5=84ski?= Date: Sun, 4 Apr 2021 08:59:24 +0200 Subject: [PATCH 059/178] Qt::MidButton is deprecated. Use Qt::MiddleButton instead. --- src/Gui/PythonConsole.cpp | 2 +- src/Gui/Quarter/Mouse.cpp | 2 +- src/Mod/Image/Gui/ImageView.cpp | 6 +++--- src/Mod/Web/Gui/BrowserView.cpp | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Gui/PythonConsole.cpp b/src/Gui/PythonConsole.cpp index 42b5c304db..16212fcc30 100644 --- a/src/Gui/PythonConsole.cpp +++ b/src/Gui/PythonConsole.cpp @@ -963,7 +963,7 @@ void PythonConsole::changeEvent(QEvent *e) void PythonConsole::mouseReleaseEvent( QMouseEvent *e ) { - if (e->button() == Qt::MidButton && e->spontaneous()) + if (e->button() == Qt::MiddleButton && e->spontaneous()) { // on Linux-like systems the middle mouse button is typically connected to a paste operation // which will insert some text at the mouse position diff --git a/src/Gui/Quarter/Mouse.cpp b/src/Gui/Quarter/Mouse.cpp index ee832510e2..6667dee6bd 100644 --- a/src/Gui/Quarter/Mouse.cpp +++ b/src/Gui/Quarter/Mouse.cpp @@ -206,7 +206,7 @@ MouseP::mouseButtonEvent(QMouseEvent * event) case Qt::RightButton: this->mousebutton->setButton(SoMouseButtonEvent::BUTTON2); break; - case Qt::MidButton: + case Qt::MiddleButton: this->mousebutton->setButton(SoMouseButtonEvent::BUTTON3); break; default: diff --git a/src/Mod/Image/Gui/ImageView.cpp b/src/Mod/Image/Gui/ImageView.cpp index 3cd607f449..36e7d5dc81 100644 --- a/src/Mod/Image/Gui/ImageView.cpp +++ b/src/Mod/Image/Gui/ImageView.cpp @@ -358,12 +358,12 @@ void ImageView::mousePressEvent(QMouseEvent* cEvent) _currY = box_y; switch(cEvent->buttons()) { - case Qt::MidButton: + case Qt::MiddleButton: _currMode = panning; this->setCursor(QCursor(Qt::ClosedHandCursor)); startDrag(); break; - //case Qt::LeftButton | Qt::MidButton: + //case Qt::LeftButton | Qt::MiddleButton: // _currMode = zooming; // break; case Qt::LeftButton: @@ -392,7 +392,7 @@ void ImageView::mouseDoubleClickEvent(QMouseEvent* cEvent) int box_y = cEvent->y() - offset.y(); _currX = box_x; _currY = box_y; - if(cEvent->button() == Qt::MidButton) + if(cEvent->button() == Qt::MiddleButton) { double icX = _pGLImageBox->WCToIC_X(_currX); double icY = _pGLImageBox->WCToIC_Y(_currY); diff --git a/src/Mod/Web/Gui/BrowserView.cpp b/src/Mod/Web/Gui/BrowserView.cpp index ae3e964039..0c776f066b 100644 --- a/src/Mod/Web/Gui/BrowserView.cpp +++ b/src/Mod/Web/Gui/BrowserView.cpp @@ -247,7 +247,7 @@ WebView::WebView(QWidget *parent) void WebView::mousePressEvent(QMouseEvent *event) { #ifdef QTWEBKIT - if (event->button() == Qt::MidButton) { + if (event->button() == Qt::MiddleButton) { QWebHitTestResult r = page()->mainFrame()->hitTestContent(event->pos()); if (!r.linkUrl().isEmpty()) { openLinkInNewWindow(r.linkUrl()); From 252d30e40f8deaf988b94fefcb3fa4632c4c5998 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Skowro=C5=84ski?= Date: Sun, 4 Apr 2021 09:02:08 +0200 Subject: [PATCH 060/178] QPainter::HighQualityAntialiasing is deprecated. Use QPainter::Antialiasing instead. --- src/Mod/TechDraw/Gui/QGVPage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/TechDraw/Gui/QGVPage.cpp b/src/Mod/TechDraw/Gui/QGVPage.cpp index fc43dd8961..d2967747c2 100644 --- a/src/Mod/TechDraw/Gui/QGVPage.cpp +++ b/src/Mod/TechDraw/Gui/QGVPage.cpp @@ -746,7 +746,7 @@ void QGVPage::setRenderer(RendererType type) void QGVPage::setHighQualityAntialiasing(bool highQualityAntialiasing) { #ifndef QT_NO_OPENGL - setRenderHint(QPainter::HighQualityAntialiasing, highQualityAntialiasing); + setRenderHint(QPainter::Antialiasing, highQualityAntialiasing); #else Q_UNUSED(highQualityAntialiasing); #endif From c48ec7cff2137051991c67885d9ae2cb4b1f7fbc Mon Sep 17 00:00:00 2001 From: tomate44 Date: Mon, 5 Apr 2021 12:20:04 +0200 Subject: [PATCH 061/178] Draft.ShapeString : add option to choose wires or faces output --- src/Mod/Draft/draftobjects/shapestring.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/Mod/Draft/draftobjects/shapestring.py b/src/Mod/Draft/draftobjects/shapestring.py index bcbdcb1c66..c150ee36ea 100644 --- a/src/Mod/Draft/draftobjects/shapestring.py +++ b/src/Mod/Draft/draftobjects/shapestring.py @@ -55,6 +55,9 @@ class ShapeString(DraftObject): _tip = QT_TRANSLATE_NOOP("App::Property", "Inter-character spacing") obj.addProperty("App::PropertyLength", "Tracking", "Draft", _tip) + _tip = QT_TRANSLATE_NOOP("App::Property", "Fill letters") + obj.addProperty("App::PropertyBool", "FillLetters", "Draft", _tip).FillLetters = True + def execute(self, obj): import Part # import OpenSCAD2Dgeom @@ -91,8 +94,12 @@ class ShapeString(DraftObject): else: sticky = True + fill = True + if hasattr(obj, "FillLetters"): + fill = obj.FillLetters + for char in CharList: - if sticky: + if sticky or (not fill): for CWire in char: SSChars.append(CWire) else: From fd7d4c91e8e9f11954004d29248f48e5d37ae649 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 5 Apr 2021 13:05:59 +0200 Subject: [PATCH 062/178] Part: implement Prism as extension --- src/Mod/Part/App/AppPart.cpp | 3 ++ src/Mod/Part/App/CMakeLists.txt | 2 + src/Mod/Part/App/PrismExtension.cpp | 79 +++++++++++++++++++++++++++++ src/Mod/Part/App/PrismExtension.h | 55 ++++++++++++++++++++ 4 files changed, 139 insertions(+) create mode 100644 src/Mod/Part/App/PrismExtension.cpp create mode 100644 src/Mod/Part/App/PrismExtension.h diff --git a/src/Mod/Part/App/AppPart.cpp b/src/Mod/Part/App/AppPart.cpp index 8fe6ca350b..903e9e8e8f 100644 --- a/src/Mod/Part/App/AppPart.cpp +++ b/src/Mod/Part/App/AppPart.cpp @@ -147,6 +147,7 @@ #include "DatumFeature.h" #include "Attacher.h" #include "AttachExtension.h" +#include "PrismExtension.h" #include "FaceMaker.h" #include "FaceMakerCheese.h" #include "FaceMakerBullseye.h" @@ -346,6 +347,8 @@ PyMOD_INIT_FUNC(Part) Part::AttachExtension ::init(); Part::AttachExtensionPython ::init(); + Part::PrismExtension ::init(); + Part::Feature ::init(); Part::FeatureExt ::init(); Part::BodyBase ::init(); diff --git a/src/Mod/Part/App/CMakeLists.txt b/src/Mod/Part/App/CMakeLists.txt index 9adfcf8e3f..67478980de 100644 --- a/src/Mod/Part/App/CMakeLists.txt +++ b/src/Mod/Part/App/CMakeLists.txt @@ -188,6 +188,8 @@ SET(Features_SRCS DatumFeature.h AttachExtension.h AttachExtension.cpp + PrismExtension.cpp + PrismExtension.h ) SOURCE_GROUP("Features" FILES ${Features_SRCS}) diff --git a/src/Mod/Part/App/PrismExtension.cpp b/src/Mod/Part/App/PrismExtension.cpp new file mode 100644 index 0000000000..e6b020442c --- /dev/null +++ b/src/Mod/Part/App/PrismExtension.cpp @@ -0,0 +1,79 @@ +/*************************************************************************** + * Copyright (c) 2021 Werner Mayer * + * * + * 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 +#endif + +#include "PrismExtension.h" +#include + + +using namespace Part; + +EXTENSION_PROPERTY_SOURCE(Part::PrismExtension, App::DocumentObjectExtension) + +PrismExtension::PrismExtension() +{ + EXTENSION_ADD_PROPERTY_TYPE(FirstAngle, (0.0f), "Prism", App::Prop_None, "Angle in first direction"); + EXTENSION_ADD_PROPERTY_TYPE(SecondAngle, (0.0f), "Prism", App::Prop_None, "Angle in second direction"); + + static const App::PropertyQuantityConstraint::Constraints angleConstraint = { -89.99999, 89.99999, 1.0 }; + FirstAngle.setConstraints(&angleConstraint); + SecondAngle.setConstraints(&angleConstraint); + + initExtensionType(PrismExtension::getExtensionClassTypeId()); +} + +PrismExtension::~PrismExtension() +{ +} + +short int PrismExtension::extensionMustExecute() +{ + if (FirstAngle.isTouched()) + return 1; + if (SecondAngle.isTouched()) + return 1; + return DocumentObjectExtension::extensionMustExecute(); +} + +App::DocumentObjectExecReturn *PrismExtension::extensionExecute() +{ + return App::DocumentObjectExtension::extensionExecute(); +} + +void PrismExtension::extensionOnChanged(const App::Property* prop) +{ + App::DocumentObjectExtension::extensionOnChanged(prop); +} + +TopoDS_Shape PrismExtension::makePrism(double height, const TopoDS_Face& face) const +{ + // the direction vector for the prism is the height for z and the given angle + BRepPrimAPI_MakePrism mkPrism(face, + gp_Vec(height * tan(Base::toRadians(FirstAngle.getValue())), + height * tan(Base::toRadians(SecondAngle.getValue())), + height)); + return mkPrism.Shape(); +} diff --git a/src/Mod/Part/App/PrismExtension.h b/src/Mod/Part/App/PrismExtension.h new file mode 100644 index 0000000000..42294ddde3 --- /dev/null +++ b/src/Mod/Part/App/PrismExtension.h @@ -0,0 +1,55 @@ +/*************************************************************************** + * Copyright (c) 2021 Werner Mayer * + * * + * 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 PART_PRISM_EXTENSION_H +#define PART_PRISM_EXTENSION_H + +#include +#include +#include + +namespace Part +{ + +class PartExport PrismExtension : public App::DocumentObjectExtension +{ + EXTENSION_PROPERTY_HEADER(Part::PrismExtension); +public: + PrismExtension(); + virtual ~PrismExtension(); + + + App::PropertyAngle FirstAngle; + App::PropertyAngle SecondAngle; + + TopoDS_Shape makePrism(double height, const TopoDS_Face& face) const; + + virtual short int extensionMustExecute(void); + virtual App::DocumentObjectExecReturn *extensionExecute(void); + +protected: + virtual void extensionOnChanged(const App::Property* /*prop*/); +}; + +} // namespace Part + +#endif // PART_PRISM_EXTENSION_H From 2b09a3ebeca82305a0319343bc1cbabb54b92bbc Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 5 Apr 2021 13:25:19 +0200 Subject: [PATCH 063/178] Part: for Prism feature use PrismExtension --- src/Mod/Part/App/PrimitiveFeature.cpp | 17 +++-------------- src/Mod/Part/App/PrimitiveFeature.h | 6 +++--- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/src/Mod/Part/App/PrimitiveFeature.cpp b/src/Mod/Part/App/PrimitiveFeature.cpp index e95e1bc7b4..fdb9630bd2 100644 --- a/src/Mod/Part/App/PrimitiveFeature.cpp +++ b/src/Mod/Part/App/PrimitiveFeature.cpp @@ -573,12 +573,9 @@ Prism::Prism(void) ADD_PROPERTY_TYPE(Polygon, (6.0), "Prism", App::Prop_None, "Number of sides in the polygon, of the prism"); ADD_PROPERTY_TYPE(Circumradius, (2.0), "Prism", App::Prop_None, "Circumradius (centre to vertex) of the polygon, of the prism"); ADD_PROPERTY_TYPE(Height, (10.0f), "Prism", App::Prop_None, "The height of the prism"); - ADD_PROPERTY_TYPE(FirstAngle, (0.0f), "Prism", App::Prop_None, "Angle in first direction"); - ADD_PROPERTY_TYPE(SecondAngle, (0.0f), "Prism", App::Prop_None, "Angle in second direction"); Polygon.setConstraints(&polygonRange); - static const App::PropertyQuantityConstraint::Constraints angleConstraint = { -89.99999, 89.99999, 1.0 }; - FirstAngle.setConstraints(&angleConstraint); - SecondAngle.setConstraints(&angleConstraint); + + PrismExtension::initExtension(this); } short Prism::mustExecute() const @@ -589,10 +586,6 @@ short Prism::mustExecute() const return 1; if (Height.isTouched()) return 1; - if (FirstAngle.isTouched()) - return 1; - if (SecondAngle.isTouched()) - return 1; return Primitive::mustExecute(); } @@ -621,11 +614,7 @@ App::DocumentObjectExecReturn *Prism::execute(void) mkPoly.Add(gp_Pnt(v.x,v.y,v.z)); BRepBuilderAPI_MakeFace mkFace(mkPoly.Wire()); // the direction vector for the prism is the height for z and the given angle - BRepPrimAPI_MakePrism mkPrism(mkFace.Face(), - gp_Vec(Height.getValue() * tan(Base::toRadians(FirstAngle.getValue())), - Height.getValue() * tan(Base::toRadians(SecondAngle.getValue())), - Height.getValue())); - this->Shape.setValue(mkPrism.Shape()); + this->Shape.setValue(makePrism(Height.getValue(), mkFace.Face())); } catch (Standard_Failure& e) { return new App::DocumentObjectExecReturn(e.GetMessageString()); diff --git a/src/Mod/Part/App/PrimitiveFeature.h b/src/Mod/Part/App/PrimitiveFeature.h index 9f8f150802..c32009903c 100644 --- a/src/Mod/Part/App/PrimitiveFeature.h +++ b/src/Mod/Part/App/PrimitiveFeature.h @@ -27,6 +27,7 @@ #include #include "PartFeature.h" #include "AttachExtension.h" +#include "PrismExtension.h" namespace Part { @@ -199,7 +200,8 @@ public: //@} }; -class PartExport Prism : public Primitive +class PartExport Prism : public Primitive, + public PrismExtension { PROPERTY_HEADER(Part::Prism); @@ -209,8 +211,6 @@ public: App::PropertyIntegerConstraint Polygon; App::PropertyLength Circumradius; App::PropertyLength Height; - App::PropertyAngle FirstAngle; - App::PropertyAngle SecondAngle; /** @name methods override feature */ //@{ From 021f42f82890ef5e2feee820a00513a52ea25692 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 5 Apr 2021 13:25:36 +0200 Subject: [PATCH 064/178] PartDesign: for Prism feature use PrismExtension --- src/Mod/PartDesign/App/FeaturePrimitive.cpp | 18 ++++-------------- src/Mod/PartDesign/App/FeaturePrimitive.h | 11 +++-------- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/src/Mod/PartDesign/App/FeaturePrimitive.cpp b/src/Mod/PartDesign/App/FeaturePrimitive.cpp index f8f79bfea2..444b61ddc2 100644 --- a/src/Mod/PartDesign/App/FeaturePrimitive.cpp +++ b/src/Mod/PartDesign/App/FeaturePrimitive.cpp @@ -553,11 +553,8 @@ Prism::Prism() ADD_PROPERTY_TYPE(Polygon, (6.0), "Prism", App::Prop_None, "Number of sides in the polygon, of the prism"); ADD_PROPERTY_TYPE(Circumradius, (2.0), "Prism", App::Prop_None, "Circumradius (centre to vertex) of the polygon, of the prism"); ADD_PROPERTY_TYPE(Height, (10.0f), "Prism", App::Prop_None, "The height of the prism"); - ADD_PROPERTY_TYPE(FirstAngle, (0.0f), "Prism", App::Prop_None, "Angle in first direction"); - ADD_PROPERTY_TYPE(SecondAngle, (0.0f), "Prism", App::Prop_None, "Angle in second direction"); - static const App::PropertyQuantityConstraint::Constraints angleConstraint = { -89.99999, 89.99999, 1.0 }; - FirstAngle.setConstraints(&angleConstraint); - SecondAngle.setConstraints(&angleConstraint); + + Part::PrismExtension::initExtension(this); primitiveType = FeaturePrimitive::Prism; } @@ -587,11 +584,8 @@ App::DocumentObjectExecReturn* Prism::execute(void) mkPoly.Add(gp_Pnt(v.x,v.y,v.z)); BRepBuilderAPI_MakeFace mkFace(mkPoly.Wire()); // the direction vector for the prism is the height for z and the given angle - BRepPrimAPI_MakePrism mkPrism(mkFace.Face(), - gp_Vec(Height.getValue() * tan(Base::toRadians(FirstAngle.getValue())), - Height.getValue() * tan(Base::toRadians(SecondAngle.getValue())), - Height.getValue())); - return FeaturePrimitive::execute(mkPrism.Shape()); + TopoDS_Shape prism = makePrism(Height.getValue(), mkFace.Face()); + return FeaturePrimitive::execute(prism); } catch (Standard_Failure& e) { return new App::DocumentObjectExecReturn(e.GetMessageString()); @@ -608,10 +602,6 @@ short int Prism::mustExecute() const return 1; if (Height.isTouched()) return 1; - if (FirstAngle.isTouched()) - return 1; - if (SecondAngle.isTouched()) - return 1; return FeaturePrimitive::mustExecute(); } diff --git a/src/Mod/PartDesign/App/FeaturePrimitive.h b/src/Mod/PartDesign/App/FeaturePrimitive.h index 7d6d7d4408..6b4dc7a713 100644 --- a/src/Mod/PartDesign/App/FeaturePrimitive.h +++ b/src/Mod/PartDesign/App/FeaturePrimitive.h @@ -29,6 +29,7 @@ #include "FeatureAddSub.h" #include +#include namespace PartDesign { @@ -307,28 +308,22 @@ class PartDesignExport SubtractiveTorus : public Torus { }; -class PartDesignExport Prism : public PartDesign::FeaturePrimitive { +class PartDesignExport Prism : public PartDesign::FeaturePrimitive, public Part::PrismExtension { PROPERTY_HEADER(PartDesign::Prism); public: - Prism(); - + App::PropertyIntegerConstraint Polygon; App::PropertyLength Circumradius; App::PropertyLength Height; - App::PropertyAngle FirstAngle; - App::PropertyAngle SecondAngle; /** @name methods override feature */ //@{ /// recalculate the Feature App::DocumentObjectExecReturn *execute(void); short mustExecute() const; - -protected: - }; class PartDesignExport AdditivePrism : public Prism { From 1f0e0f3e2141aa650884cb2a7e15351d328f8302 Mon Sep 17 00:00:00 2001 From: donovaly Date: Mon, 5 Apr 2021 13:59:03 +0200 Subject: [PATCH 065/178] [Part] add direction to cylinder primitive We already have the possibility to create skewed prisms. I recently stumbled upon that I would need this feature for cylinders too. This PR takes the existing prism extrude direction feature and use it for cylinders too --- src/Mod/Part/App/PrimitiveFeature.cpp | 11 +++++- src/Mod/Part/App/PrimitiveFeature.h | 3 +- src/Mod/Part/Gui/DlgPrimitives.cpp | 20 +++++++++- src/Mod/Part/Gui/DlgPrimitives.ui | 54 ++++++++++++++++++++++++++- 4 files changed, 82 insertions(+), 6 deletions(-) diff --git a/src/Mod/Part/App/PrimitiveFeature.cpp b/src/Mod/Part/App/PrimitiveFeature.cpp index fdb9630bd2..8d2dc9989f 100644 --- a/src/Mod/Part/App/PrimitiveFeature.cpp +++ b/src/Mod/Part/App/PrimitiveFeature.cpp @@ -30,6 +30,7 @@ # include # include # include +# include # include # include # include @@ -529,6 +530,8 @@ Cylinder::Cylinder(void) ADD_PROPERTY_TYPE(Height,(10.0f),"Cylinder",App::Prop_None,"The height of the cylinder"); ADD_PROPERTY_TYPE(Angle,(360.0f),"Cylinder",App::Prop_None,"The angle of the cylinder"); Angle.setConstraints(&angleRangeU); + + PrismExtension::initExtension(this); } short Cylinder::mustExecute() const @@ -549,11 +552,15 @@ App::DocumentObjectExecReturn *Cylinder::execute(void) return new App::DocumentObjectExecReturn("Radius of cylinder too small"); if (Height.getValue() < Precision::Confusion()) return new App::DocumentObjectExecReturn("Height of cylinder too small"); + if (Angle.getValue() < Precision::Confusion()) + return new App::DocumentObjectExecReturn("Rotation angle of cylinder too small"); try { BRepPrimAPI_MakeCylinder mkCylr(Radius.getValue(), Height.getValue(), - Angle.getValue()/180.0f*M_PI); - TopoDS_Shape ResultShape = mkCylr.Shape(); + Base::toRadians(Angle.getValue())); + // the direction vector for the prism is the height for z and the given angle + BRepPrim_Cylinder prim = mkCylr.Cylinder(); + TopoDS_Shape ResultShape = makePrism(Height.getValue(), prim.BottomFace()); this->Shape.setValue(ResultShape); } catch (Standard_Failure& e) { diff --git a/src/Mod/Part/App/PrimitiveFeature.h b/src/Mod/Part/App/PrimitiveFeature.h index c32009903c..e9cd075e72 100644 --- a/src/Mod/Part/App/PrimitiveFeature.h +++ b/src/Mod/Part/App/PrimitiveFeature.h @@ -177,7 +177,8 @@ public: } }; -class PartExport Cylinder : public Primitive +class PartExport Cylinder : public Primitive, + public PrismExtension { PROPERTY_HEADER(Part::Cylinder); diff --git a/src/Mod/Part/Gui/DlgPrimitives.cpp b/src/Mod/Part/Gui/DlgPrimitives.cpp index b62a36ce37..ce19072f44 100644 --- a/src/Mod/Part/Gui/DlgPrimitives.cpp +++ b/src/Mod/Part/Gui/DlgPrimitives.cpp @@ -358,6 +358,10 @@ DlgPrimitives::DlgPrimitives(QWidget* parent, Part::Primitive* feature) ui->cylinderRadius->bind(cyl->Radius); ui->cylinderHeight->setValue(cyl->Height.getQuantityValue()); ui->cylinderHeight->bind(cyl->Height); + ui->cylinderXSkew->setValue(cyl->FirstAngle.getQuantityValue()); + ui->cylinderXSkew->bind(cyl->FirstAngle); + ui->cylinderYSkew->setValue(cyl->SecondAngle.getQuantityValue()); + ui->cylinderYSkew->bind(cyl->SecondAngle); ui->cylinderAngle->setValue(cyl->Angle.getQuantityValue()); ui->cylinderAngle->bind(cyl->Angle); @@ -365,6 +369,8 @@ DlgPrimitives::DlgPrimitives(QWidget* parent, Part::Primitive* feature) connect(mapper, SIGNAL(mapped(QWidget*)), this, SLOT(onChangeCylinder(QWidget*))); connectSignalMapper(ui->cylinderRadius, SIGNAL(valueChanged(double)), mapper); connectSignalMapper(ui->cylinderHeight, SIGNAL(valueChanged(double)), mapper); + connectSignalMapper(ui->cylinderXSkew, SIGNAL(valueChanged(double)), mapper); + connectSignalMapper(ui->cylinderYSkew, SIGNAL(valueChanged(double)), mapper); connectSignalMapper(ui->cylinderAngle, SIGNAL(valueChanged(double)), mapper); } else if (type == Part::Cone::getClassTypeId()) { @@ -744,12 +750,16 @@ QString DlgPrimitives::createCylinder(const QString& objectName, const QString& "App.ActiveDocument.%1.Radius=%2\n" "App.ActiveDocument.%1.Height=%3\n" "App.ActiveDocument.%1.Angle=%4\n" - "App.ActiveDocument.%1.Placement=%5\n" - "App.ActiveDocument.%1.Label='%6'\n") + "App.ActiveDocument.%1.FirstAngle=%5\n" + "App.ActiveDocument.%1.SecondAngle=%6\n" + "App.ActiveDocument.%1.Placement=%7\n" + "App.ActiveDocument.%1.Label='%8'\n") .arg(objectName) .arg(ui->cylinderRadius->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) .arg(ui->cylinderHeight->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) .arg(ui->cylinderAngle->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) + .arg(ui->cylinderXSkew->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) + .arg(ui->cylinderYSkew->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) .arg(placement) .arg(tr("Cylinder")); } @@ -1494,6 +1504,12 @@ void DlgPrimitives::onChangeCylinder(QWidget* widget) else if (widget == ui->cylinderAngle) { cyl->Angle.setValue(ui->cylinderAngle->value().getValue()); } + else if (widget == ui->cylinderXSkew) { + cyl->FirstAngle.setValue(ui->cylinderXSkew->value().getValue()); + } + else if (widget == ui->cylinderYSkew) { + cyl->SecondAngle.setValue(ui->cylinderYSkew->value().getValue()); + } cyl->recomputeFeature(); } diff --git a/src/Mod/Part/Gui/DlgPrimitives.ui b/src/Mod/Part/Gui/DlgPrimitives.ui index f3b661d254..d912cf9556 100644 --- a/src/Mod/Part/Gui/DlgPrimitives.ui +++ b/src/Mod/Part/Gui/DlgPrimitives.ui @@ -442,7 +442,7 @@ - Angle: + Rotation angle: @@ -544,6 +544,58 @@ + + + + Angle in first direction: + + + + + + + Angle in first direction + + + false + + + deg + + + -90.000000000000000 + + + 90.000000000000000 + + + + + + + Angle in second direction: + + + + + + + Angle in second direction + + + false + + + deg + + + -90.000000000000000 + + + 90.000000000000000 + + + From 0369bc08536c0ca88744f6e9b013d524fab98f27 Mon Sep 17 00:00:00 2001 From: donovaly Date: Mon, 5 Apr 2021 14:35:50 +0200 Subject: [PATCH 066/178] [PartDesign] add direction to cylinder primitive We already have the possibility to create skewed prisms. I recently stumbled upon that I would need this feature for cylinders too. This PR takes the existing prism extrude direction feature and use it for cylinders too --- src/Mod/PartDesign/App/FeaturePrimitive.cpp | 13 +++- src/Mod/PartDesign/App/FeaturePrimitive.h | 5 +- .../Gui/TaskPrimitiveParameters.cpp | 48 ++++++++++++- .../PartDesign/Gui/TaskPrimitiveParameters.h | 2 + .../PartDesign/Gui/TaskPrimitiveParameters.ui | 68 ++++++++++++++++--- 5 files changed, 120 insertions(+), 16 deletions(-) diff --git a/src/Mod/PartDesign/App/FeaturePrimitive.cpp b/src/Mod/PartDesign/App/FeaturePrimitive.cpp index 444b61ddc2..b97eb878dd 100644 --- a/src/Mod/PartDesign/App/FeaturePrimitive.cpp +++ b/src/Mod/PartDesign/App/FeaturePrimitive.cpp @@ -33,6 +33,7 @@ # include # include # include +# include # include # include # include @@ -242,6 +243,8 @@ Cylinder::Cylinder() Radius.setConstraints(&quantityRange); Height.setConstraints(&quantityRange); + Part::PrismExtension::initExtension(this); + primitiveType = FeaturePrimitive::Cylinder; } @@ -252,12 +255,18 @@ App::DocumentObjectExecReturn* Cylinder::execute(void) return new App::DocumentObjectExecReturn("Radius of cylinder too small"); if (Height.getValue() < Precision::Confusion()) return new App::DocumentObjectExecReturn("Height of cylinder too small"); + if (Angle.getValue() < Precision::Confusion()) + return new App::DocumentObjectExecReturn("Rotation angle of cylinder too small"); try { BRepPrimAPI_MakeCylinder mkCylr(Radius.getValue(), Height.getValue(), - Angle.getValue()/180.0f*M_PI); + Base::toRadians(Angle.getValue())); - return FeaturePrimitive::execute(mkCylr.Shape()); + // the direction vector for the prism is the height for z and the given angle + BRepPrim_Cylinder prim = mkCylr.Cylinder(); + TopoDS_Shape result = makePrism(Height.getValue(), prim.BottomFace()); + + return FeaturePrimitive::execute(result); } catch (Standard_Failure& e) { diff --git a/src/Mod/PartDesign/App/FeaturePrimitive.h b/src/Mod/PartDesign/App/FeaturePrimitive.h index 6b4dc7a713..1c8a656369 100644 --- a/src/Mod/PartDesign/App/FeaturePrimitive.h +++ b/src/Mod/PartDesign/App/FeaturePrimitive.h @@ -107,7 +107,7 @@ class PartDesignExport SubtractiveBox : public Box { }; -class PartDesignExport Cylinder : public PartDesign::FeaturePrimitive { +class PartDesignExport Cylinder : public PartDesign::FeaturePrimitive, public Part::PrismExtension { PROPERTY_HEADER(PartDesign::Cylinder); @@ -124,9 +124,6 @@ public: /// recalculate the Feature App::DocumentObjectExecReturn *execute(void); short mustExecute() const; - -protected: - }; class PartDesignExport AdditiveCylinder : public Cylinder { diff --git a/src/Mod/PartDesign/Gui/TaskPrimitiveParameters.cpp b/src/Mod/PartDesign/Gui/TaskPrimitiveParameters.cpp index e9a4e8923f..c8f9e40f89 100644 --- a/src/Mod/PartDesign/Gui/TaskPrimitiveParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPrimitiveParameters.cpp @@ -87,6 +87,10 @@ TaskBoxPrimitives::TaskBoxPrimitives(ViewProviderPrimitive* vp, QWidget* parent) ui->cylinderHeight->bind(static_cast(vp->getObject())->Height); ui->cylinderRadius->setValue(static_cast(vp->getObject())->Radius.getValue()); ui->cylinderRadius->bind(static_cast(vp->getObject())->Radius); + ui->cylinderXSkew->setValue(static_cast(vp->getObject())->FirstAngle.getValue()); + ui->cylinderXSkew->bind(static_cast(vp->getObject())->FirstAngle); + ui->cylinderYSkew->setValue(static_cast(vp->getObject())->SecondAngle.getValue()); + ui->cylinderYSkew->bind(static_cast(vp->getObject())->SecondAngle); ui->cylinderAngle->setMaximum(static_cast(vp->getObject())->Angle.getMaximum()); ui->cylinderAngle->setMinimum(static_cast(vp->getObject())->Angle.getMinimum()); ui->cylinderHeight->setMaximum(INT_MAX); @@ -278,6 +282,8 @@ TaskBoxPrimitives::TaskBoxPrimitives(ViewProviderPrimitive* vp, QWidget* parent) // cylinder connect(ui->cylinderRadius, SIGNAL(valueChanged(double)), this, SLOT(onCylinderRadiusChanged(double))); connect(ui->cylinderHeight, SIGNAL(valueChanged(double)), this, SLOT(onCylinderHeightChanged(double))); + connect(ui->cylinderXSkew, SIGNAL(valueChanged(double)), this, SLOT(onCylinderXSkewChanged(double))); + connect(ui->cylinderYSkew, SIGNAL(valueChanged(double)), this, SLOT(onCylinderYSkewChanged(double))); connect(ui->cylinderAngle, SIGNAL(valueChanged(double)), this, SLOT(onCylinderAngleChanged(double))); // cone @@ -388,6 +394,40 @@ void TaskBoxPrimitives::onCylinderRadiusChanged(double v) { vp->getObject()->getDocument()->recomputeFeature(vp->getObject()); } +void TaskBoxPrimitives::onCylinderXSkewChanged(double v) { + PartDesign::Cylinder* cyl = static_cast(vp->getObject()); + // we must assure that if the user incremented from e.g. 85 degree with the + // spin buttons he does not end at 90.0 but 89.9999 which is shown rounded to 90 degree + if ((v < 90.0) && (v > -90.0)) { + cyl->FirstAngle.setValue(v); + } + else { + if (v == 90.0) + cyl->FirstAngle.setValue(cyl->FirstAngle.getMaximum()); + else if (v == -90.0) + cyl->FirstAngle.setValue(cyl->FirstAngle.getMinimum()); + ui->cylinderXSkew->setValue(cyl->FirstAngle.getQuantityValue()); + } + vp->getObject()->getDocument()->recomputeFeature(vp->getObject()); +} + +void TaskBoxPrimitives::onCylinderYSkewChanged(double v) { + PartDesign::Cylinder* cyl = static_cast(vp->getObject()); + // we must assure that if the user incremented from e.g. 85 degree with the + // spin buttons he does not end at 90.0 but 89.9999 which is shown rounded to 90 degree + if ((v < 90.0) && (v > -90.0)) { + cyl->SecondAngle.setValue(v); + } + else { + if (v == 90.0) + cyl->SecondAngle.setValue(cyl->SecondAngle.getMaximum()); + else if (v == -90.0) + cyl->SecondAngle.setValue(cyl->SecondAngle.getMinimum()); + ui->cylinderYSkew->setValue(cyl->SecondAngle.getQuantityValue()); + } + vp->getObject()->getDocument()->recomputeFeature(vp->getObject()); +} + void TaskBoxPrimitives::onSphereAngle1Changed(double v) { PartDesign::Sphere* sph = static_cast(vp->getObject()); ui->sphereAngle2->setMinimum(v); // Angle1 must geometrically be <= than Angle2 @@ -665,11 +705,15 @@ void TaskBoxPrimitives::setPrimitive(App::DocumentObject *obj) cmd = QString::fromLatin1( "%1.Radius=%2\n" "%1.Height=%3\n" - "%1.Angle=%4\n") + "%1.Angle=%4\n" + "%1.FirstAngle=%5\n" + "%1.SecondAngle=%6\n") .arg(name) .arg(ui->cylinderRadius->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) .arg(ui->cylinderHeight->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->cylinderAngle->value().getValue(),0,'f',Base::UnitsApi::getDecimals()); + .arg(ui->cylinderAngle->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) + .arg(ui->cylinderXSkew->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) + .arg(ui->cylinderYSkew->value().getValue(),0,'f',Base::UnitsApi::getDecimals()); break; case 3: // cone diff --git a/src/Mod/PartDesign/Gui/TaskPrimitiveParameters.h b/src/Mod/PartDesign/Gui/TaskPrimitiveParameters.h index 0049d2017f..11c079fc2f 100644 --- a/src/Mod/PartDesign/Gui/TaskPrimitiveParameters.h +++ b/src/Mod/PartDesign/Gui/TaskPrimitiveParameters.h @@ -63,6 +63,8 @@ public Q_SLOTS: void onBoxHeightChanged(double); void onCylinderRadiusChanged(double); void onCylinderHeightChanged(double); + void onCylinderXSkewChanged(double); + void onCylinderYSkewChanged(double); void onCylinderAngleChanged(double); void onSphereRadiusChanged(double); void onSphereAngle1Changed(double); diff --git a/src/Mod/PartDesign/Gui/TaskPrimitiveParameters.ui b/src/Mod/PartDesign/Gui/TaskPrimitiveParameters.ui index bcacdbd4dd..ba04ef99e8 100644 --- a/src/Mod/PartDesign/Gui/TaskPrimitiveParameters.ui +++ b/src/Mod/PartDesign/Gui/TaskPrimitiveParameters.ui @@ -264,7 +264,7 @@ - Angle: + Rotation angle: @@ -333,6 +333,19 @@ + + + + false + + + mm + + + 2.000000000000000 + + + @@ -353,16 +366,55 @@ - - + + + + Angle in first direction: + + + + + + + Angle in first direction + false - mm + deg - - 2.000000000000000 + + -90.000000000000000 + + + 90.000000000000000 + + + + + + + Angle in second direction: + + + + + + + Angle in second direction + + + false + + + deg + + + -90.000000000000000 + + + 90.000000000000000 @@ -1201,7 +1253,7 @@ - + Angle in first direction: @@ -1227,7 +1279,7 @@ - + Angle in second direction: From 751399892ad6f645f257607729f4c69a34513e93 Mon Sep 17 00:00:00 2001 From: luz paz Date: Mon, 5 Apr 2021 07:33:17 -0400 Subject: [PATCH 067/178] [TD] icon uniformity for ActiveView and FaceCenterLine commands Renamed SVGs, saved as plain svg, updated appropriate areas in the source code --- src/Mod/TechDraw/Gui/Command.cpp | 2 +- src/Mod/TechDraw/Gui/CommandAnnotate.cpp | 4 +- src/Mod/TechDraw/Gui/Resources/TechDraw.qrc | 4 +- ...ActiveView.svg => TechDraw_ActiveView.svg} | 33 +------ ...erline.svg => TechDraw_FaceCenterLine.svg} | 98 +++---------------- src/Mod/TechDraw/Gui/TaskActiveView.cpp | 2 +- src/Mod/TechDraw/Gui/TaskActiveView.ui | 2 +- src/Mod/TechDraw/Gui/TaskCenterLine.cpp | 4 +- src/Mod/TechDraw/Gui/TaskCenterLine.ui | 2 +- 9 files changed, 24 insertions(+), 127 deletions(-) rename src/Mod/TechDraw/Gui/Resources/icons/actions/{techdraw-ActiveView.svg => TechDraw_ActiveView.svg} (77%) rename src/Mod/TechDraw/Gui/Resources/icons/actions/{techdraw-facecenterline.svg => TechDraw_FaceCenterLine.svg} (76%) diff --git a/src/Mod/TechDraw/Gui/Command.cpp b/src/Mod/TechDraw/Gui/Command.cpp index a461d41eff..4a46756f92 100644 --- a/src/Mod/TechDraw/Gui/Command.cpp +++ b/src/Mod/TechDraw/Gui/Command.cpp @@ -436,7 +436,7 @@ CmdTechDrawActiveView::CmdTechDrawActiveView() sToolTipText = sMenuText; sWhatsThis = "TechDraw_ActiveView"; sStatusTip = sToolTipText; - sPixmap = "actions/techdraw-ActiveView"; + sPixmap = "actions/TechDraw_ActiveView"; } void CmdTechDrawActiveView::activated(int iMsg) diff --git a/src/Mod/TechDraw/Gui/CommandAnnotate.cpp b/src/Mod/TechDraw/Gui/CommandAnnotate.cpp index 31a6581e12..3976423d2d 100644 --- a/src/Mod/TechDraw/Gui/CommandAnnotate.cpp +++ b/src/Mod/TechDraw/Gui/CommandAnnotate.cpp @@ -612,7 +612,7 @@ Gui::Action * CmdTechDrawCenterLineGroup::createAction(void) applyCommandData(this->className(), pcAction); QAction* p1 = pcAction->addAction(QString()); - p1->setIcon(Gui::BitmapFactory().iconFromTheme("actions/techdraw-facecenterline")); + p1->setIcon(Gui::BitmapFactory().iconFromTheme("actions/TechDraw_FaceCenterLine")); p1->setObjectName(QString::fromLatin1("TechDraw_FaceCenterLine")); p1->setWhatsThis(QString::fromLatin1("TechDraw_FaceCenterLine")); QAction* p2 = pcAction->addAction(QString()); @@ -678,7 +678,7 @@ CmdTechDrawFaceCenterLine::CmdTechDrawFaceCenterLine() sToolTipText = sMenuText; sWhatsThis = "TechDraw_FaceCenterLine"; sStatusTip = sToolTipText; - sPixmap = "actions/techdraw-facecenterline"; + sPixmap = "actions/TechDraw_FaceCenterLine"; } void CmdTechDrawFaceCenterLine::activated(int iMsg) diff --git a/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc b/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc index f2de840fb5..a947b7304e 100644 --- a/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc +++ b/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc @@ -47,7 +47,7 @@ icons/actions/techdraw-PageDefault.svg icons/actions/techdraw-PageTemplate.svg icons/actions/techdraw-View.svg - icons/actions/techdraw-ActiveView.svg + icons/actions/TechDraw_ActiveView.svg icons/actions/techdraw-multiview.svg icons/actions/techdraw-annotation.svg icons/actions/techdraw-ClipGroup.svg @@ -72,7 +72,7 @@ icons/actions/techdraw-CosmeticVertex.svg icons/actions/techdraw-Midpoints.svg icons/actions/techdraw-Quadrants.svg - icons/actions/techdraw-facecenterline.svg + icons/actions/TechDraw_FaceCenterLine.svg icons/actions/techdraw-2linecenterline.svg icons/actions/techdraw-2pointcenterline.svg icons/actions/techdraw-line2points.svg diff --git a/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-ActiveView.svg b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_ActiveView.svg similarity index 77% rename from src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-ActiveView.svg rename to src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_ActiveView.svg index 5b814cc300..927dcc7811 100644 --- a/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-ActiveView.svg +++ b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_ActiveView.svg @@ -6,16 +6,12 @@ xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="64" height="64" viewBox="0 0 64 64" version="1.1" id="svg142" - sodipodi:docname="techdraw-activeview.svg" - style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-linejoin:round" - inkscape:version="0.92.4 (unknown)"> + style="fill:none;stroke:#000000;stroke-width:2;stroke-linecap:round;stroke-linejoin:round"> @@ -31,8 +27,7 @@ + id="linearGradient1328"> - diff --git a/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-facecenterline.svg b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_FaceCenterLine.svg similarity index 76% rename from src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-facecenterline.svg rename to src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_FaceCenterLine.svg index 5204290391..763ecc0b09 100644 --- a/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-facecenterline.svg +++ b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_FaceCenterLine.svg @@ -1,6 +1,4 @@ - - - - - + id="svg3085"> + style="overflow:visible"> + style="overflow:visible"> + style="overflow:visible"> + style="overflow:visible;"> + style="overflow:visible"> + style="overflow:visible;"> + style="overflow:visible"> + style="overflow:visible;"> + style="overflow:visible"> - @@ -312,7 +240,7 @@ y="46.145554" id="text3130" xml:space="preserve" - style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:10px;line-height:125%;font-family:Sans;-inkscape-font-specification:Sans;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;letter-spacing:0px;word-spacing:0px;text-transform:none;writing-mode:lr-tb;direction:ltr;baseline-shift:baseline;text-anchor:start;display:inline;overflow:visible;visibility:visible;fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-width:0.28200001;marker:none;enable-background:accumulate"> @@ -335,10 +263,8 @@ + id="path384" /> diff --git a/src/Mod/TechDraw/Gui/TaskActiveView.cpp b/src/Mod/TechDraw/Gui/TaskActiveView.cpp index ecffa22108..d96c780e1e 100644 --- a/src/Mod/TechDraw/Gui/TaskActiveView.cpp +++ b/src/Mod/TechDraw/Gui/TaskActiveView.cpp @@ -219,7 +219,7 @@ TaskDlgActiveView::TaskDlgActiveView(TechDraw::DrawPage* page) : TaskDialog() { widget = new TaskActiveView(page); - taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-ActiveView"), + taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/TechDraw_ActiveView"), widget->windowTitle(), true, 0); taskbox->groupLayout()->addWidget(widget); Content.push_back(taskbox); diff --git a/src/Mod/TechDraw/Gui/TaskActiveView.ui b/src/Mod/TechDraw/Gui/TaskActiveView.ui index d8631f3525..ca22f4ae2c 100644 --- a/src/Mod/TechDraw/Gui/TaskActiveView.ui +++ b/src/Mod/TechDraw/Gui/TaskActiveView.ui @@ -27,7 +27,7 @@ - :/icons/actions/techdraw-ActiveView.svg:/icons/actions/techdraw-ActiveView.svg + :/icons/actions/TechDraw_ActiveView.svg:/icons/actions/TechDraw_ActiveView.svg diff --git a/src/Mod/TechDraw/Gui/TaskCenterLine.cpp b/src/Mod/TechDraw/Gui/TaskCenterLine.cpp index ab959eecbb..2daeb0c60e 100644 --- a/src/Mod/TechDraw/Gui/TaskCenterLine.cpp +++ b/src/Mod/TechDraw/Gui/TaskCenterLine.cpp @@ -515,7 +515,7 @@ TaskDlgCenterLine::TaskDlgCenterLine(TechDraw::DrawViewPart* partFeat, : TaskDialog() { widget = new TaskCenterLine(partFeat,page,subNames, editMode); - taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-facecenterline"), + taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/TechDraw_FaceCenterLine"), widget->windowTitle(), true, 0); taskbox->groupLayout()->addWidget(widget); Content.push_back(taskbox); @@ -528,7 +528,7 @@ TaskDlgCenterLine::TaskDlgCenterLine(TechDraw::DrawViewPart* partFeat, : TaskDialog() { widget = new TaskCenterLine(partFeat,page, edgeName, editMode); - taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-facecenterline"), + taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/TechDraw_FaceCenterLine"), widget->windowTitle(), true, 0); taskbox->groupLayout()->addWidget(widget); Content.push_back(taskbox); diff --git a/src/Mod/TechDraw/Gui/TaskCenterLine.ui b/src/Mod/TechDraw/Gui/TaskCenterLine.ui index 278d2cc5a9..e905c2d9c9 100644 --- a/src/Mod/TechDraw/Gui/TaskCenterLine.ui +++ b/src/Mod/TechDraw/Gui/TaskCenterLine.ui @@ -30,7 +30,7 @@ - :/icons/actions/techdraw-facecenterline.svg:/icons/actions/techdraw-facecenterline.svg + :/icons/actions/TechDraw_FaceCenterLine.svg:/icons/actions/TechDraw_FaceCenterLine.svg From 6197243fa7ee8c8c8833ab77e0b442cd0db0a6d9 Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 6 Apr 2021 11:37:35 +0200 Subject: [PATCH 068/178] Base: Vector3::GetAngle() uses a smaller epsilon --- src/Base/Vector3D.cpp | 27 ++++++++++++++------------- src/Mod/Test/BaseTests.py | 12 ++++++++++++ 2 files changed, 26 insertions(+), 13 deletions(-) diff --git a/src/Base/Vector3D.cpp b/src/Base/Vector3D.cpp index aca56bb940..03920ed72d 100644 --- a/src/Base/Vector3D.cpp +++ b/src/Base/Vector3D.cpp @@ -22,6 +22,7 @@ #include "PreCompiled.h" +#include #include "Tools.h" #include "Vector3D.h" @@ -418,21 +419,21 @@ Vector3<_Precision> & Vector3<_Precision>::Normalize (void) template _Precision Vector3<_Precision>::GetAngle (const Vector3 &rcVect) const { - _Precision divid, fNum; + _Precision len1 = Length(); + _Precision len2 = rcVect.Length(); + if (len1 <= traits_type::epsilon() || len2 <= traits_type::epsilon()) + return std::numeric_limits<_Precision>::quiet_NaN(); // division by zero - divid = Length() * ((Vector3<_Precision>&)rcVect).Length(); + _Precision dot = Dot(rcVect); + dot /= len1; + dot /= len2; - if ((divid < -1e-10f) || (divid > 1e-10f)) { - fNum = (*this * rcVect) / divid; - if (fNum < -1) - return traits_type::pi(); - else if (fNum > 1) - return 0.0F; - else - return _Precision(acos(fNum)); - } - else - return traits_type::maximum(); // division by zero + if (dot <= -1.0) + return traits_type::pi(); + else if (dot >= 1.0) + return 0.0; + + return _Precision(acos(dot)); } template diff --git a/src/Mod/Test/BaseTests.py b/src/Mod/Test/BaseTests.py index 941efca5b1..61a47a1b44 100644 --- a/src/Mod/Test/BaseTests.py +++ b/src/Mod/Test/BaseTests.py @@ -156,6 +156,18 @@ class ParameterTestCase(unittest.TestCase): self.TestPar.RemString("44") self.failUnless(self.TestPar.GetString("44","hallo") == "hallo","Deletion error at String") + def testAngle(self): + v1 = FreeCAD.Vector(0,0,0.000001) + v2 = FreeCAD.Vector(0,0.000001,0) + self.assertAlmostEqual(v1.getAngle(v2), math.pi/2) + self.assertAlmostEqual(v2.getAngle(v1), math.pi/2) + + def testAngleWithNullVector(self): + v1 = FreeCAD.Vector(0,0,0) + v2 = FreeCAD.Vector(0,1,0) + self.assertTrue(math.isnan(v1.getAngle(v2))) + self.assertTrue(math.isnan(v2.getAngle(v1))) + def testMatrix(self): m=FreeCAD.Matrix(4,2,1,0,1,1,1,0,0,0,1,0,0,0,0,1) u=m.multiply(m.inverse()) From c3264a7cfa5a65dabb46172e6b0a02ba4dc4b32d Mon Sep 17 00:00:00 2001 From: donovaly Date: Tue, 6 Apr 2021 03:36:35 +0200 Subject: [PATCH 069/178] [Part] [skip ci] add a word in description since we have now 3 angles for cylinders, make clear the angle property is for the rotation --- src/Mod/Part/App/PrimitiveFeature.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Part/App/PrimitiveFeature.cpp b/src/Mod/Part/App/PrimitiveFeature.cpp index 8d2dc9989f..7240e72e6a 100644 --- a/src/Mod/Part/App/PrimitiveFeature.cpp +++ b/src/Mod/Part/App/PrimitiveFeature.cpp @@ -528,7 +528,7 @@ Cylinder::Cylinder(void) { ADD_PROPERTY_TYPE(Radius,(2.0),"Cylinder",App::Prop_None,"The radius of the cylinder"); ADD_PROPERTY_TYPE(Height,(10.0f),"Cylinder",App::Prop_None,"The height of the cylinder"); - ADD_PROPERTY_TYPE(Angle,(360.0f),"Cylinder",App::Prop_None,"The angle of the cylinder"); + ADD_PROPERTY_TYPE(Angle,(360.0f),"Cylinder",App::Prop_None,"The rotation angle of the cylinder"); Angle.setConstraints(&angleRangeU); PrismExtension::initExtension(this); From f1ab972234993551a279dba6aed5cec7f12300dc Mon Sep 17 00:00:00 2001 From: donovaly Date: Tue, 6 Apr 2021 04:33:50 +0200 Subject: [PATCH 070/178] [PD] UI file fixes the rotation angle settings of primitives had a different layout than the other parameters, this things like shown in the image below happened. - The PR uniforms all layouts to grid and for the PD layout - it sets for the cylinder page a minimum width - the PD UI file is now also sorted using David's file sorter - fix the mess with stdset="0"> I accidentally introduced with the merges from yesterday (I simply forgot to install to Qt designer the FreeCAD widgets and then designer pollutes the file with these tags for all FC-specific widgets since it doesn't know them --- src/Mod/Part/Gui/DlgPrimitives.ui | 38 +- .../PartDesign/Gui/TaskPrimitiveParameters.ui | 1425 ++++++++--------- 2 files changed, 697 insertions(+), 766 deletions(-) diff --git a/src/Mod/Part/Gui/DlgPrimitives.ui b/src/Mod/Part/Gui/DlgPrimitives.ui index d912cf9556..3e47cda6a6 100644 --- a/src/Mod/Part/Gui/DlgPrimitives.ui +++ b/src/Mod/Part/Gui/DlgPrimitives.ui @@ -7,7 +7,7 @@ 0 0 360 - 298 + 246 @@ -423,10 +423,7 @@ 6 - - - 6 - + 0 @@ -439,14 +436,20 @@ 0 - + + + + 123 + 0 + + Rotation angle: - + false @@ -556,16 +559,16 @@ Angle in first direction - + false deg - + -90.000000000000000 - + 90.000000000000000 @@ -582,16 +585,16 @@ Angle in second direction - + false deg - + -90.000000000000000 - + 90.000000000000000 @@ -618,10 +621,7 @@ 6 - - - 6 - + 0 @@ -634,14 +634,14 @@ 0 - + Angle: - + false diff --git a/src/Mod/PartDesign/Gui/TaskPrimitiveParameters.ui b/src/Mod/PartDesign/Gui/TaskPrimitiveParameters.ui index ba04ef99e8..77f0b7b46d 100644 --- a/src/Mod/PartDesign/Gui/TaskPrimitiveParameters.ui +++ b/src/Mod/PartDesign/Gui/TaskPrimitiveParameters.ui @@ -7,7 +7,7 @@ 0 0 326 - 370 + 241 @@ -56,6 +56,13 @@ 6 + + + + Length: + + + @@ -76,13 +83,6 @@ - - - - Length: - - - @@ -130,22 +130,6 @@ 6 - - - - Qt::Vertical - - - QSizePolicy::Expanding - - - - 0 - 0 - - - - @@ -163,8 +147,15 @@ 6 - - + + + + Length: + + + + + false @@ -176,8 +167,15 @@ - - + + + + Width: + + + + + false @@ -196,22 +194,8 @@ - - - - Length: - - - - - - - Width: - - - - - + + false @@ -225,7 +209,23 @@ - + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 0 + 0 + + + + + @@ -244,71 +244,6 @@ 6 - - - - 6 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Rotation angle: - - - - - - - false - - - deg - - - 360.000000000000000 - - - - - - - - - QFrame::HLine - - - QFrame::Sunken - - - - - - - Qt::Vertical - - - QSizePolicy::Expanding - - - - 0 - 0 - - - - @@ -420,6 +355,74 @@ + + + + QFrame::HLine + + + QFrame::Sunken + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 123 + 0 + + + + Rotation angle: + + + + + + + false + + + deg + + + 360.000000000000000 + + + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 0 + 0 + + + + @@ -439,71 +442,6 @@ 6 - - - - 6 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - Angle: - - - - - - - false - - - deg - - - 360.000000000000000 - - - - - - - - - QFrame::HLine - - - QFrame::Sunken - - - - - - - Qt::Vertical - - - QSizePolicy::Expanding - - - - 0 - 0 - - - - @@ -521,16 +459,10 @@ 6 - - - - false - - - mm - - - 10.000000000000000 + + + + Radius 1: @@ -547,20 +479,6 @@ - - - - Height: - - - - - - - Radius 1: - - - @@ -581,29 +499,30 @@ + + + + Height: + + + + + + + false + + + mm + + + 10.000000000000000 + + + - - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 6 - - + QFrame::HLine @@ -613,7 +532,7 @@ - + 0 @@ -626,67 +545,15 @@ 0 - - 6 - - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 81 - 20 - - - - - + - U parameter: + Angle: - - - - V parameters: - - - - - - - false - - - deg - - - -90.000000000000000 - - - - - - - false - - - deg - - - 90.000000000000000 - - - - - + + false @@ -716,6 +583,25 @@ + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 6 + @@ -755,7 +641,121 @@ - + + + + QFrame::HLine + + + QFrame::Sunken + + + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 6 + + + + + U parameter: + + + + + + + false + + + deg + + + 360.000000000000000 + + + + + + + V parameters: + + + + + + + false + + + deg + + + -90.000000000000000 + + + + + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 81 + 20 + + + + + + + + false + + + deg + + + 90.000000000000000 + + + + + + + + + Qt::Vertical + + + QSizePolicy::Expanding + + + + 0 + 0 + + + + + @@ -774,29 +774,6 @@ 6 - - - - Qt::Vertical - - - - 0 - 0 - - - - - - - - QFrame::HLine - - - QFrame::Sunken - - - @@ -821,20 +798,6 @@ - - - - Radius 2: - - - - - - - Radius 3: - - - @@ -848,6 +811,13 @@ + + + + Radius 2: + + + @@ -861,6 +831,13 @@ + + + + Radius 3: + + + @@ -876,6 +853,16 @@ + + + + QFrame::HLine + + + QFrame::Sunken + + + @@ -900,29 +887,6 @@ - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 81 - 20 - - - - - - - - V parameter: - - - @@ -936,6 +900,13 @@ + + + + V parameter: + + + @@ -949,6 +920,22 @@ + + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 81 + 20 + + + + @@ -964,7 +951,20 @@ - + + + + Qt::Vertical + + + + 0 + 0 + + + + + @@ -983,6 +983,65 @@ 6 + + + + 0 + + + 0 + + + 0 + + + 0 + + + 6 + + + + + Radius 1: + + + + + + + false + + + mm + + + 10.000000000000000 + + + + + + + Radius 2: + + + + + + + false + + + mm + + + 2.000000000000000 + + + + + @@ -1017,29 +1076,6 @@ - - - - Qt::Horizontal - - - QSizePolicy::Preferred - - - - 81 - 20 - - - - - - - - V parameter: - - - @@ -1053,6 +1089,13 @@ + + + + V parameter: + + + @@ -1066,6 +1109,22 @@ + + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 81 + 20 + + + + @@ -1097,66 +1156,7 @@ - - - - 0 - - - 0 - - - 0 - - - 0 - - - 6 - - - - - false - - - mm - - - 10.000000000000000 - - - - - - - Radius 2: - - - - - - - Radius 1: - - - - - - - false - - - mm - - - 2.000000000000000 - - - - - - + @@ -1192,19 +1192,6 @@ 6 - - - - false - - - mm - - - 2.000000000000000 - - - @@ -1232,6 +1219,19 @@ + + + + false + + + mm + + + 2.000000000000000 + + + @@ -1338,34 +1338,6 @@ - - - - Y min/max: - - - - - - - Z min/max: - - - - - - - X2 min/max: - - - - - - - Z2 min/max: - - - @@ -1389,6 +1361,13 @@ + + + + Y min/max: + + + @@ -1412,6 +1391,13 @@ + + + + Z min/max: + + + @@ -1435,6 +1421,13 @@ + + + + X2 min/max: + + + @@ -1461,6 +1454,13 @@ + + + + Z2 min/max: + + + @@ -1521,19 +1521,6 @@ 6 - - - - Qt::Vertical - - - - 0 - 0 - - - - @@ -1551,13 +1538,6 @@ 6 - - - - Radius: - - - @@ -1565,6 +1545,19 @@ + + + + false + + + mm + + + 1.000000000000000 + + + @@ -1572,6 +1565,39 @@ + + + + false + + + mm + + + 2.000000000000000 + + + + + + + Radius: + + + + + + + false + + + mm + + + 1.000000000000000 + + + @@ -1579,6 +1605,16 @@ + + + + false + + + deg + + + @@ -1600,58 +1636,22 @@ - - - - false - - - deg - - - - - - - false - - - mm - - - 1.000000000000000 - - - - - - - false - - - mm - - - 2.000000000000000 - - - - - - - false - - - mm - - - 1.000000000000000 - - - - + + + + Qt::Vertical + + + + 0 + 0 + + + + + @@ -1670,19 +1670,6 @@ 6 - - - - Qt::Vertical - - - - 0 - 0 - - - - @@ -1700,13 +1687,6 @@ 6 - - - - Radius: - - - @@ -1714,13 +1694,6 @@ - - - - Number of rotations: - - - @@ -1734,6 +1707,13 @@ + + + + Number of rotations: + + + @@ -1747,6 +1727,13 @@ + + + + Radius: + + + @@ -1762,7 +1749,20 @@ - + + + + Qt::Vertical + + + + 0 + 0 + + + + + @@ -1790,6 +1790,19 @@ + + + + false + + + mm + + + 2.000000000000000 + + + @@ -1797,13 +1810,6 @@ - - - - Angle 2: - - - @@ -1814,6 +1820,13 @@ + + + + Angle 2: + + + @@ -1827,19 +1840,6 @@ - - - - false - - - mm - - - 2.000000000000000 - - - @@ -1892,27 +1892,6 @@ - - - - Minor radius: - - - - - - - Angle 1: - - - - - - - Angle 2: - - - @@ -1926,6 +1905,13 @@ + + + + Minor radius: + + + @@ -1939,6 +1925,13 @@ + + + + Angle 1: + + + @@ -1949,6 +1942,13 @@ + + + + Angle 2: + + + @@ -1993,26 +1993,6 @@ - - - - Y: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - Z: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - @@ -2023,6 +2003,16 @@ + + + + Y: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + @@ -2033,6 +2023,16 @@ + + + + Z: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + @@ -2064,6 +2064,13 @@ + + + + Start point + + + @@ -2074,6 +2081,16 @@ + + + + false + + + mm + + + @@ -2084,6 +2101,16 @@ + + + + false + + + mm + + + @@ -2094,6 +2121,16 @@ + + + + false + + + mm + + + @@ -2111,13 +2148,6 @@ - - - - Start point - - - @@ -2128,56 +2158,6 @@ - - - - Y: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - Z: - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - false - - - mm - - - - - - - false - - - mm - - - - - - - false - - - mm - - - @@ -2191,6 +2171,16 @@ + + + + Y: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + @@ -2204,6 +2194,16 @@ + + + + Z: + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + @@ -2340,75 +2340,6 @@
    Gui/QuantitySpinBox.h
    - - planeLength - planeWidth - boxLength - boxWidth - boxHeight - cylinderRadius - cylinderHeight - cylinderAngle - coneRadius1 - coneRadius2 - coneHeight - coneAngle - sphereRadius - sphereAngle3 - sphereAngle1 - sphereAngle2 - ellipsoidRadius1 - ellipsoidRadius2 - ellipsoidRadius3 - ellipsoidAngle3 - ellipsoidAngle1 - ellipsoidAngle2 - torusRadius1 - torusRadius2 - torusAngle3 - torusAngle1 - torusAngle2 - prismPolygon - prismCircumradius - prismHeight - wedgeXmin - wedgeXmax - wedgeYmin - wedgeYmax - wedgeZmin - wedgeZmax - wedgeX2min - wedgeX2max - wedgeZ2min - wedgeZ2max - helixPitch - helixHeight - helixRadius - helixAngle - helixLocalCS - spiralGrowth - spiralRotation - spiralRadius - circleRadius - circleAngle0 - circleAngle1 - buttonCircleFromThreePoints - ellipseMajorRadius - ellipseMinorRadius - ellipseAngle0 - ellipseAngle1 - vertexX - vertexY - vertexZ - edgeX1 - edgeY1 - edgeZ1 - edgeX2 - edgeY2 - edgeZ2 - regularPolygonPolygon - regularPolygonCircumradius - From aee3e86e6158d7a8b735ec1bffa75051575b0364 Mon Sep 17 00:00:00 2001 From: Syres916 <46537884+Syres916@users.noreply.github.com> Date: Wed, 17 Feb 2021 15:59:14 +0000 Subject: [PATCH 071/178] [0.20][PartDesign] Sprocket - Allow multiple... ... standard reference sprockets rather than just ANSI as well as capturing the thickness as stated in the particular standard. The user is not bound by this but it saves them looking it up manually. See recent posts in discussion : https://forum.freecadweb.org/viewtopic.php?f=22&t=44525 --- src/Mod/PartDesign/SprocketFeature.py | 77 ++++++++++++++++++--------- 1 file changed, 52 insertions(+), 25 deletions(-) diff --git a/src/Mod/PartDesign/SprocketFeature.py b/src/Mod/PartDesign/SprocketFeature.py index 95977518cb..15e6b704ec 100644 --- a/src/Mod/PartDesign/SprocketFeature.py +++ b/src/Mod/PartDesign/SprocketFeature.py @@ -87,12 +87,14 @@ class Sprocket: obj.addProperty("App::PropertyInteger","NumberOfTeeth","Sprocket","Number of gear teeth") obj.addProperty("App::PropertyLength","Pitch","Sprocket","Chain Pitch") obj.addProperty("App::PropertyLength","RollerDiameter","Sprocket","Roller Diameter") - obj.addProperty("App::PropertyString","ANSISize","Sprocket","ANSI Size") + obj.addProperty("App::PropertyString","SprocketReference","Sprocket","Sprocket Reference") + obj.addProperty("App::PropertyLength","Thickness","Sprocket","Thickness as stated in the reference specification") obj.NumberOfTeeth = 50 obj.Pitch = "0.375 in" obj.RollerDiameter = "0.20 in" - obj.ANSISize = "35" + obj.SprocketReference = "ANSI 35" + obj.Thickness = "0.11 in" obj.Proxy = self @@ -154,7 +156,8 @@ class SprocketTaskPanel: QtCore.QObject.connect(self.form.Quantity_Pitch, QtCore.SIGNAL("valueChanged(double)"), self.pitchChanged) QtCore.QObject.connect(self.form.Quantity_RollerDiameter, QtCore.SIGNAL("valueChanged(double)"), self.rollerDiameterChanged) QtCore.QObject.connect(self.form.spinBox_NumberOfTeeth, QtCore.SIGNAL("valueChanged(int)"), self.numTeethChanged) - QtCore.QObject.connect(self.form.comboBox_ANSISize, QtCore.SIGNAL("currentTextChanged(const QString)"), self.ANSISizeChanged) + QtCore.QObject.connect(self.form.comboBox_SprocketReference, QtCore.SIGNAL("currentTextChanged(const QString)"), self.SprocketReferenceChanged) + QtCore.QObject.connect(self.form.Quantity_Thickness, QtCore.SIGNAL("valueChanged(double)"), self.ThicknessChanged) self.update() @@ -166,10 +169,11 @@ class SprocketTaskPanel: """ Transfer from the dialog to the object """ - self.obj.NumberOfTeeth = self.form.spinBox_NumberOfTeeth.value() - self.obj.Pitch = self.form.Quantity_Pitch.text() - self.obj.RollerDiameter = self.form.Quantity_RollerDiameter.text() - self.obj.ANSISize = self.form.comboBox_ANSISize.currentText() + self.obj.NumberOfTeeth = self.form.spinBox_NumberOfTeeth.value() + self.obj.Pitch = self.form.Quantity_Pitch.text() + self.obj.RollerDiameter = self.form.Quantity_RollerDiameter.text() + self.obj.SprocketReference = self.form.comboBox_SprocketReference.currentText() + self.obj.Thickness = self.form.Quantity_Thickness.text() def transferFrom(self): """ @@ -178,37 +182,56 @@ class SprocketTaskPanel: self.form.spinBox_NumberOfTeeth.setValue(self.obj.NumberOfTeeth) self.form.Quantity_Pitch.setText(self.obj.Pitch.UserString) self.form.Quantity_RollerDiameter.setText(self.obj.RollerDiameter.UserString) - self.form.comboBox_ANSISize.setCurrentText(self.obj.ANSISize) + self.form.comboBox_SprocketReference.setCurrentText(self.obj.SprocketReference) + self.form.Quantity_Thickness.setText(self.obj.Thickness.UserString) def pitchChanged(self, value): self.obj.Pitch = value self.obj.Proxy.execute(self.obj) FreeCAD.Gui.SendMsgToActiveView("ViewFit") - def ANSISizeChanged(self, size): + def SprocketReferenceChanged(self, size): """ ANSI B29.1-2011 standard roller chain sizes in USCS units (inches) {size: [Pitch, Roller Diameter]} """ - ANSIRollerTable = {"25": [0.250, 0.130], - "35": [0.375, 0.200], - "41": [0.500, 0.306], - "40": [0.500, 0.312], - "50": [0.625, 0.400], - "60": [0.750, 0.469], - "80": [1.000, 0.625], - "100":[1.250, 0.750], - "120":[1.500, 0.875], - "140":[1.750, 1.000], - "160":[2.000, 1.125], - "180":[2.250, 1.460], - "200":[2.500, 1.562], - "240":[3.000, 1.875]} + SprocketReferenceRollerTable = {"ANSI 25": [0.250, 0.130, 0.110], + "ANSI 35": [0.375, 0.200, 0.168], + "ANSI 41": [0.500, 0.306, 0.227], + "ANSI 40": [0.500, 0.312, 0.284], + "ANSI 50": [0.625, 0.400, 0.343], + "ANSI 60": [0.750, 0.469, 0.459], + "ANSI 80": [1.000, 0.625, 0.575], + "ANSI 100":[1.250, 0.750, 0.692], + "ANSI 120":[1.500, 0.875, 0.924], + "ANSI 140":[1.750, 1.000, 0.924], + "ANSI 160":[2.000, 1.125, 1.156], + "ANSI 180":[2.250, 1.460, 1.301], + "ANSI 200":[2.500, 1.562, 1.389], + "ANSI 240":[3.000, 1.875, 1.738], + "Motorcycle 420":[0.500, 0.3125, 0.227], + "Motorcycle 425":[0.500, 0.3125, 0.284], + "Motorcycle 428":[0.500, 0.335, 0.284], + "Motorcycle 520":[0.625, 0.400, 0.227], + "Motorcycle 525":[0.625, 0.400, 0.284], + "Motorcycle 530":[0.625, 0.400, 0.343], + "Motorcycle 630":[0.75, 0.400, 0.343], + "Bicycle with Derailleur":[0.500, 0.3125, 0.11], + "Bicycle without Derailleur":[0.500, 0.3125, 0.084], + "ISO 606 06B":[0.375, 5.72/25.4, 5.2/25.4], + "ISO 606 08B":[0.500, 7.75/25.4, 7.0/25.4], + "ISO 606 10B":[0.625, 9.65/25.4, 9.1/25.4], + "ISO 606 12B":[0.750, 11.68/25.4, 11.1/25.4], + "ISO 606 16B":[1.000, 17.02/25.4, 16.2/25.4], + "ISO 606 20B":[1.250, 19.56/25.4, 18.5/25.4], + "ISO 606 24B":[1.5, 25.4/25.4, 24.1/25.4]} - self.obj.Pitch = str(ANSIRollerTable[size][0]) + " in" - self.obj.RollerDiameter = str(ANSIRollerTable[size][1]) + " in" + self.obj.Pitch = str(SprocketReferenceRollerTable[size][0]) + " in" + self.obj.RollerDiameter = str(SprocketReferenceRollerTable[size][1]) + " in" + self.obj.Thickness = str(SprocketReferenceRollerTable[size][2]) + " in" self.form.Quantity_Pitch.setText(self.obj.Pitch.UserString) self.form.Quantity_RollerDiameter.setText(self.obj.RollerDiameter.UserString) + self.form.Quantity_Thickness.setText(self.obj.Thickness.UserString) self.obj.Proxy.execute(self.obj) FreeCAD.Gui.SendMsgToActiveView("ViewFit") @@ -221,6 +244,10 @@ class SprocketTaskPanel: self.obj.NumberOfTeeth = value self.obj.Proxy.execute(self.obj) FreeCAD.Gui.SendMsgToActiveView("ViewFit") + + def ThicknessChanged(self, value): + self.obj.Thickness = str(value) + self.obj.Proxy.execute(self.obj) def getStandardButtons(self): return int(QtGui.QDialogButtonBox.Ok) | int(QtGui.QDialogButtonBox.Cancel)| int(QtGui.QDialogButtonBox.Apply) From 3295ec035aabe7c4db21bef3e847174d96e8fb72 Mon Sep 17 00:00:00 2001 From: Syres916 <46537884+Syres916@users.noreply.github.com> Date: Wed, 17 Feb 2021 16:02:52 +0000 Subject: [PATCH 072/178] [0.20][PartDesign] Sprocket UI - Allow multiple... ... standard reference sprockets rather than just ANSI as well as capturing the thickness as stated in the particular standard. The user is not bound by this but it saves them looking it up manually. See recent posts in discussion : https://forum.freecadweb.org/viewtopic.php?f=22&t=44525 --- src/Mod/PartDesign/SprocketFeature.ui | 159 +++++++++++++++++++++++--- 1 file changed, 143 insertions(+), 16 deletions(-) diff --git a/src/Mod/PartDesign/SprocketFeature.ui b/src/Mod/PartDesign/SprocketFeature.ui index c1960a8837..28176e021a 100644 --- a/src/Mod/PartDesign/SprocketFeature.ui +++ b/src/Mod/PartDesign/SprocketFeature.ui @@ -39,81 +39,161 @@ - ANSI Size: + Sprocket Reference - + - 25 + ANSI 25 - 35 + ANSI 35 - 41 + ANSI 41 - 40 + ANSI 40 - 50 + ANSI 50 - 60 + ANSI 60 - 80 + ANSI 80 - 100 + ANSI 100 - 120 + ANSI 120 - 140 + ANSI 140 - 160 + ANSI 160 - 180 + ANSI 180 - 200 + ANSI 200 - 240 + ANSI 240 + + + + + Motorcycle 420 + + + + + Motorcycle 425 + + + + + Motorcycle 428 + + + + + Motorcycle 520 + + + + + Motorcycle 525 + + + + + Motorcycle 530 + + + + + Motorcycle 630 + + + + + Bicycle with Derailleur + + + + + Bicycle without Derailleur + + + + + ISO 606 06B + + + + + ISO 606 08B + + + + + ISO 606 10B + + + + + ISO 606 12B + + + + + ISO 606 16B + + + + + ISO 606 20B + + + + + ISO 606 24B @@ -218,6 +298,53 @@ + + + + + Thickness: + + + + + + + + 0 + 0 + + + + + 80 + 20 + + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + in + + + 3 + + + 50.000000000000000 + + + 0.01 + + + + 0.01 + + + 0.20 + + + +
    From c2c2058c9f73297c25197a4a5d419ffb95d2c8ac Mon Sep 17 00:00:00 2001 From: Syres916 <46537884+Syres916@users.noreply.github.com> Date: Wed, 17 Feb 2021 16:10:03 +0000 Subject: [PATCH 073/178] [0.20][PartDesign] Sprocket - Correct camelCase --- src/Mod/PartDesign/SprocketFeature.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Mod/PartDesign/SprocketFeature.py b/src/Mod/PartDesign/SprocketFeature.py index 15e6b704ec..6d0656edb6 100644 --- a/src/Mod/PartDesign/SprocketFeature.py +++ b/src/Mod/PartDesign/SprocketFeature.py @@ -156,8 +156,8 @@ class SprocketTaskPanel: QtCore.QObject.connect(self.form.Quantity_Pitch, QtCore.SIGNAL("valueChanged(double)"), self.pitchChanged) QtCore.QObject.connect(self.form.Quantity_RollerDiameter, QtCore.SIGNAL("valueChanged(double)"), self.rollerDiameterChanged) QtCore.QObject.connect(self.form.spinBox_NumberOfTeeth, QtCore.SIGNAL("valueChanged(int)"), self.numTeethChanged) - QtCore.QObject.connect(self.form.comboBox_SprocketReference, QtCore.SIGNAL("currentTextChanged(const QString)"), self.SprocketReferenceChanged) - QtCore.QObject.connect(self.form.Quantity_Thickness, QtCore.SIGNAL("valueChanged(double)"), self.ThicknessChanged) + QtCore.QObject.connect(self.form.comboBox_SprocketReference, QtCore.SIGNAL("currentTextChanged(const QString)"), self.sprocketReferenceChanged) + QtCore.QObject.connect(self.form.Quantity_Thickness, QtCore.SIGNAL("valueChanged(double)"), self.thicknessChanged) self.update() @@ -190,7 +190,7 @@ class SprocketTaskPanel: self.obj.Proxy.execute(self.obj) FreeCAD.Gui.SendMsgToActiveView("ViewFit") - def SprocketReferenceChanged(self, size): + def sprocketReferenceChanged(self, size): """ ANSI B29.1-2011 standard roller chain sizes in USCS units (inches) {size: [Pitch, Roller Diameter]} @@ -245,7 +245,7 @@ class SprocketTaskPanel: self.obj.Proxy.execute(self.obj) FreeCAD.Gui.SendMsgToActiveView("ViewFit") - def ThicknessChanged(self, value): + def thicknessChanged(self, value): self.obj.Thickness = str(value) self.obj.Proxy.execute(self.obj) From a6cae70e9429ca63b3fe4861d9c606ac792dd205 Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Wed, 7 Apr 2021 08:05:04 +0200 Subject: [PATCH 074/178] Sketcher: Adapt fillet to moving addConstraint --- src/Mod/Sketcher/App/SketchObject.cpp | 31 ++++++++++++++------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index db96c20248..9fc6e73921 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -1797,33 +1797,34 @@ int SketchObject::fillet(int GeoId1, int GeoId2, delConstraintOnPoint(GeoId2, PosId2, false); } - Sketcher::Constraint tangent1, tangent2; + auto tangent1 = std::make_unique(); + auto tangent2 = std::make_unique(); - tangent1.Type = Sketcher::Tangent; - tangent1.First = GeoId1; - tangent1.FirstPos = PosId1; - tangent1.Second = filletId; + tangent1->Type = Sketcher::Tangent; + tangent1->First = GeoId1; + tangent1->FirstPos = PosId1; + tangent1->Second = filletId; - tangent2.Type = Sketcher::Tangent; - tangent2.First = GeoId2; - tangent2.FirstPos = PosId2; - tangent2.Second = filletId; + tangent2->Type = Sketcher::Tangent; + tangent2->First = GeoId2; + tangent2->FirstPos = PosId2; + tangent2->Second = filletId; if (dist1.Length() < dist2.Length()) { - tangent1.SecondPos = start; - tangent2.SecondPos = end; + tangent1->SecondPos = start; + tangent2->SecondPos = end; movePoint(GeoId1, PosId1, arc->getStartPoint(/*emulateCCW=*/true),false,true); movePoint(GeoId2, PosId2, arc->getEndPoint(/*emulateCCW=*/true),false,true); } else { - tangent1.SecondPos = end; - tangent2.SecondPos = start; + tangent1->SecondPos = end; + tangent2->SecondPos = start; movePoint(GeoId1, PosId1, arc->getEndPoint(/*emulateCCW=*/true),false,true); movePoint(GeoId2, PosId2, arc->getStartPoint(/*emulateCCW=*/true),false,true); } - addConstraint(&tangent1); - addConstraint(&tangent2); + addConstraint(std::move(tangent1)); + addConstraint(std::move(tangent2)); } if (noRecomputes) // if we do not have a recompute after the geometry creation, the sketch must be solved to update the DoF of the solver From 62a86deff0debecb7f3392485a4d82fee16125cc Mon Sep 17 00:00:00 2001 From: donovaly Date: Wed, 7 Apr 2021 03:36:22 +0200 Subject: [PATCH 075/178] [PD] sort entries in sprocket feature as the title says. (The other UI file changes were made by Qt's designer.) --- src/Mod/PartDesign/SprocketFeature.py | 23 ++-- src/Mod/PartDesign/SprocketFeature.ui | 157 ++++++++++++-------------- 2 files changed, 82 insertions(+), 98 deletions(-) diff --git a/src/Mod/PartDesign/SprocketFeature.py b/src/Mod/PartDesign/SprocketFeature.py index 6d0656edb6..c1c9223cbf 100644 --- a/src/Mod/PartDesign/SprocketFeature.py +++ b/src/Mod/PartDesign/SprocketFeature.py @@ -209,13 +209,6 @@ class SprocketTaskPanel: "ANSI 180":[2.250, 1.460, 1.301], "ANSI 200":[2.500, 1.562, 1.389], "ANSI 240":[3.000, 1.875, 1.738], - "Motorcycle 420":[0.500, 0.3125, 0.227], - "Motorcycle 425":[0.500, 0.3125, 0.284], - "Motorcycle 428":[0.500, 0.335, 0.284], - "Motorcycle 520":[0.625, 0.400, 0.227], - "Motorcycle 525":[0.625, 0.400, 0.284], - "Motorcycle 530":[0.625, 0.400, 0.343], - "Motorcycle 630":[0.75, 0.400, 0.343], "Bicycle with Derailleur":[0.500, 0.3125, 0.11], "Bicycle without Derailleur":[0.500, 0.3125, 0.084], "ISO 606 06B":[0.375, 5.72/25.4, 5.2/25.4], @@ -224,11 +217,18 @@ class SprocketTaskPanel: "ISO 606 12B":[0.750, 11.68/25.4, 11.1/25.4], "ISO 606 16B":[1.000, 17.02/25.4, 16.2/25.4], "ISO 606 20B":[1.250, 19.56/25.4, 18.5/25.4], - "ISO 606 24B":[1.5, 25.4/25.4, 24.1/25.4]} + "ISO 606 24B":[1.500, 25.4/25.4, 24.1/25.4], + "Motorcycle 420":[0.500, 0.3125, 0.227], + "Motorcycle 425":[0.500, 0.3125, 0.284], + "Motorcycle 428":[0.500, 0.335, 0.284], + "Motorcycle 520":[0.625, 0.400, 0.227], + "Motorcycle 525":[0.625, 0.400, 0.284], + "Motorcycle 530":[0.625, 0.400, 0.343], + "Motorcycle 630":[0.750, 0.400, 0.343],} - self.obj.Pitch = str(SprocketReferenceRollerTable[size][0]) + " in" - self.obj.RollerDiameter = str(SprocketReferenceRollerTable[size][1]) + " in" - self.obj.Thickness = str(SprocketReferenceRollerTable[size][2]) + " in" + self.obj.Pitch = str(SprocketReferenceRollerTable[size][0]) + " in" + self.obj.RollerDiameter = str(SprocketReferenceRollerTable[size][1]) + " in" + self.obj.Thickness = str(SprocketReferenceRollerTable[size][2]) + " in" self.form.Quantity_Pitch.setText(self.obj.Pitch.UserString) self.form.Quantity_RollerDiameter.setText(self.obj.RollerDiameter.UserString) self.form.Quantity_Thickness.setText(self.obj.Thickness.UserString) @@ -270,6 +270,5 @@ class SprocketTaskPanel: FreeCAD.ActiveDocument.abortTransaction() - if FreeCAD.GuiUp: FreeCADGui.addCommand('PartDesign_Sprocket', CommandSprocket()) diff --git a/src/Mod/PartDesign/SprocketFeature.ui b/src/Mod/PartDesign/SprocketFeature.ui index 28176e021a..d45ca8c48f 100644 --- a/src/Mod/PartDesign/SprocketFeature.ui +++ b/src/Mod/PartDesign/SprocketFeature.ui @@ -6,7 +6,7 @@ 0 0 - 195 + 264 142 @@ -14,7 +14,6 @@ Sprocket parameter - @@ -35,7 +34,6 @@ - @@ -44,21 +42,20 @@ - - + - ANSI 25 + ANSI 25 - ANSI 35 + ANSI 35 - ANSI 41 + ANSI 41 @@ -116,41 +113,6 @@ ANSI 240 - - - Motorcycle 420 - - - - - Motorcycle 425 - - - - - Motorcycle 428 - - - - - Motorcycle 520 - - - - - Motorcycle 525 - - - - - Motorcycle 530 - - - - - Motorcycle 630 - - Bicycle with Derailleur @@ -196,20 +158,51 @@ ISO 606 24B + + + Motorcycle 420 + + + + + Motorcycle 425 + + + + + Motorcycle 428 + + + + + Motorcycle 520 + + + + + Motorcycle 525 + + + + + Motorcycle 530 + + + + + Motorcycle 630 + + - - Chain Pitch: - - @@ -224,35 +217,32 @@ - + 0 in Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + 0.001000000000000 + + + 2000.000000000000000 + + + 0.010000000000000 + in 3 - - 2000.000000000000000 - - - 0.01 - - - - 0.001 - - 0.375 + 0.375000000000000 - - Roller Diameter: @@ -276,30 +266,27 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + 0.010000000000000 + + + 50.000000000000000 + + + 0.010000000000000 + in 3 - - 50.000000000000000 - - - 0.01 - - - - 0.01 - - 0.20 + 0.200000000000000 - - Thickness: @@ -323,28 +310,26 @@ Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + 0.010000000000000 + + + 50.000000000000000 + + + 0.010000000000000 + in 3 - - 50.000000000000000 - - - 0.01 - - - - 0.01 - - 0.20 + 0.200000000000000 - From e8668e9e4589794d45747d71db3a0be6b7bbc1d6 Mon Sep 17 00:00:00 2001 From: donovaly Date: Wed, 7 Apr 2021 05:11:38 +0200 Subject: [PATCH 076/178] fix bug that property "SprocketReference" is not an enum --- src/Mod/PartDesign/SprocketFeature.py | 81 ++++++++++++++------------- 1 file changed, 42 insertions(+), 39 deletions(-) diff --git a/src/Mod/PartDesign/SprocketFeature.py b/src/Mod/PartDesign/SprocketFeature.py index c1c9223cbf..3c6c6c6d5a 100644 --- a/src/Mod/PartDesign/SprocketFeature.py +++ b/src/Mod/PartDesign/SprocketFeature.py @@ -82,14 +82,51 @@ class Sprocket: The Sprocket object """ + """ + ANSI B29.1-2011 standard roller chain sizes in USCS units (inches) + {size: [Pitch, Roller Diameter]} + """ + SprocketReferenceRollerTable = {"ANSI 25": [0.250, 0.130, 0.110], + "ANSI 35": [0.375, 0.200, 0.168], + "ANSI 41": [0.500, 0.306, 0.227], + "ANSI 40": [0.500, 0.312, 0.284], + "ANSI 50": [0.625, 0.400, 0.343], + "ANSI 60": [0.750, 0.469, 0.459], + "ANSI 80": [1.000, 0.625, 0.575], + "ANSI 100":[1.250, 0.750, 0.692], + "ANSI 120":[1.500, 0.875, 0.924], + "ANSI 140":[1.750, 1.000, 0.924], + "ANSI 160":[2.000, 1.125, 1.156], + "ANSI 180":[2.250, 1.460, 1.301], + "ANSI 200":[2.500, 1.562, 1.389], + "ANSI 240":[3.000, 1.875, 1.738], + "Bicycle with Derailleur":[0.500, 0.3125, 0.11], + "Bicycle without Derailleur":[0.500, 0.3125, 0.084], + "ISO 606 06B":[0.375, 5.72/25.4, 5.2/25.4], + "ISO 606 08B":[0.500, 7.75/25.4, 7.0/25.4], + "ISO 606 10B":[0.625, 9.65/25.4, 9.1/25.4], + "ISO 606 12B":[0.750, 11.68/25.4, 11.1/25.4], + "ISO 606 16B":[1.000, 17.02/25.4, 16.2/25.4], + "ISO 606 20B":[1.250, 19.56/25.4, 18.5/25.4], + "ISO 606 24B":[1.500, 25.4/25.4, 24.1/25.4], + "Motorcycle 420":[0.500, 0.3125, 0.227], + "Motorcycle 425":[0.500, 0.3125, 0.284], + "Motorcycle 428":[0.500, 0.335, 0.284], + "Motorcycle 520":[0.625, 0.400, 0.227], + "Motorcycle 525":[0.625, 0.400, 0.284], + "Motorcycle 530":[0.625, 0.400, 0.343], + "Motorcycle 630":[0.750, 0.400, 0.343]} + def __init__(self,obj): self.Type = "Sprocket" obj.addProperty("App::PropertyInteger","NumberOfTeeth","Sprocket","Number of gear teeth") obj.addProperty("App::PropertyLength","Pitch","Sprocket","Chain Pitch") obj.addProperty("App::PropertyLength","RollerDiameter","Sprocket","Roller Diameter") - obj.addProperty("App::PropertyString","SprocketReference","Sprocket","Sprocket Reference") + obj.addProperty("App::PropertyEnumeration","SprocketReference","Sprocket","Sprocket Reference") obj.addProperty("App::PropertyLength","Thickness","Sprocket","Thickness as stated in the reference specification") + obj.SprocketReference = list(self.SprocketReferenceRollerTable.keys()) + obj.NumberOfTeeth = 50 obj.Pitch = "0.375 in" obj.RollerDiameter = "0.20 in" @@ -191,44 +228,10 @@ class SprocketTaskPanel: FreeCAD.Gui.SendMsgToActiveView("ViewFit") def sprocketReferenceChanged(self, size): - """ - ANSI B29.1-2011 standard roller chain sizes in USCS units (inches) - {size: [Pitch, Roller Diameter]} - """ - SprocketReferenceRollerTable = {"ANSI 25": [0.250, 0.130, 0.110], - "ANSI 35": [0.375, 0.200, 0.168], - "ANSI 41": [0.500, 0.306, 0.227], - "ANSI 40": [0.500, 0.312, 0.284], - "ANSI 50": [0.625, 0.400, 0.343], - "ANSI 60": [0.750, 0.469, 0.459], - "ANSI 80": [1.000, 0.625, 0.575], - "ANSI 100":[1.250, 0.750, 0.692], - "ANSI 120":[1.500, 0.875, 0.924], - "ANSI 140":[1.750, 1.000, 0.924], - "ANSI 160":[2.000, 1.125, 1.156], - "ANSI 180":[2.250, 1.460, 1.301], - "ANSI 200":[2.500, 1.562, 1.389], - "ANSI 240":[3.000, 1.875, 1.738], - "Bicycle with Derailleur":[0.500, 0.3125, 0.11], - "Bicycle without Derailleur":[0.500, 0.3125, 0.084], - "ISO 606 06B":[0.375, 5.72/25.4, 5.2/25.4], - "ISO 606 08B":[0.500, 7.75/25.4, 7.0/25.4], - "ISO 606 10B":[0.625, 9.65/25.4, 9.1/25.4], - "ISO 606 12B":[0.750, 11.68/25.4, 11.1/25.4], - "ISO 606 16B":[1.000, 17.02/25.4, 16.2/25.4], - "ISO 606 20B":[1.250, 19.56/25.4, 18.5/25.4], - "ISO 606 24B":[1.500, 25.4/25.4, 24.1/25.4], - "Motorcycle 420":[0.500, 0.3125, 0.227], - "Motorcycle 425":[0.500, 0.3125, 0.284], - "Motorcycle 428":[0.500, 0.335, 0.284], - "Motorcycle 520":[0.625, 0.400, 0.227], - "Motorcycle 525":[0.625, 0.400, 0.284], - "Motorcycle 530":[0.625, 0.400, 0.343], - "Motorcycle 630":[0.750, 0.400, 0.343],} - - self.obj.Pitch = str(SprocketReferenceRollerTable[size][0]) + " in" - self.obj.RollerDiameter = str(SprocketReferenceRollerTable[size][1]) + " in" - self.obj.Thickness = str(SprocketReferenceRollerTable[size][2]) + " in" + self.obj.Pitch = str(Sprocket.SprocketReferenceRollerTable[size][0]) + " in" + self.obj.RollerDiameter = str(Sprocket.SprocketReferenceRollerTable[size][1]) + " in" + self.obj.Thickness = str(Sprocket.SprocketReferenceRollerTable[size][2]) + " in" + self.obj.SprocketReference = str(size) self.form.Quantity_Pitch.setText(self.obj.Pitch.UserString) self.form.Quantity_RollerDiameter.setText(self.obj.RollerDiameter.UserString) self.form.Quantity_Thickness.setText(self.obj.Thickness.UserString) From 5cc042379aae307f720c6fb2aaffee8788925266 Mon Sep 17 00:00:00 2001 From: marioalexis Date: Sun, 4 Apr 2021 15:55:47 -0300 Subject: [PATCH 077/178] Draft: Add functions to transform Cartesian coordinates to spherical and vice versa --- src/Mod/Draft/DraftVecUtils.py | 72 ++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+) diff --git a/src/Mod/Draft/DraftVecUtils.py b/src/Mod/Draft/DraftVecUtils.py index ee5c4be172..a696eda056 100644 --- a/src/Mod/Draft/DraftVecUtils.py +++ b/src/Mod/Draft/DraftVecUtils.py @@ -829,4 +829,76 @@ def removeDoubles(vlist): nlist.append(vlist[-1]) return nlist +def get_spherical_coords(x, y, z): + """Get the Spherical coordinates of the vector represented + by Cartesian coordinates (x, y, z). + + Parameters + ---------- + vector : Base::Vector3 + The input vector. + + Returns + ------- + tuple of float + Tuple (radius, theta, phi) with the Spherical coordinates. + Radius is the radial coordinate, theta the polar angle and + phi the azimuthal angle in radians. + + Notes + ----- + The vector (0, 0, 0) has undefined values for theta and phi, while + points on the z axis has undefined value for phi. The following + conventions are used (useful in DraftToolBar methods): + (0, 0, 0) -> (0, pi/2, 0) + (0, 0, z) -> (radius, theta, 0) + """ + + v = Vector(x,y,z) + x_axis = Vector(1,0,0) + z_axis = Vector(0,0,1) + y_axis = Vector(0,1,0) + rad = v.Length + + if not bool(round(rad, precision())): + return (0, math.pi/2, 0) + + theta = v.getAngle(z_axis) + v.projectToPlane(Vector(0,0,0), z_axis) + phi = v.getAngle(x_axis) + if math.isnan(phi): + return (rad, theta, 0) + # projected vector is on 3rd or 4th quadrant + if v.dot(Vector(y_axis)) < 0: + phi = -1*phi + + return (rad, theta, phi) + + +def get_cartesian_coords(radius, theta, phi): + """Get the three-dimensional Cartesian coordinates of the vector + represented by Spherical coordinates (radius, theta, phi). + + Parameters + ---------- + radius : float, int + Radial coordinate of the vector. + theta : float, int + Polar coordinate of the vector in radians. + phi : float, int + Azimuthal coordinate of the vector in radians. + + Returns + ------- + tuple of float : + Tuple (x, y, z) with the Cartesian coordinates. + """ + + x = radius*math.sin(theta)*math.cos(phi) + y = radius*math.sin(theta)*math.sin(phi) + z = radius*math.cos(theta) + + return (x, y, z) + + ## @} From 2f81ca40be5cc4bb8f719767f52fd811842f8fd8 Mon Sep 17 00:00:00 2001 From: marioalexis Date: Mon, 5 Apr 2021 01:07:45 -0300 Subject: [PATCH 078/178] Draft: Sync input fields in task panel --- src/Mod/Draft/DraftGui.py | 97 ++++++++++++++++++++++++--------------- 1 file changed, 61 insertions(+), 36 deletions(-) diff --git a/src/Mod/Draft/DraftGui.py b/src/Mod/Draft/DraftGui.py index fff6c1db04..01b651ab3b 100644 --- a/src/Mod/Draft/DraftGui.py +++ b/src/Mod/Draft/DraftGui.py @@ -273,11 +273,13 @@ class DraftToolBar: self.fillmode = Draft.getParam("fillmode",False) self.mask = None self.alock = False - self.angle = None - self.avalue = None self.x = 0 self.y = 0 self.z = 0 + self.lvalue = 0 + self.pvalue = 90 + self.avalue = 0 + self.angle = None self.radius = 0 self.offset = 0 self.uiloader = FreeCADGui.UiLoader() @@ -835,11 +837,7 @@ class DraftToolBar: def taskUi(self,title="Draft",extra=None,icon="Draft_Draft"): # reset InputField values - self.x = 0 - self.y = 0 - self.z = 0 - self.radius = 0 - self.offset = 0 + self.reset_ui_values() if self.taskmode: self.isTaskOn = True todo.delay(FreeCADGui.Control.closeDialog,None) @@ -1577,7 +1575,6 @@ class DraftToolBar: def wipeLine(self): """wipes existing segments of a line""" - FreeCAD.Console.PrintMessage("el de wipe\n") self.sourceCmd.wipe() def orientWP(self): @@ -1791,16 +1788,18 @@ class DraftToolBar: # set length and angle if last and dp and plane: - self.lengthValue.setText(displayExternal(dp.Length,None,'Length')) - a = math.degrees(-DraftVecUtils.angle(dp,plane.u,plane.axis)) - if not self.angleLock.isChecked(): - self.angleValue.setText(displayExternal(a,None,'Angle')) + length, theta, phi = DraftVecUtils.get_spherical_coords(*dp) + theta = math.degrees(theta) + phi = math.degrees(phi) + self.lengthValue.setText(displayExternal(length,None,'Length')) + #if not self.angleLock.isChecked(): + self.angleValue.setText(displayExternal(phi,None,'Angle')) if not mask: - # automask, a is rounded to identify one of the below cases - a = round(a, Draft.getParam("precision")) - if a in [0,180,-180]: + # automask, phi is rounded to identify one of the below cases + phi = round(phi, Draft.getParam("precision")) + if phi in [0,180,-180]: mask = "x" - elif a in [90,270,-90,-270]: + elif phi in [90,270,-90,-270]: mask = "y" # set masks @@ -2108,12 +2107,21 @@ class DraftToolBar: def changeXValue(self,d): self.x = d + if not self.xValue.hasFocus(): + return None + self.update_spherical_coords() def changeYValue(self,d): self.y = d + if not self.yValue.hasFocus(): + return None + self.update_spherical_coords() def changeZValue(self,d): self.z = d + if not self.zValue.hasFocus(): + return None + self.update_spherical_coords() def changeRadiusValue(self,d): self.radius = d @@ -2126,29 +2134,15 @@ class DraftToolBar: def changeLengthValue(self,d): self.lvalue = d - v = FreeCAD.Vector(self.x,self.y,self.z) - if not v.Length: - if self.angle: - v = FreeCAD.Vector(self.angle) - else: - v = FreeCAD.Vector(FreeCAD.DraftWorkingPlane.u) - if self.avalue: - v = DraftVecUtils.rotate(v,math.radians(d),FreeCAD.DraftWorkingPlane.axis) - v = DraftVecUtils.scaleTo(v,d) - self.xValue.setText(displayExternal(v.x,None,'Length')) - self.yValue.setText(displayExternal(v.y,None,'Length')) - self.zValue.setText(displayExternal(v.z,None,'Length')) + if not self.lengthValue.hasFocus(): + return None + self.update_cartesian_coords() def changeAngleValue(self,d): self.avalue = d - v = FreeCAD.Vector(self.x,self.y,self.z) - a = DraftVecUtils.angle(v,FreeCAD.DraftWorkingPlane.u,FreeCAD.DraftWorkingPlane.axis) - a = math.radians(d)+a - v = DraftVecUtils.rotate(v,a,FreeCAD.DraftWorkingPlane.axis) - self.angle = v - self.xValue.setText(displayExternal(v.x,None,'Length')) - self.yValue.setText(displayExternal(v.y,None,'Length')) - self.zValue.setText(displayExternal(v.z,None,'Length')) + if not self.angleValue.hasFocus(): + return None + self.update_cartesian_coords() if self.angleLock.isChecked(): FreeCADGui.Snapper.setAngle(self.angle) @@ -2160,6 +2154,25 @@ class DraftToolBar: FreeCADGui.Snapper.setAngle() self.angle = None + def update_spherical_coords(self): + length, theta, phi = DraftVecUtils.get_spherical_coords( + self.x,self.y,self.z) + self.lvalue = length + self.pvalue = math.degrees(theta) + self.avalue = math.degrees(phi) + self.angle = FreeCAD.Vector(DraftVecUtils.get_cartesian_coords( + 1, theta, phi)) + self.lengthValue.setText(displayExternal(self.lvalue,None,'Length')) + self.angleValue.setText(displayExternal(self.avalue,None,'Angle')) + + def update_cartesian_coords(self): + self.x, self.y, self.z = DraftVecUtils.get_cartesian_coords( + self.lvalue,math.radians(self.pvalue),math.radians(self.avalue)) + self.angle = FreeCAD.Vector(DraftVecUtils.get_cartesian_coords( + 1, math.radians(self.pvalue), math.radians(self.avalue))) + self.xValue.setText(displayExternal(self.x,None,'Length')) + self.yValue.setText(displayExternal(self.y,None,'Length')) + self.zValue.setText(displayExternal(self.z,None,'Length')) #--------------------------------------------------------------------------- # TaskView operations @@ -2235,6 +2248,18 @@ class DraftToolBar: self.draftWidget.setVisible(False) self.draftWidget.toggleViewAction().setVisible(False) + def reset_ui_values(self): + """Method to reset task panel values""" + self.x = 0 + self.y = 0 + self.z = 0 + self.lvalue = 0 + self.pvalue = 90 + self.avalue = 0 + self.angle = None + self.radius = 0 + self.offset = 0 + class FacebinderTaskPanel: '''A TaskPanel for the facebinder''' From 58b0dd38c2408763e7841506bb0b1a94076a99d2 Mon Sep 17 00:00:00 2001 From: donovaly Date: Sat, 3 Apr 2021 03:55:15 +0200 Subject: [PATCH 079/178] [FEM] proper support for Gmsh HighOrder optimization There are 4 optimizers available while we only supported 1. This PR adds support for all. --- src/Mod/Fem/femmesh/gmshtools.py | 32 ++++++++++++------- src/Mod/Fem/femobjects/mesh_gmsh.py | 29 ++++++++++++++--- src/Mod/Fem/femtest/data/elmer/group_mesh.geo | 5 +-- src/Mod/MeshPart/Gui/Tessellation.cpp | 2 +- 4 files changed, 49 insertions(+), 19 deletions(-) diff --git a/src/Mod/Fem/femmesh/gmshtools.py b/src/Mod/Fem/femmesh/gmshtools.py index 72b329a72e..801104de94 100644 --- a/src/Mod/Fem/femmesh/gmshtools.py +++ b/src/Mod/Fem/femmesh/gmshtools.py @@ -125,6 +125,21 @@ class GmshTools(): else: self.algorithm3D = "1" + # HighOrderOptimize + optimizers = self.mesh_obj.HighOrderOptimize + if optimizers == "None": + self.HighOrderOptimize = "0" + elif optimizers == "Optimization": + self.HighOrderOptimize = "1" + elif optimizers == "Elastic+Optimization": + self.HighOrderOptimize = "2" + elif optimizers == "Elastic": + self.HighOrderOptimize = "3" + elif optimizers == "Fast Curving": + self.HighOrderOptimize = "4" + else: + self.HighOrderOptimize = "0" + # mesh groups if self.mesh_obj.GroupsOfNodes is True: self.group_nodes_export = True @@ -767,16 +782,11 @@ class GmshTools(): else: geo.write("Mesh.OptimizeNetgen = 0;\n") # higher order mesh optimizing - if hasattr(self.mesh_obj, "HighOrderOptimize") and self.mesh_obj.HighOrderOptimize is True: - geo.write( - "Mesh.HighOrderOptimize = 1; // for more HighOrderOptimize " - "parameter check http://gmsh.info/doc/texinfo/gmsh.html\n" - ) - else: - geo.write( - "Mesh.HighOrderOptimize = 0; // for more HighOrderOptimize " - "parameter check http://gmsh.info/doc/texinfo/gmsh.html\n" - ) + geo.write( + "// High-order meshes optimization (0=none, 1=optimization, 2=elastic+optimization, " + "3=elastic, 4=fast curving)\n" + ) + geo.write("Mesh.HighOrderOptimize = " + self.HighOrderOptimize + ";\n") geo.write("\n") geo.write("// mesh order\n") @@ -850,7 +860,7 @@ class GmshTools(): # some useful information geo.write("// " + "*" * 70 + "\n") geo.write("// Gmsh documentation:\n") - geo.write("// http://gmsh.info/doc/texinfo/gmsh.html#Mesh\n") + geo.write("// https://gmsh.info/doc/texinfo/gmsh.html#Mesh\n") geo.write("//\n") geo.write( "// We do not check if something went wrong, like negative " diff --git a/src/Mod/Fem/femobjects/mesh_gmsh.py b/src/Mod/Fem/femobjects/mesh_gmsh.py index 81685c5d96..cc1167a0b8 100644 --- a/src/Mod/Fem/femobjects/mesh_gmsh.py +++ b/src/Mod/Fem/femobjects/mesh_gmsh.py @@ -60,16 +60,34 @@ class MeshGmsh(base_fempythonobject.BaseFemPythonObject): "R-tree", "HXT" ] + known_mesh_HighOrderOptimizers = [ + "None", + "Optimization", + "Elastic+Optimization", + "Elastic", + "Fast curving" + ] def __init__(self, obj): super(MeshGmsh, self).__init__(obj) self.add_properties(obj) def onDocumentRestored(self, obj): + # HighOrderOptimize was once App::PropertyBool, so check this + HighOrderOptimizer = "" + if obj.HighOrderOptimize is True: + HighOrderOptimizer = "Optimization" + obj.removeProperty("HighOrderOptimize") + elif obj.HighOrderOptimize is False: + HighOrderOptimizer = "None" + obj.removeProperty("HighOrderOptimize") self.add_properties(obj) # refresh the list of known 3D algorithms for existing meshes # since some algos are meanwhile deprecated and new algos are available obj.Algorithm3D = MeshGmsh.known_mesh_algorithm_3D + # write the stored HighOrderOptimizer + if HighOrderOptimizer: + obj.HighOrderOptimize = HighOrderOptimizer def add_properties(self, obj): if not hasattr(obj, "MeshBoundaryLayerList"): @@ -166,12 +184,13 @@ class MeshGmsh(base_fempythonobject.BaseFemPythonObject): if not hasattr(obj, "HighOrderOptimize"): obj.addProperty( - "App::PropertyBool", + "App::PropertyEnumeration", "HighOrderOptimize", "FEM Gmsh Mesh Params", - "Optimize high order meshes" + "Optimization of high order meshes" ) - obj.HighOrderOptimize = False + obj.HighOrderOptimize = MeshGmsh.known_mesh_HighOrderOptimizers + obj.HighOrderOptimize = "None" if not hasattr(obj, "RecombineAll"): obj.addProperty( @@ -232,7 +251,7 @@ class MeshGmsh(base_fempythonobject.BaseFemPythonObject): "mesh algorithm 2D" ) obj.Algorithm2D = MeshGmsh.known_mesh_algorithm_2D - obj.Algorithm2D = "Automatic" # ? + obj.Algorithm2D = "Automatic" if not hasattr(obj, "Algorithm3D"): obj.addProperty( @@ -242,7 +261,7 @@ class MeshGmsh(base_fempythonobject.BaseFemPythonObject): "mesh algorithm 3D" ) obj.Algorithm3D = MeshGmsh.known_mesh_algorithm_3D - obj.Algorithm3D = "Automatic" # ? + obj.Algorithm3D = "Automatic" if not hasattr(obj, "GroupsOfNodes"): obj.addProperty( diff --git a/src/Mod/Fem/femtest/data/elmer/group_mesh.geo b/src/Mod/Fem/femtest/data/elmer/group_mesh.geo index 48cf1a8658..9c3c37a053 100644 --- a/src/Mod/Fem/femtest/data/elmer/group_mesh.geo +++ b/src/Mod/Fem/femtest/data/elmer/group_mesh.geo @@ -19,7 +19,8 @@ Mesh.MeshSizeFromCurvature = 12; // number of elements per 2*pi radians, 0 to de // optimize the mesh Mesh.Optimize = 1; Mesh.OptimizeNetgen = 0; -Mesh.HighOrderOptimize = 0; // for more HighOrderOptimize parameter check http://gmsh.info/doc/texinfo/gmsh.html +// High-order meshes optimization (0=none, 1=optimization, 2=elastic+optimization, 3=elastic, 4=fast curving) +Mesh.HighOrderOptimize = 0; // mesh order Mesh.ElementOrder = 2; @@ -45,7 +46,7 @@ Save "/tmp/tmpjVhNNb.unv"; // ********************************************************************** // Gmsh documentation: -// http://gmsh.info/doc/texinfo/gmsh.html#Mesh +// https://gmsh.info/doc/texinfo/gmsh.html#Mesh // // We do not check if something went wrong, like negative jacobians etc. You can run Gmsh manually yourself: // diff --git a/src/Mod/MeshPart/Gui/Tessellation.cpp b/src/Mod/MeshPart/Gui/Tessellation.cpp index cc5822aae0..aa343fc07b 100644 --- a/src/Mod/MeshPart/Gui/Tessellation.cpp +++ b/src/Mod/MeshPart/Gui/Tessellation.cpp @@ -514,7 +514,7 @@ bool Mesh2ShapeGmsh::writeProject(QString& inpFile, QString& outFile) << "// optimize the mesh\n" << "Mesh.Optimize = 1;\n" << "Mesh.OptimizeNetgen = 0;\n" - << "// for more HighOrderOptimize parameter check http://gmsh.info/doc/texinfo/gmsh.html\n" + << "// High-order meshes optimization (0=none, 1=optimization, 2=elastic+optimization, 3=elastic, 4=fast curving)\n" << "Mesh.HighOrderOptimize = 0;\n\n" << "// mesh order\n" << "Mesh.ElementOrder = 2;\n" From c30433c041552b61c26d9b1bc79ace0c6989def6 Mon Sep 17 00:00:00 2001 From: Syres916 <46537884+Syres916@users.noreply.github.com> Date: Fri, 9 Apr 2021 10:23:29 +0100 Subject: [PATCH 080/178] [Techdraw] Fix minor bug changing Image Crop... ... from True to False does not fill image view box only approx three quarters. This was found testing reported issue https://forum.freecadweb.org/viewtopic.php?f=35&t=57537 (otherwise it works as @wandererfan expected) --- src/Mod/TechDraw/Gui/QGIViewImage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/TechDraw/Gui/QGIViewImage.cpp b/src/Mod/TechDraw/Gui/QGIViewImage.cpp index a021b4024e..5dc0add9da 100644 --- a/src/Mod/TechDraw/Gui/QGIViewImage.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewImage.cpp @@ -135,7 +135,7 @@ void QGIViewImage::draw() } m_cliparea->centerAt(0.0,0.0); - QGIView::draw(); + drawImage(); } void QGIViewImage::drawImage() From 14e3c9115803a1a5b3914fcfbe1905c06da01aec Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 9 Apr 2021 16:59:33 +0200 Subject: [PATCH 081/178] Py: fix memory leak --- src/Mod/Part/App/TopoShapeFacePyImp.cpp | 13 +++++++------ src/Mod/Part/App/TopoShapeVertexPyImp.cpp | 4 +++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Mod/Part/App/TopoShapeFacePyImp.cpp b/src/Mod/Part/App/TopoShapeFacePyImp.cpp index cd0ff350a1..ea6cd98bdf 100644 --- a/src/Mod/Part/App/TopoShapeFacePyImp.cpp +++ b/src/Mod/Part/App/TopoShapeFacePyImp.cpp @@ -977,13 +977,14 @@ Py::Object TopoShapeFacePy::getWire(void) const Py::Object TopoShapeFacePy::getOuterWire(void) const { - const TopoDS_Shape& clSh = getTopoShapePtr()->getShape(); - if (clSh.IsNull()) + const TopoDS_Shape& shape = getTopoShapePtr()->getShape(); + if (shape.IsNull()) throw Py::RuntimeError("Null shape"); - if (clSh.ShapeType() == TopAbs_FACE) { - TopoDS_Face clFace = (TopoDS_Face&)clSh; - TopoDS_Wire clWire = ShapeAnalysis::OuterWire(clFace); - return Py::Object(new TopoShapeWirePy(new TopoShape(clWire)),true); + if (shape.ShapeType() == TopAbs_FACE) { + TopoDS_Wire wire = ShapeAnalysis::OuterWire(TopoDS::Face(shape)); + Base::PyObjectBase* wirepy = new TopoShapeWirePy(new TopoShape(wire)); + wirepy->setNotTracking(); + return Py::asObject(wirepy); } else { throw Py::TypeError("Internal error, TopoDS_Shape is not a face!"); diff --git a/src/Mod/Part/App/TopoShapeVertexPyImp.cpp b/src/Mod/Part/App/TopoShapeVertexPyImp.cpp index 6c7dd4bba0..35ba09393e 100644 --- a/src/Mod/Part/App/TopoShapeVertexPyImp.cpp +++ b/src/Mod/Part/App/TopoShapeVertexPyImp.cpp @@ -194,7 +194,9 @@ Py::Object TopoShapeVertexPy::getPoint(void) const try { const TopoDS_Vertex& v = TopoDS::Vertex(getTopoShapePtr()->getShape()); gp_Pnt p = BRep_Tool::Pnt(v); - return Py::asObject(new Base::VectorPy(new Base::Vector3d(p.X(),p.Y(),p.Z()))); + Base::PyObjectBase* pnt = new Base::VectorPy(new Base::Vector3d(p.X(),p.Y(),p.Z())); + pnt->setNotTracking(); + return Py::asObject(pnt); } catch (Standard_Failure& e) { From 2751398ec0adc3ee7d50b160f8c333bc6996946a Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Fri, 9 Apr 2021 11:57:44 -0500 Subject: [PATCH 082/178] [OpenSCAD] Fix twist angle to not limit to 360 deg --- src/Mod/OpenSCAD/OpenSCADFeatures.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/Mod/OpenSCAD/OpenSCADFeatures.py b/src/Mod/OpenSCAD/OpenSCADFeatures.py index 433cf0d83f..b3cd2d0a24 100644 --- a/src/Mod/OpenSCAD/OpenSCADFeatures.py +++ b/src/Mod/OpenSCAD/OpenSCADFeatures.py @@ -390,12 +390,13 @@ class Twist: def __init__(self, obj,child=None,h=1.0,angle=0.0,scale=[1.0,1.0]): obj.addProperty("App::PropertyLink","Base","Base", "The base object that must be transformed") - obj.addProperty("App::PropertyAngle","Angle","Base","Twist Angle in degrees") #degree or rad + obj.addProperty("App::PropertyQuantity","Angle","Base","Twist Angle") + obj.Angle = App.Units.Angle # assign the Angle unit obj.addProperty("App::PropertyDistance","Height","Base","Height of the Extrusion") obj.addProperty("App::PropertyFloatList","Scale","Base","Scale to apply during the Extrusion") obj.Base = child - obj.Angle = angle + obj.Angle = angle obj.Height = h obj.Scale = scale obj.Proxy = self From c65504fc9222c3c859753d1ca7a8cdc24c53905c Mon Sep 17 00:00:00 2001 From: bitacovir Date: Fri, 9 Apr 2021 14:18:22 -0400 Subject: [PATCH 083/178] [UI] Add SVG icon for Std TransformManip command --- src/Gui/CommandDoc.cpp | 1 + src/Gui/Icons/Std_TransformManip.svg | 269 +++++++++++++++++++++++++++ src/Gui/Icons/resource.qrc | 1 + 3 files changed, 271 insertions(+) create mode 100644 src/Gui/Icons/Std_TransformManip.svg diff --git a/src/Gui/CommandDoc.cpp b/src/Gui/CommandDoc.cpp index 066d876a17..155865b179 100644 --- a/src/Gui/CommandDoc.cpp +++ b/src/Gui/CommandDoc.cpp @@ -1590,6 +1590,7 @@ StdCmdTransformManip::StdCmdTransformManip() sToolTipText = QT_TR_NOOP("Transform the selected object in the 3d view"); sStatusTip = QT_TR_NOOP("Transform the selected object in the 3d view"); sWhatsThis = "Std_TransformManip"; + sPixmap = "Std_TransformManip"; } void StdCmdTransformManip::activated(int iMsg) diff --git a/src/Gui/Icons/Std_TransformManip.svg b/src/Gui/Icons/Std_TransformManip.svg new file mode 100644 index 0000000000..721a4bcf90 --- /dev/null +++ b/src/Gui/Icons/Std_TransformManip.svg @@ -0,0 +1,269 @@ + + + Std_TransformManip + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + Std_TransformManip + + + [bitacovir] + + + + + FreeCAD LGPL2+ + + + + + FreeCAD + + + 2021/04/09 + + + + + + + + + + + + + + + + + + + + diff --git a/src/Gui/Icons/resource.qrc b/src/Gui/Icons/resource.qrc index 9269f819ed..bea622cecf 100644 --- a/src/Gui/Icons/resource.qrc +++ b/src/Gui/Icons/resource.qrc @@ -189,6 +189,7 @@ Std_Tool10.svg Std_Tool11.svg Std_Tool12.svg + Std_TransformManip.svg Std_ViewDimetric.svg Std_ViewHome.svg Std_ViewIvIssueCamPos.svg From 8c4b2506bd0e697c324c2700396d76362ef617fb Mon Sep 17 00:00:00 2001 From: wmayer Date: Sat, 10 Apr 2021 18:37:56 +0200 Subject: [PATCH 084/178] Import: [skip ci] for glTF export set scale factor of 0.001 because lengths are measured in meters --- src/Mod/Import/Gui/AppImportGuiPy.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Mod/Import/Gui/AppImportGuiPy.cpp b/src/Mod/Import/Gui/AppImportGuiPy.cpp index e081764279..6601973cc2 100644 --- a/src/Mod/Import/Gui/AppImportGuiPy.cpp +++ b/src/Mod/Import/Gui/AppImportGuiPy.cpp @@ -693,7 +693,8 @@ private: TColStd_IndexedDataMapOfStringString aMetadata; RWGltf_CafWriter aWriter (name8bit.c_str(), file.hasExtension("glb")); aWriter.SetTransformationFormat (RWGltf_WriterTrsfFormat_Compact); - //aWriter.ChangeCoordinateSystemConverter().SetInputLengthUnit (0.001); + // https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#coordinate-system-and-units + aWriter.ChangeCoordinateSystemConverter().SetInputLengthUnit (0.001); aWriter.ChangeCoordinateSystemConverter().SetInputCoordinateSystem (RWMesh_CoordinateSystem_Zup); Standard_Boolean ret = aWriter.Perform (hDoc, aMetadata, Message_ProgressRange()); if (!ret) { From c617b252ff362e2ef6c91dcefce1af4ee93d7b9a Mon Sep 17 00:00:00 2001 From: Stephen Early Date: Sat, 10 Apr 2021 17:39:46 +0100 Subject: [PATCH 085/178] Improve WebGL export javascript template Several improvements to the javascript in the template: * Render on demand rather than continuously * Support high-DPI displays * Fix the frustum depth for both cameras * Deal correctly with the browser window being resized * Only show controls for objects with geometry Also some changes made for code clarity: * Use 'const' and 'let' instead of 'var', as appropriate * Use for...of and .map() instead of iterating over arrays using a loop counter --- src/Mod/Arch/importWebGL.py | 783 ++++++++++++++++++++---------------- 1 file changed, 434 insertions(+), 349 deletions(-) diff --git a/src/Mod/Arch/importWebGL.py b/src/Mod/Arch/importWebGL.py index 3558dca0a8..e2e2302200 100644 --- a/src/Mod/Arch/importWebGL.py +++ b/src/Mod/Arch/importWebGL.py @@ -38,6 +38,7 @@ """FreeCAD WebGL Exporter""" import FreeCAD,Mesh,Draft,Part,OfflineRenderingUtils,json,six +import textwrap if FreeCAD.GuiUp: import FreeCADGui @@ -60,291 +61,324 @@ base = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!#$%&()*+- baseFloat = ',.-0123456789' def getHTMLTemplate(): - return """ + return textwrap.dedent("""\ + $pagetitle - - - + + + + + - """ + """) def export( exportList, filename, colors = None, camera = None ): """Exports objects to an html file""" @@ -772,11 +858,10 @@ def export( exportList, filename, colors = None, camera = None ): html = html.replace('$version',version[0] + '.' + version[1] + '.' + version[2]) # Remove data compression in JS - if disableCompression: html = html.replace('$disableCompression','true') - else: html = html.replace('$disableCompression','false') + data['compressed'] = not disableCompression + data['base'] = base + data['baseFloat'] = baseFloat - html = html.replace('$base', base) - html = html.replace('$float', baseFloat) html = html.replace('$data', json.dumps(data, separators=(',', ':')) ) # Shape Data if six.PY2: From dbbac56185fa8bd559f85ab09fd5f9fa741ec785 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 11 Apr 2021 14:54:11 +0200 Subject: [PATCH 086/178] Base: do not report C++ exception when converting it to Python exception See https://forum.freecadweb.org/viewtopic.php?f=23&t=56464 --- src/Base/PyObjectBase.h | 2 -- src/Mod/Part/App/OCCError.h | 1 - src/Tools/generateTemplates/templateClassPyExport.py | 6 ------ 3 files changed, 9 deletions(-) diff --git a/src/Base/PyObjectBase.h b/src/Base/PyObjectBase.h index d7d1c0b6e8..593253f89e 100644 --- a/src/Base/PyObjectBase.h +++ b/src/Base/PyObjectBase.h @@ -463,12 +463,10 @@ BaseExport extern PyObject* BaseExceptionFreeCADAbort; #define __PY_CATCH(R) \ catch(Base::AbortException &e) \ { \ - e.ReportException(); \ _Py_ErrorObj(R,Base::BaseExceptionFreeCADAbort,e.getPyObject());\ } \ catch(Base::Exception &e) \ { \ - e.ReportException(); \ auto pye = e.getPyExceptionType(); \ if(!pye) \ pye = Base::BaseExceptionFreeCADError; \ diff --git a/src/Mod/Part/App/OCCError.h b/src/Mod/Part/App/OCCError.h index fbdd98d202..411641858a 100644 --- a/src/Mod/Part/App/OCCError.h +++ b/src/Mod/Part/App/OCCError.h @@ -80,7 +80,6 @@ PartExport extern PyObject* PartExceptionOCCDimensionError; str += " "; \ if (msg) {str += msg;} \ else {str += "No OCCT Exception Message";} \ - Base::Console().Error(str.c_str()); \ _Py_Error(R,Part::PartExceptionOCCError,str.c_str()); \ } \ _PY_CATCH(R) diff --git a/src/Tools/generateTemplates/templateClassPyExport.py b/src/Tools/generateTemplates/templateClassPyExport.py index bc7f60749a..4621d855b3 100644 --- a/src/Tools/generateTemplates/templateClassPyExport.py +++ b/src/Tools/generateTemplates/templateClassPyExport.py @@ -615,13 +615,11 @@ PyObject * @self.export.Name@::staticCallback_@i.Name@ (PyObject *self, PyObject } // Please sync the following catch implementation with PY_CATCH catch(Base::AbortException &e) { - e.ReportException(); PyErr_SetObject(Base::BaseExceptionFreeCADAbort,e.getPyObject()); return NULL; } catch(Base::Exception &e) { - e.ReportException(); auto pye = e.getPyExceptionType(); if(!pye) pye = Base::BaseExceptionFreeCADError; @@ -790,13 +788,11 @@ PyObject *@self.export.Name@::_getattr(const char *attr) // __getattr__ functi } // Please sync the following catch implementation with PY_CATCH catch(Base::AbortException &e) { - e.ReportException(); PyErr_SetObject(Base::BaseExceptionFreeCADAbort,e.getPyObject()); return NULL; } catch(Base::Exception &e) { - e.ReportException(); auto pye = e.getPyExceptionType(); if(!pye) pye = Base::BaseExceptionFreeCADError; @@ -852,13 +848,11 @@ int @self.export.Name@::_setattr(const char *attr, PyObject *value) // __setattr } // Please sync the following catch implementation with PY_CATCH catch(Base::AbortException &e) { - e.ReportException(); PyErr_SetObject(Base::BaseExceptionFreeCADAbort,e.getPyObject()); return -1; } catch(Base::Exception &e) { - e.ReportException(); auto pye = e.getPyExceptionType(); if(!pye) pye = Base::BaseExceptionFreeCADError; From d0c1935cbf32820c6ad36977304435b4a4eda0e8 Mon Sep 17 00:00:00 2001 From: marioalexis Date: Sun, 11 Apr 2021 16:24:02 -0300 Subject: [PATCH 087/178] Draft: Fix regression in trimex command --- src/Mod/Draft/draftguitools/gui_trimex.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Mod/Draft/draftguitools/gui_trimex.py b/src/Mod/Draft/draftguitools/gui_trimex.py index 47b449d641..c478d4fcab 100644 --- a/src/Mod/Draft/draftguitools/gui_trimex.py +++ b/src/Mod/Draft/draftguitools/gui_trimex.py @@ -120,7 +120,7 @@ class Trimex(gui_base_original.Modifier): self.extrudeMode = True self.ghost = [trackers.ghostTracker([self.obj])] self.normal = self.obj.Shape.Faces[0].normalAt(0.5, 0.5) - self.ghost += [trackers.lineTracker()] * len(self.obj.Shape.Vertexes) + self.ghost += [trackers.lineTracker() for _v in self.obj.Shape.Vertexes] elif len(self.obj.Shape.Faces) > 1: # face extrude mode, a new object is created ss = Gui.Selection.getSelectionEx()[0] @@ -131,7 +131,7 @@ class Trimex(gui_base_original.Modifier): self.extrudeMode = True self.ghost = [trackers.ghostTracker([self.obj])] self.normal = self.obj.Shape.Faces[0].normalAt(0.5, 0.5) - self.ghost += [trackers.lineTracker()] * len(self.obj.Shape.Vertexes) + self.ghost += [trackers.lineTracker() for _v in self.obj.Shape.Vertexes] else: # normal wire trimex mode self.color = self.obj.ViewObject.LineColor From 333859d618deada642128a3c876953431f0604c4 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 12 Apr 2021 00:05:42 +0200 Subject: [PATCH 088/178] Py: fix memory leak --- src/Mod/Part/App/TopoShape.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Mod/Part/App/TopoShape.cpp b/src/Mod/Part/App/TopoShape.cpp index 76e46556ae..a714012221 100644 --- a/src/Mod/Part/App/TopoShape.cpp +++ b/src/Mod/Part/App/TopoShape.cpp @@ -592,6 +592,7 @@ PyObject * TopoShape::getPyObject() } } + prop->setNotTracking(); return prop; } From a61c930aaaa50ae79207f53a9d8e7a76397bcec7 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 12 Apr 2021 00:06:00 +0200 Subject: [PATCH 089/178] Py: fix memory leak --- src/Base/QuantityPyImp.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/Base/QuantityPyImp.cpp b/src/Base/QuantityPyImp.cpp index 60266fd737..90af3385bd 100644 --- a/src/Base/QuantityPyImp.cpp +++ b/src/Base/QuantityPyImp.cpp @@ -672,25 +672,31 @@ void QuantityPy::setFormat(Py::Dict arg) PyObject *QuantityPy::getCustomAttributes(const char* attr) const { + QuantityPy* py = nullptr; if (strcmp(attr, "Torr") == 0) { - return new QuantityPy(new Quantity(Quantity::Torr)); + py = new QuantityPy(new Quantity(Quantity::Torr)); } else if (strcmp(attr, "mTorr") == 0) { - return new QuantityPy(new Quantity(Quantity::mTorr)); + py = new QuantityPy(new Quantity(Quantity::mTorr)); } else if (strcmp(attr, "yTorr") == 0) { - return new QuantityPy(new Quantity(Quantity::yTorr)); + py = new QuantityPy(new Quantity(Quantity::yTorr)); } else if (strcmp(attr, "PoundForce") == 0) { - return new QuantityPy(new Quantity(Quantity::PoundForce)); + py = new QuantityPy(new Quantity(Quantity::PoundForce)); } else if (strcmp(attr, "AngularMinute") == 0) { - return new QuantityPy(new Quantity(Quantity::AngMinute)); + py = new QuantityPy(new Quantity(Quantity::AngMinute)); } else if (strcmp(attr, "AngularSecond") == 0) { - return new QuantityPy(new Quantity(Quantity::AngSecond)); + py = new QuantityPy(new Quantity(Quantity::AngSecond)); } - return 0; + + if (py) { + py->setNotTracking(); + } + + return py; } int QuantityPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/) From 08ee40692a86f60fcbff1f0376ac45229967abbc Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 12 Apr 2021 00:06:18 +0200 Subject: [PATCH 090/178] Gui: fix memory leak --- src/Gui/FileDialog.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Gui/FileDialog.cpp b/src/Gui/FileDialog.cpp index f4312f55fd..1047880a50 100644 --- a/src/Gui/FileDialog.cpp +++ b/src/Gui/FileDialog.cpp @@ -194,7 +194,8 @@ QString FileDialog::getSaveFileName (QWidget * parent, const QString & caption, FileDialog dlg(parent); dlg.setWindowTitle(windowTitle); dlg.setSidebarUrls(urls); - dlg.setIconProvider(new FileIconProvider()); + auto iconprov = std::make_unique(); + dlg.setIconProvider(iconprov.get()); dlg.setFileMode(QFileDialog::AnyFile); dlg.setAcceptMode(QFileDialog::AcceptSave); dlg.setDirectory(dirName); From 056644390742b2ece0db2c7d28dad13d914d14ff Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 12 Apr 2021 14:17:16 +0200 Subject: [PATCH 091/178] Base: [skip ci] remove Py2 code from PyObjectBase --- src/Base/PyObjectBase.cpp | 48 +++++---------------------------------- 1 file changed, 6 insertions(+), 42 deletions(-) diff --git a/src/Base/PyObjectBase.cpp b/src/Base/PyObjectBase.cpp index a5967c60ac..6e6a8e44f6 100644 --- a/src/Base/PyObjectBase.cpp +++ b/src/Base/PyObjectBase.cpp @@ -103,11 +103,7 @@ PyTypeObject PyObjectBase::Type = { /* --- Functions to access object as input/output buffer ---------*/ 0, /* tp_as_buffer */ /* --- Flags to define presence of optional/expanded features */ -#if PY_MAJOR_VERSION >= 3 Py_TPFLAGS_BASETYPE|Py_TPFLAGS_DEFAULT, /*tp_flags */ -#else - Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_CLASS, /*tp_flags */ -#endif "The most base class for Python binding", /*tp_doc */ 0, /*tp_traverse */ 0, /*tp_clear */ @@ -134,10 +130,8 @@ PyTypeObject PyObjectBase::Type = { 0, /*tp_subclasses */ 0, /*tp_weaklist */ 0, /*tp_del */ - 0 /*tp_version_tag */ -#if PY_MAJOR_VERSION >= 3 - ,0 /*tp_finalize */ -#endif + 0, /*tp_version_tag */ + 0 /*tp_finalize */ #if PY_VERSION_HEX >= 0x03090000 ,0 /*tp_vectorcall */ #elif PY_VERSION_HEX >= 0x03080000 @@ -161,11 +155,7 @@ PyMethodDef PyObjectBase::Methods[] = { PyObject* PyObjectBase::__getattro(PyObject * obj, PyObject *attro) { const char *attr; -#if PY_MAJOR_VERSION >= 3 attr = PyUnicode_AsUTF8(attro); -#else - attr = PyString_AsString(attro); -#endif // For the __class__ attribute get it directly as with // ExtensionContainerPy::getCustomAttributes we may get @@ -204,7 +194,9 @@ PyObject* PyObjectBase::__getattro(PyObject * obj, PyObject *attro) pyObj->trackAttribute(attr, value); } } - else if (value && PyCFunction_Check(value)) { + else +#endif + if (value && PyCFunction_Check(value)) { // ExtensionContainerPy::initialization() transfers the methods of an // extension object by creating PyCFunction objects. // At this point no 'self' object is passed but is handled and determined @@ -220,18 +212,14 @@ PyObject* PyObjectBase::__getattro(PyObject * obj, PyObject *attro) PyErr_Format(PyExc_AttributeError, "", attr); } } -#endif + return value; } int PyObjectBase::__setattro(PyObject *obj, PyObject *attro, PyObject *value) { const char *attr; -#if PY_MAJOR_VERSION >= 3 attr = PyUnicode_AsUTF8(attro); -#else - attr = PyString_AsString(attro); -#endif //FIXME: In general we don't allow to delete attributes (i.e. value=0). However, if we want to allow //we must check then in _setattr() of all subclasses whether value is 0. @@ -294,11 +282,7 @@ PyObject *PyObjectBase::_getattr(const char *attr) else { // As fallback solution use Python's default method to get generic attributes PyObject *w, *res; -#if PY_MAJOR_VERSION >= 3 w = PyUnicode_InternFromString(attr); -#else - w = PyString_InternFromString(attr); -#endif if (w != NULL) { res = PyObject_GenericGetAttr(this, w); Py_XDECREF(w); @@ -318,11 +302,7 @@ int PyObjectBase::_setattr(const char *attr, PyObject *value) return -1; // filter out softspace PyObject *w; // As fallback solution use Python's default method to get generic attributes -#if PY_MAJOR_VERSION >= 3 w = PyUnicode_InternFromString(attr); // new reference -#else - w = PyString_InternFromString(attr); // new reference -#endif if (w != NULL) { // call methods from tp_getset if defined int res = PyObject_GenericSetAttr(this, w, value); @@ -354,13 +334,8 @@ void PyObjectBase::resetAttribute() if (attrDict) { // This is the attribute name to the parent structure // which we search for in the dict -#if PY_MAJOR_VERSION < 3 - PyObject* key1 = PyString_FromString("__attribute_of_parent__"); - PyObject* key2 = PyString_FromString("__instance_of_parent__"); -#else PyObject* key1 = PyBytes_FromString("__attribute_of_parent__"); PyObject* key2 = PyBytes_FromString("__instance_of_parent__"); -#endif PyObject* attr = PyDict_GetItem(attrDict, key1); PyObject* inst = PyDict_GetItem(attrDict, key2); if (attr) { @@ -379,15 +354,9 @@ void PyObjectBase::setAttributeOf(const char* attr, PyObject* par) if (!attrDict) { attrDict = PyDict_New(); } -#if PY_MAJOR_VERSION < 3 - PyObject* key1 = PyString_FromString("__attribute_of_parent__"); - PyObject* key2 = PyString_FromString("__instance_of_parent__"); - PyObject* attro = PyString_FromString(attr); -#else PyObject* key1 = PyBytes_FromString("__attribute_of_parent__"); PyObject* key2 = PyBytes_FromString("__instance_of_parent__"); PyObject* attro = PyUnicode_FromString(attr); -#endif PyDict_SetItem(attrDict, key1, attro); PyDict_SetItem(attrDict, key2, par); Py_DECREF(attro); @@ -403,13 +372,8 @@ void PyObjectBase::startNotify() if (attrDict) { // This is the attribute name to the parent structure // which we search for in the dict -#if PY_MAJOR_VERSION < 3 - PyObject* key1 = PyString_FromString("__attribute_of_parent__"); - PyObject* key2 = PyString_FromString("__instance_of_parent__"); -#else PyObject* key1 = PyBytes_FromString("__attribute_of_parent__"); PyObject* key2 = PyBytes_FromString("__instance_of_parent__"); -#endif PyObject* attr = PyDict_GetItem(attrDict, key1); PyObject* parent = PyDict_GetItem(attrDict, key2); if (attr && parent) { From b15e41fdb1d7ddb29daf374f4ce5a5edde6c8ebb Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 12 Apr 2021 15:12:21 +0200 Subject: [PATCH 092/178] Base: [skip ci] add convenience function to get PyObjectBase from GeometryT --- src/Base/GeometryPyCXX.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Base/GeometryPyCXX.h b/src/Base/GeometryPyCXX.h index 8226918845..8dfd6cf9f8 100644 --- a/src/Base/GeometryPyCXX.h +++ b/src/Base/GeometryPyCXX.h @@ -185,11 +185,12 @@ public: } operator T() const { - // cast the PyObject pointer to the matching sub-class - // and call then the defined member function + return getValue(); + } + PyT* getPy() const + { PyT* py = static_cast(ptr()); - T* v = (py->*valuePtr)(); - return *v; + return py; } private: From d573386ec1ca8b0edaf720152e7e6b0765113bcd Mon Sep 17 00:00:00 2001 From: Uwe Date: Tue, 13 Apr 2021 07:32:44 +0200 Subject: [PATCH 093/178] [FEM] add support for 3D recombinations (#4706) * [FEM] add support for 3D recombinations currently we only support surface recombinations but for some applications 3D recombinations are useful as well * add support for the recombination algorithms using a sensible algorithm is important to get useful results, see https://wiki.freecadweb.org/FEM_MeshGmshFromShape#Properties where I described examples --- src/Mod/Fem/femmesh/gmshtools.py | 22 +++++++++++++++++++++- src/Mod/Fem/femobjects/mesh_gmsh.py | 27 ++++++++++++++++++++++++++- 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/src/Mod/Fem/femmesh/gmshtools.py b/src/Mod/Fem/femmesh/gmshtools.py index 801104de94..d77260b4cf 100644 --- a/src/Mod/Fem/femmesh/gmshtools.py +++ b/src/Mod/Fem/femmesh/gmshtools.py @@ -125,6 +125,19 @@ class GmshTools(): else: self.algorithm3D = "1" + # RecombinationAlgorithm + algoRecombo = self.mesh_obj.RecombinationAlgorithm + if algoRecombo == "Simple": + self.RecombinationAlgorithm = "0" + elif algoRecombo == "Blossom": + self.RecombinationAlgorithm = "1" + elif algoRecombo == "Simple full-quad": + self.RecombinationAlgorithm = "2" + elif algoRecombo == "Blossom full-quad": + self.RecombinationAlgorithm = "3" + else: + self.algoRecombo = "0" + # HighOrderOptimize optimizers = self.mesh_obj.HighOrderOptimize if optimizers == "None": @@ -766,8 +779,15 @@ class GmshTools(): ) geo.write("\n") if hasattr(self.mesh_obj, "RecombineAll") and self.mesh_obj.RecombineAll is True: - geo.write("// other mesh options\n") + geo.write("// recombination for surfaces\n") geo.write("Mesh.RecombineAll = 1;\n") + if hasattr(self.mesh_obj, "Recombine3DAll") and self.mesh_obj.Recombine3DAll is True: + geo.write("// recombination for volumes\n") + geo.write("Mesh.Recombine3DAll = 1;\n") + if ( (hasattr(self.mesh_obj, "RecombineAll") and self.mesh_obj.RecombineAll is True) + or (hasattr(self.mesh_obj, "Recombine3DAll") and self.mesh_obj.Recombine3DAll is True)): + geo.write("// recombination algorithm\n") + geo.write("Mesh.RecombinationAlgorithm = " + self.RecombinationAlgorithm + ";\n") geo.write("\n") geo.write("// optimize the mesh\n") diff --git a/src/Mod/Fem/femobjects/mesh_gmsh.py b/src/Mod/Fem/femobjects/mesh_gmsh.py index cc1167a0b8..9feeef7737 100644 --- a/src/Mod/Fem/femobjects/mesh_gmsh.py +++ b/src/Mod/Fem/femobjects/mesh_gmsh.py @@ -60,6 +60,12 @@ class MeshGmsh(base_fempythonobject.BaseFemPythonObject): "R-tree", "HXT" ] + known_mesh_RecombinationAlgorithms = [ + "Simple", + "Blossom", + "Simple full-quad", + "Blossom full-quad" + ] known_mesh_HighOrderOptimizers = [ "None", "Optimization", @@ -169,7 +175,7 @@ class MeshGmsh(base_fempythonobject.BaseFemPythonObject): "App::PropertyBool", "OptimizeStd", "FEM Gmsh Mesh Params", - "Optimize tetra elements" + "Optimize tetrahedral elements" ) obj.OptimizeStd = True @@ -201,6 +207,25 @@ class MeshGmsh(base_fempythonobject.BaseFemPythonObject): ) obj.RecombineAll = False + if not hasattr(obj, "Recombine3DAll"): + obj.addProperty( + "App::PropertyBool", + "Recombine3DAll", + "FEM Gmsh Mesh Params", + "Apply recombination algorithm to all volumes" + ) + obj.Recombine3DAll = False + + if not hasattr(obj, "RecombinationAlgorithm"): + obj.addProperty( + "App::PropertyEnumeration", + "RecombinationAlgorithm", + "FEM Gmsh Mesh Params", + "Recombination algorithm" + ) + obj.RecombinationAlgorithm = MeshGmsh.known_mesh_RecombinationAlgorithms + obj.RecombinationAlgorithm = "Simple" + if not hasattr(obj, "CoherenceMesh"): obj.addProperty( "App::PropertyBool", From 703670694500b9c5d130635c97d776a284ea69ea Mon Sep 17 00:00:00 2001 From: easyw Date: Tue, 13 Apr 2021 15:56:31 +0200 Subject: [PATCH 094/178] allowing to export stZ files on different drivers os.rename() doesn't move its actual data on the disk shutil.move() method allows to transfer files between two different drives --- src/Mod/Import/stepZ.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Mod/Import/stepZ.py b/src/Mod/Import/stepZ.py index fca2d48150..afec487d45 100644 --- a/src/Mod/Import/stepZ.py +++ b/src/Mod/Import/stepZ.py @@ -20,8 +20,9 @@ import ImportGui import PySide from PySide import QtGui, QtCore import tempfile +import shutil -___stpZversion___ = "1.3.7" +___stpZversion___ = "1.3.8" # support both gz and zipfile archives # Catia seems to use gz, Inventor zipfile # improved import, open and export @@ -175,10 +176,10 @@ def export(objs,filename): f_out.close() if os.path.exists(outfpath): os.remove(outfpath) - os.rename(outfpathT_str, outfpath) + shutil.move(outfpathT_str, outfpath) #os.remove(outfpathT_stp) else: - os.rename(outfpathT_str, outfpath) + shutil.move(outfpathT_str, outfpath) #os.remove(outfpathT_stp) #### From 2fd0bb68593b3b659d396c526cdd20e7e9963447 Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 13 Apr 2021 18:55:18 +0200 Subject: [PATCH 095/178] PD: [skip ci] fixes -Wreturn-std-move --- src/Mod/PartDesign/App/FeatureTransformed.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/PartDesign/App/FeatureTransformed.cpp b/src/Mod/PartDesign/App/FeatureTransformed.cpp index 4f5abc70b8..f52d1dfca8 100644 --- a/src/Mod/PartDesign/App/FeatureTransformed.cpp +++ b/src/Mod/PartDesign/App/FeatureTransformed.cpp @@ -461,7 +461,7 @@ TopoDS_Shape Transformed::getRemainingSolids(const TopoDS_Shape& shape) builder.Add(compShape, xp.Current()); } - return compShape; + return TopoDS_Shape(std::move(compShape)); } } From a54eab7187b1ea1664258f6e2c034b7e11f8b43f Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Wed, 7 Apr 2021 13:04:38 -0500 Subject: [PATCH 096/178] [GUI] Stylesheet fix for icons in Qt file dialog Work by @turn211. --- src/Gui/Stylesheets/Behave-dark.qss | 12 ++++++++++++ src/Gui/Stylesheets/Dark-blue.qss | 12 ++++++++++++ src/Gui/Stylesheets/Dark-contrast.qss | 12 ++++++++++++ src/Gui/Stylesheets/Dark-green.qss | 11 +++++++++++ src/Gui/Stylesheets/Dark-orange.qss | 12 ++++++++++++ src/Gui/Stylesheets/Darker-blue.qss | 12 ++++++++++++ src/Gui/Stylesheets/Darker-green.qss | 12 ++++++++++++ src/Gui/Stylesheets/Darker-orange.qss | 12 ++++++++++++ src/Gui/Stylesheets/Light-blue.qss | 12 ++++++++++++ src/Gui/Stylesheets/Light-green.qss | 12 ++++++++++++ src/Gui/Stylesheets/Light-orange.qss | 12 ++++++++++++ 11 files changed, 131 insertions(+) diff --git a/src/Gui/Stylesheets/Behave-dark.qss b/src/Gui/Stylesheets/Behave-dark.qss index 8cac105dc0..da1db23fc5 100644 --- a/src/Gui/Stylesheets/Behave-dark.qss +++ b/src/Gui/Stylesheets/Behave-dark.qss @@ -1552,6 +1552,18 @@ QPushButton:checked { border-color: #65A2E5; } +/*================================================================================================== +Tool button Icon fix in save dialogs +==================================================================================================*/ +/* found under Tools -> Save Picture */ /* Draft -> ShapeString -> Font file */ + +QFileDialog#QFileDialog QToolButton { + background-color: transparent; + padding: 1px; + border: 1px; + margin: 0px; +} + /*================================================================================================== Tool button inside QDialogs that works as QPushButtons diff --git a/src/Gui/Stylesheets/Dark-blue.qss b/src/Gui/Stylesheets/Dark-blue.qss index 22a21751af..32c2c0f3d1 100644 --- a/src/Gui/Stylesheets/Dark-blue.qss +++ b/src/Gui/Stylesheets/Dark-blue.qss @@ -1519,6 +1519,18 @@ QPushButton:checked { border-color: #3874f2; } +/*================================================================================================== +Tool button Icon fix in save dialogs +==================================================================================================*/ +/* found under Tools -> Save Picture */ /* Draft -> ShapeString -> Font file */ + +QFileDialog#QFileDialog QToolButton { + background-color: transparent; + padding: 1px; + border: 1px; + margin: 0px; +} + /*================================================================================================== Tool button inside QDialogs that works as QPushButtons diff --git a/src/Gui/Stylesheets/Dark-contrast.qss b/src/Gui/Stylesheets/Dark-contrast.qss index e73ce94ad4..a60202a669 100644 --- a/src/Gui/Stylesheets/Dark-contrast.qss +++ b/src/Gui/Stylesheets/Dark-contrast.qss @@ -1519,6 +1519,18 @@ QPushButton:checked { border-color: #2053c0; } +/*================================================================================================== +Tool button Icon fix in save dialogs +==================================================================================================*/ +/* found under Tools -> Save Picture */ /* Draft -> ShapeString -> Font file */ + +QFileDialog#QFileDialog QToolButton { + background-color: transparent; + padding: 1px; + border: 1px; + margin: 0px; +} + /*================================================================================================== Tool button inside QDialogs that works as QPushButtons diff --git a/src/Gui/Stylesheets/Dark-green.qss b/src/Gui/Stylesheets/Dark-green.qss index 829e141ce1..7b49d5bcd0 100644 --- a/src/Gui/Stylesheets/Dark-green.qss +++ b/src/Gui/Stylesheets/Dark-green.qss @@ -1519,6 +1519,17 @@ QPushButton:checked { border-color: #819c0c; } +/*================================================================================================== +Tool button Icon fix in save dialogs +==================================================================================================*/ +/* found under Tools -> Save Picture */ /* Draft -> ShapeString -> Font file */ + +QFileDialog#QFileDialog QToolButton { + background-color: transparent; + padding: 1px; + border: 1px; + margin: 0px; +} /*================================================================================================== Tool button inside QDialogs that works as QPushButtons diff --git a/src/Gui/Stylesheets/Dark-orange.qss b/src/Gui/Stylesheets/Dark-orange.qss index f36840ef99..4305187e0f 100644 --- a/src/Gui/Stylesheets/Dark-orange.qss +++ b/src/Gui/Stylesheets/Dark-orange.qss @@ -1519,6 +1519,18 @@ QPushButton:checked { border-color: #d0970c; } +/*================================================================================================== +Tool button Icon fix in save dialogs +==================================================================================================*/ +/* found under Tools -> Save Picture */ /* Draft -> ShapeString -> Font file */ + +QFileDialog#QFileDialog QToolButton { + background-color: transparent; + padding: 1px; + border: 1px; + margin: 0px; +} + /*================================================================================================== Tool button inside QDialogs that works as QPushButtons diff --git a/src/Gui/Stylesheets/Darker-blue.qss b/src/Gui/Stylesheets/Darker-blue.qss index 73cdd9a09a..12cf7a1204 100644 --- a/src/Gui/Stylesheets/Darker-blue.qss +++ b/src/Gui/Stylesheets/Darker-blue.qss @@ -1519,6 +1519,18 @@ QPushButton:checked { border-color: #2053c0; } +/*================================================================================================== +Tool button Icon fix in save dialogs +==================================================================================================*/ +/* found under Tools -> Save Picture */ /* Draft -> ShapeString -> Font file */ + +QFileDialog#QFileDialog QToolButton { + background-color: transparent; + padding: 1px; + border: 1px; + margin: 0px; +} + /*================================================================================================== Tool button inside QDialogs that works as QPushButtons diff --git a/src/Gui/Stylesheets/Darker-green.qss b/src/Gui/Stylesheets/Darker-green.qss index f18adf34cd..9a54cefc36 100644 --- a/src/Gui/Stylesheets/Darker-green.qss +++ b/src/Gui/Stylesheets/Darker-green.qss @@ -1519,6 +1519,18 @@ QPushButton:checked { border-color: #74831d; } +/*================================================================================================== +Tool button Icon fix in save dialogs +==================================================================================================*/ +/* found under Tools -> Save Picture */ /* Draft -> ShapeString -> Font file */ + +QFileDialog#QFileDialog QToolButton { + background-color: transparent; + padding: 1px; + border: 1px; + margin: 0px; +} + /*================================================================================================== Tool button inside QDialogs that works as QPushButtons diff --git a/src/Gui/Stylesheets/Darker-orange.qss b/src/Gui/Stylesheets/Darker-orange.qss index 316b908814..1f94c59206 100644 --- a/src/Gui/Stylesheets/Darker-orange.qss +++ b/src/Gui/Stylesheets/Darker-orange.qss @@ -1519,6 +1519,18 @@ QPushButton:checked { border-color: #b28416; } +/*================================================================================================== +Tool button Icon fix in save dialogs +==================================================================================================*/ +/* found under Tools -> Save Picture */ /* Draft -> ShapeString -> Font file */ + +QFileDialog#QFileDialog QToolButton { + background-color: transparent; + padding: 1px; + border: 1px; + margin: 0px; +} + /*================================================================================================== Tool button inside QDialogs that works as QPushButtons diff --git a/src/Gui/Stylesheets/Light-blue.qss b/src/Gui/Stylesheets/Light-blue.qss index 18e4bef37f..0742fd3cf2 100644 --- a/src/Gui/Stylesheets/Light-blue.qss +++ b/src/Gui/Stylesheets/Light-blue.qss @@ -1516,6 +1516,18 @@ QPushButton:checked { border-color: #3874f2; } +/*================================================================================================== +Tool button Icon fix in save dialogs +==================================================================================================*/ +/* found under Tools -> Save Picture */ /* Draft -> ShapeString -> Font file */ + +QFileDialog#QFileDialog QToolButton { + background-color: transparent; + padding: 1px; + border: 1px; + margin: 0px; +} + /*================================================================================================== Tool button inside QDialogs that works as QPushButtons diff --git a/src/Gui/Stylesheets/Light-green.qss b/src/Gui/Stylesheets/Light-green.qss index ef63811bc9..6bf2e1a460 100644 --- a/src/Gui/Stylesheets/Light-green.qss +++ b/src/Gui/Stylesheets/Light-green.qss @@ -1516,6 +1516,18 @@ QPushButton:checked { border-color: #819c0c; } +/*================================================================================================== +Tool button Icon fix in save dialogs +==================================================================================================*/ +/* found under Tools -> Save Picture */ /* Draft -> ShapeString -> Font file */ + +QFileDialog#QFileDialog QToolButton { + background-color: transparent; + padding: 1px; + border: 1px; + margin: 0px; +} + /*================================================================================================== Tool button inside QDialogs that works as QPushButtons diff --git a/src/Gui/Stylesheets/Light-orange.qss b/src/Gui/Stylesheets/Light-orange.qss index 2503a85cd7..3df634467c 100644 --- a/src/Gui/Stylesheets/Light-orange.qss +++ b/src/Gui/Stylesheets/Light-orange.qss @@ -1516,6 +1516,18 @@ QPushButton:checked { border-color: #d0970c; } +/*================================================================================================== +Tool button Icon fix in save dialogs +==================================================================================================*/ +/* found under Tools -> Save Picture */ /* Draft -> ShapeString -> Font file */ + +QFileDialog#QFileDialog QToolButton { + background-color: transparent; + padding: 1px; + border: 1px; + margin: 0px; +} + /*================================================================================================== Tool button inside QDialogs that works as QPushButtons From f43329f80aba5bffc6cb11212fcc601ec5078566 Mon Sep 17 00:00:00 2001 From: ShoofLLC <15924772+ShoofLLC@users.noreply.github.com> Date: Tue, 13 Apr 2021 23:05:42 +0200 Subject: [PATCH 097/178] Added the removable-media plug I'm trying to use freecad with external storage but the snap doesn't provide the removable media plug --- vagrant/generate_yaml.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vagrant/generate_yaml.sh b/vagrant/generate_yaml.sh index 0528dfab54..ff6f2c9189 100755 --- a/vagrant/generate_yaml.sh +++ b/vagrant/generate_yaml.sh @@ -117,5 +117,5 @@ echo " apps: FreeCAD: command: bin/launcher - plugs: [ locale-control,x11,opengl,network-bind,home,unity7 ] + plugs: [ locale-control,x11,opengl,network-bind,home,unity7,removable-media ] " >> snapcraft.yaml From 3a7583be5ede1b3b68848f97b2facd5f6c70f253 Mon Sep 17 00:00:00 2001 From: ShoofLLC <15924772+ShoofLLC@users.noreply.github.com> Date: Tue, 13 Apr 2021 23:07:21 +0200 Subject: [PATCH 098/178] added removable-media plug --- vagrant/Xenial/generate_yaml.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vagrant/Xenial/generate_yaml.sh b/vagrant/Xenial/generate_yaml.sh index 37107c40bb..3f20c4866c 100755 --- a/vagrant/Xenial/generate_yaml.sh +++ b/vagrant/Xenial/generate_yaml.sh @@ -101,5 +101,5 @@ echo " apps: FreeCAD: command: bin/launcher - plugs: [ locale-control,x11,opengl,network-bind,home,unity7 ] + plugs: [ locale-control,x11,opengl,network-bind,home,unity7,removable-media ] " >> snapcraft.yaml From cc7f36599e88afdbccde69145afa5d52000e7e8d Mon Sep 17 00:00:00 2001 From: Pierre Le Moine Date: Mon, 12 Apr 2021 18:23:37 +0200 Subject: [PATCH 099/178] Remove ancient dockerfile --- .gitignore | 1 - .subuser.json | 1 - subuser/freecad-dev/image/Dockerfile | 14 -------------- subuser/freecad-dev/permissions.json | 11 ----------- 4 files changed, 27 deletions(-) delete mode 100644 .subuser.json delete mode 100644 subuser/freecad-dev/image/Dockerfile delete mode 100644 subuser/freecad-dev/permissions.json diff --git a/.gitignore b/.gitignore index 82e1234e88..1f9a93accd 100644 --- a/.gitignore +++ b/.gitignore @@ -34,7 +34,6 @@ install_manifest.txt /src/Tools/offlinedoc/localwiki/ /src/Tools/offlinedoc/*.txt OpenSCAD_rc.py -.subuser-dev /\.idea/ .tags tags diff --git a/.subuser.json b/.subuser.json deleted file mode 100644 index a004b52acb..0000000000 --- a/.subuser.json +++ /dev/null @@ -1 +0,0 @@ -{"image-sources-dir": "./subuser"} \ No newline at end of file diff --git a/subuser/freecad-dev/image/Dockerfile b/subuser/freecad-dev/image/Dockerfile deleted file mode 100644 index e971bd04e1..0000000000 --- a/subuser/freecad-dev/image/Dockerfile +++ /dev/null @@ -1,14 +0,0 @@ -FROM ubuntu:14.04 -RUN apt-get update -RUN apt-get install -yqq software-properties-common -RUN add-apt-repository ppa:freecad-maintainers/freecad-daily -RUN apt-get update -RUN apt-get install -yqq build-essential python python2.7-dev subversion cmake libtool autotools-dev automake bison flex gfortran git -RUN apt-get install -yqq libCoin80-dev libCoin80-doc libsoqt4-dev libqt4-dev qt4-dev-tools libsoqt4-dev python-qt4 libqtwebkit-dev -RUN apt-get install -yqq liboce-foundation-dev liboce-modeling-dev liboce-ocaf-dev liboce-visualization-dev oce-draw -RUN apt-get install -yqq libode-dev libeigen2-dev libeigen3-dev libsimage-dev libxerces-c2-dev -RUN apt-get install -yqq libpyside-dev pyside-tools libshiboken-dev doxygen python-pivy -RUN apt-get install -yqq libboost1.55-all-dev -RUN apt-get install -yqq libmedc-dev libvtk6-dev libproj-dev -RUN apt-get install -yqq libxerces-c-dev -RUN ln -s /usr/lib/x86_64-linux-gnu/libxerces-c.so /usr/lib/libxerces-c.so diff --git a/subuser/freecad-dev/permissions.json b/subuser/freecad-dev/permissions.json deleted file mode 100644 index 509ee26c6c..0000000000 --- a/subuser/freecad-dev/permissions.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "maintainer": "Timothy ", - "stateful-home": true, - "executable": "/bin/bash", - "allow-network-access": true, - "basic-common-permissions": true, - "description": "A development environment for building and running freecad.", - "access-working-directory": true, - "graphics-card": true, - "gui": {"clipboard":true} -} From a213071c87e34ebcf36fedd72902216af0881c23 Mon Sep 17 00:00:00 2001 From: luz paz Date: Mon, 12 Apr 2021 10:56:27 -0400 Subject: [PATCH 100/178] Gui: remove Py2 code from several src/Gui .cpp files --- src/Gui/ApplicationPy.cpp | 8 ----- src/Gui/CommandPyImp.cpp | 21 ------------- src/Gui/OnlineDocumentation.cpp | 8 ----- src/Gui/PythonConsole.cpp | 24 +-------------- src/Gui/PythonConsolePy.cpp | 24 --------------- src/Gui/PythonDebugger.cpp | 8 ----- src/Gui/Selection.cpp | 10 ------- src/Gui/WidgetFactory.cpp | 52 --------------------------------- src/Main/FreeCADGuiPy.cpp | 6 ---- src/Main/MainPy.cpp | 31 -------------------- 10 files changed, 1 insertion(+), 191 deletions(-) diff --git a/src/Gui/ApplicationPy.cpp b/src/Gui/ApplicationPy.cpp index 9124592a90..746b383373 100644 --- a/src/Gui/ApplicationPy.cpp +++ b/src/Gui/ApplicationPy.cpp @@ -737,11 +737,7 @@ PyObject* Application::sGetLocale(PyObject * /*self*/, PyObject *args) return NULL; std::string locale = Translator::instance()->activeLanguage(); -#if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(locale.c_str()); -#else - return PyString_FromString(locale.c_str()); -#endif } PyObject* Application::sSetLocale(PyObject * /*self*/, PyObject *args) @@ -819,11 +815,7 @@ PyObject* Application::sAddPreferencePage(PyObject * /*self*/, PyObject *args) PyObject* dlg; // old style classes -#if PY_MAJOR_VERSION >= 3 if (PyArg_ParseTuple(args, "O!s", &PyType_Type, &dlg, &grp)) { -#else - if (PyArg_ParseTuple(args, "O!s", &PyClass_Type, &dlg, &grp)) { -#endif // add to the preferences dialog new PrefPagePyProducer(Py::Object(dlg), grp); diff --git a/src/Gui/CommandPyImp.cpp b/src/Gui/CommandPyImp.cpp index ac53da4441..b705ec8149 100644 --- a/src/Gui/CommandPyImp.cpp +++ b/src/Gui/CommandPyImp.cpp @@ -77,11 +77,7 @@ PyObject* CommandPy::listAll(PyObject *args) PyObject* pyList = PyList_New(cmds.size()); int i=0; for ( std::vector::iterator it = cmds.begin(); it != cmds.end(); ++it ) { -#if PY_MAJOR_VERSION >= 3 PyObject* str = PyUnicode_FromString((*it)->getName()); -#else - PyObject* str = PyString_FromString((*it)->getName()); -#endif PyList_SetItem(pyList, i++, str); } return pyList; @@ -123,11 +119,7 @@ PyObject* CommandPy::listByShortcut(PyObject *args) PyObject* pyList = PyList_New(matches.size()); int i=0; for (std::string match : matches) { -#if PY_MAJOR_VERSION >= 3 PyObject* str = PyUnicode_FromString(match.c_str()); -#else - PyObject* str = PyString_FromString(match.c_str()); -#endif PyList_SetItem(pyList, i++, str); } return pyList; @@ -178,11 +170,7 @@ PyObject* CommandPy::getShortcut(PyObject *args) Command* cmd = this->getCommandPtr(); if (cmd) { -#if PY_MAJOR_VERSION >= 3 PyObject* str = PyUnicode_FromString(cmd->getAction() ? cmd->getAction()->shortcut().toString().toStdString().c_str() : ""); -#else - PyObject* str = PyString_FromString(cmd->getAction() ? cmd->getAction()->shortcut().toString().toStdString().c_str() : ""); -#endif return str; } else { @@ -283,21 +271,12 @@ PyObject* CommandPy::getInfo(PyObject *args) if (action) shortcutTxt = action->shortcut().toString().toStdString(); -#if PY_MAJOR_VERSION >= 3 PyObject* strMenuTxt = PyUnicode_FromString(menuTxt ? menuTxt : ""); PyObject* strTooltipTxt = PyUnicode_FromString(tooltipTxt ? tooltipTxt : ""); PyObject* strWhatsThisTxt = PyUnicode_FromString(whatsThisTxt ? whatsThisTxt : ""); PyObject* strStatustipTxt = PyUnicode_FromString(statustipTxt ? statustipTxt : ""); PyObject* strPixMapTxt = PyUnicode_FromString(pixMapTxt ? pixMapTxt : ""); PyObject* strShortcutTxt = PyUnicode_FromString(!shortcutTxt.empty() ? shortcutTxt.c_str() : ""); -#else - PyObject* strMenuTxt = PyString_FromString(menuTxt ? menuTxt : ""); - PyObject* strTooltipTxt = PyString_FromString(tooltipTxt ? tooltipTxt : ""); - PyObject* strWhatsThisTxt = PyString_FromString(whatsThisTxt ? whatsThisTxt : ""); - PyObject* strStatustipTxt = PyString_FromString(statustipTxt ? statustipTxt : ""); - PyObject* strPixMapTxt = PyString_FromString(pixMapTxt ? pixMapTxt : ""); - PyObject* strShortcutTxt = PyString_FromString(!shortcutTxt.empty() ? shortcutTxt.c_str() : ""); -#endif PyList_SetItem(pyList, 0, strMenuTxt); PyList_SetItem(pyList, 1, strTooltipTxt); PyList_SetItem(pyList, 2, strWhatsThisTxt); diff --git a/src/Gui/OnlineDocumentation.cpp b/src/Gui/OnlineDocumentation.cpp index 90b75c4683..9f7583effb 100644 --- a/src/Gui/OnlineDocumentation.cpp +++ b/src/Gui/OnlineDocumentation.cpp @@ -169,11 +169,7 @@ QByteArray PythonOnlineHelp::loadResource(const QString& filename) const if (result) { Py_DECREF(result); result = PyDict_GetItemString(dict, "htmldocument"); -#if PY_MAJOR_VERSION >= 3 const char* contents = PyUnicode_AsUTF8(result); -#else - const char* contents = PyString_AsString(result); -#endif res.append("HTTP/1.0 200 OK\n"); res.append("Content-type: text/html\n"); res.append(contents); @@ -204,11 +200,7 @@ QByteArray PythonOnlineHelp::loadResource(const QString& filename) const if (result) { Py_DECREF(result); result = PyDict_GetItemString(dict, "page"); -#if PY_MAJOR_VERSION >= 3 const char* page = PyUnicode_AsUTF8(result); -#else - const char* page = PyString_AsString(result); -#endif res.append("HTTP/1.0 200 OK\n"); res.append("Content-type: text/html\n"); res.append(page); diff --git a/src/Gui/PythonConsole.cpp b/src/Gui/PythonConsole.cpp index 16212fcc30..3eacfdacfa 100644 --- a/src/Gui/PythonConsole.cpp +++ b/src/Gui/PythonConsole.cpp @@ -171,17 +171,9 @@ void InteractiveInterpreter::setPrompt() Base::PyGILStateLocker lock; d->sysmodule = PyImport_ImportModule("sys"); if (!PyObject_HasAttrString(d->sysmodule, "ps1")) -#if PY_MAJOR_VERSION >= 3 PyObject_SetAttrString(d->sysmodule, "ps1", PyUnicode_FromString(">>> ")); -#else - PyObject_SetAttrString(d->sysmodule, "ps1", PyString_FromString(">>> ")); -#endif if (!PyObject_HasAttrString(d->sysmodule, "ps2")) -#if PY_MAJOR_VERSION >= 3 PyObject_SetAttrString(d->sysmodule, "ps2", PyUnicode_FromString("... ")); -#else - PyObject_SetAttrString(d->sysmodule, "ps2", PyString_FromString("... ")); -#endif } /** @@ -323,11 +315,7 @@ void InteractiveInterpreter::runCode(PyCodeObject* code) const throw Base::PyException(); /* not incref'd */ // It seems that the return value is always 'None' or Null -#if PY_MAJOR_VERSION >= 3 presult = PyEval_EvalCode((PyObject*)code, dict, dict); /* run compiled bytecode */ -#else - presult = PyEval_EvalCode(code, dict, dict); /* run compiled bytecode */ -#endif Py_XDECREF(code); /* decref the code object */ if (!presult) { if (PyErr_ExceptionMatches(PyExc_SystemExit)) { @@ -359,11 +347,7 @@ void InteractiveInterpreter::runCode(PyCodeObject* code) const } std::string err = str.str(); -#if PY_MAJOR_VERSION >= 3 errdata = PyUnicode_FromString(err.c_str()); -#else - errdata = PyString_FromString(err.c_str()); -#endif } } PyErr_Restore(errobj, errdata, errtraceback); @@ -474,13 +458,8 @@ PythonConsole::PythonConsole(QWidget *parent) d->_stdin = PySys_GetObject("stdin"); PySys_SetObject("stdin", d->_stdinPy); -#if PY_MAJOR_VERSION >= 3 const char* version = PyUnicode_AsUTF8(PySys_GetObject("version")); const char* platform = PyUnicode_AsUTF8(PySys_GetObject("platform")); -#else - const char* version = PyString_AsString(PySys_GetObject("version")); - const char* platform = PyString_AsString(PySys_GetObject("platform")); -#endif d->info = QString::fromLatin1("Python %1 on %2\n" "Type 'help', 'copyright', 'credits' or 'license' for more information.") .arg(QString::fromLatin1(version), QString::fromLatin1(platform)); @@ -837,12 +816,11 @@ void PythonConsole::runSource(const QString& line) setFocus(); // if focus was lost } catch (const Base::SystemExitException&) { -#if PY_MAJOR_VERSION >= 3 // In Python the exception must be cleared because when the message box below appears // callable Python objects can be invoked and due to a failing assert the application // will be aborted. PyErr_Clear(); -#endif + ParameterGrp::handle hPrefGrp = getWindowParameter(); bool check = hPrefGrp->GetBool("CheckSystemExit",true); int ret = QMessageBox::Yes; diff --git a/src/Gui/PythonConsolePy.cpp b/src/Gui/PythonConsolePy.cpp index c92b65a750..5f8be304e0 100644 --- a/src/Gui/PythonConsolePy.cpp +++ b/src/Gui/PythonConsolePy.cpp @@ -80,15 +80,9 @@ Py::Object PythonStdout::write(const Py::Tuple& args) try { Py::Object output(args[0]); if (PyUnicode_Check(output.ptr())) { -#if PY_MAJOR_VERSION >= 3 PyObject* unicode = PyUnicode_AsEncodedString(output.ptr(), "utf-8", 0); if (unicode) { const char* string = PyBytes_AsString(unicode); -#else - PyObject* unicode = PyUnicode_AsEncodedObject(output.ptr(), "utf-8", "strict"); - if (unicode) { - const char* string = PyString_AsString(unicode); -#endif int maxlen = qstrlen(string) > 10000 ? 10000 : -1; pyConsole->insertPythonOutput(QString::fromUtf8(string, maxlen)); Py_DECREF(unicode); @@ -163,15 +157,9 @@ Py::Object PythonStderr::write(const Py::Tuple& args) try { Py::Object output(args[0]); if (PyUnicode_Check(output.ptr())) { -#if PY_MAJOR_VERSION >= 3 PyObject* unicode = PyUnicode_AsEncodedString(output.ptr(), "utf-8", 0); if (unicode) { const char* string = PyBytes_AsString(unicode); -#else - PyObject* unicode = PyUnicode_AsEncodedObject(output.ptr(), "utf-8", "strict"); - if (unicode) { - const char* string = PyString_AsString(unicode); -#endif int maxlen = qstrlen(string) > 10000 ? 10000 : -1; pyConsole->insertPythonError(QString::fromUtf8(string, maxlen)); Py_DECREF(unicode); @@ -245,15 +233,9 @@ Py::Object OutputStdout::write(const Py::Tuple& args) try { Py::Object output(args[0]); if (PyUnicode_Check(output.ptr())) { -#if PY_MAJOR_VERSION >= 3 PyObject* unicode = PyUnicode_AsEncodedString(output.ptr(), "utf-8", 0); if (unicode) { const char* string = PyBytes_AsString(unicode); -#else - PyObject* unicode = PyUnicode_AsEncodedObject(output.ptr(), "utf-8", "strict"); - if (unicode) { - const char* string = PyString_AsString(unicode); -#endif Base::Console().Message("%s",string); Py_DECREF(unicode); } @@ -326,15 +308,9 @@ Py::Object OutputStderr::write(const Py::Tuple& args) try { Py::Object output(args[0]); if (PyUnicode_Check(output.ptr())) { -#if PY_MAJOR_VERSION >= 3 PyObject* unicode = PyUnicode_AsEncodedString(output.ptr(), "utf-8", 0); if (unicode) { const char* string = PyBytes_AsString(unicode); -#else - PyObject* unicode = PyUnicode_AsEncodedObject(output.ptr(), "utf-8", "strict"); - if (unicode) { - const char* string = PyString_AsString(unicode); -#endif Base::Console().Error("%s",string); Py_DECREF(unicode); } diff --git a/src/Gui/PythonDebugger.cpp b/src/Gui/PythonDebugger.cpp index 10f51e8119..403fd0ae88 100644 --- a/src/Gui/PythonDebugger.cpp +++ b/src/Gui/PythonDebugger.cpp @@ -437,11 +437,7 @@ void PythonDebugger::runFile(const QString& fn) dict = PyModule_GetDict(module); dict = PyDict_Copy(dict); if (PyDict_GetItemString(dict, "__file__") == NULL) { -#if PY_MAJOR_VERSION >= 3 PyObject *f = PyUnicode_FromString((const char*)pxFileName); -#else - PyObject *f = PyString_FromString((const char*)pxFileName); -#endif if (f == NULL) { fclose(fp); return; @@ -580,11 +576,7 @@ int PythonDebugger::tracer_callback(PyObject *obj, PyFrameObject *frame, int wha //no = frame->f_tstate->recursion_depth; //std::string funcname = PyString_AsString(frame->f_code->co_name); -#if PY_MAJOR_VERSION >= 3 QString file = QString::fromUtf8(PyUnicode_AsUTF8(frame->f_code->co_filename)); -#else - QString file = QString::fromUtf8(PyString_AsString(frame->f_code->co_filename)); -#endif switch (what) { case PyTrace_CALL: self->depth++; diff --git a/src/Gui/Selection.cpp b/src/Gui/Selection.cpp index 84fa8d1b2a..d2be885c9f 100644 --- a/src/Gui/Selection.cpp +++ b/src/Gui/Selection.cpp @@ -2067,11 +2067,7 @@ PyObject *SelectionSingleton::sCountObjectsOfType(PyObject * /*self*/, PyObject return NULL; unsigned int count = Selection().countObjectsOfType(objecttype, document, resolve); -#if PY_MAJOR_VERSION < 3 - return PyInt_FromLong(count); -#else return PyLong_FromLong(count); -#endif } PyObject *SelectionSingleton::sGetSelection(PyObject * /*self*/, PyObject *args) @@ -2340,15 +2336,9 @@ PyObject *SelectionSingleton::sSetVisible(PyObject * /*self*/, PyObject *args) if(visible == Py_None) { vis = -1; } -#if PY_MAJOR_VERSION < 3 - else if(PyInt_Check(visible)) { - vis = PyInt_AsLong(visible); - } -#else else if(PyLong_Check(visible)) { vis = PyLong_AsLong(visible); } -#endif else { vis = PyObject_IsTrue(visible)?1:0; } diff --git a/src/Gui/WidgetFactory.cpp b/src/Gui/WidgetFactory.cpp index dcbdc43cb1..4ffeeff5db 100644 --- a/src/Gui/WidgetFactory.cpp +++ b/src/Gui/WidgetFactory.cpp @@ -324,25 +324,14 @@ bool PythonWrapper::toCString(const Py::Object& pyobject, std::string& str) { if (PyUnicode_Check(pyobject.ptr())) { PyObject* unicode = PyUnicode_AsUTF8String(pyobject.ptr()); -#if PY_MAJOR_VERSION >= 3 str = PyBytes_AsString(unicode); -#else - str = PyString_AsString(unicode); -#endif Py_DECREF(unicode); return true; } -#if PY_MAJOR_VERSION >= 3 else if (PyBytes_Check(pyobject.ptr())) { str = PyBytes_AsString(pyobject.ptr()); return true; } -#else - else if (PyString_Check(pyobject.ptr())) { - str = PyString_AsString(pyobject.ptr()); - return true; - } -#endif #if defined (HAVE_SHIBOKEN) && defined(HAVE_PYSIDE) if (Shiboken::String::check(pyobject.ptr())) { const char* s = Shiboken::String::toCString(pyobject.ptr()); @@ -1002,16 +991,7 @@ Py::Object UiLoaderPy::createWidget(const Py::Tuple& args) // 1st argument Py::String str(args[0]); std::string className; -#if PY_MAJOR_VERSION >= 3 className = str.as_std_string("utf-8"); -#else - if (str.isUnicode()) { - className = str.as_std_string("utf-8"); - } - else { - className = (std::string)str; - } -#endif // 2nd argument QWidget* parent = 0; if (wrap.loadCoreModule() && args.size() > 1) { @@ -1024,16 +1004,7 @@ Py::Object UiLoaderPy::createWidget(const Py::Tuple& args) std::string objectName; if (args.size() > 2) { Py::String str(args[2]); -#if PY_MAJOR_VERSION >= 3 objectName = str.as_std_string("utf-8"); -#else - if (str.isUnicode()) { - objectName = str.as_std_string("utf-8"); - } - else { - objectName = (std::string)str; - } -#endif } QWidget* widget = loader.createWidget(QString::fromLatin1(className.c_str()), parent, @@ -1484,24 +1455,9 @@ Py::Object PyResource::setValue(const Py::Tuple& args) QVariant v; if (PyUnicode_Check(psValue)) { -#if PY_MAJOR_VERSION >= 3 v = QString::fromUtf8(PyUnicode_AsUTF8(psValue)); -#else - PyObject* unicode = PyUnicode_AsUTF8String(psValue); - v = QString::fromUtf8(PyString_AsString(unicode)); - Py_DECREF(unicode); - } - else if (PyString_Check(psValue)) { - v = QString::fromLatin1(PyString_AsString(psValue)); -#endif } -#if PY_MAJOR_VERSION < 3 - else if (PyInt_Check(psValue)) { - int val = PyInt_AsLong(psValue); - v = val; - } -#endif else if (PyLong_Check(psValue)) { unsigned int val = PyLong_AsLong(psValue); v = val; @@ -1514,17 +1470,9 @@ Py::Object PyResource::setValue(const Py::Tuple& args) int nSize = PyList_Size(psValue); for (int i=0; i= 3 if (!PyUnicode_Check(item)) -#else - if (!PyString_Check(item)) -#endif continue; -#if PY_MAJOR_VERSION >= 3 const char* pItem = PyUnicode_AsUTF8(item); -#else - char* pItem = PyString_AsString(item); -#endif str.append(QString::fromUtf8(pItem)); } diff --git a/src/Main/FreeCADGuiPy.cpp b/src/Main/FreeCADGuiPy.cpp index 83ef7a2def..bbaf03b6e8 100644 --- a/src/Main/FreeCADGuiPy.cpp +++ b/src/Main/FreeCADGuiPy.cpp @@ -377,7 +377,6 @@ PyMOD_INIT_FUNC(FreeCADGui) // is started in command mode if (Base::Type::fromName("Gui::BaseView").isBad()) Gui::Application::initApplication(); -#if PY_MAJOR_VERSION >= 3 static struct PyModuleDef FreeCADGuiModuleDef = { PyModuleDef_HEAD_INIT, "FreeCADGui", "FreeCAD GUI module\n", -1, @@ -386,9 +385,6 @@ PyMOD_INIT_FUNC(FreeCADGui) }; PyObject* module = PyModule_Create(&FreeCADGuiModuleDef); return module; -#else - Py_InitModule3("FreeCADGui", FreeCADGui_methods, "FreeCAD GUI module\n"); -#endif } catch (const Base::Exception& e) { PyErr_Format(PyExc_ImportError, "%s\n", e.what()); @@ -396,8 +392,6 @@ PyMOD_INIT_FUNC(FreeCADGui) catch (...) { PyErr_SetString(PyExc_ImportError, "Unknown runtime error occurred"); } -#if PY_MAJOR_VERSION >= 3 return 0; -#endif } diff --git a/src/Main/MainPy.cpp b/src/Main/MainPy.cpp index 88f3b6e5e2..10ed3a39c1 100644 --- a/src/Main/MainPy.cpp +++ b/src/Main/MainPy.cpp @@ -109,19 +109,11 @@ PyMOD_INIT_FUNC(FreeCAD) putenv("LC_ALL=C"); // get whole path of the library Dl_info info; -#if PY_MAJOR_VERSION >= 3 int ret = dladdr((void*)PyInit_FreeCAD, &info); -#else - int ret = dladdr((void*)initFreeCAD, &info); -#endif if ((ret == 0) || (!info.dli_fname)) { free(argv); PyErr_SetString(PyExc_ImportError, "Cannot get path of the FreeCAD module!"); -#if PY_MAJOR_VERSION >= 3 return 0; -#else - return; -#endif } argv[0] = (char*)malloc(PATH_MAX); @@ -145,31 +137,14 @@ PyMOD_INIT_FUNC(FreeCAD) // backwards since the FreeCAD path was likely appended just before // we were imported. for (i = PyList_Size(pySysPath) - 1; i >= 0 ; --i) { -#if PY_MAJOR_VERSION >= 3 const char *basePath; -#else - char *basePath; -#endif PyObject *pyPath = PyList_GetItem(pySysPath, i); long sz = 0; -#if PY_MAJOR_VERSION >= 3 if ( PyUnicode_Check(pyPath) ) { // Python 3 string basePath = PyUnicode_AsUTF8AndSize(pyPath, &sz); } -#else - if ( PyString_Check(pyPath) ) { - // Python 2 string type - PyString_AsStringAndSize(pyPath, &basePath, &sz); - } - else if ( PyUnicode_Check(pyPath) ) { - // Python 2 unicode type - explicitly use UTF-8 codec - PyObject *fromUnicode = PyUnicode_AsUTF8String(pyPath); - PyString_AsStringAndSize(fromUnicode, &basePath, &sz); - Py_XDECREF(fromUnicode); - } -#endif // #if/else PY_MAJOR_VERSION >= 3 else { continue; } @@ -201,11 +176,7 @@ PyMOD_INIT_FUNC(FreeCAD) if (buf == NULL) { PyErr_SetString(PyExc_ImportError, "Cannot get path of the FreeCAD module!"); -#if PY_MAJOR_VERSION >= 3 return 0; -#else - return; -#endif } argv[0] = buf; @@ -239,7 +210,6 @@ PyMOD_INIT_FUNC(FreeCAD) std::clog.rdbuf(&stdclog); std::cerr.rdbuf(&stdcerr); -#if PY_MAJOR_VERSION >= 3 //PyObject* module = _PyImport_FindBuiltin("FreeCAD"); PyObject* modules = PyImport_GetModuleDict(); PyObject* module = PyDict_GetItemString(modules, "FreeCAD"); @@ -247,6 +217,5 @@ PyMOD_INIT_FUNC(FreeCAD) PyErr_SetString(PyExc_ImportError, "Failed to load FreeCAD module!"); } return module; -#endif } From a0dd2dbdcfdc38fecf68e5460ac872da650e8e9c Mon Sep 17 00:00:00 2001 From: donovaly Date: Sun, 11 Apr 2021 22:05:42 +0200 Subject: [PATCH 101/178] [GUI] new icon to mark for recomputation The icon is from @bitacovir --- src/Gui/Icons/Std_MarkToRecompute.svg | 550 ++++++++++++++++++++++++++ src/Gui/Icons/resource.qrc | 1 + src/Gui/Tree.cpp | 1 + 3 files changed, 552 insertions(+) create mode 100644 src/Gui/Icons/Std_MarkToRecompute.svg diff --git a/src/Gui/Icons/Std_MarkToRecompute.svg b/src/Gui/Icons/Std_MarkToRecompute.svg new file mode 100644 index 0000000000..190fd5432f --- /dev/null +++ b/src/Gui/Icons/Std_MarkToRecompute.svg @@ -0,0 +1,550 @@ + + + Std_MarkToRecompute + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + [bitacovir] + + + + + Std_MarkToRecompute + + + + 11-04-2021 + + + FreeCAD LGPL2+ + + + + + FreeCAD + + + http://www.freecadweb.org/wiki/index.php?title=Artwork + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Gui/Icons/resource.qrc b/src/Gui/Icons/resource.qrc index 9269f819ed..abff6b522b 100644 --- a/src/Gui/Icons/resource.qrc +++ b/src/Gui/Icons/resource.qrc @@ -162,6 +162,7 @@ Std_HideSelection.svg Std_Import.svg Std_MergeProjects.svg + Std_MarkToRecompute.svg Std_PrintPdf.svg Std_RandomColor.svg Std_RecentFiles.svg diff --git a/src/Gui/Tree.cpp b/src/Gui/Tree.cpp index bf503200ee..196ea983f2 100644 --- a/src/Gui/Tree.cpp +++ b/src/Gui/Tree.cpp @@ -2681,6 +2681,7 @@ void TreeWidget::setupText() this->markRecomputeAction->setText(tr("Mark to recompute")); this->markRecomputeAction->setStatusTip(tr("Mark this object to be recomputed")); + this->markRecomputeAction->setIcon(BitmapFactory().iconFromTheme("Std_MarkToRecompute")); this->recomputeObjectAction->setText(tr("Recompute object")); this->recomputeObjectAction->setStatusTip(tr("Recompute the selected object")); From 6b4e7fb9d78d75f9a51fdca8c68c441c6099644f Mon Sep 17 00:00:00 2001 From: luz paz Date: Thu, 8 Apr 2021 12:52:44 -0400 Subject: [PATCH 102/178] [TD] Fix typo in Gui/CommandAnnotate.cpp [skip ci] --- src/Mod/TechDraw/Gui/CommandAnnotate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/TechDraw/Gui/CommandAnnotate.cpp b/src/Mod/TechDraw/Gui/CommandAnnotate.cpp index 3976423d2d..0096539fee 100644 --- a/src/Mod/TechDraw/Gui/CommandAnnotate.cpp +++ b/src/Mod/TechDraw/Gui/CommandAnnotate.cpp @@ -1199,7 +1199,7 @@ void CmdTechDrawCosmeticEraser::activated(int iMsg) cl2Delete.push_back(tag); } else { Base::Console().Message( - "CMD::CosmeticEraserP - edge: %d is confused - source: %d\n",idx,source); + "CMD::CosmeticEraser - edge: %d is confused - source: %d\n",idx,source); } } } else if (geomType == "Vertex") { From ab444031180d4f50947e1e983d36a52f2a14a3ac Mon Sep 17 00:00:00 2001 From: luz paz Date: Fri, 9 Apr 2021 07:57:22 -0400 Subject: [PATCH 103/178] [TD] Fix minor superfluous whitespace [skip ci] --- src/Mod/TechDraw/Gui/ViewProviderRichAnno.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/TechDraw/Gui/ViewProviderRichAnno.cpp b/src/Mod/TechDraw/Gui/ViewProviderRichAnno.cpp index 63e4ea828d..bca90ecae9 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderRichAnno.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderRichAnno.cpp @@ -99,7 +99,7 @@ bool ViewProviderRichAnno::setEdit(int ModNum) { // Base::Console().Message("VPRA::setEdit(%d)\n",ModNum); if (ModNum == ViewProvider::Default ) { - if (Gui::Control().activeDialog()) { //TaskPanel already open! + if (Gui::Control().activeDialog()) { //TaskPanel already open! return false; } Gui::Selection().clearSelection(); From 89e101403f48323ca5468d62b7f2f0502d16ead3 Mon Sep 17 00:00:00 2001 From: donovaly Date: Fri, 9 Apr 2021 02:34:28 +0200 Subject: [PATCH 104/178] [PD] [skip ci] fix sprocket icon in the Wiki it is displayed wrong because e.g. Firefox cannot handle the strange code inside the SVG --- .../Resources/icons/PartDesign_Sprocket.svg | 490 +----------------- 1 file changed, 7 insertions(+), 483 deletions(-) diff --git a/src/Mod/PartDesign/Gui/Resources/icons/PartDesign_Sprocket.svg b/src/Mod/PartDesign/Gui/Resources/icons/PartDesign_Sprocket.svg index 15bc199d19..5cf2dc0cae 100644 --- a/src/Mod/PartDesign/Gui/Resources/icons/PartDesign_Sprocket.svg +++ b/src/Mod/PartDesign/Gui/Resources/icons/PartDesign_Sprocket.svg @@ -1,492 +1,16 @@ - - - - - - + + + - + image/svg+xml - + - - - + + From 739a2a92a205a9d7180380b5aad0e2b215b9abe7 Mon Sep 17 00:00:00 2001 From: turn211 <78619703+turn211@users.noreply.github.com> Date: Wed, 14 Apr 2021 19:30:08 -0700 Subject: [PATCH 105/178] Gui: ProDark Stylesheet QT Icon Fix forum thread: https://forum.freecadweb.org/viewtopic.php?f=34&t=57427 --- src/Gui/Stylesheets/ProDark.qss | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/src/Gui/Stylesheets/ProDark.qss b/src/Gui/Stylesheets/ProDark.qss index 3238ff9885..1fe4f811fe 100644 --- a/src/Gui/Stylesheets/ProDark.qss +++ b/src/Gui/Stylesheets/ProDark.qss @@ -1709,6 +1709,25 @@ Gui--PropertyEditor--PropertyEditor > QWidget > QWidget > QWidget > QWidget > QF padding: 2px 6px; } +/*================================================================================================== +Tool button Icon fix in save dialogs +==================================================================================================*/ +/* found under Tools -> Save Picture */ /* Draft -> ShapeString -> Font file */ + +QFileDialog#QFileDialog QToolButton { + background-color: transparent; + padding: 1px; + border: 1px; + margin: 0px; +} + +QFileDialog#QFileDialog QToolButton:hover, +QFileDialog#QFileDialog QToolButton:focus { + color: #ffffff; + background-color: #557bb6; + border: 1px solid #f5f5f5; +} + /*================================================================================================== Tool button inside QDialogs that works as QPushButtons ==================================================================================================*/ @@ -1753,8 +1772,8 @@ Tool button inside Task Panel content that works as QPushButtons QSint--ActionGroup QFrame[class="content"] QToolButton { color: #e0e0e0; text-align: center; - background-color: qlineargradient(spread:pad, x1:0, y1:0.3, x2:0, y2:1, stop:0 #2a2a2a, stop:1 #1e1e1e); - border: 1px solid #1e1e1e; + background-color: #2a2a2a; + border: 1px solid #494949; border-bottom-color: black; /* simulates shadow under the button */ padding: 2px 6px; /* different than regular QPushButton */ margin: 2px; /* different than regular QPushButton */ @@ -1765,14 +1784,14 @@ QSint--ActionGroup QFrame[class="content"] QToolButton { QSint--ActionGroup QFrame[class="content"] QToolButton:hover, QSint--ActionGroup QFrame[class="content"] QToolButton:focus { color: white; - border-color: #557BB6; + border-color: solid #f5f5f5; background-color: #557BB6; } QSint--ActionGroup QFrame[class="content"] QToolButton:disabled, QSint--ActionGroup QFrame[class="content"] QToolButton:disabled:checked { color: #f5f5f5; - border-color: #424242; + border-color: #494949; background-color: #424242; } From fe3d5d07280afbbc9e6d59ccf554a329f5b045be Mon Sep 17 00:00:00 2001 From: luz paz Date: Fri, 9 Apr 2021 07:19:28 -0400 Subject: [PATCH 106/178] [TD] icon name uniformity (cont.) `WeldSymbol`, `PageDefault`, `PageTemplate`, `Symbol`, `ExportPageSVG`. `ExportPageDXF`, and `Tile` Moved `icons/arrow*` files further down the list + continuing to sort. --- src/Mod/TechDraw/Gui/Command.cpp | 10 +++---- src/Mod/TechDraw/Gui/CommandAnnotate.cpp | 2 +- src/Mod/TechDraw/Gui/Resources/TechDraw.qrc | 30 +++++++++---------- ...PageDXF.svg => TechDraw_ExportPageDXF.svg} | 4 +-- ...PageSVG.svg => TechDraw_ExportPageSVG.svg} | 6 ++-- ...geDefault.svg => TechDraw_PageDefault.svg} | 0 ...Template.svg => TechDraw_PageTemplate.svg} | 0 ...echdraw-symbol.svg => TechDraw_Symbol.svg} | 6 ++-- .../{techdraw-tile.svg => TechDraw_Tile.svg} | 2 +- ...weldsymbol.svg => TechDraw_WeldSymbol.svg} | 2 +- src/Mod/TechDraw/Gui/TaskWeldingSymbol.cpp | 4 +-- src/Mod/TechDraw/Gui/TaskWeldingSymbol.ui | 2 +- src/Mod/TechDraw/Gui/ViewProviderTile.cpp | 2 +- src/Mod/TechDraw/Gui/ViewProviderWeld.cpp | 2 +- 14 files changed, 36 insertions(+), 36 deletions(-) rename src/Mod/TechDraw/Gui/Resources/icons/actions/{techdraw-ExportPageDXF.svg => TechDraw_ExportPageDXF.svg} (99%) rename src/Mod/TechDraw/Gui/Resources/icons/actions/{techdraw-ExportPageSVG.svg => TechDraw_ExportPageSVG.svg} (99%) rename src/Mod/TechDraw/Gui/Resources/icons/actions/{techdraw-PageDefault.svg => TechDraw_PageDefault.svg} (100%) rename src/Mod/TechDraw/Gui/Resources/icons/actions/{techdraw-PageTemplate.svg => TechDraw_PageTemplate.svg} (100%) rename src/Mod/TechDraw/Gui/Resources/icons/actions/{techdraw-symbol.svg => TechDraw_Symbol.svg} (99%) rename src/Mod/TechDraw/Gui/Resources/icons/actions/{techdraw-tile.svg => TechDraw_Tile.svg} (99%) rename src/Mod/TechDraw/Gui/Resources/icons/actions/{techdraw-weldsymbol.svg => TechDraw_WeldSymbol.svg} (99%) diff --git a/src/Mod/TechDraw/Gui/Command.cpp b/src/Mod/TechDraw/Gui/Command.cpp index 4a46756f92..9dbdcad86a 100644 --- a/src/Mod/TechDraw/Gui/Command.cpp +++ b/src/Mod/TechDraw/Gui/Command.cpp @@ -114,7 +114,7 @@ CmdTechDrawPageDefault::CmdTechDrawPageDefault() sToolTipText = sMenuText; sWhatsThis = "TechDraw_PageDefault"; sStatusTip = sToolTipText; - sPixmap = "actions/techdraw-PageDefault"; + sPixmap = "actions/TechDraw_PageDefault"; } void CmdTechDrawPageDefault::activated(int iMsg) @@ -177,7 +177,7 @@ CmdTechDrawPageTemplate::CmdTechDrawPageTemplate() sToolTipText = sMenuText; sWhatsThis = "TechDraw_PageTemplate"; sStatusTip = sToolTipText; - sPixmap = "actions/techdraw-PageTemplate"; + sPixmap = "actions/TechDraw_PageTemplate"; } void CmdTechDrawPageTemplate::activated(int iMsg) @@ -1058,7 +1058,7 @@ CmdTechDrawSymbol::CmdTechDrawSymbol() sToolTipText = QT_TR_NOOP("Insert symbol from an SVG file"); sWhatsThis = "TechDraw_Symbol"; sStatusTip = sToolTipText; - sPixmap = "actions/techdraw-symbol"; + sPixmap = "actions/TechDraw_Symbol"; } void CmdTechDrawSymbol::activated(int iMsg) @@ -1307,7 +1307,7 @@ CmdTechDrawExportPageSVG::CmdTechDrawExportPageSVG() sToolTipText = sMenuText; sWhatsThis = "TechDraw_ExportPageSVG"; sStatusTip = sToolTipText; - sPixmap = "actions/techdraw-ExportPageSVG"; + sPixmap = "actions/TechDraw_ExportPageSVG"; } void CmdTechDrawExportPageSVG::activated(int iMsg) @@ -1351,7 +1351,7 @@ CmdTechDrawExportPageDXF::CmdTechDrawExportPageDXF() sToolTipText = sMenuText; sWhatsThis = "TechDraw_ExportPageDXF"; sStatusTip = sToolTipText; - sPixmap = "actions/techdraw-ExportPageDXF"; + sPixmap = "actions/TechDraw_ExportPageDXF"; } void CmdTechDrawExportPageDXF::activated(int iMsg) diff --git a/src/Mod/TechDraw/Gui/CommandAnnotate.cpp b/src/Mod/TechDraw/Gui/CommandAnnotate.cpp index 0096539fee..fcdfed6e63 100644 --- a/src/Mod/TechDraw/Gui/CommandAnnotate.cpp +++ b/src/Mod/TechDraw/Gui/CommandAnnotate.cpp @@ -1401,7 +1401,7 @@ CmdTechDrawWeldSymbol::CmdTechDrawWeldSymbol() sToolTipText = sMenuText; sWhatsThis = "TechDraw_WeldSymbol"; sStatusTip = sToolTipText; - sPixmap = "actions/techdraw-weldsymbol"; + sPixmap = "actions/TechDraw_WeldSymbol"; } void CmdTechDrawWeldSymbol::activated(int iMsg) diff --git a/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc b/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc index a947b7304e..dfb31be550 100644 --- a/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc +++ b/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc @@ -36,16 +36,6 @@ icons/TechDraw_VerticalExtentDimension.svg icons/techdraw-landmarkdistance.svg icons/preferences-techdraw.svg - icons/arrownone.svg - icons/arrowdot.svg - icons/arrowopendot.svg - icons/arrowfilled.svg - icons/arrowopen.svg - icons/arrowtick.svg - icons/arrowfork.svg - icons/arrowpyramid.svg - icons/actions/techdraw-PageDefault.svg - icons/actions/techdraw-PageTemplate.svg icons/actions/techdraw-View.svg icons/actions/TechDraw_ActiveView.svg icons/actions/techdraw-multiview.svg @@ -53,17 +43,18 @@ icons/actions/techdraw-ClipGroup.svg icons/actions/techdraw-ClipGroupAdd.svg icons/actions/techdraw-ClipGroupRemove.svg - icons/actions/techdraw-symbol.svg icons/actions/techdraw-DraftView.svg icons/actions/techdraw-ArchView.svg - icons/actions/techdraw-ExportPageSVG.svg - icons/actions/techdraw-ExportPageDXF.svg + icons/actions/TechDraw_ExportPageDXF.svg + icons/actions/TechDraw_ExportPageSVG.svg icons/actions/techdraw-SectionView.svg icons/actions/techdraw-hatch.svg icons/actions/techdraw-GeometricHatch.svg icons/actions/techdraw-toggleframe.svg icons/actions/TechDraw_RedrawPage.svg icons/actions/techdraw-ProjectionGroup.svg + icons/actions/TechDraw_PageDefault.svg + icons/actions/TechDraw_PageTemplate.svg icons/actions/techdraw-SpreadsheetView.svg icons/actions/techdraw-image.svg icons/actions/techdraw-DetailView.svg @@ -80,8 +71,9 @@ icons/actions/techdraw-DecorateLine.svg icons/actions/techdraw-facedecor.svg icons/actions/techdraw-showall.svg - icons/actions/techdraw-weldsymbol.svg - icons/actions/techdraw-tile.svg + icons/actions/TechDraw_Symbol.svg + icons/actions/TechDraw_Tile.svg + icons/actions/TechDraw_WeldSymbol.svg icons/actions/section-up.svg icons/actions/section-down.svg icons/actions/section-left.svg @@ -92,6 +84,14 @@ icons/arrow-down.svg icons/arrow-ccw.svg icons/arrow-cw.svg + icons/arrowdot.svg + icons/arrowfilled.svg + icons/arrowfork.svg + icons/arrownone.svg + icons/arrowopen.svg + icons/arrowopendot.svg + icons/arrowpyramid.svg + icons/arrowtick.svg icons/continuous-line.svg icons/dot-line.svg icons/dashDot-line.svg diff --git a/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-ExportPageDXF.svg b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_ExportPageDXF.svg similarity index 99% rename from src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-ExportPageDXF.svg rename to src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_ExportPageDXF.svg index f187bfc7ec..9c6c19b996 100644 --- a/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-ExportPageDXF.svg +++ b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_ExportPageDXF.svg @@ -24,7 +24,7 @@ [WandererFan] - techdraw-symbol + TechDraw_ExportPageDXF 2016-01-14 http://www.freecadweb.org/wiki/index.php?title=Artwork @@ -32,7 +32,7 @@ FreeCAD - FreeCAD/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-symbol.svg + FreeCAD/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_ExportPageDXF.svg FreeCAD LGPL2+ diff --git a/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-ExportPageSVG.svg b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_ExportPageSVG.svg similarity index 99% rename from src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-ExportPageSVG.svg rename to src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_ExportPageSVG.svg index 763e2e7382..f5b104c478 100644 --- a/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-ExportPageSVG.svg +++ b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_ExportPageSVG.svg @@ -15,7 +15,7 @@ height="64" id="svg2160" inkscape:version="0.48.5 r10040" - sodipodi:docname="techdraw-saveSVG.svg"> + sodipodi:docname="TechDraw_ExportPageSVG.svg"> @@ -30,7 +30,7 @@ [WandererFan] - techdraw-symbol + TechDraw_ExportPageSVG 2016-01-14 http://www.freecadweb.org/wiki/index.php?title=Artwork @@ -38,7 +38,7 @@ FreeCAD - FreeCAD/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-symbol.svg + FreeCAD/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_ExportPageSVG.svg FreeCAD LGPL2+ diff --git a/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-PageDefault.svg b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_PageDefault.svg similarity index 100% rename from src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-PageDefault.svg rename to src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_PageDefault.svg diff --git a/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-PageTemplate.svg b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_PageTemplate.svg similarity index 100% rename from src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-PageTemplate.svg rename to src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_PageTemplate.svg diff --git a/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-symbol.svg b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_Symbol.svg similarity index 99% rename from src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-symbol.svg rename to src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_Symbol.svg index 211de461ba..246f289925 100644 --- a/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-symbol.svg +++ b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_Symbol.svg @@ -15,7 +15,7 @@ height="64" id="svg2160" inkscape:version="0.48.5 r10040" - sodipodi:docname="techdraw-symbol.svg"> + sodipodi:docname="TechDraw_Symbol.svg"> @@ -30,7 +30,7 @@ [WandererFan] - techdraw-symbol + TechDraw_Symbol 2016-01-14 http://www.freecadweb.org/wiki/index.php?title=Artwork @@ -38,7 +38,7 @@ FreeCAD - FreeCAD/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-symbol.svg + FreeCAD/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_Symbol.svg FreeCAD LGPL2+ diff --git a/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-tile.svg b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_Tile.svg similarity index 99% rename from src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-tile.svg rename to src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_Tile.svg index e746e04f5a..e6a39f3c39 100644 --- a/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-tile.svg +++ b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_Tile.svg @@ -14,7 +14,7 @@ width="64" height="64" id="svg3085" - sodipodi:docname="techdraw-tile.svg" + sodipodi:docname="TechDraw_Tile.svg" inkscape:version="0.92.4 (unknown)"> windowTitle(), true, 0); taskbox->groupLayout()->addWidget(widget); Content.push_back(taskbox); @@ -701,7 +701,7 @@ TaskDlgWeldingSymbol::TaskDlgWeldingSymbol(TechDraw::DrawWeldSymbol* weld) : TaskDialog() { widget = new TaskWeldingSymbol(weld); - taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-weldsymbol"), + taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/TechDraw_WeldSymbol"), widget->windowTitle(), true, 0); taskbox->groupLayout()->addWidget(widget); Content.push_back(taskbox); diff --git a/src/Mod/TechDraw/Gui/TaskWeldingSymbol.ui b/src/Mod/TechDraw/Gui/TaskWeldingSymbol.ui index 504f12f6b9..dd2fa839df 100644 --- a/src/Mod/TechDraw/Gui/TaskWeldingSymbol.ui +++ b/src/Mod/TechDraw/Gui/TaskWeldingSymbol.ui @@ -27,7 +27,7 @@ - :/icons/actions/techdraw-weldsymbol.svg:/icons/actions/techdraw-weldsymbol.svg + :/icons/actions/TechDraw_WeldSymbol.svg:/icons/actions/TechDraw_WeldSymbol.svg diff --git a/src/Mod/TechDraw/Gui/ViewProviderTile.cpp b/src/Mod/TechDraw/Gui/ViewProviderTile.cpp index 2cf4ad10c5..6e888a97dd 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderTile.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderTile.cpp @@ -48,7 +48,7 @@ PROPERTY_SOURCE(TechDrawGui::ViewProviderTile, Gui::ViewProviderDocumentObject) ViewProviderTile::ViewProviderTile() { - sPixmap = "actions/techdraw-tile"; + sPixmap = "actions/TechDraw_Tile"; } ViewProviderTile::~ViewProviderTile() diff --git a/src/Mod/TechDraw/Gui/ViewProviderWeld.cpp b/src/Mod/TechDraw/Gui/ViewProviderWeld.cpp index 89baae9274..8bd2fd00c1 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderWeld.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderWeld.cpp @@ -59,7 +59,7 @@ PROPERTY_SOURCE(TechDrawGui::ViewProviderWeld, TechDrawGui::ViewProviderDrawingV ViewProviderWeld::ViewProviderWeld() { - sPixmap = "actions/techdraw-weldsymbol"; + sPixmap = "actions/TechDraw_WeldSymbol"; static const char *group = "Text"; ADD_PROPERTY_TYPE(Font, (prefFontName().c_str()),group,App::Prop_None, "The name of the font to use"); From d13e4503431d654de525a3dba03e38aa8b347964 Mon Sep 17 00:00:00 2001 From: luz paz Date: Fri, 9 Apr 2021 07:46:43 -0400 Subject: [PATCH 107/178] [TD] Renamed `SpreadsheetView`, `RichTextAnnotation`, `SectionView`... `Quadrants`, `DetailView`, `ShowAll` --- src/Mod/TechDraw/Gui/Command.cpp | 6 +++--- src/Mod/TechDraw/Gui/CommandAnnotate.cpp | 12 ++++++------ src/Mod/TechDraw/Gui/Resources/TechDraw.qrc | 14 +++++++------- ...draw-DetailView.svg => TechDraw_DetailView.svg} | 6 +++--- ...chdraw-Midpoints.svg => TechDraw_Midpoints.svg} | 0 ...chdraw-Quadrants.svg => TechDraw_Quadrants.svg} | 2 +- ...otation.svg => TechDraw_RichTextAnnotation.svg} | 2 +- ...aw-SectionView.svg => TechDraw_SectionView.svg} | 6 +++--- .../{techdraw-showall.svg => TechDraw_ShowAll.svg} | 2 +- ...dsheetView.svg => TechDraw_SpreadsheetView.svg} | 6 +++--- src/Mod/TechDraw/Gui/TaskDetail.cpp | 4 ++-- src/Mod/TechDraw/Gui/TaskDetail.ui | 2 +- src/Mod/TechDraw/Gui/TaskRichAnno.cpp | 4 ++-- src/Mod/TechDraw/Gui/TaskRichAnno.ui | 2 +- src/Mod/TechDraw/Gui/TaskSectionView.cpp | 4 ++-- src/Mod/TechDraw/Gui/ViewProviderRichAnno.cpp | 2 +- src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp | 2 +- 17 files changed, 38 insertions(+), 38 deletions(-) rename src/Mod/TechDraw/Gui/Resources/icons/actions/{techdraw-DetailView.svg => TechDraw_DetailView.svg} (99%) rename src/Mod/TechDraw/Gui/Resources/icons/actions/{techdraw-Midpoints.svg => TechDraw_Midpoints.svg} (100%) rename src/Mod/TechDraw/Gui/Resources/icons/actions/{techdraw-Quadrants.svg => TechDraw_Quadrants.svg} (99%) rename src/Mod/TechDraw/Gui/Resources/icons/actions/{techdraw-RichTextAnnotation.svg => TechDraw_RichTextAnnotation.svg} (99%) rename src/Mod/TechDraw/Gui/Resources/icons/actions/{techdraw-SectionView.svg => TechDraw_SectionView.svg} (99%) rename src/Mod/TechDraw/Gui/Resources/icons/actions/{techdraw-showall.svg => TechDraw_ShowAll.svg} (99%) rename src/Mod/TechDraw/Gui/Resources/icons/actions/{techdraw-SpreadsheetView.svg => TechDraw_SpreadsheetView.svg} (99%) diff --git a/src/Mod/TechDraw/Gui/Command.cpp b/src/Mod/TechDraw/Gui/Command.cpp index 9dbdcad86a..559116d44c 100644 --- a/src/Mod/TechDraw/Gui/Command.cpp +++ b/src/Mod/TechDraw/Gui/Command.cpp @@ -470,7 +470,7 @@ CmdTechDrawSectionView::CmdTechDrawSectionView() sToolTipText = sMenuText; sWhatsThis = "TechDraw_SectionView"; sStatusTip = sToolTipText; - sPixmap = "actions/techdraw-SectionView"; + sPixmap = "actions/TechDraw_SectionView"; } void CmdTechDrawSectionView::activated(int iMsg) @@ -520,7 +520,7 @@ CmdTechDrawDetailView::CmdTechDrawDetailView() sToolTipText = sMenuText; sWhatsThis = "TechDraw_DetailView"; sStatusTip = sToolTipText; - sPixmap = "actions/techdraw-DetailView"; + sPixmap = "actions/TechDraw_DetailView"; } void CmdTechDrawDetailView::activated(int iMsg) @@ -1248,7 +1248,7 @@ CmdTechDrawSpreadsheetView::CmdTechDrawSpreadsheetView() sToolTipText = QT_TR_NOOP("Insert View to a spreadsheet"); sWhatsThis = "TechDraw_SpreadsheetView"; sStatusTip = sToolTipText; - sPixmap = "actions/techdraw-SpreadsheetView"; + sPixmap = "actions/TechDraw_SpreadsheetView"; } void CmdTechDrawSpreadsheetView::activated(int iMsg) diff --git a/src/Mod/TechDraw/Gui/CommandAnnotate.cpp b/src/Mod/TechDraw/Gui/CommandAnnotate.cpp index fcdfed6e63..369e84a776 100644 --- a/src/Mod/TechDraw/Gui/CommandAnnotate.cpp +++ b/src/Mod/TechDraw/Gui/CommandAnnotate.cpp @@ -165,7 +165,7 @@ CmdTechDrawRichTextAnnotation::CmdTechDrawRichTextAnnotation() sToolTipText = sMenuText; sWhatsThis = "TechDraw_RichTextAnnotation"; sStatusTip = sToolTipText; - sPixmap = "actions/techdraw-RichTextAnnotation"; + sPixmap = "actions/TechDraw_RichTextAnnotation"; } void CmdTechDrawRichTextAnnotation::activated(int iMsg) @@ -260,11 +260,11 @@ Gui::Action * CmdTechDrawCosmeticVertexGroup::createAction(void) p1->setObjectName(QString::fromLatin1("TechDraw_CosmeticVertex")); p1->setWhatsThis(QString::fromLatin1("TechDraw_CosmeticVertx")); QAction* p2 = pcAction->addAction(QString()); - p2->setIcon(Gui::BitmapFactory().iconFromTheme("actions/techdraw-Midpoints")); + p2->setIcon(Gui::BitmapFactory().iconFromTheme("actions/TechDraw_Midpoints")); p2->setObjectName(QString::fromLatin1("TechDraw_Midpoints")); p2->setWhatsThis(QString::fromLatin1("TechDraw_Midpoints")); QAction* p3 = pcAction->addAction(QString()); - p3->setIcon(Gui::BitmapFactory().iconFromTheme("actions/techdraw-Quadrants")); + p3->setIcon(Gui::BitmapFactory().iconFromTheme("actions/TechDraw_Quadrants")); p3->setObjectName(QString::fromLatin1("TechDraw_Quadrants")); p3->setWhatsThis(QString::fromLatin1("TechDraw_Quadrants")); @@ -457,7 +457,7 @@ CmdTechDrawMidpoints::CmdTechDrawMidpoints() sToolTipText = sMenuText; sWhatsThis = "TechDraw_Midpoints"; sStatusTip = sToolTipText; - sPixmap = "actions/techdraw-Midpoints"; + sPixmap = "actions/TechDraw_Midpoints"; } void CmdTechDrawMidpoints::activated(int iMsg) @@ -496,7 +496,7 @@ CmdTechDrawQuadrants::CmdTechDrawQuadrants() sToolTipText = sMenuText; sWhatsThis = "TechDraw_Quadrants"; sStatusTip = sToolTipText; - sPixmap = "actions/techdraw-Quadrants"; + sPixmap = "actions/TechDraw_Quadrants"; } void CmdTechDrawQuadrants::activated(int iMsg) @@ -1336,7 +1336,7 @@ CmdTechDrawShowAll::CmdTechDrawShowAll() sToolTipText = sMenuText; sWhatsThis = "TechDraw_ShowAll"; sStatusTip = sToolTipText; - sPixmap = "actions/techdraw-showall"; + sPixmap = "actions/TechDraw_ShowAll"; } void CmdTechDrawShowAll::activated(int iMsg) diff --git a/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc b/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc index dfb31be550..3487a602f3 100644 --- a/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc +++ b/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc @@ -47,7 +47,7 @@ icons/actions/techdraw-ArchView.svg icons/actions/TechDraw_ExportPageDXF.svg icons/actions/TechDraw_ExportPageSVG.svg - icons/actions/techdraw-SectionView.svg + icons/actions/TechDraw_SectionView.svg icons/actions/techdraw-hatch.svg icons/actions/techdraw-GeometricHatch.svg icons/actions/techdraw-toggleframe.svg @@ -55,14 +55,14 @@ icons/actions/techdraw-ProjectionGroup.svg icons/actions/TechDraw_PageDefault.svg icons/actions/TechDraw_PageTemplate.svg - icons/actions/techdraw-SpreadsheetView.svg + icons/actions/TechDraw_SpreadsheetView.svg icons/actions/techdraw-image.svg - icons/actions/techdraw-DetailView.svg + icons/actions/TechDraw_DetailView.svg icons/actions/techdraw-LeaderLine.svg - icons/actions/techdraw-RichTextAnnotation.svg + icons/actions/TechDraw_RichTextAnnotation.svg icons/actions/techdraw-CosmeticVertex.svg - icons/actions/techdraw-Midpoints.svg - icons/actions/techdraw-Quadrants.svg + icons/actions/TechDraw_Midpoints.svg + icons/actions/TechDraw_Quadrants.svg icons/actions/TechDraw_FaceCenterLine.svg icons/actions/techdraw-2linecenterline.svg icons/actions/techdraw-2pointcenterline.svg @@ -70,7 +70,7 @@ icons/actions/techdraw-CosmeticEraser.svg icons/actions/techdraw-DecorateLine.svg icons/actions/techdraw-facedecor.svg - icons/actions/techdraw-showall.svg + icons/actions/TechDraw_ShowAll.svg icons/actions/TechDraw_Symbol.svg icons/actions/TechDraw_Tile.svg icons/actions/TechDraw_WeldSymbol.svg diff --git a/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-DetailView.svg b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_DetailView.svg similarity index 99% rename from src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-DetailView.svg rename to src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_DetailView.svg index 895ed413b7..7386a4500e 100644 --- a/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-DetailView.svg +++ b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_DetailView.svg @@ -1,6 +1,6 @@ - + @@ -133,7 +133,7 @@ http://agryson.net - techdraw-viewdetail + TechDraw_DetailView 2016-11-20 http://www.freecadweb.org/wiki/index.php?title=Artwork @@ -141,7 +141,7 @@ FreeCAD - FreeCAD/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-viewdetail.svg + FreeCAD/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_DetailView.svg FreeCAD LGPL2+ diff --git a/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-Midpoints.svg b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_Midpoints.svg similarity index 100% rename from src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-Midpoints.svg rename to src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_Midpoints.svg diff --git a/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-Quadrants.svg b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_Quadrants.svg similarity index 99% rename from src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-Quadrants.svg rename to src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_Quadrants.svg index f758e22adb..3b982c7910 100644 --- a/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-Quadrants.svg +++ b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_Quadrants.svg @@ -14,7 +14,7 @@ width="64" height="64" id="svg3085" - sodipodi:docname="techdraw-quadrant.svg" + sodipodi:docname="TechDraw_Quadrants.svg" inkscape:version="0.92.4 (unknown)"> - + @@ -164,7 +164,7 @@ http://agryson.net - techdraw-viewsection + TechDraw_SectionView 2016-01-14 http://www.freecadweb.org/wiki/index.php?title=Artwork @@ -172,7 +172,7 @@ FreeCAD - FreeCAD/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-viewsection.svg + FreeCAD/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_SectionView.svg FreeCAD LGPL2+ diff --git a/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-showall.svg b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_ShowAll.svg similarity index 99% rename from src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-showall.svg rename to src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_ShowAll.svg index 99a2d1140d..59d3245f93 100644 --- a/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-showall.svg +++ b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_ShowAll.svg @@ -14,7 +14,7 @@ width="64" height="64" id="svg3085" - sodipodi:docname="techdraw-showall.svg" + sodipodi:docname="TechDraw_ShowAll.svg" inkscape:version="0.92.4 (unknown)"> - + @@ -134,7 +134,7 @@ [WandererFan] - techdraw-spreadsheet + TechDraw_SpreadsheetView 2016-05-04 http://www.freecadweb.org/wiki/index.php?title=Artwork @@ -142,7 +142,7 @@ FreeCAD - FreeCAD/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-spreadsheet.svg + FreeCAD/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_SpreadsheetView.svg FreeCAD LGPL2+ diff --git a/src/Mod/TechDraw/Gui/TaskDetail.cpp b/src/Mod/TechDraw/Gui/TaskDetail.cpp index 361705c1e1..896a109500 100644 --- a/src/Mod/TechDraw/Gui/TaskDetail.cpp +++ b/src/Mod/TechDraw/Gui/TaskDetail.cpp @@ -661,7 +661,7 @@ TaskDlgDetail::TaskDlgDetail(TechDraw::DrawViewPart* baseFeat) : TaskDialog() { widget = new TaskDetail(baseFeat); - taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-DetailView"), + taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/TechDraw_DetailView"), widget->windowTitle(), true, 0); taskbox->groupLayout()->addWidget(widget); Content.push_back(taskbox); @@ -671,7 +671,7 @@ TaskDlgDetail::TaskDlgDetail(TechDraw::DrawViewDetail* detailFeat) : TaskDialog() { widget = new TaskDetail(detailFeat); - taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-DetailView"), + taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/TechDraw_DetailView"), widget->windowTitle(), true, 0); taskbox->groupLayout()->addWidget(widget); Content.push_back(taskbox); diff --git a/src/Mod/TechDraw/Gui/TaskDetail.ui b/src/Mod/TechDraw/Gui/TaskDetail.ui index b6fd523c4a..d2063edada 100644 --- a/src/Mod/TechDraw/Gui/TaskDetail.ui +++ b/src/Mod/TechDraw/Gui/TaskDetail.ui @@ -27,7 +27,7 @@ - :/icons/actions/techdraw-DetailView.svg:/icons/actions/techdraw-DetailView.svg + :/icons/actions/TechDraw_DetailView.svg:/icons/actions/TechDraw_DetailView.svg diff --git a/src/Mod/TechDraw/Gui/TaskRichAnno.cpp b/src/Mod/TechDraw/Gui/TaskRichAnno.cpp index 3d3eef2dcd..7e19bdf8c9 100644 --- a/src/Mod/TechDraw/Gui/TaskRichAnno.cpp +++ b/src/Mod/TechDraw/Gui/TaskRichAnno.cpp @@ -588,7 +588,7 @@ TaskDlgRichAnno::TaskDlgRichAnno(TechDraw::DrawView* baseFeat, : TaskDialog() { widget = new TaskRichAnno(baseFeat,page); - taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-RichTextAnnotation"), + taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/TechDraw_RichTextAnnotation"), widget->windowTitle(), true, 0); taskbox->groupLayout()->addWidget(widget); Content.push_back(taskbox); @@ -598,7 +598,7 @@ TaskDlgRichAnno::TaskDlgRichAnno(TechDrawGui::ViewProviderRichAnno* leadVP) : TaskDialog() { widget = new TaskRichAnno(leadVP); - taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-RichTextAnnotation"), + taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/TechDraw_RichTextAnnotation"), widget->windowTitle(), true, 0); taskbox->groupLayout()->addWidget(widget); Content.push_back(taskbox); diff --git a/src/Mod/TechDraw/Gui/TaskRichAnno.ui b/src/Mod/TechDraw/Gui/TaskRichAnno.ui index 06ec52b906..fb10466766 100644 --- a/src/Mod/TechDraw/Gui/TaskRichAnno.ui +++ b/src/Mod/TechDraw/Gui/TaskRichAnno.ui @@ -27,7 +27,7 @@ - :/icons/actions/techdraw-RichTextAnnotation.svg:/icons/actions/techdraw-RichTextAnnotation.svg + :/icons/actions/TechDraw_RichTextAnnotation.svg:/icons/actions/TechDraw_RichTextAnnotation.svg diff --git a/src/Mod/TechDraw/Gui/TaskSectionView.cpp b/src/Mod/TechDraw/Gui/TaskSectionView.cpp index a98ff6b3e0..01ce2aef0e 100644 --- a/src/Mod/TechDraw/Gui/TaskSectionView.cpp +++ b/src/Mod/TechDraw/Gui/TaskSectionView.cpp @@ -572,7 +572,7 @@ TaskDlgSectionView::TaskDlgSectionView(TechDraw::DrawViewPart* base) : TaskDialog() { widget = new TaskSectionView(base); - taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-SectionView"), + taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/TechDraw_SectionView"), widget->windowTitle(), true, 0); taskbox->groupLayout()->addWidget(widget); Content.push_back(taskbox); @@ -582,7 +582,7 @@ TaskDlgSectionView::TaskDlgSectionView(TechDraw::DrawViewSection* section) : TaskDialog() { widget = new TaskSectionView(section); - taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-SectionView"), + taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/TechDraw_SectionView"), widget->windowTitle(), true, 0); taskbox->groupLayout()->addWidget(widget); Content.push_back(taskbox); diff --git a/src/Mod/TechDraw/Gui/ViewProviderRichAnno.cpp b/src/Mod/TechDraw/Gui/ViewProviderRichAnno.cpp index bca90ecae9..d747df5b27 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderRichAnno.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderRichAnno.cpp @@ -75,7 +75,7 @@ const char* ViewProviderRichAnno::LineStyleEnums[] = { "NoLine", ViewProviderRichAnno::ViewProviderRichAnno() { - sPixmap = "actions/techdraw-RichTextAnnotation"; + sPixmap = "actions/TechDraw_RichTextAnnotation"; static const char *group = "Frame Format"; diff --git a/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp b/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp index 052f891d53..7c2e0cdab4 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp @@ -179,7 +179,7 @@ void ViewProviderViewPart::attach(App::DocumentObject *pcFeat) if (dvm != nullptr) { sPixmap = "TechDraw_Tree_Multi"; } else if (dvd != nullptr) { - sPixmap = "actions/techdraw-DetailView"; + sPixmap = "actions/TechDraw_DetailView"; } ViewProviderDrawingView::attach(pcFeat); From 035d146d8818df0cbd09bb90cf9b60e34b618bcd Mon Sep 17 00:00:00 2001 From: luz paz Date: Sun, 11 Apr 2021 08:20:32 -0400 Subject: [PATCH 108/178] [TD] Renamed `ClipGroup`, `ClipGroupAdd`, `ClipGroupRemove` --- src/Mod/TechDraw/Gui/Command.cpp | 6 +++--- src/Mod/TechDraw/Gui/Resources/TechDraw.qrc | 6 +++--- .../{techdraw-ClipGroup.svg => TechDraw_ClipGroup.svg} | 0 ...{techdraw-ClipGroupAdd.svg => TechDraw_ClipGroupAdd.svg} | 0 ...raw-ClipGroupRemove.svg => TechDraw_ClipGroupRemove.svg} | 0 src/Mod/TechDraw/Gui/ViewProviderViewClip.cpp | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) rename src/Mod/TechDraw/Gui/Resources/icons/actions/{techdraw-ClipGroup.svg => TechDraw_ClipGroup.svg} (100%) rename src/Mod/TechDraw/Gui/Resources/icons/actions/{techdraw-ClipGroupAdd.svg => TechDraw_ClipGroupAdd.svg} (100%) rename src/Mod/TechDraw/Gui/Resources/icons/actions/{techdraw-ClipGroupRemove.svg => TechDraw_ClipGroupRemove.svg} (100%) diff --git a/src/Mod/TechDraw/Gui/Command.cpp b/src/Mod/TechDraw/Gui/Command.cpp index 559116d44c..bbe14661fb 100644 --- a/src/Mod/TechDraw/Gui/Command.cpp +++ b/src/Mod/TechDraw/Gui/Command.cpp @@ -861,7 +861,7 @@ CmdTechDrawClipGroup::CmdTechDrawClipGroup() sToolTipText = sMenuText; sWhatsThis = "TechDraw_ClipGroup"; sStatusTip = sToolTipText; - sPixmap = "actions/techdraw-ClipGroup"; + sPixmap = "actions/TechDraw_ClipGroup"; } void CmdTechDrawClipGroup::activated(int iMsg) @@ -900,7 +900,7 @@ CmdTechDrawClipGroupAdd::CmdTechDrawClipGroupAdd() sToolTipText = sMenuText; sWhatsThis = "TechDraw_ClipGroupAdd"; sStatusTip = sToolTipText; - sPixmap = "actions/techdraw-ClipGroupAdd"; + sPixmap = "actions/TechDraw_ClipGroupAdd"; } void CmdTechDrawClipGroupAdd::activated(int iMsg) @@ -983,7 +983,7 @@ CmdTechDrawClipGroupRemove::CmdTechDrawClipGroupRemove() sToolTipText = sMenuText; sWhatsThis = "TechDraw_ClipGroupRemove"; sStatusTip = sToolTipText; - sPixmap = "actions/techdraw-ClipGroupRemove"; + sPixmap = "actions/TechDraw_ClipGroupRemove"; } void CmdTechDrawClipGroupRemove::activated(int iMsg) diff --git a/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc b/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc index 3487a602f3..5126892fe5 100644 --- a/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc +++ b/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc @@ -40,9 +40,9 @@ icons/actions/TechDraw_ActiveView.svg icons/actions/techdraw-multiview.svg icons/actions/techdraw-annotation.svg - icons/actions/techdraw-ClipGroup.svg - icons/actions/techdraw-ClipGroupAdd.svg - icons/actions/techdraw-ClipGroupRemove.svg + icons/actions/TechDraw_ClipGroup.svg + icons/actions/TechDraw_ClipGroupAdd.svg + icons/actions/TechDraw_ClipGroupRemove.svg icons/actions/techdraw-DraftView.svg icons/actions/techdraw-ArchView.svg icons/actions/TechDraw_ExportPageDXF.svg diff --git a/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-ClipGroup.svg b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_ClipGroup.svg similarity index 100% rename from src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-ClipGroup.svg rename to src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_ClipGroup.svg diff --git a/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-ClipGroupAdd.svg b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_ClipGroupAdd.svg similarity index 100% rename from src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-ClipGroupAdd.svg rename to src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_ClipGroupAdd.svg diff --git a/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-ClipGroupRemove.svg b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_ClipGroupRemove.svg similarity index 100% rename from src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-ClipGroupRemove.svg rename to src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_ClipGroupRemove.svg diff --git a/src/Mod/TechDraw/Gui/ViewProviderViewClip.cpp b/src/Mod/TechDraw/Gui/ViewProviderViewClip.cpp index cc8f1f4ae5..434741ac95 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderViewClip.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderViewClip.cpp @@ -46,7 +46,7 @@ PROPERTY_SOURCE(TechDrawGui::ViewProviderViewClip, TechDrawGui::ViewProviderDraw ViewProviderViewClip::ViewProviderViewClip() { - sPixmap = "actions/techdraw-ClipGroup"; + sPixmap = "actions/TechDraw_ClipGroup"; // Do not show in property editor //DisplayMode.StatusBits.set(3, true); From f1eb1ff44e210f36fb59ac23e7547518854ade55 Mon Sep 17 00:00:00 2001 From: luz paz Date: Sun, 11 Apr 2021 08:27:03 -0400 Subject: [PATCH 109/178] [TD] Renamed `ProjectionGroup`, `Hatch`, `GeomericHatch` --- src/Mod/TechDraw/Gui/Command.cpp | 2 +- src/Mod/TechDraw/Gui/CommandDecorate.cpp | 4 ++-- src/Mod/TechDraw/Gui/Resources/TechDraw.qrc | 6 +++--- ...hdraw-GeometricHatch.svg => TechDraw_GeometricHatch.svg} | 2 +- .../actions/{techdraw-hatch.svg => TechDraw_Hatch.svg} | 4 ++-- ...raw-ProjectionGroup.svg => TechDraw_ProjectionGroup.svg} | 2 +- src/Mod/TechDraw/Gui/TaskProjGroup.cpp | 2 +- src/Mod/TechDraw/Gui/ViewProviderGeomHatch.cpp | 2 +- 8 files changed, 12 insertions(+), 12 deletions(-) rename src/Mod/TechDraw/Gui/Resources/icons/actions/{techdraw-GeometricHatch.svg => TechDraw_GeometricHatch.svg} (99%) rename src/Mod/TechDraw/Gui/Resources/icons/actions/{techdraw-hatch.svg => TechDraw_Hatch.svg} (98%) rename src/Mod/TechDraw/Gui/Resources/icons/actions/{techdraw-ProjectionGroup.svg => TechDraw_ProjectionGroup.svg} (99%) diff --git a/src/Mod/TechDraw/Gui/Command.cpp b/src/Mod/TechDraw/Gui/Command.cpp index bbe14661fb..fa73b7f491 100644 --- a/src/Mod/TechDraw/Gui/Command.cpp +++ b/src/Mod/TechDraw/Gui/Command.cpp @@ -569,7 +569,7 @@ CmdTechDrawProjectionGroup::CmdTechDrawProjectionGroup() sToolTipText = QT_TR_NOOP("Insert multiple linked views of drawable object(s)"); sWhatsThis = "TechDraw_ProjectionGroup"; sStatusTip = sToolTipText; - sPixmap = "actions/techdraw-ProjectionGroup"; + sPixmap = "actions/TechDraw_ProjectionGroup"; } void CmdTechDrawProjectionGroup::activated(int iMsg) diff --git a/src/Mod/TechDraw/Gui/CommandDecorate.cpp b/src/Mod/TechDraw/Gui/CommandDecorate.cpp index 7fe0600142..6678a98971 100644 --- a/src/Mod/TechDraw/Gui/CommandDecorate.cpp +++ b/src/Mod/TechDraw/Gui/CommandDecorate.cpp @@ -207,7 +207,7 @@ CmdTechDrawHatch::CmdTechDrawHatch() sToolTipText = sMenuText; sWhatsThis = "TechDraw_Hatch"; sStatusTip = sToolTipText; - sPixmap = "actions/techdraw-hatch"; + sPixmap = "actions/TechDraw_Hatch"; } void CmdTechDrawHatch::activated(int iMsg) @@ -328,7 +328,7 @@ CmdTechDrawGeometricHatch::CmdTechDrawGeometricHatch() sToolTipText = sMenuText; sWhatsThis = "TechDraw_GeometricHatch"; sStatusTip = sToolTipText; - sPixmap = "actions/techdraw-GeometricHatch"; + sPixmap = "actions/TechDraw_GeometricHatch"; } void CmdTechDrawGeometricHatch::activated(int iMsg) diff --git a/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc b/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc index 5126892fe5..fba320f926 100644 --- a/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc +++ b/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc @@ -48,11 +48,11 @@ icons/actions/TechDraw_ExportPageDXF.svg icons/actions/TechDraw_ExportPageSVG.svg icons/actions/TechDraw_SectionView.svg - icons/actions/techdraw-hatch.svg - icons/actions/techdraw-GeometricHatch.svg + icons/actions/TechDraw_Hatch.svg + icons/actions/TechDraw_GeometricHatch.svg icons/actions/techdraw-toggleframe.svg icons/actions/TechDraw_RedrawPage.svg - icons/actions/techdraw-ProjectionGroup.svg + icons/actions/TechDraw_ProjectionGroup.svg icons/actions/TechDraw_PageDefault.svg icons/actions/TechDraw_PageTemplate.svg icons/actions/TechDraw_SpreadsheetView.svg diff --git a/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-GeometricHatch.svg b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_GeometricHatch.svg similarity index 99% rename from src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-GeometricHatch.svg rename to src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_GeometricHatch.svg index 4f60e3142a..6228ee8196 100644 --- a/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-GeometricHatch.svg +++ b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_GeometricHatch.svg @@ -15,7 +15,7 @@ height="64" id="svg3039" inkscape:version="0.48.4 r9939" - sodipodi:docname="techdraw-crosshatch.svg"> + sodipodi:docname="TechDraw_GeometricHatch.svg"> [WandererFan] - techdraw-hatch + TechDraw_Hatch 2016-01-14 http://www.freecadweb.org/wiki/index.php?title=Artwork @@ -19,7 +19,7 @@ FreeCAD - FreeCAD/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-hatch.svg + FreeCAD/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_Hatch.svg FreeCAD LGPL2+ diff --git a/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-ProjectionGroup.svg b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_ProjectionGroup.svg similarity index 99% rename from src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-ProjectionGroup.svg rename to src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_ProjectionGroup.svg index 8e5c47468a..b2e0c10d71 100755 --- a/src/Mod/TechDraw/Gui/Resources/icons/actions/techdraw-ProjectionGroup.svg +++ b/src/Mod/TechDraw/Gui/Resources/icons/actions/TechDraw_ProjectionGroup.svg @@ -15,7 +15,7 @@ id="svg249" sodipodi:version="0.32" inkscape:version="0.48.5 r10040" - sodipodi:docname="techdraw-projgroup.svg" + sodipodi:docname="TechDraw_ProjectionGroup.svg" inkscape:export-filename="/home/jimmac/gfx/novell/pdes/trunk/docs/BIGmime-text.png" inkscape:export-xdpi="240.00000" inkscape:export-ydpi="240.00000" diff --git a/src/Mod/TechDraw/Gui/TaskProjGroup.cpp b/src/Mod/TechDraw/Gui/TaskProjGroup.cpp index 82c96dbd42..bf6fa0cd1e 100644 --- a/src/Mod/TechDraw/Gui/TaskProjGroup.cpp +++ b/src/Mod/TechDraw/Gui/TaskProjGroup.cpp @@ -582,7 +582,7 @@ TaskDlgProjGroup::TaskDlgProjGroup(TechDraw::DrawProjGroup* featView, bool mode) { //viewProvider = dynamic_cast(featView); widget = new TaskProjGroup(featView,mode); - taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/techdraw-ProjectionGroup"), + taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/TechDraw_ProjectionGroup"), widget->windowTitle(), true, 0); taskbox->groupLayout()->addWidget(widget); Content.push_back(taskbox); diff --git a/src/Mod/TechDraw/Gui/ViewProviderGeomHatch.cpp b/src/Mod/TechDraw/Gui/ViewProviderGeomHatch.cpp index 7f8adc1165..0a05c3e48f 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderGeomHatch.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderGeomHatch.cpp @@ -69,7 +69,7 @@ PROPERTY_SOURCE(TechDrawGui::ViewProviderGeomHatch, Gui::ViewProviderDocumentObj ViewProviderGeomHatch::ViewProviderGeomHatch() { - sPixmap = "actions/techdraw-GeometricHatch"; + sPixmap = "actions/TechDraw_GeometricHatch"; static const char *vgroup = "GeomHatch"; From d070091fc7072d2fe4d2e419c7e7a892d06cda79 Mon Sep 17 00:00:00 2001 From: luz paz Date: Fri, 9 Apr 2021 13:27:44 -0400 Subject: [PATCH 110/178] [TD] Cont. organizing TechDraw.qrc file Use similar approach that is used in `src/Mod/Fem/Gui/Resources/Fem.qrc` --- src/Mod/TechDraw/Gui/Resources/TechDraw.qrc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc b/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc index fba320f926..ff467cabed 100644 --- a/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc +++ b/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc @@ -35,7 +35,6 @@ icons/TechDraw_HorizontalExtentDimension.svg icons/TechDraw_VerticalExtentDimension.svg icons/techdraw-landmarkdistance.svg - icons/preferences-techdraw.svg icons/actions/techdraw-View.svg icons/actions/TechDraw_ActiveView.svg icons/actions/techdraw-multiview.svg @@ -106,6 +105,8 @@ icons/rectangle.svg icons/triangle.svg icons/square.svg + + icons/MRTE/menu.svg icons/MRTE/bgColor.svg icons/MRTE/fgColor.svg @@ -126,6 +127,11 @@ icons/MRTE/edit-undo.svg icons/MRTE/edit-redo.svg icons/MRTE/internet-web-browser.svg + + + icons/preferences-techdraw.svg + + translations/TechDraw_af.qm translations/TechDraw_zh-CN.qm translations/TechDraw_zh-TW.qm From 18e707c6b791caa6372a5ee818e40fbd39b5cabf Mon Sep 17 00:00:00 2001 From: luz paz Date: Sun, 11 Apr 2021 09:04:54 -0400 Subject: [PATCH 111/178] [TD] Replace techdraw-lock.png and rename with TechDraw_Lock.svg --- src/Mod/TechDraw/Gui/QGIView.cpp | 2 +- src/Mod/TechDraw/Gui/Resources/TechDraw.qrc | 2 +- .../Gui/Resources/icons/TechDraw_Lock.svg | 445 ++++++++++++++++++ .../Gui/Resources/icons/techdraw-lock.png | Bin 1615 -> 0 bytes 4 files changed, 447 insertions(+), 2 deletions(-) create mode 100644 src/Mod/TechDraw/Gui/Resources/icons/TechDraw_Lock.svg delete mode 100644 src/Mod/TechDraw/Gui/Resources/icons/techdraw-lock.png diff --git a/src/Mod/TechDraw/Gui/QGIView.cpp b/src/Mod/TechDraw/Gui/QGIView.cpp index cd8dfff134..71d7fe6913 100644 --- a/src/Mod/TechDraw/Gui/QGIView.cpp +++ b/src/Mod/TechDraw/Gui/QGIView.cpp @@ -113,7 +113,7 @@ QGIView::QGIView() addToGroup(m_caption); m_lock = new QGCustomImage(); m_lock->setParentItem(m_border); - m_lock->load(QString::fromUtf8(":/icons/techdraw-lock.png")); + m_lock->load(QString::fromUtf8(":/icons/TechDraw_Lock.svg")); QSize sizeLock = m_lock->imageSize(); m_lockWidth = (double) sizeLock.width(); m_lockHeight = (double) sizeLock.height(); diff --git a/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc b/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc index ff467cabed..6fe6e9d8a4 100644 --- a/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc +++ b/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc @@ -96,7 +96,7 @@ icons/dashDot-line.svg icons/dashDotDot-line.svg icons/dash-line.svg - icons/techdraw-lock.png + icons/TechDraw_Lock.svg icons/cursor-balloon.png icons/none.svg icons/circular.svg diff --git a/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_Lock.svg b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_Lock.svg new file mode 100644 index 0000000000..e95a9ade84 --- /dev/null +++ b/src/Mod/TechDraw/Gui/Resources/icons/TechDraw_Lock.svg @@ -0,0 +1,445 @@ + + + TechDraw_Lock + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + TechDraw_Lock + + + [bitacovir] + + + Assembly_Assembly_Constraints_Tree + 09-04-2021 + http://www.freecadweb.org/wiki/index.php?title=Artwork + + + FreeCAD + + + + + + FreeCAD LGPL2+ + + + https://www.gnu.org/copyleft/lesser.html + + + + + + + + + + + + + + + + + + diff --git a/src/Mod/TechDraw/Gui/Resources/icons/techdraw-lock.png b/src/Mod/TechDraw/Gui/Resources/icons/techdraw-lock.png deleted file mode 100644 index c5ba8c876f661f0fe773246323261f1a1cb73c36..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1615 zcmV-V2C(^wP)b8U8{xd8vpaCF2tL}S;6_TJ745>6ZgeNug+dqBS`nce5k*TkTBY;}#e!s$OjDI$ z+cYK(nM|5w=H7cg7x&I1$(=iQ(wQ{>-JLn-e82O(&V49WsjaXx0(%8^D%cA20L|Xt zSzuh?x`L}3e!C7=S7S%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f693eda0705907ba9be9e3b631f Mon Sep 17 00:00:00 2001 From: luz paz Date: Sun, 11 Apr 2021 20:59:58 -0400 Subject: [PATCH 112/178] [TD] remove icons/cursor-balloon.png and replace references w/ SVG file Replacing w/ the already installed`TechDraw_Balloon.svg` file in the same directory. --- src/Mod/TechDraw/Gui/QGVPage.cpp | 4 ++-- src/Mod/TechDraw/Gui/Resources/TechDraw.qrc | 1 - .../Gui/Resources/icons/cursor-balloon.png | Bin 1676 -> 0 bytes 3 files changed, 2 insertions(+), 3 deletions(-) delete mode 100644 src/Mod/TechDraw/Gui/Resources/icons/cursor-balloon.png diff --git a/src/Mod/TechDraw/Gui/QGVPage.cpp b/src/Mod/TechDraw/Gui/QGVPage.cpp index d2967747c2..f0df865ff6 100644 --- a/src/Mod/TechDraw/Gui/QGVPage.cpp +++ b/src/Mod/TechDraw/Gui/QGVPage.cpp @@ -171,7 +171,7 @@ QGVPage::QGVPage(ViewProviderPage *vp, QGraphicsScene* s, QWidget *parent) bkgBrush = new QBrush(getBackgroundColor()); balloonCursor = new QLabel(this); - balloonCursor->setPixmap(QPixmap(QString::fromUtf8(":/icons/cursor-balloon.png"))); + balloonCursor->setPixmap(QPixmap(QString::fromUtf8(":/icons/TechDraw_Balloon.svg"))); balloonCursor->hide(); resetCachedContent(); @@ -1114,7 +1114,7 @@ void QGVPage::enterEvent(QEvent *event) QGraphicsView::enterEvent(event); if(getDrawPage()->balloonPlacing) { balloonCursor->hide(); - QApplication::setOverrideCursor(QCursor(QPixmap(QString::fromUtf8(":/icons/cursor-balloon.png")),0,32)); + QApplication::setOverrideCursor(QCursor(QPixmap(QString::fromUtf8(":/icons/TechDraw_Balloon.svg")),0,32)); } else { QApplication::restoreOverrideCursor(); viewport()->setCursor(Qt::ArrowCursor); diff --git a/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc b/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc index 6fe6e9d8a4..01df9c2087 100644 --- a/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc +++ b/src/Mod/TechDraw/Gui/Resources/TechDraw.qrc @@ -97,7 +97,6 @@ icons/dashDotDot-line.svg icons/dash-line.svg icons/TechDraw_Lock.svg - icons/cursor-balloon.png icons/none.svg icons/circular.svg icons/hexagon.svg diff --git a/src/Mod/TechDraw/Gui/Resources/icons/cursor-balloon.png b/src/Mod/TechDraw/Gui/Resources/icons/cursor-balloon.png deleted file mode 100644 index dd755464c964b81dd449067893299874107b6c16..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1676 zcmV;726Op|P)%I)3Q~gX0)eCpy(}9A9GaL#(Z}c1CAX zYfG7F6RfeVQ=6KSL{nbF5)x=BNoZJ>w`|yDU+%rf4{4mzkO(qOkJRKk!GiD_GScfP4e&Qb+pvp~=37xJiTj`$NHI!|1 zF&~^_Di9zX3ZrT&j7Ad!fE!UA7B?Pu~o2B<8}Yh+P`3e_!@;9JIl8!42cHSB80DfAJSI*4tl1e`SU^p-P-04&1hl%Git{^P+eqHJ0>1mB zw-~z+=}N#|%cbL%=5_O{op;&gyKgti=MUz{Di6|E&aWHSW4oD;+fAm|&C9h_LLO^( z%f8p^W!+{~R=U}<>b!g1#NRkvFW+o0k+oGwpPOH<#J8md)$8Wv?e&`M{mW6y!ibw-cRx*hx_)>nJ-IBY;!I4)dh{iaZp3OH`;@i=Ik${JSGy3ew(-YKG=a6Jo zvZ6McRt$io`QAI%adjrZTRmZf;HSrqp|3Q8em}Dk9`AhZ5~^aw=XM|@%_{{^0C%N3 zo2lRx;t6R=jX$pT_^Jw>lfgK#M3m}^Y$TMg2%w?@7hp+BQn(T_0H*u;m|rb`Wswnp zcwCT`VL?D1fOZqb_X8Ec5C)sB3Bg1P1<5t>tk(2&bfSPz5Sag3`v!o3P>@@^jRApy7?%49=vF{+BtBisWVUe&Fqup`T9MNE=NYJ3@>(6*W?+PEGYlCL-KC?Xu1q1zt@=v-ceN@DY-;#4IXjW8S1 zq-x3NRTMUlU5v@8K#;HODnV66k++<^D+QQO;TLIXmV$d4^6B?a5?+)MQ@s|!8vrz6 zlz2+hL?RO9^0YK`Q|swDLpPF+Cl8%RRR#N6Js{cdE$5M2MWVVIi`UKLswy6C`(Ztk z<6}H~Bmk0w0|QJg3n0x{W<|M^SZtB25nZ5K-UJYmZ;xGyO}8IDM`3}J@9(KnG({Zn zy6N(k^1142lCRI<@!<5ic}R~kkeaORexmJe^eaK0dTyLhSe{!n*uU&;==HA8AaP;t z1IWwA=lLoc@!<=6hz~jk#Fx58y%(0gml^0*?s9;}iOUA3QeR@~Pa5Vp~-Pg#~tO zHkF7WI6D?)Xmo*717U)5B!H(A@IC(!vo~mN$pH|0RcT3j+kB}|_D`BtF_ zNYWJQYjZ)LyHg|l=qC;^Fc5go6saSJ+D9;v48NP8t9#B=G{>-Fbrjx~9?k2`+g@L5 zmGAX#m(^ao;q$qU-u6cE3p<_hEk3KP@;ZBN*P7~wKWr(EA``j3w=Yx-*Pbo^_x4W= WJaj7$?)M@90000 Date: Thu, 15 Apr 2021 21:14:09 +0300 Subject: [PATCH 113/178] TD: fix center line style settings forum thread: https://forum.freecadweb.org/viewtopic.php?f=35&t=57783 --- src/Mod/TechDraw/Gui/TaskCenterLine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/TechDraw/Gui/TaskCenterLine.cpp b/src/Mod/TechDraw/Gui/TaskCenterLine.cpp index 2daeb0c60e..f023618039 100644 --- a/src/Mod/TechDraw/Gui/TaskCenterLine.cpp +++ b/src/Mod/TechDraw/Gui/TaskCenterLine.cpp @@ -447,7 +447,7 @@ Qt::PenStyle TaskCenterLine::getCenterStyle() { Base::Reference hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")-> GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations"); - Qt::PenStyle centerStyle = static_cast (hGrp->GetInt("CosmoCLStyle", 2)); + Qt::PenStyle centerStyle = static_cast (hGrp->GetInt("CenterLine", 2)); return centerStyle; } From 2daf6a03e467c4f8535b06ff894ab269d63db057 Mon Sep 17 00:00:00 2001 From: tomate44 Date: Tue, 6 Apr 2021 18:45:41 +0200 Subject: [PATCH 114/178] Part: Shape.ReflectLines: add 2D/3D, visibility and EdgeType options --- src/Mod/Part/App/TopoShapePy.xml | 17 ++++++++-- src/Mod/Part/App/TopoShapePyImp.cpp | 48 +++++++++++++++++++++++------ 2 files changed, 52 insertions(+), 13 deletions(-) diff --git a/src/Mod/Part/App/TopoShapePy.xml b/src/Mod/Part/App/TopoShapePy.xml index c2fa24ac61..fada5da207 100644 --- a/src/Mod/Part/App/TopoShapePy.xml +++ b/src/Mod/Part/App/TopoShapePy.xml @@ -673,10 +673,21 @@ makePerspectiveProjection(shape, pnt) -> Shape - Build reflect lines on a shape according to the axes of view. -reflectLines(ViewDir, ViewPos, UpDir) -> Shape + Build projection or reflect lines of a shape according to a view direction. +reflectLines(ViewDir, [ViewPos, UpDir, EdgeType, Visible, OnShape]) -> Shape (Compound of edges) -- -Reflect lines are represented by edges in 3d. +This algorithm computes the projection of the shape in the ViewDir direction. +If OnShape is False(default), the returned edges are flat on the XY plane defined by +ViewPos(origin) and UpDir(up direction). +If OnShape is True, the returned edges are the corresponding 3D reflect lines located on the shape. +EdgeType is a string defining the type of result edges : +- IsoLine : isoparametric line +- OutLine : outline (silhouette) edge +- Rg1Line : smooth edge of G1-continuity between two surfaces +- RgNLine : sewn edge of CN-continuity on one surface +- Sharp : sharp edge (of C0-continuity) +If Visible is True (default), only visible edges are returned. +If Visible is False, only invisible edges are returned. diff --git a/src/Mod/Part/App/TopoShapePyImp.cpp b/src/Mod/Part/App/TopoShapePyImp.cpp index 3ea305a027..89dc9c5766 100644 --- a/src/Mod/Part/App/TopoShapePyImp.cpp +++ b/src/Mod/Part/App/TopoShapePyImp.cpp @@ -2069,35 +2069,63 @@ pos=Gui.ActiveDocument.ActiveView.getCameraNode().position.getValue().getValue() pos=App.Vector(*pos) shape=App.ActiveDocument.ActiveObject.Shape -reflect=shape.reflectLines(ViewDir=vdir, ViewPos=pos, UpDir=udir) +reflect=shape.reflectLines(ViewDir=vdir, ViewPos=pos, UpDir=udir, EdgeType="Sharp", Visible=True, OnShape=False) Part.show(reflect) */ PyObject* TopoShapePy::reflectLines(PyObject *args, PyObject *kwds) { - static char *kwlist[] = {"ViewDir", "ViewPos", "UpDir", NULL}; + static char *kwlist[] = {"ViewDir", "ViewPos", "UpDir", "EdgeType", "Visible", "OnShape", nullptr}; - PyObject *pView, *pPos, *pUp; - if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!O!O!", kwlist, + char* type="OutLine"; + PyObject* vis = Py_True; + PyObject* in3d = Py_False; + PyObject* pPos = nullptr; + PyObject* pUp = nullptr; + PyObject *pView; + if (!PyArg_ParseTupleAndKeywords(args, kwds, "O!|O!O!sO!O!", kwlist, &Base::VectorPy::Type, &pView, &Base::VectorPy::Type, &pPos, - &Base::VectorPy::Type, &pUp)) - return 0; + &Base::VectorPy::Type, &pUp, + &type, + &PyBool_Type, &vis, + &PyBool_Type, &in3d)) + return nullptr; try { + HLRBRep_TypeOfResultingEdge t; + std::string str = type; + if (str == "IsoLine") + t = HLRBRep_IsoLine; + else if (str == "Rg1Line") + t = HLRBRep_Rg1Line; + else if (str == "RgNLine") + t = HLRBRep_RgNLine; + else if (str == "Sharp") + t = HLRBRep_Sharp; + else + t = HLRBRep_OutLine; + + Base::Vector3d p(0.0, 0.0, 0.0); + if (pPos) { + p = Py::Vector(pPos,false).toVector(); + } + Base::Vector3d u(0.0, 1.0, 0.0); + if (pUp) { + u = Py::Vector(pUp,false).toVector(); + } Base::Vector3d v = Py::Vector(pView,false).toVector(); - Base::Vector3d p = Py::Vector(pPos,false).toVector(); - Base::Vector3d u = Py::Vector(pUp,false).toVector(); const TopoDS_Shape& shape = this->getTopoShapePtr()->getShape(); HLRAppli_ReflectLines reflect(shape); reflect.SetAxes(v.x, v.y, v.z, p.x, p.y, p.z, u.x, u.y, u.z); reflect.Perform(); - TopoDS_Shape lines = reflect.GetResult(); + TopoDS_Shape lines = reflect.GetCompoundOf3dEdges(t, PyObject_IsTrue(vis) ? Standard_True : Standard_False, + PyObject_IsTrue(in3d) ? Standard_True : Standard_False); return new TopoShapePy(new TopoShape(lines)); } catch (Standard_Failure& e) { PyErr_SetString(PartExceptionOCCError, e.GetMessageString()); - return 0; + return nullptr; } } From 9ade68e9bfcff97fa647363cc769a267bfe21c11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Skowro=C5=84ski?= Date: Mon, 5 Apr 2021 00:02:35 +0200 Subject: [PATCH 115/178] Fix CMake warning: qt5_make_output_file is not part of the official API, and might be removed in Qt 6. --- cMake/FreeCAD_Helpers/SetupQt.cmake | 20 +-- src/Base/CMakeLists.txt | 7 - src/Gui/CMakeLists.txt | 133 +----------------- src/Mod/Drawing/Gui/CMakeLists.txt | 13 -- src/Mod/Fem/Gui/CMakeLists.txt | 45 ------ src/Mod/Image/Gui/CMakeLists.txt | 19 --- src/Mod/Inspection/Gui/CMakeLists.txt | 6 - src/Mod/Mesh/Gui/CMakeLists.txt | 18 --- src/Mod/MeshPart/Gui/CMakeLists.txt | 9 -- src/Mod/Part/Gui/CMakeLists.txt | 30 ---- src/Mod/PartDesign/Gui/CMakeLists.txt | 31 ---- src/Mod/Path/Gui/CMakeLists.txt | 9 -- src/Mod/Points/Gui/CMakeLists.txt | 6 - src/Mod/Raytracing/Gui/CMakeLists.txt | 6 - src/Mod/ReverseEngineering/Gui/CMakeLists.txt | 9 -- src/Mod/Robot/Gui/CMakeLists.txt | 18 --- src/Mod/Sketcher/Gui/CMakeLists.txt | 20 --- src/Mod/Spreadsheet/Gui/CMakeLists.txt | 22 +-- src/Mod/Start/Gui/CMakeLists.txt | 6 - src/Mod/Surface/Gui/CMakeLists.txt | 10 -- src/Mod/TechDraw/Gui/CMakeLists.txt | 50 ------- src/Mod/Test/Gui/CMakeLists.txt | 6 - src/Mod/Web/App/CMakeLists.txt | 6 - src/Mod/Web/Gui/CMakeLists.txt | 7 - 24 files changed, 14 insertions(+), 492 deletions(-) diff --git a/cMake/FreeCAD_Helpers/SetupQt.cmake b/cMake/FreeCAD_Helpers/SetupQt.cmake index cb51e52804..1e5519fe23 100644 --- a/cMake/FreeCAD_Helpers/SetupQt.cmake +++ b/cMake/FreeCAD_Helpers/SetupQt.cmake @@ -1,6 +1,7 @@ # -------------------------------- Qt -------------------------------- find_package(Qt5Core REQUIRED) +set(CMAKE_AUTOMOC TRUE) # For FreeCAD 0.20, pegged to Ubutu 18.04 LTS: if(${Qt5Core_VERSION} VERSION_LESS "5.9") @@ -32,22 +33,3 @@ if(BUILD_GUI) find_package(Qt5WinExtras QUIET) endif() endif(BUILD_GUI) - -# This is a special version of the built in macro qt5_wrap_cpp -# It is required since moc'ed files are now included instead of being added to projects directly -# It adds a reverse dependency to solve this -# This has the unfortunate side effect that some files are always rebuilt -# There is probably a cleaner solution than this -macro(fc_wrap_cpp outfiles ) - # get include dirs - qt5_get_moc_flags(moc_flags) - set(moc_files ${ARGN}) - - foreach(it ${moc_files}) - get_filename_component(it ${it} ABSOLUTE) - qt5_make_output_file(${it} moc_ cpp outfile) - qt5_create_moc_command(${it} ${outfile} "${moc_flags}" "${moc_options}" "${moc_target}" "${moc_depends}") - set(${outfiles} ${${outfiles}} ${outfile}) - add_file_dependencies(${it} ${outfile}) - endforeach(it) -endmacro(fc_wrap_cpp) diff --git a/src/Base/CMakeLists.txt b/src/Base/CMakeLists.txt index 2c418ede80..e1206b2228 100644 --- a/src/Base/CMakeLists.txt +++ b/src/Base/CMakeLists.txt @@ -178,13 +178,6 @@ SET(FreeCADBase_XML_SRCS ) SOURCE_GROUP("XML" FILES ${FreeCADBase_XML_SRCS}) -set(FreeCADBase_MOC_HDRS - Debugger.h - FutureWatcherProgress.h -) - -fc_wrap_cpp(FreeCADBase_MOC_SRCS ${FreeCADBase_MOC_HDRS}) - SET(FreeCADBase_UNITAPI_SRCS UnitsApi.cpp UnitsApiPy.cpp diff --git a/src/Gui/CMakeLists.txt b/src/Gui/CMakeLists.txt index 03cba79384..e682cc825b 100644 --- a/src/Gui/CMakeLists.txt +++ b/src/Gui/CMakeLists.txt @@ -278,143 +278,24 @@ SET(FreeCADGui_SDK_MOC_HDRS ) endif(FREECAD_USE_3DCONNEXION AND APPLE) -set(Gui_MOC_HDRS - Action.h - ActionFunction.h - Assistant.h - AutoSaver.h - CallTips.h - ComboView.h - Control.h - Clipping.h - DemoMode.h - DownloadItem.h - DownloadManager.h - DlgActionsImp.h - DlgActivateWindowImp.h - DlgUnitsCalculatorImp.h - DlgCommandsImp.h - DlgCustomizeImp.h - DlgCustomizeSpaceball.h - DlgCustomizeSpNavSettings.h - DlgDisplayPropertiesImp.h - DlgEditorImp.h - DlgGeneralImp.h - DlgInputDialogImp.h - DlgKeyboardImp.h - DlgMacroExecuteImp.h - DlgMacroRecordImp.h - DlgRunExternal.h - DlgEditFileIncludePropertyExternal.h - DlgMaterialPropertiesImp.h - DlgOnlineHelpImp.h - DlgParameterImp.h - DlgParameterFind.h - DlgPreferencesImp.h - DlgProjectInformationImp.h - DlgProjectUtility.h - DlgPropertyLink.h - DlgReportViewImp.h - DlgSettings3DViewImp.h - DlgSettingsNavigation.h - DlgSettingsSelection.h - DlgSettingsViewColor.h - DlgSettingsColorGradientImp.h - DlgSettingsDocumentImp.h - DlgSettingsImageImp.h - DlgSettingsLazyLoadedImp.h - DlgSettingsMacroImp.h - DlgSettingsUnitsImp.h - DlgCheckableMessageBox.h - DlgToolbarsImp.h - DlgWorkbenchesImp.h - TaskDlgRelocation.h - TaskCSysDragger.h - DlgUndoRedo.h - DockWindow.h - DockWindowManager.h - DocumentRecovery.h - EditorView.h - TextDocumentEditorView.h - ExpressionCompleter.h - DlgExpressionInput.h - FileDialog.h - Flag.h - GraphicsViewZoom.h - GraphvizView.h - GuiApplication.h - GuiApplicationNativeEventAware.h - InputVector.h - MainWindow.h - ManualAlignment.h - MDIView.h - NetworkRetriever.h - OnlineDocumentation.h - Placement.h - InputField.h - PrefWidgets.h - ProgressBar.h - ProgressDialog.h - PropertyPage.h - PropertyView.h - PythonConsole.h - PythonDebugger.h - PythonEditor.h - QuantitySpinBox.h - QListWidgetCustom.h - QuantitySpinBox_p.h - ReportView.h - SceneInspector.h - SelectionView.h - SpinBox.h - Splashscreen.h - TextEdit.h - TextureMapping.h - ToolBox.h - Transform.h - Tree.h - TreeView.h - ProjectView.h - View3DInventor.h - VectorListEditor.h - WidgetFactory.h - Widgets.h - Language/Translator.h - propertyeditor/PropertyEditor.h - propertyeditor/PropertyItem.h - propertyeditor/PropertyItemDelegate.h - propertyeditor/PropertyModel.h - TaskView/TaskAppearance.h - TaskView/TaskSelectLinkProperty.h - TaskView/TaskDialog.h - TaskView/TaskWatcher.h - TaskView/TaskEditControl.h - TaskView/TaskView.h - DAGView/DAGView.h - DAGView/DAGModel.h - TaskElementColors.h - DlgObjectSelection.h - DlgAddProperty.h - ${FreeCADGui_SDK_MOC_HDRS} -) - -fc_wrap_cpp(Gui_MOC_SRCS ${Gui_MOC_HDRS}) -#SOURCE_GROUP("Moc" FILES ${Gui_MOC_SRCS}) - if (BUILD_QT5) + set_property(SOURCE GraphvizView.h GraphvizView.cpp PROPERTY SKIP_AUTOMOC ON) add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/moc_GraphvizView-internal.cpp COMMAND ${Qt5Core_MOC_EXECUTABLE} -o ${CMAKE_CURRENT_BINARY_DIR}/moc_GraphvizView-internal.cpp ${CMAKE_CURRENT_SOURCE_DIR}/GraphvizView.cpp DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/GraphvizView.cpp) - set_property(SOURCE GraphvizView.cpp APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/moc_GraphvizView-internal.cpp) + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/moc_GraphvizView.cpp + COMMAND ${Qt5Core_MOC_EXECUTABLE} -o ${CMAKE_CURRENT_BINARY_DIR}/moc_GraphvizView.cpp ${CMAKE_CURRENT_SOURCE_DIR}/GraphvizView.h + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/GraphvizView.h) else() add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/moc_GraphvizView-internal.cpp COMMAND ${QT_MOC_EXECUTABLE} -o ${CMAKE_CURRENT_BINARY_DIR}/moc_GraphvizView-internal.cpp ${CMAKE_CURRENT_SOURCE_DIR}/GraphvizView.cpp DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/GraphvizView.cpp) - - set_property(SOURCE GraphvizView.cpp APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/moc_GraphvizView-internal.cpp) endif() +set_property(SOURCE GraphvizView.cpp APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/moc_GraphvizView-internal.cpp) +set_property(SOURCE GraphvizView.h APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/moc_GraphvizView.cpp) + SET(Gui_UIC_SRCS AboutApplication.ui Clipping.ui diff --git a/src/Mod/Drawing/Gui/CMakeLists.txt b/src/Mod/Drawing/Gui/CMakeLists.txt index 2b5c83a4a3..5579504cb4 100644 --- a/src/Mod/Drawing/Gui/CMakeLists.txt +++ b/src/Mod/Drawing/Gui/CMakeLists.txt @@ -22,19 +22,6 @@ set(DrawingGui_LIBS FreeCADGui ) - -set(DrawingGui_MOC_HDRS - DrawingView.h - TaskOrthoViews.h - TaskDialog.h -) - - - - -fc_wrap_cpp(DrawingGui_MOC_SRCS ${DrawingGui_MOC_HDRS}) -SOURCE_GROUP("Moc" FILES ${DrawingGui_MOC_SRCS}) - set(DrawingGui_UIC_SRCS TaskOrthoViews.ui ) diff --git a/src/Mod/Fem/Gui/CMakeLists.txt b/src/Mod/Fem/Gui/CMakeLists.txt index 0b73d0ba66..dcb75c68d8 100755 --- a/src/Mod/Fem/Gui/CMakeLists.txt +++ b/src/Mod/Fem/Gui/CMakeLists.txt @@ -55,51 +55,6 @@ SET(Python_SRCS SOURCE_GROUP("Python" FILES ${Python_SRCS}) -set(FemGui_MOC_HDRS - DlgSettingsFemCcxImp.h - DlgSettingsFemElmerImp.h - DlgSettingsFemExportAbaqusImp.h - DlgSettingsFemGeneralImp.h - DlgSettingsFemGmshImp.h - DlgSettingsFemInOutVtkImp.h - DlgSettingsFemMaterialImp.h - DlgSettingsFemZ88Imp.h - PropertyFemMeshItem.h - TaskObjectName.h - TaskCreateNodeSet.h - TaskDlgCreateNodeSet.h - TaskFemConstraint.h - TaskFemConstraintBearing.h - TaskFemConstraintFixed.h - TaskFemConstraintForce.h - TaskFemConstraintFluidBoundary.h - TaskFemConstraintPressure.h - TaskFemConstraintGear.h - TaskFemConstraintPulley.h - TaskFemConstraintDisplacement.h - TaskFemConstraintTemperature.h - TaskFemConstraintHeatflux.h - TaskFemConstraintInitialTemperature.h - TaskFemConstraintPlaneRotation.h - TaskFemConstraintContact.h - TaskFemConstraintTransform.h - TaskTetParameter.h - TaskAnalysisInfo.h - TaskDriver.h - TaskDlgAnalysis.h - TaskDlgMeshShapeNetgen.h -) -if(BUILD_FEM_VTK) - set(FemGui_MOC_HDRS - ${FemGui_MOC_HDRS} - TaskPostBoxes.h - ViewProviderFemPostFunction.h - ) -endif(BUILD_FEM_VTK) -fc_wrap_cpp(FemGui_MOC_SRCS ${FemGui_MOC_HDRS}) -SOURCE_GROUP("Moc" FILES ${FemGui_MOC_SRCS}) - - set(FemGui_UIC_SRCS DlgSettingsFemCcx.ui DlgSettingsFemElmer.ui diff --git a/src/Mod/Image/Gui/CMakeLists.txt b/src/Mod/Image/Gui/CMakeLists.txt index 5fd78952d9..8034d0ac7f 100644 --- a/src/Mod/Image/Gui/CMakeLists.txt +++ b/src/Mod/Image/Gui/CMakeLists.txt @@ -27,24 +27,6 @@ set(ImageGui_LIBS ${OPENGL_glu_LIBRARY} ) -set(ImageGui_MOC_HDRS - ImageView.h - ImageOrientationDialog.h -) - -if(FREECAD_USE_QTOPENGL_WIDGET) - list(APPEND ImageGui_MOC_HDRS - OpenGLImageBox.h - ) -else() - list(APPEND ImageGui_MOC_HDRS - GLImageBox.h - ) -endif() - -fc_wrap_cpp(ImageGui_MOC_SRCS ${ImageGui_MOC_HDRS}) -SOURCE_GROUP("Moc" FILES ${ImageGui_MOC_SRCS}) - SET(ImageGui_RES_SRCS Resources/Image.qrc ) @@ -62,7 +44,6 @@ else() endif() SET(ImageGui_SRCS -# ${ImageGui_MOC_SRCS} ${ImageGui_QRC_SRCS} ${ImageGui_UIC_HDRS} AppImageGui.cpp diff --git a/src/Mod/Inspection/Gui/CMakeLists.txt b/src/Mod/Inspection/Gui/CMakeLists.txt index bb1d7f4b7c..657f842c46 100644 --- a/src/Mod/Inspection/Gui/CMakeLists.txt +++ b/src/Mod/Inspection/Gui/CMakeLists.txt @@ -15,12 +15,6 @@ set(InspectionGui_LIBS FreeCADGui ) -set(InspectionGui_MOC_HDRS - VisualInspection.h -) -fc_wrap_cpp(InspectionGui_MOC_SRCS ${InspectionGui_MOC_HDRS}) -SOURCE_GROUP("Moc" FILES ${InspectionGui_MOC_SRCS}) - set(Dialogs_UIC_SRCS VisualInspection.ui ) diff --git a/src/Mod/Mesh/Gui/CMakeLists.txt b/src/Mod/Mesh/Gui/CMakeLists.txt index aa25884867..33ba8cd1c8 100644 --- a/src/Mod/Mesh/Gui/CMakeLists.txt +++ b/src/Mod/Mesh/Gui/CMakeLists.txt @@ -28,24 +28,6 @@ SET(MeshGui_XML_SRCS ) SOURCE_GROUP("XML" FILES ${MeshGui_XML_SRCS}) -set(Mesh_MOC_HDRS - DlgEvaluateMeshImp.h - DlgEvaluateSettings.h - DlgRegularSolidImp.h - DlgSettingsMeshView.h - DlgSettingsImportExportImp.h - DlgDecimating.h - DlgSmoothing.h - MeshEditor.h - PropertyEditorMesh.h - RemoveComponents.h - RemeshGmsh.h - SegmentationBestFit.h - Selection.h -) -fc_wrap_cpp(Mesh_MOC_SRCS ${Mesh_MOC_HDRS}) -SOURCE_GROUP("Moc" FILES ${Mesh_MOC_SRCS}) - set(Dialogs_UIC_SRCS DlgEvaluateMesh.ui DlgEvaluateSettings.ui diff --git a/src/Mod/MeshPart/Gui/CMakeLists.txt b/src/Mod/MeshPart/Gui/CMakeLists.txt index c5bb5ddc2a..60ae4f6a01 100644 --- a/src/Mod/MeshPart/Gui/CMakeLists.txt +++ b/src/Mod/MeshPart/Gui/CMakeLists.txt @@ -34,15 +34,6 @@ set(MeshPartGui_LIBS FreeCADGui ) -set(MeshPartGui_MOC_HDRS - CrossSections.h - CurveOnMesh.h - TaskCurveOnMesh.h - Tessellation.h -) -fc_wrap_cpp(MeshPartGui_MOC_SRCS ${MeshPartGui_MOC_HDRS}) -SOURCE_GROUP("Moc" FILES ${MeshPartGui_MOC_SRCS}) - set(MeshPartGui_UIC_SRCS CrossSections.ui TaskCurveOnMesh.ui diff --git a/src/Mod/Part/Gui/CMakeLists.txt b/src/Mod/Part/Gui/CMakeLists.txt index 29dba58cfe..d59a9daf4f 100644 --- a/src/Mod/Part/Gui/CMakeLists.txt +++ b/src/Mod/Part/Gui/CMakeLists.txt @@ -38,36 +38,6 @@ if (BUILD_QT5) ) endif() -set(PartGui_MOC_HDRS - CrossSections.h - Mirroring.h - DlgBooleanOperation.h - DlgExtrusion.h - DlgFilletEdges.h - DlgPartBoxImp.h - DlgPartCylinderImp.h - DlgPartImportIgesImp.h - DlgPartImportStepImp.h - DlgPrimitives.h - DlgRevolution.h - DlgSettings3DViewPartImp.h - DlgSettingsGeneral.h - DlgSettingsObjectColor.h - DlgProjectionOnSurface.h - PropertyEnumAttacherItem.h - TaskFaceColors.h - TaskShapeBuilder.h - TaskLoft.h - TaskOffset.h - TaskSweep.h - TaskThickness.h - TaskDimension.h - TaskCheckGeometry.h - TaskAttacher.h -) -fc_wrap_cpp(PartGui_MOC_SRCS ${PartGui_MOC_HDRS}) -SOURCE_GROUP("Moc" FILES ${PartGui_MOC_SRCS}) - if (BUILD_QT5) qt5_add_resources(PartGui_QRC_SRCS Resources/Part.qrc) else() diff --git a/src/Mod/PartDesign/Gui/CMakeLists.txt b/src/Mod/PartDesign/Gui/CMakeLists.txt index 2a2ce18401..5db22b5752 100644 --- a/src/Mod/PartDesign/Gui/CMakeLists.txt +++ b/src/Mod/PartDesign/Gui/CMakeLists.txt @@ -29,37 +29,6 @@ set(PartDesignGui_LIBS FreeCADGui ) -set(PartDesignGui_MOC_HDRS - TaskFeaturePick.h - TaskFeatureParameters.h - TaskSketchBasedParameters.h - TaskPadParameters.h - TaskPocketParameters.h - TaskChamferParameters.h - TaskFilletParameters.h - TaskDraftParameters.h - TaskThicknessParameters.h - TaskDressUpParameters.h - TaskHoleParameters.h - TaskRevolutionParameters.h - TaskTransformedMessages.h - TaskTransformedParameters.h - TaskMirroredParameters.h - TaskLinearPatternParameters.h - TaskPolarPatternParameters.h - TaskScaledParameters.h - TaskMultiTransformParameters.h - TaskDatumParameters.h - TaskShapeBinder.h - TaskBooleanParameters.h - TaskPrimitiveParameters.h - TaskPipeParameters.h - TaskLoftParameters.h - TaskHelixParameters.h -) -fc_wrap_cpp(PartDesignGui_MOC_SRCS ${PartDesignGui_MOC_HDRS}) -SOURCE_GROUP("Moc" FILES ${PartDesignGui_MOC_SRCS}) - if(BUILD_QT5) qt5_add_resources(PartDesignGui_SRCS Resources/PartDesign.qrc) else() diff --git a/src/Mod/Path/Gui/CMakeLists.txt b/src/Mod/Path/Gui/CMakeLists.txt index eb05743bbe..e0c8d919f9 100644 --- a/src/Mod/Path/Gui/CMakeLists.txt +++ b/src/Mod/Path/Gui/CMakeLists.txt @@ -33,15 +33,6 @@ endif() SOURCE_GROUP("Resources" FILES ${PathResource_SRCS}) -set(PathGui_MOC_HDRS - DlgSettingsPathColor.h - TaskDlgPathCompound.h - DlgProcessorChooser.h -) -fc_wrap_cpp(PathGui_MOC_SRCS ${PathGui_MOC_HDRS}) - -SOURCE_GROUP("Moc" FILES ${PathGui_MOC_SRCS}) - set(PathGui_UIC_SRCS DlgSettingsPathColor.ui TaskDlgPathCompound.ui diff --git a/src/Mod/Points/Gui/CMakeLists.txt b/src/Mod/Points/Gui/CMakeLists.txt index 8d37fc2129..eef1165d7d 100644 --- a/src/Mod/Points/Gui/CMakeLists.txt +++ b/src/Mod/Points/Gui/CMakeLists.txt @@ -13,12 +13,6 @@ set(PointsGui_LIBS FreeCADGui ) -set(PointsGui_MOC_HDRS - DlgPointsReadImp.h -) -fc_wrap_cpp(PointsGui_MOC_SRCS ${PointsGui_MOC_HDRS}) -SOURCE_GROUP("Moc" FILES ${PointsGui_MOC_SRCS}) - set(Dialog_UIC_SRCS DlgPointsRead.ui ) diff --git a/src/Mod/Raytracing/Gui/CMakeLists.txt b/src/Mod/Raytracing/Gui/CMakeLists.txt index 7e6c95df36..31e8b524b4 100644 --- a/src/Mod/Raytracing/Gui/CMakeLists.txt +++ b/src/Mod/Raytracing/Gui/CMakeLists.txt @@ -36,12 +36,6 @@ endmacro(generate_from_py2) generate_from_py2(FreeCADpov FreeCADpov.h) -set(RaytracingGui_MOC_HDRS - DlgSettingsRayImp.h -) -fc_wrap_cpp(RaytracingGui_MOC_SRCS ${RaytracingGui_MOC_HDRS}) -SOURCE_GROUP("Moc" FILES ${RaytracingGui_MOC_SRCS}) - SET(Resource_SRCS ${Resource_SRCS} Resources/Raytracing.qrc diff --git a/src/Mod/ReverseEngineering/Gui/CMakeLists.txt b/src/Mod/ReverseEngineering/Gui/CMakeLists.txt index 8f77f8c9cd..183ec9aea1 100644 --- a/src/Mod/ReverseEngineering/Gui/CMakeLists.txt +++ b/src/Mod/ReverseEngineering/Gui/CMakeLists.txt @@ -28,15 +28,6 @@ else() qt4_add_resources(ReenGui_QRC_SRCS Resources/ReverseEngineering.qrc) endif() -set(ReenGui_MOC_HDRS - FitBSplineSurface.h - Poisson.h - Segmentation.h - SegmentationManual.h -) -fc_wrap_cpp(ReenGui_MOC_SRCS ${ReenGui_MOC_HDRS}) -SOURCE_GROUP("Moc" FILES ${ReenGui_MOC_SRCS}) - set(Dialogs_UIC_SRCS FitBSplineSurface.ui Poisson.ui diff --git a/src/Mod/Robot/Gui/CMakeLists.txt b/src/Mod/Robot/Gui/CMakeLists.txt index e460a69d9c..a76aa5b00b 100644 --- a/src/Mod/Robot/Gui/CMakeLists.txt +++ b/src/Mod/Robot/Gui/CMakeLists.txt @@ -49,24 +49,6 @@ else() qt4_wrap_ui(RobotGui_UIC_HDRS ${RobotGui_UIC_SRCS}) endif() -set(RobotGui_MOC_HDRS - TaskTrajectory.h - TaskRobot6Axis.h - TrajectorySimulate.h - TaskDlgSimulate.h - TaskDlgEdge2Trac.h - TaskDlgTrajectoryDressUp.h - TaskDlgTrajectoryCompound.h - TaskRobotMessages.h - TaskRobotControl.h - TaskEdge2TracParameter.h - TaskTrajectoryDressUpParameter.h - TaskWatcher.h -) -fc_wrap_cpp(RobotGui_MOC_SRCS ${RobotGui_MOC_HDRS}) -SOURCE_GROUP("Qt" FILES ${PartDesignGui_MOC_SRCS}) - - SET(RobotGui_SRCS_Module AppRobotGui.cpp Resources/Robot.qrc diff --git a/src/Mod/Sketcher/Gui/CMakeLists.txt b/src/Mod/Sketcher/Gui/CMakeLists.txt index 2a16b77d0e..0f9dafb6f5 100644 --- a/src/Mod/Sketcher/Gui/CMakeLists.txt +++ b/src/Mod/Sketcher/Gui/CMakeLists.txt @@ -25,26 +25,6 @@ set(SketcherGui_LIBS FreeCADGui ) -set(SketcherGui_MOC_HDRS - EditDatumDialog.h - TaskSketcherConstrains.h - TaskSketcherElements.h - TaskSketcherCreateCommands.h - TaskSketcherGeneral.h - TaskSketcherMessages.h - TaskSketcherSolverAdvanced.h - TaskSketcherValidation.h - TaskDlgEditSketch.h - SketchOrientationDialog.h - SketchMirrorDialog.h - SketcherSettings.h - SketchRectangularArrayDialog.h - SketcherRegularPolygonDialog.h - PropertyConstraintListItem.h -) -fc_wrap_cpp(SketcherGui_MOC_SRCS ${SketcherGui_MOC_HDRS}) -SOURCE_GROUP("Moc" FILES ${SketcherGui_MOC_SRCS}) - if(BUILD_QT5) qt5_add_resources(SketcherGui_SRCS Resources/Sketcher.qrc) else() diff --git a/src/Mod/Spreadsheet/Gui/CMakeLists.txt b/src/Mod/Spreadsheet/Gui/CMakeLists.txt index 5c6b85620b..26f707ada8 100644 --- a/src/Mod/Spreadsheet/Gui/CMakeLists.txt +++ b/src/Mod/Spreadsheet/Gui/CMakeLists.txt @@ -13,21 +13,15 @@ set(SpreadsheetGui_LIBS FreeCADGui ) -set(SpreadsheetGui_MOC_HDRS - LineEdit.h - SpreadsheetView.h - SheetModel.h - SheetTableView.h - SpreadsheetDelegate.h - Workbench.h - PropertiesDialog.h - qtcolorpicker.h -) - if(BUILD_QT5) + set_property(SOURCE qtcolorpicker.h qtcolorpicker.cpp PROPERTY SKIP_AUTOMOC ON) add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/moc_qtcolorpicker-internal.cpp COMMAND ${Qt5Core_MOC_EXECUTABLE} -o ${CMAKE_CURRENT_BINARY_DIR}/moc_qtcolorpicker-internal.cpp ${CMAKE_CURRENT_SOURCE_DIR}/qtcolorpicker.cpp DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/qtcolorpicker.cpp) + + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/moc_qtcolorpicker.cpp + COMMAND ${Qt5Core_MOC_EXECUTABLE} -o ${CMAKE_CURRENT_BINARY_DIR}/moc_qtcolorpicker.cpp ${CMAKE_CURRENT_SOURCE_DIR}/qtcolorpicker.h + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/qtcolorpicker.h) else() add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/moc_qtcolorpicker-internal.cpp COMMAND ${QT_MOC_EXECUTABLE} -o ${CMAKE_CURRENT_BINARY_DIR}/moc_qtcolorpicker-internal.cpp ${CMAKE_CURRENT_SOURCE_DIR}/qtcolorpicker.cpp @@ -35,10 +29,7 @@ else() endif() set_property(SOURCE qtcolorpicker.cpp APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/moc_qtcolorpicker-internal.cpp) - -fc_wrap_cpp(SpreadsheetGui_MOC_SRCS ${SpreadsheetGui_MOC_HDRS}) -SOURCE_GROUP("Moc" FILES ${SpreadsheetGui_MOC_SRCS}) - +set_property(SOURCE qtcolorpicker.h APPEND PROPERTY OBJECT_DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/moc_qtcolorpicker.cpp) SET(SpreadsheetGui_RES_SRCS Resources/Spreadsheet.qrc @@ -62,7 +53,6 @@ else() endif() SET(SpreadsheetGui_SRCS -# ${SpreadsheetGui_MOC_SRCS} ${SpreadsheetGui_QRC_SRCS} AppSpreadsheetGui.cpp Command.cpp diff --git a/src/Mod/Start/Gui/CMakeLists.txt b/src/Mod/Start/Gui/CMakeLists.txt index 79a8d34182..caa6a64e1d 100644 --- a/src/Mod/Start/Gui/CMakeLists.txt +++ b/src/Mod/Start/Gui/CMakeLists.txt @@ -12,12 +12,6 @@ set(StartGui_LIBS FreeCADGui ) -set(StartGui_MOC_HDRS - DlgStartPreferencesImp.h -) -fc_wrap_cpp(StartGui_MOC_SRCS ${StartGui_MOC_HDRS}) -SOURCE_GROUP("Moc" FILES ${StartGui_MOC_SRCS}) - set(StartGui_UIC_SRCS DlgStartPreferences.ui ) diff --git a/src/Mod/Surface/Gui/CMakeLists.txt b/src/Mod/Surface/Gui/CMakeLists.txt index 61335dc94c..e300c4e955 100644 --- a/src/Mod/Surface/Gui/CMakeLists.txt +++ b/src/Mod/Surface/Gui/CMakeLists.txt @@ -23,16 +23,6 @@ set(SurfaceGui_LIBS FreeCADGui ) -set(SurfaceGui_MOC_HDRS - TaskFilling.h - TaskFillingEdge.h - TaskFillingVertex.h - TaskGeomFillSurface.h - TaskSections.h -) -fc_wrap_cpp(SurfaceGui_MOC_SRCS ${SurfaceGui_MOC_HDRS}) -SOURCE_GROUP("Moc" FILES ${SurfaceGui_MOC_SRCS}) - if (BUILD_QT5) qt5_add_resources(SurfaceGui_QRC_SRCS Resources/Surface.qrc) else() diff --git a/src/Mod/TechDraw/Gui/CMakeLists.txt b/src/Mod/TechDraw/Gui/CMakeLists.txt index 914f41a108..57589f77f7 100644 --- a/src/Mod/TechDraw/Gui/CMakeLists.txt +++ b/src/Mod/TechDraw/Gui/CMakeLists.txt @@ -34,54 +34,6 @@ set(TechDrawGui_LIBS FreeCADGui ) -set(TechDrawGui_MOC_HDRS - DlgPrefsTechDrawAdvancedImp.h - DlgPrefsTechDrawAnnotationImp.h - DlgPrefsTechDrawColorsImp.h - DlgPrefsTechDrawDimensionsImp.h - DlgPrefsTechDrawGeneralImp.h - DlgPrefsTechDrawHLRImp.h - DlgPrefsTechDrawScaleImp.h - DlgTemplateField.h - MDIViewPage.h - mrichtextedit.h - mtextedit.h - QGEPath.h - QGIDrawingTemplate.h - QGIGhostHighlight.h - QGILeaderLine.h - QGIRichAnno.h - QGITemplate.h - QGISVGTemplate.h - QGIView.h - QGIViewDimension.h - QGIViewBalloon.h - QGIWeldSymbol.h - QGMText.h - QGTracker.h - QGVPage.h - TaskActiveView.h - TaskBalloon.h - TaskCenterLine.h - TaskCosmeticLine.h - TaskCosVertex.h - TaskDetail.h - TaskDimension.h - TaskGeomHatch.h - TaskHatch.h - TaskLeaderLine.h - TaskLinkDim.h - TaskLineDecor.h - TaskProjGroup.h - TaskRichAnno.h - TaskSectionView.h - TaskWeldingSymbol.h - SymbolChooser.h -) - -fc_wrap_cpp(TechDrawGui_MOC_SRCS ${TechDrawGui_MOC_HDRS}) -SOURCE_GROUP("Moc" FILES ${TechDrawGui_MOC_SRCS}) - if(BUILD_QT5) qt5_add_resources(TechDrawGui_SRCS Resources/TechDraw.qrc) else() @@ -428,8 +380,6 @@ INSTALL(FILES ${TechDrawGuiIcon_SVG} DESTINATION "${CMAKE_INSTALL_DATADIR}/Mod/T fc_copy_sources(TechDrawGui "${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_DATADIR}/Mod/TechDraw" ${TechDrawGuiFonts}) INSTALL(FILES ${TechDrawGuiFonts} DESTINATION "${CMAKE_INSTALL_DATADIR}/Mod/TechDraw/Resources/fonts") -fc_copy_sources(TechDrawGui "${CMAKE_BINARY_DIR}/src/Mod/TechDraw/Gui" ${MRTE_HDRS}) - SET_BIN_DIR(TechDrawGui TechDrawGui /Mod/TechDraw) SET_PYTHON_PREFIX_SUFFIX(TechDrawGui) diff --git a/src/Mod/Test/Gui/CMakeLists.txt b/src/Mod/Test/Gui/CMakeLists.txt index 5723401f18..536662aa5b 100644 --- a/src/Mod/Test/Gui/CMakeLists.txt +++ b/src/Mod/Test/Gui/CMakeLists.txt @@ -10,12 +10,6 @@ set(TestGui_LIBS FreeCADGui ) -set(Test_MOC_HDRS - UnitTestImp.h -) -fc_wrap_cpp(Test_MOC_SRCS ${Test_MOC_HDRS}) -SOURCE_GROUP("Moc" FILES ${Test_MOC_SRCS}) - set(Dialogs_UIC_SRCS UnitTest.ui ) diff --git a/src/Mod/Web/App/CMakeLists.txt b/src/Mod/Web/App/CMakeLists.txt index 3cb32fe305..9f777aff3e 100644 --- a/src/Mod/Web/App/CMakeLists.txt +++ b/src/Mod/Web/App/CMakeLists.txt @@ -23,12 +23,6 @@ else() ) endif() -set(Web_MOC_HDRS - Server.h -) -fc_wrap_cpp(Web_MOC_SRCS ${Web_MOC_HDRS}) -SOURCE_GROUP("Moc" FILES ${Web_MOC_SRCS}) - SET(Web_SRCS AppWeb.cpp PreCompiled.cpp diff --git a/src/Mod/Web/Gui/CMakeLists.txt b/src/Mod/Web/Gui/CMakeLists.txt index 98b20b2bdf..8167f35779 100644 --- a/src/Mod/Web/Gui/CMakeLists.txt +++ b/src/Mod/Web/Gui/CMakeLists.txt @@ -44,13 +44,6 @@ SET(WebGui_SRCS CookieJar.h # QWebkit only ) -set(WebGui_MOC_HDRS - BrowserView.h - CookieJar.h -) -fc_wrap_cpp(WebGui_MOC_SRCS ${WebGui_MOC_HDRS}) -SOURCE_GROUP("Moc" FILES ${SketcherGui_MOC_SRCS}) - SET(WebGuiIcon_SVG Resources/icons/WebWorkbench.svg ) From 80415446cf947be0eebcf8667e6565fd790b98b6 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 19 Apr 2021 15:12:43 +0200 Subject: [PATCH 116/178] CMake: disable moc for some targets and fix failure for existing builds --- src/3rdParty/salomesmesh/CMakeLists.txt | 1 + src/Mod/TechDraw/Gui/CMakeLists.txt | 12 +++++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/3rdParty/salomesmesh/CMakeLists.txt b/src/3rdParty/salomesmesh/CMakeLists.txt index 5bf7e0e0b9..104ffebba6 100644 --- a/src/3rdParty/salomesmesh/CMakeLists.txt +++ b/src/3rdParty/salomesmesh/CMakeLists.txt @@ -1,5 +1,6 @@ # SGEOM cmake build file #PROJECT(SMESH Fortran CXX) +set(CMAKE_AUTOMOC FALSE) SET(SMESH_VERSION_MAJOR 7) # see main CMakeLists.txt of FreeCAD SET(SMESH_VERSION_MINOR 7) diff --git a/src/Mod/TechDraw/Gui/CMakeLists.txt b/src/Mod/TechDraw/Gui/CMakeLists.txt index 57589f77f7..eb9660bcd6 100644 --- a/src/Mod/TechDraw/Gui/CMakeLists.txt +++ b/src/Mod/TechDraw/Gui/CMakeLists.txt @@ -4,6 +4,13 @@ else(MSVC) add_definitions(-DHAVE_LIMITS_H -DHAVE_CONFIG_H) endif(MSVC) +# In previous versions this target copied mtextedit.h to the binary directory that causes +# automoc to generate linking errors. +if (EXISTS ${CMAKE_CURRENT_BINARY_DIR}/mtextedit.h) + file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/mtextedit.h) + execute_process(COMMAND "${CMAKE_COMMAND}" -E touch_nocreate "${CMAKE_CURRENT_SOURCE_DIR}/mtextedit.h") +endif() + include_directories( ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/src @@ -84,11 +91,6 @@ SET(MRTE_SRCS mtextedit.h ) -SET(MRTE_HDRS - mtextedit.h -) - - SET(TechDrawGui_SRCS ${CMAKE_SOURCE_DIR}/src/Mod/TechDraw/InitGui.py ${TechDrawGui_SRCS} From a1fc733ddf58d37f84e2305558ad08831ded715a Mon Sep 17 00:00:00 2001 From: luz paz Date: Wed, 14 Apr 2021 10:18:27 -0400 Subject: [PATCH 117/178] App: remove Py2 code from several src/App .cpp files --- src/App/ApplicationPy.cpp | 17 --------- src/App/DocumentObjectPyImp.cpp | 40 -------------------- src/App/DocumentPyImp.cpp | 24 ------------ src/App/Expression.cpp | 60 ------------------------------ src/App/FeaturePythonPyImp.inl | 14 ------- src/App/LinkBaseExtensionPyImp.cpp | 16 -------- src/App/ObjectIdentifier.cpp | 4 -- src/App/Property.cpp | 4 -- src/App/PropertyFile.cpp | 43 --------------------- src/App/PropertyGeo.cpp | 20 ---------- src/App/PropertyPythonObject.cpp | 11 ------ src/App/PropertyUnits.cpp | 15 -------- 12 files changed, 268 deletions(-) diff --git a/src/App/ApplicationPy.cpp b/src/App/ApplicationPy.cpp index d24cafc460..0eaa6ac788 100644 --- a/src/App/ApplicationPy.cpp +++ b/src/App/ApplicationPy.cpp @@ -449,11 +449,7 @@ PyObject* Application::sGetConfig(PyObject * /*self*/, PyObject *args) } else { // do not set an error because this may break existing python code -#if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(""); -#else - return PyString_FromString(""); -#endif } } @@ -465,11 +461,7 @@ PyObject* Application::sDumpConfig(PyObject * /*self*/, PyObject *args) PyObject *dict = PyDict_New(); for (std::map::iterator It= GetApplication()._mConfig.begin(); It!=GetApplication()._mConfig.end();++It) { -#if PY_MAJOR_VERSION >= 3 PyDict_SetItemString(dict,It->first.c_str(), PyUnicode_FromString(It->second.c_str())); -#else - PyDict_SetItemString(dict,It->first.c_str(), PyString_FromString(It->second.c_str())); -#endif } return dict; } @@ -718,11 +710,7 @@ PyObject* Application::sListDocuments(PyObject * /*self*/, PyObject *args) docs = Document::getDependentDocuments(docs,true); for (auto doc : docs) { -#if PY_MAJOR_VERSION >= 3 pKey = PyUnicode_FromString(doc->getName()); -#else - pKey = PyString_FromString(doc->getName()); -#endif // GetPyObject() increments pValue = static_cast(doc->getPyObject()); PyDict_SetItem(pDict, pKey, pValue); @@ -764,13 +752,8 @@ PyObject *Application::sSetLogLevel(PyObject * /*self*/, PyObject *args) return NULL; PY_TRY{ int l; -#if PY_MAJOR_VERSION < 3 - if (PyString_Check(pcObj)) { - const char *pstr = PyString_AsString(pcObj); -#else if (PyUnicode_Check(pcObj)) { const char *pstr = PyUnicode_AsUTF8(pcObj); -#endif if(strcmp(pstr,"Log") == 0) l = FC_LOGLEVEL_LOG; else if(strcmp(pstr,"Warning") == 0) diff --git a/src/App/DocumentObjectPyImp.cpp b/src/App/DocumentObjectPyImp.cpp index a0fecb195e..450ef7e69a 100644 --- a/src/App/DocumentObjectPyImp.cpp +++ b/src/App/DocumentObjectPyImp.cpp @@ -330,13 +330,8 @@ PyObject* DocumentObjectPy::setExpression(PyObject * args) if (Py::Object(expr).isNone()) getDocumentObjectPtr()->setExpression(p, std::shared_ptr()); -#if PY_MAJOR_VERSION >= 3 else if (PyUnicode_Check(expr)) { const char * exprStr = PyUnicode_AsUTF8(expr); -#else - else if (PyString_Check(expr)) { - const char * exprStr = PyString_AsString(expr); -#endif std::shared_ptr shared_expr(Expression::parse(getDocumentObjectPtr(), exprStr)); if(shared_expr && comment) shared_expr->comment = comment; @@ -344,24 +339,7 @@ PyObject* DocumentObjectPy::setExpression(PyObject * args) getDocumentObjectPtr()->setExpression(p, shared_expr); } else if (PyUnicode_Check(expr)) { -#if PY_MAJOR_VERSION >= 3 std::string exprStr = PyUnicode_AsUTF8(expr); -#else - PyObject* unicode = PyUnicode_AsEncodedString(expr, "utf-8", 0); - if (unicode) { - std::string exprStr = PyString_AsString(unicode); - Py_DECREF(unicode); - std::shared_ptr shared_expr(ExpressionParser::parse(getDocumentObjectPtr(), exprStr.c_str())); - - if(shared_expr && comment) - shared_expr->comment = comment; - getDocumentObjectPtr()->setExpression(p, shared_expr); - } - else { - // utf-8 encoding failed - return 0; - } -#endif } else throw Py::TypeError("String or None expected."); @@ -445,32 +423,14 @@ PyObject* DocumentObjectPy::getSubObject(PyObject *args, PyObject *keywds) std::vector subs; bool single=true; if (PyUnicode_Check(obj)) { -#if PY_MAJOR_VERSION >= 3 subs.push_back(PyUnicode_AsUTF8(obj)); -#else - PyObject* unicode = PyUnicode_AsUTF8String(obj); - subs.push_back(PyString_AsString(unicode)); - Py_DECREF(unicode); - } - else if (PyString_Check(obj)) { - subs.push_back(PyString_AsString(obj)); -#endif } else if (PySequence_Check(obj)) { single=false; Py::Sequence shapeSeq(obj); for (Py::Sequence::iterator it = shapeSeq.begin(); it != shapeSeq.end(); ++it) { PyObject* item = (*it).ptr(); if (PyUnicode_Check(item)) { -#if PY_MAJOR_VERSION >= 3 subs.push_back(PyUnicode_AsUTF8(item)); -#else - PyObject* unicode = PyUnicode_AsUTF8String(item); - subs.push_back(PyString_AsString(unicode)); - Py_DECREF(unicode); - } - else if (PyString_Check(item)) { - subs.push_back(PyString_AsString(item)); -#endif }else{ PyErr_SetString(PyExc_TypeError, "non-string object in sequence"); return 0; diff --git a/src/App/DocumentPyImp.cpp b/src/App/DocumentPyImp.cpp index fc5fba2526..18d1e1830a 100644 --- a/src/App/DocumentPyImp.cpp +++ b/src/App/DocumentPyImp.cpp @@ -179,11 +179,7 @@ PyObject* DocumentPy::exportGraphviz(PyObject * args) else { std::stringstream str; getDocumentPtr()->exportGraphviz(str); -#if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(str.str().c_str()); -#else - return PyString_FromString(str.str().c_str()); -#endif } } @@ -400,20 +396,9 @@ PyObject* DocumentPy::openTransaction(PyObject *args) if (!value) { cmd = ""; } -#if PY_MAJOR_VERSION >= 3 else if (PyUnicode_Check(value)) { cmd = PyUnicode_AsUTF8(value); } -#else - else if (PyUnicode_Check(value)) { - PyObject* unicode = PyUnicode_AsUTF8String(value); - cmd = PyString_AsString(unicode); - Py_DECREF(unicode); - } - else if (PyString_Check(value)) { - cmd = PyString_AsString(value); - } -#endif else { PyErr_SetString(PyExc_TypeError, "string or unicode expected"); return NULL; @@ -716,16 +701,7 @@ PyObject* DocumentPy::getTempFileName(PyObject *args) std::string string; if (PyUnicode_Check(value)) { -#if PY_MAJOR_VERSION >= 3 string = PyUnicode_AsUTF8(value); -#else - PyObject* unicode = PyUnicode_AsUTF8String(value); - string = PyString_AsString(unicode); - Py_DECREF(unicode); - } - else if (PyString_Check(value)) { - string = PyString_AsString(value); -#endif } else { std::string error = std::string("type must be a string!"); diff --git a/src/App/Expression.cpp b/src/App/Expression.cpp index a68118389f..af94bb3622 100644 --- a/src/App/Expression.cpp +++ b/src/App/Expression.cpp @@ -445,17 +445,8 @@ static Py::Object _pyObjectFromAny(const App::any &value, const Expression *e) { else if (is_type(value,typeid(float))) return Py::Float(cast(value)); else if (is_type(value,typeid(int))) -#if PY_MAJOR_VERSION < 3 - return Py::Int(cast(value)); -#else return Py::Long(cast(value)); -#endif else if (is_type(value,typeid(long))) { -#if PY_MAJOR_VERSION < 3 - long l = cast(value); - if(std::abs(l)<=INT_MAX) - return Py::Int(int(l)); -#endif return Py::Long(cast(value)); } else if (is_type(value,typeid(bool))) return Py::Boolean(cast(value)); @@ -490,23 +481,8 @@ App::any pyObjectToAny(Py::Object value, bool check) { } if (PyFloat_Check(pyvalue)) return App::any(PyFloat_AsDouble(pyvalue)); -#if PY_MAJOR_VERSION < 3 - if (PyInt_Check(pyvalue)) - return App::any(PyInt_AsLong(pyvalue)); -#endif if (PyLong_Check(pyvalue)) return App::any(PyLong_AsLong(pyvalue)); -#if PY_MAJOR_VERSION < 3 - else if (PyString_Check(pyvalue)) - return App::any(std::string(PyString_AsString(pyvalue))); - else if (PyUnicode_Check(pyvalue)) { - PyObject * s = PyUnicode_AsUTF8String(pyvalue); - if(!s) - FC_THROWM(Base::ValueError,"Invalid unicode string"); - Py::Object o(s,true); - return App::any(std::string(PyString_AsString(s))); - } -#else else if (PyUnicode_Check(pyvalue)) { const char* value = PyUnicode_AsUTF8(pyvalue); if (!value) { @@ -514,7 +490,6 @@ App::any pyObjectToAny(Py::Object value, bool check) { } return App::any(std::string(value)); } -#endif else { return App::any(pyObjectWrap(pyvalue)); } @@ -525,10 +500,6 @@ bool pyToQuantity(Quantity &q, const Py::Object &pyobj) { q = *static_cast(*pyobj)->getQuantityPtr(); else if (PyFloat_Check(*pyobj)) q = Quantity(PyFloat_AsDouble(*pyobj)); -#if PY_MAJOR_VERSION < 3 - else if (PyInt_Check(*pyobj)) - q = Quantity(PyInt_AsLong(*pyobj)); -#endif else if (PyLong_Check(*pyobj)) q = Quantity(PyLong_AsLong(*pyobj)); else @@ -1479,30 +1450,6 @@ static Py::Object calc(const Expression *expr, int op, BINARY_OP(DIV,TrueDivide) case OperatorExpression::ADD: { PyObject *res; -#if PY_MAJOR_VERSION < 3 - if (PyString_CheckExact(*l) && PyString_CheckExact(*r)) { - Py_ssize_t v_len = PyString_GET_SIZE(*l); - Py_ssize_t w_len = PyString_GET_SIZE(*r); - Py_ssize_t new_len = v_len + w_len; - if (new_len < 0) - __EXPR_THROW(OverflowError, "strings are too large to concat", expr); - - if (l.ptr()->ob_refcnt==1 && !PyString_CHECK_INTERNED(l.ptr())) { - res = Py::new_reference_to(l); - // Must make sure ob_refcnt is still 1 - l = Py::Object(); - if (_PyString_Resize(&res, new_len) != 0) - EXPR_PY_THROW(expr); - memcpy(PyString_AS_STRING(res) + v_len, PyString_AS_STRING(*r), w_len); - }else{ - res = Py::new_reference_to(l); - l = Py::Object(); - PyString_Concat(&res,*r); - if(!res) EXPR_PY_THROW(expr); - } - return Py::asObject(res); - } -#else if (PyUnicode_CheckExact(*l) && PyUnicode_CheckExact(*r)) { if(inplace) { res = Py::new_reference_to(l); @@ -1516,7 +1463,6 @@ static Py::Object calc(const Expression *expr, int op, if(!res) EXPR_PY_THROW(expr); return Py::asObject(res); } -#endif _BINARY_OP(Add); } case OperatorExpression::POW: { @@ -1530,15 +1476,9 @@ static Py::Object calc(const Expression *expr, int op, } case OperatorExpression::MOD: { PyObject *res; -#if PY_MAJOR_VERSION < 3 - if (PyString_CheckExact(l.ptr()) && - (!PyString_Check(r.ptr()) || PyString_CheckExact(r.ptr()))) - res = PyString_Format(l.ptr(), r.ptr()); -#else if (PyUnicode_CheckExact(l.ptr()) && (!PyUnicode_Check(r.ptr()) || PyUnicode_CheckExact(r.ptr()))) res = PyUnicode_Format(l.ptr(), r.ptr()); -#endif else if(inplace) res = PyNumber_InPlaceRemainder(l.ptr(),r.ptr()); else diff --git a/src/App/FeaturePythonPyImp.inl b/src/App/FeaturePythonPyImp.inl index 600cfaef04..2d518cb7d3 100644 --- a/src/App/FeaturePythonPyImp.inl +++ b/src/App/FeaturePythonPyImp.inl @@ -49,11 +49,7 @@ PyTypeObject FeaturePythonPyT::Type = { /* --- Functions to access object as input/output buffer ---------*/ 0, /* tp_as_buffer */ /* --- Flags to define presence of optional/expanded features */ -#if PY_MAJOR_VERSION >= 3 Py_TPFLAGS_BASETYPE|Py_TPFLAGS_DEFAULT, /*tp_flags */ -#else - Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_CLASS, /*tp_flags */ -#endif "This is the father of all Feature classes", /*tp_doc */ 0, /*tp_traverse */ 0, /*tp_clear */ @@ -81,9 +77,7 @@ PyTypeObject FeaturePythonPyT::Type = { 0, /*tp_weaklist */ 0, /*tp_del */ 0 /*tp_version_tag */ -#if PY_MAJOR_VERSION >= 3 ,0 /*tp_finalize */ -#endif #if PY_VERSION_HEX >= 0x03080000 ,0 /*tp_vectorcall */ #endif @@ -108,11 +102,7 @@ template int FeaturePythonPyT::__setattro(PyObject *obj, PyObject *attro, PyObject *value) { const char *attr; -#if PY_MAJOR_VERSION >= 3 attr = PyUnicode_AsUTF8(attro); -#else - attr = PyString_AsString(attro); -#endif // This overwrites PyObjectBase::__setattr because this actively disallows to delete an attribute // @@ -144,11 +134,7 @@ int FeaturePythonPyT::_setattr(const char *attr, PyObject *value) if (value) { if (PyFunction_Check(value)) { PyErr_Clear(); -#if PY_MAJOR_VERSION < 3 - dict_item = PyMethod_New(value, this, 0); -#else dict_item = PyMethod_New(value, this); -#endif returnValue = PyDict_SetItemString(dict_methods, attr, dict_item); Py_XDECREF(dict_item); } diff --git a/src/App/LinkBaseExtensionPyImp.cpp b/src/App/LinkBaseExtensionPyImp.cpp index be38bc2fc5..e723e720c1 100644 --- a/src/App/LinkBaseExtensionPyImp.cpp +++ b/src/App/LinkBaseExtensionPyImp.cpp @@ -48,19 +48,11 @@ static bool getProperty(PropTmpMap &props, const LinkBaseExtension::PropInfoMap { std::ostringstream str; - #if PY_MAJOR_VERSION < 3 - if(!PyString_Check(key)) { - PyErr_SetString(PyExc_TypeError, "key must be string"); - return false; - } - const char *keyStr = PyString_AsString(key); -#else if(!PyUnicode_Check(key)) { PyErr_SetString(PyExc_TypeError, "key must be a unicode string"); return false; } const char *keyStr = PyUnicode_AsUTF8(key); -#endif auto it = infoMap.find(keyStr); if(it == infoMap.end()){ str << "unknown key '" << keyStr << "'"; @@ -72,19 +64,11 @@ static bool getProperty(PropTmpMap &props, const LinkBaseExtension::PropInfoMap if(key == value) valStr = keyStr; else if (value!=Py_None) { -#if PY_MAJOR_VERSION < 3 - if(!PyString_Check(value)) { - PyErr_SetString(PyExc_TypeError, "value must be string"); - return false; - } - valStr = PyString_AsString(value); -#else if(!PyUnicode_Check(value)) { PyErr_SetString(PyExc_TypeError, "value must be unicode string"); return false; } valStr = PyUnicode_AsUTF8(value); -#endif } App::Property *prop = 0; diff --git a/src/App/ObjectIdentifier.cpp b/src/App/ObjectIdentifier.cpp index 0ac3f82b1a..3b47871109 100644 --- a/src/App/ObjectIdentifier.cpp +++ b/src/App/ObjectIdentifier.cpp @@ -1548,11 +1548,7 @@ Py::Object ObjectIdentifier::access(const ResolveResults &result, Py::Object *va GET_MODULE(re); break; case PseudoBuiltins: -#if PY_MAJOR_VERSION < 3 - GET_MODULE(__builtin__); -#else GET_MODULE(builtins); -#endif break; case PseudoMath: GET_MODULE(math); diff --git a/src/App/Property.cpp b/src/App/Property.cpp index b0ab46c021..8f2142fd52 100644 --- a/src/App/Property.cpp +++ b/src/App/Property.cpp @@ -286,11 +286,7 @@ void PropertyListsBase::_setPyObject(PyObject *value) { for(auto it=dict.begin();it!=dict.end();++it) { const auto &item = *it; PyObject *key = item.first.ptr(); -#if PY_MAJOR_VERSION < 3 - if(!PyInt_Check(key)) -#else if(!PyLong_Check(key)) -#endif throw Base::TypeError("expect key type to be integer"); long idx = PyLong_AsLong(key); if(idx<-1 || idx>listSize) diff --git a/src/App/PropertyFile.cpp b/src/App/PropertyFile.cpp index 93394d47ec..c563cb79c6 100644 --- a/src/App/PropertyFile.cpp +++ b/src/App/PropertyFile.cpp @@ -253,7 +253,6 @@ PyObject *PropertyFileIncluded::getPyObject(void) return p; } -#if PY_MAJOR_VERSION >= 3 namespace App { const char* getNameFromFile(PyObject* value) { @@ -286,11 +285,9 @@ bool isIOFile(PyObject* file) return isFile; } } -#endif void PropertyFileIncluded::setPyObject(PyObject *value) { -#if PY_MAJOR_VERSION >= 3 std::string string; if (PyUnicode_Check(value)) { string = PyUnicode_AsUTF8(value); @@ -301,21 +298,6 @@ void PropertyFileIncluded::setPyObject(PyObject *value) else if (isIOFile(value)){ string = getNameFromFile(value); } -#else - std::string string; - if (PyUnicode_Check(value)) { - PyObject* unicode = PyUnicode_AsUTF8String(value); - string = PyString_AsString(unicode); - Py_DECREF(unicode); - } - else if (PyString_Check(value)) { - string = PyString_AsString(value); - } - else if (PyFile_Check(value)) { - PyObject* FileName = PyFile_Name(value); - string = PyString_AsString(FileName); - } -#endif else if (PyTuple_Check(value)) { if (PyTuple_Size(value) != 2) throw Base::TypeError("Tuple needs size of (filePath,newFileName)"); @@ -324,7 +306,6 @@ void PropertyFileIncluded::setPyObject(PyObject *value) // decoding file std::string fileStr; -#if PY_MAJOR_VERSION >= 3 if (PyUnicode_Check(file)) { fileStr = PyUnicode_AsUTF8(file); } @@ -334,20 +315,6 @@ void PropertyFileIncluded::setPyObject(PyObject *value) else if (isIOFile(value)) { fileStr = getNameFromFile(file); } -#else - if (PyUnicode_Check(file)) { - PyObject* unicode = PyUnicode_AsUTF8String(file); - fileStr = PyString_AsString(unicode); - Py_DECREF(unicode); - } - else if (PyString_Check(file)) { - fileStr = PyString_AsString(file); - } - else if (PyFile_Check(file)) { - PyObject* FileName = PyFile_Name(file); - fileStr = PyString_AsString(FileName); - } -#endif else { std::string error = std::string("First item in tuple must be a file or string, not "); error += file->ob_type->tp_name; @@ -356,7 +323,6 @@ void PropertyFileIncluded::setPyObject(PyObject *value) // decoding name std::string nameStr; -#if PY_MAJOR_VERSION >= 3 if (PyUnicode_Check(name)) { nameStr = PyUnicode_AsUTF8(name); } @@ -366,15 +332,6 @@ void PropertyFileIncluded::setPyObject(PyObject *value) else if (isIOFile(value)) { nameStr = getNameFromFile(name); } -#else - if (PyString_Check(name)) { - nameStr = PyString_AsString(name); - } - else if (PyFile_Check(name)) { - PyObject* FileName = PyFile_Name(name); - nameStr = PyString_AsString(FileName); - } -#endif else { std::string error = std::string("Second item in tuple must be a string, not "); error += name->ob_type->tp_name; diff --git a/src/App/PropertyGeo.cpp b/src/App/PropertyGeo.cpp index e6d1a20064..02909b32d5 100644 --- a/src/App/PropertyGeo.cpp +++ b/src/App/PropertyGeo.cpp @@ -118,39 +118,24 @@ void PropertyVector::setPyObject(PyObject *value) item = PyTuple_GetItem(value,0); if (PyFloat_Check(item)) cVec.x = PyFloat_AsDouble(item); -#if PY_MAJOR_VERSION < 3 - else if (PyInt_Check(item)) - cVec.x = (double)PyInt_AsLong(item); -#else else if (PyLong_Check(item)) cVec.x = (double)PyLong_AsLong(item); -#endif else throw Base::TypeError("Not allowed type used in tuple (float expected)..."); // y item = PyTuple_GetItem(value,1); if (PyFloat_Check(item)) cVec.y = PyFloat_AsDouble(item); -#if PY_MAJOR_VERSION < 3 - else if (PyInt_Check(item)) - cVec.y = (double)PyInt_AsLong(item); -#else else if (PyLong_Check(item)) cVec.y = (double)PyLong_AsLong(item); -#endif else throw Base::TypeError("Not allowed type used in tuple (float expected)..."); // z item = PyTuple_GetItem(value,2); if (PyFloat_Check(item)) cVec.z = PyFloat_AsDouble(item); -#if PY_MAJOR_VERSION < 3 - else if (PyInt_Check(item)) - cVec.z = (double)PyInt_AsLong(item); -#else else if (PyLong_Check(item)) cVec.z = (double)PyLong_AsLong(item); -#endif else throw Base::TypeError("Not allowed type used in tuple (float expected)..."); setValue( cVec ); @@ -474,13 +459,8 @@ void PropertyMatrix::setPyObject(PyObject *value) item = PyTuple_GetItem(value,x+y*4); if (PyFloat_Check(item)) cMatrix[x][y] = PyFloat_AsDouble(item); -#if PY_MAJOR_VERSION < 3 - else if (PyInt_Check(item)) - cMatrix[x][y] = (double)PyInt_AsLong(item); -#else else if (PyLong_Check(item)) cMatrix[x][y] = (double)PyLong_AsLong(item); -#endif else throw Base::TypeError("Not allowed type used in matrix tuple (a number expected)..."); } diff --git a/src/App/PropertyPythonObject.cpp b/src/App/PropertyPythonObject.cpp index d7aa79a295..8e201a5cba 100644 --- a/src/App/PropertyPythonObject.cpp +++ b/src/App/PropertyPythonObject.cpp @@ -341,14 +341,7 @@ void PropertyPythonObject::Restore(Base::XMLReader &reader) << " has no class " << reader.getAttribute("class"); throw Py::AttributeError(s.str()); } -#if PY_MAJOR_VERSION >= 3 if (PyType_Check(cls)) { -#else - if (PyClass_Check(cls)) { - this->object = PyInstance_NewRaw(cls, 0); - } - else if (PyType_Check(cls)) { -#endif this->object = PyType_GenericAlloc((PyTypeObject*)cls, 0); } else { @@ -362,11 +355,7 @@ void PropertyPythonObject::Restore(Base::XMLReader &reader) Py::Module mod(PyImport_ImportModule(nam.c_str()),true); if (mod.isNull()) throw Py::Exception(); -#if PY_MAJOR_VERSION >= 3 this->object = PyObject_CallObject(mod.getAttr(cls).ptr(), NULL); -#else - this->object = PyInstance_NewRaw(mod.getAttr(cls).ptr(), 0); -#endif load_pickle = true; buffer = std::string(what[2].second, end); } diff --git a/src/App/PropertyUnits.cpp b/src/App/PropertyUnits.cpp index 36884cb81a..8e3443cc01 100644 --- a/src/App/PropertyUnits.cpp +++ b/src/App/PropertyUnits.cpp @@ -78,25 +78,10 @@ Base::Quantity PropertyQuantity::createQuantityFromPy(PyObject *value) Base::Quantity quant; if (PyUnicode_Check(value)){ -#if PY_MAJOR_VERSION >= 3 quant = Quantity::parse(QString::fromUtf8(PyUnicode_AsUTF8(value))); } -#else - PyObject* unicode = PyUnicode_AsUTF8String(value); - std::string Str; - Str = PyString_AsString(unicode); - quant = Quantity::parse(QString::fromUtf8(Str.c_str())); - Py_DECREF(unicode); - } - else if (PyString_Check(value)) - quant = Quantity::parse(QString::fromLatin1(PyString_AsString(value))); -#endif else if (PyFloat_Check(value)) quant = Quantity(PyFloat_AsDouble(value),_Unit); -#if PY_MAJOR_VERSION < 3 - else if (PyInt_Check(value)) - quant = Quantity((double)PyInt_AsLong(value),_Unit); -#endif else if (PyLong_Check(value)) quant = Quantity((double)PyLong_AsLong(value),_Unit); else if (PyObject_TypeCheck(value, &(QuantityPy::Type))) { From 9458e5c12fe5669119fc6d612f56e9ccffb7307c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Stelmach?= Date: Mon, 19 Apr 2021 19:39:22 +0200 Subject: [PATCH 118/178] Draft: Ensure horizontal orientation of snap_widget MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From time to time when switching to other workbenches snap_widget changes orientation to vertical. Make sure it stays horizontal. Signed-off-by: Åukasz Stelmach --- src/Mod/Draft/draftutils/init_draft_statusbar.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Mod/Draft/draftutils/init_draft_statusbar.py b/src/Mod/Draft/draftutils/init_draft_statusbar.py index 1c0c1c07d9..5d41b8b6a1 100644 --- a/src/Mod/Draft/draftutils/init_draft_statusbar.py +++ b/src/Mod/Draft/draftutils/init_draft_statusbar.py @@ -340,6 +340,7 @@ def init_draft_statusbar_snap(): # add snap widget to the statusbar sb.insertPermanentWidget(2, snap_widget) + snap_widget.setOrientation(QtCore.Qt.Orientation.Horizontal) snap_widget.show() @@ -373,11 +374,13 @@ def show_draft_statusbar(): snap_widget = sb.findChild(QtGui.QToolBar,"draft_snap_widget") if snap_widget: + snap_widget.setOrientation(QtCore.Qt.Orientation.Horizontal) snap_widget.show() else: snap_widget = mw.findChild(QtGui.QToolBar,"draft_snap_widget") if snap_widget: sb.insertPermanentWidget(2, snap_widget) + snap_widget.setOrientation(QtCore.Qt.Orientation.Horizontal) snap_widget.show() elif params.GetBool("DisplayStatusbarSnapWidget", True): t = QtCore.QTimer() From e4f98b4512bb4a28ba6689f177b792c615b0d691 Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 20 Apr 2021 14:07:20 +0200 Subject: [PATCH 119/178] Base: add convenience functions to create a QString from quantity or double --- src/Base/Quantity.cpp | 8 ++++++++ src/Base/Quantity.h | 1 + src/Base/UnitsApi.cpp | 11 +++++++++++ src/Base/UnitsApi.h | 7 +++++++ 4 files changed, 27 insertions(+) diff --git a/src/Base/Quantity.cpp b/src/Base/Quantity.cpp index d90413c109..4e1da56480 100644 --- a/src/Base/Quantity.cpp +++ b/src/Base/Quantity.cpp @@ -63,6 +63,14 @@ QuantityFormat::QuantityFormat() { } +QuantityFormat::QuantityFormat(QuantityFormat::NumberFormat format, int decimals) + : option(OmitGroupSeparator | RejectGroupSeparator) + , format(format) + , precision(decimals < 0 ? UnitsApi::getDecimals() : decimals) + , denominator(defaultDenominator) +{ +} + // ---------------------------------------------------------------------------- Quantity::Quantity() diff --git a/src/Base/Quantity.h b/src/Base/Quantity.h index d142fca0df..d5b11331f0 100644 --- a/src/Base/Quantity.h +++ b/src/Base/Quantity.h @@ -75,6 +75,7 @@ struct BaseExport QuantityFormat { denominator = denom; } QuantityFormat(); + QuantityFormat(NumberFormat format, int decimals=-1); inline char toFormat() const { switch (format) { case Fixed: diff --git a/src/Base/UnitsApi.cpp b/src/Base/UnitsApi.cpp index e5fdf5fd0d..5512a438f9 100644 --- a/src/Base/UnitsApi.cpp +++ b/src/Base/UnitsApi.cpp @@ -154,6 +154,17 @@ void UnitsApi::setSchema(UnitSystem s) UserPrefSystem->setSchemaUnits(); // if necessary a unit schema can change the constants in Quantity (e.g. mi=1.8km rather then 1.6km). } +QString UnitsApi::toNumber(const Base::Quantity& q, const QuantityFormat& f) +{ + QString number = QString::fromLatin1("%1").arg(q.getValue(), 0, f.toFormat(), f.precision); + return number; +} + +QString UnitsApi::toNumber(double d, const QuantityFormat& f) +{ + QString number = QString::fromLatin1("%1").arg(d, 0, f.toFormat(), f.precision); + return number; +} //double UnitsApi::translateUnit(const char* str) //{ diff --git a/src/Base/UnitsApi.h b/src/Base/UnitsApi.h index a6e4e1a21a..17d4d36ab5 100644 --- a/src/Base/UnitsApi.h +++ b/src/Base/UnitsApi.h @@ -66,6 +66,13 @@ public: return UnitsApi::schemaTranslate(quant, dummy1, dummy2); } + /** Get a number as string for a quantity of a given format. + * The string is a number in C locale (i.e. the decimal separator is always a dot) and if + * needed represented in scientific notation. The string doesn't include the unit of the quantity. + */ + static QString toNumber(const Base::Quantity& q, const QuantityFormat& f = QuantityFormat(QuantityFormat::Default)); + static QString toNumber(double d, const QuantityFormat& f = QuantityFormat(QuantityFormat::Default)); + /// generate a value for a quantity with default user preferred system static double toDbl(PyObject *ArgObj,const Base::Unit &u=Base::Unit()); /// generate a value for a quantity with default user preferred system From b0d29b745cb8018a6fd103ee229924b3880d675a Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 20 Apr 2021 14:56:29 +0200 Subject: [PATCH 120/178] Base: add convenience functions to create a QString from quantity --- src/Base/UnitsApi.cpp | 12 +++++++++--- src/Base/UnitsApi.h | 9 +++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/Base/UnitsApi.cpp b/src/Base/UnitsApi.cpp index 5512a438f9..b42d7f29bd 100644 --- a/src/Base/UnitsApi.cpp +++ b/src/Base/UnitsApi.cpp @@ -154,15 +154,21 @@ void UnitsApi::setSchema(UnitSystem s) UserPrefSystem->setSchemaUnits(); // if necessary a unit schema can change the constants in Quantity (e.g. mi=1.8km rather then 1.6km). } +QString UnitsApi::toString(const Base::Quantity& q, const QuantityFormat& f) +{ + QString value = QString::fromLatin1("'%1 %2'").arg(q.getValue(), 0, f.toFormat(), f.precision+1) + .arg(q.getUnit().getString()); + return value; +} + QString UnitsApi::toNumber(const Base::Quantity& q, const QuantityFormat& f) { - QString number = QString::fromLatin1("%1").arg(q.getValue(), 0, f.toFormat(), f.precision); - return number; + return toNumber(q.getValue(), f); } QString UnitsApi::toNumber(double d, const QuantityFormat& f) { - QString number = QString::fromLatin1("%1").arg(d, 0, f.toFormat(), f.precision); + QString number = QString::fromLatin1("%1").arg(d, 0, f.toFormat(), f.precision+1); return number; } diff --git a/src/Base/UnitsApi.h b/src/Base/UnitsApi.h index 17d4d36ab5..594878d7e7 100644 --- a/src/Base/UnitsApi.h +++ b/src/Base/UnitsApi.h @@ -66,11 +66,20 @@ public: return UnitsApi::schemaTranslate(quant, dummy1, dummy2); } + /** Get a number as string for a quantity of a given format. + * The string is a number in C locale (i.e. the decimal separator is always a dot) and if + * needed represented in scientific notation. The string also includes the unit of the quantity. + */ + static QString toString(const Base::Quantity& q, const QuantityFormat& f = QuantityFormat(QuantityFormat::Default)); /** Get a number as string for a quantity of a given format. * The string is a number in C locale (i.e. the decimal separator is always a dot) and if * needed represented in scientific notation. The string doesn't include the unit of the quantity. */ static QString toNumber(const Base::Quantity& q, const QuantityFormat& f = QuantityFormat(QuantityFormat::Default)); + /** Get a number as string for a double of a given format. + * The string is a number in C locale (i.e. the decimal separator is always a dot) and if + * needed represented in scientific notation. The string doesn't include the unit of the quantity. + */ static QString toNumber(double d, const QuantityFormat& f = QuantityFormat(QuantityFormat::Default)); /// generate a value for a quantity with default user preferred system From ba63ef51e5ab14cef4d1a85ad2df41909c3d77af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Stelmach?= Date: Tue, 20 Apr 2021 14:37:53 +0200 Subject: [PATCH 121/178] Arch: Parse window opening modes with more than one digit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Åukasz Stelmach --- src/Mod/Arch/ArchWindow.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Mod/Arch/ArchWindow.py b/src/Mod/Arch/ArchWindow.py index 8326d1a3d6..4b9f92cdd5 100644 --- a/src/Mod/Arch/ArchWindow.py +++ b/src/Mod/Arch/ArchWindow.py @@ -632,7 +632,10 @@ class _Window(ArchComponent.Component): elif "Edge" in s: hinge = int(s[4:])-1 elif "Mode" in s: - omode = int(s[-1]) + omode = int(s[4:]) + if omode >= len(WindowOpeningModes): + # Ignore modes not listed in WindowOpeningModes + omode = None if wires: max_length = 0 for w in wires: @@ -1510,7 +1513,11 @@ class _ArchWindowTaskPanel: elif "Edge" in l: self.field6.setText(l) elif "Mode" in l: - self.field7.setCurrentIndex(int(l[-1])) + if int(l[4:]) < len(WindowOpeningModes): + self.field7.setCurrentIndex(int(l[4:])) + else: + # Ignore modes not listed in WindowOpeningModes + self.field7.setCurrentIndex(0) if wires: f.setText(",".join(wires)) From 7f66f3f4dc0282d8312d12dc58749e74aeb4f6aa Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 20 Apr 2021 17:10:33 +0200 Subject: [PATCH 122/178] Gui: properly handle small quantities in property editor --- src/Gui/propertyeditor/PropertyItem.cpp | 27 ++++++++++++++----------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/Gui/propertyeditor/PropertyItem.cpp b/src/Gui/propertyeditor/PropertyItem.cpp index 75d67ce4cb..512e7589cb 100644 --- a/src/Gui/propertyeditor/PropertyItem.cpp +++ b/src/Gui/propertyeditor/PropertyItem.cpp @@ -1051,8 +1051,8 @@ void PropertyUnitItem::setValue(const QVariant& value) return; const Base::Quantity& val = value.value(); - QString unit = QString::fromLatin1("'%1 %2'").arg(val.getValue(),0,'f',decimals()) - .arg(val.getUnit().getString()); + Base::QuantityFormat format(Base::QuantityFormat::Default, decimals()); + QString unit = Base::UnitsApi::toString(val, format); setPropertyValue(unit); } } @@ -1643,10 +1643,12 @@ void PropertyVectorDistanceItem::setValue(const QVariant& variant) Base::Quantity x = Base::Quantity(value.x, Base::Unit::Length); Base::Quantity y = Base::Quantity(value.y, Base::Unit::Length); Base::Quantity z = Base::Quantity(value.z, Base::Unit::Length); + + Base::QuantityFormat format(Base::QuantityFormat::Default, decimals()); QString data = QString::fromLatin1("(%1, %2, %3)") - .arg(x.getValue(),0,'f',decimals()) - .arg(y.getValue(),0,'f',decimals()) - .arg(z.getValue(),0,'f',decimals()); + .arg(Base::UnitsApi::toNumber(x, format)) + .arg(Base::UnitsApi::toNumber(y, format)) + .arg(Base::UnitsApi::toNumber(z, format)); setPropertyValue(data); } @@ -2368,16 +2370,17 @@ void PropertyPlacementItem::setValue(const QVariant& value) const Base::Placement& val = value.value(); Base::Vector3d pos = val.getPosition(); + Base::QuantityFormat format(Base::QuantityFormat::Default, decimals()); QString data = QString::fromLatin1("App.Placement(" "App.Vector(%1,%2,%3)," "App.Rotation(App.Vector(%4,%5,%6),%7))") - .arg(pos.x, 0, 'f', decimals()) - .arg(pos.y, 0, 'f', decimals()) - .arg(pos.z, 0, 'f', decimals()) - .arg(rot_axis.x, 0, 'f', decimals()) - .arg(rot_axis.y, 0, 'f', decimals()) - .arg(rot_axis.z, 0, 'f', decimals()) - .arg(rot_angle, 0, 'f', decimals()); + .arg(Base::UnitsApi::toNumber(pos.x, format)) + .arg(Base::UnitsApi::toNumber(pos.y, format)) + .arg(Base::UnitsApi::toNumber(pos.z, format)) + .arg(Base::UnitsApi::toNumber(rot_axis.x, format)) + .arg(Base::UnitsApi::toNumber(rot_axis.y, format)) + .arg(Base::UnitsApi::toNumber(rot_axis.z, format)) + .arg(Base::UnitsApi::toNumber(rot_angle, format)); setPropertyValue(data); } From 791508eb0d53dd1dc5b4211a426bdab7b3ee9a58 Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 20 Apr 2021 17:11:17 +0200 Subject: [PATCH 123/178] Mesh: properly handle small quantities in mesh primitive dialog --- src/Mod/Mesh/Gui/DlgRegularSolidImp.cpp | 30 ++++++++++++------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/Mod/Mesh/Gui/DlgRegularSolidImp.cpp b/src/Mod/Mesh/Gui/DlgRegularSolidImp.cpp index da41a8068b..d521324db4 100644 --- a/src/Mod/Mesh/Gui/DlgRegularSolidImp.cpp +++ b/src/Mod/Mesh/Gui/DlgRegularSolidImp.cpp @@ -135,9 +135,9 @@ void DlgRegularSolidImp::on_createSolidButton_clicked() "App.ActiveDocument.%1.Width=%3\n" "App.ActiveDocument.%1.Height=%4\n")) .arg(QLatin1String(name.c_str())) - .arg(ui->boxLength->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->boxWidth->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->boxHeight->value().getValue(),0,'f',Base::UnitsApi::getDecimals()); + .arg(Base::UnitsApi::toNumber(ui->boxLength->value())) + .arg(Base::UnitsApi::toNumber(ui->boxWidth->value())) + .arg(Base::UnitsApi::toNumber(ui->boxHeight->value())); } else if (ui->comboBox1->currentIndex() == 1) { // cylinder name = doc->getUniqueObjectName("Cylinder"); @@ -149,9 +149,9 @@ void DlgRegularSolidImp::on_createSolidButton_clicked() "App.ActiveDocument.%1.Closed=%5\n" "App.ActiveDocument.%1.Sampling=%6\n")) .arg(QLatin1String(name.c_str())) - .arg(ui->cylinderRadius->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->cylinderLength->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->cylinderEdgeLength->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) + .arg(Base::UnitsApi::toNumber(ui->cylinderRadius->value())) + .arg(Base::UnitsApi::toNumber(ui->cylinderLength->value())) + .arg(Base::UnitsApi::toNumber(ui->cylinderEdgeLength->value())) .arg(QLatin1String((ui->cylinderClosed->isChecked()?"True":"False"))) .arg(ui->cylinderCount->value()); } @@ -166,10 +166,10 @@ void DlgRegularSolidImp::on_createSolidButton_clicked() "App.ActiveDocument.%1.Closed=%6\n" "App.ActiveDocument.%1.Sampling=%7\n")) .arg(QLatin1String(name.c_str())) - .arg(ui->coneRadius1->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->coneRadius2->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->coneLength->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->coneEdgeLength->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) + .arg(Base::UnitsApi::toNumber(ui->coneRadius1->value())) + .arg(Base::UnitsApi::toNumber(ui->coneRadius2->value())) + .arg(Base::UnitsApi::toNumber(ui->coneLength->value())) + .arg(Base::UnitsApi::toNumber(ui->coneEdgeLength->value())) .arg(QLatin1String((ui->coneClosed->isChecked()?"True":"False"))) .arg(ui->coneCount->value()); } @@ -180,7 +180,7 @@ void DlgRegularSolidImp::on_createSolidButton_clicked() "App.ActiveDocument.%1.Radius=%2\n" "App.ActiveDocument.%1.Sampling=%3\n")) .arg(QLatin1String(name.c_str())) - .arg(ui->sphereRadius->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) + .arg(Base::UnitsApi::toNumber(ui->sphereRadius->value())) .arg(ui->sphereCount->value()); } else if (ui->comboBox1->currentIndex() == 4) { // ellipsoid @@ -191,8 +191,8 @@ void DlgRegularSolidImp::on_createSolidButton_clicked() "App.ActiveDocument.%1.Radius2=%3\n" "App.ActiveDocument.%1.Sampling=%4\n")) .arg(QLatin1String(name.c_str())) - .arg(ui->ellipsoidRadius1->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->ellipsoidRadius2->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) + .arg(Base::UnitsApi::toNumber(ui->ellipsoidRadius1->value())) + .arg(Base::UnitsApi::toNumber(ui->ellipsoidRadius2->value())) .arg(ui->ellipsoidCount->value()); } else if (ui->comboBox1->currentIndex() == 5) { // toroid @@ -203,8 +203,8 @@ void DlgRegularSolidImp::on_createSolidButton_clicked() "App.ActiveDocument.%1.Radius2=%3\n" "App.ActiveDocument.%1.Sampling=%4\n")) .arg(QLatin1String(name.c_str())) - .arg(ui->toroidRadius1->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->toroidRadius2->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) + .arg(Base::UnitsApi::toNumber(ui->toroidRadius1->value())) + .arg(Base::UnitsApi::toNumber(ui->toroidRadius2->value())) .arg(ui->toroidCount->value()); } From 2fe44f80b90978c0d0242f0b9aae7c99ac779536 Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 20 Apr 2021 17:11:38 +0200 Subject: [PATCH 124/178] Part: properly handle small quantities in part primitive dialog --- src/Mod/Part/Gui/DlgPrimitives.cpp | 284 ++++++++++++++--------------- 1 file changed, 142 insertions(+), 142 deletions(-) diff --git a/src/Mod/Part/Gui/DlgPrimitives.cpp b/src/Mod/Part/Gui/DlgPrimitives.cpp index ce19072f44..3e428146ad 100644 --- a/src/Mod/Part/Gui/DlgPrimitives.cpp +++ b/src/Mod/Part/Gui/DlgPrimitives.cpp @@ -137,13 +137,13 @@ QString Picker::toPlacement(const gp_Ax2& axis) const gp_Pnt loc = axis.Location(); return QString::fromLatin1("Base.Placement(Base.Vector(%1,%2,%3),Base.Rotation(%4,%5,%6,%7))") - .arg(loc.X(),0,'f',Base::UnitsApi::getDecimals()) - .arg(loc.Y(),0,'f',Base::UnitsApi::getDecimals()) - .arg(loc.Z(),0,'f',Base::UnitsApi::getDecimals()) - .arg(rot[0],0,'f',Base::UnitsApi::getDecimals()) - .arg(rot[1],0,'f',Base::UnitsApi::getDecimals()) - .arg(rot[2],0,'f',Base::UnitsApi::getDecimals()) - .arg(rot[3],0,'f',Base::UnitsApi::getDecimals()); + .arg(loc.X(),0,'g',Base::UnitsApi::getDecimals()) + .arg(loc.Y(),0,'g',Base::UnitsApi::getDecimals()) + .arg(loc.Z(),0,'g',Base::UnitsApi::getDecimals()) + .arg(rot[0],0,'g',Base::UnitsApi::getDecimals()) + .arg(rot[1],0,'g',Base::UnitsApi::getDecimals()) + .arg(rot[2],0,'g',Base::UnitsApi::getDecimals()) + .arg(rot[3],0,'g',Base::UnitsApi::getDecimals()); } class CircleFromThreePoints : public Picker @@ -174,9 +174,9 @@ public: "App.ActiveDocument.%1.Angle1=%4\n" "App.ActiveDocument.%1.Placement=%5\n") .arg(name) - .arg(circle->Radius(),0,'f',Base::UnitsApi::getDecimals()) - .arg(Base::toDegrees(trim->FirstParameter()),0,'f',Base::UnitsApi::getDecimals()) - .arg(Base::toDegrees(trim->LastParameter ()),0,'f',Base::UnitsApi::getDecimals()) + .arg(circle->Radius(),0,'g',Base::UnitsApi::getDecimals()) + .arg(Base::toDegrees(trim->FirstParameter()),0,'g',Base::UnitsApi::getDecimals()) + .arg(Base::toDegrees(trim->LastParameter ()),0,'g',Base::UnitsApi::getDecimals()) .arg(toPlacement(circle->Position())); } @@ -720,8 +720,8 @@ QString DlgPrimitives::createPlane(const QString& objectName, const QString& pla "App.ActiveDocument.%1.Placement=%4\n" "App.ActiveDocument.%1.Label='%5'\n") .arg(objectName) - .arg(ui->planeLength->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->planeWidth->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) + .arg(Base::UnitsApi::toNumber(ui->planeLength->value())) + .arg(Base::UnitsApi::toNumber(ui->planeWidth->value())) .arg(placement) .arg(tr("Plane")); } @@ -736,9 +736,9 @@ QString DlgPrimitives::createBox(const QString& objectName, const QString& place "App.ActiveDocument.%1.Placement=%5\n" "App.ActiveDocument.%1.Label='%6'\n") .arg(objectName) - .arg(ui->boxLength->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->boxWidth->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->boxHeight->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) + .arg(Base::UnitsApi::toNumber(ui->boxLength->value())) + .arg(Base::UnitsApi::toNumber(ui->boxWidth->value())) + .arg(Base::UnitsApi::toNumber(ui->boxHeight->value())) .arg(placement) .arg(tr("Box")); } @@ -755,11 +755,11 @@ QString DlgPrimitives::createCylinder(const QString& objectName, const QString& "App.ActiveDocument.%1.Placement=%7\n" "App.ActiveDocument.%1.Label='%8'\n") .arg(objectName) - .arg(ui->cylinderRadius->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->cylinderHeight->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->cylinderAngle->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->cylinderXSkew->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->cylinderYSkew->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) + .arg(Base::UnitsApi::toNumber(ui->cylinderRadius->value())) + .arg(Base::UnitsApi::toNumber(ui->cylinderHeight->value())) + .arg(Base::UnitsApi::toNumber(ui->cylinderAngle->value())) + .arg(Base::UnitsApi::toNumber(ui->cylinderXSkew->value())) + .arg(Base::UnitsApi::toNumber(ui->cylinderYSkew->value())) .arg(placement) .arg(tr("Cylinder")); } @@ -775,10 +775,10 @@ QString DlgPrimitives::createCone(const QString& objectName, const QString& plac "App.ActiveDocument.%1.Placement=%6\n" "App.ActiveDocument.%1.Label='%7'\n") .arg(objectName) - .arg(ui->coneRadius1->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->coneRadius2->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->coneHeight->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->coneAngle->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) + .arg(Base::UnitsApi::toNumber(ui->coneRadius1->value())) + .arg(Base::UnitsApi::toNumber(ui->coneRadius2->value())) + .arg(Base::UnitsApi::toNumber(ui->coneHeight->value())) + .arg(Base::UnitsApi::toNumber(ui->coneAngle->value())) .arg(placement) .arg(tr("Cone")); } @@ -794,10 +794,10 @@ QString DlgPrimitives::createSphere(const QString& objectName, const QString& pl "App.ActiveDocument.%1.Placement=%6\n" "App.ActiveDocument.%1.Label='%7'\n") .arg(objectName) - .arg(ui->sphereRadius->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->sphereAngle1->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->sphereAngle2->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->sphereAngle3->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) + .arg(Base::UnitsApi::toNumber(ui->sphereRadius->value())) + .arg(Base::UnitsApi::toNumber(ui->sphereAngle1->value())) + .arg(Base::UnitsApi::toNumber(ui->sphereAngle2->value())) + .arg(Base::UnitsApi::toNumber(ui->sphereAngle3->value())) .arg(placement) .arg(tr("Sphere")); } @@ -815,12 +815,12 @@ QString DlgPrimitives::createEllipsoid(const QString& objectName, const QString& "App.ActiveDocument.%1.Placement=%8\n" "App.ActiveDocument.%1.Label='%9'\n") .arg(objectName) - .arg(ui->ellipsoidRadius1->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->ellipsoidRadius2->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->ellipsoidRadius3->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->ellipsoidAngle1->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->ellipsoidAngle2->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->ellipsoidAngle3->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) + .arg(Base::UnitsApi::toNumber(ui->ellipsoidRadius1->value())) + .arg(Base::UnitsApi::toNumber(ui->ellipsoidRadius2->value())) + .arg(Base::UnitsApi::toNumber(ui->ellipsoidRadius3->value())) + .arg(Base::UnitsApi::toNumber(ui->ellipsoidAngle1->value())) + .arg(Base::UnitsApi::toNumber(ui->ellipsoidAngle2->value())) + .arg(Base::UnitsApi::toNumber(ui->ellipsoidAngle3->value())) .arg(placement) .arg(tr("Ellipsoid")); } @@ -837,11 +837,11 @@ QString DlgPrimitives::createTorus(const QString& objectName, const QString& pla "App.ActiveDocument.%1.Placement=%7\n" "App.ActiveDocument.%1.Label='%8'\n") .arg(objectName) - .arg(ui->torusRadius1->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->torusRadius2->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->torusAngle1->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->torusAngle2->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->torusAngle3->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) + .arg(Base::UnitsApi::toNumber(ui->torusRadius1->value())) + .arg(Base::UnitsApi::toNumber(ui->torusRadius2->value())) + .arg(Base::UnitsApi::toNumber(ui->torusAngle1->value())) + .arg(Base::UnitsApi::toNumber(ui->torusAngle2->value())) + .arg(Base::UnitsApi::toNumber(ui->torusAngle3->value())) .arg(placement) .arg(tr("Torus")); } @@ -859,10 +859,10 @@ QString DlgPrimitives::createPrism(const QString& objectName, const QString& pla "App.ActiveDocument.%1.Label='%8'\n") .arg(objectName) .arg(ui->prismPolygon->value()) - .arg(ui->prismCircumradius->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->prismHeight->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->prismXSkew->value().getValue(), 0, 'f', Base::UnitsApi::getDecimals()) - .arg(ui->prismYSkew->value().getValue(), 0, 'f', Base::UnitsApi::getDecimals()) + .arg(Base::UnitsApi::toNumber(ui->prismCircumradius->value())) + .arg(Base::UnitsApi::toNumber(ui->prismHeight->value())) + .arg(Base::UnitsApi::toNumber(ui->prismXSkew->value())) + .arg(Base::UnitsApi::toNumber(ui->prismYSkew->value())) .arg(placement) .arg(tr("Prism")); } @@ -884,16 +884,16 @@ QString DlgPrimitives::createWedge(const QString& objectName, const QString& pla "App.ActiveDocument.%1.Placement=%12\n" "App.ActiveDocument.%1.Label='%13'\n") .arg(objectName) - .arg(ui->wedgeXmin->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->wedgeYmin->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->wedgeZmin->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->wedgeX2min->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->wedgeZ2min->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->wedgeXmax->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->wedgeYmax->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->wedgeZmax->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->wedgeX2max->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->wedgeZ2max->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) + .arg(Base::UnitsApi::toNumber(ui->wedgeXmin->value())) + .arg(Base::UnitsApi::toNumber(ui->wedgeYmin->value())) + .arg(Base::UnitsApi::toNumber(ui->wedgeZmin->value())) + .arg(Base::UnitsApi::toNumber(ui->wedgeX2min->value())) + .arg(Base::UnitsApi::toNumber(ui->wedgeZ2min->value())) + .arg(Base::UnitsApi::toNumber(ui->wedgeXmax->value())) + .arg(Base::UnitsApi::toNumber(ui->wedgeYmax->value())) + .arg(Base::UnitsApi::toNumber(ui->wedgeZmax->value())) + .arg(Base::UnitsApi::toNumber(ui->wedgeX2max->value())) + .arg(Base::UnitsApi::toNumber(ui->wedgeZ2max->value())) .arg(placement) .arg(tr("Wedge")); } @@ -911,10 +911,10 @@ QString DlgPrimitives::createHelix(const QString& objectName, const QString& pla "App.ActiveDocument.%1.Placement=%7\n" "App.ActiveDocument.%1.Label='%8'\n") .arg(objectName) - .arg(ui->helixPitch->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->helixHeight->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->helixRadius->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->helixAngle->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) + .arg(Base::UnitsApi::toNumber(ui->helixPitch->value())) + .arg(Base::UnitsApi::toNumber(ui->helixHeight->value())) + .arg(Base::UnitsApi::toNumber(ui->helixRadius->value())) + .arg(Base::UnitsApi::toNumber(ui->helixAngle->value())) .arg(ui->helixLocalCS->currentIndex()) .arg(placement) .arg(tr("Helix")); @@ -930,9 +930,9 @@ QString DlgPrimitives::createSpiral(const QString& objectName, const QString& pl "App.ActiveDocument.%1.Placement=%5\n" "App.ActiveDocument.%1.Label='%6'\n") .arg(objectName) - .arg(ui->spiralGrowth->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->spiralRotation->value(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->spiralRadius->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) + .arg(Base::UnitsApi::toNumber(ui->spiralGrowth->value())) + .arg(Base::UnitsApi::toNumber(ui->spiralRotation->value())) + .arg(Base::UnitsApi::toNumber(ui->spiralRadius->value())) .arg(placement) .arg(tr("Spiral")); } @@ -947,9 +947,9 @@ QString DlgPrimitives::createCircle(const QString& objectName, const QString& pl "App.ActiveDocument.%1.Placement=%5\n" "App.ActiveDocument.%1.Label='%6'\n") .arg(objectName) - .arg(ui->circleRadius->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->circleAngle0->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->circleAngle1->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) + .arg(Base::UnitsApi::toNumber(ui->circleRadius->value())) + .arg(Base::UnitsApi::toNumber(ui->circleAngle0->value())) + .arg(Base::UnitsApi::toNumber(ui->circleAngle1->value())) .arg(placement) .arg(tr("Circle")); } @@ -965,10 +965,10 @@ QString DlgPrimitives::createEllipse(const QString& objectName, const QString& p "App.ActiveDocument.%1.Placement=%6\n" "App.ActiveDocument.%1.Label='%7'\n") .arg(objectName) - .arg(ui->ellipseMajorRadius->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->ellipseMinorRadius->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->ellipseAngle0->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->ellipseAngle1->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) + .arg(Base::UnitsApi::toNumber(ui->ellipseMajorRadius->value())) + .arg(Base::UnitsApi::toNumber(ui->ellipseMinorRadius->value())) + .arg(Base::UnitsApi::toNumber(ui->ellipseAngle0->value())) + .arg(Base::UnitsApi::toNumber(ui->ellipseAngle1->value())) .arg(placement) .arg(tr("Ellipse")); } @@ -983,9 +983,9 @@ QString DlgPrimitives::createVertex(const QString& objectName, const QString& pl "App.ActiveDocument.%1.Placement=%5\n" "App.ActiveDocument.%1.Label='%6'\n") .arg(objectName) - .arg(ui->vertexX->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->vertexY->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->vertexZ->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) + .arg(Base::UnitsApi::toNumber(ui->vertexX->value())) + .arg(Base::UnitsApi::toNumber(ui->vertexY->value())) + .arg(Base::UnitsApi::toNumber(ui->vertexZ->value())) .arg(placement) .arg(tr("Vertex")); } @@ -1003,12 +1003,12 @@ QString DlgPrimitives::createLine(const QString& objectName, const QString& plac "App.ActiveDocument.%1.Placement=%8\n" "App.ActiveDocument.%1.Label='%9'\n") .arg(objectName) - .arg(ui->edgeX1->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->edgeY1->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->edgeZ1->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->edgeX2->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->edgeY2->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->edgeZ2->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) + .arg(Base::UnitsApi::toNumber(ui->edgeX1->value())) + .arg(Base::UnitsApi::toNumber(ui->edgeY1->value())) + .arg(Base::UnitsApi::toNumber(ui->edgeZ1->value())) + .arg(Base::UnitsApi::toNumber(ui->edgeX2->value())) + .arg(Base::UnitsApi::toNumber(ui->edgeY2->value())) + .arg(Base::UnitsApi::toNumber(ui->edgeZ2->value())) .arg(placement) .arg(tr("Line")); } @@ -1023,7 +1023,7 @@ QString DlgPrimitives::createRegularPolygon(const QString& objectName, const QSt "App.ActiveDocument.%1.Label='%5'\n") .arg(objectName) .arg(ui->regularPolygonPolygon->value()) - .arg(ui->regularPolygonCircumradius->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) + .arg(Base::UnitsApi::toNumber(ui->regularPolygonCircumradius->value())) .arg(placement) .arg(tr("Regular polygon")); } @@ -1124,8 +1124,8 @@ QString DlgPrimitives::changePlane(const QString& objectName, const QString& pla "%1.Width=%3\n" "%1.Placement=%4\n") .arg(objectName) - .arg(ui->planeLength->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->planeWidth->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) + .arg(Base::UnitsApi::toNumber(ui->planeLength->value())) + .arg(Base::UnitsApi::toNumber(ui->planeWidth->value())) .arg(placement); } @@ -1137,9 +1137,9 @@ QString DlgPrimitives::changeBox(const QString& objectName, const QString& place "%1.Height=%4\n" "%1.Placement=%5\n") .arg(objectName) - .arg(ui->boxLength->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->boxWidth->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->boxHeight->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) + .arg(Base::UnitsApi::toNumber(ui->boxLength->value())) + .arg(Base::UnitsApi::toNumber(ui->boxWidth->value())) + .arg(Base::UnitsApi::toNumber(ui->boxHeight->value())) .arg(placement); } @@ -1151,9 +1151,9 @@ QString DlgPrimitives::changeCylinder(const QString& objectName, const QString& "%1.Angle=%4\n" "%1.Placement=%5\n") .arg(objectName) - .arg(ui->cylinderRadius->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->cylinderHeight->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->cylinderAngle->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) + .arg(Base::UnitsApi::toNumber(ui->cylinderRadius->value())) + .arg(Base::UnitsApi::toNumber(ui->cylinderHeight->value())) + .arg(Base::UnitsApi::toNumber(ui->cylinderAngle->value())) .arg(placement); } @@ -1166,10 +1166,10 @@ QString DlgPrimitives::changeCone(const QString& objectName, const QString& plac "%1.Angle=%5\n" "%1.Placement=%6\n") .arg(objectName) - .arg(ui->coneRadius1->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->coneRadius2->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->coneHeight->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->coneAngle->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) + .arg(Base::UnitsApi::toNumber(ui->coneRadius1->value())) + .arg(Base::UnitsApi::toNumber(ui->coneRadius2->value())) + .arg(Base::UnitsApi::toNumber(ui->coneHeight->value())) + .arg(Base::UnitsApi::toNumber(ui->coneAngle->value())) .arg(placement); } @@ -1182,10 +1182,10 @@ QString DlgPrimitives::changeSphere(const QString& objectName, const QString& pl "%1.Angle3=%5\n" "%1.Placement=%6\n") .arg(objectName) - .arg(ui->sphereRadius->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->sphereAngle1->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->sphereAngle2->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->sphereAngle3->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) + .arg(Base::UnitsApi::toNumber(ui->sphereRadius->value())) + .arg(Base::UnitsApi::toNumber(ui->sphereAngle1->value())) + .arg(Base::UnitsApi::toNumber(ui->sphereAngle2->value())) + .arg(Base::UnitsApi::toNumber(ui->sphereAngle3->value())) .arg(placement); } @@ -1200,12 +1200,12 @@ QString DlgPrimitives::changeEllipsoid(const QString& objectName, const QString& "%1.Angle3=%7\n" "%1.Placement=%8\n") .arg(objectName) - .arg(ui->ellipsoidRadius1->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->ellipsoidRadius2->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->ellipsoidRadius3->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->ellipsoidAngle1->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->ellipsoidAngle2->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->ellipsoidAngle3->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) + .arg(Base::UnitsApi::toNumber(ui->ellipsoidRadius1->value())) + .arg(Base::UnitsApi::toNumber(ui->ellipsoidRadius2->value())) + .arg(Base::UnitsApi::toNumber(ui->ellipsoidRadius3->value())) + .arg(Base::UnitsApi::toNumber(ui->ellipsoidAngle1->value())) + .arg(Base::UnitsApi::toNumber(ui->ellipsoidAngle2->value())) + .arg(Base::UnitsApi::toNumber(ui->ellipsoidAngle3->value())) .arg(placement); } @@ -1219,11 +1219,11 @@ QString DlgPrimitives::changeTorus(const QString& objectName, const QString& pla "%1.Angle3=%6\n" "%1.Placement=%7\n") .arg(objectName) - .arg(ui->torusRadius1->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->torusRadius2->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->torusAngle1->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->torusAngle2->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->torusAngle3->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) + .arg(Base::UnitsApi::toNumber(ui->torusRadius1->value())) + .arg(Base::UnitsApi::toNumber(ui->torusRadius2->value())) + .arg(Base::UnitsApi::toNumber(ui->torusAngle1->value())) + .arg(Base::UnitsApi::toNumber(ui->torusAngle2->value())) + .arg(Base::UnitsApi::toNumber(ui->torusAngle3->value())) .arg(placement); } @@ -1238,10 +1238,10 @@ QString DlgPrimitives::changePrism(const QString& objectName, const QString& pla "%1.Placement=%7\n") .arg(objectName) .arg(ui->prismPolygon->value()) - .arg(ui->prismCircumradius->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->prismHeight->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->prismXSkew->value().getValue(), 0, 'f', Base::UnitsApi::getDecimals()) - .arg(ui->prismYSkew->value().getValue(), 0, 'f', Base::UnitsApi::getDecimals()) + .arg(Base::UnitsApi::toNumber(ui->prismCircumradius->value())) + .arg(Base::UnitsApi::toNumber(ui->prismHeight->value())) + .arg(Base::UnitsApi::toNumber(ui->prismXSkew->value())) + .arg(Base::UnitsApi::toNumber(ui->prismYSkew->value())) .arg(placement); } @@ -1260,16 +1260,16 @@ QString DlgPrimitives::changeWedge(const QString& objectName, const QString& pla "%1.Z2max=%11\n" "%1.Placement=%12\n") .arg(objectName) - .arg(ui->wedgeXmin->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->wedgeYmin->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->wedgeZmin->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->wedgeX2min->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->wedgeZ2min->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->wedgeXmax->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->wedgeYmax->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->wedgeZmax->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->wedgeX2max->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->wedgeZ2max->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) + .arg(Base::UnitsApi::toNumber(ui->wedgeXmin->value())) + .arg(Base::UnitsApi::toNumber(ui->wedgeYmin->value())) + .arg(Base::UnitsApi::toNumber(ui->wedgeZmin->value())) + .arg(Base::UnitsApi::toNumber(ui->wedgeX2min->value())) + .arg(Base::UnitsApi::toNumber(ui->wedgeZ2min->value())) + .arg(Base::UnitsApi::toNumber(ui->wedgeXmax->value())) + .arg(Base::UnitsApi::toNumber(ui->wedgeYmax->value())) + .arg(Base::UnitsApi::toNumber(ui->wedgeZmax->value())) + .arg(Base::UnitsApi::toNumber(ui->wedgeX2max->value())) + .arg(Base::UnitsApi::toNumber(ui->wedgeZ2max->value())) .arg(placement); } @@ -1283,10 +1283,10 @@ QString DlgPrimitives::changeHelix(const QString& objectName, const QString& pla "%1.LocalCoord=%6\n" "%1.Placement=%7\n") .arg(objectName) - .arg(ui->helixPitch->value().getValue(), 0, 'f', Base::UnitsApi::getDecimals()) - .arg(ui->helixHeight->value().getValue(), 0, 'f', Base::UnitsApi::getDecimals()) - .arg(ui->helixRadius->value().getValue(), 0, 'f', Base::UnitsApi::getDecimals()) - .arg(ui->helixAngle->value().getValue(), 0, 'f', Base::UnitsApi::getDecimals()) + .arg(Base::UnitsApi::toNumber(ui->helixPitch->value())) + .arg(Base::UnitsApi::toNumber(ui->helixHeight->value())) + .arg(Base::UnitsApi::toNumber(ui->helixRadius->value())) + .arg(Base::UnitsApi::toNumber(ui->helixAngle->value())) .arg(ui->helixLocalCS->currentIndex()) .arg(placement); } @@ -1299,9 +1299,9 @@ QString DlgPrimitives::changeSpiral(const QString& objectName, const QString& pl "%1.Radius=%4\n" "%1.Placement=%5\n") .arg(objectName) - .arg(ui->spiralGrowth->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->spiralRotation->value(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->spiralRadius->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) + .arg(Base::UnitsApi::toNumber(ui->spiralGrowth->value())) + .arg(Base::UnitsApi::toNumber(ui->spiralRotation->value())) + .arg(Base::UnitsApi::toNumber(ui->spiralRadius->value())) .arg(placement); } @@ -1313,9 +1313,9 @@ QString DlgPrimitives::changeCircle(const QString& objectName, const QString& pl "%1.Angle1=%4\n" "%1.Placement=%5\n") .arg(objectName) - .arg(ui->circleRadius->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->circleAngle0->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->circleAngle1->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) + .arg(Base::UnitsApi::toNumber(ui->circleRadius->value())) + .arg(Base::UnitsApi::toNumber(ui->circleAngle0->value())) + .arg(Base::UnitsApi::toNumber(ui->circleAngle1->value())) .arg(placement); } @@ -1328,10 +1328,10 @@ QString DlgPrimitives::changeEllipse(const QString& objectName, const QString& p "%1.Angle1=%5\n" "%1.Placement=%6\n") .arg(objectName) - .arg(ui->ellipseMajorRadius->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->ellipseMinorRadius->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->ellipseAngle0->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->ellipseAngle1->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) + .arg(Base::UnitsApi::toNumber(ui->ellipseMajorRadius->value())) + .arg(Base::UnitsApi::toNumber(ui->ellipseMinorRadius->value())) + .arg(Base::UnitsApi::toNumber(ui->ellipseAngle0->value())) + .arg(Base::UnitsApi::toNumber(ui->ellipseAngle1->value())) .arg(placement); } @@ -1343,9 +1343,9 @@ QString DlgPrimitives::changeVertex(const QString& objectName, const QString& pl "%1.Z=%4\n" "%1.Placement=%5\n") .arg(objectName) - .arg(ui->vertexX->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->vertexY->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->vertexZ->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) + .arg(Base::UnitsApi::toNumber(ui->vertexX->value())) + .arg(Base::UnitsApi::toNumber(ui->vertexY->value())) + .arg(Base::UnitsApi::toNumber(ui->vertexZ->value())) .arg(placement); } @@ -1360,12 +1360,12 @@ QString DlgPrimitives::changeLine(const QString& objectName, const QString& plac "%1.Z2=%7\n" "%1.Placement=%8\n") .arg(objectName) - .arg(ui->edgeX1->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->edgeY1->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->edgeZ1->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->edgeX2->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->edgeY2->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->edgeZ2->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) + .arg(Base::UnitsApi::toNumber(ui->edgeX1->value())) + .arg(Base::UnitsApi::toNumber(ui->edgeY1->value())) + .arg(Base::UnitsApi::toNumber(ui->edgeZ1->value())) + .arg(Base::UnitsApi::toNumber(ui->edgeX2->value())) + .arg(Base::UnitsApi::toNumber(ui->edgeY2->value())) + .arg(Base::UnitsApi::toNumber(ui->edgeZ2->value())) .arg(placement); } @@ -1377,7 +1377,7 @@ QString DlgPrimitives::changeRegularPolygon(const QString& objectName, const QSt "%1.Placement=%4\n") .arg(objectName) .arg(ui->regularPolygonPolygon->value()) - .arg(ui->regularPolygonCircumradius->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) + .arg(Base::UnitsApi::toNumber(ui->regularPolygonCircumradius->value())) .arg(placement); } From f0655f7c3f4e44272f931426c9b348b88b48e447 Mon Sep 17 00:00:00 2001 From: donovaly Date: Sun, 11 Apr 2021 21:39:28 +0200 Subject: [PATCH 125/178] [PD] fix primitives issues - to avoid invalid results: - don't allow to set equal radii for cones - don't allow to set equal wedge parameters - don't allow zero quantities like e.g. the box width - use full internal precision because it must be possible to create an e.g. 23.5 um wide box and using the default 2 displayed digits - take spinbox limits from App - add missing tooltips - remove disturbing commented out line from Workbench.cpp - some coding style issues fixed automatically by the MSVC IDE --- src/Mod/PartDesign/App/FeaturePrimitive.cpp | 76 ++++--- .../Gui/TaskPrimitiveParameters.cpp | 201 ++++++++++-------- .../PartDesign/Gui/TaskPrimitiveParameters.h | 2 +- .../PartDesign/Gui/TaskPrimitiveParameters.ui | 28 ++- src/Mod/PartDesign/Gui/Workbench.cpp | 1 - 5 files changed, 174 insertions(+), 134 deletions(-) diff --git a/src/Mod/PartDesign/App/FeaturePrimitive.cpp b/src/Mod/PartDesign/App/FeaturePrimitive.cpp index b97eb878dd..93ae307c80 100644 --- a/src/Mod/PartDesign/App/FeaturePrimitive.cpp +++ b/src/Mod/PartDesign/App/FeaturePrimitive.cpp @@ -56,10 +56,13 @@ using namespace PartDesign; namespace PartDesign { -const App::PropertyQuantityConstraint::Constraints torusRangeV = {-180.0,180.0,1.0}; -const App::PropertyQuantityConstraint::Constraints angleRangeU = {0.0,360.0,1.0}; -const App::PropertyQuantityConstraint::Constraints angleRangeV = {-90.0,90.0,1.0}; -const App::PropertyQuantityConstraint::Constraints quantityRange = {0.0,FLT_MAX,0.1}; +const App::PropertyQuantityConstraint::Constraints torusRangeV = { -180.0, 180.0, 1.0 }; +const App::PropertyQuantityConstraint::Constraints angleRangeU = { 0.0, 360.0, 1.0 }; +const App::PropertyQuantityConstraint::Constraints angleRangeV = { -90.0, 90.0, 1.0 }; +// it turned out that OCC cannot e.g. create a box with a width of Precision::Confusion() +// with two times Precision::Confusion() all geometric primitives can be created +const App::PropertyQuantityConstraint::Constraints quantityRange = { 2 * Precision::Confusion(), FLT_MAX, 0.1 }; +const App::PropertyQuantityConstraint::Constraints quantityRangeZero = { 0.0, FLT_MAX, 0.1 }; PROPERTY_SOURCE_WITH_EXTENSIONS(PartDesign::FeaturePrimitive, PartDesign::FeatureAddSub) @@ -77,12 +80,12 @@ App::DocumentObjectExecReturn* FeaturePrimitive::execute(const TopoDS_Shape& pri //if we have no base we just add the standard primitive shape TopoDS_Shape base; - try{ + try { //if we have a base shape we need to make sure that it does not get our transformation to BRepBuilderAPI_Transform trsf(getBaseShape(), getLocation().Transformation().Inverted(), true); base = trsf.Shape(); } - catch(const Base::Exception&) { + catch (const Base::Exception&) { //as we use this for preview we can add it even if useless for subtractive AddSubShape.setValue(primitiveShape); @@ -95,7 +98,7 @@ App::DocumentObjectExecReturn* FeaturePrimitive::execute(const TopoDS_Shape& pri return App::DocumentObject::StdReturn; } - if(getAddSubType() == FeatureAddSub::Additive) { + if (getAddSubType() == FeatureAddSub::Additive) { BRepAlgoAPI_Fuse mkFuse(base, primitiveShape); if (!mkFuse.IsDone()) @@ -115,7 +118,7 @@ App::DocumentObjectExecReturn* FeaturePrimitive::execute(const TopoDS_Shape& pri Shape.setValue(getSolid(boolOp)); AddSubShape.setValue(primitiveShape); } - else if(getAddSubType() == FeatureAddSub::Subtractive) { + else if (getAddSubType() == FeatureAddSub::Subtractive) { BRepAlgoAPI_Cut mkCut(base, primitiveShape); if (!mkCut.IsDone()) @@ -200,10 +203,8 @@ App::DocumentObjectExecReturn* Box::execute(void) if (L < Precision::Confusion()) return new App::DocumentObjectExecReturn("Length of box too small"); - if (W < Precision::Confusion()) return new App::DocumentObjectExecReturn("Width of box too small"); - if (H < Precision::Confusion()) return new App::DocumentObjectExecReturn("Height of box too small"); @@ -213,7 +214,6 @@ App::DocumentObjectExecReturn* Box::execute(void) return FeaturePrimitive::execute(mkBox.Shape()); } catch (Standard_Failure& e) { - return new App::DocumentObjectExecReturn(e.GetMessageString()); } } @@ -269,7 +269,6 @@ App::DocumentObjectExecReturn* Cylinder::execute(void) return FeaturePrimitive::execute(result); } catch (Standard_Failure& e) { - return new App::DocumentObjectExecReturn(e.GetMessageString()); } @@ -313,13 +312,12 @@ App::DocumentObjectExecReturn* Sphere::execute(void) return new App::DocumentObjectExecReturn("Radius of sphere too small"); try { BRepPrimAPI_MakeSphere mkSphere(Radius.getValue(), - Angle1.getValue()/180.0f*M_PI, - Angle2.getValue()/180.0f*M_PI, - Angle3.getValue()/180.0f*M_PI); + Base::toRadians(Angle1.getValue()), + Base::toRadians(Angle2.getValue()), + Base::toRadians(Angle3.getValue())); return FeaturePrimitive::execute(mkSphere.Shape()); } catch (Standard_Failure& e) { - return new App::DocumentObjectExecReturn(e.GetMessageString()); } @@ -350,8 +348,8 @@ Cone::Cone() ADD_PROPERTY_TYPE(Height,(10.0),"Cone",App::Prop_None,"The height of the cone"); ADD_PROPERTY_TYPE(Angle,(360.0),"Cone",App::Prop_None,"The angle of the cone"); Angle.setConstraints(&angleRangeU); - Radius1.setConstraints(&quantityRange); - Radius2.setConstraints(&quantityRange); + Radius1.setConstraints(&quantityRangeZero); + Radius2.setConstraints(&quantityRangeZero); Height.setConstraints(&quantityRange); primitiveType = FeaturePrimitive::Cone; @@ -359,10 +357,12 @@ Cone::Cone() App::DocumentObjectExecReturn* Cone::execute(void) { - if (Radius1.getValue() < 0) - return new App::DocumentObjectExecReturn("Radius of cone too small"); - if (Radius2.getValue() < 0) - return new App::DocumentObjectExecReturn("Radius of cone too small"); + if (Radius1.getValue() < 0.0) + return new App::DocumentObjectExecReturn("Radius of cone cannot be negative"); + if (Radius2.getValue() < 0.0) + return new App::DocumentObjectExecReturn("Radius of cone cannot be negative"); + if (Radius1.getValue() == Radius2.getValue()) + return new App::DocumentObjectExecReturn("The radii for cones must not be equal"); if (Height.getValue() < Precision::Confusion()) return new App::DocumentObjectExecReturn("Height of cone too small"); try { @@ -370,12 +370,11 @@ App::DocumentObjectExecReturn* Cone::execute(void) BRepPrimAPI_MakeCone mkCone(Radius1.getValue(), Radius2.getValue(), Height.getValue(), - Angle.getValue()/180.0f*M_PI); + Base::toRadians(Angle.getValue())); return FeaturePrimitive::execute(mkCone.Shape()); } catch (Standard_Failure& e) { - return new App::DocumentObjectExecReturn(e.GetMessageString()); } @@ -402,12 +401,12 @@ PROPERTY_SOURCE(PartDesign::Ellipsoid, PartDesign::FeaturePrimitive) Ellipsoid::Ellipsoid() { - ADD_PROPERTY_TYPE(Radius1,(2.0),"Ellipsoid",App::Prop_None,"The radius of the ellipsoid"); + ADD_PROPERTY_TYPE(Radius1,(2.0),"Ellipsoid",App::Prop_None,"Radius in local z-direction"); Radius1.setConstraints(&quantityRange); - ADD_PROPERTY_TYPE(Radius2,(4.0),"Ellipsoid",App::Prop_None,"The radius of the ellipsoid"); + ADD_PROPERTY_TYPE(Radius2,(4.0),"Ellipsoid",App::Prop_None,"Radius in local x-direction"); Radius2.setConstraints(&quantityRange); - ADD_PROPERTY_TYPE(Radius3,(0.0),"Ellipsoid",App::Prop_None,"The radius of the ellipsoid"); - Radius3.setConstraints(&quantityRange); + ADD_PROPERTY_TYPE(Radius3,(0.0),"Ellipsoid",App::Prop_None,"Radius in local y-direction\nIf zero, it is equal to Radius2"); + Radius3.setConstraints(&quantityRangeZero); ADD_PROPERTY_TYPE(Angle1,(-90.0f),"Ellipsoid",App::Prop_None,"The angle of the ellipsoid"); Angle1.setConstraints(&angleRangeV); ADD_PROPERTY_TYPE(Angle2,(90.0f),"Ellipsoid",App::Prop_None,"The angle of the ellipsoid"); @@ -432,9 +431,9 @@ App::DocumentObjectExecReturn* Ellipsoid::execute(void) gp_Ax2 ax2(pnt,dir); BRepPrimAPI_MakeSphere mkSphere(ax2, Radius2.getValue(), - Angle1.getValue()/180.0f*M_PI, - Angle2.getValue()/180.0f*M_PI, - Angle3.getValue()/180.0f*M_PI); + Base::toRadians(Angle1.getValue()), + Base::toRadians(Angle2.getValue()), + Base::toRadians(Angle3.getValue())); Standard_Real scaleX = 1.0; Standard_Real scaleZ = Radius1.getValue()/Radius2.getValue(); // issue #1798: A third radius has been introduced. To be backward @@ -457,7 +456,6 @@ App::DocumentObjectExecReturn* Ellipsoid::execute(void) return FeaturePrimitive::execute(mkTrsf.Shape()); } catch (Standard_Failure& e) { - return new App::DocumentObjectExecReturn(e.GetMessageString()); } @@ -490,9 +488,9 @@ PROPERTY_SOURCE(PartDesign::Torus, PartDesign::FeaturePrimitive) Torus::Torus() { - ADD_PROPERTY_TYPE(Radius1,(10.0),"Torus",App::Prop_None,"The radius of the torus"); + ADD_PROPERTY_TYPE(Radius1,(10.0),"Torus",App::Prop_None,"Radius in local xy-plane"); Radius1.setConstraints(&quantityRange); - ADD_PROPERTY_TYPE(Radius2,(2.0),"Torus",App::Prop_None,"The radius of the torus"); + ADD_PROPERTY_TYPE(Radius2,(2.0),"Torus",App::Prop_None,"Radius in local xz-plane"); Radius2.setConstraints(&quantityRange); ADD_PROPERTY_TYPE(Angle1,(-180.0),"Torus",App::Prop_None,"The angle of the torus"); Angle1.setConstraints(&torusRangeV); @@ -515,9 +513,9 @@ App::DocumentObjectExecReturn* Torus::execute(void) #if 0 BRepPrimAPI_MakeTorus mkTorus(Radius1.getValue(), Radius2.getValue(), - Angle1.getValue()/180.0f*M_PI, - Angle2.getValue()/180.0f*M_PI, - Angle3.getValue()/180.0f*M_PI); + Base::toRadians(Angle1.getValue()), + Base::toRadians(Angle2.getValue()), + Base::toRadians(Angle3.getValue())); return FeaturePrimitive::execute(mkTorus.Solid()); #else Part::TopoShape shape; @@ -639,7 +637,7 @@ Wedge::Wedge() App::DocumentObjectExecReturn* Wedge::execute(void) { - double xmin = Xmin.getValue(); + double xmin = Xmin.getValue(); double ymin = Ymin.getValue(); double zmin = Zmin.getValue(); double z2min = Z2min.getValue(); @@ -650,7 +648,6 @@ App::DocumentObjectExecReturn* Wedge::execute(void) double z2max = Z2max.getValue(); double x2max = X2max.getValue(); - double dx = xmax-xmin; double dy = ymax-ymin; double dz = zmax-zmin; @@ -683,7 +680,6 @@ App::DocumentObjectExecReturn* Wedge::execute(void) return FeaturePrimitive::execute(mkSolid.Solid()); } catch (Standard_Failure& e) { - return new App::DocumentObjectExecReturn(e.GetMessageString()); } diff --git a/src/Mod/PartDesign/Gui/TaskPrimitiveParameters.cpp b/src/Mod/PartDesign/Gui/TaskPrimitiveParameters.cpp index c8f9e40f89..9563e773cf 100644 --- a/src/Mod/PartDesign/Gui/TaskPrimitiveParameters.cpp +++ b/src/Mod/PartDesign/Gui/TaskPrimitiveParameters.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -72,12 +73,12 @@ TaskBoxPrimitives::TaskBoxPrimitives(ViewProviderPrimitive* vp, QWidget* parent) ui->boxHeight->bind(static_cast(vp->getObject())->Height); ui->boxWidth->setValue(static_cast(vp->getObject())->Width.getValue()); ui->boxWidth->bind(static_cast(vp->getObject())->Width); - ui->boxLength->setMinimum(0.0); - ui->boxLength->setMaximum(INT_MAX); - ui->boxWidth->setMinimum(0.0); - ui->boxWidth->setMaximum(INT_MAX); - ui->boxHeight->setMinimum(0.0); - ui->boxHeight->setMaximum(INT_MAX); + ui->boxLength->setMinimum(static_cast(vp->getObject())->Length.getMinimum()); + ui->boxLength->setMaximum(static_cast(vp->getObject())->Length.getMaximum()); + ui->boxWidth->setMinimum(static_cast(vp->getObject())->Width.getMinimum()); + ui->boxWidth->setMaximum(static_cast(vp->getObject())->Width.getMaximum()); + ui->boxHeight->setMinimum(static_cast(vp->getObject())->Height.getMinimum()); + ui->boxHeight->setMaximum(static_cast(vp->getObject())->Height.getMaximum()); break; case PartDesign::FeaturePrimitive::Cylinder: index = 2; @@ -93,10 +94,10 @@ TaskBoxPrimitives::TaskBoxPrimitives(ViewProviderPrimitive* vp, QWidget* parent) ui->cylinderYSkew->bind(static_cast(vp->getObject())->SecondAngle); ui->cylinderAngle->setMaximum(static_cast(vp->getObject())->Angle.getMaximum()); ui->cylinderAngle->setMinimum(static_cast(vp->getObject())->Angle.getMinimum()); - ui->cylinderHeight->setMaximum(INT_MAX); - ui->cylinderHeight->setMinimum(0.0); - ui->cylinderRadius->setMaximum(INT_MAX); - ui->cylinderRadius->setMinimum(0.0); + ui->cylinderHeight->setMaximum(static_cast(vp->getObject())->Height.getMaximum()); + ui->cylinderHeight->setMinimum(static_cast(vp->getObject())->Height.getMinimum()); + ui->cylinderRadius->setMaximum(static_cast(vp->getObject())->Radius.getMaximum()); + ui->cylinderRadius->setMinimum(static_cast(vp->getObject())->Radius.getMinimum()); break; case PartDesign::FeaturePrimitive::Sphere: index = 4; @@ -114,8 +115,8 @@ TaskBoxPrimitives::TaskBoxPrimitives(ViewProviderPrimitive* vp, QWidget* parent) ui->sphereAngle2->setMinimum(ui->sphereAngle1->rawValue()); ui->sphereAngle3->setMaximum(static_cast(vp->getObject())->Angle3.getMaximum()); ui->sphereAngle3->setMinimum(static_cast(vp->getObject())->Angle3.getMinimum()); - ui->sphereRadius->setMaximum(INT_MAX); - ui->sphereRadius->setMinimum(0.0); + ui->sphereRadius->setMaximum(static_cast(vp->getObject())->Radius.getMaximum()); + ui->sphereRadius->setMinimum(static_cast(vp->getObject())->Radius.getMinimum()); break; case PartDesign::FeaturePrimitive::Cone: index = 3; @@ -129,12 +130,12 @@ TaskBoxPrimitives::TaskBoxPrimitives(ViewProviderPrimitive* vp, QWidget* parent) ui->coneRadius2->bind(static_cast(vp->getObject())->Radius2); ui->coneAngle->setMaximum(static_cast(vp->getObject())->Angle.getMaximum()); ui->coneAngle->setMinimum(static_cast(vp->getObject())->Angle.getMinimum()); - ui->coneHeight->setMaximum(INT_MAX); - ui->coneHeight->setMinimum(0.0); - ui->coneRadius1->setMaximum(INT_MAX); - ui->coneRadius1->setMinimum(0.0); - ui->coneRadius2->setMaximum(INT_MAX); - ui->coneRadius2->setMinimum(0.0); + ui->coneHeight->setMaximum(static_cast(vp->getObject())->Height.getMaximum()); + ui->coneHeight->setMinimum(static_cast(vp->getObject())->Height.getMinimum()); + ui->coneRadius1->setMaximum(static_cast(vp->getObject())->Radius1.getMaximum()); + ui->coneRadius1->setMinimum(static_cast(vp->getObject())->Radius1.getMinimum()); + ui->coneRadius2->setMaximum(static_cast(vp->getObject())->Radius2.getMaximum()); + ui->coneRadius2->setMinimum(static_cast(vp->getObject())->Radius2.getMinimum()); break; case PartDesign::FeaturePrimitive::Ellipsoid: index = 5; @@ -156,12 +157,12 @@ TaskBoxPrimitives::TaskBoxPrimitives(ViewProviderPrimitive* vp, QWidget* parent) ui->ellipsoidAngle2->setMinimum(ui->ellipsoidAngle1->rawValue()); ui->ellipsoidAngle3->setMaximum(static_cast(vp->getObject())->Angle3.getMaximum()); ui->ellipsoidAngle3->setMinimum(static_cast(vp->getObject())->Angle3.getMinimum()); - ui->ellipsoidRadius1->setMinimum(0.0); - ui->ellipsoidRadius1->setMaximum(INT_MAX); - ui->ellipsoidRadius2->setMinimum(0.0); - ui->ellipsoidRadius2->setMaximum(INT_MAX); - ui->ellipsoidRadius3->setMinimum(0.0); - ui->ellipsoidRadius3->setMaximum(INT_MAX); + ui->ellipsoidRadius1->setMinimum(static_cast(vp->getObject())->Radius1.getMinimum()); + ui->ellipsoidRadius1->setMaximum(static_cast(vp->getObject())->Radius1.getMaximum()); + ui->ellipsoidRadius2->setMinimum(static_cast(vp->getObject())->Radius2.getMinimum()); + ui->ellipsoidRadius2->setMaximum(static_cast(vp->getObject())->Radius2.getMaximum()); + ui->ellipsoidRadius3->setMinimum(static_cast(vp->getObject())->Radius3.getMinimum()); + ui->ellipsoidRadius3->setMaximum(static_cast(vp->getObject())->Radius3.getMaximum()); break; case PartDesign::FeaturePrimitive::Torus: index = 6; @@ -184,10 +185,10 @@ TaskBoxPrimitives::TaskBoxPrimitives(ViewProviderPrimitive* vp, QWidget* parent) // this is the outer radius that must not be smaller than the inner one // otherwise the geometry is impossible and we can even get a crash: // https://forum.freecadweb.org/viewtopic.php?f=3&t=44467 - ui->torusRadius1->setMaximum(INT_MAX); + ui->torusRadius1->setMaximum(static_cast(vp->getObject())->Radius1.getMaximum()); ui->torusRadius1->setMinimum(ui->torusRadius2->rawValue()); ui->torusRadius2->setMaximum(ui->torusRadius1->rawValue()); - ui->torusRadius2->setMinimum(0.0); + ui->torusRadius2->setMinimum(static_cast(vp->getObject())->Radius2.getMinimum()); break; case PartDesign::FeaturePrimitive::Prism: index = 7; @@ -200,10 +201,10 @@ TaskBoxPrimitives::TaskBoxPrimitives(ViewProviderPrimitive* vp, QWidget* parent) ui->prismXSkew->bind(static_cast(vp->getObject())->FirstAngle); ui->prismYSkew->setValue(static_cast(vp->getObject())->SecondAngle.getValue()); ui->prismYSkew->bind(static_cast(vp->getObject())->SecondAngle); - ui->prismCircumradius->setMaximum(INT_MAX); - ui->prismCircumradius->setMinimum(0.0); - ui->prismHeight->setMaximum(INT_MAX); - ui->prismHeight->setMinimum(0.0); + ui->prismCircumradius->setMaximum(static_cast(vp->getObject())->Circumradius.getMaximum()); + ui->prismCircumradius->setMinimum(static_cast(vp->getObject())->Circumradius.getMinimum()); + ui->prismHeight->setMaximum(static_cast(vp->getObject())->Height.getMaximum()); + ui->prismHeight->setMinimum(static_cast(vp->getObject())->Height.getMinimum()); break; case PartDesign::FeaturePrimitive::Wedge: index = 8; @@ -228,11 +229,11 @@ TaskBoxPrimitives::TaskBoxPrimitives(ViewProviderPrimitive* vp, QWidget* parent) ui->wedgeZ2min->setValue(static_cast(vp->getObject())->Z2min.getValue()); ui->wedgeZ2min->bind(static_cast(vp->getObject())->Z2min); ui->wedgeXmin->setMinimum(INT_MIN); - ui->wedgeXmin->setMaximum(ui->wedgeXmax->rawValue()); // must be <= than wedgeXmax + ui->wedgeXmin->setMaximum(ui->wedgeXmax->rawValue()); // must be < than wedgeXmax ui->wedgeYmin->setMinimum(INT_MIN); - ui->wedgeYmin->setMaximum(ui->wedgeYmax->rawValue()); // must be <= than wedgeYmax + ui->wedgeYmin->setMaximum(ui->wedgeYmax->rawValue()); // must be < than wedgeYmax ui->wedgeZmin->setMinimum(INT_MIN); - ui->wedgeZmin->setMaximum(ui->wedgeZmax->rawValue()); // must be <= than wedgeZmax + ui->wedgeZmin->setMaximum(ui->wedgeZmax->rawValue()); // must be < than wedgeZmax ui->wedgeX2min->setMinimum(INT_MIN); ui->wedgeX2min->setMaximum(ui->wedgeX2max->rawValue()); // must be <= than wedgeXmax ui->wedgeZ2min->setMinimum(INT_MIN); @@ -468,12 +469,14 @@ void TaskBoxPrimitives::onConeHeightChanged(double v) { } void TaskBoxPrimitives::onConeRadius1Changed(double v) { + PartDesign::Cone* sph = static_cast(vp->getObject()); sph->Radius1.setValue(v); vp->getObject()->getDocument()->recomputeFeature(vp->getObject()); } void TaskBoxPrimitives::onConeRadius2Changed(double v) { + PartDesign::Cone* sph = static_cast(vp->getObject()); sph->Radius2.setValue(v); vp->getObject()->getDocument()->recomputeFeature(vp->getObject()); @@ -630,65 +633,65 @@ void TaskBoxPrimitives::onWedgeXminChanged(double v) { void TaskBoxPrimitives::onWedgeXmaxChanged(double v) { PartDesign::Wedge* sph = static_cast(vp->getObject()); - ui->wedgeXmin->setMaximum(v); // must be <= than wedgeXmax + ui->wedgeXmin->setMaximum(v); // must be < than wedgeXmax sph->Xmax.setValue(v); vp->getObject()->getDocument()->recomputeFeature(vp->getObject()); } void TaskBoxPrimitives::onWedgeYminChanged(double v) { PartDesign::Wedge* sph = static_cast(vp->getObject()); - ui->wedgeYmax->setMinimum(v); + ui->wedgeYmax->setMinimum(v); // must be > than wedgeYmin sph->Ymin.setValue(v); vp->getObject()->getDocument()->recomputeFeature(vp->getObject()); } void TaskBoxPrimitives::onWedgeYmaxChanged(double v) { PartDesign::Wedge* sph = static_cast(vp->getObject()); - ui->wedgeYmin->setMaximum(v); + ui->wedgeYmin->setMaximum(v); // must be < than wedgeYmax sph->Ymax.setValue(v); vp->getObject()->getDocument()->recomputeFeature(vp->getObject()); } void TaskBoxPrimitives::onWedgeZ2minChanged(double v) { PartDesign::Wedge* sph = static_cast(vp->getObject()); - ui->wedgeZ2max->setMinimum(v); + ui->wedgeZ2max->setMinimum(v); // must be >= than wedgeZ2min sph->Z2min.setValue(v); vp->getObject()->getDocument()->recomputeFeature(vp->getObject()); } void TaskBoxPrimitives::onWedgeZ2maxChanged(double v) { PartDesign::Wedge* sph = static_cast(vp->getObject()); - ui->wedgeZ2min->setMaximum(v); // must be <= than wedgeXmax + ui->wedgeZ2min->setMaximum(v); // must be <= than wedgeZ2max sph->Z2max.setValue(v); vp->getObject()->getDocument()->recomputeFeature(vp->getObject()); } void TaskBoxPrimitives::onWedgeZminChanged(double v) { PartDesign::Wedge* sph = static_cast(vp->getObject()); - ui->wedgeZmax->setMinimum(v); + ui->wedgeZmax->setMinimum(v); // must be > than wedgeZmin sph->Zmin.setValue(v); vp->getObject()->getDocument()->recomputeFeature(vp->getObject()); } void TaskBoxPrimitives::onWedgeZmaxChanged(double v) { PartDesign::Wedge* sph = static_cast(vp->getObject()); - ui->wedgeZmin->setMaximum(v); + ui->wedgeZmin->setMaximum(v); // must be < than wedgeZmax sph->Zmax.setValue(v); vp->getObject()->getDocument()->recomputeFeature(vp->getObject()); } - - -void TaskBoxPrimitives::setPrimitive(App::DocumentObject *obj) +bool TaskBoxPrimitives::setPrimitive(App::DocumentObject *obj) { try { QString name(QString::fromLatin1(Gui::Command::getObjectCmd(obj).c_str())); QString cmd; App::Document* doc = App::GetApplication().getActiveDocument(); if (!doc) { - return; + return false; } + + Base::QuantityFormat format(Base::QuantityFormat::Default, Base::UnitsApi::getDecimals()); switch(ui->widgetStack->currentIndex()) { case 1: // box cmd = QString::fromLatin1( @@ -696,9 +699,9 @@ void TaskBoxPrimitives::setPrimitive(App::DocumentObject *obj) "%1.Width=%3\n" "%1.Height=%4\n") .arg(name) - .arg(ui->boxLength->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->boxWidth->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->boxHeight->value().getValue(),0,'f',Base::UnitsApi::getDecimals()); + .arg(Base::UnitsApi::toNumber(ui->boxLength->value(), format)) + .arg(Base::UnitsApi::toNumber(ui->boxWidth->value(), format)) + .arg(Base::UnitsApi::toNumber(ui->boxHeight->value(), format)); break; case 2: // cylinder @@ -709,24 +712,30 @@ void TaskBoxPrimitives::setPrimitive(App::DocumentObject *obj) "%1.FirstAngle=%5\n" "%1.SecondAngle=%6\n") .arg(name) - .arg(ui->cylinderRadius->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->cylinderHeight->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->cylinderAngle->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->cylinderXSkew->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->cylinderYSkew->value().getValue(),0,'f',Base::UnitsApi::getDecimals()); + .arg(Base::UnitsApi::toNumber(ui->cylinderRadius->value(), format)) + .arg(Base::UnitsApi::toNumber(ui->cylinderHeight->value(), format)) + .arg(Base::UnitsApi::toNumber(ui->cylinderAngle->value(), format)) + .arg(Base::UnitsApi::toNumber(ui->cylinderXSkew->value(), format)) + .arg(Base::UnitsApi::toNumber(ui->cylinderYSkew->value(), format)); break; case 3: // cone + // the cone radii must not be equal + if (ui->coneRadius1->value().getValue() == ui->coneRadius2->value().getValue()) { + QMessageBox::warning(Gui::getMainWindow(), tr("Cone radii are equal"), + tr("The radii for cones must not be equal!")); + return false; + } cmd = QString::fromLatin1( "%1.Radius1=%2\n" "%1.Radius2=%3\n" "%1.Height=%4\n" "%1.Angle=%5\n") .arg(name) - .arg(ui->coneRadius1->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->coneRadius2->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->coneHeight->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->coneAngle->value().getValue(),0,'f',Base::UnitsApi::getDecimals()); + .arg(Base::UnitsApi::toNumber(ui->coneRadius1->value(), format)) + .arg(Base::UnitsApi::toNumber(ui->coneRadius2->value(), format)) + .arg(Base::UnitsApi::toNumber(ui->coneHeight->value(), format)) + .arg(Base::UnitsApi::toNumber(ui->coneAngle->value(), format)); break; case 4: // sphere @@ -736,10 +745,10 @@ void TaskBoxPrimitives::setPrimitive(App::DocumentObject *obj) "%1.Angle2=%4\n" "%1.Angle3=%5\n") .arg(name) - .arg(ui->sphereRadius->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->sphereAngle1->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->sphereAngle2->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->sphereAngle3->value().getValue(),0,'f',Base::UnitsApi::getDecimals()); + .arg(Base::UnitsApi::toNumber(ui->sphereRadius->value(), format)) + .arg(Base::UnitsApi::toNumber(ui->sphereAngle1->value(), format)) + .arg(Base::UnitsApi::toNumber(ui->sphereAngle2->value(), format)) + .arg(Base::UnitsApi::toNumber(ui->sphereAngle3->value(), format)); break; case 5: // ellipsoid cmd = QString::fromLatin1( @@ -750,12 +759,12 @@ void TaskBoxPrimitives::setPrimitive(App::DocumentObject *obj) "%1.Angle2=%6\n" "%1.Angle3=%7\n") .arg(name) - .arg(ui->ellipsoidRadius1->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->ellipsoidRadius2->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->ellipsoidRadius3->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->ellipsoidAngle1->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->ellipsoidAngle2->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->ellipsoidAngle3->value().getValue(),0,'f',Base::UnitsApi::getDecimals()); + .arg(Base::UnitsApi::toNumber(ui->ellipsoidRadius1->value(), format)) + .arg(Base::UnitsApi::toNumber(ui->ellipsoidRadius2->value(), format)) + .arg(Base::UnitsApi::toNumber(ui->ellipsoidRadius3->value(), format)) + .arg(Base::UnitsApi::toNumber(ui->ellipsoidAngle1->value(), format)) + .arg(Base::UnitsApi::toNumber(ui->ellipsoidAngle2->value(), format)) + .arg(Base::UnitsApi::toNumber(ui->ellipsoidAngle3->value(), format)); break; case 6: // torus @@ -766,11 +775,11 @@ void TaskBoxPrimitives::setPrimitive(App::DocumentObject *obj) "%1.Angle2=%5\n" "%1.Angle3=%6\n") .arg(name) - .arg(ui->torusRadius1->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->torusRadius2->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->torusAngle1->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->torusAngle2->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->torusAngle3->value().getValue(),0,'f',Base::UnitsApi::getDecimals()); + .arg(Base::UnitsApi::toNumber(ui->torusRadius1->value(), format)) + .arg(Base::UnitsApi::toNumber(ui->torusRadius2->value(), format)) + .arg(Base::UnitsApi::toNumber(ui->torusAngle1->value(), format)) + .arg(Base::UnitsApi::toNumber(ui->torusAngle2->value(), format)) + .arg(Base::UnitsApi::toNumber(ui->torusAngle3->value(), format)); break; case 7: // prism cmd = QString::fromLatin1( @@ -781,12 +790,28 @@ void TaskBoxPrimitives::setPrimitive(App::DocumentObject *obj) "%1.SecondAngle=%6\n") .arg(name) .arg(ui->prismPolygon->value()) - .arg(ui->prismCircumradius->value().getValue(), 0, 'f', Base::UnitsApi::getDecimals()) - .arg(ui->prismHeight->value().getValue(), 0, 'f', Base::UnitsApi::getDecimals()) - .arg(ui->prismXSkew->value().getValue(), 0, 'f', Base::UnitsApi::getDecimals()) - .arg(ui->prismYSkew->value().getValue(), 0, 'f', Base::UnitsApi::getDecimals()); + .arg(Base::UnitsApi::toNumber(ui->prismCircumradius->value(), format)) + .arg(Base::UnitsApi::toNumber(ui->prismHeight->value(), format)) + .arg(Base::UnitsApi::toNumber(ui->prismXSkew->value(), format)) + .arg(Base::UnitsApi::toNumber(ui->prismYSkew->value(), format)); break; case 8: // wedge + // Xmin/max, Ymin/max and Zmin/max must each not be equal + if (ui->wedgeXmin->value().getValue() == ui->wedgeXmax->value().getValue()) { + QMessageBox::warning(Gui::getMainWindow(), tr("Invalid wedge parameters"), + tr("X min must not be equal to X max!")); + return false; + } + else if (ui->wedgeYmin->value().getValue() == ui->wedgeYmax->value().getValue()) { + QMessageBox::warning(Gui::getMainWindow(), tr("Invalid wedge parameters"), + tr("Y min must not be equal to Y max!")); + return false; + } + else if (ui->wedgeZmin->value().getValue() == ui->wedgeZmax->value().getValue()) { + QMessageBox::warning(Gui::getMainWindow(), tr("Invalid wedge parameters"), + tr("Z min must not be equal to Z max!")); + return false; + } cmd = QString::fromLatin1( "%1.Xmin=%2\n" "%1.Ymin=%3\n" @@ -799,16 +824,16 @@ void TaskBoxPrimitives::setPrimitive(App::DocumentObject *obj) "%1.X2max=%10\n" "%1.Z2max=%11\n") .arg(name) - .arg(ui->wedgeXmin->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->wedgeYmin->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->wedgeZmin->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->wedgeX2min->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->wedgeZ2min->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->wedgeXmax->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->wedgeYmax->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->wedgeZmax->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->wedgeX2max->value().getValue(),0,'f',Base::UnitsApi::getDecimals()) - .arg(ui->wedgeZ2max->value().getValue(),0,'f',Base::UnitsApi::getDecimals()); + .arg(Base::UnitsApi::toNumber(ui->wedgeXmin->value())) + .arg(Base::UnitsApi::toNumber(ui->wedgeYmin->value(), format)) + .arg(Base::UnitsApi::toNumber(ui->wedgeZmin->value(), format)) + .arg(Base::UnitsApi::toNumber(ui->wedgeX2min->value(), format)) + .arg(Base::UnitsApi::toNumber(ui->wedgeZ2min->value(), format)) + .arg(Base::UnitsApi::toNumber(ui->wedgeXmax->value(), format)) + .arg(Base::UnitsApi::toNumber(ui->wedgeYmax->value(), format)) + .arg(Base::UnitsApi::toNumber(ui->wedgeZmax->value(), format)) + .arg(Base::UnitsApi::toNumber(ui->wedgeX2max->value(), format)) + .arg(Base::UnitsApi::toNumber(ui->wedgeZ2max->value(), format)); break; default: @@ -823,7 +848,9 @@ void TaskBoxPrimitives::setPrimitive(App::DocumentObject *obj) } catch (const Base::PyException& e) { QMessageBox::warning(this, tr("Create primitive"), QString::fromLatin1(e.what())); + return false; } + return true; } TaskPrimitiveParameters::TaskPrimitiveParameters(ViewProviderPrimitive* PrimitiveView) : vp_prm(PrimitiveView) @@ -881,7 +908,9 @@ TaskPrimitiveParameters::~TaskPrimitiveParameters() bool TaskPrimitiveParameters::accept() { - primitive->setPrimitive(vp_prm->getObject()); + bool primitiveOK = primitive->setPrimitive(vp_prm->getObject()); + if (!primitiveOK) + return primitiveOK; Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()"); Gui::Command::doCommand(Gui::Command::Gui,"Gui.activeDocument().resetEdit()"); diff --git a/src/Mod/PartDesign/Gui/TaskPrimitiveParameters.h b/src/Mod/PartDesign/Gui/TaskPrimitiveParameters.h index 11c079fc2f..b6f49a0e86 100644 --- a/src/Mod/PartDesign/Gui/TaskPrimitiveParameters.h +++ b/src/Mod/PartDesign/Gui/TaskPrimitiveParameters.h @@ -55,7 +55,7 @@ public: TaskBoxPrimitives(ViewProviderPrimitive* vp, QWidget* parent = 0); ~TaskBoxPrimitives(); - void setPrimitive(App::DocumentObject *); + bool setPrimitive(App::DocumentObject *); public Q_SLOTS: void onBoxLengthChanged(double); diff --git a/src/Mod/PartDesign/Gui/TaskPrimitiveParameters.ui b/src/Mod/PartDesign/Gui/TaskPrimitiveParameters.ui index 77f0b7b46d..70e89795fb 100644 --- a/src/Mod/PartDesign/Gui/TaskPrimitiveParameters.ui +++ b/src/Mod/PartDesign/Gui/TaskPrimitiveParameters.ui @@ -225,7 +225,7 @@
    - + @@ -755,7 +755,7 @@ - + @@ -800,6 +800,9 @@ + + Radius in local z-direction + false @@ -820,6 +823,9 @@ + + Radius in local x-direction + false @@ -840,6 +846,10 @@ + + Radius in local y-direction +If zero, it is equal to Radius2 + false @@ -964,7 +974,7 @@ - + @@ -1009,6 +1019,9 @@ + + Radius in local xy-plane + false @@ -1029,6 +1042,9 @@ + + Radius in local xz-plane + false @@ -1156,7 +1172,7 @@ - + @@ -1651,7 +1667,7 @@ - + @@ -1762,7 +1778,7 @@ - + diff --git a/src/Mod/PartDesign/Gui/Workbench.cpp b/src/Mod/PartDesign/Gui/Workbench.cpp index 73b7576c16..b07911a55e 100644 --- a/src/Mod/PartDesign/Gui/Workbench.cpp +++ b/src/Mod/PartDesign/Gui/Workbench.cpp @@ -540,7 +540,6 @@ Gui::MenuItem* Workbench::setupMenuBar() const << "Separator" << "PartDesign_Boolean" << "Separator" - //<< "PartDesign_Hole" << "PartDesign_Migrate" << "PartDesign_Sprocket" << "PartDesign_InvoluteGear"; From a5768a2f169e7d56e3daa63d504de69b71da3a97 Mon Sep 17 00:00:00 2001 From: sliptonic Date: Tue, 20 Apr 2021 18:32:09 -0500 Subject: [PATCH 126/178] adjust tool position during inspect --- src/Mod/Path/PathScripts/PathInspect.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/Mod/Path/PathScripts/PathInspect.py b/src/Mod/Path/PathScripts/PathInspect.py index 615b01b50b..f22fbe8f0d 100644 --- a/src/Mod/Path/PathScripts/PathInspect.py +++ b/src/Mod/Path/PathScripts/PathInspect.py @@ -89,9 +89,15 @@ class GCodeHighlighter(QtGui.QSyntaxHighlighter): class GCodeEditorDialog(QtGui.QDialog): + tool = None def __init__(self, PathObj, parent=FreeCADGui.getMainWindow()): - self.PathObj = PathObj + self.PathObj = PathObj.Path + if hasattr(PathObj, 'ToolController'): + self.tool = PathObj.ToolController.Tool + else: + self.tool = None + QtGui.QDialog.__init__(self, parent) layout = QtGui.QVBoxLayout(self) @@ -189,6 +195,11 @@ class GCodeEditorDialog(QtGui.QDialog): p.Commands = selectionpath self.selectionobj.Path = p + if self.tool is not None: + self.tool.Placement.Base.x = prevX + self.tool.Placement.Base.y = prevY + self.tool.Placement.Base.z = prevZ + def show(obj): "show(obj): shows the G-code data of the given Path object in a dialog" @@ -200,7 +211,7 @@ def show(obj): if hasattr(obj, "Path"): if obj.Path: - dia = GCodeEditorDialog(obj.Path) + dia = GCodeEditorDialog(obj) dia.editor.setText(obj.Path.toGCode()) gcodeSize = len(dia.editor.toPlainText()) if (gcodeSize <= mhs): From 87e6dddd379181f0d292b4a640b89a62ebb676b5 Mon Sep 17 00:00:00 2001 From: Ondrej Flidr Date: Wed, 21 Apr 2021 13:37:10 +0200 Subject: [PATCH 127/178] fix path lenght for ecryptfs --- src/Mod/AddonManager/addonmanager_workers.py | 22 ++++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/Mod/AddonManager/addonmanager_workers.py b/src/Mod/AddonManager/addonmanager_workers.py index f1fe3bcee4..37c3db0b67 100644 --- a/src/Mod/AddonManager/addonmanager_workers.py +++ b/src/Mod/AddonManager/addonmanager_workers.py @@ -600,8 +600,8 @@ class ShowWorker(QtCore.QThread): name = path.split("/")[-1] if name and path.startswith("http"): storename = os.path.join(store, name) - if len(storename) >= 260: - remainChars = 259 - (len(store) + len(wbName) + 1) + if len(storename) >= fscharlimit: + remainChars = (fscharlimit - 1) - (len(store) + len(wbName) + 1) storename = os.path.join(store, wbName+name[-remainChars:]) if not os.path.exists(storename): try: @@ -611,13 +611,17 @@ class ShowWorker(QtCore.QThread): except Exception: print("AddonManager: Debug: Error retrieving image from", path) else: - f = open(storename, "wb") - f.write(imagedata) - f.close() - - # resize the image to 300x300px if needed - img = QtGui.QImage(storename) - if (img.width() > 300) or (img.height() > 300): + try: + f = open(storename, "wb") + except OSError: + # ecryptfs (and probably not only ecryptfs) has lower length limit for path + storename = storename[-140:] + f = open(storename, "wb") + f.write(imagedata) + f.close() + # resize the image to 300x300px if needed + img = QtGui.QImage(storename) + if (img.width() > 300) or (img.height() > 300): pix = QtGui.QPixmap() pix = pix.fromImage(img.scaled(300, 300, QtCore.Qt.KeepAspectRatio, From b457dc40627aa308fe6d922400bea7d5f3e68f74 Mon Sep 17 00:00:00 2001 From: Ondrej Flidr Date: Wed, 21 Apr 2021 13:38:51 +0200 Subject: [PATCH 128/178] revert dynamic char limit --- src/Mod/AddonManager/addonmanager_workers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Mod/AddonManager/addonmanager_workers.py b/src/Mod/AddonManager/addonmanager_workers.py index 37c3db0b67..62484b94c7 100644 --- a/src/Mod/AddonManager/addonmanager_workers.py +++ b/src/Mod/AddonManager/addonmanager_workers.py @@ -600,8 +600,8 @@ class ShowWorker(QtCore.QThread): name = path.split("/")[-1] if name and path.startswith("http"): storename = os.path.join(store, name) - if len(storename) >= fscharlimit: - remainChars = (fscharlimit - 1) - (len(store) + len(wbName) + 1) + if len(storename) >= 260: + remainChars = 259 - (len(store) + len(wbName) + 1) storename = os.path.join(store, wbName+name[-remainChars:]) if not os.path.exists(storename): try: From ef60a73cb52b151d5a1ec053973b3b3faca90f65 Mon Sep 17 00:00:00 2001 From: Chris Hennes Date: Tue, 20 Apr 2021 15:35:43 -0500 Subject: [PATCH 129/178] [OpenSCAD] Fix regression with angle specification Correct mistake introduced in 0e66abcab. --- src/Mod/OpenSCAD/OpenSCADFeatures.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Mod/OpenSCAD/OpenSCADFeatures.py b/src/Mod/OpenSCAD/OpenSCADFeatures.py index b3cd2d0a24..93332b67a2 100644 --- a/src/Mod/OpenSCAD/OpenSCADFeatures.py +++ b/src/Mod/OpenSCAD/OpenSCADFeatures.py @@ -388,10 +388,11 @@ class Frustum: class Twist: def __init__(self, obj,child=None,h=1.0,angle=0.0,scale=[1.0,1.0]): + import FreeCAD obj.addProperty("App::PropertyLink","Base","Base", "The base object that must be transformed") obj.addProperty("App::PropertyQuantity","Angle","Base","Twist Angle") - obj.Angle = App.Units.Angle # assign the Angle unit + obj.Angle = FreeCAD.Units.Angle # assign the Angle unit obj.addProperty("App::PropertyDistance","Height","Base","Height of the Extrusion") obj.addProperty("App::PropertyFloatList","Scale","Base","Scale to apply during the Extrusion") From 5ee0a355dd2318249e187881009ec8aca58fed34 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 21 Apr 2021 14:50:45 +0200 Subject: [PATCH 130/178] Mesh: [skip ci] fixes #0004430: Mesh_BuildRegularSolid: parametric mesh props have no units in Property editor --- src/Mod/Mesh/App/FeatureMeshSolid.cpp | 81 ++++++++++++++++++++++++++- src/Mod/Mesh/App/FeatureMeshSolid.h | 38 +++++++------ 2 files changed, 101 insertions(+), 18 deletions(-) diff --git a/src/Mod/Mesh/App/FeatureMeshSolid.cpp b/src/Mod/Mesh/App/FeatureMeshSolid.cpp index 3d320c3992..d44549f127 100644 --- a/src/Mod/Mesh/App/FeatureMeshSolid.cpp +++ b/src/Mod/Mesh/App/FeatureMeshSolid.cpp @@ -35,8 +35,8 @@ namespace Mesh { - const App::PropertyIntegerConstraint::Constraints intSampling = {0,1000,1}; - const App::PropertyFloatConstraint::Constraints floatRange = {0.0,1000.0,1.0}; + const App::PropertyIntegerConstraint::Constraints intSampling = {0,INT_MAX,1}; + const App::PropertyLength::Constraints floatRange = {0.0,FLT_MAX,1.0}; } using namespace Mesh; @@ -72,6 +72,18 @@ App::DocumentObjectExecReturn *Sphere::execute(void) } } +void Sphere::handleChangedPropertyType(Base::XMLReader &reader, const char *TypeName, App::Property *prop) +{ + if (prop == &Radius && strcmp(TypeName, "App::PropertyFloatConstraint") == 0) { + App::PropertyFloatConstraint r; + r.Restore(reader); + Radius.setValue(r.getValue()); + } + else { + Mesh::Feature::handleChangedPropertyType(reader, TypeName, prop); + } +} + // ------------------------------------------------------------- PROPERTY_SOURCE(Mesh::Ellipsoid, Mesh::Feature) @@ -108,6 +120,19 @@ App::DocumentObjectExecReturn *Ellipsoid::execute(void) } } +void Ellipsoid::handleChangedPropertyType(Base::XMLReader &reader, const char *TypeName, App::Property *prop) +{ + if ((prop == &Radius1 || prop == &Radius2) && + strcmp(TypeName, "App::PropertyFloatConstraint") == 0) { + App::PropertyFloatConstraint r; + r.Restore(reader); + static_cast(prop)->setValue(r.getValue()); + } + else { + Mesh::Feature::handleChangedPropertyType(reader, TypeName, prop); + } +} + // ------------------------------------------------------------- PROPERTY_SOURCE(Mesh::Cylinder, Mesh::Feature) @@ -150,6 +175,19 @@ App::DocumentObjectExecReturn *Cylinder::execute(void) } } +void Cylinder::handleChangedPropertyType(Base::XMLReader &reader, const char *TypeName, App::Property *prop) +{ + if ((prop == &Radius || prop == &Length || prop == &EdgeLength) && + strcmp(TypeName, "App::PropertyFloatConstraint") == 0) { + App::PropertyFloatConstraint r; + r.Restore(reader); + static_cast(prop)->setValue(r.getValue()); + } + else { + Mesh::Feature::handleChangedPropertyType(reader, TypeName, prop); + } +} + // ------------------------------------------------------------- PROPERTY_SOURCE(Mesh::Cone, Mesh::Feature) @@ -195,6 +233,19 @@ App::DocumentObjectExecReturn *Cone::execute(void) } } +void Cone::handleChangedPropertyType(Base::XMLReader &reader, const char *TypeName, App::Property *prop) +{ + if ((prop == &Radius1 || prop == &Radius2 || prop == &Length || prop == &EdgeLength) && + strcmp(TypeName, "App::PropertyFloatConstraint") == 0) { + App::PropertyFloatConstraint r; + r.Restore(reader); + static_cast(prop)->setValue(r.getValue()); + } + else { + Mesh::Feature::handleChangedPropertyType(reader, TypeName, prop); + } +} + // ------------------------------------------------------------- PROPERTY_SOURCE(Mesh::Torus, Mesh::Feature) @@ -231,6 +282,19 @@ App::DocumentObjectExecReturn *Torus::execute(void) } } +void Torus::handleChangedPropertyType(Base::XMLReader &reader, const char *TypeName, App::Property *prop) +{ + if ((prop == &Radius1 || prop == &Radius2) && + strcmp(TypeName, "App::PropertyFloatConstraint") == 0) { + App::PropertyFloatConstraint r; + r.Restore(reader); + static_cast(prop)->setValue(r.getValue()); + } + else { + Mesh::Feature::handleChangedPropertyType(reader, TypeName, prop); + } +} + // ------------------------------------------------------------- PROPERTY_SOURCE(Mesh::Cube, Mesh::Feature) @@ -266,3 +330,16 @@ App::DocumentObjectExecReturn *Cube::execute(void) return new App::DocumentObjectExecReturn("Cannot create cube", this); } } + +void Cube::handleChangedPropertyType(Base::XMLReader &reader, const char *TypeName, App::Property *prop) +{ + if ((prop == &Length || prop == &Width || prop == &Height) && + strcmp(TypeName, "App::PropertyFloatConstraint") == 0) { + App::PropertyFloatConstraint r; + r.Restore(reader); + static_cast(prop)->setValue(r.getValue()); + } + else { + Mesh::Feature::handleChangedPropertyType(reader, TypeName, prop); + } +} diff --git a/src/Mod/Mesh/App/FeatureMeshSolid.h b/src/Mod/Mesh/App/FeatureMeshSolid.h index 1eb3ad5024..60bea888c9 100644 --- a/src/Mod/Mesh/App/FeatureMeshSolid.h +++ b/src/Mod/Mesh/App/FeatureMeshSolid.h @@ -26,7 +26,7 @@ #include "MeshFeature.h" -#include +#include #include namespace Mesh @@ -42,7 +42,7 @@ class Sphere : public Mesh::Feature public: Sphere(); - App::PropertyFloatConstraint Radius; + App::PropertyLength Radius; App::PropertyIntegerConstraint Sampling; /** @name methods override Feature */ @@ -50,6 +50,7 @@ public: /// recalculate the Feature App::DocumentObjectExecReturn *execute(void); short mustExecute() const; + void handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, App::Property * prop); //@} }; @@ -62,8 +63,8 @@ class Ellipsoid : public Mesh::Feature public: Ellipsoid(); - App::PropertyFloatConstraint Radius1; - App::PropertyFloatConstraint Radius2; + App::PropertyLength Radius1; + App::PropertyLength Radius2; App::PropertyIntegerConstraint Sampling; /** @name methods override Feature */ @@ -71,6 +72,7 @@ public: /// recalculate the Feature App::DocumentObjectExecReturn *execute(void); short mustExecute() const; + void handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, App::Property * prop); //@} }; @@ -83,9 +85,9 @@ class Cylinder : public Mesh::Feature public: Cylinder(); - App::PropertyFloatConstraint Radius; - App::PropertyFloatConstraint Length; - App::PropertyFloatConstraint EdgeLength; + App::PropertyLength Radius; + App::PropertyLength Length; + App::PropertyLength EdgeLength; App::PropertyBool Closed; App::PropertyIntegerConstraint Sampling; @@ -94,6 +96,7 @@ public: /// recalculate the Feature App::DocumentObjectExecReturn *execute(void); short mustExecute() const; + void handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, App::Property * prop); //@} }; @@ -106,10 +109,10 @@ class Cone : public Mesh::Feature public: Cone(); - App::PropertyFloatConstraint Radius1; - App::PropertyFloatConstraint Radius2; - App::PropertyFloatConstraint Length; - App::PropertyFloatConstraint EdgeLength; + App::PropertyLength Radius1; + App::PropertyLength Radius2; + App::PropertyLength Length; + App::PropertyLength EdgeLength; App::PropertyBool Closed; App::PropertyIntegerConstraint Sampling; @@ -118,6 +121,7 @@ public: /// recalculate the Feature App::DocumentObjectExecReturn *execute(void); short mustExecute() const; + void handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, App::Property * prop); //@} }; @@ -130,8 +134,8 @@ class Torus : public Mesh::Feature public: Torus(); - App::PropertyFloatConstraint Radius1; - App::PropertyFloatConstraint Radius2; + App::PropertyLength Radius1; + App::PropertyLength Radius2; App::PropertyIntegerConstraint Sampling; /** @name methods override Feature */ @@ -139,6 +143,7 @@ public: /// recalculate the Feature App::DocumentObjectExecReturn *execute(void); short mustExecute() const; + void handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, App::Property * prop); //@} }; @@ -151,15 +156,16 @@ class Cube : public Mesh::Feature public: Cube(); - App::PropertyFloatConstraint Length; - App::PropertyFloatConstraint Width; - App::PropertyFloatConstraint Height; + App::PropertyLength Length; + App::PropertyLength Width; + App::PropertyLength Height; /** @name methods override Feature */ //@{ /// recalculate the Feature App::DocumentObjectExecReturn *execute(void); short mustExecute() const; + void handleChangedPropertyType(Base::XMLReader &reader, const char * TypeName, App::Property * prop); //@} }; From 7d0f808b9c358cb1695db1a2368ef711938d8d7b Mon Sep 17 00:00:00 2001 From: Ondrej Flidr Date: Wed, 21 Apr 2021 15:31:40 +0200 Subject: [PATCH 131/178] tabs to spaces --- src/Mod/AddonManager/addonmanager_workers.py | 22 ++++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Mod/AddonManager/addonmanager_workers.py b/src/Mod/AddonManager/addonmanager_workers.py index 62484b94c7..25ff53f6e0 100644 --- a/src/Mod/AddonManager/addonmanager_workers.py +++ b/src/Mod/AddonManager/addonmanager_workers.py @@ -611,17 +611,17 @@ class ShowWorker(QtCore.QThread): except Exception: print("AddonManager: Debug: Error retrieving image from", path) else: - try: - f = open(storename, "wb") - except OSError: - # ecryptfs (and probably not only ecryptfs) has lower length limit for path - storename = storename[-140:] - f = open(storename, "wb") - f.write(imagedata) - f.close() - # resize the image to 300x300px if needed - img = QtGui.QImage(storename) - if (img.width() > 300) or (img.height() > 300): + try: + f = open(storename, "wb") + except OSError: + # ecryptfs (and probably not only ecryptfs) has lower length limit for path + storename = storename[-140:] + f = open(storename, "wb") + f.write(imagedata) + f.close() + # resize the image to 300x300px if needed + img = QtGui.QImage(storename) + if (img.width() > 300) or (img.height() > 300): pix = QtGui.QPixmap() pix = pix.fromImage(img.scaled(300, 300, QtCore.Qt.KeepAspectRatio, From e3df634a20b15becb563356c73f091a4bc191023 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Stelmach?= Date: Wed, 21 Apr 2021 16:54:21 +0200 Subject: [PATCH 132/178] Arch: Fix material color pickers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Provide currently set color as initial value for getColor() to enable convenient incremental changes. Do not change the colour if the Cancel buton was pressed. Signed-off-by: Åukasz Stelmach --- src/Mod/Arch/ArchMaterial.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/src/Mod/Arch/ArchMaterial.py b/src/Mod/Arch/ArchMaterial.py index 1d9f536d4f..f258a781d5 100644 --- a/src/Mod/Arch/ArchMaterial.py +++ b/src/Mod/Arch/ArchMaterial.py @@ -645,18 +645,20 @@ class _ArchMaterialTaskPanel: self.material["Father"] = text def getColor(self): - "opens a color picker dialog" - color = QtGui.QColorDialog.getColor() - colorPix = QtGui.QPixmap(16,16) - colorPix.fill(color) - self.form.ButtonColor.setIcon(QtGui.QIcon(colorPix)) + self.getColorForButton(self.form.ButtonColor) def getSectionColor(self): + self.getColorForButton(self.form.ButtonSectionColor) + + def getColorForButton(self,button): "opens a color picker dialog" - color = QtGui.QColorDialog.getColor() - colorPix = QtGui.QPixmap(16,16) - colorPix.fill(color) - self.form.ButtonSectionColor.setIcon(QtGui.QIcon(colorPix)) + icon = button.icon() + pixel = icon.pixmap(16,16).toImage().pixel(0,0) + color = QtGui.QColorDialog.getColor(QtGui.QColor(pixel)) + if color.isValid(): + colorPix = QtGui.QPixmap(16,16) + colorPix.fill(color) + button.setIcon(QtGui.QIcon(colorPix)) def fillMaterialCombo(self): "fills the combo with the existing FCMat cards" From f66bc8fc90e8ea75d0509045c6e03f87788e7e23 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 21 Apr 2021 19:33:40 +0200 Subject: [PATCH 133/178] Gui: use public methods in Command sub-classes --- src/Gui/CommandDoc.cpp | 12 ++++----- src/Gui/CommandLink.cpp | 6 ++--- src/Gui/CommandStd.cpp | 24 ++++++++--------- src/Gui/CommandView.cpp | 26 +++++++++---------- src/Gui/CommandWindow.cpp | 8 +++--- src/Gui/NetworkRetriever.cpp | 22 ++++++++-------- src/Mod/Sketcher/Gui/CommandConstraints.cpp | 4 +-- src/Mod/Sketcher/Gui/CommandSketcherTools.cpp | 6 ++--- 8 files changed, 54 insertions(+), 54 deletions(-) diff --git a/src/Gui/CommandDoc.cpp b/src/Gui/CommandDoc.cpp index 155865b179..61977bc9b5 100644 --- a/src/Gui/CommandDoc.cpp +++ b/src/Gui/CommandDoc.cpp @@ -1017,10 +1017,10 @@ Action * StdCmdUndo::createAction(void) Action *pcAction; pcAction = new UndoAction(this,getMainWindow()); - pcAction->setShortcut(QString::fromLatin1(sAccel)); + pcAction->setShortcut(QString::fromLatin1(getAccel())); applyCommandData(this->className(), pcAction); - if (sPixmap) - pcAction->setIcon(Gui::BitmapFactory().iconFromTheme(sPixmap)); + if (getPixmap()) + pcAction->setIcon(Gui::BitmapFactory().iconFromTheme(getPixmap())); return pcAction; } @@ -1061,10 +1061,10 @@ Action * StdCmdRedo::createAction(void) Action *pcAction; pcAction = new RedoAction(this,getMainWindow()); - pcAction->setShortcut(QString::fromLatin1(sAccel)); + pcAction->setShortcut(QString::fromLatin1(getAccel())); applyCommandData(this->className(), pcAction); - if (sPixmap) - pcAction->setIcon(Gui::BitmapFactory().iconFromTheme(sPixmap)); + if (getPixmap()) + pcAction->setIcon(Gui::BitmapFactory().iconFromTheme(getPixmap())); return pcAction; } diff --git a/src/Gui/CommandLink.cpp b/src/Gui/CommandLink.cpp index 5063588389..cbbbd6f1fb 100644 --- a/src/Gui/CommandLink.cpp +++ b/src/Gui/CommandLink.cpp @@ -98,11 +98,11 @@ Action * StdCmdLinkMakeGroup::createAction(void) // add the action items QAction* action = nullptr; action = pcAction->addAction(QObject::tr("Simple group")); - action->setWhatsThis(QString::fromLatin1(sWhatsThis)); + action->setWhatsThis(QString::fromLatin1(getWhatsThis())); action = pcAction->addAction(QObject::tr("Group with links")); - action->setWhatsThis(QString::fromLatin1(sWhatsThis)); + action->setWhatsThis(QString::fromLatin1(getWhatsThis())); action = pcAction->addAction(QObject::tr("Group with transform links")); - action->setWhatsThis(QString::fromLatin1(sWhatsThis)); + action->setWhatsThis(QString::fromLatin1(getWhatsThis())); return pcAction; } diff --git a/src/Gui/CommandStd.cpp b/src/Gui/CommandStd.cpp index 1259b5a3b3..e62df2d7e8 100644 --- a/src/Gui/CommandStd.cpp +++ b/src/Gui/CommandStd.cpp @@ -122,10 +122,10 @@ Action * StdCmdWorkbench::createAction(void) Action *pcAction; pcAction = new WorkbenchGroup(this,getMainWindow()); - pcAction->setShortcut(QString::fromLatin1(sAccel)); + pcAction->setShortcut(QString::fromLatin1(getAccel())); applyCommandData(this->className(), pcAction); - if (sPixmap) - pcAction->setIcon(Gui::BitmapFactory().iconFromTheme(sPixmap)); + if (getPixmap()) + pcAction->setIcon(Gui::BitmapFactory().iconFromTheme(getPixmap())); return pcAction; } @@ -235,14 +235,14 @@ Action * StdCmdAbout::createAction(void) QString exe = qApp->applicationName(); pcAction = new Action(this,getMainWindow()); pcAction->setText(QCoreApplication::translate( - this->className(), sMenuText).arg(exe)); + this->className(), getMenuText()).arg(exe)); pcAction->setToolTip(QCoreApplication::translate( - this->className(), sToolTipText).arg(exe)); + this->className(), getToolTipText()).arg(exe)); pcAction->setStatusTip(QCoreApplication::translate( - this->className(), sStatusTip).arg(exe)); - pcAction->setWhatsThis(QLatin1String(sWhatsThis)); + this->className(), getStatusTip()).arg(exe)); + pcAction->setWhatsThis(QLatin1String(getWhatsThis())); pcAction->setIcon(QApplication::windowIcon()); - pcAction->setShortcut(QString::fromLatin1(sAccel)); + pcAction->setShortcut(QString::fromLatin1(getAccel())); // Needs to have AboutRole set to avoid duplicates if adding the about action more than once on macOS pcAction->setMenuRole(QAction::AboutRole); return pcAction; @@ -269,12 +269,12 @@ void StdCmdAbout::languageChange() if (_pcAction) { QString exe = qApp->applicationName(); _pcAction->setText(QCoreApplication::translate( - this->className(), sMenuText).arg(exe)); + this->className(), getMenuText()).arg(exe)); _pcAction->setToolTip(QCoreApplication::translate( - this->className(), sToolTipText).arg(exe)); + this->className(), getToolTipText()).arg(exe)); _pcAction->setStatusTip(QCoreApplication::translate( - this->className(), sStatusTip).arg(exe)); - _pcAction->setWhatsThis(QLatin1String(sWhatsThis)); + this->className(), getStatusTip()).arg(exe)); + _pcAction->setWhatsThis(QLatin1String(getWhatsThis())); } } diff --git a/src/Gui/CommandView.cpp b/src/Gui/CommandView.cpp index 2300c1e7b6..63c68f9ffe 100644 --- a/src/Gui/CommandView.cpp +++ b/src/Gui/CommandView.cpp @@ -315,15 +315,15 @@ Action * StdCmdFreezeViews::createAction(void) // add the action items saveView = pcAction->addAction(QObject::tr("Save views...")); - saveView->setWhatsThis(QString::fromLatin1(sWhatsThis)); + saveView->setWhatsThis(QString::fromLatin1(getWhatsThis())); QAction* loadView = pcAction->addAction(QObject::tr("Load views...")); - loadView->setWhatsThis(QString::fromLatin1(sWhatsThis)); + loadView->setWhatsThis(QString::fromLatin1(getWhatsThis())); pcAction->addAction(QString::fromLatin1(""))->setSeparator(true); freezeView = pcAction->addAction(QObject::tr("Freeze view")); - freezeView->setShortcut(QString::fromLatin1(sAccel)); - freezeView->setWhatsThis(QString::fromLatin1(sWhatsThis)); + freezeView->setShortcut(QString::fromLatin1(getAccel())); + freezeView->setWhatsThis(QString::fromLatin1(getWhatsThis())); clearView = pcAction->addAction(QObject::tr("Clear views")); - clearView->setWhatsThis(QString::fromLatin1(sWhatsThis)); + clearView->setWhatsThis(QString::fromLatin1(getWhatsThis())); separator = pcAction->addAction(QString::fromLatin1("")); separator->setSeparator(true); offset = pcAction->actions().count(); @@ -663,43 +663,43 @@ Gui::Action * StdCmdDrawStyle::createAction(void) a0->setChecked(true); a0->setObjectName(QString::fromLatin1("Std_DrawStyleAsIs")); a0->setShortcut(QKeySequence(QString::fromUtf8("V,1"))); - a0->setWhatsThis(QString::fromLatin1(sWhatsThis)); + a0->setWhatsThis(QString::fromLatin1(getWhatsThis())); QAction* a1 = pcAction->addAction(QString()); a1->setCheckable(true); a1->setIcon(BitmapFactory().iconFromTheme("DrawStylePoints")); a1->setObjectName(QString::fromLatin1("Std_DrawStylePoints")); a1->setShortcut(QKeySequence(QString::fromUtf8("V,2"))); - a1->setWhatsThis(QString::fromLatin1(sWhatsThis)); + a1->setWhatsThis(QString::fromLatin1(getWhatsThis())); QAction* a2 = pcAction->addAction(QString()); a2->setCheckable(true); a2->setIcon(BitmapFactory().iconFromTheme("DrawStyleWireFrame")); a2->setObjectName(QString::fromLatin1("Std_DrawStyleWireframe")); a2->setShortcut(QKeySequence(QString::fromUtf8("V,3"))); - a2->setWhatsThis(QString::fromLatin1(sWhatsThis)); + a2->setWhatsThis(QString::fromLatin1(getWhatsThis())); QAction* a3 = pcAction->addAction(QString()); a3->setCheckable(true); a3->setIcon(BitmapFactory().iconFromTheme("DrawStyleHiddenLine")); a3->setObjectName(QString::fromLatin1("Std_DrawStyleHiddenLine")); a3->setShortcut(QKeySequence(QString::fromUtf8("V,4"))); - a3->setWhatsThis(QString::fromLatin1(sWhatsThis)); + a3->setWhatsThis(QString::fromLatin1(getWhatsThis())); QAction* a4 = pcAction->addAction(QString()); a4->setCheckable(true); a4->setIcon(BitmapFactory().iconFromTheme("DrawStyleNoShading")); a4->setObjectName(QString::fromLatin1("Std_DrawStyleNoShading")); a4->setShortcut(QKeySequence(QString::fromUtf8("V,5"))); - a4->setWhatsThis(QString::fromLatin1(sWhatsThis)); + a4->setWhatsThis(QString::fromLatin1(getWhatsThis())); QAction* a5 = pcAction->addAction(QString()); a5->setCheckable(true); a5->setIcon(BitmapFactory().iconFromTheme("DrawStyleShaded")); a5->setObjectName(QString::fromLatin1("Std_DrawStyleShaded")); a5->setShortcut(QKeySequence(QString::fromUtf8("V,6"))); - a5->setWhatsThis(QString::fromLatin1(sWhatsThis)); + a5->setWhatsThis(QString::fromLatin1(getWhatsThis())); QAction* a6 = pcAction->addAction(QString()); a6->setCheckable(true); a6->setIcon(BitmapFactory().iconFromTheme("DrawStyleFlatLines")); a6->setObjectName(QString::fromLatin1("Std_DrawStyleFlatLines")); a6->setShortcut(QKeySequence(QString::fromUtf8("V,7"))); - a6->setWhatsThis(QString::fromLatin1(sWhatsThis)); + a6->setWhatsThis(QString::fromLatin1(getWhatsThis())); pcAction->setIcon(a0->icon()); @@ -1683,7 +1683,7 @@ Action * StdViewDockUndockFullscreen::createAction(void) ActionGroup* pcAction = new ActionGroup(this, getMainWindow()); pcAction->setDropDownMenu(true); pcAction->setText(QCoreApplication::translate( - this->className(), sMenuText)); + this->className(), getMenuText())); CommandManager &rcCmdMgr = Application::Instance->commandManager(); Command* cmdD = rcCmdMgr.getCommandByName("Std_ViewDock"); diff --git a/src/Gui/CommandWindow.cpp b/src/Gui/CommandWindow.cpp index b87997ec93..6527d95a4f 100644 --- a/src/Gui/CommandWindow.cpp +++ b/src/Gui/CommandWindow.cpp @@ -460,14 +460,14 @@ Action * StdCmdWindowsMenu::createAction(void) WindowAction *pcAction; pcAction = new WindowAction(this, getMainWindow()); for ( int i=0; i<10; i++ ) { - QAction* window = pcAction->addAction(QObject::tr(sToolTipText)); + QAction* window = pcAction->addAction(QObject::tr(getToolTipText())); window->setCheckable(true); window->setToolTip(QCoreApplication::translate( - this->className(), sToolTipText)); + this->className(), getToolTipText())); window->setStatusTip(QCoreApplication::translate( - this->className(), sStatusTip)); + this->className(), getStatusTip())); window->setWhatsThis(QCoreApplication::translate( - this->className(), sWhatsThis)); + this->className(), getWhatsThis())); } QAction* sep = pcAction->addAction(QLatin1String("")); diff --git a/src/Gui/NetworkRetriever.cpp b/src/Gui/NetworkRetriever.cpp index b64327bd2f..85a16f8d9b 100644 --- a/src/Gui/NetworkRetriever.cpp +++ b/src/Gui/NetworkRetriever.cpp @@ -421,15 +421,15 @@ Action * StdCmdDownloadOnlineHelp::createAction(void) QString exe = QString::fromLatin1(App::GetApplication().getExecutableName()); pcAction = new Action(this,getMainWindow()); pcAction->setText(QCoreApplication::translate( - this->className(), sMenuText)); + this->className(), getMenuText())); pcAction->setToolTip(QCoreApplication::translate( - this->className(), sToolTipText).arg(exe)); + this->className(), getToolTipText()).arg(exe)); pcAction->setStatusTip(QCoreApplication::translate( - this->className(), sStatusTip).arg(exe)); + this->className(), getStatusTip()).arg(exe)); pcAction->setWhatsThis(QCoreApplication::translate( - this->className(), sWhatsThis).arg(exe)); - pcAction->setIcon(Gui::BitmapFactory().pixmap(sPixmap)); - pcAction->setShortcut(QString::fromLatin1(sAccel)); + this->className(), getWhatsThis()).arg(exe)); + pcAction->setIcon(Gui::BitmapFactory().pixmap(getPixmap())); + pcAction->setShortcut(QString::fromLatin1(getAccel())); return pcAction; } @@ -439,13 +439,13 @@ void StdCmdDownloadOnlineHelp::languageChange() if (_pcAction) { QString exe = QString::fromLatin1(App::GetApplication().getExecutableName()); _pcAction->setText(QCoreApplication::translate( - this->className(), sMenuText)); + this->className(), getMenuText())); _pcAction->setToolTip(QCoreApplication::translate( - this->className(), sToolTipText).arg(exe)); + this->className(), getToolTipText()).arg(exe)); _pcAction->setStatusTip(QCoreApplication::translate( - this->className(), sStatusTip).arg(exe)); + this->className(), getStatusTip()).arg(exe)); _pcAction->setWhatsThis(QCoreApplication::translate( - this->className(), sWhatsThis).arg(exe)); + this->className(), getWhatsThis()).arg(exe)); } } @@ -550,7 +550,7 @@ void StdCmdDownloadOnlineHelp::wgetFinished() { if (_pcAction) _pcAction->setText(QCoreApplication::translate( - this->className(), sMenuText)); + this->className(), getMenuText())); } #include "moc_NetworkRetriever.cpp" diff --git a/src/Mod/Sketcher/Gui/CommandConstraints.cpp b/src/Mod/Sketcher/Gui/CommandConstraints.cpp index e6aeb20df8..99d9938c27 100644 --- a/src/Mod/Sketcher/Gui/CommandConstraints.cpp +++ b/src/Mod/Sketcher/Gui/CommandConstraints.cpp @@ -898,7 +898,7 @@ public: qreal fullIconWidth = 32 * pixelRatio; qreal iconWidth = 16 * pixelRatio; QPixmap cursorPixmap = Gui::BitmapFactory().pixmapFromSvg("Sketcher_Crosshair", QSizeF(fullIconWidth, fullIconWidth), colorMapping), - icon = Gui::BitmapFactory().pixmapFromSvg(cmd->sPixmap, QSizeF(iconWidth, iconWidth)); + icon = Gui::BitmapFactory().pixmapFromSvg(cmd->getPixmap(), QSizeF(iconWidth, iconWidth)); QPainter cursorPainter; cursorPainter.begin(&cursorPixmap); cursorPainter.drawPixmap(16 * pixelRatio, 16 * pixelRatio, icon); @@ -5902,7 +5902,7 @@ Gui::Action * CmdSketcherCompConstrainRadDia::createAction(void) pcAction->setProperty("defaultAction", QVariant(defaultId)); } - pcAction->setShortcut(QString::fromLatin1(sAccel)); + pcAction->setShortcut(QString::fromLatin1(getAccel())); return pcAction; } diff --git a/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp b/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp index 32444ce8f8..26a9d47b80 100644 --- a/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp +++ b/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp @@ -1653,12 +1653,12 @@ void CmdSketcherCompCopy::activated(int iMsg) if (iMsg == 0){ CmdSketcherClone sc; sc.activate(); - pcAction->setShortcut(QString::fromLatin1(this->sAccel)); + pcAction->setShortcut(QString::fromLatin1(this->getAccel())); } else if (iMsg == 1) { CmdSketcherCopy sc; sc.activate(); - pcAction->setShortcut(QString::fromLatin1(this->sAccel)); + pcAction->setShortcut(QString::fromLatin1(this->getAccel())); } else if (iMsg == 2) { CmdSketcherMove sc; @@ -1687,7 +1687,7 @@ Gui::Action * CmdSketcherCompCopy::createAction(void) int defaultId = 0; pcAction->setProperty("defaultAction", QVariant(defaultId)); - pcAction->setShortcut(QString::fromLatin1(sAccel)); + pcAction->setShortcut(QString::fromLatin1(getAccel())); return pcAction; } From 3fd643d3eeefe11cb52ad870023d951a666d830f Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 21 Apr 2021 21:46:14 +0200 Subject: [PATCH 134/178] fixes #0003844: PVS: The pointer was not released in destructor. A memory leak is possible. --- src/Gui/Command.cpp | 110 +++++++++++++++----------------------------- 1 file changed, 36 insertions(+), 74 deletions(-) diff --git a/src/Gui/Command.cpp b/src/Gui/Command.cpp index c69257d668..83b9a92286 100644 --- a/src/Gui/Command.cpp +++ b/src/Gui/Command.cpp @@ -135,10 +135,25 @@ using namespace Gui::DockWnd; // list of modules already loaded by a command (not issue again for macro cleanness) std::set alreadyLoadedModule; -CommandBase::CommandBase( const char* sMenu, const char* sToolTip, const char* sWhat, - const char* sStatus, const char* sPixmap, const char* sAcc) - : sMenuText(sMenu), sToolTipText(sToolTip), sWhatsThis(sWhat?sWhat:sToolTip), - sStatusTip(sStatus?sStatus:sToolTip), sPixmap(sPixmap), sAccel(sAcc), _pcAction(0) +class StringCache { +public: + static const char* New(const char* str) { + using StringList = std::list; + static StringList strings; + strings.emplace_back(str); + return strings.back().c_str(); + } +}; + +CommandBase::CommandBase(const char* sMenu, const char* sToolTip, const char* sWhat, + const char* sStatus, const char* sPixmap, const char* sAcc) + : sMenuText(sMenu) + , sToolTipText(sToolTip) + , sWhatsThis(sWhat ? sWhat : sToolTip) + , sStatusTip(sStatus ? sStatus : sToolTip) + , sPixmap(sPixmap) + , sAccel(sAcc) + , _pcAction(nullptr) { } @@ -162,56 +177,32 @@ Action * CommandBase::createAction() void CommandBase::setMenuText(const char* s) { -#if defined (_MSC_VER) - this->sMenuText = _strdup(s); -#else - this->sMenuText = strdup(s); -#endif + this->sMenuText = StringCache::New(s); } void CommandBase::setToolTipText(const char* s) { -#if defined (_MSC_VER) - this->sToolTipText = _strdup(s); -#else - this->sToolTipText = strdup(s); -#endif + this->sToolTipText = StringCache::New(s); } void CommandBase::setStatusTip(const char* s) { -#if defined (_MSC_VER) - this->sStatusTip = _strdup(s); -#else - this->sStatusTip = strdup(s); -#endif + this->sStatusTip = StringCache::New(s); } void CommandBase::setWhatsThis(const char* s) { -#if defined (_MSC_VER) - this->sWhatsThis = _strdup(s); -#else - this->sWhatsThis = strdup(s); -#endif + this->sWhatsThis = StringCache::New(s); } void CommandBase::setPixmap(const char* s) { -#if defined (_MSC_VER) - this->sPixmap = _strdup(s); -#else - this->sPixmap = strdup(s); -#endif + this->sPixmap = StringCache::New(s); } void CommandBase::setAccel(const char* s) { -#if defined (_MSC_VER) - this->sAccel = _strdup(s); -#else - this->sAccel = strdup(s); -#endif + this->sAccel = StringCache::New(s); } //=========================================================================== @@ -221,7 +212,9 @@ void CommandBase::setAccel(const char* s) /* TRANSLATOR Gui::Command */ Command::Command(const char* name) - : CommandBase(0), sName(name), sHelpUrl(0) + : CommandBase(nullptr) + , sName(name) + , sHelpUrl(0) { sAppModule = "FreeCAD"; sGroup = QT_TR_NOOP("Standard"); @@ -578,20 +571,12 @@ std::string Command::getObjectCmd(const App::DocumentObject *obj, void Command::setAppModuleName(const char* s) { -#if defined (_MSC_VER) - this->sAppModule = _strdup(s); -#else - this->sAppModule = strdup(s); -#endif + this->sAppModule = StringCache::New(s); } void Command::setGroupName(const char* s) { -#if defined (_MSC_VER) - this->sGroup = _strdup(s); -#else - this->sGroup = strdup(s); -#endif + this->sGroup = StringCache::New(s); } //-------------------------------------------------------------------------- @@ -1073,23 +1058,16 @@ void GroupCommand::setup(Action *pcAction) { /* TRANSLATOR Gui::MacroCommand */ MacroCommand::MacroCommand(const char* name, bool system) -#if defined (_MSC_VER) - : Command( _strdup(name) ), systemMacro(system) -#else - : Command( strdup(name) ), systemMacro(system) -#endif + : Command(StringCache::New(name)) + , systemMacro(system) { sGroup = QT_TR_NOOP("Macros"); eType = 0; - sScriptName = 0; + sScriptName = nullptr; } MacroCommand::~MacroCommand() { - free(const_cast(sName)); - sName = 0; - free(const_cast(sScriptName)); - sScriptName = 0; } void MacroCommand::activated(int iMsg) @@ -1157,11 +1135,7 @@ Action * MacroCommand::createAction(void) void MacroCommand::setScriptName( const char* s ) { -#if defined (_MSC_VER) - this->sScriptName = _strdup( s ); -#else - this->sScriptName = strdup( s ); -#endif + this->sScriptName = StringCache::New(s); } void MacroCommand::load() @@ -1214,11 +1188,7 @@ void MacroCommand::save() //=========================================================================== PythonCommand::PythonCommand(const char* name, PyObject * pcPyCommand, const char* pActivationString) -#if defined (_MSC_VER) - : Command( _strdup(name) ) -#else - : Command( strdup(name) ) -#endif + : Command(StringCache::New(name)) ,_pcPyCommand(pcPyCommand) { if (pActivationString) @@ -1258,8 +1228,6 @@ PythonCommand::~PythonCommand() { Base::PyGILStateLocker lock; Py_DECREF(_pcPyCommand); - free(const_cast(sName)); - sName = 0; } const char* PythonCommand::getResource(const char* sName) const @@ -1449,11 +1417,7 @@ bool PythonCommand::isChecked() const //=========================================================================== PythonGroupCommand::PythonGroupCommand(const char* name, PyObject * pcPyCommand) -#if defined (_MSC_VER) - : Command( _strdup(name) ) -#else - : Command( strdup(name) ) -#endif + : Command(StringCache::New(name)) ,_pcPyCommand(pcPyCommand) { sGroup = "Python"; @@ -1488,8 +1452,6 @@ PythonGroupCommand::~PythonGroupCommand() { Base::PyGILStateLocker lock; Py_DECREF(_pcPyCommand); - free(const_cast(sName)); - sName = 0; } void PythonGroupCommand::activated(int iMsg) From 738a697d94936b85ddbb1c9204fb6a85eb99557d Mon Sep 17 00:00:00 2001 From: luz paz Date: Wed, 21 Apr 2021 22:06:59 -0400 Subject: [PATCH 135/178] [TD] remove Py2 code from TD --- src/Mod/TechDraw/App/AppTechDrawPy.cpp | 19 ----------------- src/Mod/TechDraw/App/CenterLinePyImp.cpp | 21 ------------------- src/Mod/TechDraw/App/DrawPagePyImp.cpp | 8 ------- src/Mod/TechDraw/App/DrawProjGroupPyImp.cpp | 8 ------- src/Mod/TechDraw/App/DrawSVGTemplatePyImp.cpp | 4 ---- .../TechDraw/App/DrawViewCollectionPyImp.cpp | 8 ------- src/Mod/TechDraw/App/DrawViewPartPyImp.cpp | 7 ------- src/Mod/TechDraw/Gui/Command.cpp | 4 ---- src/Mod/TechDraw/Gui/QGITile.cpp | 4 ---- src/Mod/TechDraw/Gui/QGIWeldSymbol.cpp | 4 ---- src/Mod/TechDraw/Gui/TaskActiveView.cpp | 4 ---- 11 files changed, 91 deletions(-) diff --git a/src/Mod/TechDraw/App/AppTechDrawPy.cpp b/src/Mod/TechDraw/App/AppTechDrawPy.cpp index ed07a2a5fe..23e64468a1 100644 --- a/src/Mod/TechDraw/App/AppTechDrawPy.cpp +++ b/src/Mod/TechDraw/App/AppTechDrawPy.cpp @@ -781,17 +781,10 @@ private: try { Py::Sequence list(pEdgeList); for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) { -#if PY_MAJOR_VERSION >= 3 if (PyUnicode_Check((*it).ptr())) { std::string temp = PyUnicode_AsUTF8((*it).ptr()); edgeList.push_back(temp); } -#else - if (PyString_Check((*it).ptr())) { - std::string temp = PyString_AsString((*it).ptr()); //py2 only!!! - edgeList.push_back(temp); - } -#endif } } catch (Standard_Failure& e) { @@ -829,15 +822,9 @@ private: else { throw Py::TypeError("expected (DrawViewPart, dimType, from, to"); } -#if PY_MAJOR_VERSION >= 3 if (PyUnicode_Check(pDimType) ) { dimType = PyUnicode_AsUTF8(pDimType); } -#else - if (PyString_Check(pDimType) ) { - dimType = PyString_AsString(pDimType); - } -#endif if (PyObject_TypeCheck(pFrom, &(Base::VectorPy::Type))) { from = static_cast(pFrom)->value(); @@ -877,15 +864,9 @@ private: else { throw Py::TypeError("expected (DrawViewPart, dimType, from, to"); } -#if PY_MAJOR_VERSION >= 3 if (PyUnicode_Check(pDimType)) { dimType = PyUnicode_AsUTF8(pDimType); } -#else - if (PyString_Check(pDimType)) { - dimType = PyString_AsString(pDimType); - } -#endif if (PyObject_TypeCheck(pFrom, &(Base::VectorPy::Type))) { from = static_cast(pFrom)->value(); } diff --git a/src/Mod/TechDraw/App/CenterLinePyImp.cpp b/src/Mod/TechDraw/App/CenterLinePyImp.cpp index 570aec4fa9..823e3f140f 100644 --- a/src/Mod/TechDraw/App/CenterLinePyImp.cpp +++ b/src/Mod/TechDraw/App/CenterLinePyImp.cpp @@ -321,17 +321,10 @@ void CenterLinePy::setEdges(Py::Object arg) int i = 0; for ( ; i < tSize; i++) { PyObject* item = PyList_GetItem(pList, (Py_ssize_t) i); -#if PY_MAJOR_VERSION >= 3 if (PyUnicode_Check(item)) { std::string s = PyUnicode_AsUTF8(item); //py3 only!!! temp.push_back(s); } -#else - if (PyString_Check(item)) { - std::string s = PyString_AsString(item); //py2 only!!! - temp.push_back(s); - } -#endif } cl->m_edges = temp; } else { @@ -367,17 +360,10 @@ void CenterLinePy::setFaces(Py::Object arg) int i = 0; for ( ; i < tSize; i++) { PyObject* item = PyList_GetItem(pList, (Py_ssize_t) i); -#if PY_MAJOR_VERSION >= 3 if (PyUnicode_Check(item)) { std::string s = PyUnicode_AsUTF8(item); //py3 only!!! temp.push_back(s); } -#else - if (PyString_Check(item)) { - std::string s = PyString_AsString(item); //py2 only!!! - temp.push_back(s); - } -#endif } cl->m_faces = temp; } else { @@ -414,17 +400,10 @@ void CenterLinePy::setPoints(Py::Object arg) int i = 0; for ( ; i < tSize; i++) { PyObject* item = PyList_GetItem(pList, (Py_ssize_t) i); -#if PY_MAJOR_VERSION >= 3 if (PyUnicode_Check(item)) { std::string s = PyUnicode_AsUTF8(item); //py3 only!!! temp.push_back(s); } -#else - if (PyString_Check(item)) { - std::string s = PyString_AsString(item); //py2 only!!! - temp.push_back(s); - } -#endif } cl->m_verts = temp; } else { diff --git a/src/Mod/TechDraw/App/DrawPagePyImp.cpp b/src/Mod/TechDraw/App/DrawPagePyImp.cpp index 42607a80d4..cb52fd3fd4 100644 --- a/src/Mod/TechDraw/App/DrawPagePyImp.cpp +++ b/src/Mod/TechDraw/App/DrawPagePyImp.cpp @@ -44,11 +44,7 @@ PyObject* DrawPagePy::addView(PyObject* args) DrawView* view = pyView->getDrawViewPtr(); //get DrawView for pyView int rc = page->addView(view); -#if PY_MAJOR_VERSION < 3 - return PyInt_FromLong((long) rc); -#else return PyLong_FromLong((long) rc); -#endif } PyObject* DrawPagePy::removeView(PyObject* args) @@ -69,11 +65,7 @@ PyObject* DrawPagePy::removeView(PyObject* args) int rc = page->removeView(view); -#if PY_MAJOR_VERSION < 3 - return PyInt_FromLong((long) rc); -#else return PyLong_FromLong((long) rc); -#endif } PyObject* DrawPagePy::getAllViews(PyObject* args) diff --git a/src/Mod/TechDraw/App/DrawProjGroupPyImp.cpp b/src/Mod/TechDraw/App/DrawProjGroupPyImp.cpp index 663dfaefd3..b2b58f02bd 100644 --- a/src/Mod/TechDraw/App/DrawProjGroupPyImp.cpp +++ b/src/Mod/TechDraw/App/DrawProjGroupPyImp.cpp @@ -72,11 +72,7 @@ PyObject* DrawProjGroupPy::removeProjection(PyObject* args) DrawProjGroup* projGroup = getDrawProjGroupPtr(); int i = projGroup->removeProjection(projType); -#if PY_MAJOR_VERSION < 3 - return PyInt_FromLong((long) i); -#else return PyLong_FromLong((long) i); -#endif } PyObject* DrawProjGroupPy::purgeProjections(PyObject* /*args*/) @@ -84,11 +80,7 @@ PyObject* DrawProjGroupPy::purgeProjections(PyObject* /*args*/) DrawProjGroup* projGroup = getDrawProjGroupPtr(); int i = projGroup->purgeProjections(); -#if PY_MAJOR_VERSION < 3 - return PyInt_FromLong((long) i); -#else return PyLong_FromLong((long) i); -#endif } PyObject* DrawProjGroupPy::getItemByLabel(PyObject* args) diff --git a/src/Mod/TechDraw/App/DrawSVGTemplatePyImp.cpp b/src/Mod/TechDraw/App/DrawSVGTemplatePyImp.cpp index cca9db485a..5823e3af7e 100644 --- a/src/Mod/TechDraw/App/DrawSVGTemplatePyImp.cpp +++ b/src/Mod/TechDraw/App/DrawSVGTemplatePyImp.cpp @@ -71,11 +71,7 @@ PyObject* DrawSVGTemplatePy::getEditFieldContent(PyObject* args) } std::string content = getDrawSVGTemplatePtr()->EditableTexts[fieldName]; if (!content.empty()) { -#if PY_MAJOR_VERSION < 3 - result = PyString_FromString(content.c_str()); -#else result = PyUnicode_FromString(content.c_str()); -#endif } return result; } diff --git a/src/Mod/TechDraw/App/DrawViewCollectionPyImp.cpp b/src/Mod/TechDraw/App/DrawViewCollectionPyImp.cpp index cb696f7983..1827abfb56 100644 --- a/src/Mod/TechDraw/App/DrawViewCollectionPyImp.cpp +++ b/src/Mod/TechDraw/App/DrawViewCollectionPyImp.cpp @@ -50,11 +50,7 @@ PyObject* DrawViewCollectionPy::addView(PyObject* args) int i = collect->addView(view); -#if PY_MAJOR_VERSION < 3 - return PyInt_FromLong((long) i); -#else return PyLong_FromLong((long) i); -#endif } PyObject* DrawViewCollectionPy::removeView(PyObject* args) @@ -72,11 +68,7 @@ PyObject* DrawViewCollectionPy::removeView(PyObject* args) int i = collect->removeView(view); -#if PY_MAJOR_VERSION < 3 - return PyInt_FromLong((long) i); -#else return PyLong_FromLong((long) i); -#endif } diff --git a/src/Mod/TechDraw/App/DrawViewPartPyImp.cpp b/src/Mod/TechDraw/App/DrawViewPartPyImp.cpp index 1a39f3beb6..610c185290 100644 --- a/src/Mod/TechDraw/App/DrawViewPartPyImp.cpp +++ b/src/Mod/TechDraw/App/DrawViewPartPyImp.cpp @@ -553,17 +553,10 @@ PyObject* DrawViewPartPy::makeCenterLine(PyObject *args) int i = 0; for ( ; i < size; i++) { PyObject* po = PyList_GetItem(pSubs, i); -#if PY_MAJOR_VERSION >= 3 if (PyUnicode_Check(po)) { std::string s = PyUnicode_AsUTF8(po); //py3 only!!! subs.push_back(s); } -#else - if (PyString_Check(po)) { - std::string s = PyString_AsString(po); //py2 only!!! - subs.push_back(s); - } -#endif } } CenterLine* cl = nullptr; diff --git a/src/Mod/TechDraw/Gui/Command.cpp b/src/Mod/TechDraw/Gui/Command.cpp index fa73b7f491..31a94facfd 100644 --- a/src/Mod/TechDraw/Gui/Command.cpp +++ b/src/Mod/TechDraw/Gui/Command.cpp @@ -1082,11 +1082,7 @@ void CmdTechDrawSymbol::activated(int iMsg) std::string FeatName = getUniqueObjectName("Symbol"); filename = Base::Tools::escapeEncodeFilename(filename); openCommand(QT_TRANSLATE_NOOP("Command", "Create Symbol")); -#if PY_MAJOR_VERSION < 3 - doCommand(Doc,"f = open(unicode(\"%s\",'utf-8'),'r')",(const char*)filename.toUtf8()); -#else doCommand(Doc,"f = open(\"%s\",'r')",(const char*)filename.toUtf8()); -#endif doCommand(Doc,"svg = f.read()"); doCommand(Doc,"f.close()"); doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewSymbol','%s')",FeatName.c_str()); diff --git a/src/Mod/TechDraw/Gui/QGITile.cpp b/src/Mod/TechDraw/Gui/QGITile.cpp index 7ef9c76488..717d71ee96 100644 --- a/src/Mod/TechDraw/Gui/QGITile.cpp +++ b/src/Mod/TechDraw/Gui/QGITile.cpp @@ -86,11 +86,7 @@ QGITile::QGITile(TechDraw::DrawTileWeld* dtw) : 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); diff --git a/src/Mod/TechDraw/Gui/QGIWeldSymbol.cpp b/src/Mod/TechDraw/Gui/QGIWeldSymbol.cpp index 5f4d7a269b..9c58e78065 100644 --- a/src/Mod/TechDraw/Gui/QGIWeldSymbol.cpp +++ b/src/Mod/TechDraw/Gui/QGIWeldSymbol.cpp @@ -86,11 +86,7 @@ QGIWeldSymbol::QGIWeldSymbol(QGILeaderLine* myParent) : 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); diff --git a/src/Mod/TechDraw/Gui/TaskActiveView.cpp b/src/Mod/TechDraw/Gui/TaskActiveView.cpp index d96c780e1e..3bbf8c8fc1 100644 --- a/src/Mod/TechDraw/Gui/TaskActiveView.cpp +++ b/src/Mod/TechDraw/Gui/TaskActiveView.cpp @@ -151,11 +151,7 @@ TechDraw::DrawViewSymbol* TaskActiveView::createActiveView(void) ui->qsbWeight->rawValue(), ui->qsbBorder->rawValue(), ui->cbMode->currentIndex()); -#if PY_MAJOR_VERSION < 3 - Command::doCommand(Command::Doc,"f = open(unicode(\"%s\",'utf-8'),'r')",(const char*)fileSpec.c_str()); -#else Command::doCommand(Command::Doc,"f = open(\"%s\",'r')",(const char*)fileSpec.c_str()); -#endif Command::doCommand(Command::Doc,"svg = f.read()"); // Command::doCommand(Command::Doc,"print('length of svg: {}'.format(len(svg)))"); From 9e6fe284edfb29331a3dafb726bdc02039febf4e Mon Sep 17 00:00:00 2001 From: luz paz Date: Wed, 21 Apr 2021 22:12:07 -0400 Subject: [PATCH 136/178] Sketcher: remove Py2 code from Sketcher wb --- src/Mod/Sketcher/App/ConstraintPyImp.cpp | 50 ---------------------- src/Mod/Sketcher/App/SketchObjectPyImp.cpp | 25 ----------- 2 files changed, 75 deletions(-) diff --git a/src/Mod/Sketcher/App/ConstraintPyImp.cpp b/src/Mod/Sketcher/App/ConstraintPyImp.cpp index cafa0019e0..6f4c0a79e9 100644 --- a/src/Mod/Sketcher/App/ConstraintPyImp.cpp +++ b/src/Mod/Sketcher/App/ConstraintPyImp.cpp @@ -86,13 +86,8 @@ int ConstraintPy::PyInit(PyObject* args, PyObject* /*kwd*/) if (PyArg_ParseTuple(args, "siO", &ConstraintType, &FirstIndex, &index_or_value)) { // ConstraintType, GeoIndex1, GeoIndex2 -#if PY_MAJOR_VERSION >= 3 if (PyLong_Check(index_or_value)) { SecondIndex = PyLong_AsLong(index_or_value); -#else - if (PyLong_Check(index_or_value) || PyInt_Check(index_or_value)) { - SecondIndex = PyInt_AsLong(index_or_value); -#endif bool valid = false; if (strcmp("Tangent",ConstraintType) == 0) { this->getConstraintPtr()->Type = Tangent; @@ -187,15 +182,9 @@ int ConstraintPy::PyInit(PyObject* args, PyObject* /*kwd*/) if (PyArg_ParseTuple(args, "siiO", &ConstraintType, &FirstIndex, &any_index, &index_or_value)) { // ConstraintType, GeoIndex1, PosIndex1, GeoIndex2 -#if PY_MAJOR_VERSION >= 3 if (PyLong_Check(index_or_value)) { FirstPos = any_index; SecondIndex = PyLong_AsLong(index_or_value); -#else - if (PyLong_Check(index_or_value) || PyInt_Check(index_or_value)) { - FirstPos = any_index; - SecondIndex = PyInt_AsLong(index_or_value); -#endif bool valid = false; if (strcmp("Perpendicular", ConstraintType) == 0) { this->getConstraintPtr()->Type = Perpendicular; @@ -279,13 +268,8 @@ int ConstraintPy::PyInit(PyObject* args, PyObject* /*kwd*/) if (PyArg_ParseTuple(args, "siiiO", &ConstraintType, &intArg1, &intArg2, &intArg3, &oNumArg4)) { // Value, ConstraintType, GeoIndex1, PosIndex1, GeoIndex2, PosIndex2 -#if PY_MAJOR_VERSION >= 3 if (PyLong_Check(oNumArg4)) { intArg4 = PyLong_AsLong(oNumArg4); -#else - if (PyInt_Check(oNumArg4)) { - intArg4 = PyInt_AsLong(oNumArg4); -#endif bool valid = false; if (strcmp("Coincident", ConstraintType) == 0) { this->getConstraintPtr()->Type = Coincident; @@ -376,13 +360,8 @@ int ConstraintPy::PyInit(PyObject* args, PyObject* /*kwd*/) if (PyArg_ParseTuple(args, "siiiiO", &ConstraintType, &intArg1, &intArg2, &intArg3, &intArg4, &oNumArg5)) { // ConstraintType, GeoIndex1, PosIndex1, GeoIndex2, PosIndex2, GeoIndex3 -#if PY_MAJOR_VERSION >= 3 if (PyLong_Check(oNumArg5)) { intArg5 = PyLong_AsLong(oNumArg5); -#else - if (PyInt_Check(oNumArg5)) { - intArg5 = PyInt_AsLong(oNumArg5); -#endif if (strcmp("Symmetric",ConstraintType) == 0 ) { this->getConstraintPtr()->Type = Symmetric; this->getConstraintPtr()->First = intArg1; @@ -448,13 +427,8 @@ int ConstraintPy::PyInit(PyObject* args, PyObject* /*kwd*/) PyErr_Clear(); if (PyArg_ParseTuple(args, "siiiiiO", &ConstraintType, &FirstIndex, &FirstPos, &SecondIndex, &SecondPos, &ThirdIndex, &index_or_value)) { -#if PY_MAJOR_VERSION >= 3 if (PyLong_Check(index_or_value)) { ThirdPos = PyLong_AsLong(index_or_value); -#else - if (PyInt_Check(index_or_value)) { - ThirdPos = PyInt_AsLong(index_or_value); -#endif // ConstraintType, GeoIndex1, PosIndex1, GeoIndex2, PosIndex2, GeoIndex3, PosIndex3 if (strcmp("Symmetric",ConstraintType) == 0 ) { this->getConstraintPtr()->Type = Symmetric; @@ -584,11 +558,7 @@ Py::Long ConstraintPy::getFirst(void) const void ConstraintPy::setFirst(Py::Long arg) { -#if PY_MAJOR_VERSION < 3 - this->getConstraintPtr()->First = Py::Int(arg); -#else this->getConstraintPtr()->First = arg; -#endif } Py::Long ConstraintPy::getFirstPos(void) const @@ -598,11 +568,7 @@ Py::Long ConstraintPy::getFirstPos(void) const void ConstraintPy::setFirstPos(Py::Long arg) { - #if PY_MAJOR_VERSION < 3 - int pos = Py::Int(arg); - #else int pos = arg; - #endif if(pos>=Sketcher::none && pos<=Sketcher::mid) { this->getConstraintPtr()->FirstPos = (Sketcher::PointPos)pos; @@ -622,11 +588,7 @@ Py::Long ConstraintPy::getSecond(void) const void ConstraintPy::setSecond(Py::Long arg) { -#if PY_MAJOR_VERSION < 3 - this->getConstraintPtr()->Second = Py::Int(arg); -#else this->getConstraintPtr()->Second = arg; -#endif } Py::Long ConstraintPy::getSecondPos(void) const @@ -636,11 +598,7 @@ Py::Long ConstraintPy::getSecondPos(void) const void ConstraintPy::setSecondPos(Py::Long arg) { - #if PY_MAJOR_VERSION < 3 - int pos = Py::Int(arg); - #else int pos = arg; - #endif if(pos>=Sketcher::none && pos<=Sketcher::mid) { this->getConstraintPtr()->SecondPos = (Sketcher::PointPos)pos; @@ -660,11 +618,7 @@ Py::Long ConstraintPy::getThird(void) const void ConstraintPy::setThird(Py::Long arg) { -#if PY_MAJOR_VERSION < 3 - this->getConstraintPtr()->Third = Py::Int(arg); -#else this->getConstraintPtr()->Third = arg; -#endif } Py::Long ConstraintPy::getThirdPos(void) const @@ -674,11 +628,7 @@ Py::Long ConstraintPy::getThirdPos(void) const void ConstraintPy::setThirdPos(Py::Long arg) { - #if PY_MAJOR_VERSION < 3 - int pos = Py::Int(arg); - #else int pos = arg; - #endif if(pos>=Sketcher::none && pos<=Sketcher::mid) { this->getConstraintPtr()->ThirdPos = (Sketcher::PointPos)pos; diff --git a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp index 4a464b9a92..4600c9e248 100644 --- a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp +++ b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp @@ -227,13 +227,8 @@ PyObject* SketchObjectPy::delGeometries(PyObject *args) std::vector geoIdList; Py::Sequence list(pcObj); for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) { -#if PY_MAJOR_VERSION >= 3 if (PyLong_Check((*it).ptr())) geoIdList.push_back(PyLong_AsLong((*it).ptr())); -#else - if (PyInt_Check((*it).ptr())) - geoIdList.push_back(PyInt_AsLong((*it).ptr())); -#endif } if(this->getSketchObjectPtr()->delGeometries(geoIdList)) { @@ -1139,13 +1134,8 @@ PyObject* SketchObjectPy::addSymmetric(PyObject *args) std::vector geoIdList; Py::Sequence list(pcObj); for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) { -#if PY_MAJOR_VERSION >= 3 if (PyLong_Check((*it).ptr())) geoIdList.push_back(PyLong_AsLong((*it).ptr())); -#else - if (PyInt_Check((*it).ptr())) - geoIdList.push_back(PyInt_AsLong((*it).ptr())); -#endif } int ret = this->getSketchObjectPtr()->addSymmetric(geoIdList,refGeoId,(Sketcher::PointPos) refPosId) + 1; @@ -1183,13 +1173,8 @@ PyObject* SketchObjectPy::addCopy(PyObject *args) std::vector geoIdList; Py::Sequence list(pcObj); for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) { -#if PY_MAJOR_VERSION >= 3 if (PyLong_Check((*it).ptr())) geoIdList.push_back(PyLong_AsLong((*it).ptr())); -#else - if (PyInt_Check((*it).ptr())) - geoIdList.push_back(PyInt_AsLong((*it).ptr())); -#endif } try { @@ -1232,13 +1217,8 @@ PyObject* SketchObjectPy::addMove(PyObject *args) std::vector geoIdList; Py::Sequence list(pcObj); for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) { - #if PY_MAJOR_VERSION >= 3 if (PyLong_Check((*it).ptr())) geoIdList.push_back(PyLong_AsLong((*it).ptr())); - #else - if (PyInt_Check((*it).ptr())) - geoIdList.push_back(PyInt_AsLong((*it).ptr())); - #endif } this->getSketchObjectPtr()->addCopy(geoIdList, vect, true); @@ -1270,13 +1250,8 @@ PyObject* SketchObjectPy::addRectangularArray(PyObject *args) std::vector geoIdList; Py::Sequence list(pcObj); for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) { -#if PY_MAJOR_VERSION >= 3 if (PyLong_Check((*it).ptr())) geoIdList.push_back(PyLong_AsLong((*it).ptr())); -#else - if (PyInt_Check((*it).ptr())) - geoIdList.push_back(PyInt_AsLong((*it).ptr())); -#endif } try { From 1d34fc0aa188ca6733fe6b512e7a409f13e2f139 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 22 Apr 2021 23:16:03 +0200 Subject: [PATCH 137/178] Gui: fix memory leak in SelectionParser::yyparse() --- src/Gui/SelectionFilter.cpp | 26 ++++++++++++++++++++++++++ src/Gui/SelectionFilter.h | 4 +--- src/Gui/SelectionFilter.l | 2 +- src/Gui/SelectionFilter.tab.c | 2 +- src/Gui/SelectionFilter.y | 22 +++++++++++----------- src/Gui/lex.SelectionFilter.c | 2 +- 6 files changed, 41 insertions(+), 17 deletions(-) diff --git a/src/Gui/SelectionFilter.cpp b/src/Gui/SelectionFilter.cpp index dd4e2d89d9..5c6d26a590 100644 --- a/src/Gui/SelectionFilter.cpp +++ b/src/Gui/SelectionFilter.cpp @@ -363,6 +363,31 @@ int fileno(FILE *stream) {return _fileno(stream);} namespace SelectionParser { +/*! + * \brief The StringFactory class + * Helper class to record the created strings used by the parser. + */ +class StringFactory { + std::list> data; + std::size_t max_elements = 20; +public: + static StringFactory* instance() { + static StringFactory* inst = new StringFactory(); + return inst; + } + std::string* make(const std::string& str) { + data.push_back(std::make_unique(str)); + return data.back().get(); + } + static std::string* New(const std::string& str) { + return StringFactory::instance()->make(str); + } + void clear() { + if (data.size() > max_elements) + data.clear(); + } +}; + // show the parser the lexer method #define yylex SelectionFilterlex int SelectionFilterlex(void); @@ -401,6 +426,7 @@ bool SelectionFilter::parse(void) Ast.reset(TopBlock); TopBlock = 0; SelectionParser::SelectionFilter_delete_buffer (my_string_buffer); + SelectionParser::StringFactory::instance()->clear(); if (Errors.empty()) { return true; diff --git a/src/Gui/SelectionFilter.h b/src/Gui/SelectionFilter.h index 7f625f854e..505b0db9c4 100644 --- a/src/Gui/SelectionFilter.h +++ b/src/Gui/SelectionFilter.h @@ -207,10 +207,8 @@ struct Node_Object :Slice(slc) { ObjectType = Base::Type::fromName(type->c_str()); - delete (type); - if(subname){ + if (subname) { SubName = *subname; - delete subname; } } ~Node_Object(){ diff --git a/src/Gui/SelectionFilter.l b/src/Gui/SelectionFilter.l index eda00025a7..fe96a20d6b 100644 --- a/src/Gui/SelectionFilter.l +++ b/src/Gui/SelectionFilter.l @@ -58,7 +58,7 @@ "::" return TNAMESPACE; [a-zA-Z_][a-zA-Z0-9_]* { - yylval.string = new std::string(yytext); + yylval.string = StringFactory::New(yytext); return TIDENTIFIER; } [0-9]+ { diff --git a/src/Gui/SelectionFilter.tab.c b/src/Gui/SelectionFilter.tab.c index 5dabdbc950..9d136765b3 100644 --- a/src/Gui/SelectionFilter.tab.c +++ b/src/Gui/SelectionFilter.tab.c @@ -1345,7 +1345,7 @@ yyreduce: /* Line 1464 of yacc.c */ #line 40 "SelectionFilter.y" - { (yyval.string) = new std::string(*(yyvsp[(2) - (4)].string) + "::" + *(yyvsp[(4) - (4)].string)) ;} + { (yyval.string) = StringFactory::New(*(yyvsp[(2) - (4)].string) + "::" + *(yyvsp[(4) - (4)].string)) ;} break; case 4: diff --git a/src/Gui/SelectionFilter.y b/src/Gui/SelectionFilter.y index 051599e7ed..e82d4c109b 100644 --- a/src/Gui/SelectionFilter.y +++ b/src/Gui/SelectionFilter.y @@ -55,25 +55,25 @@ -type : TSELECT TIDENTIFIER { $$ = $2 } - | TSELECT TIDENTIFIER TNAMESPACE TIDENTIFIER { $$ = new std::string(*$2 + "::" + *$4) } +type : TSELECT TIDENTIFIER { $$ = $2; } + | TSELECT TIDENTIFIER TNAMESPACE TIDENTIFIER { $$ = StringFactory::New(*$2 + "::" + *$4); } -subname : { $$ = 0 } - | TSUB TIDENTIFIER { $$ = $2 } +subname : { $$ = 0; } + | TSUB TIDENTIFIER { $$ = $2; } -count : { $$ = 0 } - | TCOUNT TNUMBER TSLICE TNUMBER { $$ = new Node_Slice($2,$4) } - | TCOUNT TNUMBER TSLICE { $$ = new Node_Slice($2) } - | TCOUNT TNUMBER { $$ = new Node_Slice($2,$2) } +count : { $$ = 0; } + | TCOUNT TNUMBER TSLICE TNUMBER { $$ = new Node_Slice($2,$4); } + | TCOUNT TNUMBER TSLICE { $$ = new Node_Slice($2); } + | TCOUNT TNUMBER { $$ = new Node_Slice($2,$2); } -matchline : type subname count { $$ = new Node_Object($1,$2,$3) } +matchline : type subname count { $$ = new Node_Object($1,$2,$3); } matchlines : matchline { $$ = new Node_Block($1); } | matchlines matchline { $$ = $1 ; $$->Objects.emplace_back($2); } -block : matchlines { $$ = $1 } +block : matchlines { $$ = $1; } -filter: block { TopBlock = $1 } +filter: block { TopBlock = $1; } ; diff --git a/src/Gui/lex.SelectionFilter.c b/src/Gui/lex.SelectionFilter.c index 1518012aa4..4e0c03f462 100644 --- a/src/Gui/lex.SelectionFilter.c +++ b/src/Gui/lex.SelectionFilter.c @@ -856,7 +856,7 @@ case 8: YY_RULE_SETUP #line 41 "SelectionFilter.l" { - yylval.string = new std::string(SelectionFiltertext); + yylval.string = StringFactory::New(SelectionFiltertext); return TIDENTIFIER; } YY_BREAK From 0edbea13163e58a9ad5abc6add6b98b2102e0a1b Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 23 Apr 2021 11:02:19 +0200 Subject: [PATCH 138/178] Base: use Python's weak reference mechanism to avoid memory leaks due to cyclic dependencies --- src/Base/PyObjectBase.cpp | 127 ++++++++++++++++++++++++++++++++++++-- src/Base/PyObjectBase.h | 3 + 2 files changed, 125 insertions(+), 5 deletions(-) diff --git a/src/Base/PyObjectBase.cpp b/src/Base/PyObjectBase.cpp index 6e6a8e44f6..bc8d6d2d86 100644 --- a/src/Base/PyObjectBase.cpp +++ b/src/Base/PyObjectBase.cpp @@ -39,9 +39,19 @@ using namespace Base; PyObject* Base::BaseExceptionFreeCADError = 0; PyObject* Base::BaseExceptionFreeCADAbort = 0; +#ifdef ATTR_TRACKING +typedef struct { + PyObject_HEAD + PyObject* baseobject; + PyObject* weakreflist; /* List of weak references */ +} PyBaseProxy; +#endif + // Constructor PyObjectBase::PyObjectBase(void* p,PyTypeObject *T) - : _pcTwinPointer(p), attrDict(0) + : _pcTwinPointer(p) + , baseProxy(nullptr) + , attrDict(nullptr) { Py_TYPE(this) = T; _Py_NewReference(this); @@ -59,6 +69,8 @@ PyObjectBase::~PyObjectBase() #ifdef FC_LOGPYOBJECTS Base::Console().Log("PyO-: %s (%p)\n",Py_TYPE(this)->tp_name, this); #endif + if (baseProxy && reinterpret_cast(baseProxy)->baseobject == this) + Py_DECREF(baseProxy); Py_XDECREF(attrDict); } @@ -80,6 +92,73 @@ PyObjectBase::~PyObjectBase() # pragma clang diagnostic ignored "-Wdeprecated-declarations" #endif +static void +PyBaseProxy_dealloc(PyObject* self) +{ + /* Clear weakrefs first before calling any destructors */ + if (reinterpret_cast(self)->weakreflist != NULL) + PyObject_ClearWeakRefs(self); + Py_TYPE(self)->tp_free(self); +} + +static PyTypeObject PyBaseProxyType = { + PyVarObject_HEAD_INIT(NULL, 0) + "PyBaseProxy", /*tp_name*/ + sizeof(PyBaseProxy), /*tp_basicsize*/ + 0, /*tp_itemsize*/ + PyBaseProxy_dealloc, /*tp_dealloc*/ + 0, /*tp_print*/ + 0, /*tp_getattr*/ + 0, /*tp_setattr*/ + 0, /*tp_compare*/ + 0, /*tp_repr*/ + 0, /*tp_as_number*/ + 0, /*tp_as_sequence*/ + 0, /*tp_as_mapping*/ + 0, /*tp_hash*/ + 0, /*tp_call */ + 0, /*tp_str */ + 0, /*tp_getattro*/ + 0, /*tp_setattro*/ + 0, /* tp_as_buffer */ + Py_TPFLAGS_BASETYPE | Py_TPFLAGS_DEFAULT, /*tp_flags */ + "Proxy class", /*tp_doc */ + 0, /*tp_traverse */ + 0, /*tp_clear */ + 0, /*tp_richcompare */ + offsetof(PyBaseProxy, weakreflist), /*tp_weaklistoffset */ + 0, /*tp_iter */ + 0, /*tp_iternext */ + 0, /*tp_methods */ + 0, /*tp_members */ + 0, /*tp_getset */ + 0, /*tp_base */ + 0, /*tp_dict */ + 0, /*tp_descr_get */ + 0, /*tp_descr_set */ + 0, /*tp_dictoffset */ + 0, /*tp_init */ + 0, /*tp_alloc */ + 0, /*tp_new */ + 0, /*tp_free Low-level free-memory routine */ + 0, /*tp_is_gc For PyObject_IS_GC */ + 0, /*tp_bases */ + 0, /*tp_mro method resolution order */ + 0, /*tp_cache */ + 0, /*tp_subclasses */ + 0, /*tp_weaklist */ + 0, /*tp_del */ + 0, /*tp_version_tag */ + 0 /*tp_finalize */ +#if PY_VERSION_HEX >= 0x03090000 + ,0 /*tp_vectorcall */ +#elif PY_VERSION_HEX >= 0x03080000 + ,0 /*tp_vectorcall */ + /* bpo-37250: kept for backwards compatibility in CPython 3.8 only */ + ,0 /*tp_print */ +#endif +}; + PyTypeObject PyObjectBase::Type = { PyVarObject_HEAD_INIT(&PyType_Type,0) "PyObjectBase", /*tp_name*/ @@ -145,6 +224,39 @@ PyTypeObject PyObjectBase::Type = { # pragma clang diagnostic pop #endif +#ifdef ATTR_TRACKING +PyObject* createWeakRef(PyObjectBase* ptr) +{ + static bool init = false; + if (!init) { + init = true; + PyType_Ready(&PyBaseProxyType); + } + + PyObject* proxy = ptr->baseProxy; + if (!proxy) { + proxy = PyType_GenericAlloc(&PyBaseProxyType, 0); + ptr->baseProxy = proxy; + reinterpret_cast(proxy)->baseobject = ptr; + } + + PyObject* ref = PyWeakref_NewRef(proxy, nullptr); + return ref; +} + +PyObjectBase* getFromWeakRef(PyObject* ref) +{ + if (ref) { + PyObject* proxy = PyWeakref_GetObject(ref); + if (proxy && PyObject_TypeCheck(proxy, &PyBaseProxyType)) { + return static_cast(reinterpret_cast(proxy)->baseobject); + } + } + + return nullptr; +} +#endif + /*------------------------------ * PyObjectBase Methods -- Every class, even the abstract one should have a Methods ------------------------------*/ @@ -329,6 +441,8 @@ PyObject *PyObjectBase::_repr(void) return Py_BuildValue("s", a.str().c_str()); } +// Tracking functions + void PyObjectBase::resetAttribute() { if (attrDict) { @@ -354,6 +468,7 @@ void PyObjectBase::setAttributeOf(const char* attr, PyObject* par) if (!attrDict) { attrDict = PyDict_New(); } + PyObject* key1 = PyBytes_FromString("__attribute_of_parent__"); PyObject* key2 = PyBytes_FromString("__instance_of_parent__"); PyObject* attro = PyUnicode_FromString(attr); @@ -363,7 +478,6 @@ void PyObjectBase::setAttributeOf(const char* attr, PyObject* par) Py_DECREF(key1); Py_DECREF(key2); } - void PyObjectBase::startNotify() { if (!shouldNotify()) @@ -398,12 +512,12 @@ void PyObjectBase::startNotify() Py_DECREF(key2); } } - PyObject* PyObjectBase::getTrackedAttribute(const char* attr) { - PyObject* obj = 0; + PyObject* obj = nullptr; if (attrDict) { obj = PyDict_GetItemString(attrDict, attr); + obj = getFromWeakRef(obj); } return obj; } @@ -414,7 +528,10 @@ void PyObjectBase::trackAttribute(const char* attr, PyObject* obj) attrDict = PyDict_New(); } - PyDict_SetItemString(attrDict, attr, obj); + PyObject* obj_ref = createWeakRef(static_cast(obj)); + if (obj_ref) { + PyDict_SetItemString(attrDict, attr, obj_ref); + } } void PyObjectBase::untrackAttribute(const char* attr) diff --git a/src/Base/PyObjectBase.h b/src/Base/PyObjectBase.h index 593253f89e..a37dc0cf78 100644 --- a/src/Base/PyObjectBase.h +++ b/src/Base/PyObjectBase.h @@ -345,6 +345,9 @@ protected: /// pointer to the handled class void * _pcTwinPointer; +public: + PyObject* baseProxy; + private: PyObject* attrDict; }; From 57c708a4d6636e4444a2bf697e1d6f23df7fded5 Mon Sep 17 00:00:00 2001 From: Andrew White Date: Thu, 22 Apr 2021 22:34:25 -0400 Subject: [PATCH 139/178] Add human readable version to mac app bundle CFBundleVersion is used by the system to identify app versions, but CFBundleShortVersionString is what Finder shows about the app when using the Get Info screen. Having the version available there makes it easer to check app versions without launching FreeCAD --- src/MacAppBundle/FreeCAD.app/Contents/Info.plist | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MacAppBundle/FreeCAD.app/Contents/Info.plist b/src/MacAppBundle/FreeCAD.app/Contents/Info.plist index 54e858d0dc..c8683067e7 100644 --- a/src/MacAppBundle/FreeCAD.app/Contents/Info.plist +++ b/src/MacAppBundle/FreeCAD.app/Contents/Info.plist @@ -21,7 +21,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - + VERSION_STRING_FROM_CMAKE CFBundleSignature ???? CFBundleVersion From 8d7281e97bb2c49fa42688614cf31d08417eb916 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Fri, 23 Apr 2021 15:46:39 +0200 Subject: [PATCH 140/178] Draft: Fixed default color for new dimensions (now uses DefautTextColor instead of DefaultLineColor) --- src/Mod/Draft/draftutils/gui_utils.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Mod/Draft/draftutils/gui_utils.py b/src/Mod/Draft/draftutils/gui_utils.py index 07db9887dd..936d868322 100644 --- a/src/Mod/Draft/draftutils/gui_utils.py +++ b/src/Mod/Draft/draftutils/gui_utils.py @@ -381,7 +381,12 @@ def format_object(target, origin=None): if "PointColor" in obrep.PropertiesList: obrep.PointColor = lcol if "LineColor" in obrep.PropertiesList: - obrep.LineColor = lcol + if hasattr(obrep,"FontName") and (not hasattr(obrep,"TextColor")): + # dimensions and other objects with text but no specific + # TextColor property. TODO: Add TextColor property to dimensions + obrep.LineColor = tcol + else: + obrep.LineColor = lcol if "ShapeColor" in obrep.PropertiesList: obrep.ShapeColor = fcol else: From 9209d35390007e52dffce9e04541d51ef261c1a0 Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 23 Apr 2021 17:05:13 +0200 Subject: [PATCH 141/178] TD: fix memory leaks in BaseGeom::baseFactory() and make code more readable --- src/Mod/TechDraw/App/Geometry.cpp | 73 +++++++------------------------ 1 file changed, 17 insertions(+), 56 deletions(-) diff --git a/src/Mod/TechDraw/App/Geometry.cpp b/src/Mod/TechDraw/App/Geometry.cpp index a242ee9298..13a5aa9133 100644 --- a/src/Mod/TechDraw/App/Geometry.cpp +++ b/src/Mod/TechDraw/App/Geometry.cpp @@ -102,7 +102,7 @@ Wire::Wire(const TopoDS_Wire &w) const auto edge( TopoDS::Edge(edges.Current()) ); BaseGeom* bg = BaseGeom::baseFactory(edge); if (bg != nullptr) { - geoms.push_back( BaseGeom::baseFactory(edge) ); + geoms.push_back(bg); } else { Base::Console().Log("G::Wire - baseFactory returned null geom ptr\n"); } @@ -433,17 +433,16 @@ bool BaseGeom::closed(void) //! Convert 1 OCC edge into 1 BaseGeom (static factory method) BaseGeom* BaseGeom::baseFactory(TopoDS_Edge edge) { - BaseGeom* result = NULL; + std::unique_ptr result; if (edge.IsNull()) { Base::Console().Message("BG::baseFactory - input edge is NULL \n"); } //weed out rubbish edges before making geometry if (!validateEdge(edge)) { - return result; + return nullptr; } - Generic *primitive = new Generic(edge); - result = primitive; + result = std::make_unique(edge); BRepAdaptor_Curve adapt(edge); switch(adapt.GetType()) { @@ -457,11 +456,9 @@ BaseGeom* BaseGeom::baseFactory(TopoDS_Edge edge) //if first to last is > 1 radian? are circles parameterize by rotation angle? //if start and end points are close? if (fabs(l-f) > 1.0 && s.SquareDistance(e) < 0.001) { - Circle *circle = new Circle(edge); - result = circle; + result = std::make_unique(edge); } else { - AOC *aoc = new AOC(edge); - result = aoc; + result = std::make_unique(edge); } } break; case GeomAbs_Ellipse: { @@ -470,17 +467,15 @@ BaseGeom* BaseGeom::baseFactory(TopoDS_Edge edge) gp_Pnt s = adapt.Value(f); gp_Pnt e = adapt.Value(l); if (fabs(l-f) > 1.0 && s.SquareDistance(e) < 0.001) { - Ellipse *ellipse = new Ellipse(edge); - result = ellipse; + result = std::make_unique(edge); } else { - AOE *aoe = new AOE(edge); - result = aoe; + result = std::make_unique(edge); } } break; case GeomAbs_BezierCurve: { Handle(Geom_BezierCurve) bez = adapt.Bezier(); //if (bez->Degree() < 4) { - result = new BezierSegment(edge); + result = std::make_unique(edge); if (edge.Orientation() == TopAbs_REVERSED) { result->reversed = true; } @@ -488,37 +483,25 @@ BaseGeom* BaseGeom::baseFactory(TopoDS_Edge edge) // OCC is quite happy with Degree > 3 but QtGui handles only 2,3 } break; case GeomAbs_BSplineCurve: { - BSpline *bspline = 0; - Generic* gen = NULL; - Circle* circ = nullptr; - AOC* aoc = nullptr; + std::unique_ptr bspline; TopoDS_Edge circEdge; bool isArc = false; try { - bspline = new BSpline(edge); + bspline = std::make_unique(edge); if (bspline->isLine()) { - gen = new Generic(edge); - result = gen; - delete bspline; - bspline = nullptr; + result = std::make_unique(edge); } else { circEdge = bspline->asCircle(isArc); if (!circEdge.IsNull()) { if (isArc) { - aoc = new AOC(circEdge); - result = aoc; - delete bspline; - bspline = nullptr; + result = std::make_unique(circEdge); } else { - circ = new Circle(circEdge); - result = circ; - delete bspline; - bspline = nullptr; + result = std::make_unique(circEdge); } } else { // Base::Console().Message("Geom::baseFactory - circEdge is Null\n"); - result = bspline; + result = std::move(bspline); } } break; @@ -526,41 +509,19 @@ BaseGeom* BaseGeom::baseFactory(TopoDS_Edge edge) catch (const Standard_Failure& e) { Base::Console().Error("Geom::baseFactory - OCC error - %s - while making spline\n", e.GetMessageString()); - if (bspline != nullptr) { - delete bspline; - bspline = nullptr; - } - if (gen != nullptr) { - delete gen; - gen = nullptr; - } break; } catch (...) { Base::Console().Error("Geom::baseFactory - unknown error occurred while making spline\n"); - if (bspline != nullptr) { - delete bspline; - bspline = nullptr; - } - if (gen != nullptr) { - delete gen; - gen = nullptr; - } break; } break; } // end bspline case default: { - primitive = new Generic(edge); - result = primitive; + result = std::make_unique(edge); } break; } - - if ( (primitive != nullptr) && - (primitive != result) ) { - delete primitive; - } - return result; + return result.release(); } bool BaseGeom::validateEdge(TopoDS_Edge edge) From a7d83b5e15a6641178682fa8d629d35d4f9c86cf Mon Sep 17 00:00:00 2001 From: Tomas Pavlicek Date: Tue, 9 Feb 2021 23:17:40 +0100 Subject: [PATCH 142/178] Sketcher - Add new Split Edge action --- src/Mod/Part/App/Geometry.cpp | 2 +- src/Mod/Part/App/Geometry.h | 2 +- src/Mod/Sketcher/App/SketchObject.cpp | 356 +++++++++- src/Mod/Sketcher/App/SketchObject.h | 12 +- src/Mod/Sketcher/App/SketchObjectPy.xml | 5 + src/Mod/Sketcher/App/SketchObjectPyImp.cpp | 21 +- src/Mod/Sketcher/Gui/CommandCreateGeo.cpp | 120 ++++ src/Mod/Sketcher/Gui/Resources/Sketcher.qrc | 2 + .../icons/geometry/Sketcher_Split.svg | 671 ++++++++++++++++++ .../pointers/Sketcher_Pointer_Splitting.svg | 98 +++ src/Mod/Sketcher/Gui/Workbench.cpp | 1 + 11 files changed, 1276 insertions(+), 14 deletions(-) create mode 100644 src/Mod/Sketcher/Gui/Resources/icons/geometry/Sketcher_Split.svg create mode 100644 src/Mod/Sketcher/Gui/Resources/icons/pointers/Sketcher_Pointer_Splitting.svg diff --git a/src/Mod/Part/App/Geometry.cpp b/src/Mod/Part/App/Geometry.cpp index e2dc02e7bb..e6d6396ca9 100644 --- a/src/Mod/Part/App/Geometry.cpp +++ b/src/Mod/Part/App/Geometry.cpp @@ -684,7 +684,7 @@ bool GeomCurve::normalAt(double u, Base::Vector3d& dir) const return false; } -bool GeomCurve::intersect( GeomCurve * c, +bool GeomCurve::intersect( const GeomCurve *c, std::vector>& points, double tol) const { diff --git a/src/Mod/Part/App/Geometry.h b/src/Mod/Part/App/Geometry.h index fea71fbbbc..4cbd45c540 100644 --- a/src/Mod/Part/App/Geometry.h +++ b/src/Mod/Part/App/Geometry.h @@ -197,7 +197,7 @@ public: double curvatureAt(double u) const; double length(double u, double v) const; bool normalAt(double u, Base::Vector3d& dir) const; - bool intersect(GeomCurve * c, + bool intersect(const GeomCurve *c, std::vector>& points, double tol = Precision::Confusion()) const; diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index 9fc6e73921..e671585ecf 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -1647,7 +1647,7 @@ void SketchObject::transferFilletConstraints(int geoId1, PointPos posId1, int ge this->Constraints.setValues(std::move(newConstraints)); } -int SketchObject::transferConstraints(int fromGeoId, PointPos fromPosId, int toGeoId, PointPos toPosId) +int SketchObject::transferConstraints(int fromGeoId, PointPos fromPosId, int toGeoId, PointPos toPosId, bool tangencyHolds) { Base::StateLocker lock(managedoperation, true); // no need to check input data validity as this is an sketchobject managed operation. @@ -1659,15 +1659,17 @@ int SketchObject::transferConstraints(int fromGeoId, PointPos fromPosId, int toG !(vals[i]->Second == toGeoId && vals[i]->SecondPos == toPosId) && !(toGeoId < 0 && vals[i]->Second <0) ) { - // Nothing guarantees that a tangent can be freely transferred to another coincident point, as - // the transfer destination edge most likely won't be intended to be tangent. However, if it is - // an end to end point tangency, the user expects it to be substituted by a coincidence constraint. std::unique_ptr constNew(newVals[i]->clone()); constNew->First = toGeoId; constNew->FirstPos = toPosId; - if(vals[i]->Type == Sketcher::Tangent || vals[i]->Type == Sketcher::Perpendicular){ - constNew->Type = Sketcher::Coincident; + // If not explicitly confirmed, nothing guarantees that a tangent can be freely transferred to another coincident + // point, as the transfer destination edge most likely won't be intended to be tangent. However, if it is + // an end to end point tangency, the user expects it to be substituted by a coincidence constraint. + if (vals[i]->Type == Sketcher::Tangent || vals[i]->Type == Sketcher::Perpendicular) { + if (!tangencyHolds) { + constNew->Type = Sketcher::Coincident; + } } // With respect to angle constraints, if it is a DeepSOIC style angle constraint (segment+segment+point), // then no problem arises as the segments are PosId=none. In this case there is no call to this function. @@ -1690,11 +1692,13 @@ int SketchObject::transferConstraints(int fromGeoId, PointPos fromPosId, int toG std::unique_ptr constNew(newVals[i]->clone()); constNew->Second = toGeoId; constNew->SecondPos = toPosId; - // Nothing guarantees that a tangent can be freely transferred to another coincident point, as - // the transfer destination edge most likely won't be intended to be tangent. However, if it is + // If not explicitly confirmed, nothing guarantees that a tangent can be freely transferred to another coincident + // point, as the transfer destination edge most likely won't be intended to be tangent. However, if it is // an end to end point tangency, the user expects it to be substituted by a coincidence constraint. - if(vals[i]->Type == Sketcher::Tangent || vals[i]->Type == Sketcher::Perpendicular) { - constNew->Type = Sketcher::Coincident; + if (vals[i]->Type == Sketcher::Tangent || vals[i]->Type == Sketcher::Perpendicular) { + if (!tangencyHolds) { + constNew->Type = Sketcher::Coincident; + } } else if(vals[i]->Type == Sketcher::Angle) { continue; @@ -1713,6 +1717,19 @@ int SketchObject::transferConstraints(int fromGeoId, PointPos fromPosId, int toG return 0; } +void SketchObject::swapInvolvedGeometry(Constraint *constraint, int fromGeoId, int toGeoId) +{ + if (constraint->First == fromGeoId) { + constraint->First = toGeoId; + } + if (constraint->Second == fromGeoId) { + constraint->Second = toGeoId; + } + if (constraint->Third == fromGeoId) { + constraint->Third = toGeoId; + } +} + int SketchObject::fillet(int GeoId, PointPos PosId, double radius, bool trim, bool createCorner) { if (GeoId < 0 || GeoId > getHighestCurveIndex()) @@ -2964,6 +2981,312 @@ int SketchObject::trim(int GeoId, const Base::Vector3d& point) return -1; } +int SketchObject::split(int GeoId, const Base::Vector3d &point) +{ + // No need to check input data validity as this is an sketchobject managed operation + + Base::StateLocker lock(managedoperation, true); + + if (GeoId < 0 || GeoId > getHighestCurveIndex()) { + return -1; + } + + const Part::Geometry *geo = getGeometry(GeoId); + std::vector newGeometries; + std::vector newIds; + std::vector newConstraints; + bool ok = false; + + Base::Vector3d startPoint, endPoint, splitPoint; + double radius, startAngle, endAngle, splitAngle; + unsigned int longestPart = 0; + + do { + if (geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + const Part::GeomLineSegment *lineSegm = static_cast(geo); + + startPoint = lineSegm->getStartPoint(); + endPoint = lineSegm->getEndPoint(); + splitPoint = point.Perpendicular(startPoint, endPoint - startPoint); + if ((endPoint - splitPoint).Length() > (splitPoint - startPoint).Length()) { + longestPart = 1; + } + + Part::GeomLineSegment *newLine = static_cast(lineSegm->copy()); + newGeometries.push_back(newLine); + + newLine->setPoints(startPoint, splitPoint); + int newId = addGeometry(newLine); + if (newId < 0) { + continue; + } + newIds.push_back(newId); + setConstruction(newId, GeometryFacade::getConstruction(geo)); + + newLine = static_cast(lineSegm->copy()); + newGeometries.push_back(newLine); + + newLine->setPoints(splitPoint, endPoint); + newId = addGeometry(newLine); + if (newId < 0) { + continue; + } + newIds.push_back(newId); + setConstruction(newId, GeometryFacade::getConstruction(geo)); + + Constraint *joint = new Constraint(); + joint->Type = Coincident; + joint->First = newIds[0]; + joint->FirstPos = end; + joint->Second = newIds[1]; + joint->SecondPos = start; + newConstraints.push_back(joint); + + transferConstraints(GeoId, start, newIds[0], start, true); + transferConstraints(GeoId, end, newIds[1], end, true); + ok = true; + } + else if (geo->getTypeId() == Part::GeomCircle::getClassTypeId()) { + const Part::GeomCircle *circle = static_cast(geo); + + Base::Vector3d center(circle->getLocation()); + Base::Vector3d dir(point - center); + radius = circle->getRadius(); + + splitAngle = atan2(dir.y, dir.x); + startAngle = splitAngle; + endAngle = splitAngle + M_PI*2.0; + + splitPoint = Base::Vector3d(center.x + radius*cos(splitAngle), center.y + radius*sin(splitAngle)); + startPoint = splitPoint; + endPoint = splitPoint; + + Part::GeomArcOfCircle *arc = new Part::GeomArcOfCircle(); + newGeometries.push_back(arc); + + arc->setLocation(center); + arc->setRadius(radius); + arc->setRange(startAngle, endAngle, false); + int arcId = addGeometry(arc); + if (arcId < 0) { + continue; + } + newIds.push_back(arcId); + setConstruction(arcId, GeometryFacade::getConstruction(geo)); + + transferConstraints(GeoId, mid, arcId, mid); + ok = true; + } + else if (geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + const Part::GeomArcOfCircle *arc = static_cast(geo); + + startPoint = arc->getStartPoint(); + endPoint = arc->getEndPoint(); + + Base::Vector3d center(arc->getLocation()); + radius = arc->getRadius(); + arc->getRange(startAngle, endAngle, false); + + Base::Vector3d dir(point - center); + splitAngle = atan2(dir.y, dir.x); + if (splitAngle < startAngle) { + splitAngle += M_PI*2.0; + } + if (endAngle - splitAngle > splitAngle - startAngle) { + longestPart = 1; + } + + splitPoint = Base::Vector3d(center.x + radius*cos(splitAngle), center.y + radius*sin(splitAngle)); + startPoint = splitPoint; + endPoint = splitPoint; + + Part::GeomArcOfCircle *newArc = static_cast(arc->copy()); + newGeometries.push_back(newArc); + + newArc->setRange(startAngle, splitAngle, false); + int newId = addGeometry(newArc); + if (newId < 0) { + continue; + } + newIds.push_back(newId); + setConstruction(newId, GeometryFacade::getConstruction(geo)); + + newArc = static_cast(arc->copy()); + newGeometries.push_back(newArc); + + newArc->setRange(splitAngle, endAngle, false); + newId = addGeometry(newArc); + if (newId < 0) { + continue; + } + newIds.push_back(newId); + setConstruction(newId, GeometryFacade::getConstruction(geo)); + + Constraint *joint = new Constraint(); + joint->Type = Coincident; + joint->First = newIds[0]; + joint->FirstPos = end; + joint->Second = newIds[1]; + joint->SecondPos = start; + newConstraints.push_back(joint); + + joint = new Constraint(); + joint->Type = Coincident; + joint->First = newIds[0]; + joint->FirstPos = mid; + joint->Second = newIds[1]; + joint->SecondPos = mid; + newConstraints.push_back(joint); + + transferConstraints(GeoId, start, newIds[0], start, true); + transferConstraints(GeoId, mid, newIds[0], mid); + transferConstraints(GeoId, end, newIds[1], end, true); + ok = true; + } + } + while (false); + + if (ok) { + std::vector oldConstraints; + getAppliedConstraints(GeoId, oldConstraints); + + for (unsigned int i = 0; i < oldConstraints.size(); ++i) { + + Constraint *con = this->Constraints.getValues()[oldConstraints[i]]; + int conId = con->First; + PointPos conPos = con->FirstPos; + if (conId == GeoId) { + conId = con->Second; + conPos = con->SecondPos; + } + + bool transferToAll = false; + switch (con->Type) { + case Horizontal: + case Vertical: + case Parallel: { + transferToAll = geo->getTypeId() == Part::GeomLineSegment::getClassTypeId(); + break; + } + case Tangent: + case Perpendicular: { + unsigned int initial = 0; + unsigned int limit = newIds.size(); + + if (geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + const Part::Geometry *conGeo = getGeometry(conId); + if (conGeo && conGeo->isDerivedFrom(Part::GeomCurve::getClassTypeId())) { + std::vector> intersections; + bool intersects[2]; + + intersects[0] = static_cast(newGeometries[0])-> + intersect(static_cast(conGeo), intersections); + intersects[1] = static_cast(newGeometries[1])-> + intersect(static_cast(conGeo), intersections); + + initial = longestPart; + if (intersects[0] != intersects[1]) { + initial = intersects[1] ? 1 : 0; + } + limit = initial + 1; + } + } + + for (unsigned int i = initial; i < limit; ++i) { + Constraint *trans = con->copy(); + swapInvolvedGeometry(trans, GeoId, newIds[i]); + newConstraints.push_back(trans); + } + break; + } + case Distance: + case DistanceX: + case DistanceY: + case PointOnObject: { + if (con->FirstPos == none && con->SecondPos == none) { + Constraint *dist = con->copy(); + dist->First = newIds[0]; + dist->FirstPos = start; + dist->Second = newIds[1]; + dist->SecondPos = end; + newConstraints.push_back(dist); + } + else { + Constraint *trans = con->copy(); + trans->First = conId; + trans->FirstPos = conPos; + trans->SecondPos = none; + + Base::Vector3d conPoint(getPoint(conId, conPos)); + int targetId = newIds[0]; + + if (geo->getTypeId() == Part::GeomLineSegment::getClassTypeId()) { + Base::Vector3d projPoint(conPoint.Perpendicular(startPoint, endPoint - startPoint)); + Base::Vector3d splitDir = splitPoint - startPoint; + if ((projPoint - startPoint)*splitDir > splitDir*splitDir) { + targetId = newIds[1]; + } + } + else if (geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + Base::Vector3d conDir(conPoint - static_cast(geo)->getLocation()); + double conAngle = atan2(conDir.y, conDir.x); + if (conAngle < startAngle) { + conAngle += M_PI*2.0; + } + if (conAngle > splitAngle) { + targetId = newIds[1]; + } + } + trans->Second = targetId; + + newConstraints.push_back(trans); + } + break; + } + case Radius: + case Diameter: + case Equal: { + transferToAll = geo->getTypeId() == Part::GeomCircle::getClassTypeId() + || geo->getTypeId() == Part::GeomArcOfCircle::getClassTypeId(); + break; + } + default: + // Release other constraints + break; + } + + if (transferToAll) { + for (unsigned int i = 0; i < newIds.size(); ++i) { + Constraint *trans = con->copy(); + swapInvolvedGeometry(trans, GeoId, newIds[i]); + newConstraints.push_back(trans); + } + } + } + + if (noRecomputes) { + solve(); + } + + delConstraints(oldConstraints); + addConstraints(newConstraints); + } + + for (std::vector::iterator it = newGeometries.begin(); it != newGeometries.end(); ++it) { + delete *it; + } + for (std::vector::iterator it = newConstraints.begin(); it != newConstraints.end(); ++it) { + delete *it; + } + + if (ok) { + delGeometry(GeoId); + return 0; + } + + return -1; +} + bool SketchObject::isExternalAllowed(App::Document *pDoc, App::DocumentObject *pObj, eReasonList* rsn) const { if (rsn) @@ -6826,6 +7149,19 @@ bool SketchObject::arePointsCoincident(int GeoId1, PointPos PosId1, return false; } +void SketchObject::getAppliedConstraints(int GeoId, std::vector &constraintList) +{ + const std::vector &constraints = this->Constraints.getValues(); + int i = 0; + + for (std::vector::const_iterator it = constraints.begin(); it != constraints.end(); ++it) { + if ((*it)->First == GeoId || (*it)->Second == GeoId || (*it)->Third == GeoId) { + constraintList.push_back(i); + } + ++i; + } +} + void SketchObject::appendConflictMsg(const std::vector &conflicting, std::string &msg) { appendConstraintsMsg(conflicting, diff --git a/src/Mod/Sketcher/App/SketchObject.h b/src/Mod/Sketcher/App/SketchObject.h index 462692f2df..2d1def3f9f 100644 --- a/src/Mod/Sketcher/App/SketchObject.h +++ b/src/Mod/Sketcher/App/SketchObject.h @@ -157,7 +157,12 @@ public: /// Deletes all constraints referencing an external geometry int delConstraintsToExternal(); /// transfers all constraints of a point to a new point - int transferConstraints(int fromGeoId, PointPos fromPosId, int toGeoId, PointPos toPosId); + int transferConstraints(int fromGeoId, PointPos fromPosId, int toGeoId, PointPos toPosId, + bool tangencyHolds = false); + + /// swaps original GeoId for a new one + void swapInvolvedGeometry(Constraint *constraint, int fromGeoId, int toGeoId); + /// Carbon copy another sketch geometry and constraints int carbonCopy(App::DocumentObject * pObj, bool construction = true); /// add an external geometry reference @@ -282,6 +287,8 @@ public: int trim(int geoId, const Base::Vector3d& point); /// extend a curve int extend(int geoId, double increment, int endPoint); + /// split a curve + int split(int geoId, const Base::Vector3d &point); /// adds symmetric geometric elements with respect to the refGeoId (line or point) int addSymmetric(const std::vector &geoIdList, int refGeoId, Sketcher::PointPos refPosId=Sketcher::none); @@ -358,6 +365,9 @@ public: void getDirectlyCoincidentPoints(int VertexId, std::vector &GeoIdList, std::vector &PosIdList); bool arePointsCoincident(int GeoId1, PointPos PosId1, int GeoId2, PointPos PosId2); + /// fetches all constraints involving given GeoId + void getAppliedConstraints(int GeoId, std::vector &constraintList); + /// generates a warning message about constraint conflicts and appends it to the given message static void appendConflictMsg(const std::vector &conflicting, std::string &msg); /// generates a warning message about redundant constraints and appends it to the given message diff --git a/src/Mod/Sketcher/App/SketchObjectPy.xml b/src/Mod/Sketcher/App/SketchObjectPy.xml index 11f340481c..20f993e6a4 100644 --- a/src/Mod/Sketcher/App/SketchObjectPy.xml +++ b/src/Mod/Sketcher/App/SketchObjectPy.xml @@ -217,6 +217,11 @@ If there is no such constraint an exception is raised. extend a curve to new start and end positions + + + split a curve with a given id at a given reference point + + add a symmetric geometric objects to the sketch with respect to a reference point or line diff --git a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp index 4600c9e248..1162db047e 100644 --- a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp +++ b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp @@ -570,7 +570,7 @@ PyObject* SketchObjectPy::delConstraintOnPoint(PyObject *args) if (!PyArg_ParseTuple(args, "i|i", &Index, &pos)) return 0; - if (pos>=0 && pos<3) { // Sketcher::none Sketcher::mid + if (pos>=0 && pos<=3) { // Sketcher::none Sketcher::mid if (this->getSketchObjectPtr()->delConstraintOnPoint(Index,(Sketcher::PointPos)pos)) { std::stringstream str; str << "Not able to delete a constraint on point with the given index: " << Index @@ -1120,6 +1120,25 @@ PyObject* SketchObjectPy::extend(PyObject *args) return 0; } +PyObject* SketchObjectPy::split(PyObject *args) +{ + PyObject *pcObj; + int GeoId; + + if (!PyArg_ParseTuple(args, "iO!", &GeoId, &(Base::VectorPy::Type), &pcObj)) + return 0; + + Base::Vector3d v1 = static_cast(pcObj)->value(); + if (this->getSketchObjectPtr()->split(GeoId,v1)) { + std::stringstream str; + str << "Not able to split curve with the given index: " << GeoId; + PyErr_SetString(PyExc_ValueError, str.str().c_str()); + return 0; + } + + Py_Return; +} + PyObject* SketchObjectPy::addSymmetric(PyObject *args) { PyObject *pcObj; diff --git a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp index 25a6be8ae6..e2f28175b1 100644 --- a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp +++ b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp @@ -5904,6 +5904,125 @@ bool CmdSketcherExtend::isActive(void) } +// ====================================================================================== + +namespace SketcherGui { + class SplittingSelection : public Gui::SelectionFilterGate + { + App::DocumentObject* object; + public: + SplittingSelection(App::DocumentObject* obj) + : Gui::SelectionFilterGate((Gui::SelectionFilter*)0), object(obj) + {} + + bool allow(App::Document * /*pDoc*/, App::DocumentObject *pObj, const char *sSubName) + { + if (pObj != this->object) + return false; + if (!sSubName || sSubName[0] == '\0') + return false; + std::string element(sSubName); + if (element.substr(0,4) == "Edge") { + int GeoId = std::atoi(element.substr(4,4000).c_str()) - 1; + Sketcher::SketchObject *Sketch = static_cast(object); + const Part::Geometry *geom = Sketch->getGeometry(GeoId); + if (geom->getTypeId() == Part::GeomLineSegment::getClassTypeId() + || geom->getTypeId() == Part::GeomCircle::getClassTypeId() + || geom->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + return true; + } + } + return false; + } + }; +} + +class DrawSketchHandlerSplitting: public DrawSketchHandler +{ +public: + DrawSketchHandlerSplitting() {} + virtual ~DrawSketchHandlerSplitting() + { + Gui::Selection().rmvSelectionGate(); + } + + virtual void activated(ViewProviderSketch *sketchgui) + { + Gui::Selection().clearSelection(); + Gui::Selection().rmvSelectionGate(); + Gui::Selection().addSelectionGate(new SplittingSelection(sketchgui->getObject())); + setCrosshairCursor("Sketcher_Pointer_Splitting"); + } + + virtual void mouseMove(Base::Vector2d onSketchPos) + { + Q_UNUSED(onSketchPos); + } + + virtual bool pressButton(Base::Vector2d onSketchPos) + { + Q_UNUSED(onSketchPos); + return true; + } + + virtual bool releaseButton(Base::Vector2d onSketchPos) + { + int GeoId = sketchgui->getPreselectCurve(); + if (GeoId >= 0) { + const Part::Geometry *geom = sketchgui->getSketchObject()->getGeometry(GeoId); + if (geom->getTypeId() == Part::GeomLineSegment::getClassTypeId() + || geom->getTypeId() == Part::GeomCircle::getClassTypeId() + || geom->getTypeId() == Part::GeomArcOfCircle::getClassTypeId()) { + try { + Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Split edge")); + Gui::cmdAppObjectArgs(sketchgui->getObject(), "split(%d,App.Vector(%f,%f,0))", + GeoId, onSketchPos.x, onSketchPos.y); + Gui::Command::commitCommand(); + tryAutoRecompute(static_cast(sketchgui->getObject())); + } + catch (const Base::Exception& e) { + Base::Console().Error("Failed to split edge: %s\n", e.what()); + Gui::Command::abortCommand(); + } + } + } + else { + sketchgui->purgeHandler(); + } + + return true; + } +}; + +DEF_STD_CMD_A(CmdSketcherSplit) + +//TODO: fix the translations for this +CmdSketcherSplit::CmdSketcherSplit() + : Command("Sketcher_Split") +{ + sAppModule = "Sketcher"; + sGroup = QT_TR_NOOP("Sketcher"); + sMenuText = QT_TR_NOOP("Split edge"); + sToolTipText = QT_TR_NOOP("Splits an edge into two while preserving constraints"); + sWhatsThis = "Sketcher_Split"; + sStatusTip = sToolTipText; + sPixmap = "Sketcher_Split"; + sAccel = "T,S"; + eType = ForEdit; +} + +void CmdSketcherSplit::activated(int iMsg) +{ + Q_UNUSED(iMsg); + ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerSplitting()); +} + +bool CmdSketcherSplit::isActive(void) +{ + return isCreateGeoActive(getActiveGuiDocument()); +} + + namespace SketcherGui { class ExternalSelection : public Gui::SelectionFilterGate { @@ -7061,6 +7180,7 @@ void CreateSketcherCommandsCreateGeo(void) //rcCmdMgr.addCommand(new CmdSketcherCreateDraftLine()); rcCmdMgr.addCommand(new CmdSketcherTrimming()); rcCmdMgr.addCommand(new CmdSketcherExtend()); + rcCmdMgr.addCommand(new CmdSketcherSplit()); rcCmdMgr.addCommand(new CmdSketcherExternal()); rcCmdMgr.addCommand(new CmdSketcherCarbonCopy()); } diff --git a/src/Mod/Sketcher/Gui/Resources/Sketcher.qrc b/src/Mod/Sketcher/Gui/Resources/Sketcher.qrc index 4dcefcaaf7..2b19b852cd 100644 --- a/src/Mod/Sketcher/Gui/Resources/Sketcher.qrc +++ b/src/Mod/Sketcher/Gui/Resources/Sketcher.qrc @@ -161,6 +161,7 @@ icons/geometry/Sketcher_CreateTriangle_Constr.svg icons/geometry/Sketcher_Extend.svg icons/geometry/Sketcher_External.svg + icons/geometry/Sketcher_Split.svg icons/geometry/Sketcher_ToggleConstruction.svg icons/geometry/Sketcher_Trimming.svg @@ -195,6 +196,7 @@ icons/pointers/Sketcher_Pointer_External.svg icons/pointers/Sketcher_Pointer_Regular_Polygon.svg icons/pointers/Sketcher_Pointer_Slot.svg + icons/pointers/Sketcher_Pointer_Splitting.svg icons/pointers/Sketcher_Pointer_Trimming.svg diff --git a/src/Mod/Sketcher/Gui/Resources/icons/geometry/Sketcher_Split.svg b/src/Mod/Sketcher/Gui/Resources/icons/geometry/Sketcher_Split.svg new file mode 100644 index 0000000000..65f04b8eae --- /dev/null +++ b/src/Mod/Sketcher/Gui/Resources/icons/geometry/Sketcher_Split.svg @@ -0,0 +1,671 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + [wmayer] + + + + 2011-10-10 + http://www.freecadweb.org/wiki/index.php?title=Artwork + + + FreeCAD + + + FreeCAD/src/Mod/Sketcher/Gui/Resources/icons/Sketcher_CreateLine.svg + + + FreeCAD LGPL2+ + + + https://www.gnu.org/copyleft/lesser.html + + + [agryson] Alexander Gryson + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Mod/Sketcher/Gui/Resources/icons/pointers/Sketcher_Pointer_Splitting.svg b/src/Mod/Sketcher/Gui/Resources/icons/pointers/Sketcher_Pointer_Splitting.svg new file mode 100644 index 0000000000..e0b739dc07 --- /dev/null +++ b/src/Mod/Sketcher/Gui/Resources/icons/pointers/Sketcher_Pointer_Splitting.svg @@ -0,0 +1,98 @@ + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + diff --git a/src/Mod/Sketcher/Gui/Workbench.cpp b/src/Mod/Sketcher/Gui/Workbench.cpp index 4b0abff114..c85a405f0e 100644 --- a/src/Mod/Sketcher/Gui/Workbench.cpp +++ b/src/Mod/Sketcher/Gui/Workbench.cpp @@ -265,6 +265,7 @@ inline void SketcherAddWorkbenchGeometries(T& geom) SketcherAddWorkspaceFillets(geom); geom << "Sketcher_Trimming" << "Sketcher_Extend" + << "Sketcher_Split" << "Sketcher_External" << "Sketcher_CarbonCopy" << "Sketcher_ToggleConstruction" From 841c328eb3c120cfe27a965030d04aae576f8e22 Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Sat, 24 Apr 2021 14:31:18 +0200 Subject: [PATCH 143/178] Sketcher: Changes to split edge functionality ============================================= This commit is directed to external functionality of the split() function. 1. getAppliedConstraints renamed to getConstraintIndices This is just for clarity being a general function 2. SwapInvolvedGeometry functionality moved to Constraint class Why? i. Because it is a specific operation on a constraint, it must not be a public function, as it does not define interface of the Sketch. ii. It could be a lambda or a private utility function, but them it would not be reusable. iii. It could be part of a helper class, but then, it is would be less reusable. 3. renaming of the flag passed to transferConstraints function --- src/Mod/Sketcher/App/Constraint.cpp | 13 +++++++++++ src/Mod/Sketcher/App/Constraint.h | 8 ++++++- src/Mod/Sketcher/App/SketchObject.cpp | 27 ++++++---------------- src/Mod/Sketcher/App/SketchObject.h | 9 +++----- src/Mod/Sketcher/App/SketchObjectPyImp.cpp | 2 +- 5 files changed, 31 insertions(+), 28 deletions(-) diff --git a/src/Mod/Sketcher/App/Constraint.cpp b/src/Mod/Sketcher/App/Constraint.cpp index 1b00d25061..82eecc011c 100644 --- a/src/Mod/Sketcher/App/Constraint.cpp +++ b/src/Mod/Sketcher/App/Constraint.cpp @@ -217,3 +217,16 @@ void Constraint::Restore(XMLReader &reader) if (reader.hasAttribute("IsActive")) isActive = reader.getAttributeAsInteger("IsActive") ? true : false; } + +void Constraint::substituteIndex(int fromGeoId, int toGeoId) +{ + if (this->First == fromGeoId) { + this->First = toGeoId; + } + if (this->Second == fromGeoId) { + this->Second = toGeoId; + } + if (this->Third == fromGeoId) { + this->Third = toGeoId; + } +} diff --git a/src/Mod/Sketcher/App/Constraint.h b/src/Mod/Sketcher/App/Constraint.h index 6e526030cc..03a8bcdc47 100644 --- a/src/Mod/Sketcher/App/Constraint.h +++ b/src/Mod/Sketcher/App/Constraint.h @@ -82,7 +82,10 @@ enum InternalAlignmentType { * complex geometries like parabola focus or b-spline knots use InternalAlignment constraints * in addition to PointPos. */ -enum PointPos { none, start, end, mid }; +enum PointPos { none = 0, + start = 1, + end = 2, + mid = 3 }; class SketcherExport Constraint : public Base::Persistence { @@ -127,6 +130,9 @@ public: Type == Radius || Type == Diameter || Type == Angle || Type == SnellsLaw || Type == Weight; } + /// utility function to swap the index in First/Second/Third of the provided constraint from the fromGeoId GeoId to toGeoId + void substituteIndex(int fromGeoId, int toGeoId); + friend class PropertyConstraintList; private: diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index e671585ecf..4d36e22d1e 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -1647,7 +1647,7 @@ void SketchObject::transferFilletConstraints(int geoId1, PointPos posId1, int ge this->Constraints.setValues(std::move(newConstraints)); } -int SketchObject::transferConstraints(int fromGeoId, PointPos fromPosId, int toGeoId, PointPos toPosId, bool tangencyHolds) +int SketchObject::transferConstraints(int fromGeoId, PointPos fromPosId, int toGeoId, PointPos toPosId, bool doNotTransformTangencies) { Base::StateLocker lock(managedoperation, true); // no need to check input data validity as this is an sketchobject managed operation. @@ -1667,7 +1667,7 @@ int SketchObject::transferConstraints(int fromGeoId, PointPos fromPosId, int toG // point, as the transfer destination edge most likely won't be intended to be tangent. However, if it is // an end to end point tangency, the user expects it to be substituted by a coincidence constraint. if (vals[i]->Type == Sketcher::Tangent || vals[i]->Type == Sketcher::Perpendicular) { - if (!tangencyHolds) { + if (!doNotTransformTangencies) { constNew->Type = Sketcher::Coincident; } } @@ -1696,7 +1696,7 @@ int SketchObject::transferConstraints(int fromGeoId, PointPos fromPosId, int toG // point, as the transfer destination edge most likely won't be intended to be tangent. However, if it is // an end to end point tangency, the user expects it to be substituted by a coincidence constraint. if (vals[i]->Type == Sketcher::Tangent || vals[i]->Type == Sketcher::Perpendicular) { - if (!tangencyHolds) { + if (!doNotTransformTangencies) { constNew->Type = Sketcher::Coincident; } } @@ -1717,19 +1717,6 @@ int SketchObject::transferConstraints(int fromGeoId, PointPos fromPosId, int toG return 0; } -void SketchObject::swapInvolvedGeometry(Constraint *constraint, int fromGeoId, int toGeoId) -{ - if (constraint->First == fromGeoId) { - constraint->First = toGeoId; - } - if (constraint->Second == fromGeoId) { - constraint->Second = toGeoId; - } - if (constraint->Third == fromGeoId) { - constraint->Third = toGeoId; - } -} - int SketchObject::fillet(int GeoId, PointPos PosId, double radius, bool trim, bool createCorner) { if (GeoId < 0 || GeoId > getHighestCurveIndex()) @@ -3148,7 +3135,7 @@ int SketchObject::split(int GeoId, const Base::Vector3d &point) if (ok) { std::vector oldConstraints; - getAppliedConstraints(GeoId, oldConstraints); + getConstraintIndices(GeoId, oldConstraints); for (unsigned int i = 0; i < oldConstraints.size(); ++i) { @@ -3194,7 +3181,7 @@ int SketchObject::split(int GeoId, const Base::Vector3d &point) for (unsigned int i = initial; i < limit; ++i) { Constraint *trans = con->copy(); - swapInvolvedGeometry(trans, GeoId, newIds[i]); + trans->substituteIndex(GeoId, newIds[i]); newConstraints.push_back(trans); } break; @@ -3258,7 +3245,7 @@ int SketchObject::split(int GeoId, const Base::Vector3d &point) if (transferToAll) { for (unsigned int i = 0; i < newIds.size(); ++i) { Constraint *trans = con->copy(); - swapInvolvedGeometry(trans, GeoId, newIds[i]); + trans->substituteIndex(GeoId, newIds[i]); newConstraints.push_back(trans); } } @@ -7149,7 +7136,7 @@ bool SketchObject::arePointsCoincident(int GeoId1, PointPos PosId1, return false; } -void SketchObject::getAppliedConstraints(int GeoId, std::vector &constraintList) +void SketchObject::getConstraintIndices (int GeoId, std::vector &constraintList) { const std::vector &constraints = this->Constraints.getValues(); int i = 0; diff --git a/src/Mod/Sketcher/App/SketchObject.h b/src/Mod/Sketcher/App/SketchObject.h index 2d1def3f9f..5254669778 100644 --- a/src/Mod/Sketcher/App/SketchObject.h +++ b/src/Mod/Sketcher/App/SketchObject.h @@ -158,10 +158,7 @@ public: int delConstraintsToExternal(); /// transfers all constraints of a point to a new point int transferConstraints(int fromGeoId, PointPos fromPosId, int toGeoId, PointPos toPosId, - bool tangencyHolds = false); - - /// swaps original GeoId for a new one - void swapInvolvedGeometry(Constraint *constraint, int fromGeoId, int toGeoId); + bool doNotTransformTangencies = false); /// Carbon copy another sketch geometry and constraints int carbonCopy(App::DocumentObject * pObj, bool construction = true); @@ -365,8 +362,8 @@ public: void getDirectlyCoincidentPoints(int VertexId, std::vector &GeoIdList, std::vector &PosIdList); bool arePointsCoincident(int GeoId1, PointPos PosId1, int GeoId2, PointPos PosId2); - /// fetches all constraints involving given GeoId - void getAppliedConstraints(int GeoId, std::vector &constraintList); + /// returns a list of indices of all constraints involving given GeoId + void getConstraintIndices(int GeoId, std::vector &constraintList); /// generates a warning message about constraint conflicts and appends it to the given message static void appendConflictMsg(const std::vector &conflicting, std::string &msg); diff --git a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp index 1162db047e..d466d72cf1 100644 --- a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp +++ b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp @@ -570,7 +570,7 @@ PyObject* SketchObjectPy::delConstraintOnPoint(PyObject *args) if (!PyArg_ParseTuple(args, "i|i", &Index, &pos)) return 0; - if (pos>=0 && pos<=3) { // Sketcher::none Sketcher::mid + if (pos>=Sketcher::none && pos<=Sketcher::mid) { // This is the whole range of valid positions if (this->getSketchObjectPtr()->delConstraintOnPoint(Index,(Sketcher::PointPos)pos)) { std::stringstream str; str << "Not able to delete a constraint on point with the given index: " << Index From 5c10c586cddc3e99f48f2a5e6a396e2f772d7de1 Mon Sep 17 00:00:00 2001 From: 0penBrain <48731257+0penBrain@users.noreply.github.com> Date: Sun, 18 Apr 2021 19:49:43 +0200 Subject: [PATCH 144/178] [Sketcher] Visibility automation : add ability to open sketch in Section View mode --- src/Mod/Sketcher/Gui/SketcherSettings.cpp | 8 ++++++-- .../Sketcher/Gui/SketcherSettingsDisplay.ui | 19 +++++++++++++++++++ src/Mod/Sketcher/Gui/ViewProviderSketch.cpp | 3 +++ src/Mod/Sketcher/Gui/ViewProviderSketch.h | 1 + 4 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/Mod/Sketcher/Gui/SketcherSettings.cpp b/src/Mod/Sketcher/Gui/SketcherSettings.cpp index d31d1e6fd5..9734c597af 100644 --- a/src/Mod/Sketcher/Gui/SketcherSettings.cpp +++ b/src/Mod/Sketcher/Gui/SketcherSettings.cpp @@ -156,6 +156,7 @@ void SketcherSettingsDisplay::saveSettings() ui->checkBoxTVShowLinks->onSave(); ui->checkBoxTVShowSupport->onSave(); ui->checkBoxTVRestoreCamera->onSave(); + ui->checkBoxTVSectionView->onSave(); ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Part"); QVariant data = ui->comboBox->itemData(ui->comboBox->currentIndex()); @@ -177,6 +178,7 @@ void SketcherSettingsDisplay::loadSettings() ui->checkBoxTVShowLinks->onRestore(); ui->checkBoxTVShowSupport->onRestore(); ui->checkBoxTVRestoreCamera->onRestore(); + ui->checkBoxTVSectionView->onRestore(); ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Part"); int pattern = hGrp->GetInt("GridLinePattern", 0x0f0f); @@ -208,11 +210,13 @@ void SketcherSettingsDisplay::onBtnTVApplyClicked(bool) " sketch.ViewObject.HideDependent = %s\n" " sketch.ViewObject.ShowLinks = %s\n" " sketch.ViewObject.ShowSupport = %s\n" - " sketch.ViewObject.RestoreCamera = %s\n", + " sketch.ViewObject.RestoreCamera = %s\n" + " sketch.ViewObject.SectionView = %s\n", this->ui->checkBoxTVHideDependent->isChecked() ? "True": "False", this->ui->checkBoxTVShowLinks->isChecked() ? "True": "False", this->ui->checkBoxTVShowSupport->isChecked() ? "True": "False", - this->ui->checkBoxTVRestoreCamera->isChecked() ? "True": "False"); + this->ui->checkBoxTVRestoreCamera->isChecked() ? "True": "False", + this->ui->checkBoxTVSectionView->isChecked() ? "True": "False"); } catch (Base::PyException &e){ Base::Console().Error("SketcherSettings::onBtnTVApplyClicked:\n"); e.ReportException(); diff --git a/src/Mod/Sketcher/Gui/SketcherSettingsDisplay.ui b/src/Mod/Sketcher/Gui/SketcherSettingsDisplay.ui index 028009982f..46ce790e35 100644 --- a/src/Mod/Sketcher/Gui/SketcherSettingsDisplay.ui +++ b/src/Mod/Sketcher/Gui/SketcherSettingsDisplay.ui @@ -230,6 +230,25 @@ Supports all unit systems except 'US customary' and 'Building US/Euro'. + + + + By default, open a sketch in Section View mode -- objects are only visible behind sketch plane + + + Open sketch in Section View mode + + + false + + + SectionView + + + Mod/Sketcher/General + + + diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp index 34798294e2..241e4467b7 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -335,6 +335,7 @@ ViewProviderSketch::ViewProviderSketch() ADD_PROPERTY_TYPE(ShowLinks,(true),"Visibility automation",(App::PropertyType)(App::Prop_None),"If true, all objects used in links to external geometry are shown when opening sketch."); ADD_PROPERTY_TYPE(ShowSupport,(true),"Visibility automation",(App::PropertyType)(App::Prop_None),"If true, all objects this sketch is attached to are shown when opening sketch."); ADD_PROPERTY_TYPE(RestoreCamera,(true),"Visibility automation",(App::PropertyType)(App::Prop_None),"If true, camera position before entering sketch is remembered, and restored after closing it."); + ADD_PROPERTY_TYPE(SectionView,(false),"Visibility automation",(App::PropertyType)(App::Prop_None),"If true, only objects (or part of) located behind the sketch plane are visible."); ADD_PROPERTY_TYPE(EditingWorkbench,("SketcherWorkbench"),"Visibility automation",(App::PropertyType)(App::Prop_None),"Name of the workbench to activate when editing this sketch."); {//visibility automation: update defaults to follow preferences @@ -343,6 +344,7 @@ ViewProviderSketch::ViewProviderSketch() this->ShowLinks.setValue(hGrp->GetBool("ShowLinks", true)); this->ShowSupport.setValue(hGrp->GetBool("ShowSupport", true)); this->RestoreCamera.setValue(hGrp->GetBool("RestoreCamera", true)); + this->SectionView.setValue(hGrp->GetBool("SectionView", false)); // well it is not visibility automation but a good place nevertheless this->ShowGrid.setValue(hGrp->GetBool("ShowGrid", false)); @@ -6326,6 +6328,7 @@ bool ViewProviderSketch::setEdit(int ModNum) " tv.show([ref[0] for ref in ActiveSketch.Support if not ref[0].isDerivedFrom(\"PartDesign::Plane\")])\n" "if ActiveSketch.ViewObject.ShowLinks:\n" " tv.show([ref[0] for ref in ActiveSketch.ExternalGeometry])\n" + " tv.sketchClipPlane(ActiveSketch, ActiveSketch.ViewObject.SectionView)\n" "tv.hide(ActiveSketch)\n" "del(tv)\n" ).arg(QString::fromLatin1(getDocument()->getDocument()->getName()), diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.h b/src/Mod/Sketcher/Gui/ViewProviderSketch.h index 6f66d6507f..5d2bfb147d 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.h +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.h @@ -114,6 +114,7 @@ public: App::PropertyBool ShowLinks; App::PropertyBool ShowSupport; App::PropertyBool RestoreCamera; + App::PropertyBool SectionView; App::PropertyString EditingWorkbench; /// Draw all constraint icons From 1212bef4cdac700ac49c7f6f64f43a6fa0bb470d Mon Sep 17 00:00:00 2001 From: luz paz Date: Fri, 23 Apr 2021 16:29:53 -0400 Subject: [PATCH 145/178] [FEM] remove Py2 code --- src/Mod/Fem/App/FemMeshPyImp.cpp | 56 -------------------------------- src/Mod/Fem/App/HypothesisPy.cpp | 12 ------- 2 files changed, 68 deletions(-) diff --git a/src/Mod/Fem/App/FemMeshPyImp.cpp b/src/Mod/Fem/App/FemMeshPyImp.cpp index bc9c592d5e..cc2ddde654 100644 --- a/src/Mod/Fem/App/FemMeshPyImp.cpp +++ b/src/Mod/Fem/App/FemMeshPyImp.cpp @@ -262,11 +262,7 @@ PyObject* FemMeshPy::addEdge(PyObject *args) Py::List list(obj); std::vector Nodes; for (Py::List::iterator it = list.begin(); it != list.end(); ++it) { -#if PY_MAJOR_VERSION >= 3 Py::Long NoNr(*it); -#else - Py::Int NoNr(*it); -#endif const SMDS_MeshNode* node = meshDS->FindNode(NoNr); if (!node) throw std::runtime_error("Failed to get node of the given indices"); @@ -306,11 +302,7 @@ PyObject* FemMeshPy::addEdge(PyObject *args) throw std::runtime_error("Unknown node count, [2|3] are allowed"); //unknown edge type } } -#if PY_MAJOR_VERSION >= 3 return Py::new_reference_to(Py::Long(edge->GetID())); -#else - return Py::new_reference_to(Py::Int(edge->GetID())); -#endif } PyErr_SetString(PyExc_TypeError, "addEdge accepts:\n" "-- int,int\n" @@ -352,11 +344,7 @@ PyObject* FemMeshPy::addFace(PyObject *args) Py::List list(obj); std::vector Nodes; for (Py::List::iterator it = list.begin(); it != list.end(); ++it) { -#if PY_MAJOR_VERSION >= 3 Py::Long NoNr(*it); -#else - Py::Int NoNr(*it); -#endif const SMDS_MeshNode* node = meshDS->FindNode(NoNr); if (!node) throw std::runtime_error("Failed to get node of the given indices"); @@ -485,11 +473,7 @@ PyObject* FemMeshPy::addVolume(PyObject *args) Py::List list(obj); std::vector Nodes; for (Py::List::iterator it = list.begin(); it != list.end(); ++it) { -#if PY_MAJOR_VERSION >= 3 Py::Long NoNr(*it); -#else - Py::Int NoNr(*it); -#endif const SMDS_MeshNode* node = meshDS->FindNode(NoNr); if (!node) throw std::runtime_error("Failed to get node of the given indices"); @@ -699,11 +683,7 @@ PyObject* FemMeshPy::getFacesByFace(PyObject *args) Py::List ret; std::list resultSet = getFemMeshPtr()->getFacesByFace(fc); for (std::list::const_iterator it = resultSet.begin();it!=resultSet.end();++it) { -#if PY_MAJOR_VERSION >= 3 ret.append(Py::Long(*it)); -#else - ret.append(Py::Int(*it)); -#endif } return Py::new_reference_to(ret); @@ -733,11 +713,7 @@ PyObject* FemMeshPy::getEdgesByEdge(PyObject *args) Py::List ret; std::list resultSet = getFemMeshPtr()->getEdgesByEdge(fc); for (std::list::const_iterator it = resultSet.begin();it!=resultSet.end();++it) { -#if PY_MAJOR_VERSION >= 3 ret.append(Py::Long(*it)); -#else - ret.append(Py::Int(*it)); -#endif } return Py::new_reference_to(ret); @@ -965,11 +941,7 @@ PyObject* FemMeshPy::getGroupName(PyObject *args) int id; if (!PyArg_ParseTuple(args, "i", &id)) return 0; -#if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(getFemMeshPtr()->getSMesh()->GetGroup(id)->GetName()); -#else - return PyString_FromString(getFemMeshPtr()->getSMesh()->GetGroup(id)->GetName()); -#endif } PyObject* FemMeshPy::getGroupElementType(PyObject *args) @@ -995,11 +967,7 @@ PyObject* FemMeshPy::getGroupElementType(PyObject *args) case SMDSAbs_Ball : typeString = "Ball"; break; default : typeString = "Unknown"; break; } -#if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(typeString); -#else - return PyString_FromString(typeString); -#endif } PyObject* FemMeshPy::getGroupElements(PyObject *args) @@ -1024,11 +992,7 @@ PyObject* FemMeshPy::getGroupElements(PyObject *args) Py::Tuple tuple(ids.size()); int index = 0; for (std::set::iterator it = ids.begin(); it != ids.end(); ++it) { -#if PY_MAJOR_VERSION >= 3 tuple.setItem(index++, Py::Long(*it)); -#else - tuple.setItem(index++, Py::Int(*it)); -#endif } return Py::new_reference_to(tuple); @@ -1061,11 +1025,7 @@ PyObject* FemMeshPy::addGroup(PyObject *args) } std::cout << "Added Group: Name: \'" << EncodedName << "\' Type: \'" << EncodedTypeString << "\' id: " << retId << std::endl; -#if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(retId); -#else - return PyInt_FromLong(retId); -#endif } PyObject* FemMeshPy::addGroupElements(PyObject *args) @@ -1088,19 +1048,11 @@ PyObject* FemMeshPy::addGroupElements(PyObject *args) std::cout << "AddGroupElements: num elements: " << n << " sizeof: " << sizeof(n) << std::endl; for (Py_ssize_t i = 0; i < n; i++) { pItem = PyList_GetItem(pList, i); -#if PY_MAJOR_VERSION >= 3 if(!PyLong_Check(pItem)) { -#else - if(!PyInt_Check(pItem)) { -#endif PyErr_SetString(PyExc_TypeError, "AddGroupElements: List items must be integers."); return 0; } -#if PY_MAJOR_VERSION >= 3 ids.insert(PyLong_AsSsize_t(pItem)); -#else - ids.insert(PyInt_AsSsize_t(pItem)); -#endif // Py_ssize_t transparently handles maximum array lengths on 32bit and 64bit machines // See: https://www.python.org/dev/peps/pep-0353/ } @@ -1157,11 +1109,7 @@ PyObject* FemMeshPy::getElementType(PyObject *args) } } -#if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(typeString); -#else - return PyString_FromString(typeString); -#endif } PyObject* FemMeshPy::getIdByElementType(PyObject *args) @@ -1386,11 +1334,7 @@ Py::Tuple FemMeshPy::getGroups(void) const Py::Tuple tuple(groupIDs.size()); int index = 0; for (std::list::iterator it = groupIDs.begin(); it != groupIDs.end(); ++it) { -#if PY_MAJOR_VERSION >= 3 tuple.setItem(index++, Py::Long(*it)); -#else - tuple.setItem(index++, Py::Int(*it)); -#endif } return tuple; diff --git a/src/Mod/Fem/App/HypothesisPy.cpp b/src/Mod/Fem/App/HypothesisPy.cpp index 67651204c6..9dfb45ee34 100755 --- a/src/Mod/Fem/App/HypothesisPy.cpp +++ b/src/Mod/Fem/App/HypothesisPy.cpp @@ -1134,11 +1134,7 @@ StdMeshers_NumberOfSegmentsPy::~StdMeshers_NumberOfSegmentsPy() Py::Object StdMeshers_NumberOfSegmentsPy::setNumSegm(const Py::Tuple& args) { -#if PY_MAJOR_VERSION >= 3 hypothesis()->SetNumberOfSegments((int)Py::Long(args[0])); -#else - hypothesis()->SetNumberOfSegments((int)Py::Int(args[0])); -#endif return Py::None(); } @@ -1178,11 +1174,7 @@ StdMeshers_NumberOfLayersPy::~StdMeshers_NumberOfLayersPy() Py::Object StdMeshers_NumberOfLayersPy::setNumLayers(const Py::Tuple& args) { -#if PY_MAJOR_VERSION >= 3 hypothesis()->SetNumberOfLayers((int)Py::Long(args[0])); -#else - hypothesis()->SetNumberOfLayers((int)Py::Int(args[0])); -#endif return Py::None(); } @@ -1287,11 +1279,7 @@ StdMeshers_LengthFromEdgesPy::~StdMeshers_LengthFromEdgesPy() Py::Object StdMeshers_LengthFromEdgesPy::setMode(const Py::Tuple& args) { -#if PY_MAJOR_VERSION >= 3 hypothesis()->SetMode((int)Py::Long(args[0])); -#else - hypothesis()->SetMode((int)Py::Int(args[0])); -#endif return Py::None(); } From 2321c90c769840830eecc0b2e8cb41d4ab548f2d Mon Sep 17 00:00:00 2001 From: luz paz Date: Fri, 23 Apr 2021 16:32:11 -0400 Subject: [PATCH 146/178] Mesh: remove py2 code --- src/Mod/Mesh/App/AppMeshPy.cpp | 4 -- src/Mod/Mesh/App/Mesh.cpp | 24 ------------ src/Mod/Mesh/App/MeshPyImp.cpp | 72 ---------------------------------- 3 files changed, 100 deletions(-) diff --git a/src/Mod/Mesh/App/AppMeshPy.cpp b/src/Mod/Mesh/App/AppMeshPy.cpp index 524e84f40c..92a6524e7f 100644 --- a/src/Mod/Mesh/App/AppMeshPy.cpp +++ b/src/Mod/Mesh/App/AppMeshPy.cpp @@ -226,11 +226,7 @@ private: "exportAmfCompressed", NULL}; if (!PyArg_ParseTupleAndKeywords( args.ptr(), keywds.ptr(), -#if PY_MAJOR_VERSION >= 3 "Oet|dp", -#else - "Oet|di", -#endif // Python version switch kwList, &objects, "utf-8", &fileNamePy, &fTolerance, &exportAmfCompressed )) { throw Py::Exception(); diff --git a/src/Mod/Mesh/App/Mesh.cpp b/src/Mod/Mesh/App/Mesh.cpp index 26b7666be7..2f727d90c6 100644 --- a/src/Mod/Mesh/App/Mesh.cpp +++ b/src/Mod/Mesh/App/Mesh.cpp @@ -1597,11 +1597,7 @@ MeshObject* MeshObject::createSphere(float radius, int sampling) Py::Callable call(dict.getItem("Sphere")); Py::Tuple args(2); args.setItem(0, Py::Float(radius)); -#if PY_MAJOR_VERSION >= 3 args.setItem(1, Py::Long(sampling)); -#else - args.setItem(1, Py::Int(sampling)); -#endif Py::List list(call.apply(args)); return createMeshFromList(list); } @@ -1625,11 +1621,7 @@ MeshObject* MeshObject::createEllipsoid(float radius1, float radius2, int sampli Py::Tuple args(3); args.setItem(0, Py::Float(radius1)); args.setItem(1, Py::Float(radius2)); -#if PY_MAJOR_VERSION >= 3 args.setItem(2, Py::Long(sampling)); -#else - args.setItem(2, Py::Int(sampling)); -#endif Py::List list(call.apply(args)); return createMeshFromList(list); } @@ -1653,15 +1645,9 @@ MeshObject* MeshObject::createCylinder(float radius, float length, int closed, f Py::Tuple args(5); args.setItem(0, Py::Float(radius)); args.setItem(1, Py::Float(length)); -#if PY_MAJOR_VERSION >= 3 args.setItem(2, Py::Long(closed)); args.setItem(3, Py::Float(edgelen)); args.setItem(4, Py::Long(sampling)); -#else - args.setItem(2, Py::Int(closed)); - args.setItem(3, Py::Float(edgelen)); - args.setItem(4, Py::Int(sampling)); -#endif Py::List list(call.apply(args)); return createMeshFromList(list); } @@ -1686,15 +1672,9 @@ MeshObject* MeshObject::createCone(float radius1, float radius2, float len, int args.setItem(0, Py::Float(radius1)); args.setItem(1, Py::Float(radius2)); args.setItem(2, Py::Float(len)); -#if PY_MAJOR_VERSION >= 3 args.setItem(3, Py::Long(closed)); args.setItem(4, Py::Float(edgelen)); args.setItem(5, Py::Long(sampling)); -#else - args.setItem(3, Py::Int(closed)); - args.setItem(4, Py::Float(edgelen)); - args.setItem(5, Py::Int(sampling)); -#endif Py::List list(call.apply(args)); return createMeshFromList(list); } @@ -1718,11 +1698,7 @@ MeshObject* MeshObject::createTorus(float radius1, float radius2, int sampling) Py::Tuple args(3); args.setItem(0, Py::Float(radius1)); args.setItem(1, Py::Float(radius2)); -#if PY_MAJOR_VERSION >= 3 args.setItem(2, Py::Long(sampling)); -#else - args.setItem(2, Py::Int(sampling)); -#endif Py::List list(call.apply(args)); return createMeshFromList(list); } diff --git a/src/Mod/Mesh/App/MeshPyImp.cpp b/src/Mod/Mesh/App/MeshPyImp.cpp index c984ffe3a8..d4ca9b4d52 100644 --- a/src/Mod/Mesh/App/MeshPyImp.cpp +++ b/src/Mod/Mesh/App/MeshPyImp.cpp @@ -88,17 +88,7 @@ int MeshPy::PyInit(PyObject* args, PyObject*) if (!ok) return -1; } else if (PyUnicode_Check(pcObj)) { -#if PY_MAJOR_VERSION >= 3 getMeshObjectPtr()->load(PyUnicode_AsUTF8(pcObj)); -#else - PyObject* unicode = PyUnicode_AsEncodedString(pcObj, "utf-8", 0); - char* pItem = PyString_AsString(unicode); - Py_DECREF(unicode); - getMeshObjectPtr()->load(pItem); - } - else if (PyString_Check(pcObj)) { - getMeshObjectPtr()->load(PyString_AsString(pcObj)); -#endif } else { PyErr_Format(PyExc_TypeError, "Cannot create a mesh out of a '%s'", @@ -723,15 +713,9 @@ PyObject* MeshPy::addFacets(PyObject *args) for (Py::List::iterator it = list_f.begin(); it != list_f.end(); ++it) { Py::Tuple f(*it); MeshCore::MeshFacet face; -#if PY_MAJOR_VERSION >= 3 face._aulPoints[0] = (long)Py::Long(f.getItem(0)); face._aulPoints[1] = (long)Py::Long(f.getItem(1)); face._aulPoints[2] = (long)Py::Long(f.getItem(2)); -#else - face._aulPoints[0] = (long)Py::Int(f.getItem(0)); - face._aulPoints[1] = (long)Py::Int(f.getItem(1)); - face._aulPoints[2] = (long)Py::Int(f.getItem(2)); -#endif faces.push_back(face); } @@ -755,11 +739,7 @@ PyObject* MeshPy::removeFacets(PyObject *args) std::vector indices; Py::Sequence ary(list); for (Py::Sequence::iterator it = ary.begin(); it != ary.end(); ++it) { -#if PY_MAJOR_VERSION >= 3 Py::Long f(*it); -#else - Py::Int f(*it); -#endif indices.push_back((long)f); } @@ -863,11 +843,7 @@ PyObject* MeshPy::getSegment(PyObject *args) Py::List ary; const std::vector& segm = getMeshObjectPtr()->getSegment(index).getIndices(); for (std::vector::const_iterator it = segm.begin(); it != segm.end(); ++it) { -#if PY_MAJOR_VERSION >= 3 ary.append(Py::Long((int)*it)); -#else - ary.append(Py::Int((int)*it)); -#endif } return Py::new_reference_to(ary); @@ -897,11 +873,7 @@ PyObject* MeshPy::getFacetSelection(PyObject *args) std::vector facets; getMeshObjectPtr()->getFacetsFromSelection(facets); for (std::vector::const_iterator it = facets.begin(); it != facets.end(); ++it) { -#if PY_MAJOR_VERSION >= 3 ary.append(Py::Long((int)*it)); -#else - ary.append(Py::Int((int)*it)); -#endif } return Py::new_reference_to(ary); @@ -916,11 +888,7 @@ PyObject* MeshPy::getPointSelection(PyObject *args) std::vector points; getMeshObjectPtr()->getPointsFromSelection(points); for (std::vector::const_iterator it = points.begin(); it != points.end(); ++it) { -#if PY_MAJOR_VERSION >= 3 ary.append(Py::Long((int)*it)); -#else - ary.append(Py::Int((int)*it)); -#endif } return Py::new_reference_to(ary); @@ -935,11 +903,7 @@ PyObject* MeshPy::meshFromSegment(PyObject *args) std::vector segment; Py::Sequence ary(list); for (Py::Sequence::iterator it = ary.begin(); it != ary.end(); ++it) { -#if PY_MAJOR_VERSION >= 3 Py::Long f(*it); -#else - Py::Int f(*it); -#endif segment.push_back((long)f); } @@ -1588,15 +1552,9 @@ PyObject* MeshPy::collapseFacets(PyObject *args) Py::Sequence list(pcObj); std::vector facets; for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) { -#if PY_MAJOR_VERSION >= 3 Py::Long idx(*it); unsigned long iIdx = static_cast(idx); facets.push_back(iIdx); -#else - Py::Int idx(*it); - unsigned long iIdx = static_cast(idx); - facets.push_back(iIdx); -#endif } getMeshObjectPtr()->collapseFacets(facets); @@ -1636,11 +1594,7 @@ PyObject* MeshPy::foraminate(PyObject *args) tuple.setItem(0, Py::Float(res.x)); tuple.setItem(1, Py::Float(res.y)); tuple.setItem(2, Py::Float(res.z)); -#if PY_MAJOR_VERSION >= 3 dict.setItem(Py::Long(index), tuple); -#else - dict.setItem(Py::Int(index), tuple); -#endif } } @@ -1818,11 +1772,7 @@ PyObject* MeshPy::nearestFacetOnRay(PyObject *args) tuple.setItem(0, Py::Float(res.x)); tuple.setItem(1, Py::Float(res.y)); tuple.setItem(2, Py::Float(res.z)); -#if PY_MAJOR_VERSION >= 3 dict.setItem(Py::Long((int)index), tuple); -#else - dict.setItem(Py::Int((int)index), tuple); -#endif } #if 0 // for testing only @@ -1867,11 +1817,7 @@ PyObject* MeshPy::getPlanarSegments(PyObject *args) const std::vector& segm = it->getIndices(); Py::List ary; for (std::vector::const_iterator jt = segm.begin(); jt != segm.end(); ++jt) { -#if PY_MAJOR_VERSION >= 3 ary.append(Py::Long((int)*jt)); -#else - ary.append(Py::Int((int)*jt)); -#endif } s.append(ary); } @@ -1911,11 +1857,7 @@ PyObject* MeshPy::getSegmentsOfType(PyObject *args) const std::vector& segm = it->getIndices(); Py::List ary; for (std::vector::const_iterator jt = segm.begin(); jt != segm.end(); ++jt) { -#if PY_MAJOR_VERSION >= 3 ary.append(Py::Long((int)*jt)); -#else - ary.append(Py::Int((int)*jt)); -#endif } s.append(ary); } @@ -1942,11 +1884,7 @@ PyObject* MeshPy::getSegmentsByCurvature(PyObject *args) float c2 = (float)Py::Float(t[1]); float tol1 = (float)Py::Float(t[2]); float tol2 = (float)Py::Float(t[3]); -#if PY_MAJOR_VERSION >= 3 int num = (int)Py::Long(t[4]); -#else - int num = (int)Py::Int(t[4]); -#endif segm.emplace_back(std::make_shared(meshCurv.GetCurvature(), num, tol1, tol2, c1, c2)); } @@ -1958,11 +1896,7 @@ PyObject* MeshPy::getSegmentsByCurvature(PyObject *args) for (std::vector::const_iterator it = data.begin(); it != data.end(); ++it) { Py::List ary; for (MeshCore::MeshSegment::const_iterator jt = it->begin(); jt != it->end(); ++jt) { -#if PY_MAJOR_VERSION >= 3 ary.append(Py::Long((int)*jt)); -#else - ary.append(Py::Int((int)*jt)); -#endif } list.append(ary); } @@ -2074,15 +2008,9 @@ Py::Tuple MeshPy::getTopology(void) const for (std::vector::const_iterator it = Facets.begin(); it != Facets.end(); ++it) { Py::Tuple f(3); -#if PY_MAJOR_VERSION >= 3 f.setItem(0,Py::Long((int)it->I1)); f.setItem(1,Py::Long((int)it->I2)); f.setItem(2,Py::Long((int)it->I3)); -#else - f.setItem(0,Py::Int((int)it->I1)); - f.setItem(1,Py::Int((int)it->I2)); - f.setItem(2,Py::Int((int)it->I3)); -#endif facet.append(f); } tuple.setItem(1, facet); From 17ffa8255bfa6b5ead0b7c9cae32789807873f2f Mon Sep 17 00:00:00 2001 From: luz paz Date: Fri, 23 Apr 2021 17:44:15 -0400 Subject: [PATCH 147/178] Gui: remove py2 code --- src/Gui/CallTips.cpp | 12 ---- src/Gui/Command.cpp | 28 --------- src/Gui/PythonWorkbenchPyImp.cpp | 104 ------------------------------- src/Gui/ViewProviderPyImp.cpp | 15 ----- 4 files changed, 159 deletions(-) diff --git a/src/Gui/CallTips.cpp b/src/Gui/CallTips.cpp index d6e71d96fa..2a1a5e63b9 100644 --- a/src/Gui/CallTips.cpp +++ b/src/Gui/CallTips.cpp @@ -236,11 +236,7 @@ QMap CallTipsList::extractTips(const QString& context) const PyObject* eval = 0; if (PyCode_Check(code)) { -#if PY_MAJOR_VERSION >= 3 eval = PyEval_EvalCode(code, dict.ptr(), dict.ptr()); -#else - eval = PyEval_EvalCode(reinterpret_cast(code), dict.ptr(), dict.ptr()); -#endif } Py_DECREF(code); if (!eval) { @@ -276,14 +272,6 @@ QMap CallTipsList::extractTips(const QString& context) const else if (PyObject_IsSubclass(type.ptr(), typeobj.o) == 1) { obj = type; } -#if PY_MAJOR_VERSION < 3 - else if (PyInstance_Check(obj.ptr())) { - // instances of old style classes - PyInstanceObject* inst = reinterpret_cast(obj.ptr()); - PyObject* classobj = reinterpret_cast(inst->in_class); - obj = Py::Object(classobj); - } -#endif else if (PyObject_IsInstance(obj.ptr(), basetype.o) == 1) { // New style class which can be a module, type, list, tuple, int, float, ... // Make sure it's not a type object diff --git a/src/Gui/Command.cpp b/src/Gui/Command.cpp index 83b9a92286..1647192f68 100644 --- a/src/Gui/Command.cpp +++ b/src/Gui/Command.cpp @@ -649,11 +649,7 @@ void Command::printPyCaller() { if(!frame) return; int line = PyFrame_GetLineNumber(frame); -#if PY_MAJOR_VERSION >= 3 const char *file = PyUnicode_AsUTF8(frame->f_code->co_filename); -#else - const char *file = PyString_AsString(frame->f_code->co_filename); -#endif printCaller(file?file:"",line); } @@ -1239,19 +1235,11 @@ const char* PythonCommand::getResource(const char* sName) const pcTemp = PyDict_GetItemString(_pcPyResourceDict,sName); if (!pcTemp) return ""; -#if PY_MAJOR_VERSION >= 3 if (!PyUnicode_Check(pcTemp)) { -#else - if (!PyString_Check(pcTemp)) { -#endif throw Base::TypeError("PythonCommand::getResource(): Method GetResources() of the Python " "command object returns a dictionary which holds not only strings"); } -#if PY_MAJOR_VERSION >= 3 return PyUnicode_AsUTF8(pcTemp); -#else - return PyString_AsString(pcTemp); -#endif } void PythonCommand::activated(int iMsg) @@ -1314,17 +1302,9 @@ const char* PythonCommand::getHelpUrl(void) const pcTemp = Interpreter().runMethodObject(_pcPyCommand, "CmdHelpURL"); if (! pcTemp ) return ""; -#if PY_MAJOR_VERSION >= 3 if (! PyUnicode_Check(pcTemp) ) -#else - if (! PyString_Check(pcTemp) ) -#endif throw Base::TypeError("PythonCommand::CmdHelpURL(): Method CmdHelpURL() of the Python command object returns no string"); -#if PY_MAJOR_VERSION >= 3 return PyUnicode_AsUTF8(pcTemp); -#else - return PyString_AsString(pcTemp); -#endif } Action * PythonCommand::createAction(void) @@ -1647,19 +1627,11 @@ const char* PythonGroupCommand::getResource(const char* sName) const pcTemp = PyDict_GetItemString(_pcPyResource, sName); if (!pcTemp) return ""; -#if PY_MAJOR_VERSION >= 3 if (!PyUnicode_Check(pcTemp)) { -#else - if (!PyString_Check(pcTemp)) { -#endif throw Base::ValueError("PythonGroupCommand::getResource(): Method GetResources() of the Python " "group command object returns a dictionary which holds not only strings"); } -#if PY_MAJOR_VERSION >= 3 return PyUnicode_AsUTF8(pcTemp); -#else - return PyString_AsString(pcTemp); -#endif } const char* PythonGroupCommand::getWhatsThis() const diff --git a/src/Gui/PythonWorkbenchPyImp.cpp b/src/Gui/PythonWorkbenchPyImp.cpp index 54c5a7e7a4..6a4b5d7a3f 100644 --- a/src/Gui/PythonWorkbenchPyImp.cpp +++ b/src/Gui/PythonWorkbenchPyImp.cpp @@ -63,36 +63,15 @@ PyObject* PythonWorkbenchPy::appendMenu(PyObject *args) for (int j=0; j= 3 const char* pItem = PyUnicode_AsUTF8(item); path.push_back(pItem); -#else - PyObject* unicode = PyUnicode_AsEncodedString(item, "utf-8", 0); - char* pItem = PyString_AsString(unicode); - path.push_back(pItem); - Py_DECREF(unicode); - } else if (PyString_Check(item)) { - char* pItem = PyString_AsString(item); - path.push_back(pItem); -#endif } else { continue; } } } else if (PyUnicode_Check(pPath)) { -#if PY_MAJOR_VERSION >= 3 const char* pItem = PyUnicode_AsUTF8(pPath); path.push_back(pItem); -#else - PyObject* unicode = PyUnicode_AsEncodedString(pPath, "utf-8", 0); - char* pItem = PyString_AsString(unicode); - path.push_back(pItem); - Py_DECREF(unicode); - } else if (PyString_Check(pPath)) { - // one single item - char* pItem = PyString_AsString(pPath); - path.push_back(pItem); -#endif } else { PyErr_SetString(PyExc_AssertionError, "Expected either a string or a stringlist as first argument"); return nullptr; @@ -105,36 +84,15 @@ PyObject* PythonWorkbenchPy::appendMenu(PyObject *args) for (int i=0; i= 3 const char* pItem = PyUnicode_AsUTF8(item); items.push_back(pItem); -#else - PyObject* unicode = PyUnicode_AsEncodedString(item, "utf-8", 0); - char* pItem = PyString_AsString(unicode); - items.push_back(pItem); - Py_DECREF(unicode); - } else if (PyString_Check(item)) { - char* pItem = PyString_AsString(item); - items.push_back(pItem); -#endif } else { continue; } } } else if (PyUnicode_Check(pItems)) { -#if PY_MAJOR_VERSION >= 3 const char* pItem = PyUnicode_AsUTF8(pItems); items.push_back(pItem); -#else - PyObject* unicode = PyUnicode_AsEncodedString(pItems, "utf-8", 0); - char* pItem = PyString_AsString(unicode); - items.push_back(pItem); - Py_DECREF(unicode); - } else if (PyString_Check(pItems)) { - // one single item - char* pItem = PyString_AsString(pItems); - items.push_back(pItem); -#endif } else { PyErr_SetString(PyExc_AssertionError, "Expected either a string or a stringlist as first argument"); return nullptr; @@ -175,36 +133,15 @@ PyObject* PythonWorkbenchPy::appendContextMenu(PyObject *args) for (int j=0; j= 3 const char* pItem = PyUnicode_AsUTF8(item); path.push_back(pItem); -#else - PyObject* unicode = PyUnicode_AsEncodedString(item, "utf-8", 0); - char* pItem = PyString_AsString(unicode); - path.push_back(pItem); - Py_DECREF(unicode); - } else if (PyString_Check(item)) { - char* pItem = PyString_AsString(item); - path.push_back(pItem); -#endif } else { continue; } } } else if (PyUnicode_Check(pPath)) { -#if PY_MAJOR_VERSION >= 3 const char* pItem = PyUnicode_AsUTF8(pPath); path.push_back(pItem); -#else - PyObject* unicode = PyUnicode_AsEncodedString(pPath, "utf-8", 0); - char* pItem = PyString_AsString(unicode); - path.push_back(pItem); - Py_DECREF(unicode); - } else if (PyString_Check(pPath)) { - // one single item - char* pItem = PyString_AsString(pPath); - path.push_back(pItem); -#endif } else { PyErr_SetString(PyExc_AssertionError, "Expected either a string or a stringlist as first argument"); return nullptr; @@ -217,36 +154,15 @@ PyObject* PythonWorkbenchPy::appendContextMenu(PyObject *args) for (int i=0; i= 3 const char* pItem = PyUnicode_AsUTF8(item); items.push_back(pItem); -#else - PyObject* unicode = PyUnicode_AsEncodedString(item, "utf-8", 0); - char* pItem = PyString_AsString(unicode); - items.push_back(pItem); - Py_DECREF(unicode); - } else if (PyString_Check(item)) { - char* pItem = PyString_AsString(item); - items.push_back(pItem); -#endif } else { continue; } } } else if (PyUnicode_Check(pItems)) { -#if PY_MAJOR_VERSION >= 3 const char* pItem = PyUnicode_AsUTF8(pItems); items.push_back(pItem); -#else - PyObject* unicode = PyUnicode_AsEncodedString(pItems, "utf-8", 0); - char* pItem = PyString_AsString(unicode); - items.push_back(pItem); - Py_DECREF(unicode); - } else if (PyString_Check(pItems)) { - // one single item - char* pItem = PyString_AsString(pItems); - items.push_back(pItem); -#endif } else { PyErr_SetString(PyExc_AssertionError, "Expected either a string or a stringlist as first argument"); return nullptr; @@ -289,18 +205,8 @@ PyObject* PythonWorkbenchPy::appendToolbar(PyObject *args) for (int i=0; i= 3 const char* pItem = PyUnicode_AsUTF8(item); items.push_back(pItem); -#else - PyObject* unicode = PyUnicode_AsEncodedString(item, "utf-8", 0); - char* pItem = PyString_AsString(unicode); - items.push_back(pItem); - Py_DECREF(unicode); - } else if (PyString_Check(item)) { - char* pItem = PyString_AsString(item); - items.push_back(pItem); -#endif } else { continue; } @@ -342,18 +248,8 @@ PyObject* PythonWorkbenchPy::appendCommandbar(PyObject *args) for (int i=0; i= 3 const char* pItem = PyUnicode_AsUTF8(item); items.push_back(pItem); -#else - PyObject* unicode = PyUnicode_AsEncodedString(item, "utf-8", 0); - char* pItem = PyString_AsString(unicode); - items.push_back(pItem); - Py_DECREF(unicode); - } else if (PyString_Check(item)) { - char* pItem = PyString_AsString(item); - items.push_back(pItem); -#endif } else { continue; } diff --git a/src/Gui/ViewProviderPyImp.cpp b/src/Gui/ViewProviderPyImp.cpp index c8669d99f8..506050f9fc 100644 --- a/src/Gui/ViewProviderPyImp.cpp +++ b/src/Gui/ViewProviderPyImp.cpp @@ -320,11 +320,7 @@ PyObject* ViewProviderPy::listDisplayModes(PyObject *args) int i=0; for ( std::vector::iterator it = modes.begin(); it != modes.end(); ++it ) { -#if PY_MAJOR_VERSION >= 3 PyObject* str = PyUnicode_FromString(it->c_str()); -#else - PyObject* str = PyString_FromString(it->c_str()); -#endif PyList_SetItem(pyList, i++, str); } @@ -400,19 +396,8 @@ PyObject* ViewProviderPy::partialRender(PyObject* args) for (Py_ssize_t i = 0; i < nSize; ++i) { if(value) item = PySequence_GetItem(value, i); if (PyUnicode_Check(item)) { -#if PY_MAJOR_VERSION >= 3 values[i] = PyUnicode_AsUTF8(item); -#else - PyObject* unicode = PyUnicode_AsUTF8String(item); - values[i] = PyString_AsString(unicode); - Py_DECREF(unicode); -#endif } -#if PY_MAJOR_VERSION < 3 - else if (PyString_Check(item)) { - values[i] = PyString_AsString(item); - } -#endif else { std::string error = std::string("type must be str or unicode"); error += " not, "; From e0ab0382b315847a3ad0520df8cb8b058a6df3c6 Mon Sep 17 00:00:00 2001 From: luz paz Date: Sat, 24 Apr 2021 09:32:38 -0400 Subject: [PATCH 148/178] Part: remove py2 code --- src/Mod/Part/App/AppPartPy.cpp | 5 ----- src/Mod/Part/App/AttachEnginePyImp.cpp | 17 ---------------- src/Mod/Part/App/BSplineCurvePyImp.cpp | 8 -------- src/Mod/Part/App/BSplineSurfacePyImp.cpp | 16 --------------- .../Part/App/Geom2d/BSplineCurve2dPyImp.cpp | 20 ------------------- src/Mod/Part/App/GeometryCurvePyImp.cpp | 7 ------- src/Mod/Part/App/PropertyTopoShape.cpp | 8 -------- src/Mod/Part/App/TopoShapeEdgePyImp.cpp | 7 ------- src/Mod/Part/App/TopoShapePyImp.cpp | 10 ---------- src/Mod/Part/App/TopoShapeWirePyImp.cpp | 7 ------- src/Mod/Part/Gui/AppPartGui.cpp | 5 ----- 11 files changed, 110 deletions(-) diff --git a/src/Mod/Part/App/AppPartPy.cpp b/src/Mod/Part/App/AppPartPy.cpp index afffec947d..a0d8f59feb 100644 --- a/src/Mod/Part/App/AppPartPy.cpp +++ b/src/Mod/Part/App/AppPartPy.cpp @@ -2023,13 +2023,8 @@ private: PyErr_Clear(); PyObject* index_or_value; if (PyArg_ParseTuple(args.ptr(), "sO", &name, &index_or_value)) { -#if PY_MAJOR_VERSION >= 3 if (PyLong_Check(index_or_value)) { int ival = (int)PyLong_AsLong(index_or_value); -#else - if (PyInt_Check(index_or_value)) { - int ival = (int)PyInt_AsLong(index_or_value); -#endif if (!Interface_Static::SetIVal(name, ival)) { std::stringstream str; str << "Failed to set '" << name << "'"; diff --git a/src/Mod/Part/App/AttachEnginePyImp.cpp b/src/Mod/Part/App/AttachEnginePyImp.cpp index 0057a048ae..31c93ac01e 100644 --- a/src/Mod/Part/App/AttachEnginePyImp.cpp +++ b/src/Mod/Part/App/AttachEnginePyImp.cpp @@ -277,11 +277,7 @@ PyObject* AttachEnginePy::getModeInfo(PyObject* args) } Py::Dict ret; ret["ReferenceCombinations"] = pyListOfCombinations; -#if PY_MAJOR_VERSION >= 3 ret["ModeIndex"] = Py::Long(mmode); -#else - ret["ModeIndex"] = Py::Int(mmode); -#endif try { Py::Module module(PyImport_ImportModule("PartGui"),true); if (module.isNull() || !module.hasAttr("AttachEngineResources")) { @@ -292,11 +288,7 @@ PyObject* AttachEnginePy::getModeInfo(PyObject* args) Py::Callable method(submod.getAttr("getModeStrings")); Py::Tuple arg(2); arg.setItem(0, Py::String(this->getAttachEnginePtr()->getTypeId().getName())); -#if PY_MAJOR_VERSION >= 3 arg.setItem(1, Py::Long(mmode)); -#else - arg.setItem(1, Py::Int(mmode)); -#endif Py::List strs = method.apply(arg); assert(strs.size() == 2); ret["UserFriendlyName"] = strs[0]; @@ -369,13 +361,8 @@ PyObject* AttachEnginePy::getRefTypeInfo(PyObject* args) AttachEngine &attacher = *(this->getAttachEnginePtr()); eRefType rt = attacher.getRefTypeByName(typeName); Py::Dict ret; -#if PY_MAJOR_VERSION >= 3 ret["TypeIndex"] = Py::Long(rt); ret["Rank"] = Py::Long(AttachEngine::getTypeRank(rt)); -#else - ret["TypeIndex"] = Py::Int(rt); - ret["Rank"] = Py::Int(AttachEngine::getTypeRank(rt)); -#endif try { Py::Module module(PyImport_ImportModule("PartGui"),true); @@ -386,11 +373,7 @@ PyObject* AttachEnginePy::getRefTypeInfo(PyObject* args) Py::Object submod(module.getAttr("AttachEngineResources")); Py::Callable method(submod.getAttr("getRefTypeUserFriendlyName")); Py::Tuple arg(1); -#if PY_MAJOR_VERSION >= 3 arg.setItem(0, Py::Long(rt)); -#else - arg.setItem(0, Py::Int(rt)); -#endif Py::String st = method.apply(arg); ret["UserFriendlyName"] = st; } catch (Py::Exception& e) { diff --git a/src/Mod/Part/App/BSplineCurvePyImp.cpp b/src/Mod/Part/App/BSplineCurvePyImp.cpp index e4c84ca343..b6084fe76c 100644 --- a/src/Mod/Part/App/BSplineCurvePyImp.cpp +++ b/src/Mod/Part/App/BSplineCurvePyImp.cpp @@ -250,11 +250,7 @@ PyObject* BSplineCurvePy::insertKnots(PyObject * args) TColStd_Array1OfInteger m(1,mults.size()); index=1; for (Py::Sequence::iterator it = mults.begin(); it != mults.end(); ++it) { -#if PY_MAJOR_VERSION >= 3 Py::Long val(*it); -#else - Py::Int val(*it); -#endif m(index++) = (int)val; } @@ -1253,11 +1249,7 @@ PyObject* BSplineCurvePy::buildFromPolesMultsKnots(PyObject *args, PyObject *key Py::Sequence multssq(mults); Standard_Integer index = 1; for (Py::Sequence::iterator it = multssq.begin(); it != multssq.end() && index <= occmults.Length(); ++it) { -#if PY_MAJOR_VERSION >= 3 Py::Long mult(*it); -#else - Py::Int mult(*it); -#endif if (index < occmults.Length() || PyObject_Not(periodic)) { sum_of_mults += static_cast(mult); //sum up the mults to compare them against the number of poles later } diff --git a/src/Mod/Part/App/BSplineSurfacePyImp.cpp b/src/Mod/Part/App/BSplineSurfacePyImp.cpp index da7f502fc6..9b368f476f 100644 --- a/src/Mod/Part/App/BSplineSurfacePyImp.cpp +++ b/src/Mod/Part/App/BSplineSurfacePyImp.cpp @@ -284,11 +284,7 @@ PyObject* BSplineSurfacePy::insertUKnots(PyObject *args) TColStd_Array1OfInteger m(1,mults.size()); index=1; for (Py::Sequence::iterator it = mults.begin(); it != mults.end(); ++it) { -#if PY_MAJOR_VERSION >= 3 Py::Long val(*it); -#else - Py::Int val(*it); -#endif m(index++) = (int)val; } @@ -349,11 +345,7 @@ PyObject* BSplineSurfacePy::insertVKnots(PyObject *args) TColStd_Array1OfInteger m(1,mults.size()); index=1; for (Py::Sequence::iterator it = mults.begin(); it != mults.end(); ++it) { -#if PY_MAJOR_VERSION >= 3 Py::Long val(*it); -#else - Py::Int val(*it); -#endif m(index++) = (int)val; } @@ -1423,11 +1415,7 @@ PyObject* BSplineSurfacePy::buildFromPolesMultsKnots(PyObject *args, PyObject *k Py::Sequence umultssq(umults); Standard_Integer index = 1; for (Py::Sequence::iterator it = umultssq.begin(); it != umultssq.end() && index <= occumults.Length(); ++it) { -#if PY_MAJOR_VERSION >= 3 Py::Long mult(*it); -#else - Py::Int mult(*it); -#endif if (index < occumults.Length() || PyObject_Not(uperiodic)) { sum_of_umults += static_cast(mult); //sum up the mults to compare them against the number of poles later } @@ -1436,11 +1424,7 @@ PyObject* BSplineSurfacePy::buildFromPolesMultsKnots(PyObject *args, PyObject *k Py::Sequence vmultssq(vmults); index = 1; for (Py::Sequence::iterator it = vmultssq.begin(); it != vmultssq.end() && index <= occvmults.Length(); ++it) { -#if PY_MAJOR_VERSION >= 3 Py::Long mult(*it); -#else - Py::Int mult(*it); -#endif if (index < occvmults.Length() || PyObject_Not(vperiodic)) { sum_of_vmults += static_cast(mult); //sum up the mults to compare them against the number of poles later } diff --git a/src/Mod/Part/App/Geom2d/BSplineCurve2dPyImp.cpp b/src/Mod/Part/App/Geom2d/BSplineCurve2dPyImp.cpp index e0f7a8238a..1c69f6211e 100644 --- a/src/Mod/Part/App/Geom2d/BSplineCurve2dPyImp.cpp +++ b/src/Mod/Part/App/Geom2d/BSplineCurve2dPyImp.cpp @@ -214,11 +214,7 @@ PyObject* BSplineCurve2dPy::insertKnots(PyObject * args) TColStd_Array1OfInteger m(1,mults.size()); index=1; for (Py::Sequence::iterator it = mults.begin(); it != mults.end(); ++it) { -#if PY_MAJOR_VERSION >= 3 Py::Long val(*it); -#else - Py::Int val(*it); -#endif m(index++) = (int)val; } @@ -649,11 +645,7 @@ PyObject* BSplineCurve2dPy::getMultiplicities(PyObject * args) curve->Multiplicities(m); Py::List mults; for (Standard_Integer i=m.Lower(); i<=m.Upper(); i++) { -#if PY_MAJOR_VERSION >= 3 mults.append(Py::Long(m(i))); -#else - mults.append(Py::Int(m(i))); -#endif } return Py::new_reference_to(mults); } @@ -724,22 +716,14 @@ Py::Object BSplineCurve2dPy::getFirstUKnotIndex(void) const { Handle(Geom2d_BSplineCurve) curve = Handle(Geom2d_BSplineCurve)::DownCast (getGeometry2dPtr()->handle()); -#if PY_MAJOR_VERSION >= 3 return Py::Long(curve->FirstUKnotIndex()); -#else - return Py::Int(curve->FirstUKnotIndex()); -#endif } Py::Object BSplineCurve2dPy::getLastUKnotIndex(void) const { Handle(Geom2d_BSplineCurve) curve = Handle(Geom2d_BSplineCurve)::DownCast (getGeometry2dPtr()->handle()); -#if PY_MAJOR_VERSION >= 3 return Py::Long(curve->LastUKnotIndex()); -#else - return Py::Int(curve->LastUKnotIndex()); -#endif } Py::List BSplineCurve2dPy::getKnotSequence(void) const @@ -1224,11 +1208,7 @@ PyObject* BSplineCurve2dPy::buildFromPolesMultsKnots(PyObject *args, PyObject *k Py::Sequence multssq(mults); Standard_Integer index = 1; for (Py::Sequence::iterator it = multssq.begin(); it != multssq.end() && index <= occmults.Length(); ++it) { -#if PY_MAJOR_VERSION >=3 Py::Long mult(*it); -#else - Py::Int mult(*it); -#endif if (index < occmults.Length() || PyObject_Not(periodic)) { sum_of_mults += (int)mult; //sum up the mults to compare them against the number of poles later } diff --git a/src/Mod/Part/App/GeometryCurvePyImp.cpp b/src/Mod/Part/App/GeometryCurvePyImp.cpp index 813a8932ab..6cc12f6760 100644 --- a/src/Mod/Part/App/GeometryCurvePyImp.cpp +++ b/src/Mod/Part/App/GeometryCurvePyImp.cpp @@ -149,17 +149,10 @@ PyObject* GeometryCurvePy::discretize(PyObject *args, PyObject *kwds) // use no kwds PyObject* dist_or_num; if (PyArg_ParseTuple(args, "O", &dist_or_num)) { -#if PY_MAJOR_VERSION >= 3 if (PyLong_Check(dist_or_num)) { numPoints = PyLong_AsLong(dist_or_num); uniformAbscissaPoints = true; } -#else - if (PyInt_Check(dist_or_num)) { - numPoints = PyInt_AsLong(dist_or_num); - uniformAbscissaPoints = true; - } -#endif else if (PyFloat_Check(dist_or_num)) { distance = PyFloat_AsDouble(dist_or_num); uniformAbscissaDistance = true; diff --git a/src/Mod/Part/App/PropertyTopoShape.cpp b/src/Mod/Part/App/PropertyTopoShape.cpp index ca011e5e4b..6743402e0a 100644 --- a/src/Mod/Part/App/PropertyTopoShape.cpp +++ b/src/Mod/Part/App/PropertyTopoShape.cpp @@ -507,11 +507,7 @@ PyObject *PropertyFilletEdges::getPyObject(void) int index = 0; for (it = _lValueList.begin(); it != _lValueList.end(); ++it) { Py::Tuple ent(3); -#if PY_MAJOR_VERSION >= 3 ent.setItem(0, Py::Long(it->edgeid)); -#else - ent.setItem(0, Py::Int(it->edgeid)); -#endif ent.setItem(1, Py::Float(it->radius1)); ent.setItem(2, Py::Float(it->radius2)); list[index++] = ent; @@ -528,11 +524,7 @@ void PropertyFilletEdges::setPyObject(PyObject *value) for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) { FilletElement fe; Py::Tuple ent(*it); -#if PY_MAJOR_VERSION >= 3 fe.edgeid = (int)Py::Long(ent.getItem(0)); -#else - fe.edgeid = (int)Py::Int(ent.getItem(0)); -#endif fe.radius1 = (double)Py::Float(ent.getItem(1)); fe.radius2 = (double)Py::Float(ent.getItem(2)); values.push_back(fe); diff --git a/src/Mod/Part/App/TopoShapeEdgePyImp.cpp b/src/Mod/Part/App/TopoShapeEdgePyImp.cpp index a915a4a750..dd124fef39 100644 --- a/src/Mod/Part/App/TopoShapeEdgePyImp.cpp +++ b/src/Mod/Part/App/TopoShapeEdgePyImp.cpp @@ -491,17 +491,10 @@ PyObject* TopoShapeEdgePy::discretize(PyObject *args, PyObject *kwds) // use no kwds PyObject* dist_or_num; if (PyArg_ParseTuple(args, "O", &dist_or_num)) { -#if PY_MAJOR_VERSION >= 3 if (PyLong_Check(dist_or_num)) { numPoints = PyLong_AsLong(dist_or_num); uniformAbscissaPoints = true; } -#else - if (PyInt_Check(dist_or_num)) { - numPoints = PyInt_AsLong(dist_or_num); - uniformAbscissaPoints = true; - } -#endif else if (PyFloat_Check(dist_or_num)) { distance = PyFloat_AsDouble(dist_or_num); uniformAbscissaDistance = true; diff --git a/src/Mod/Part/App/TopoShapePyImp.cpp b/src/Mod/Part/App/TopoShapePyImp.cpp index 89dc9c5766..6d3edd729f 100644 --- a/src/Mod/Part/App/TopoShapePyImp.cpp +++ b/src/Mod/Part/App/TopoShapePyImp.cpp @@ -2150,15 +2150,9 @@ PyObject* TopoShapePy::makeShapeFromMesh(PyObject *args) for (Py::Sequence::iterator it = facets.begin(); it != facets.end(); ++it) { Data::ComplexGeoData::Facet face; Py::Tuple f(*it); -#if PY_MAJOR_VERSION >= 3 face.I1 = (int)Py::Long(f[0]); face.I2 = (int)Py::Long(f[1]); face.I3 = (int)Py::Long(f[2]); -#else - face.I1 = (int)Py::Int(f[0]); - face.I2 = (int)Py::Int(f[1]); - face.I3 = (int)Py::Int(f[2]); -#endif Facets.push_back(face); } @@ -2547,11 +2541,7 @@ PyObject* _getSupportIndex(const char* suppStr, TopoShape* ts, TopoDS_Shape supp break; } } -#if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(supportIndex); -#else - return PyInt_FromLong(supportIndex); -#endif } PyObject* TopoShapePy::proximity(PyObject *args) diff --git a/src/Mod/Part/App/TopoShapeWirePyImp.cpp b/src/Mod/Part/App/TopoShapeWirePyImp.cpp index 800546abb2..95c1aff681 100644 --- a/src/Mod/Part/App/TopoShapeWirePyImp.cpp +++ b/src/Mod/Part/App/TopoShapeWirePyImp.cpp @@ -376,17 +376,10 @@ PyObject* TopoShapeWirePy::discretize(PyObject *args, PyObject *kwds) // use no kwds PyObject* dist_or_num; if (PyArg_ParseTuple(args, "O", &dist_or_num)) { -#if PY_MAJOR_VERSION >= 3 if (PyLong_Check(dist_or_num)) { numPoints = PyLong_AsLong(dist_or_num); uniformAbscissaPoints = true; } -#else - if (PyInt_Check(dist_or_num)) { - numPoints = PyInt_AsLong(dist_or_num); - uniformAbscissaPoints = true; - } -#endif else if (PyFloat_Check(dist_or_num)) { distance = PyFloat_AsDouble(dist_or_num); uniformAbscissaDistance = true; diff --git a/src/Mod/Part/Gui/AppPartGui.cpp b/src/Mod/Part/Gui/AppPartGui.cpp index e6c62db27b..1addb59b70 100644 --- a/src/Mod/Part/Gui/AppPartGui.cpp +++ b/src/Mod/Part/Gui/AppPartGui.cpp @@ -132,7 +132,6 @@ PyMOD_INIT_FUNC(PartGui) Gui::BitmapFactory().addPath(QString::fromLatin1(":/icons/parametric")); Gui::BitmapFactory().addPath(QString::fromLatin1(":/icons/tools")); -#if PY_MAJOR_VERSION >= 3 static struct PyModuleDef pAttachEngineTextsModuleDef = { PyModuleDef_HEAD_INIT, "AttachEngineResources", @@ -141,10 +140,6 @@ PyMOD_INIT_FUNC(PartGui) NULL, NULL, NULL, NULL }; PyObject* pAttachEngineTextsModule = PyModule_Create(&pAttachEngineTextsModuleDef); -#else - PyObject* pAttachEngineTextsModule = Py_InitModule3("AttachEngineResources", AttacherGui::AttacherGuiPy::Methods, - "AttachEngine Gui resources"); -#endif Py_INCREF(pAttachEngineTextsModule); PyModule_AddObject(partGuiModule, "AttachEngineResources", pAttachEngineTextsModule); From 8c4d77f2cadf10bcb49ae356ef1dec1e60ed3e7d Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 25 Apr 2021 13:15:20 +0200 Subject: [PATCH 149/178] TD: do not delete mtextedit.h for in-source builds --- src/Mod/TechDraw/Gui/CMakeLists.txt | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/Mod/TechDraw/Gui/CMakeLists.txt b/src/Mod/TechDraw/Gui/CMakeLists.txt index eb9660bcd6..722cc0d3c3 100644 --- a/src/Mod/TechDraw/Gui/CMakeLists.txt +++ b/src/Mod/TechDraw/Gui/CMakeLists.txt @@ -6,9 +6,11 @@ endif(MSVC) # In previous versions this target copied mtextedit.h to the binary directory that causes # automoc to generate linking errors. -if (EXISTS ${CMAKE_CURRENT_BINARY_DIR}/mtextedit.h) - file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/mtextedit.h) - execute_process(COMMAND "${CMAKE_COMMAND}" -E touch_nocreate "${CMAKE_CURRENT_SOURCE_DIR}/mtextedit.h") +if(NOT ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) + if (EXISTS ${CMAKE_CURRENT_BINARY_DIR}/mtextedit.h) + file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/mtextedit.h) + execute_process(COMMAND "${CMAKE_COMMAND}" -E touch_nocreate "${CMAKE_CURRENT_SOURCE_DIR}/mtextedit.h") + endif() endif() include_directories( From 1e82643eed7a66d1af159449e54e2269eeccd132 Mon Sep 17 00:00:00 2001 From: Keith Sloan Date: Sun, 25 Apr 2021 15:10:46 +0100 Subject: [PATCH 150/178] Add load/save/refresh to addElement --- src/Mod/OpenSCAD/OpenSCADCommands.py | 45 +++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/src/Mod/OpenSCAD/OpenSCADCommands.py b/src/Mod/OpenSCAD/OpenSCADCommands.py index 7a1928e15a..22fd7efced 100644 --- a/src/Mod/OpenSCAD/OpenSCADCommands.py +++ b/src/Mod/OpenSCAD/OpenSCADCommands.py @@ -328,12 +328,17 @@ class AddSCADWidget(QtGui.QWidget): def __init__(self,*args): QtGui.QWidget.__init__(self,*args) self.textEdit=QtGui.QTextEdit() - self.textEdit.setAcceptRichText(False) self.buttonadd = QtGui.QPushButton(translate('OpenSCAD','Add')) self.buttonclear = QtGui.QPushButton(translate('OpenSCAD','Clear')) + self.buttonload = QtGui.QPushButton(translate('OpenSCAD','Load')) + self.buttonsave = QtGui.QPushButton(translate('OpenSCAD','Save')) + self.buttonrefresh = QtGui.QPushButton(translate('OpenSCAD','Refresh')) self.checkboxmesh = QtGui.QCheckBox(translate('OpenSCAD','as Mesh')) layouth=QtGui.QHBoxLayout() layouth.addWidget(self.buttonadd) + layouth.addWidget(self.buttonload) + layouth.addWidget(self.buttonsave) + layouth.addWidget(self.buttonrefresh) layouth.addWidget(self.buttonclear) layout= QtGui.QVBoxLayout() layout.addLayout(layouth) @@ -354,6 +359,9 @@ class AddSCADTask: def __init__(self): self.form = AddSCADWidget() self.form.buttonadd.clicked.connect(self.addelement) + self.form.buttonload.clicked.connect(self.loadelement) + self.form.buttonsave.clicked.connect(self.saveelement) + self.form.buttonrefresh.clicked.connect(self.refreshelement) def getStandardButtons(self): return int(QtGui.QDialogButtonBox.Close) @@ -387,7 +395,42 @@ class AddSCADTask: except OpenSCADUtils.OpenSCADError as e: FreeCAD.Console.PrintError(e.value) + + def refreshelement(self): + print('Refresh Element') + doc=FreeCAD.activeDocument() + if doc : + for obj in doc.Objects : + doc.removeObject(obj.Name) + self.addelement() + def loadelement(self): + print('Load Element') + print('Load Element') + filename, filter = QtGui.QFileDialog.getOpenFileName(parent=self.form, caption='Open file', dir='.', filter='OpenSCAD Files (*.scad)',selectedFilter='',option=0) + + if filename: + print('filename :'+filename) + fp = open(filename,'r') + with fp: + data = fp.read() + self.form.textEdit.setText(data) + + def saveelement(self) : + print('Save Element') + filename, filter = QtGui.QFileDialog.getSaveFileName(parent=self.form, caption='Open file', dir='.', filter='OpenSCAD Files (*.scad)',selectedFilter='',option=0) + + if filename: + print('filename :'+filename) + Text = self.form.textEdit.toPlainText() + fp = open(filename,'w') + with fp: + fp.write(Text) + +class OpenSCADMeshBooleanWidget(QtGui.QWidget): + def __init__(self,*args): + QtGui.QWidget.__init__(self,*args) + #self.textEdit=QtGui.QTextEdit() class OpenSCADMeshBooleanWidget(QtGui.QWidget): def __init__(self,*args): QtGui.QWidget.__init__(self,*args) From 5626bab0558004724e9feda224fcbf33ca02d25f Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 25 Apr 2021 21:58:24 +0200 Subject: [PATCH 151/178] App: [skip ci] fix memory leaks: Found two memory leaks in class Enumeration * method tearDown() always ignored to free the memory of the first element * assignment operator didn't call tearDown() when needed --- src/App/Enumeration.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/App/Enumeration.cpp b/src/App/Enumeration.cpp index f9a346c55c..bda0899206 100644 --- a/src/App/Enumeration.cpp +++ b/src/App/Enumeration.cpp @@ -84,8 +84,8 @@ void Enumeration::tearDown(void) char **plEnums = (char **)_EnumArray; // Delete C Strings first - while (*(plEnums++) != NULL) { - free(*plEnums); + while (*plEnums != NULL) { + free(*(plEnums++)); } delete [] _EnumArray; @@ -288,9 +288,16 @@ bool Enumeration::isValid(void) const Enumeration & Enumeration::operator=(const Enumeration &other) { + if (this == &other) + return *this; + if (other._ownEnumArray) { setEnums(other.getEnumVector()); } else { + if (isValid() && _ownEnumArray) { + tearDown(); + } + _EnumArray = other._EnumArray; } From 1d4722f32c6ba1386d8d913e0669856ece11f36a Mon Sep 17 00:00:00 2001 From: bitacovir Date: Sun, 25 Apr 2021 10:34:09 -0400 Subject: [PATCH 152/178] [UI] Replace SVG icon files for Plain SVG format --- .../icons/geometry/Sketcher_Split.svg | 768 +++++++----------- .../pointers/Sketcher_Pointer_Splitting.svg | 88 +- 2 files changed, 342 insertions(+), 514 deletions(-) diff --git a/src/Mod/Sketcher/Gui/Resources/icons/geometry/Sketcher_Split.svg b/src/Mod/Sketcher/Gui/Resources/icons/geometry/Sketcher_Split.svg index 65f04b8eae..bc965d49d1 100644 --- a/src/Mod/Sketcher/Gui/Resources/icons/geometry/Sketcher_Split.svg +++ b/src/Mod/Sketcher/Gui/Resources/icons/geometry/Sketcher_Split.svg @@ -1,6 +1,4 @@ - - + height="64px" + width="64px"> + fx="225.26402" + cy="672.79736" + cx="225.26402" + gradientTransform="matrix(1,0,0,0.6985294,0,202.82863)" + gradientUnits="userSpaceOnUse" + id="radialGradient4274" + xlink:href="#linearGradient3144" /> + style="stop-color:#ffffff;stop-opacity:1;" /> + style="stop-color:#ffffff;stop-opacity:0;" /> - + fx="225.26402" + cy="672.79736" + cx="225.26402" + gradientTransform="matrix(1,0,0,0.6985294,0,202.82863)" + gradientUnits="userSpaceOnUse" + id="radialGradient4272" + xlink:href="#linearGradient3144" /> + style="stop-color:#c4a000;stop-opacity:1;" /> + style="stop-color:#fce94f;stop-opacity:1;" /> + y1="18" + x1="-18" + gradientUnits="userSpaceOnUse" + id="linearGradient3801-1-3" + xlink:href="#linearGradient3836-0-6" /> + style="stop-color:#a40000;stop-opacity:1" /> + style="stop-color:#ef2929;stop-opacity:1" /> + y1="18" + x1="-18" + gradientUnits="userSpaceOnUse" + id="linearGradient3801-1-3-3" + xlink:href="#linearGradient3836-0-6-6" /> + style="stop-color:#a40000;stop-opacity:1" /> + style="stop-color:#ef2929;stop-opacity:1" /> - + - + - + - - + - + - + - + - - + - - + - + - + - - + + id="radialGradient3675-8" + gradientUnits="userSpaceOnUse" + gradientTransform="matrix(1,0,0,0.6985294,0,202.82863)" + cx="225.26402" + cy="672.79736" + fx="225.26402" + fy="672.79736" + r="34.345188" /> + x1="10.504496" + y1="16.48678" + x2="5.9349073" + y2="1.6356687" + id="linearGradient-1"> + id="stop5308" /> + id="stop5310" /> + id="linearGradient3963"> + id="stop3965" /> + id="stop3967" /> + id="stop3595" /> + id="stop3597" /> + style="stop-color:#71b2f8;stop-opacity:1;" /> + style="stop-color:#002795;stop-opacity:1;" /> - - + - - - - - + + + + + - + - + - + - + + x1="-13" + y1="35" + x2="-20" + y2="38" + gradientUnits="userSpaceOnUse" /> + id="linearGradient3978" + gradientUnits="userSpaceOnUse" + x1="-15" + y1="37" + x2="-19" + y2="37" + gradientTransform="rotate(15,69.468151,244.38323)" /> - - - @@ -524,7 +409,7 @@ FreeCAD - FreeCAD/src/Mod/Sketcher/Gui/Resources/icons/Sketcher_CreateLine.svg + FreeCAD LGPL2+ @@ -540,127 +425,106 @@ + id="layer1"> + transform="matrix(0.1621282,0,0,0.1621282,6.3605986,-66.108806)" + id="g4289"> + transform="rotate(178.46629,109.91858,681.48533)" + id="g3154"> + id="path3063" /> + d="m 162.40856,627.63483 25.45866,26.85945 -97.662823,92.57154 -25.460812,-26.86174 z" + style="fill:#d3d7cf;stroke:#2e3436;stroke-width:12.3359;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" + transform="translate(-2.5887148e-6,-1.6278964e-5)" /> + id="g3827-1-3" + transform="matrix(-6.1657491,-0.16508637,0.16508637,-6.1657491,251.65298,959.14094)"> + id="g3797-9-5" + transform="translate(31.322131,40.570289)"> + style="fill:none;stroke:#280000;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + style="fill:url(#linearGradient3801-1-3);fill-opacity:1;stroke:#ef2929;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + id="path3063-1" /> + id="path3061" /> + id="g3827-1-3-3" + transform="matrix(-6.1657491,-0.16508637,0.16508637,-6.1657491,-1.5804401,1199.1674)"> + id="g3797-9-5-5" + transform="translate(31.322131,40.570289)"> + style="fill:none;stroke:#280000;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + style="fill:url(#linearGradient3801-1-3-3);fill-opacity:1;stroke:#ef2929;stroke-width:2;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> + transform="translate(-109.2455,94.720058)" + id="g4942"> + transform="matrix(-6.1657491,-0.16508637,0.16508637,-6.1657491,354.29343,1111.0482)" + id="g3827-1-3-7"> + transform="translate(31.322131,40.570289)" + id="g3797-9-5-53"> + d="M -26.156204,5.582626 A 8.993818,8.9934077 0.02042283 1 1 -12.493793,17.282241 8.993818,8.9934077 0.02042283 1 1 -26.156204,5.582626 Z" /> + d="M -24.633588,6.893588 A 6.9999997,7.0000001 0 1 1 -14,16 6.9999997,7.0000001 0 0 1 -24.633588,6.893588 Z" /> + transform="matrix(3.2431314,-5.2465049,5.2465049,3.2431314,-137.95207,940.74257)" + id="g3971"> + id="path3941" /> diff --git a/src/Mod/Sketcher/Gui/Resources/icons/pointers/Sketcher_Pointer_Splitting.svg b/src/Mod/Sketcher/Gui/Resources/icons/pointers/Sketcher_Pointer_Splitting.svg index e0b739dc07..ca47090f65 100644 --- a/src/Mod/Sketcher/Gui/Resources/icons/pointers/Sketcher_Pointer_Splitting.svg +++ b/src/Mod/Sketcher/Gui/Resources/icons/pointers/Sketcher_Pointer_Splitting.svg @@ -5,14 +5,10 @@ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" - xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" - xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" - version="1.1" - height="64" - width="64" id="svg8" - sodipodi:docname="Sketcher_Pointer_Split.svg" - inkscape:version="0.92.3 (2405546, 2018-03-11)"> + width="64" + height="64" + version="1.1"> @@ -21,78 +17,46 @@ image/svg+xml + - + style="fill:#cc0000;stroke:none;" + id="symbol"> + cy="32" + cx="32" /> + style="stroke:#ffffff;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:miter;" + id="crosshair"> + id="path5" + d="m16,3v9m0,8v9m-13-13h9m8,0h9" /> - + - + r="5" + id="circle4757" + style="fill:none;stroke:#cc0000;stroke-width:2" /> + + d="M 43.754846,38.836982 56,27" + style="fill:none;fill-rule:evenodd;stroke:#cc0000;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" /> From 59b7e9fdd0d1c41a453110c22080f4674c6073dc Mon Sep 17 00:00:00 2001 From: luz paz Date: Fri, 23 Apr 2021 12:48:46 -0400 Subject: [PATCH 153/178] Base: remove Py2 code --- src/Base/Console.cpp | 76 ---------------------- src/Base/Exception.cpp | 8 --- src/Base/Interpreter.cpp | 123 ------------------------------------ src/Base/MatrixPyImp.cpp | 37 ----------- src/Base/ParameterPy.cpp | 17 ----- src/Base/PlacementPyImp.cpp | 32 ---------- src/Base/PyObjectBase.h | 9 --- src/Base/PyTools.c | 32 ---------- src/Base/QuantityPyImp.cpp | 55 ---------------- src/Base/RotationPyImp.cpp | 32 ---------- src/Base/Stream.cpp | 12 ---- src/Base/Tools.cpp | 15 ----- src/Base/UnitPyImp.cpp | 29 --------- src/Base/UnitsApi.cpp | 20 ------ src/Base/VectorPyImp.cpp | 45 ------------- src/Base/swigpyrun.inl | 4 -- 16 files changed, 546 deletions(-) diff --git a/src/Base/Console.cpp b/src/Base/Console.cpp index d39a71c3ef..1f0d588244 100644 --- a/src/Base/Console.cpp +++ b/src/Base/Console.cpp @@ -480,7 +480,6 @@ PyObject *ConsoleSingleton::sPyMessage(PyObject * /*self*/, PyObject *args) if (!PyArg_ParseTuple(args, "O", &output)) return NULL; -#if PY_MAJOR_VERSION >= 3 const char* string=0; PyObject* unicode=0; if (PyUnicode_Check(output)) { @@ -491,23 +490,6 @@ PyObject *ConsoleSingleton::sPyMessage(PyObject * /*self*/, PyObject *args) if (unicode) string = PyUnicode_AsUTF8(unicode); } -#else - const char* string=0; - PyObject* unicode=0; - if (PyUnicode_Check(output)) { - unicode = PyUnicode_AsEncodedObject(output, "utf-8", "strict"); - if (unicode) - string = PyString_AsString(unicode); - } - else if (PyString_Check(output)) { - string = PyString_AsString(output); - } - else { - unicode = PyObject_Str(output); - if (unicode) - string = PyString_AsString(unicode); - } -#endif PY_TRY { if (string) @@ -526,7 +508,6 @@ PyObject *ConsoleSingleton::sPyWarning(PyObject * /*self*/, PyObject *args) if (!PyArg_ParseTuple(args, "O", &output)) return NULL; -#if PY_MAJOR_VERSION >= 3 const char* string=0; PyObject* unicode=0; if (PyUnicode_Check(output)) { @@ -537,23 +518,6 @@ PyObject *ConsoleSingleton::sPyWarning(PyObject * /*self*/, PyObject *args) if (unicode) string = PyUnicode_AsUTF8(unicode); } -#else - const char* string=0; - PyObject* unicode=0; - if (PyUnicode_Check(output)) { - unicode = PyUnicode_AsEncodedObject(output, "utf-8", "strict"); - if (unicode) - string = PyString_AsString(unicode); - } - else if (PyString_Check(output)) { - string = PyString_AsString(output); - } - else { - unicode = PyObject_Str(output); - if (unicode) - string = PyString_AsString(unicode); - } -#endif PY_TRY { if (string) @@ -572,7 +536,6 @@ PyObject *ConsoleSingleton::sPyError(PyObject * /*self*/, PyObject *args) if (!PyArg_ParseTuple(args, "O", &output)) return NULL; -#if PY_MAJOR_VERSION >= 3 const char* string=0; PyObject* unicode=0; if (PyUnicode_Check(output)) { @@ -583,23 +546,6 @@ PyObject *ConsoleSingleton::sPyError(PyObject * /*self*/, PyObject *args) if (unicode) string = PyUnicode_AsUTF8(unicode); } -#else - const char* string=0; - PyObject* unicode=0; - if (PyUnicode_Check(output)) { - unicode = PyUnicode_AsEncodedObject(output, "utf-8", "strict"); - if (unicode) - string = PyString_AsString(unicode); - } - else if (PyString_Check(output)) { - string = PyString_AsString(output); - } - else { - unicode = PyObject_Str(output); - if (unicode) - string = PyString_AsString(unicode); - } -#endif PY_TRY { if (string) @@ -618,7 +564,6 @@ PyObject *ConsoleSingleton::sPyLog(PyObject * /*self*/, PyObject *args) if (!PyArg_ParseTuple(args, "O", &output)) return NULL; -#if PY_MAJOR_VERSION >= 3 const char* string=0; PyObject* unicode=0; if (PyUnicode_Check(output)) { @@ -629,23 +574,6 @@ PyObject *ConsoleSingleton::sPyLog(PyObject * /*self*/, PyObject *args) if (unicode) string = PyUnicode_AsUTF8(unicode); } -#else - const char* string=0; - PyObject* unicode=0; - if (PyUnicode_Check(output)) { - unicode = PyUnicode_AsEncodedObject(output, "utf-8", "strict"); - if (unicode) - string = PyString_AsString(unicode); - } - else if (PyString_Check(output)) { - string = PyString_AsString(output); - } - else { - unicode = PyObject_Str(output); - if (unicode) - string = PyString_AsString(unicode); - } -#endif PY_TRY { if (string) @@ -950,11 +878,7 @@ std::stringstream &LogLevel::prefix(std::stringstream &str, const char *src, int PyFrameObject* frame = PyEval_GetFrame(); if (frame) { line = PyFrame_GetLineNumber(frame); -#if PY_MAJOR_VERSION >= 3 src = PyUnicode_AsUTF8(frame->f_code->co_filename); -#else - src = PyString_AsString(frame->f_code->co_filename); -#endif } } if (print_src && src && src[0]) { diff --git a/src/Base/Exception.cpp b/src/Base/Exception.cpp index 2fca2a0de4..1efd8c0110 100644 --- a/src/Base/Exception.cpp +++ b/src/Base/Exception.cpp @@ -111,11 +111,7 @@ PyObject * Exception::getPyObject(void) edict.setItem("sclassname", Py::String(typeid(*this).name())); edict.setItem("sErrMsg", Py::String(this->getMessage())); edict.setItem("sfile", Py::String(this->getFile())); -#if PY_MAJOR_VERSION >= 3 edict.setItem("iline", Py::Long(this->getLine())); -#else - edict.setItem("iline", Py::Int(this->getLine())); -#endif edict.setItem("sfunction", Py::String(this->getFunction())); edict.setItem("swhat", Py::String(this->what())); edict.setItem("btranslatable", Py::Boolean(this->getTranslatable())); @@ -138,11 +134,7 @@ void Exception::setPyObject( PyObject * pydict) _sErrMsg = static_cast(Py::String(edict.getItem("sErrMsg"))); if (edict.hasKey("iline")) -#if PY_MAJOR_VERSION >= 3 _line = static_cast(Py::Long(edict.getItem("iline"))); -#else - _line = static_cast(Py::Int(edict.getItem("iline"))); -#endif if (edict.hasKey("btranslatable")) _isTranslatable = static_cast(Py::Boolean(edict.getItem("btranslatable"))); if (edict.hasKey("breported")) diff --git a/src/Base/Interpreter.cpp b/src/Base/Interpreter.cpp index 369c347902..82198de448 100644 --- a/src/Base/Interpreter.cpp +++ b/src/Base/Interpreter.cpp @@ -183,7 +183,6 @@ SystemExitException::SystemExitException() value = code; } -#if PY_MAJOR_VERSION >= 3 if (PyLong_Check(value)) { errCode = PyLong_AsLong(value); } @@ -192,16 +191,6 @@ SystemExitException::SystemExitException() if (str) errMsg = errMsg + ": " + str; } -#else - if (PyInt_Check(value)) { - errCode = PyInt_AsLong(value); - } - else { - const char *str = PyString_AsString(value); - if (str) - errMsg = errMsg + ": " + str; - } -#endif } _sErrMsg = errMsg; @@ -279,11 +268,7 @@ std::string InterpreterSingleton::runString(const char *sCmd) PyObject* repr = PyObject_Repr(presult); Py_DECREF(presult); if (repr) { -#if PY_MAJOR_VERSION >= 3 std::string ret(PyUnicode_AsUTF8(repr)); -#else - std::string ret(PyString_AsString(repr)); -#endif Py_DECREF(repr); return ret; } @@ -328,12 +313,8 @@ std::string InterpreterSingleton::runStringWithKey(const char *psCmd, const char if (!key_return_value.isString()) key_return_value = key_return_value.str(); -#if PY_MAJOR_VERSION >= 3 Py::Bytes str = Py::String(key_return_value).encode("utf-8", "~E~"); std::string result = static_cast(str); -#else - std::string result = static_cast(Py::String(key_return_value)); -#endif return result; } @@ -368,10 +349,6 @@ void InterpreterSingleton::systemExit(void) int exitcode = 0; PyErr_Fetch(&exception, &value, &tb); -#if PY_MAJOR_VERSION < 3 - if (Py_FlushLine()) - PyErr_Clear(); -#endif fflush(stdout); if (value == NULL || value == Py_None) goto done; @@ -387,13 +364,8 @@ void InterpreterSingleton::systemExit(void) /* If we failed to dig out the 'code' attribute, just let the else clause below print the error. */ } -#if PY_MAJOR_VERSION < 3 - if (PyInt_Check(value)) - exitcode = (int)PyInt_AsLong(value); -#else if (PyLong_Check(value)) exitcode = (int)PyLong_AsLong(value); -#endif else { PyObject_Print(value, stderr, Py_PRINT_RAW); PySys_WriteStderr("\n"); @@ -435,13 +407,8 @@ void InterpreterSingleton::runInteractiveString(const char *sCmd) RuntimeError exc(""); // do not use PyException since this clears the error indicator if (errdata) { -#if PY_MAJOR_VERSION >= 3 if (PyUnicode_Check(errdata)) exc.setMessage(PyUnicode_AsUTF8(errdata)); -#else - if (PyString_Check(errdata)) - exc.setMessage(PyString_AsString(errdata)); -#endif } PyErr_Restore(errobj, errdata, errtraceback); if (PyErr_Occurred()) @@ -476,11 +443,7 @@ void InterpreterSingleton::runFile(const char*pxFileName, bool local) } if (PyDict_GetItemString(dict, "__file__") == NULL) { -#if PY_MAJOR_VERSION >= 3 PyObject *f = PyUnicode_FromString(pxFileName); -#else - PyObject *f = PyString_FromString(pxFileName); -#endif if (f == NULL) { fclose(fp); Py_DECREF(dict); @@ -585,7 +548,6 @@ const char* InterpreterSingleton::init(int argc,char *argv[]) PyEval_InitThreads(); #endif -#if PY_MAJOR_VERSION >= 3 size_t size = argc; static std::vector _argv(size); for (int i = 0; i < argc; i++) { @@ -596,22 +558,15 @@ const char* InterpreterSingleton::init(int argc,char *argv[]) #endif } PySys_SetArgv(argc, _argv.data()); -#else - PySys_SetArgv(argc, argv); -#endif PythonStdOutput::init_type(); this->_global = PyEval_SaveThread(); } -#if PY_MAJOR_VERSION >= 3 PyGILStateLocker lock; #if PY_MINOR_VERSION >= 5 return Py_EncodeLocale(Py_GetPath(),NULL); #else return _Py_wchar2char(Py_GetPath(),NULL); #endif -#else - return Py_GetPath(); -#endif } void InterpreterSingleton::replaceStdOutput() @@ -873,42 +828,13 @@ int getSWIGVersionFromModule(const std::string& module) #if (defined(HAVE_SWIG) && (HAVE_SWIG == 1)) namespace Swig_python { extern int createSWIGPointerObj_T(const char* TypeName, void* obj, PyObject** ptr, int own); } #endif -#if PY_MAJOR_VERSION < 3 -namespace Swig_1_3_25 { extern int createSWIGPointerObj_T(const char* TypeName, void* obj, PyObject** ptr, int own); } -namespace Swig_1_3_33 { extern int createSWIGPointerObj_T(const char* TypeName, void* obj, PyObject** ptr, int own); } -namespace Swig_1_3_36 { extern int createSWIGPointerObj_T(const char* TypeName, void* obj, PyObject** ptr, int own); } -namespace Swig_1_3_38 { extern int createSWIGPointerObj_T(const char* TypeName, void* obj, PyObject** ptr, int own); } -namespace Swig_1_3_40 { extern int createSWIGPointerObj_T(const char* TypeName, void* obj, PyObject** ptr, int own); } -#endif PyObject* InterpreterSingleton::createSWIGPointerObj(const char* Module, const char* TypeName, void* Pointer, int own) { int result = 0; PyObject* proxy=0; PyGILStateLocker locker; -#if PY_MAJOR_VERSION < 3 - int version = getSWIGVersionFromModule(Module); - switch (version) - { - case 66329: - result = Swig_1_3_25::createSWIGPointerObj_T(TypeName, Pointer, &proxy, own); - break; - case 66337: - result = Swig_1_3_33::createSWIGPointerObj_T(TypeName, Pointer, &proxy, own); - break; - case 66340: - result = Swig_1_3_36::createSWIGPointerObj_T(TypeName, Pointer, &proxy, own); - break; - case 66342: - result = Swig_1_3_38::createSWIGPointerObj_T(TypeName, Pointer, &proxy, own); - break; - case 66344: - result = Swig_1_3_40::createSWIGPointerObj_T(TypeName, Pointer, &proxy, own); - break; - default: -#else (void)Module; -#endif #if (defined(HAVE_SWIG) && (HAVE_SWIG == 1)) result = Swig_python::createSWIGPointerObj_T(TypeName, Pointer, &proxy, own); #else @@ -917,9 +843,6 @@ PyObject* InterpreterSingleton::createSWIGPointerObj(const char* Module, const c (void)own; result = -1; // indicates error #endif -#if PY_MAJOR_VERSION < 3 - } -#endif if (result == 0) return proxy; @@ -931,41 +854,12 @@ PyObject* InterpreterSingleton::createSWIGPointerObj(const char* Module, const c #if (defined(HAVE_SWIG) && (HAVE_SWIG == 1)) namespace Swig_python { extern int convertSWIGPointerObj_T(const char* TypeName, PyObject* obj, void** ptr, int flags); } #endif -#if PY_MAJOR_VERSION < 3 -namespace Swig_1_3_25 { extern int convertSWIGPointerObj_T(const char* TypeName, PyObject* obj, void** ptr, int flags); } -namespace Swig_1_3_33 { extern int convertSWIGPointerObj_T(const char* TypeName, PyObject* obj, void** ptr, int flags); } -namespace Swig_1_3_36 { extern int convertSWIGPointerObj_T(const char* TypeName, PyObject* obj, void** ptr, int flags); } -namespace Swig_1_3_38 { extern int convertSWIGPointerObj_T(const char* TypeName, PyObject* obj, void** ptr, int flags); } -namespace Swig_1_3_40 { extern int convertSWIGPointerObj_T(const char* TypeName, PyObject* obj, void** ptr, int flags); } -#endif bool InterpreterSingleton::convertSWIGPointerObj(const char* Module, const char* TypeName, PyObject* obj, void** ptr, int flags) { int result = 0; PyGILStateLocker locker; -#if PY_MAJOR_VERSION < 3 - int version = getSWIGVersionFromModule(Module); - switch (version) - { - case 66329: - result = Swig_1_3_25::convertSWIGPointerObj_T(TypeName, obj, ptr, flags); - break; - case 66337: - result = Swig_1_3_33::convertSWIGPointerObj_T(TypeName, obj, ptr, flags); - break; - case 66340: - result = Swig_1_3_36::convertSWIGPointerObj_T(TypeName, obj, ptr, flags); - break; - case 66342: - result = Swig_1_3_38::convertSWIGPointerObj_T(TypeName, obj, ptr, flags); - break; - case 66344: - result = Swig_1_3_40::convertSWIGPointerObj_T(TypeName, obj, ptr, flags); - break; - default: -#else (void)Module; -#endif #if (defined(HAVE_SWIG) && (HAVE_SWIG == 1)) result = Swig_python::convertSWIGPointerObj_T(TypeName, obj, ptr, flags); #else @@ -975,9 +869,6 @@ bool InterpreterSingleton::convertSWIGPointerObj(const char* Module, const char* (void)flags; result = -1; // indicates error #endif -#if PY_MAJOR_VERSION < 3 - } -#endif if (result == 0) return true; @@ -989,13 +880,6 @@ bool InterpreterSingleton::convertSWIGPointerObj(const char* Module, const char* #if (defined(HAVE_SWIG) && (HAVE_SWIG == 1)) namespace Swig_python { extern void cleanupSWIG_T(const char* TypeName); } #endif -#if PY_MAJOR_VERSION < 3 -namespace Swig_1_3_25 { extern void cleanupSWIG_T(const char* TypeName); } -namespace Swig_1_3_33 { extern void cleanupSWIG_T(const char* TypeName); } -namespace Swig_1_3_36 { extern void cleanupSWIG_T(const char* TypeName); } -namespace Swig_1_3_38 { extern void cleanupSWIG_T(const char* TypeName); } -namespace Swig_1_3_40 { extern void cleanupSWIG_T(const char* TypeName); } -#endif void InterpreterSingleton::cleanupSWIG(const char* TypeName) { @@ -1005,11 +889,4 @@ void InterpreterSingleton::cleanupSWIG(const char* TypeName) #else (void)TypeName; #endif -#if PY_MAJOR_VERSION < 3 - Swig_1_3_25::cleanupSWIG_T(TypeName); - Swig_1_3_33::cleanupSWIG_T(TypeName); - Swig_1_3_36::cleanupSWIG_T(TypeName); - Swig_1_3_38::cleanupSWIG_T(TypeName); - Swig_1_3_40::cleanupSWIG_T(TypeName); -#endif } diff --git a/src/Base/MatrixPyImp.cpp b/src/Base/MatrixPyImp.cpp index 65b6364e79..00c9ff9333 100644 --- a/src/Base/MatrixPyImp.cpp +++ b/src/Base/MatrixPyImp.cpp @@ -163,11 +163,7 @@ PyObject * MatrixPy::number_power_handler (PyObject* self, PyObject* other, PyOb { if (!PyObject_TypeCheck(self, &(MatrixPy::Type)) || -#if PY_MAJOR_VERSION < 3 - !PyInt_Check(other) -#else !PyLong_Check(other) -#endif || arg != Py_None ) { @@ -613,11 +609,7 @@ PyObject* MatrixPy::analyze(PyObject * args) PY_TRY { std::string type = getMatrixPtr()->analyse(); -#if PY_MAJOR_VERSION < 3 - return PyString_FromString(type.c_str()); -#else return PyUnicode_FromString(type.c_str()); -#endif } PY_CATCH; } @@ -909,43 +901,14 @@ PyObject * MatrixPy::number_or_handler (PyObject* /*self*/, PyObject* /*other*/) return 0; } -#if PY_MAJOR_VERSION < 3 -int MatrixPy::number_coerce_handler (PyObject ** /*self*/, PyObject ** /*other*/) -{ - return 1; -} -#endif - PyObject * MatrixPy::number_int_handler (PyObject * /*self*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); return 0; } -#if PY_MAJOR_VERSION < 3 -PyObject * MatrixPy::number_long_handler (PyObject * /*self*/) -{ - PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; -} -#endif - PyObject * MatrixPy::number_float_handler (PyObject * /*self*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); return 0; } - -#if PY_MAJOR_VERSION < 3 -PyObject * MatrixPy::number_oct_handler (PyObject * /*self*/) -{ - PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; -} - -PyObject * MatrixPy::number_hex_handler (PyObject * /*self*/) -{ - PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; -} -#endif diff --git a/src/Base/ParameterPy.cpp b/src/Base/ParameterPy.cpp index d5d95519da..fb5bfe5c1b 100644 --- a/src/Base/ParameterPy.cpp +++ b/src/Base/ParameterPy.cpp @@ -350,11 +350,7 @@ Py::Object ParameterGrpPy::getInt(const Py::Tuple& args) int Int=0; if (!PyArg_ParseTuple(args.ptr(), "s|i", &pstr,&Int)) throw Py::Exception(); -#if PY_MAJOR_VERSION < 3 - return Py::Int(_cParamGrp->GetInt(pstr,Int)); -#else return Py::Long(_cParamGrp->GetInt(pstr,Int)); -#endif } Py::Object ParameterGrpPy::getInts(const Py::Tuple& args) @@ -389,12 +385,7 @@ Py::Object ParameterGrpPy::getUnsigned(const Py::Tuple& args) unsigned int UInt=0; if (!PyArg_ParseTuple(args.ptr(), "s|I", &pstr,&UInt)) throw Py::Exception(); -#if PY_MAJOR_VERSION < 3 - PyObject* val = Py_BuildValue("I",_cParamGrp->GetUnsigned(pstr,UInt)); - return Py::asObject(val); -#else return Py::Long(_cParamGrp->GetUnsigned(pstr,UInt)); -#endif } Py::Object ParameterGrpPy::getUnsigneds(const Py::Tuple& args) @@ -660,11 +651,7 @@ Py::Object ParameterGrpPy::getContents(const Py::Tuple& args) Py::Tuple t3(3); t3.setItem(0,Py::String("Integer")); t3.setItem(1,Py::String(It3->first.c_str())); -#if PY_MAJOR_VERSION < 3 - t3.setItem(2,Py::Int(It3->second)); -#else t3.setItem(2,Py::Long(It3->second)); -#endif list.append(t3); } @@ -694,11 +681,7 @@ Py::Object ParameterGrpPy::getContents(const Py::Tuple& args) Py::Tuple t6(3); t6.setItem(0,Py::String("Unsigned Long")); t6.setItem(1,Py::String(It6->first.c_str())); -#if PY_MAJOR_VERSION < 3 - t6.setItem(2,Py::asObject(Py_BuildValue("I",It6->second))); -#else t6.setItem(2,Py::Long(It6->second)); -#endif list.append(t6); } diff --git a/src/Base/PlacementPyImp.cpp b/src/Base/PlacementPyImp.cpp index bdf8789d67..da69c0835a 100644 --- a/src/Base/PlacementPyImp.cpp +++ b/src/Base/PlacementPyImp.cpp @@ -326,11 +326,7 @@ PyObject *PlacementPy::getCustomAttributes(const char* attr) const // for backward compatibility if (strcmp(attr, "isNull") == 0) { PyObject *w, *res; -#if PY_MAJOR_VERSION >= 3 w = PyUnicode_InternFromString("isIdentity"); -#else - w = PyString_InternFromString("isIdentity"); -#endif res = PyObject_GenericGetAttr(const_cast(this), w); Py_XDECREF(w); return res; @@ -485,43 +481,15 @@ PyObject * PlacementPy::number_or_handler (PyObject* /*self*/, PyObject* /*other return 0; } -#if PY_MAJOR_VERSION < 3 -int PlacementPy::number_coerce_handler (PyObject ** /*self*/, PyObject ** /*other*/) -{ - return 1; -} -#endif - PyObject * PlacementPy::number_int_handler (PyObject * /*self*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); return 0; } -#if PY_MAJOR_VERSION < 3 -PyObject * PlacementPy::number_long_handler (PyObject * /*self*/) -{ - PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; -} -#endif - PyObject * PlacementPy::number_float_handler (PyObject * /*self*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); return 0; } -#if PY_MAJOR_VERSION < 3 -PyObject * PlacementPy::number_oct_handler (PyObject * /*self*/) -{ - PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; -} - -PyObject * PlacementPy::number_hex_handler (PyObject * /*self*/) -{ - PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; -} -#endif diff --git a/src/Base/PyObjectBase.h b/src/Base/PyObjectBase.h index a37dc0cf78..eb6ed44f32 100644 --- a/src/Base/PyObjectBase.h +++ b/src/Base/PyObjectBase.h @@ -91,17 +91,8 @@ /** Macro for initialization function of Python modules. */ -#if PY_MAJOR_VERSION >= 3 # define PyMOD_INIT_FUNC(name) PyMODINIT_FUNC PyInit_##name(void) -#else -# define PyMOD_INIT_FUNC(name) PyMODINIT_FUNC init##name(void) -#endif - -#if PY_MAJOR_VERSION >= 3 # define PyMOD_Return(name) return name -#else -# define PyMOD_Return(name) return (void)name -#endif /** * Union to convert from PyTypeObject to PyObject pointer. diff --git a/src/Base/PyTools.c b/src/Base/PyTools.c index 71785f9b94..fdb741bd4b 100644 --- a/src/Base/PyTools.c +++ b/src/Base/PyTools.c @@ -158,11 +158,7 @@ PP_Debug_Function(PyObject *func, PyObject *args) /* expand tuple at front */ // it seems that some versions of python want just 2 arguments; in that // case, remove trailing 1 -#if (PY_MAJOR_VERSION>=2)&&(PY_MINOR_VERSION>=2) oops = _PyTuple_Resize(&args, (1 + PyTuple_Size(args))); -#else - oops = _PyTuple_Resize(&args, (1 + PyTuple_Size(args)),1); -#endif oops |= PyTuple_SetItem(args, 0, func); if (oops) return NULL; /* "args = (funcobj,) + (arg,..)" */ @@ -255,15 +251,9 @@ void PP_Fetch_Error_Text() pystring = NULL; if (errobj != NULL && (pystring = PyObject_Str(errobj)) != NULL && /* str(errobj) */ -#if PY_MAJOR_VERSION >= 3 (PyUnicode_Check(pystring)) ) /* str() increfs */ { strncpy(PP_last_error_type, PyUnicode_AsUTF8(pystring), MAX); /*Py->C*/ -#else - (PyString_Check(pystring)) ) /* str() increfs */ - { - strncpy(PP_last_error_type, PyString_AsString(pystring), MAX); /*Py->C*/ -#endif PP_last_error_type[MAX-1] = '\0'; } else @@ -285,11 +275,7 @@ void PP_Fetch_Error_Text() PyObject* value = PyDict_GetItemString(errdata,"swhat"); if (value!=NULL) { -#if PY_MAJOR_VERSION < 3 - strncpy(PP_last_error_info, PyString_AsString(value), MAX); -#else strncpy(PP_last_error_info, PyUnicode_AsUTF8(value), MAX); -#endif PP_last_error_info[MAX-1] = '\0'; } @@ -298,15 +284,9 @@ void PP_Fetch_Error_Text() } else if (errdata != NULL && (pystring = PyObject_Str(errdata)) != NULL && /* str(): increfs */ -#if PY_MAJOR_VERSION >= 3 (PyUnicode_Check(pystring)) ) { strncpy(PP_last_error_info, PyUnicode_AsUTF8(pystring), MAX); /*Py->C*/ -#else - (PyString_Check(pystring)) ) - { - strncpy(PP_last_error_info, PyString_AsString(pystring), MAX); /*Py->C*/ -#endif PP_last_error_info[MAX-1] = '\0'; } else @@ -320,11 +300,7 @@ void PP_Fetch_Error_Text() pystring = NULL; if (errtraceback != NULL && -#if PY_MAJOR_VERSION < 3 - (PP_Run_Function("StringIO", "StringIO", "O", &pystring, "()") == 0) && -#else (PP_Run_Function("io", "StringIO", "O", &pystring, "()") == 0) && -#endif (PyTraceBack_Print(errtraceback, pystring) == 0) && (PP_Run_Method(pystring, "getvalue", "s", &tempstr, "()") == 0) ) @@ -338,11 +314,7 @@ void PP_Fetch_Error_Text() if(!frame) return; int line = PyFrame_GetLineNumber(frame); -#if PY_MAJOR_VERSION >= 3 const char *file = PyUnicode_AsUTF8(frame->f_code->co_filename); -#else - const char *file = PyString_AsString(frame->f_code->co_filename); -#endif #ifdef FC_OS_WIN32 const char *_f = strstr(file, "\\src\\"); #else @@ -638,11 +610,7 @@ PP_Run_Bytecode(PyObject *codeobj, /* run compiled bytecode object */ if (PP_DEBUG) presult = PP_Debug_Bytecode(codeobj, dict); /* run in pdb */ else -#if PY_MAJOR_VERSION >= 3 presult = PyEval_EvalCode((PyObject*)codeobj, dict, dict); -#else - presult = PyEval_EvalCode((PyCodeObject *)codeobj, dict, dict); -#endif return PP_Convert_Result(presult, resfmt, restarget); /* expr val to C */ } diff --git a/src/Base/QuantityPyImp.cpp b/src/Base/QuantityPyImp.cpp index 90af3385bd..bb2d79986e 100644 --- a/src/Base/QuantityPyImp.cpp +++ b/src/Base/QuantityPyImp.cpp @@ -265,26 +265,9 @@ PyObject * QuantityPy::number_int_handler (PyObject *self) } QuantityPy* q = static_cast(self); -#if PY_MAJOR_VERSION < 3 - return PyInt_FromLong((long)q->getValue()); -#else return PyLong_FromLong((long)q->getValue()); -#endif } -#if PY_MAJOR_VERSION < 3 -PyObject * QuantityPy::number_long_handler (PyObject *self) -{ - if (!PyObject_TypeCheck(self, &(QuantityPy::Type))) { - PyErr_SetString(PyExc_TypeError, "Arg must be Quantity"); - return 0; - } - - QuantityPy* q = static_cast(self); - return PyInt_FromLong((long)q->getValue()); -} -#endif - PyObject * QuantityPy::number_negative_handler (PyObject *self) { if (!PyObject_TypeCheck(self, &(QuantityPy::Type))) { @@ -324,10 +307,6 @@ static Quantity &pyToQuantity(Quantity &q, PyObject *pyobj) { q = *static_cast(pyobj)->getQuantityPtr(); else if (PyFloat_Check(pyobj)) q = Quantity(PyFloat_AsDouble(pyobj)); -#if PY_MAJOR_VERSION < 3 - else if (PyInt_Check(pyobj)) - q = Quantity(PyInt_AsLong(pyobj)); -#endif else if (PyLong_Check(pyobj)) q = Quantity(PyLong_AsLong(pyobj)); else { @@ -427,11 +406,6 @@ PyObject * QuantityPy::number_remainder_handler (PyObject *self, PyObject *other else if (PyFloat_Check(other)) { d2 = PyFloat_AsDouble(other); } -#if PY_MAJOR_VERSION < 3 - else if (PyInt_Check(other)) { - d2 = (double)PyInt_AsLong(other); - } -#endif else if (PyLong_Check(other)) { d2 = (double)PyLong_AsLong(other); } @@ -479,13 +453,6 @@ PyObject * QuantityPy::number_power_handler (PyObject *self, PyObject *other, Py double b = PyFloat_AsDouble(other); return new QuantityPy(new Quantity(a->pow(b)) ); } -#if PY_MAJOR_VERSION < 3 - else if (PyInt_Check(other)) { - Base::Quantity *a = static_cast(self) ->getQuantityPtr(); - double b = (double)PyInt_AsLong(other); - return new QuantityPy(new Quantity(a->pow(b))); - } -#endif else if (PyLong_Check(other)) { Base::Quantity *a = static_cast(self) ->getQuantityPtr(); double b = (double)PyLong_AsLong(other); @@ -641,11 +608,7 @@ void QuantityPy::setFormat(Py::Dict arg) if (arg.hasKey("NumberFormat")) { Py::Char form(arg.getItem("NumberFormat")); -#if PY_MAJOR_VERSION >= 3 std::string fmtstr = static_cast(Py::String(form)); -#else - std::string fmtstr = static_cast(form); -#endif if (fmtstr.size() != 1) throw Py::ValueError("Invalid format character"); @@ -740,21 +703,3 @@ PyObject * QuantityPy::number_or_handler (PyObject* /*self*/, PyObject* /*other* return 0; } -#if PY_MAJOR_VERSION < 3 -int QuantityPy::number_coerce_handler (PyObject** /*self*/, PyObject** /*other*/) -{ - return 1; -} - -PyObject * QuantityPy::number_oct_handler (PyObject* /*self*/) -{ - PyErr_SetString(PyExc_TypeError, "oct() argument can't be converted to oct"); - return 0; -} - -PyObject * QuantityPy::number_hex_handler (PyObject* /*self*/) -{ - PyErr_SetString(PyExc_TypeError, "hex() argument can't be converted to hex"); - return 0; -} -#endif diff --git a/src/Base/RotationPyImp.cpp b/src/Base/RotationPyImp.cpp index 7a8988aeb8..0437b26149 100644 --- a/src/Base/RotationPyImp.cpp +++ b/src/Base/RotationPyImp.cpp @@ -491,11 +491,7 @@ PyObject * RotationPy::number_power_handler (PyObject* self, PyObject* other, Py { if (!PyObject_TypeCheck(self, &(RotationPy::Type)) || -#if PY_MAJOR_VERSION < 3 - !PyInt_Check(other) -#else !PyLong_Check(other) -#endif || arg != Py_None ) { @@ -605,43 +601,15 @@ PyObject * RotationPy::number_or_handler (PyObject* /*self*/, PyObject* /*other* return 0; } -#if PY_MAJOR_VERSION < 3 -int RotationPy::number_coerce_handler (PyObject ** /*self*/, PyObject ** /*other*/) -{ - return 1; -} -#endif - PyObject * RotationPy::number_int_handler (PyObject * /*self*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); return 0; } -#if PY_MAJOR_VERSION < 3 -PyObject * RotationPy::number_long_handler (PyObject * /*self*/) -{ - PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; -} -#endif - PyObject * RotationPy::number_float_handler (PyObject * /*self*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); return 0; } -#if PY_MAJOR_VERSION < 3 -PyObject * RotationPy::number_oct_handler (PyObject * /*self*/) -{ - PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; -} - -PyObject * RotationPy::number_hex_handler (PyObject * /*self*/) -{ - PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; -} -#endif diff --git a/src/Base/Stream.cpp b/src/Base/Stream.cpp index 252d5d2a7d..9ec23ad939 100644 --- a/src/Base/Stream.cpp +++ b/src/Base/Stream.cpp @@ -572,7 +572,6 @@ PyStreambuf::int_type PyStreambuf::underflow() try { std::string c; Py::Object res(meth.apply(arg)); -#if PY_MAJOR_VERSION >= 3 if (res.isBytes()) { c = static_cast(Py::Bytes(res)); } @@ -583,9 +582,6 @@ PyStreambuf::int_type PyStreambuf::underflow() // wrong type return traits_type::eof(); } -#else - c = static_cast(Py::String(res)); -#endif n = c.size(); if (n == 0) { return traits_type::eof(); @@ -656,11 +652,7 @@ bool PyStreambuf::writeStr(const char* str, std::streamsize num) return true; } else if (type == BytesIO) { -#if PY_MAJOR_VERSION >= 3 arg.setItem(0, Py::Bytes(str, num)); -#else - arg.setItem(0, Py::String(str, num)); -#endif meth.apply(arg); return true; } @@ -675,11 +667,7 @@ bool PyStreambuf::writeStr(const char* str, std::streamsize num) catch (Py::Exception& e) { if (PyErr_ExceptionMatches(PyExc_TypeError)) { e.clear(); -#if PY_MAJOR_VERSION >= 3 arg.setItem(0, Py::Bytes(str, num)); -#else - arg.setItem(0, Py::String(str, num)); -#endif meth.apply(arg); type = BytesIO; return true; diff --git a/src/Base/Tools.cpp b/src/Base/Tools.cpp index d5b32e03dd..ad12e7d7cb 100644 --- a/src/Base/Tools.cpp +++ b/src/Base/Tools.cpp @@ -153,11 +153,7 @@ std::string Base::Tools::escapedUnicodeFromUtf8(const char *s) PyObject* escaped = PyUnicode_AsUnicodeEscapeString(unicode); if (escaped) { -#if PY_MAJOR_VERSION >= 3 escapedstr = std::string(PyBytes_AsString(escaped)); -#else - escapedstr = std::string(PyString_AsString(escaped)); -#endif Py_DECREF(escaped); } @@ -173,20 +169,9 @@ std::string Base::Tools::escapedUnicodeToUtf8(const std::string& s) PyObject* unicode = PyUnicode_DecodeUnicodeEscape(s.c_str(), s.size(), "strict"); if (!unicode) return string; -#if PY_MAJOR_VERSION >= 3 if (PyUnicode_Check(unicode)) { string = PyUnicode_AsUTF8(unicode); } -#else - if (PyUnicode_Check(unicode)) { - PyObject* value = PyUnicode_AsUTF8String(unicode); - string = PyString_AsString(value); - Py_DECREF(value); - } - else if (PyString_Check(unicode)) { - string = PyString_AsString(unicode); - } -#endif Py_DECREF(unicode); return string; } diff --git a/src/Base/UnitPyImp.cpp b/src/Base/UnitPyImp.cpp index cd1f9e1fd1..5b462c89bc 100644 --- a/src/Base/UnitPyImp.cpp +++ b/src/Base/UnitPyImp.cpp @@ -328,43 +328,14 @@ PyObject * UnitPy::number_or_handler (PyObject* /*self*/, PyObject* /*other*/) return 0; } -#if PY_MAJOR_VERSION < 3 -int UnitPy::number_coerce_handler (PyObject** /*self*/, PyObject** /*other*/) -{ - return 1; -} -#endif - PyObject * UnitPy::number_int_handler (PyObject* /*self*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); return 0; } -#if PY_MAJOR_VERSION < 3 -PyObject * UnitPy::number_long_handler (PyObject* /*self*/) -{ - PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; -} -#endif - PyObject * UnitPy::number_float_handler (PyObject* /*self*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); return 0; } - -#if PY_MAJOR_VERSION < 3 -PyObject * UnitPy::number_oct_handler (PyObject* /*self*/) -{ - PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; -} - -PyObject * UnitPy::number_hex_handler (PyObject* /*self*/) -{ - PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; -} -#endif diff --git a/src/Base/UnitsApi.cpp b/src/Base/UnitsApi.cpp index b42d7f29bd..0cde90a3b0 100644 --- a/src/Base/UnitsApi.cpp +++ b/src/Base/UnitsApi.cpp @@ -213,13 +213,8 @@ QString UnitsApi::schemaTranslate(const Base::Quantity& quant, double &factor, Q double UnitsApi::toDbl(PyObject *ArgObj, const Base::Unit &u) { -#if PY_MAJOR_VERSION >= 3 if (PyUnicode_Check(ArgObj)) { QString str = QString::fromUtf8(PyUnicode_AsUTF8(ArgObj)); -#else - if (PyString_Check(ArgObj)) { - QString str = QString::fromLatin1(PyString_AsString(ArgObj)); -#endif // Parse the string Quantity q = Quantity::parse(str); if (q.getUnit() == u) @@ -229,13 +224,8 @@ double UnitsApi::toDbl(PyObject *ArgObj, const Base::Unit &u) else if (PyFloat_Check(ArgObj)) { return PyFloat_AsDouble(ArgObj); } -#if PY_MAJOR_VERSION < 3 - else if (PyInt_Check(ArgObj)) { - return static_cast(PyInt_AsLong(ArgObj)); -#else else if (PyLong_Check(ArgObj)) { return static_cast(PyLong_AsLong(ArgObj)); -#endif } else { throw Base::UnitsMismatchError("Wrong parameter type!"); @@ -245,13 +235,8 @@ double UnitsApi::toDbl(PyObject *ArgObj, const Base::Unit &u) Quantity UnitsApi::toQuantity(PyObject *ArgObj, const Base::Unit &u) { double d; -#if PY_MAJOR_VERSION >= 3 if (PyUnicode_Check(ArgObj)) { QString str = QString::fromUtf8(PyUnicode_AsUTF8(ArgObj)); -#else - if (PyString_Check(ArgObj)) { - QString str = QString::fromLatin1(PyString_AsString(ArgObj)); -#endif // Parse the string Quantity q = Quantity::parse(str); d = q.getValue(); @@ -259,13 +244,8 @@ Quantity UnitsApi::toQuantity(PyObject *ArgObj, const Base::Unit &u) else if (PyFloat_Check(ArgObj)) { d = PyFloat_AsDouble(ArgObj); } -#if PY_MAJOR_VERSION < 3 - else if (PyInt_Check(ArgObj)) { - d = static_cast(PyInt_AsLong(ArgObj)); -#else else if (PyLong_Check(ArgObj)) { d = static_cast(PyLong_AsLong(ArgObj)); -#endif } else { throw Base::UnitsMismatchError("Wrong parameter type!"); diff --git a/src/Base/VectorPyImp.cpp b/src/Base/VectorPyImp.cpp index e8333a7104..c516efb08d 100644 --- a/src/Base/VectorPyImp.cpp +++ b/src/Base/VectorPyImp.cpp @@ -155,14 +155,8 @@ PyObject* VectorPy::number_multiply_handler(PyObject *self, PyObject *other) double b = PyFloat_AsDouble(other); return new VectorPy(a * b); } -#if PY_MAJOR_VERSION < 3 - else if (PyInt_Check(other)) { - Base::Vector3d a = static_cast(self) ->value(); - long b = PyInt_AsLong(other); -#else else if (PyLong_Check(other)) { long b = PyLong_AsLong(other); -#endif return new VectorPy(a * (double)b); } else { @@ -176,13 +170,8 @@ PyObject* VectorPy::number_multiply_handler(PyObject *self, PyObject *other) double b = PyFloat_AsDouble(self); return new VectorPy(a * b); } -#if PY_MAJOR_VERSION >= 3 else if (PyLong_Check(self)) { long b = PyLong_AsLong(self); -#else - else if (PyInt_Check(self)) { - long b = PyInt_AsLong(self); -#endif return new VectorPy(a * (double)b); } else { @@ -252,11 +241,7 @@ PyObject * VectorPy::mapping_subscript(PyObject *self, PyObject *item) } else if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelength, cur, i; -#if PY_MAJOR_VERSION < 3 - PySliceObject* slice = reinterpret_cast(item); -#else PyObject* slice = item; -#endif if (PySlice_GetIndicesEx(slice, sequence_length(self), @@ -847,13 +832,6 @@ PyObject * VectorPy::number_or_handler (PyObject* self, PyObject* other) return 0; } -#if PY_MAJOR_VERSION < 3 -int VectorPy::number_coerce_handler (PyObject ** /*self*/, PyObject ** /*other*/) -{ - return 1; -} -#endif - PyObject * VectorPy::number_int_handler (PyObject* self) { PyErr_Format(PyExc_TypeError, "int() argument must be a string or a number, not '%s'", @@ -861,32 +839,9 @@ PyObject * VectorPy::number_int_handler (PyObject* self) return 0; } -#if PY_MAJOR_VERSION < 3 -PyObject * VectorPy::number_long_handler (PyObject* self) -{ - PyErr_Format(PyExc_TypeError, "long() argument must be a string or a number, not '%s'", - Py_TYPE(self)->tp_name); - return 0; -} -#endif - PyObject * VectorPy::number_float_handler (PyObject* self) { PyErr_Format(PyExc_TypeError, "float() argument must be a string or a number, not '%s'", Py_TYPE(self)->tp_name); return 0; } - -#if PY_MAJOR_VERSION < 3 -PyObject * VectorPy::number_oct_handler (PyObject* /*self*/) -{ - PyErr_SetString(PyExc_TypeError, "oct() argument can't be converted to oct"); - return 0; -} - -PyObject * VectorPy::number_hex_handler (PyObject* /*self*/) -{ - PyErr_SetString(PyExc_TypeError, "hex() argument can't be converted to hex"); - return 0; -} -#endif diff --git a/src/Base/swigpyrun.inl b/src/Base/swigpyrun.inl index 8956b30ad8..5cb3ad10c5 100644 --- a/src/Base/swigpyrun.inl +++ b/src/Base/swigpyrun.inl @@ -90,11 +90,7 @@ void cleanupSWIG_T(const char* TypeName) PyObject *key, *value; pos = 0; while (PyDict_Next(dict, &pos, &key, &value)) { -#if PY_MAJOR_VERSION >= 3 if (value != Py_None && PyUnicode_Check(key)) { -#else - if (value != Py_None && PyString_Check(key)) { -#endif void* ptr = 0; if (SWIG_ConvertPtr(value, &ptr, 0, 0) == 0) PyDict_SetItem(dict, key, Py_None); From c563198b35accddb151480f7d8155d0bcb63bba8 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 26 Apr 2021 10:29:48 +0200 Subject: [PATCH 154/178] Base: remove some more deprecated Py2 code and remove deprecated void from function signature and replace 0 or NULL with nullptr --- src/Base/Interpreter.cpp | 93 ++--- src/Base/MatrixPyImp.cpp | 126 +++---- src/Base/ParameterPy.cpp | 16 +- src/Base/PyObjectBase.cpp | 176 ++++----- src/Base/PyObjectBase.h | 20 +- src/Base/PyTools.c | 4 - src/Base/Stream.cpp | 3 +- src/Base/UnitPyImp.cpp | 58 +-- .../templateClassPyExport.py | 353 ++++++++---------- 9 files changed, 397 insertions(+), 452 deletions(-) diff --git a/src/Base/Interpreter.cpp b/src/Base/Interpreter.cpp index 82198de448..2e85c8adc6 100644 --- a/src/Base/Interpreter.cpp +++ b/src/Base/Interpreter.cpp @@ -46,10 +46,6 @@ unsigned int format2_len = 1024; using namespace Base; -#if PY_VERSION_HEX <= 0x02050000 -#error "Use Python2.5.x or higher" -#endif - PyException::PyException(const Py::Object &obj) { _sErrMsg = obj.as_string(); // WARNING: we are assuming that python type object will never be @@ -59,7 +55,7 @@ PyException::PyException(const Py::Object &obj) { _errorType = obj.ptr()->ob_type->tp_name; } -PyException::PyException(void) +PyException::PyException() { PP_Fetch_Error_Text(); /* fetch (and clear) exception */ @@ -104,7 +100,7 @@ PyException::~PyException() throw() { } -void PyException::ThrowException(void) +void PyException::ThrowException() { PyException myexcp; myexcp.ReportException(); @@ -113,11 +109,10 @@ void PyException::ThrowException(void) void PyException::raiseException() { PyGILStateLocker locker; - - if (PP_PyDict_Object!=NULL) { + if (PP_PyDict_Object!=nullptr) { // delete the Python dict upon destruction of edict Py::Dict edict(PP_PyDict_Object, true); - PP_PyDict_Object = 0; + PP_PyDict_Object = nullptr; std::string exceptionname; if (_exceptionType == Base::BaseExceptionFreeCADAbort) @@ -137,7 +132,7 @@ void PyException::raiseException() { throw *this; } -void PyException::ReportException (void) const +void PyException::ReportException () const { if (!_isReported) { _isReported = true; @@ -178,7 +173,7 @@ SystemExitException::SystemExitException() if (value) { code = PyObject_GetAttrString(value, "code"); - if (code != NULL && value != Py_None) { + if (code != nullptr && value != Py_None) { Py_DECREF(value); value = code; } @@ -203,7 +198,7 @@ SystemExitException::SystemExitException() class PythonStdOutput : public Py::PythonExtension { public: - static void init_type(void) + static void init_type() { behaviors().name("PythonStdOutput"); behaviors().doc("Python standard output"); @@ -232,7 +227,7 @@ public: InterpreterSingleton::InterpreterSingleton() { - this->_global = 0; + this->_global = nullptr; } InterpreterSingleton::~InterpreterSingleton() @@ -247,10 +242,10 @@ std::string InterpreterSingleton::runString(const char *sCmd) PyGILStateLocker locker; module = PP_Load_Module("__main__"); /* get module, init python */ - if (module == NULL) + if (module == nullptr) throw PyException(); /* not incref'd */ dict = PyModule_GetDict(module); /* get dict namespace */ - if (dict == NULL) + if (dict == nullptr) throw PyException(); /* not incref'd */ @@ -324,10 +319,10 @@ Py::Object InterpreterSingleton::runStringObject(const char *sCmd) PyGILStateLocker locker; module = PP_Load_Module("__main__"); /* get module, init python */ - if (module == NULL) + if (module == nullptr) throw PyException(); /* not incref'd */ dict = PyModule_GetDict(module); /* get dict namespace */ - if (dict == NULL) + if (dict == nullptr) throw PyException(); /* not incref'd */ @@ -342,7 +337,7 @@ Py::Object InterpreterSingleton::runStringObject(const char *sCmd) return Py::asObject(presult); } -void InterpreterSingleton::systemExit(void) +void InterpreterSingleton::systemExit() { /* This code is taken from the original Python code */ PyObject *exception, *value, *tb; @@ -350,7 +345,7 @@ void InterpreterSingleton::systemExit(void) PyErr_Fetch(&exception, &value, &tb); fflush(stdout); - if (value == NULL || value == Py_None) + if (value == nullptr || value == Py_None) goto done; if (PyExceptionInstance_Check(value)) { /* The error code should be in the `code' attribute. */ @@ -364,8 +359,9 @@ void InterpreterSingleton::systemExit(void) /* If we failed to dig out the 'code' attribute, just let the else clause below print the error. */ } - if (PyLong_Check(value)) + if (PyLong_Check(value)) { exitcode = (int)PyLong_AsLong(value); + } else { PyObject_Print(value, stderr, Py_PRINT_RAW); PySys_WriteStderr("\n"); @@ -389,10 +385,10 @@ void InterpreterSingleton::runInteractiveString(const char *sCmd) PyGILStateLocker locker; module = PP_Load_Module("__main__"); /* get module, init python */ - if (module == NULL) + if (module == nullptr) throw PyException(); /* not incref'd */ dict = PyModule_GetDict(module); /* get dict namespace */ - if (dict == NULL) + if (dict == nullptr) throw PyException(); /* not incref'd */ presult = PyRun_String(sCmd, Py_single_input, dict, dict); /* eval direct */ @@ -442,9 +438,9 @@ void InterpreterSingleton::runFile(const char*pxFileName, bool local) Py_INCREF(dict); // avoid to further distinguish between local and global dict } - if (PyDict_GetItemString(dict, "__file__") == NULL) { + if (PyDict_GetItemString(dict, "__file__") == nullptr) { PyObject *f = PyUnicode_FromString(pxFileName); - if (f == NULL) { + if (f == nullptr) { fclose(fp); Py_DECREF(dict); return; @@ -514,14 +510,10 @@ void InterpreterSingleton::addPythonPath(const char* Path) const char* InterpreterSingleton::init(int argc,char *argv[]) { if (!Py_IsInitialized()) { -#if PY_MAJOR_VERSION >= 3 -#if PY_MINOR_VERSION >= 5 - Py_SetProgramName(Py_DecodeLocale(argv[0],NULL)); +#if PY_VERSION_HEX >= 0x03050000 + Py_SetProgramName(Py_DecodeLocale(argv[0],nullptr)); #else - Py_SetProgramName(_Py_char2wchar(argv[0],NULL)); -#endif -#else - Py_SetProgramName(argv[0]); + Py_SetProgramName(_Py_char2wchar(argv[0],nullptr)); #endif // There is a serious bug in VS from 2010 until 2013 where the file descriptor for stdin, stdout or stderr // returns a valid value for GUI applications (i.e. subsystem = Windows) where it shouldn't. @@ -551,22 +543,15 @@ const char* InterpreterSingleton::init(int argc,char *argv[]) size_t size = argc; static std::vector _argv(size); for (int i = 0; i < argc; i++) { -#if PY_MINOR_VERSION >= 5 - _argv[i] = Py_DecodeLocale(argv[i],NULL); -#else - _argv[i] = _Py_char2wchar(argv[i],NULL); -#endif + _argv[i] = Py_DecodeLocale(argv[i],nullptr); } PySys_SetArgv(argc, _argv.data()); PythonStdOutput::init_type(); this->_global = PyEval_SaveThread(); } + PyGILStateLocker lock; -#if PY_MINOR_VERSION >= 5 - return Py_EncodeLocale(Py_GetPath(),NULL); -#else - return _Py_wchar2char(Py_GetPath(),NULL); -#endif + return Py_EncodeLocale(Py_GetPath(),nullptr); } void InterpreterSingleton::replaceStdOutput() @@ -577,7 +562,7 @@ void InterpreterSingleton::replaceStdOutput() PySys_SetObject("stderr", out); } -int InterpreterSingleton::cleanup(void (*func)(void)) +int InterpreterSingleton::cleanup(void (*func)()) { return Py_AtExit( func ); } @@ -610,9 +595,9 @@ void InterpreterSingleton::runStringArg(const char * psCom,...) // Singelton: -InterpreterSingleton * InterpreterSingleton::_pcSingelton = 0; +InterpreterSingleton * InterpreterSingleton::_pcSingelton = nullptr; -InterpreterSingleton & InterpreterSingleton::Instance(void) +InterpreterSingleton & InterpreterSingleton::Instance() { // not initialized! if (!_pcSingelton) @@ -620,12 +605,12 @@ InterpreterSingleton & InterpreterSingleton::Instance(void) return *_pcSingelton; } -void InterpreterSingleton::Destruct(void) +void InterpreterSingleton::Destruct() { // not initialized or double destruct! assert(_pcSingelton); delete _pcSingelton; - _pcSingelton = 0; + _pcSingelton = nullptr; } int InterpreterSingleton::runCommandLine(const char *prompt) @@ -643,8 +628,8 @@ void InterpreterSingleton::runMethodVoid(PyObject *pobject, const char *method) PyGILStateLocker locker; if (PP_Run_Method(pobject , // object method, // run method - 0, // no return type - 0, // so no return object + nullptr, // no return type + nullptr, // so no return object "()") // no arguments != 0) throw PyException(/*"Error running InterpreterSingleton::RunMethodVoid()"*/); @@ -677,7 +662,7 @@ void InterpreterSingleton::runMethod(PyObject *pobject, const char *method, PyGILStateLocker locker; pmeth = PyObject_GetAttrString(pobject, method); - if (pmeth == NULL) { /* get callable object */ + if (pmeth == nullptr) { /* get callable object */ va_end(argslist); throw AttributeError("Error running InterpreterSingleton::RunMethod() method not defined"); /* bound method? has self */ } @@ -685,7 +670,7 @@ void InterpreterSingleton::runMethod(PyObject *pobject, const char *method, pargs = Py_VaBuildValue(argfmt, argslist); /* args: c->python */ va_end(argslist); - if (pargs == NULL) { + if (pargs == nullptr) { Py_DECREF(pmeth); throw TypeError("InterpreterSingleton::RunMethod() wrong arguments"); } @@ -711,10 +696,10 @@ PyObject * InterpreterSingleton::getValue(const char * key, const char * result_ PyGILStateLocker locker; module = PP_Load_Module("__main__"); /* get module, init python */ - if (module == NULL) + if (module == nullptr) throw PyException(); /* not incref'd */ dict = PyModule_GetDict(module); /* get dict namespace */ - if (dict == NULL) + if (dict == nullptr) throw PyException(); /* not incref'd */ @@ -745,7 +730,7 @@ void InterpreterSingleton::dbgUnsetBreakPoint(unsigned int /*uiLineNumber*/) } -void InterpreterSingleton::dbgStep(void) +void InterpreterSingleton::dbgStep() { } @@ -832,7 +817,7 @@ namespace Swig_python { extern int createSWIGPointerObj_T(const char* TypeName, PyObject* InterpreterSingleton::createSWIGPointerObj(const char* Module, const char* TypeName, void* Pointer, int own) { int result = 0; - PyObject* proxy=0; + PyObject* proxy=nullptr; PyGILStateLocker locker; (void)Module; #if (defined(HAVE_SWIG) && (HAVE_SWIG == 1)) diff --git a/src/Base/MatrixPyImp.cpp b/src/Base/MatrixPyImp.cpp index 00c9ff9333..0b04fa714d 100644 --- a/src/Base/MatrixPyImp.cpp +++ b/src/Base/MatrixPyImp.cpp @@ -38,7 +38,7 @@ using namespace Base; // returns a string which represents the object e.g. when printed in python -std::string MatrixPy::representation(void) const +std::string MatrixPy::representation() const { const Base::Matrix4D& m = *(this->getMatrixPtr()); std::stringstream str; @@ -95,11 +95,11 @@ PyObject* MatrixPy::number_add_handler(PyObject *self, PyObject *other) { if (!PyObject_TypeCheck(self, &(MatrixPy::Type))) { PyErr_SetString(PyExc_NotImplementedError, ""); - return 0; + return nullptr; } if (!PyObject_TypeCheck(other, &(MatrixPy::Type))) { PyErr_SetString(PyExc_TypeError, "Second arg must be Matrix"); - return 0; + return nullptr; } Base::Matrix4D a = static_cast(self)->value(); Base::Matrix4D b = static_cast(other)->value(); @@ -110,11 +110,11 @@ PyObject* MatrixPy::number_subtract_handler(PyObject *self, PyObject *other) { if (!PyObject_TypeCheck(self, &(MatrixPy::Type))) { PyErr_SetString(PyExc_NotImplementedError, ""); - return 0; + return nullptr; } if (!PyObject_TypeCheck(other, &(MatrixPy::Type))) { PyErr_SetString(PyExc_TypeError, "Second arg must be Matrix"); - return 0; + return nullptr; } Base::Matrix4D a = static_cast(self)->value(); Base::Matrix4D b = static_cast(other)->value(); @@ -156,7 +156,7 @@ PyObject* MatrixPy::number_multiply_handler(PyObject *self, PyObject *other) } PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * MatrixPy::number_power_handler (PyObject* self, PyObject* other, PyObject* arg) @@ -168,7 +168,7 @@ PyObject * MatrixPy::number_power_handler (PyObject* self, PyObject* other, PyOb ) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } Base::Matrix4D a = static_cast(self)->value(); @@ -182,7 +182,7 @@ PyObject * MatrixPy::number_power_handler (PyObject* self, PyObject* other, PyOb a.inverseGauss(); else { PyErr_SetString(Base::BaseExceptionFreeCADError, "Cannot invert singular matrix"); - return 0; + return nullptr; } b = -b; } @@ -200,11 +200,11 @@ PyObject* MatrixPy::richCompare(PyObject *v, PyObject *w, int op) Matrix4D m1 = static_cast(v)->value(); Matrix4D m2 = static_cast(w)->value(); - PyObject *res=0; + PyObject *res=nullptr; if (op != Py_EQ && op != Py_NE) { PyErr_SetString(PyExc_TypeError, "no ordering relation is defined for Matrix"); - return 0; + return nullptr; } else if (op == Py_EQ) { res = (m1 == m2) ? Py_True : Py_False; @@ -250,7 +250,7 @@ PyObject* MatrixPy::move(PyObject * args) PyErr_Clear(); } else - return NULL; + return nullptr; PY_TRY { getMatrixPtr()->move(vec); @@ -286,7 +286,7 @@ PyObject* MatrixPy::scale(PyObject * args) PyErr_Clear(); } else - return NULL; + return nullptr; PY_TRY { getMatrixPtr()->scale(vec); @@ -300,14 +300,14 @@ PyObject* MatrixPy::hasScale(PyObject * args) { double tol=0; if (!PyArg_ParseTuple(args, "|d", &tol)) - return 0; + return nullptr; return Py::new_reference_to(Py::Int(getMatrixPtr()->hasScale(tol))); } PyObject* MatrixPy::unity(PyObject * args) { if (!PyArg_ParseTuple(args, "")) // convert args: Python->C - return NULL; // NULL triggers exception + return nullptr; // NULL triggers exception PY_TRY { getMatrixPtr()->setToUnity(); } @@ -332,7 +332,7 @@ PyObject* MatrixPy::transform(PyObject * args) PyErr_Clear(); } else - return NULL; // NULL triggers exception + return nullptr; // NULL triggers exception PY_TRY { getMatrixPtr()->transform(vec,mat); @@ -361,7 +361,7 @@ PyObject* MatrixPy::rotateX(PyObject * args) } PyErr_SetString(PyExc_TypeError, "For angle either float or Quantity expected"); - return 0; + return nullptr; } while (false); @@ -392,7 +392,7 @@ PyObject* MatrixPy::rotateY(PyObject * args) } PyErr_SetString(PyExc_TypeError, "For angle either float or Quantity expected"); - return 0; + return nullptr; } while (false); @@ -423,7 +423,7 @@ PyObject* MatrixPy::rotateZ(PyObject * args) } PyErr_SetString(PyExc_TypeError, "For angle either float or Quantity expected"); - return 0; + return nullptr; } while (false); @@ -450,14 +450,14 @@ PyObject* MatrixPy::multiply(PyObject * args) } PyErr_SetString(Base::BaseExceptionFreeCADError, "either vector or matrix expected"); - return 0; + return nullptr; } PyObject* MatrixPy::multVec(PyObject * args) { PyObject *obj; if (!PyArg_ParseTuple(args, "O!", &(VectorPy::Type), &obj)) - return NULL; + return nullptr; Base::Vector3d vec(static_cast(obj)->value()); getMatrixPtr()->multVec(vec, vec); return new VectorPy(new Vector3d(vec)); @@ -466,14 +466,14 @@ PyObject* MatrixPy::multVec(PyObject * args) PyObject* MatrixPy::invert(PyObject * args) { if (!PyArg_ParseTuple(args, "")) - return NULL; + return nullptr; PY_TRY { if (fabs(getMatrixPtr()->determinant()) > DBL_EPSILON) getMatrixPtr()->inverseGauss(); else { PyErr_SetString(Base::BaseExceptionFreeCADError, "Cannot invert singular matrix"); - return 0; + return nullptr; } } PY_CATCH; @@ -484,7 +484,7 @@ PyObject* MatrixPy::invert(PyObject * args) PyObject* MatrixPy::inverse(PyObject * args) { if (!PyArg_ParseTuple(args, "")) - return NULL; + return nullptr; PY_TRY { if (fabs(getMatrixPtr()->determinant()) > DBL_EPSILON) { @@ -494,7 +494,7 @@ PyObject* MatrixPy::inverse(PyObject * args) } else { PyErr_SetString(Base::BaseExceptionFreeCADError, "Cannot invert singular matrix"); - return 0; + return nullptr; } } PY_CATCH; @@ -505,7 +505,7 @@ PyObject* MatrixPy::inverse(PyObject * args) PyObject* MatrixPy::determinant(PyObject * args) { if (!PyArg_ParseTuple(args, "")) - return NULL; + return nullptr; return PyFloat_FromDouble(getMatrixPtr()->determinant()); } @@ -513,10 +513,10 @@ PyObject* MatrixPy::submatrix(PyObject * args) { int dim; if (!PyArg_ParseTuple(args, "i", &dim)) - return NULL; + return nullptr; if (dim < 1 || dim > 4) { PyErr_SetString(PyExc_IndexError, "Dimension out of range"); - return NULL; + return nullptr; } const Base::Matrix4D& mat = *getMatrixPtr(); @@ -547,7 +547,7 @@ PyObject* MatrixPy::isOrthogonal(PyObject * args) { double eps=1.0e-06; if (!PyArg_ParseTuple(args, "|d",&eps)) - return 0; + return nullptr; const Base::Matrix4D& mat = *getMatrixPtr(); Base::Matrix4D trp = mat; trp.transpose(); @@ -578,7 +578,7 @@ PyObject* MatrixPy::isOrthogonal(PyObject * args) PyObject* MatrixPy::transposed(PyObject * args) { if (!PyArg_ParseTuple(args, "")) - return NULL; + return nullptr; PY_TRY { Base::Matrix4D m = *getMatrixPtr(); @@ -593,7 +593,7 @@ PyObject* MatrixPy::transposed(PyObject * args) PyObject* MatrixPy::transpose(PyObject * args) { if (!PyArg_ParseTuple(args, "")) - return NULL; + return nullptr; PY_TRY { getMatrixPtr()->transpose(); @@ -605,7 +605,7 @@ PyObject* MatrixPy::transpose(PyObject * args) PyObject* MatrixPy::analyze(PyObject * args) { if (!PyArg_ParseTuple(args, "")) - return NULL; + return nullptr; PY_TRY { std::string type = getMatrixPtr()->analyse(); @@ -614,7 +614,7 @@ PyObject* MatrixPy::analyze(PyObject * args) PY_CATCH; } -Py::Float MatrixPy::getA11(void) const +Py::Float MatrixPy::getA11() const { double val = (*this->getMatrixPtr())[0][0]; return Py::Float(val); @@ -625,7 +625,7 @@ void MatrixPy::setA11(Py::Float arg) (*this->getMatrixPtr())[0][0] = (double)arg; } -Py::Float MatrixPy::getA12(void) const +Py::Float MatrixPy::getA12() const { double val = (*this->getMatrixPtr())[0][1]; return Py::Float(val); @@ -636,7 +636,7 @@ void MatrixPy::setA12(Py::Float arg) (*this->getMatrixPtr())[0][1] = (double)arg; } -Py::Float MatrixPy::getA13(void) const +Py::Float MatrixPy::getA13() const { double val = (*this->getMatrixPtr())[0][2]; return Py::Float(val); @@ -647,7 +647,7 @@ void MatrixPy::setA13(Py::Float arg) (*this->getMatrixPtr())[0][2] = (double)arg; } -Py::Float MatrixPy::getA14(void) const +Py::Float MatrixPy::getA14() const { double val = (*this->getMatrixPtr())[0][3]; return Py::Float(val); @@ -658,7 +658,7 @@ void MatrixPy::setA14(Py::Float arg) (*this->getMatrixPtr())[0][3] = (double)arg; } -Py::Float MatrixPy::getA21(void) const +Py::Float MatrixPy::getA21() const { double val = (*this->getMatrixPtr())[1][0]; return Py::Float(val); @@ -669,7 +669,7 @@ void MatrixPy::setA21(Py::Float arg) (*this->getMatrixPtr())[1][0] = (double)arg; } -Py::Float MatrixPy::getA22(void) const +Py::Float MatrixPy::getA22() const { double val = (*this->getMatrixPtr())[1][1]; return Py::Float(val); @@ -680,7 +680,7 @@ void MatrixPy::setA22(Py::Float arg) (*this->getMatrixPtr())[1][1] = (double)arg; } -Py::Float MatrixPy::getA23(void) const +Py::Float MatrixPy::getA23() const { double val = (*this->getMatrixPtr())[1][2]; return Py::Float(val); @@ -691,7 +691,7 @@ void MatrixPy::setA23(Py::Float arg) (*this->getMatrixPtr())[1][2] = (double)arg; } -Py::Float MatrixPy::getA24(void) const +Py::Float MatrixPy::getA24() const { double val = (*this->getMatrixPtr())[1][3]; return Py::Float(val); @@ -702,7 +702,7 @@ void MatrixPy::setA24(Py::Float arg) (*this->getMatrixPtr())[1][3] = (double)arg; } -Py::Float MatrixPy::getA31(void) const +Py::Float MatrixPy::getA31() const { double val = (*this->getMatrixPtr())[2][0]; return Py::Float(val); @@ -713,7 +713,7 @@ void MatrixPy::setA31(Py::Float arg) (*this->getMatrixPtr())[2][0] = (double)arg; } -Py::Float MatrixPy::getA32(void) const +Py::Float MatrixPy::getA32() const { double val = (*this->getMatrixPtr())[2][1]; return Py::Float(val); @@ -724,7 +724,7 @@ void MatrixPy::setA32(Py::Float arg) (*this->getMatrixPtr())[2][1] = (double)arg; } -Py::Float MatrixPy::getA33(void) const +Py::Float MatrixPy::getA33() const { double val = (*this->getMatrixPtr())[2][2]; return Py::Float(val); @@ -735,7 +735,7 @@ void MatrixPy::setA33(Py::Float arg) (*this->getMatrixPtr())[2][2] = (double)arg; } -Py::Float MatrixPy::getA34(void) const +Py::Float MatrixPy::getA34() const { double val = (*this->getMatrixPtr())[2][3]; return Py::Float(val); @@ -746,7 +746,7 @@ void MatrixPy::setA34(Py::Float arg) (*this->getMatrixPtr())[2][3] = (double)arg; } -Py::Float MatrixPy::getA41(void) const +Py::Float MatrixPy::getA41() const { double val = (*this->getMatrixPtr())[3][0]; return Py::Float(val); @@ -757,7 +757,7 @@ void MatrixPy::setA41(Py::Float arg) (*this->getMatrixPtr())[3][0] = (double)arg; } -Py::Float MatrixPy::getA42(void) const +Py::Float MatrixPy::getA42() const { double val = (*this->getMatrixPtr())[3][1]; return Py::Float(val); @@ -768,7 +768,7 @@ void MatrixPy::setA42(Py::Float arg) (*this->getMatrixPtr())[3][1] = (double)arg; } -Py::Float MatrixPy::getA43(void) const +Py::Float MatrixPy::getA43() const { double val = (*this->getMatrixPtr())[3][2]; return Py::Float(val); @@ -779,7 +779,7 @@ void MatrixPy::setA43(Py::Float arg) (*this->getMatrixPtr())[3][2] = (double)arg; } -Py::Float MatrixPy::getA44(void) const +Py::Float MatrixPy::getA44() const { double val = (*this->getMatrixPtr())[3][3]; return Py::Float(val); @@ -790,7 +790,7 @@ void MatrixPy::setA44(Py::Float arg) (*this->getMatrixPtr())[3][3] = (double)arg; } -Py::Sequence MatrixPy::getA(void) const +Py::Sequence MatrixPy::getA() const { double mat[16]; this->getMatrixPtr()->getMatrix(mat); @@ -816,7 +816,7 @@ void MatrixPy::setA(Py::Sequence arg) PyObject *MatrixPy::getCustomAttributes(const char* /*attr*/) const { - return 0; + return nullptr; } int MatrixPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/) @@ -827,37 +827,37 @@ int MatrixPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/) PyObject * MatrixPy::number_divide_handler (PyObject* /*self*/, PyObject* /*other*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * MatrixPy::number_remainder_handler (PyObject* /*self*/, PyObject* /*other*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * MatrixPy::number_divmod_handler (PyObject* /*self*/, PyObject* /*other*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * MatrixPy::number_negative_handler (PyObject* /*self*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * MatrixPy::number_positive_handler (PyObject* /*self*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * MatrixPy::number_absolute_handler (PyObject* /*self*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } int MatrixPy::number_nonzero_handler (PyObject* /*self*/) @@ -868,47 +868,47 @@ int MatrixPy::number_nonzero_handler (PyObject* /*self*/) PyObject * MatrixPy::number_invert_handler (PyObject* /*self*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * MatrixPy::number_lshift_handler (PyObject* /*self*/, PyObject* /*other*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * MatrixPy::number_rshift_handler (PyObject* /*self*/, PyObject* /*other*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * MatrixPy::number_and_handler (PyObject* /*self*/, PyObject* /*other*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * MatrixPy::number_xor_handler (PyObject* /*self*/, PyObject* /*other*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * MatrixPy::number_or_handler (PyObject* /*self*/, PyObject* /*other*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * MatrixPy::number_int_handler (PyObject * /*self*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * MatrixPy::number_float_handler (PyObject * /*self*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } diff --git a/src/Base/ParameterPy.cpp b/src/Base/ParameterPy.cpp index fb5bfe5c1b..2d131d2a5e 100644 --- a/src/Base/ParameterPy.cpp +++ b/src/Base/ParameterPy.cpp @@ -25,7 +25,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include +# include # include # include # include @@ -33,7 +33,7 @@ # include # include # endif -# include +# include # include # include #endif @@ -99,7 +99,7 @@ typedef std::list ParameterGrpObserverList; class ParameterGrpPy : public Py::PythonExtension { public: - static void init_type(void); // announce properties and methods + static void init_type(); // announce properties and methods ParameterGrpPy(const Base::Reference &rcParamGrp); ~ParameterGrpPy(); @@ -320,7 +320,7 @@ Py::Object ParameterGrpPy::getBool(const Py::Tuple& args) Py::Object ParameterGrpPy::getBools(const Py::Tuple& args) { - char *filter=0; + char *filter=nullptr; if (!PyArg_ParseTuple(args.ptr(), "|s", &filter)) throw Py::Exception(); @@ -355,7 +355,7 @@ Py::Object ParameterGrpPy::getInt(const Py::Tuple& args) Py::Object ParameterGrpPy::getInts(const Py::Tuple& args) { - char *filter=0; + char *filter=nullptr; if (!PyArg_ParseTuple(args.ptr(), "|s", &filter)) throw Py::Exception(); @@ -390,7 +390,7 @@ Py::Object ParameterGrpPy::getUnsigned(const Py::Tuple& args) Py::Object ParameterGrpPy::getUnsigneds(const Py::Tuple& args) { - char *filter=0; + char *filter=nullptr; if (!PyArg_ParseTuple(args.ptr(), "|s", &filter)) throw Py::Exception(); @@ -426,7 +426,7 @@ Py::Object ParameterGrpPy::getFloat(const Py::Tuple& args) Py::Object ParameterGrpPy::getFloats(const Py::Tuple& args) { - char *filter=0; + char *filter=nullptr; if (!PyArg_ParseTuple(args.ptr(), "|s", &filter)) throw Py::Exception(); @@ -462,7 +462,7 @@ Py::Object ParameterGrpPy::getString(const Py::Tuple& args) Py::Object ParameterGrpPy::getStrings(const Py::Tuple& args) { - char *filter=0; + char *filter=nullptr; if (!PyArg_ParseTuple(args.ptr(), "|s", &filter)) throw Py::Exception(); diff --git a/src/Base/PyObjectBase.cpp b/src/Base/PyObjectBase.cpp index bc8d6d2d86..7bc5e31f8c 100644 --- a/src/Base/PyObjectBase.cpp +++ b/src/Base/PyObjectBase.cpp @@ -25,7 +25,7 @@ #ifndef _PreComp_ # include -# include +# include #endif #include "PyObjectBase.h" @@ -36,8 +36,8 @@ using namespace Base; -PyObject* Base::BaseExceptionFreeCADError = 0; -PyObject* Base::BaseExceptionFreeCADAbort = 0; +PyObject* Base::BaseExceptionFreeCADError = nullptr; +PyObject* Base::BaseExceptionFreeCADAbort = nullptr; #ifdef ATTR_TRACKING typedef struct { @@ -107,49 +107,49 @@ static PyTypeObject PyBaseProxyType = { sizeof(PyBaseProxy), /*tp_basicsize*/ 0, /*tp_itemsize*/ PyBaseProxy_dealloc, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call */ - 0, /*tp_str */ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - 0, /* tp_as_buffer */ + nullptr, /*tp_print*/ + nullptr, /*tp_getattr*/ + nullptr, /*tp_setattr*/ + nullptr, /*tp_compare*/ + nullptr, /*tp_repr*/ + nullptr, /*tp_as_number*/ + nullptr, /*tp_as_sequence*/ + nullptr, /*tp_as_mapping*/ + nullptr, /*tp_hash*/ + nullptr, /*tp_call */ + nullptr, /*tp_str */ + nullptr, /*tp_getattro*/ + nullptr, /*tp_setattro*/ + nullptr, /*tp_as_buffer*/ Py_TPFLAGS_BASETYPE | Py_TPFLAGS_DEFAULT, /*tp_flags */ "Proxy class", /*tp_doc */ - 0, /*tp_traverse */ - 0, /*tp_clear */ - 0, /*tp_richcompare */ + nullptr, /*tp_traverse */ + nullptr, /*tp_clear */ + nullptr, /*tp_richcompare */ offsetof(PyBaseProxy, weakreflist), /*tp_weaklistoffset */ - 0, /*tp_iter */ - 0, /*tp_iternext */ - 0, /*tp_methods */ - 0, /*tp_members */ - 0, /*tp_getset */ - 0, /*tp_base */ - 0, /*tp_dict */ - 0, /*tp_descr_get */ - 0, /*tp_descr_set */ + nullptr, /*tp_iter */ + nullptr, /*tp_iternext */ + nullptr, /*tp_methods */ + nullptr, /*tp_members */ + nullptr, /*tp_getset */ + nullptr, /*tp_base */ + nullptr, /*tp_dict */ + nullptr, /*tp_descr_get */ + nullptr, /*tp_descr_set */ 0, /*tp_dictoffset */ - 0, /*tp_init */ - 0, /*tp_alloc */ - 0, /*tp_new */ - 0, /*tp_free Low-level free-memory routine */ - 0, /*tp_is_gc For PyObject_IS_GC */ - 0, /*tp_bases */ - 0, /*tp_mro method resolution order */ - 0, /*tp_cache */ - 0, /*tp_subclasses */ - 0, /*tp_weaklist */ - 0, /*tp_del */ + nullptr, /*tp_init */ + nullptr, /*tp_alloc */ + nullptr, /*tp_new */ + nullptr, /*tp_free Low-level free-memory routine */ + nullptr, /*tp_is_gc For PyObject_IS_GC */ + nullptr, /*tp_bases */ + nullptr, /*tp_mro method resolution order */ + nullptr, /*tp_cache */ + nullptr, /*tp_subclasses */ + nullptr, /*tp_weaklist */ + nullptr, /*tp_del */ 0, /*tp_version_tag */ - 0 /*tp_finalize */ + nullptr /*tp_finalize */ #if PY_VERSION_HEX >= 0x03090000 ,0 /*tp_vectorcall */ #elif PY_VERSION_HEX >= 0x03080000 @@ -166,51 +166,51 @@ PyTypeObject PyObjectBase::Type = { 0, /*tp_itemsize*/ /* --- methods ---------------------------------------------- */ PyDestructor, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ + nullptr, /*tp_print*/ + nullptr, /*tp_getattr*/ + nullptr, /*tp_setattr*/ + nullptr, /*tp_compare*/ __repr, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call */ - 0, /*tp_str */ + nullptr, /*tp_as_number*/ + nullptr, /*tp_as_sequence*/ + nullptr, /*tp_as_mapping*/ + nullptr, /*tp_hash*/ + nullptr, /*tp_call */ + nullptr, /*tp_str */ __getattro, /*tp_getattro*/ __setattro, /*tp_setattro*/ /* --- Functions to access object as input/output buffer ---------*/ - 0, /* tp_as_buffer */ + nullptr, /* tp_as_buffer */ /* --- Flags to define presence of optional/expanded features */ Py_TPFLAGS_BASETYPE|Py_TPFLAGS_DEFAULT, /*tp_flags */ "The most base class for Python binding", /*tp_doc */ - 0, /*tp_traverse */ - 0, /*tp_clear */ - 0, /*tp_richcompare */ + nullptr, /*tp_traverse */ + nullptr, /*tp_clear */ + nullptr, /*tp_richcompare */ 0, /*tp_weaklistoffset */ - 0, /*tp_iter */ - 0, /*tp_iternext */ - 0, /*tp_methods */ - 0, /*tp_members */ - 0, /*tp_getset */ - 0, /*tp_base */ - 0, /*tp_dict */ - 0, /*tp_descr_get */ - 0, /*tp_descr_set */ + nullptr, /*tp_iter */ + nullptr, /*tp_iternext */ + nullptr, /*tp_methods */ + nullptr, /*tp_members */ + nullptr, /*tp_getset */ + nullptr, /*tp_base */ + nullptr, /*tp_dict */ + nullptr, /*tp_descr_get */ + nullptr, /*tp_descr_set */ 0, /*tp_dictoffset */ - 0, /*tp_init */ - 0, /*tp_alloc */ - 0, /*tp_new */ - 0, /*tp_free Low-level free-memory routine */ - 0, /*tp_is_gc For PyObject_IS_GC */ - 0, /*tp_bases */ - 0, /*tp_mro method resolution order */ - 0, /*tp_cache */ - 0, /*tp_subclasses */ - 0, /*tp_weaklist */ - 0, /*tp_del */ - 0, /*tp_version_tag */ - 0 /*tp_finalize */ + nullptr, /*tp_init */ + nullptr, /*tp_alloc */ + nullptr, /*tp_new */ + nullptr, /*tp_free Low-level free-memory routine */ + nullptr, /*tp_is_gc For PyObject_IS_GC */ + nullptr, /*tp_bases */ + nullptr, /*tp_mro method resolution order */ + nullptr, /*tp_cache */ + nullptr, /*tp_subclasses */ + nullptr, /*tp_weaklist */ + nullptr, /*tp_del */ + 0, /*tp_version_tag */ + nullptr /*tp_finalize */ #if PY_VERSION_HEX >= 0x03090000 ,0 /*tp_vectorcall */ #elif PY_VERSION_HEX >= 0x03080000 @@ -261,7 +261,7 @@ PyObjectBase* getFromWeakRef(PyObject* ref) * PyObjectBase Methods -- Every class, even the abstract one should have a Methods ------------------------------*/ PyMethodDef PyObjectBase::Methods[] = { - {NULL, NULL, 0, NULL} /* Sentinel */ + {nullptr, nullptr, 0, nullptr} /* Sentinel */ }; PyObject* PyObjectBase::__getattro(PyObject * obj, PyObject *attro) @@ -282,7 +282,7 @@ PyObject* PyObjectBase::__getattro(PyObject * obj, PyObject *attro) PyObjectBase* pyObj = static_cast(obj); if (!pyObj->isValid()){ PyErr_Format(PyExc_ReferenceError, "Cannot access attribute '%s' of deleted object", attr); - return NULL; + return nullptr; } #ifdef ATTR_TRACKING @@ -320,7 +320,7 @@ PyObject* PyObjectBase::__getattro(PyObject * obj, PyObject *attro) PyCFunctionObject* cfunc = reinterpret_cast(value); if (!cfunc->m_self) { Py_DECREF(cfunc); - value = 0; + value = nullptr; PyErr_Format(PyExc_AttributeError, "", attr); } } @@ -335,7 +335,7 @@ int PyObjectBase::__setattro(PyObject *obj, PyObject *attro, PyObject *value) //FIXME: In general we don't allow to delete attributes (i.e. value=0). However, if we want to allow //we must check then in _setattr() of all subclasses whether value is 0. - if ( value==0 ) { + if ( value==nullptr ) { PyErr_Format(PyExc_AttributeError, "Cannot delete attribute: '%s'", attr); return -1; } @@ -379,7 +379,7 @@ PyObject *PyObjectBase::_getattr(const char *attr) } else if (streq(attr, "__members__")) { // Use __dict__ instead as __members__ is deprecated - return NULL; + return nullptr; } else if (streq(attr,"__dict__")) { // Return the default dict @@ -389,13 +389,13 @@ PyObject *PyObjectBase::_getattr(const char *attr) } else if (streq(attr,"softspace")) { // Internal Python stuff - return NULL; + return nullptr; } else { // As fallback solution use Python's default method to get generic attributes PyObject *w, *res; w = PyUnicode_InternFromString(attr); - if (w != NULL) { + if (w != nullptr) { res = PyObject_GenericGetAttr(this, w); Py_XDECREF(w); return res; @@ -403,7 +403,7 @@ PyObject *PyObjectBase::_getattr(const char *attr) // Throw an exception for unknown attributes PyTypeObject *tp = Py_TYPE(this); PyErr_Format(PyExc_AttributeError, "%.50s instance has no attribute '%.400s'", tp->tp_name, attr); - return NULL; + return nullptr; } } } @@ -415,7 +415,7 @@ int PyObjectBase::_setattr(const char *attr, PyObject *value) PyObject *w; // As fallback solution use Python's default method to get generic attributes w = PyUnicode_InternFromString(attr); // new reference - if (w != NULL) { + if (w != nullptr) { // call methods from tp_getset if defined int res = PyObject_GenericSetAttr(this, w, value); Py_DECREF(w); @@ -431,7 +431,7 @@ int PyObjectBase::_setattr(const char *attr, PyObject *value) /*------------------------------ * PyObjectBase repr representations ------------------------------*/ -PyObject *PyObjectBase::_repr(void) +PyObject *PyObjectBase::_repr() { std::stringstream a; a << ""; @@ -478,6 +478,7 @@ void PyObjectBase::setAttributeOf(const char* attr, PyObject* par) Py_DECREF(key1); Py_DECREF(key2); } + void PyObjectBase::startNotify() { if (!shouldNotify()) @@ -512,6 +513,7 @@ void PyObjectBase::startNotify() Py_DECREF(key2); } } + PyObject* PyObjectBase::getTrackedAttribute(const char* attr) { PyObject* obj = nullptr; diff --git a/src/Base/PyObjectBase.h b/src/Base/PyObjectBase.h index eb6ed44f32..611e1a395e 100644 --- a/src/Base/PyObjectBase.h +++ b/src/Base/PyObjectBase.h @@ -50,10 +50,8 @@ #include #include "Exception.h" -#if PY_MAJOR_VERSION > 2 -# ifndef PYCXX_PYTHON_2TO3 -# define PYCXX_PYTHON_2TO3 -# endif +#ifndef PYCXX_PYTHON_2TO3 +#define PYCXX_PYTHON_2TO3 #endif #include @@ -91,8 +89,8 @@ /** Macro for initialization function of Python modules. */ -# define PyMOD_INIT_FUNC(name) PyMODINIT_FUNC PyInit_##name(void) -# define PyMOD_Return(name) return name +#define PyMOD_INIT_FUNC(name) PyMODINIT_FUNC PyInit_##name(void) +#define PyMOD_Return(name) return name /** * Union to convert from PyTypeObject to PyObject pointer. @@ -218,9 +216,9 @@ public: static void PyDestructor(PyObject *P) // python wrapper { delete ((PyObjectBase *) P); } /// incref method wrapper (see python extending manual) - PyObjectBase* IncRef(void) {Py_INCREF(this);return this;} + PyObjectBase* IncRef() {Py_INCREF(this);return this;} /// decref method wrapper (see python extending manual) - PyObjectBase* DecRef(void) {Py_DECREF(this);return this;} + PyObjectBase* DecRef() {Py_DECREF(this);return this;} /** GetAttribute implementation * This method implements the retrieval of object attributes. @@ -259,12 +257,12 @@ public: * } * \endcode */ - virtual PyObject *_repr(void); + virtual PyObject *_repr(); /// python wrapper for the _repr() function static PyObject *__repr(PyObject *PyObj) { if (!((PyObjectBase*) PyObj)->isValid()){ PyErr_Format(PyExc_ReferenceError, "Cannot print representation of deleted object"); - return NULL; + return nullptr; } return ((PyObjectBase*) PyObj)->_repr(); } @@ -287,7 +285,7 @@ public: // first bit is not set, i.e. invalid StatusBits.reset(Valid); clearAttributes(); - _pcTwinPointer = 0; + _pcTwinPointer = nullptr; } bool isValid() { diff --git a/src/Base/PyTools.c b/src/Base/PyTools.c index fdb741bd4b..71569e26a2 100644 --- a/src/Base/PyTools.c +++ b/src/Base/PyTools.c @@ -18,10 +18,6 @@ is provided on an as is basis, without warranties of any kind. #include #include -#if PY_VERSION_HEX <= 0x02050000 -#error "Use Python2.5.x or higher" -#endif - /***************************************************************************** * RUN EMBEDDED OBJECT METHODS, ACCESS OBJECT ATTRIBUTES diff --git a/src/Base/Stream.cpp b/src/Base/Stream.cpp index 9ec23ad939..1d55cfff53 100644 --- a/src/Base/Stream.cpp +++ b/src/Base/Stream.cpp @@ -33,7 +33,7 @@ # include # include #ifdef __GNUC__ -# include +# include #endif #endif @@ -582,6 +582,7 @@ PyStreambuf::int_type PyStreambuf::underflow() // wrong type return traits_type::eof(); } + n = c.size(); if (n == 0) { return traits_type::eof(); diff --git a/src/Base/UnitPyImp.cpp b/src/Base/UnitPyImp.cpp index 5b462c89bc..de20be1ce1 100644 --- a/src/Base/UnitPyImp.cpp +++ b/src/Base/UnitPyImp.cpp @@ -32,7 +32,7 @@ using namespace Base; // returns a string which represents the object e.g. when printed in python -std::string UnitPy::representation(void) const +std::string UnitPy::representation() const { const UnitSignature & Sig = getUnitPtr()->getSignature(); std::stringstream ret; @@ -125,18 +125,18 @@ PyObject* UnitPy::number_add_handler(PyObject *self, PyObject *other) { if (!PyObject_TypeCheck(self, &(UnitPy::Type))) { PyErr_SetString(PyExc_TypeError, "First arg must be Unit"); - return 0; + return nullptr; } if (!PyObject_TypeCheck(other, &(UnitPy::Type))) { PyErr_SetString(PyExc_TypeError, "Second arg must be Unit"); - return 0; + return nullptr; } Base::Unit *a = static_cast(self)->getUnitPtr(); Base::Unit *b = static_cast(other)->getUnitPtr(); if (*a != *b) { PyErr_SetString(PyExc_TypeError, "Units not matching!"); - return 0; + return nullptr; } return new UnitPy(new Unit(*a)); @@ -146,18 +146,18 @@ PyObject* UnitPy::number_subtract_handler(PyObject *self, PyObject *other) { if (!PyObject_TypeCheck(self, &(UnitPy::Type))) { PyErr_SetString(PyExc_TypeError, "First arg must be Unit"); - return 0; + return nullptr; } if (!PyObject_TypeCheck(other, &(UnitPy::Type))) { PyErr_SetString(PyExc_TypeError, "Second arg must be Unit"); - return 0; + return nullptr; } Base::Unit *a = static_cast(self)->getUnitPtr(); Base::Unit *b = static_cast(other)->getUnitPtr(); if (*a != *b) { PyErr_SetString(PyExc_TypeError, "Units not matching!"); - return 0; + return nullptr; } return new UnitPy(new Unit(*a)); @@ -167,7 +167,7 @@ PyObject* UnitPy::number_multiply_handler(PyObject *self, PyObject *other) { if (!PyObject_TypeCheck(self, &(UnitPy::Type))) { PyErr_SetString(PyExc_TypeError, "First arg must be Unit"); - return 0; + return nullptr; } if (PyObject_TypeCheck(other, &(UnitPy::Type))) { @@ -178,7 +178,7 @@ PyObject* UnitPy::number_multiply_handler(PyObject *self, PyObject *other) } else { PyErr_SetString(PyExc_TypeError, "A Unit can only be multiplied by a Unit"); - return 0; + return nullptr; } } @@ -189,11 +189,11 @@ PyObject* UnitPy::richCompare(PyObject *v, PyObject *w, int op) const Unit * u1 = static_cast(v)->getUnitPtr(); const Unit * u2 = static_cast(w)->getUnitPtr(); - PyObject *res=0; + PyObject *res=nullptr; if (op != Py_EQ && op != Py_NE) { PyErr_SetString(PyExc_TypeError, "no ordering relation is defined for Units"); - return 0; + return nullptr; } else if (op == Py_EQ) { res = (*u1 == *u2) ? Py_True : Py_False; @@ -213,12 +213,12 @@ PyObject* UnitPy::richCompare(PyObject *v, PyObject *w, int op) } } -Py::String UnitPy::getType(void) const +Py::String UnitPy::getType() const { return Py::String(getUnitPtr()->getTypeString().toUtf8(),"utf-8"); } -Py::Tuple UnitPy::getSignature(void) const +Py::Tuple UnitPy::getSignature() const { const UnitSignature & Sig = getUnitPtr()->getSignature(); Py::Tuple tuple(8); @@ -237,7 +237,7 @@ Py::Tuple UnitPy::getSignature(void) const PyObject *UnitPy::getCustomAttributes(const char* /*attr*/) const { - return 0; + return nullptr; } int UnitPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/) @@ -248,43 +248,43 @@ int UnitPy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/) PyObject * UnitPy::number_divide_handler (PyObject* /*self*/, PyObject* /*other*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * UnitPy::number_remainder_handler (PyObject* /*self*/, PyObject* /*other*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * UnitPy::number_divmod_handler (PyObject* /*self*/, PyObject* /*other*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * UnitPy::number_power_handler (PyObject* /*self*/, PyObject* /*other*/, PyObject* /*modulo*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * UnitPy::number_negative_handler (PyObject* /*self*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * UnitPy::number_positive_handler (PyObject* /*self*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * UnitPy::number_absolute_handler (PyObject* /*self*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } int UnitPy::number_nonzero_handler (PyObject* /*self*/) @@ -295,47 +295,47 @@ int UnitPy::number_nonzero_handler (PyObject* /*self*/) PyObject * UnitPy::number_invert_handler (PyObject* /*self*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * UnitPy::number_lshift_handler (PyObject* /*self*/, PyObject* /*other*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * UnitPy::number_rshift_handler (PyObject* /*self*/, PyObject* /*other*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * UnitPy::number_and_handler (PyObject* /*self*/, PyObject* /*other*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * UnitPy::number_xor_handler (PyObject* /*self*/, PyObject* /*other*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * UnitPy::number_or_handler (PyObject* /*self*/, PyObject* /*other*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * UnitPy::number_int_handler (PyObject* /*self*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * UnitPy::number_float_handler (PyObject* /*self*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } diff --git a/src/Tools/generateTemplates/templateClassPyExport.py b/src/Tools/generateTemplates/templateClassPyExport.py index 4621d855b3..52c06e41c9 100644 --- a/src/Tools/generateTemplates/templateClassPyExport.py +++ b/src/Tools/generateTemplates/templateClassPyExport.py @@ -78,7 +78,7 @@ public: static PyObject * richCompare(PyObject *v, PyObject *w, int op); - static PyGetSetDef GetterSetter[]; - virtual PyTypeObject *GetType(void) {return &Type;} + virtual PyTypeObject *GetType() {return &Type;} public: @self.export.Name@(@self.export.TwinPointer@ *pcObject, PyTypeObject *T = &Type); @@ -92,8 +92,8 @@ public: typedef @self.export.TwinPointer@* PointerType ; - virtual PyObject *_repr(void); // the representation - std::string representation(void) const; + virtual PyObject *_repr(); // the representation + std::string representation() const; /** @name callbacks and implementers for the python object methods */ //@{ @@ -165,24 +165,10 @@ public: static PyObject * number_xor_handler (PyObject *self, PyObject *other); /// callback for the number_or_handler static PyObject * number_or_handler (PyObject *self, PyObject *other); -#if PY_MAJOR_VERSION < 3 - /// callback for the number_coerce_handler - static int number_coerce_handler (PyObject **self, PyObject **other); -#endif /// callback for the number_int_handler static PyObject * number_int_handler (PyObject *self); -#if PY_MAJOR_VERSION < 3 - /// callback for the number_long_handler - static PyObject * number_long_handler (PyObject *self); -#endif /// callback for the number_float_handler static PyObject * number_float_handler (PyObject *self); -#if PY_MAJOR_VERSION < 3 - /// callback for the number_oct_handler - static PyObject * number_oct_handler (PyObject *self); - /// callback for the number_hex_handler - static PyObject * number_hex_handler (PyObject *self); -#endif //@} - + if (self.export.Sequence): @@ -227,7 +213,7 @@ public: ///getter callback for the @i.Name@ attribute static PyObject * staticCallback_get@i.Name@ (PyObject *self, void *closure); /// getter for the @i.Name@ attribute - Py::@i.Parameter.Type@ get@i.Name@(void) const; + Py::@i.Parameter.Type@ get@i.Name@() const; /// setter callback for the @i.Name@ attribute static int staticCallback_set@i.Name@ (PyObject *self, PyObject *value, void *closure); + if (i.ReadOnly): @@ -250,7 +236,7 @@ public: - /// getter for the object handled by this class - @self.export.TwinPointer@ *get@self.export.Twin@Ptr(void) const; + @self.export.TwinPointer@ *get@self.export.Twin@Ptr() const; + if(self.export.ClassDeclarations != ""): /** @name additional declarations and methods for the wrapper class */ @@ -299,30 +285,30 @@ PyTypeObject @self.export.Name@::Type = { 0, /*tp_itemsize*/ /* methods */ PyDestructor, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ + nullptr, /*tp_print*/ + nullptr, /*tp_getattr*/ + nullptr, /*tp_setattr*/ + nullptr, /*tp_compare*/ __repr, /*tp_repr*/ + if (self.export.NumberProtocol): @self.export.Namespace@::@self.export.Name@::Number, /*tp_as_number*/ = else: - 0, /*tp_as_number*/ + nullptr, /*tp_as_number*/ - + if (self.export.Sequence): @self.export.Namespace@::@self.export.Name@::Sequence, /*tp_as_sequence*/ @self.export.Namespace@::@self.export.Name@::Mapping, /*tp_as_mapping*/ = else: - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ + nullptr, /*tp_as_sequence*/ + nullptr, /*tp_as_mapping*/ - - 0, /*tp_hash*/ - 0, /*tp_call */ - 0, /*tp_str */ + nullptr, /*tp_hash*/ + nullptr, /*tp_call */ + nullptr, /*tp_str */ __getattro, /*tp_getattro*/ __setattro, /*tp_setattro*/ /* --- Functions to access object as input/output buffer ---------*/ - 0, /* tp_as_buffer */ + nullptr, /* tp_as_buffer */ /* --- Flags to define presence of optional/expanded features */ #if PY_MAJOR_VERSION >= 3 Py_TPFLAGS_BASETYPE|Py_TPFLAGS_DEFAULT, /*tp_flags */ @@ -338,45 +324,43 @@ PyTypeObject @self.export.Name@::Type = { - #endif "@self.export.Documentation.UserDocu.replace('\\n','\\\\n\\"\\n \\"')@", /*tp_doc */ - 0, /*tp_traverse */ - 0, /*tp_clear */ + nullptr, /*tp_traverse */ + nullptr, /*tp_clear */ + if (self.export.RichCompare): @self.export.Namespace@::@self.export.Name@::richCompare, /*tp_richcompare*/ = else: - 0, /*tp_richcompare */ + nullptr, /*tp_richcompare */ - 0, /*tp_weaklistoffset */ - 0, /*tp_iter */ - 0, /*tp_iternext */ + nullptr, /*tp_iter */ + nullptr, /*tp_iternext */ @self.export.Namespace@::@self.export.Name@::Methods, /*tp_methods */ - 0, /*tp_members */ + nullptr, /*tp_members */ @self.export.Namespace@::@self.export.Name@::GetterSetter, /*tp_getset */ &@self.export.FatherNamespace@::@self.export.Father@::Type, /*tp_base */ - 0, /*tp_dict */ - 0, /*tp_descr_get */ - 0, /*tp_descr_set */ + nullptr, /*tp_dict */ + nullptr, /*tp_descr_get */ + nullptr, /*tp_descr_set */ 0, /*tp_dictoffset */ __PyInit, /*tp_init */ - 0, /*tp_alloc */ + nullptr, /*tp_alloc */ @self.export.Namespace@::@self.export.Name@::PyMake,/*tp_new */ - 0, /*tp_free Low-level free-memory routine */ - 0, /*tp_is_gc For PyObject_IS_GC */ - 0, /*tp_bases */ - 0, /*tp_mro method resolution order */ - 0, /*tp_cache */ - 0, /*tp_subclasses */ - 0, /*tp_weaklist */ - 0, /*tp_del */ - 0 /*tp_version_tag */ -#if PY_MAJOR_VERSION >= 3 - ,0 /*tp_finalize */ -#endif + nullptr, /*tp_free Low-level free-memory routine */ + nullptr, /*tp_is_gc For PyObject_IS_GC */ + nullptr, /*tp_bases */ + nullptr, /*tp_mro method resolution order */ + nullptr, /*tp_cache */ + nullptr, /*tp_subclasses */ + nullptr, /*tp_weaklist */ + nullptr, /*tp_del */ + 0, /*tp_version_tag */ + nullptr /*tp_finalize */ #if PY_VERSION_HEX >= 0x03090000 - ,0 /*tp_vectorcall */ + ,nullptr /*tp_vectorcall */ #elif PY_VERSION_HEX >= 0x03080000 - ,0 /*tp_vectorcall */ + ,nullptr /*tp_vectorcall */ /* bpo-37250: kept for backwards compatibility in CPython 3.8 only */ - ,0 /*tp_print */ + ,nullptr /*tp_print */ #endif }; @@ -408,7 +392,7 @@ PyMethodDef @self.export.Name@::Methods[] = { "@i.Documentation.UserDocu.replace('\\n','\\\\n')@" }, - - {NULL, NULL, 0, NULL} /* Sentinel */ + {nullptr, nullptr, 0, nullptr} /* Sentinel */ }; + if (self.export.NumberProtocol): @@ -416,9 +400,6 @@ PyNumberMethods @self.export.Name@::Number[] = { { number_add_handler, number_subtract_handler, number_multiply_handler, -#if PY_MAJOR_VERSION < 3 - number_divide_handler, -#endif number_remainder_handler, number_divmod_handler, number_power_handler, @@ -432,45 +413,27 @@ PyNumberMethods @self.export.Name@::Number[] = { { number_and_handler, number_xor_handler, number_or_handler, -#if PY_MAJOR_VERSION < 3 - number_coerce_handler, -#endif number_int_handler, -#if PY_MAJOR_VERSION < 3 - number_long_handler, -#else - 0, -#endif + nullptr, number_float_handler, -#if PY_MAJOR_VERSION < 3 - number_oct_handler, - number_hex_handler, -#endif - NULL, /*nb_inplace_add*/ - NULL, /*nb_inplace_subtract*/ - NULL, /*nb_inplace_multiply*/ -#if PY_MAJOR_VERSION < 3 - NULL, /*nb_inplace_divide*/ -#endif - NULL, /*nb_inplace_remainder*/ - NULL, /*nb_inplace_power*/ - NULL, /*nb_inplace_lshift*/ - NULL, /*nb_inplace_rshift*/ - NULL, /*nb_inplace_and*/ - NULL, /*nb_inplace_xor*/ - NULL, /*nb_inplace_or*/ - NULL, /*nb_floor_divide*/ -#if PY_MAJOR_VERSION < 3 - NULL, /*nb_true_divide*/ -#else + nullptr, /*nb_inplace_add*/ + nullptr, /*nb_inplace_subtract*/ + nullptr, /*nb_inplace_multiply*/ + nullptr, /*nb_inplace_remainder*/ + nullptr, /*nb_inplace_power*/ + nullptr, /*nb_inplace_lshift*/ + nullptr, /*nb_inplace_rshift*/ + nullptr, /*nb_inplace_and*/ + nullptr, /*nb_inplace_xor*/ + nullptr, /*nb_inplace_or*/ + nullptr, /*nb_floor_divide*/ number_divide_handler, /*nb_true_divide*/ -#endif - NULL, /*nb_inplace_floor_divide*/ - NULL, /*nb_inplace_true_divide*/ - NULL /*nb_index*/ + nullptr, /*nb_inplace_floor_divide*/ + nullptr, /*nb_inplace_true_divide*/ + nullptr /*nb_index*/ #if PY_VERSION_HEX >= 0x03050000 - ,NULL /*nb_matrix_multiply*/ - ,NULL /*nb_inplace_matrix_multiply*/ + ,nullptr /*nb_matrix_multiply*/ + ,nullptr /*nb_inplace_matrix_multiply*/ #endif } }; - @@ -480,44 +443,44 @@ PySequenceMethods @self.export.Name@::Sequence[] = { { + if (self.export.Sequence.sq_length): sequence_length, = else: - 0, + nullptr, - + if (self.export.Sequence.sq_concat): sequence_concat, = else: - 0, + nullptr, - + if (self.export.Sequence.sq_repeat): sequence_repeat, = else: - 0, + nullptr, - + if (self.export.Sequence.sq_item): sequence_item, = else: - 0, + nullptr, - - 0, + nullptr, + if (self.export.Sequence.sq_ass_item): sequence_ass_item, = else: - 0, + nullptr, - - 0, + nullptr, + if (self.export.Sequence.sq_contains): sequence_contains, = else: - 0, + nullptr, - + if (self.export.Sequence.sq_inplace_concat): sequence_inplace_concat, = else: - 0, + nullptr, - + if (self.export.Sequence.sq_inplace_repeat): sequence_inplace_repeat, = else: - 0 + nullptr - } }; @@ -525,17 +488,17 @@ PyMappingMethods @self.export.Name@::Mapping[] = { { + if (self.export.Sequence.sq_length): sequence_length, = else: - 0, + nullptr, - + if (self.export.Sequence.mp_subscript): mapping_subscript, = else: - 0, + nullptr, - + if (self.export.Sequence.mp_ass_subscript): mapping_ass_subscript, = else: - 0, + nullptr, - } }; - @@ -547,10 +510,10 @@ PyGetSetDef @self.export.Name@::GetterSetter[] = { (getter) staticCallback_get@i.Name@, (setter) staticCallback_set@i.Name@, "@i.Documentation.UserDocu.replace('\\n','\\\\n')@", - NULL + nullptr }, - - {NULL, NULL, NULL, NULL, NULL} /* Sentinel */ + {nullptr, nullptr, nullptr, nullptr, nullptr} /* Sentinel */ }; + for i in self.export.Methode: @@ -567,20 +530,20 @@ PyObject * @self.export.Name@::staticCallback_@i.Name@ (PyObject *self, PyObject // make sure that not a null pointer is passed if (!self) { PyErr_SetString(PyExc_TypeError, "descriptor '@i.Name@' of '@self.export.Namespace@.@self.export.Twin@' object needs an argument"); - return NULL; + return nullptr; } // test if twin object isn't already deleted if (!static_cast(self)->isValid()) { PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!"); - return NULL; + return nullptr; } + if (not i.Const): // test if object is set Const if (static_cast(self)->isConst()) { PyErr_SetString(PyExc_ReferenceError, "This object is immutable, you can not set any attribute or call a non const method"); - return NULL; + return nullptr; } - @@ -616,7 +579,7 @@ PyObject * @self.export.Name@::staticCallback_@i.Name@ (PyObject *self, PyObject catch(Base::AbortException &e) { PyErr_SetObject(Base::BaseExceptionFreeCADAbort,e.getPyObject()); - return NULL; + return nullptr; } catch(Base::Exception &e) { @@ -624,28 +587,28 @@ PyObject * @self.export.Name@::staticCallback_@i.Name@ (PyObject *self, PyObject if(!pye) pye = Base::BaseExceptionFreeCADError; PyErr_SetObject(pye,e.getPyObject()); - return NULL; + return nullptr; } catch(std::exception &e) { PyErr_SetString(Base::BaseExceptionFreeCADError,e.what()); - return NULL; + return nullptr; } catch(const Py::Exception&) { // The exception text is already set - return NULL; + return nullptr; } catch(const char *e) { PyErr_SetString(Base::BaseExceptionFreeCADError,e); - return NULL; + return nullptr; } #ifndef DONT_CATCH_CXX_EXCEPTIONS catch(...) { PyErr_SetString(Base::BaseExceptionFreeCADError,"Unknown C++ exception"); - return NULL; + return nullptr; } #endif } @@ -659,17 +622,17 @@ PyObject * @self.export.Name@::staticCallback_get@i.Name@ (PyObject *self, void { if (!static_cast(self)->isValid()){ PyErr_SetString(PyExc_ReferenceError, "This object is already deleted most likely through closing a document. This reference is no longer valid!"); - return NULL; + return nullptr; } try { return Py::new_reference_to(static_cast<@self.export.Name@*>(self)->get@i.Name@()); } catch (const Py::Exception&) { // The exception text is already set - return NULL; + return nullptr; } catch (...) { PyErr_SetString(Base::BaseExceptionFreeCADError, "Unknown exception while reading attribute '@i.Name@' of object '@self.export.Twin@'"); - return NULL; + return nullptr; } } @@ -740,7 +703,7 @@ PyObject *@self.export.Name@::PyMake(struct _typeobject *, PyObject *, PyObject // never create such objects with the constructor PyErr_SetString(PyExc_RuntimeError, "You cannot create directly an instance of '@self.export.Name@'."); - return 0; + return nullptr; } int @self.export.Name@::PyInit(PyObject* /*args*/, PyObject* /*kwd*/) @@ -770,7 +733,7 @@ int @self.export.Name@::PyInit(PyObject* /*args*/, PyObject* /*kwd*/) //-------------------------------------------------------------------------- // @self.export.Name@ representation //-------------------------------------------------------------------------- -PyObject *@self.export.Name@::_repr(void) +PyObject *@self.export.Name@::_repr() { return Py_BuildValue("s", representation().c_str()); } @@ -789,7 +752,7 @@ PyObject *@self.export.Name@::_getattr(const char *attr) // __getattr__ functi catch(Base::AbortException &e) { PyErr_SetObject(Base::BaseExceptionFreeCADAbort,e.getPyObject()); - return NULL; + return nullptr; } catch(Base::Exception &e) { @@ -797,33 +760,33 @@ PyObject *@self.export.Name@::_getattr(const char *attr) // __getattr__ functi if(!pye) pye = Base::BaseExceptionFreeCADError; PyErr_SetObject(pye,e.getPyObject()); - return NULL; + return nullptr; } catch(std::exception &e) { PyErr_SetString(Base::BaseExceptionFreeCADError,e.what()); - return NULL; + return nullptr; } catch(const Py::Exception&) { // The exception text is already set - return NULL; + return nullptr; } catch(const char *e) { PyErr_SetString(Base::BaseExceptionFreeCADError,e); - return NULL; + return nullptr; } #ifndef DONT_CATCH_CXX_EXCEPTIONS catch(...) { PyErr_SetString(Base::BaseExceptionFreeCADError,"Unknown C++ exception"); - return NULL; + return nullptr; } #endif PyMethodDef *ml = Methods; - for (; ml->ml_name != NULL; ml++) { + for (; ml->ml_name != nullptr; ml++) { if (attr[0] == ml->ml_name[0] && strcmp(attr+1, ml->ml_name+1) == 0) return PyCFunction_New(ml, this); @@ -886,7 +849,7 @@ int @self.export.Name@::_setattr(const char *attr, PyObject *value) // __setattr } - -@self.export.TwinPointer@ *@self.export.Name@::get@self.export.Twin@Ptr(void) const +@self.export.TwinPointer@ *@self.export.Name@::get@self.export.Twin@Ptr() const { return static_cast<@self.export.TwinPointer@ *>(_pcTwinPointer); } @@ -926,7 +889,7 @@ int @self.export.Name@::finalization() - // returns a string which represents the object e.g. when printed in python -std::string @self.export.Name@::representation(void) const +std::string @self.export.Name@::representation() const { return std::string("<@self.export.Twin@ object>"); } @@ -947,7 +910,7 @@ PyObject* @self.export.Name@::@i.Name@(PyObject *args) - { PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented"); - return 0; + return nullptr; } - @@ -955,61 +918,61 @@ PyObject* @self.export.Name@::@i.Name@(PyObject *args) PyObject* @self.export.Name@::number_add_handler(PyObject* /*self*/, PyObject* /*other*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject* @self.export.Name@::number_subtract_handler(PyObject* /*self*/, PyObject* /*other*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject* @self.export.Name@::number_multiply_handler(PyObject* /*self*/, PyObject* /*other*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * @self.export.Name@::number_divide_handler (PyObject* /*self*/, PyObject* /*other*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * @self.export.Name@::number_remainder_handler (PyObject* /*self*/, PyObject* /*other*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * @self.export.Name@::number_divmod_handler (PyObject* /*self*/, PyObject* /*other*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * @self.export.Name@::number_power_handler (PyObject* /*self*/, PyObject* /*other*/, PyObject* /*modulo*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * @self.export.Name@::number_negative_handler (PyObject* /*self*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * @self.export.Name@::number_positive_handler (PyObject* /*self*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * @self.export.Name@::number_absolute_handler (PyObject* /*self*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } int @self.export.Name@::number_nonzero_handler (PyObject* /*self*/) @@ -1020,37 +983,37 @@ int @self.export.Name@::number_nonzero_handler (PyObject* /*self*/) PyObject * @self.export.Name@::number_invert_handler (PyObject* /*self*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * @self.export.Name@::number_lshift_handler (PyObject* /*self*/, PyObject* /*other*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * @self.export.Name@::number_rshift_handler (PyObject* /*self*/, PyObject* /*other*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * @self.export.Name@::number_and_handler (PyObject* /*self*/, PyObject* /*other*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * @self.export.Name@::number_xor_handler (PyObject* /*self*/, PyObject* /*other*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * @self.export.Name@::number_or_handler (PyObject* /*self*/, PyObject* /*other*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } int @self.export.Name@::number_coerce_handler (PyObject** /*self*/, PyObject** /*other*/) @@ -1061,31 +1024,31 @@ int @self.export.Name@::number_coerce_handler (PyObject** /*self*/, PyObject** / PyObject * @self.export.Name@::number_int_handler (PyObject* /*self*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * @self.export.Name@::number_long_handler (PyObject* /*self*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * @self.export.Name@::number_float_handler (PyObject* /*self*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * @self.export.Name@::number_oct_handler (PyObject* /*self*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * @self.export.Name@::number_hex_handler (PyObject* /*self*/) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } - + if (self.export.Sequence): @@ -1102,7 +1065,7 @@ Py_ssize_t @self.export.Name@::sequence_length(PyObject *) PyObject* @self.export.Name@::sequence_concat(PyObject *, PyObject *) { PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented"); - return 0; + return nullptr; } - + if (self.export.Sequence.sq_repeat): @@ -1110,7 +1073,7 @@ PyObject* @self.export.Name@::sequence_concat(PyObject *, PyObject *) PyObject * @self.export.Name@::sequence_repeat(PyObject *, Py_ssize_t) { PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented"); - return 0; + return nullptr; } - + if (self.export.Sequence.sq_item): @@ -1118,7 +1081,7 @@ PyObject * @self.export.Name@::sequence_repeat(PyObject *, Py_ssize_t) PyObject * @self.export.Name@::sequence_item(PyObject *, Py_ssize_t) { PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented"); - return 0; + return nullptr; } - + if (self.export.Sequence.mp_subscript): @@ -1126,7 +1089,7 @@ PyObject * @self.export.Name@::sequence_item(PyObject *, Py_ssize_t) PyObject * @self.export.Name@::mapping_subscript(PyObject *, PyObject *) { PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented"); - return 0; + return nullptr; } - + if (self.export.Sequence.sq_ass_item): @@ -1158,7 +1121,7 @@ int @self.export.Name@::sequence_contains(PyObject *, PyObject *) PyObject* @self.export.Name@::sequence_inplace_concat(PyObject *, PyObject *) { PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented"); - return 0; + return nullptr; } - + if (self.export.Sequence.sq_inplace_repeat): @@ -1166,7 +1129,7 @@ PyObject* @self.export.Name@::sequence_inplace_concat(PyObject *, PyObject *) PyObject * @self.export.Name@::sequence_inplace_repeat(PyObject *, Py_ssize_t) { PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented"); - return 0; + return nullptr; } - - @@ -1175,12 +1138,12 @@ PyObject * @self.export.Name@::sequence_inplace_repeat(PyObject *, Py_ssize_t) PyObject* @self.export.Name@::richCompare(PyObject *v, PyObject *w, int op) { PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented"); - return 0; + return nullptr; } - + for i in self.export.Attribute: -Py::@i.Parameter.Type@ @self.export.Name@::get@i.Name@(void) const +Py::@i.Parameter.Type@ @self.export.Name@::get@i.Name@() const { //return Py::@i.Parameter.Type@(); throw Py::AttributeError("Not yet implemented"); @@ -1198,7 +1161,7 @@ void @self.export.Name@::set@i.Name@(Py::@i.Parameter.Type@ arg) PyObject *@self.export.Name@::getCustomAttributes(const char* /*attr*/) const { - return 0; + return nullptr; } int @self.export.Name@::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/) @@ -1224,7 +1187,7 @@ int @self.export.Name@::setCustomAttributes(const char* /*attr*/, PyObject* /*ob using namespace @self.export.Namespace@; // returns a string which represents the object e.g. when printed in python -std::string @self.export.Name@::representation(void) const +std::string @self.export.Name@::representation() const { return std::string("<@self.export.Twin@ object>"); } @@ -1272,7 +1235,7 @@ PyObject* @self.export.Name@::@i.Name@(PyObject * /*args*/) - { PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented"); - return 0; + return nullptr; } - @@ -1280,61 +1243,61 @@ PyObject* @self.export.Name@::@i.Name@(PyObject * /*args*/) PyObject* @self.export.Name@::number_add_handler(PyObject *self, PyObject *other) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject* @self.export.Name@::number_subtract_handler(PyObject *self, PyObject *other) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject* @self.export.Name@::number_multiply_handler(PyObject *self, PyObject *other) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * @self.export.Name@::number_divide_handler (PyObject *self, PyObject *other) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * @self.export.Name@::number_remainder_handler (PyObject *self, PyObject *other) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * @self.export.Name@::number_divmod_handler (PyObject *self, PyObject *other) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * @self.export.Name@::number_power_handler (PyObject *self, PyObject *other, PyObject *modulo) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * @self.export.Name@::number_negative_handler (PyObject *self) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * @self.export.Name@::number_positive_handler (PyObject *self) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * @self.export.Name@::number_absolute_handler (PyObject *self) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } int @self.export.Name@::number_nonzero_handler (PyObject *self) @@ -1345,37 +1308,37 @@ int @self.export.Name@::number_nonzero_handler (PyObject *self) PyObject * @self.export.Name@::number_invert_handler (PyObject *self) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * @self.export.Name@::number_lshift_handler (PyObject *self, PyObject *other) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * @self.export.Name@::number_rshift_handler (PyObject *self, PyObject *other) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * @self.export.Name@::number_and_handler (PyObject *self, PyObject *other) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * @self.export.Name@::number_xor_handler (PyObject *self, PyObject *other) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * @self.export.Name@::number_or_handler (PyObject *self, PyObject *other) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } int @self.export.Name@::number_coerce_handler (PyObject **self, PyObject **other) @@ -1386,31 +1349,31 @@ int @self.export.Name@::number_coerce_handler (PyObject **self, PyObject **other PyObject * @self.export.Name@::number_int_handler (PyObject *self) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * @self.export.Name@::number_long_handler (PyObject *self) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * @self.export.Name@::number_float_handler (PyObject *self) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * @self.export.Name@::number_oct_handler (PyObject *self) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } PyObject * @self.export.Name@::number_hex_handler (PyObject *self) { PyErr_SetString(PyExc_NotImplementedError, "Not implemented"); - return 0; + return nullptr; } - @@ -1428,7 +1391,7 @@ Py_ssize_t @self.export.Name@::sequence_length(PyObject *) PyObject* @self.export.Name@::sequence_concat(PyObject *, PyObject *) { PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented"); - return 0; + return nullptr; } - + if (self.export.Sequence.sq_repeat): @@ -1436,7 +1399,7 @@ PyObject* @self.export.Name@::sequence_concat(PyObject *, PyObject *) PyObject * @self.export.Name@::sequence_repeat(PyObject *, Py_ssize_t) { PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented"); - return 0; + return nullptr; } - + if (self.export.Sequence.sq_item): @@ -1444,7 +1407,7 @@ PyObject * @self.export.Name@::sequence_repeat(PyObject *, Py_ssize_t) PyObject * @self.export.Name@::sequence_item(PyObject *, Py_ssize_t) { PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented"); - return 0; + return nullptr; } - + if (self.export.Sequence.mp_subscript): @@ -1452,7 +1415,7 @@ PyObject * @self.export.Name@::sequence_item(PyObject *, Py_ssize_t) PyObject * @self.export.Name@::mapping_subscript(PyObject *, PyObject *) { PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented"); - return 0; + return nullptr; } - + if (self.export.Sequence.sq_ass_item): @@ -1484,7 +1447,7 @@ int @self.export.Name@::sequence_contains(PyObject *, PyObject *) PyObject* @self.export.Name@::sequence_inplace_concat(PyObject *, PyObject *) { PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented"); - return 0; + return nullptr; } - + if (self.export.Sequence.sq_inplace_repeat): @@ -1492,7 +1455,7 @@ PyObject* @self.export.Name@::sequence_inplace_concat(PyObject *, PyObject *) PyObject * @self.export.Name@::sequence_inplace_repeat(PyObject *, Py_ssize_t) { PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented"); - return 0; + return nullptr; } - - @@ -1501,13 +1464,13 @@ PyObject * @self.export.Name@::sequence_inplace_repeat(PyObject *, Py_ssize_t) PyObject* @self.export.Name@::richCompare(PyObject *v, PyObject *w, int op) { PyErr_SetString(PyExc_NotImplementedError, "Not yet implemented"); - return 0; + return nullptr; } - + for i in self.export.Attribute: -Py::@i.Parameter.Type@ @self.export.Name@::get@i.Name@(void) const +Py::@i.Parameter.Type@ @self.export.Name@::get@i.Name@() const { //return Py::@i.Parameter.Type@(); throw Py::AttributeError("Not yet implemented"); @@ -1525,7 +1488,7 @@ void @self.export.Name@::set@i.Name@(Py::@i.Parameter.Type@ /*arg*/) PyObject *@self.export.Name@::getCustomAttributes(const char* /*attr*/) const { - return 0; + return nullptr; } int @self.export.Name@::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/) From e92325c9c94e79594e36627b1b3a6f2383e41ee1 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 26 Apr 2021 10:55:56 +0200 Subject: [PATCH 155/178] App: remove some more deprecated Py2 code and remove deprecated void from function signature and replace 0 or NULL with nullptr --- src/App/Expression.cpp | 3 - src/App/FeaturePythonPyImp.h | 26 +-- src/App/PropertyStandard.cpp | 327 ++++++++--------------------------- src/Base/Interpreter.cpp | 4 - src/Main/MainGui.cpp | 8 - 5 files changed, 75 insertions(+), 293 deletions(-) diff --git a/src/App/Expression.cpp b/src/App/Expression.cpp index af94bb3622..1edc62605b 100644 --- a/src/App/Expression.cpp +++ b/src/App/Expression.cpp @@ -527,9 +527,6 @@ Py::Object pyFromQuantity(const Quantity &quantity) { int i; switch(essentiallyInteger(v,l,i)) { case 1: -#if PY_MAJOR_VERSION < 3 - return Py::Int(i); -#endif case 2: return Py::Long(l); default: diff --git a/src/App/FeaturePythonPyImp.h b/src/App/FeaturePythonPyImp.h index 1b1393ed3f..cae903ad30 100644 --- a/src/App/FeaturePythonPyImp.h +++ b/src/App/FeaturePythonPyImp.h @@ -65,7 +65,7 @@ { \ } -#elif PY_MAJOR_VERSION >= 3 +#else #define PYTHON_TYPE_IMP(_class_, _subclass_) \ PyTypeObject _class_::Type = { \ PyVarObject_HEAD_INIT(&PyType_Type, 0) \ @@ -85,30 +85,6 @@ _class_::~_class_() \ { \ } - -#else - -#define PYTHON_TYPE_IMP(_class_, _subclass_) \ - PyTypeObject _class_::Type = { \ - PyObject_HEAD_INIT(&PyType_Type) \ - 0, \ - ""#_class_"", \ - sizeof(_class_), \ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, \ - Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_CLASS, \ - ""#_class_"", \ - 0, 0, 0, 0, 0, 0, 0, 0, 0, \ - &_subclass_::Type, \ - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 \ - }; \ - _class_::_class_(Base::BaseClass *pcObject, PyTypeObject *T) \ - : _subclass_(reinterpret_cast<_subclass_::PointerType>(pcObject), T) \ - { \ - } \ - _class_::~_class_() \ - { \ - } - #endif namespace App diff --git a/src/App/PropertyStandard.cpp b/src/App/PropertyStandard.cpp index e0572d436d..684ca308f5 100644 --- a/src/App/PropertyStandard.cpp +++ b/src/App/PropertyStandard.cpp @@ -89,27 +89,21 @@ void PropertyInteger::setValue(long lValue) hasSetValue(); } -long PropertyInteger::getValue(void) const +long PropertyInteger::getValue() const { return _lValue; } -PyObject *PropertyInteger::getPyObject(void) +PyObject *PropertyInteger::getPyObject() { return Py_BuildValue("l", _lValue); } void PropertyInteger::setPyObject(PyObject *value) { -#if PY_MAJOR_VERSION < 3 - if (PyInt_Check(value)) { - aboutToSetValue(); - _lValue = PyInt_AsLong(value); -#else if (PyLong_Check(value)) { aboutToSetValue(); _lValue = PyLong_AsLong(value); -#endif hasSetValue(); } else { @@ -132,7 +126,7 @@ void PropertyInteger::Restore(Base::XMLReader &reader) setValue(reader.getAttributeAsInteger("value")); } -Property *PropertyInteger::Copy(void) const +Property *PropertyInteger::Copy() const { PropertyInteger *p= new PropertyInteger(); p->_lValue = _lValue; @@ -213,12 +207,12 @@ void PropertyPath::setValue(const char * Path) hasSetValue(); } -boost::filesystem::path PropertyPath::getValue(void) const +boost::filesystem::path PropertyPath::getValue() const { return _cValue; } -PyObject *PropertyPath::getPyObject(void) +PyObject *PropertyPath::getPyObject() { #if (BOOST_FILESYSTEM_VERSION == 2) std::string str = _cValue.native_file_string(); @@ -227,7 +221,7 @@ PyObject *PropertyPath::getPyObject(void) #endif // Returns a new reference, don't increment it! - PyObject *p = PyUnicode_DecodeUTF8(str.c_str(),str.size(),0); + PyObject *p = PyUnicode_DecodeUTF8(str.c_str(),str.size(),nullptr); if (!p) throw Base::UnicodeError("UTF8 conversion failure at PropertyPath::getPyObject()"); return p; } @@ -236,16 +230,7 @@ void PropertyPath::setPyObject(PyObject *value) { std::string path; if (PyUnicode_Check(value)) { -#if PY_MAJOR_VERSION >= 3 path = PyUnicode_AsUTF8(value); -#else - PyObject* unicode = PyUnicode_AsUTF8String(value); - path = PyString_AsString(unicode); - Py_DECREF(unicode); - } - else if (PyString_Check(value)) { - path = PyString_AsString(value); -#endif } else { std::string error = std::string("type must be str or unicode, not "); @@ -272,7 +257,7 @@ void PropertyPath::Restore(Base::XMLReader &reader) setValue(reader.getAttribute("value")); } -Property *PropertyPath::Copy(void) const +Property *PropertyPath::Copy() const { PropertyPath *p= new PropertyPath(); p->_cValue = _cValue; @@ -286,7 +271,7 @@ void PropertyPath::Paste(const Property &from) hasSetValue(); } -unsigned int PropertyPath::getMemSize (void) const +unsigned int PropertyPath::getMemSize () const { return static_cast(_cValue.string().size()); } @@ -361,7 +346,7 @@ void PropertyEnumeration::setValue(const Enumeration &source) hasSetValue(); } -long PropertyEnumeration::getValue(void) const +long PropertyEnumeration::getValue() const { return _enum.getInt(); } @@ -376,29 +361,29 @@ bool PropertyEnumeration::isPartOf(const char *value) const return _enum.contains(value); } -const char * PropertyEnumeration::getValueAsString(void) const +const char * PropertyEnumeration::getValueAsString() const { if (!_enum.isValid()) throw Base::RuntimeError("Cannot get value from invalid enumeration"); return _enum.getCStr(); } -Enumeration PropertyEnumeration::getEnum(void) const +Enumeration PropertyEnumeration::getEnum() const { return _enum; } -std::vector PropertyEnumeration::getEnumVector(void) const +std::vector PropertyEnumeration::getEnumVector() const { return _enum.getEnumVector(); } -const char ** PropertyEnumeration::getEnums(void) const +const char ** PropertyEnumeration::getEnums() const { return _enum.getEnums(); } -bool PropertyEnumeration::isValid(void) const +bool PropertyEnumeration::isValid() const { return _enum.isValid(); } @@ -454,11 +439,11 @@ void PropertyEnumeration::Restore(Base::XMLReader &reader) setValue(val); } -PyObject * PropertyEnumeration::getPyObject(void) +PyObject * PropertyEnumeration::getPyObject() { if (!_enum.isValid()) { PyErr_SetString(PyExc_AssertionError, "The enum is empty"); - return 0; + return nullptr; } return Py_BuildValue("s", getValueAsString()); @@ -466,42 +451,16 @@ PyObject * PropertyEnumeration::getPyObject(void) void PropertyEnumeration::setPyObject(PyObject *value) { -#if PY_MAJOR_VERSION < 3 - if (PyInt_Check(value)) { - long val = PyInt_AsLong(value); -#else if (PyLong_Check(value)) { long val = PyLong_AsLong(value); -#endif if (_enum.isValid()) { aboutToSetValue(); _enum.setValue(val, true); hasSetValue(); } } -#if PY_MAJOR_VERSION < 3 - else if (PyString_Check(value)) { - const char* str = PyString_AsString (value); - if (_enum.contains(str)) { - aboutToSetValue(); - _enum.setValue(PyString_AsString (value)); - hasSetValue(); - } - else { - std::stringstream out; - out << "'" << str << "' is not part of the enumeration"; - throw Base::ValueError(out.str()); - } - } -#endif else if (PyUnicode_Check(value)) { -#if PY_MAJOR_VERSION >=3 std::string str = PyUnicode_AsUTF8(value); -#else - PyObject* unicode = PyUnicode_AsUTF8String(value); - std::string str = PyString_AsString(unicode); - Py_DECREF(unicode); -#endif if (_enum.contains(str.c_str())) { aboutToSetValue(); _enum.setValue(str); @@ -522,19 +481,8 @@ void PropertyEnumeration::setPyObject(PyObject *value) PyObject *item = PySequence_GetItem(value, i); if (PyUnicode_Check(item)) { -#if PY_MAJOR_VERSION >= 3 values[i] = PyUnicode_AsUTF8(item); -#else - PyObject* unicode = PyUnicode_AsUTF8String(item); - values[i] = PyString_AsString(unicode); - Py_DECREF(unicode); -#endif } -#if PY_MAJOR_VERSION < 3 - else if (PyString_Check(item)) { - values[i] = PyString_AsString(item); - } -#endif else { std::string error = std::string("type in list must be str or unicode, not "); throw Base::TypeError(error + item->ob_type->tp_name); @@ -549,7 +497,7 @@ void PropertyEnumeration::setPyObject(PyObject *value) } } -Property * PropertyEnumeration::Copy(void) const +Property * PropertyEnumeration::Copy() const { return new PropertyEnumeration(_enum); } @@ -596,7 +544,7 @@ TYPESYSTEM_SOURCE(App::PropertyIntegerConstraint, App::PropertyInteger) PropertyIntegerConstraint::PropertyIntegerConstraint() - : _ConstStruct(0) + : _ConstStruct(nullptr) { } @@ -618,7 +566,7 @@ void PropertyIntegerConstraint::setConstraints(const Constraints* sConstrain) _ConstStruct = sConstrain; } -const PropertyIntegerConstraint::Constraints* PropertyIntegerConstraint::getConstraints(void) const +const PropertyIntegerConstraint::Constraints* PropertyIntegerConstraint::getConstraints() const { return _ConstStruct; } @@ -648,13 +596,8 @@ long PropertyIntegerConstraint::getStepSize() const void PropertyIntegerConstraint::setPyObject(PyObject *value) { -#if PY_MAJOR_VERSION < 3 - if (PyInt_Check(value)) { - long temp = PyInt_AsLong(value); -#else if (PyLong_Check(value)) { long temp = PyLong_AsLong(value); -#endif if (_ConstStruct) { if (temp > _ConstStruct->UpperBound) temp = _ConstStruct->UpperBound; @@ -671,13 +614,8 @@ void PropertyIntegerConstraint::setPyObject(PyObject *value) for (int i=0; i<4; i++) { PyObject* item; item = PyTuple_GetItem(value,i); -#if PY_MAJOR_VERSION < 3 - if (PyInt_Check(item)) - values[i] = PyInt_AsLong(item); -#else if (PyLong_Check(item)) values[i] = PyLong_AsLong(item); -#endif else throw Base::TypeError("Type in tuple must be int"); } @@ -750,26 +688,17 @@ PropertyIntegerList::~PropertyIntegerList() //************************************************************************** // Base class implementer -PyObject *PropertyIntegerList::getPyObject(void) +PyObject *PropertyIntegerList::getPyObject() { PyObject* list = PyList_New(getSize()); for(int i = 0;iob_type->tp_name; throw Base::TypeError(error); @@ -804,7 +733,7 @@ void PropertyIntegerList::Restore(Base::XMLReader &reader) setValues(values); } -Property *PropertyIntegerList::Copy(void) const +Property *PropertyIntegerList::Copy() const { PropertyIntegerList *p= new PropertyIntegerList(); p->_lValueList = _lValueList; @@ -816,7 +745,7 @@ void PropertyIntegerList::Paste(const Property &from) setValues(dynamic_cast(from)._lValueList); } -unsigned int PropertyIntegerList::getMemSize (void) const +unsigned int PropertyIntegerList::getMemSize () const { return static_cast(_lValueList.size() * sizeof(long)); } @@ -864,15 +793,11 @@ void PropertyIntegerSet::setValues(const std::set& values) hasSetValue(); } -PyObject *PropertyIntegerSet::getPyObject(void) +PyObject *PropertyIntegerSet::getPyObject() { - PyObject* set = PySet_New(NULL); + PyObject* set = PySet_New(nullptr); for(std::set::const_iterator it=_lValueSet.begin();it!=_lValueSet.end();++it) -#if PY_MAJOR_VERSION < 3 - PySet_Add(set,PyInt_FromLong(*it)); -#else PySet_Add(set,PyLong_FromLong(*it)); -#endif return set; } @@ -885,32 +810,18 @@ void PropertyIntegerSet::setPyObject(PyObject *value) for (Py_ssize_t i=0; iob_type->tp_name; - throw Base::TypeError(error); - } - values.insert(PyInt_AsLong(item)); -#else if (!PyLong_Check(item)) { std::string error = std::string("type in list must be int, not "); error += item->ob_type->tp_name; throw Base::TypeError(error); } values.insert(PyLong_AsLong(item)); -#endif } setValues(values); } -#if PY_MAJOR_VERSION < 3 - else if (PyInt_Check(value)) { - setValue(PyInt_AsLong(value)); -#else else if (PyLong_Check(value)) { setValue(PyLong_AsLong(value)); -#endif } else { std::string error = std::string("type must be int or list of int, not "); @@ -948,7 +859,7 @@ void PropertyIntegerSet::Restore(Base::XMLReader &reader) setValues(values); } -Property *PropertyIntegerSet::Copy(void) const +Property *PropertyIntegerSet::Copy() const { PropertyIntegerSet *p= new PropertyIntegerSet(); p->_lValueSet = _lValueSet; @@ -962,7 +873,7 @@ void PropertyIntegerSet::Paste(const Property &from) hasSetValue(); } -unsigned int PropertyIntegerSet::getMemSize (void) const +unsigned int PropertyIntegerSet::getMemSize () const { return static_cast(_lValueSet.size() * sizeof(long)); } @@ -1000,12 +911,12 @@ void PropertyFloat::setValue(double lValue) hasSetValue(); } -double PropertyFloat::getValue(void) const +double PropertyFloat::getValue() const { return _dValue; } -PyObject *PropertyFloat::getPyObject(void) +PyObject *PropertyFloat::getPyObject() { return Py_BuildValue("d", _dValue); } @@ -1017,15 +928,9 @@ void PropertyFloat::setPyObject(PyObject *value) _dValue = PyFloat_AsDouble(value); hasSetValue(); } -#if PY_MAJOR_VERSION < 3 - else if(PyInt_Check(value)) { - aboutToSetValue(); - _dValue = PyInt_AsLong(value); -#else else if(PyLong_Check(value)) { aboutToSetValue(); _dValue = PyLong_AsLong(value); -#endif hasSetValue(); } else { @@ -1048,7 +953,7 @@ void PropertyFloat::Restore(Base::XMLReader &reader) setValue(reader.getAttributeAsFloat("value")); } -Property *PropertyFloat::Copy(void) const +Property *PropertyFloat::Copy() const { PropertyFloat *p= new PropertyFloat(); p->_dValue = _dValue; @@ -1100,7 +1005,7 @@ TYPESYSTEM_SOURCE(App::PropertyFloatConstraint, App::PropertyFloat) PropertyFloatConstraint::PropertyFloatConstraint() - : _ConstStruct(0) + : _ConstStruct(nullptr) { } @@ -1120,7 +1025,7 @@ void PropertyFloatConstraint::setConstraints(const Constraints* sConstrain) _ConstStruct = sConstrain; } -const PropertyFloatConstraint::Constraints* PropertyFloatConstraint::getConstraints(void) const +const PropertyFloatConstraint::Constraints* PropertyFloatConstraint::getConstraints() const { return _ConstStruct; } @@ -1161,13 +1066,8 @@ void PropertyFloatConstraint::setPyObject(PyObject *value) _dValue = temp; hasSetValue(); } -#if PY_MAJOR_VERSION < 3 - else if (PyInt_Check(value)) { - double temp = (double)PyInt_AsLong(value); -#else else if (PyLong_Check(value)) { double temp = (double)PyLong_AsLong(value); -#endif if (_ConstStruct) { if (temp > _ConstStruct->UpperBound) temp = _ConstStruct->UpperBound; @@ -1186,13 +1086,8 @@ void PropertyFloatConstraint::setPyObject(PyObject *value) item = PyTuple_GetItem(value,i); if (PyFloat_Check(item)) values[i] = PyFloat_AsDouble(item); -#if PY_MAJOR_VERSION < 3 - else if (PyInt_Check(item)) - values[i] = PyInt_AsLong(item); -#else else if (PyLong_Check(item)) values[i] = PyLong_AsLong(item); -#endif else throw Base::TypeError("Type in tuple must be float or int"); } @@ -1269,7 +1164,7 @@ PropertyFloatList::~PropertyFloatList() //************************************************************************** // Base class implementer -PyObject *PropertyFloatList::getPyObject(void) +PyObject *PropertyFloatList::getPyObject() { PyObject* list = PyList_New(getSize()); for (int i = 0;i= 3 } else if (PyLong_Check(item)) { return static_cast(PyLong_AsLong(item)); -#else - } else if (PyInt_Check(item)) { - return static_cast(PyInt_AsLong(item)); -#endif } else { std::string error = std::string("type in list must be float, not "); error += item->ob_type->tp_name; @@ -1360,7 +1250,7 @@ void PropertyFloatList::RestoreDocFile(Base::Reader &reader) setValues(values); } -Property *PropertyFloatList::Copy(void) const +Property *PropertyFloatList::Copy() const { PropertyFloatList *p= new PropertyFloatList(); p->_lValueList = _lValueList; @@ -1372,7 +1262,7 @@ void PropertyFloatList::Paste(const Property &from) setValues(dynamic_cast(from)._lValueList); } -unsigned int PropertyFloatList::getMemSize (void) const +unsigned int PropertyFloatList::getMemSize () const { return static_cast(_lValueList.size() * sizeof(double)); } @@ -1515,14 +1405,14 @@ void PropertyString::setValue(const std::string &sString) setValue(sString.c_str()); } -const char* PropertyString::getValue(void) const +const char* PropertyString::getValue() const { return _cValue.c_str(); } -PyObject *PropertyString::getPyObject(void) +PyObject *PropertyString::getPyObject() { - PyObject *p = PyUnicode_DecodeUTF8(_cValue.c_str(),_cValue.size(),0); + PyObject *p = PyUnicode_DecodeUTF8(_cValue.c_str(),_cValue.size(),nullptr); if (!p) throw Base::UnicodeError("UTF8 conversion failure at PropertyString::getPyObject()"); return p; } @@ -1531,16 +1421,7 @@ void PropertyString::setPyObject(PyObject *value) { std::string string; if (PyUnicode_Check(value)) { -#if PY_MAJOR_VERSION >= 3 string = PyUnicode_AsUTF8(value); -#else - PyObject* unicode = PyUnicode_AsUTF8String(value); - string = PyString_AsString(unicode); - Py_DECREF(unicode); - } - else if (PyString_Check(value)) { - string = PyString_AsString(value); -#endif } else { std::string error = std::string("type must be str or unicode, not "); @@ -1595,7 +1476,7 @@ void PropertyString::Restore(Base::XMLReader &reader) setValue(reader.getAttribute("value")); } -Property *PropertyString::Copy(void) const +Property *PropertyString::Copy() const { PropertyString *p= new PropertyString(); p->_cValue = _cValue; @@ -1607,7 +1488,7 @@ void PropertyString::Paste(const Property &from) setValue(dynamic_cast(from)._cValue); } -unsigned int PropertyString::getMemSize (void) const +unsigned int PropertyString::getMemSize () const { return static_cast(_cValue.size()); } @@ -1681,23 +1562,19 @@ void PropertyUUID::setValue(const std::string &sString) hasSetValue(); } -const std::string& PropertyUUID::getValueStr(void) const +const std::string& PropertyUUID::getValueStr() const { return _uuid.getValue(); } -const Base::Uuid& PropertyUUID::getValue(void) const +const Base::Uuid& PropertyUUID::getValue() const { return _uuid; } -PyObject *PropertyUUID::getPyObject(void) +PyObject *PropertyUUID::getPyObject() { -#if PY_MAJOR_VERSION >= 3 PyObject *p = PyUnicode_FromString(_uuid.getValue().c_str()); -#else - PyObject *p = PyString_FromString(_uuid.getValue().c_str()); -#endif return p; } @@ -1705,16 +1582,7 @@ void PropertyUUID::setPyObject(PyObject *value) { std::string string; if (PyUnicode_Check(value)) { -#if PY_MAJOR_VERSION >= 3 string = PyUnicode_AsUTF8(value); -#else - PyObject* unicode = PyUnicode_AsUTF8String(value); - string = PyString_AsString(unicode); - Py_DECREF(unicode); - } - else if (PyString_Check(value)) { - string = PyString_AsString(value); -#endif } else { std::string error = std::string("type must be unicode or str, not "); @@ -1746,7 +1614,7 @@ void PropertyUUID::Restore(Base::XMLReader &reader) setValue(reader.getAttribute("value")); } -Property *PropertyUUID::Copy(void) const +Property *PropertyUUID::Copy() const { PropertyUUID *p= new PropertyUUID(); p->_uuid = _uuid; @@ -1760,7 +1628,7 @@ void PropertyUUID::Paste(const Property &from) hasSetValue(); } -unsigned int PropertyUUID::getMemSize (void) const +unsigned int PropertyUUID::getMemSize () const { return static_cast(sizeof(_uuid)); } @@ -1809,12 +1677,12 @@ void PropertyStringList::setValues(const std::list& lValue) setValues(vals); } -PyObject *PropertyStringList::getPyObject(void) +PyObject *PropertyStringList::getPyObject() { PyObject* list = PyList_New(getSize()); for (int i = 0;i= 3 ret = PyUnicode_AsUTF8(item); -#else - PyObject* unicode = PyUnicode_AsUTF8String(item); - ret = PyString_AsString(unicode); - Py_DECREF(unicode); - } else if (PyString_Check(item)) { - ret = PyString_AsString(item); -#endif -#if PY_MAJOR_VERSION >= 3 } else if (PyBytes_Check(item)) { ret = PyBytes_AsString(item); -#endif } else { std::string error = std::string("type in list must be str or unicode, not "); error += item->ob_type->tp_name; @@ -1850,7 +1708,7 @@ std::string PropertyStringList::getPyValue(PyObject *item) const return ret; } -unsigned int PropertyStringList::getMemSize (void) const +unsigned int PropertyStringList::getMemSize () const { size_t size=0; for(int i = 0;i_lValueList = _lValueList; @@ -1922,7 +1780,7 @@ PropertyMap::~PropertyMap() // Base class implementer -int PropertyMap::getSize(void) const +int PropertyMap::getSize() const { return static_cast(_lValueList.size()); } @@ -1954,12 +1812,12 @@ const std::string& PropertyMap::operator[] (const std::string& key) const } -PyObject *PropertyMap::getPyObject(void) +PyObject *PropertyMap::getPyObject() { PyObject* dict = PyDict_New(); for (std::map::const_iterator it = _lValueList.begin();it!= _lValueList.end(); ++it) { - PyObject* item = PyUnicode_DecodeUTF8(it->second.c_str(), it->second.size(), 0); + PyObject* item = PyUnicode_DecodeUTF8(it->second.c_str(), it->second.size(), nullptr); if (!item) { Py_DECREF(dict); throw Base::UnicodeError("UTF8 conversion failure at PropertyMap::getPyObject()"); @@ -1988,15 +1846,7 @@ void PropertyMap::setPyObject(PyObject *value) std::string keyStr; PyObject* key = PyList_GetItem(keyList, i); if (PyUnicode_Check(key)) { -#if PY_MAJOR_VERSION >= 3 keyStr = PyUnicode_AsUTF8(key); -#else - PyObject* unicode = PyUnicode_AsUTF8String(key); - keyStr = PyString_AsString(unicode); - Py_DECREF(unicode); - }else if (PyString_Check(key)) { - keyStr = PyString_AsString(key); -#endif } else { std::string error = std::string("type of the key need to be unicode or string, not"); @@ -2007,16 +1857,7 @@ void PropertyMap::setPyObject(PyObject *value) // check on the item: PyObject* item = PyList_GetItem(itemList, i); if (PyUnicode_Check(item)) { -#if PY_MAJOR_VERSION >= 3 values[keyStr] = PyUnicode_AsUTF8(item); -#else - PyObject* unicode = PyUnicode_AsUTF8String(item); - values[keyStr] = PyString_AsString(unicode); - Py_DECREF(unicode); - } - else if (PyString_Check(item)) { - values[keyStr] = PyString_AsString(item); -#endif } else { std::string error = std::string("type in list must be string or unicode, not "); @@ -2034,7 +1875,7 @@ void PropertyMap::setPyObject(PyObject *value) } } -unsigned int PropertyMap::getMemSize (void) const +unsigned int PropertyMap::getMemSize () const { size_t size=0; for (std::map::const_iterator it = _lValueList.begin();it!= _lValueList.end(); ++it) { @@ -2076,7 +1917,7 @@ void PropertyMap::Restore(Base::XMLReader &reader) setValues(values); } -Property *PropertyMap::Copy(void) const +Property *PropertyMap::Copy() const { PropertyMap *p= new PropertyMap(); p->_lValueList = _lValueList; @@ -2123,12 +1964,12 @@ void PropertyBool::setValue(bool lValue) hasSetValue(); } -bool PropertyBool::getValue(void) const +bool PropertyBool::getValue() const { return _lValue; } -PyObject *PropertyBool::getPyObject(void) +PyObject *PropertyBool::getPyObject() { return PyBool_FromLong(_lValue ? 1 : 0); } @@ -2137,13 +1978,8 @@ void PropertyBool::setPyObject(PyObject *value) { if (PyBool_Check(value)) setValue(PyObject_IsTrue(value)!=0); -#if PY_MAJOR_VERSION < 3 - else if(PyInt_Check(value)) - setValue(PyInt_AsLong(value)!=0); -#else else if(PyLong_Check(value)) setValue(PyLong_AsLong(value)!=0); -#endif else { std::string error = std::string("type must be bool, not "); error += value->ob_type->tp_name; @@ -2171,7 +2007,7 @@ void PropertyBool::Restore(Base::XMLReader &reader) } -Property *PropertyBool::Copy(void) const +Property *PropertyBool::Copy() const { PropertyBool *p= new PropertyBool(); p->_lValue = _lValue; @@ -2236,7 +2072,7 @@ PropertyBoolList::~PropertyBoolList() //************************************************************************** // Base class implementer -PyObject *PropertyBoolList::getPyObject(void) +PyObject *PropertyBoolList::getPyObject() { PyObject* tuple = PyTuple_New(getSize()); for(int i = 0;i= 3 str = PyUnicode_AsUTF8(value); -#else - PyObject* unicode = PyUnicode_AsUTF8String(value); - str = PyString_AsString(unicode); - Py_DECREF(unicode); - boost::dynamic_bitset<> values(str); - setValues(values); - } else if (PyString_Check(value)) { - str = PyString_AsString(value); -#endif boost::dynamic_bitset<> values(str); setValues(values); }else @@ -2276,13 +2102,8 @@ void PropertyBoolList::setPyObject(PyObject *value) bool PropertyBoolList::getPyValue(PyObject *item) const { if (PyBool_Check(item)) { return (PyObject_IsTrue(item) ? true : false); -#if PY_MAJOR_VERSION < 3 - } else if (PyInt_Check(item)) { - return (PyInt_AsLong(item) ? true : false); -#else } else if (PyLong_Check(item)) { return (PyLong_AsLong(item) ? true : false); -#endif } else { std::string error = std::string("type in list must be bool or int, not "); error += item->ob_type->tp_name; @@ -2309,7 +2130,7 @@ void PropertyBoolList::Restore(Base::XMLReader &reader) setValues(bitset); } -Property *PropertyBoolList::Copy(void) const +Property *PropertyBoolList::Copy() const { PropertyBoolList *p= new PropertyBoolList(); p->_lValueList = _lValueList; @@ -2321,7 +2142,7 @@ void PropertyBoolList::Paste(const Property &from) setValues(dynamic_cast(from)._lValueList); } -unsigned int PropertyBoolList::getMemSize (void) const +unsigned int PropertyBoolList::getMemSize () const { return static_cast(_lValueList.size()); } @@ -2370,12 +2191,12 @@ void PropertyColor::setValue(float r, float g, float b, float a) hasSetValue(); } -const Color& PropertyColor::getValue(void) const +const Color& PropertyColor::getValue() const { return _cCol; } -PyObject *PropertyColor::getPyObject(void) +PyObject *PropertyColor::getPyObject() { PyObject* rgba = PyTuple_New(4); PyObject* r = PyFloat_FromDouble(_cCol.r); @@ -2462,7 +2283,7 @@ void PropertyColor::Restore(Base::XMLReader &reader) setValue(rgba); } -Property *PropertyColor::Copy(void) const +Property *PropertyColor::Copy() const { PropertyColor *p= new PropertyColor(); p->_cCol = _cCol; @@ -2498,7 +2319,7 @@ PropertyColorList::~PropertyColorList() //************************************************************************** // Base class implementer -PyObject *PropertyColorList::getPyObject(void) +PyObject *PropertyColorList::getPyObject() { PyObject* list = PyList_New(getSize()); @@ -2571,7 +2392,7 @@ void PropertyColorList::RestoreDocFile(Base::Reader &reader) setValues(values); } -Property *PropertyColorList::Copy(void) const +Property *PropertyColorList::Copy() const { PropertyColorList *p= new PropertyColorList(); p->_lValueList = _lValueList; @@ -2583,7 +2404,7 @@ void PropertyColorList::Paste(const Property &from) setValues(dynamic_cast(from)._lValueList); } -unsigned int PropertyColorList::getMemSize (void) const +unsigned int PropertyColorList::getMemSize () const { return static_cast(_lValueList.size() * sizeof(Color)); } @@ -2612,7 +2433,7 @@ void PropertyMaterial::setValue(const Material &mat) hasSetValue(); } -const Material& PropertyMaterial::getValue(void) const +const Material& PropertyMaterial::getValue() const { return _cMat; } @@ -2659,7 +2480,7 @@ void PropertyMaterial::setTransparency(float val) hasSetValue(); } -PyObject *PropertyMaterial::getPyObject(void) +PyObject *PropertyMaterial::getPyObject() { return new MaterialPy(new Material(_cMat)); } @@ -2703,14 +2524,14 @@ void PropertyMaterial::Restore(Base::XMLReader &reader) hasSetValue(); } -const char* PropertyMaterial::getEditorName(void) const +const char* PropertyMaterial::getEditorName() const { if(testStatus(MaterialEdit)) return "Gui::PropertyEditor::PropertyMaterialItem"; return ""; } -Property *PropertyMaterial::Copy(void) const +Property *PropertyMaterial::Copy() const { PropertyMaterial *p= new PropertyMaterial(); p->_cMat = _cMat; @@ -2746,7 +2567,7 @@ PropertyMaterialList::~PropertyMaterialList() //************************************************************************** // Base class implementer -PyObject *PropertyMaterialList::getPyObject(void) +PyObject *PropertyMaterialList::getPyObject() { Py::Tuple tuple(getSize()); @@ -2828,14 +2649,14 @@ void PropertyMaterialList::RestoreDocFile(Base::Reader &reader) setValues(values); } -const char* PropertyMaterialList::getEditorName(void) const +const char* PropertyMaterialList::getEditorName() const { if(testStatus(NoMaterialListEdit)) return ""; return "Gui::PropertyEditor::PropertyMaterialListItem"; } -Property *PropertyMaterialList::Copy(void) const +Property *PropertyMaterialList::Copy() const { PropertyMaterialList *p = new PropertyMaterialList(); p->_lValueList = _lValueList; @@ -2847,7 +2668,7 @@ void PropertyMaterialList::Paste(const Property &from) setValues(dynamic_cast(from)._lValueList); } -unsigned int PropertyMaterialList::getMemSize(void) const +unsigned int PropertyMaterialList::getMemSize() const { return static_cast(_lValueList.size() * sizeof(Material)); } @@ -2901,7 +2722,7 @@ void PropertyPersistentObject::Paste(const Property &from){ } } -unsigned int PropertyPersistentObject::getMemSize (void) const{ +unsigned int PropertyPersistentObject::getMemSize () const{ auto size = inherited::getMemSize(); if(_pObject) size += _pObject->getMemSize(); diff --git a/src/Base/Interpreter.cpp b/src/Base/Interpreter.cpp index 2e85c8adc6..8d51a31579 100644 --- a/src/Base/Interpreter.cpp +++ b/src/Base/Interpreter.cpp @@ -510,11 +510,7 @@ void InterpreterSingleton::addPythonPath(const char* Path) const char* InterpreterSingleton::init(int argc,char *argv[]) { if (!Py_IsInitialized()) { -#if PY_VERSION_HEX >= 0x03050000 Py_SetProgramName(Py_DecodeLocale(argv[0],nullptr)); -#else - Py_SetProgramName(_Py_char2wchar(argv[0],nullptr)); -#endif // There is a serious bug in VS from 2010 until 2013 where the file descriptor for stdin, stdout or stderr // returns a valid value for GUI applications (i.e. subsystem = Windows) where it shouldn't. // This causes Python to fail during initialization. diff --git a/src/Main/MainGui.cpp b/src/Main/MainGui.cpp index 47e2e53a3d..21c54845d1 100644 --- a/src/Main/MainGui.cpp +++ b/src/Main/MainGui.cpp @@ -249,15 +249,7 @@ int main( int argc, char ** argv ) "Python is searching for its files in the following directories:\n%3\n\n" "Python version information:\n%4\n") .arg(appName, QString::fromUtf8(e.what()), -#if PY_MAJOR_VERSION >= 3 -#if PY_MINOR_VERSION >= 5 QString::fromUtf8(Py_EncodeLocale(Py_GetPath(),NULL)), QString::fromLatin1(Py_GetVersion())); -#else - QString::fromUtf8(_Py_wchar2char(Py_GetPath(),NULL)), QString::fromLatin1(Py_GetVersion())); -#endif -#else - QString::fromUtf8(Py_GetPath()), QString::fromLatin1(Py_GetVersion())); -#endif const char* pythonhome = getenv("PYTHONHOME"); if (pythonhome) { msg += QObject::tr("\nThe environment variable PYTHONHOME is set to '%1'.") From 2c0ce4eda4baa8391299b5a1f677065ff1ba937c Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 26 Apr 2021 10:59:32 +0200 Subject: [PATCH 156/178] Gui: remove some more deprecated Py2 --- src/Gui/ApplicationPy.cpp | 6 +----- src/Main/MainGui.cpp | 2 -- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/Gui/ApplicationPy.cpp b/src/Gui/ApplicationPy.cpp index 746b383373..13016c977f 100644 --- a/src/Gui/ApplicationPy.cpp +++ b/src/Gui/ApplicationPy.cpp @@ -1144,16 +1144,12 @@ PyObject* Application::sAddCommand(PyObject * /*self*/, PyObject *args) std::string file; // usually this is the file name of the calling script -#if (PY_MAJOR_VERSION > 3 || (PY_MAJOR_VERSION==3 && PY_MINOR_VERSION>=5)) Py::Object info = list.getItem(0); PyObject *pyfile = PyStructSequence_GET_ITEM(*info,1); if(!pyfile) throw Py::Exception(); file = Py::Object(pyfile).as_string(); -#else - Py::Tuple info = list.getItem(0); - file = info.getItem(1).as_string(); -#endif + Base::FileInfo fi(file); // convert backslashes to slashes file = fi.filePath(); diff --git a/src/Main/MainGui.cpp b/src/Main/MainGui.cpp index 21c54845d1..93c263d85e 100644 --- a/src/Main/MainGui.cpp +++ b/src/Main/MainGui.cpp @@ -159,12 +159,10 @@ int main( int argc, char ** argv ) } #endif -#if PY_MAJOR_VERSION >= 3 #if defined(_MSC_VER) && _MSC_VER <= 1800 // See InterpreterSingleton::init Redirection out(stdout), err(stderr), inp(stdin); #endif -#endif // PY_MAJOR_VERSION // Name and Version of the Application App::Application::Config()["ExeName"] = "FreeCAD"; From b831d9d7f29175fcf6fc8f421558d9f540c56d26 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 26 Apr 2021 11:01:59 +0200 Subject: [PATCH 157/178] TD: remove some more deprecated Py2 code --- src/Mod/TechDraw/App/DrawViewDimensionPyImp.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Mod/TechDraw/App/DrawViewDimensionPyImp.cpp b/src/Mod/TechDraw/App/DrawViewDimensionPyImp.cpp index 143204a3b3..44ef7e7092 100644 --- a/src/Mod/TechDraw/App/DrawViewDimensionPyImp.cpp +++ b/src/Mod/TechDraw/App/DrawViewDimensionPyImp.cpp @@ -63,11 +63,7 @@ PyObject* DrawViewDimensionPy::getText(PyObject* args) DrawViewDimension* dvd = getDrawViewDimensionPtr(); std::string textString = dvd->getFormattedDimensionValue(); //TODO: check multiversion code! -#if PY_MAJOR_VERSION >= 3 PyObject* pyText = Base::PyAsUnicodeObject(textString); -#else - PyObject *pyText = PyString_FromString(textString.c_str()); -#endif return pyText; } From 72a3b9cb5184b9288dccf098b38ac556e4b56678 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 26 Apr 2021 11:03:48 +0200 Subject: [PATCH 158/178] Spreadsheet: remove some more deprecated Py2 code --- src/Mod/Spreadsheet/App/SheetPyImp.cpp | 60 -------------------------- 1 file changed, 60 deletions(-) diff --git a/src/Mod/Spreadsheet/App/SheetPyImp.cpp b/src/Mod/Spreadsheet/App/SheetPyImp.cpp index bd2a7755bb..221de6a1c9 100644 --- a/src/Mod/Spreadsheet/App/SheetPyImp.cpp +++ b/src/Mod/Spreadsheet/App/SheetPyImp.cpp @@ -289,13 +289,8 @@ PyObject* SheetPy::setStyle(PyObject *args) PyObject * item = PySet_Pop(copy); // check on the key: -#if PY_MAJOR_VERSION >= 3 if (PyUnicode_Check(item)) style.insert(PyUnicode_AsUTF8(item)); -#else - if (PyString_Check(item)) - style.insert(PyString_AsString(item)); -#endif else { std::string error = std::string("type of the set need to be a string, not ") + item->ob_type->tp_name; PyErr_SetString(PyExc_TypeError, error.c_str()); @@ -305,19 +300,11 @@ PyObject* SheetPy::setStyle(PyObject *args) } Py_DECREF(copy); } -#if PY_MAJOR_VERSION >= 3 else if (PyUnicode_Check(value)) { -#else - else if (PyString_Check(value)) { -#endif using namespace boost; escaped_list_separator e('\0', '|', '\0'); -#if PY_MAJOR_VERSION >= 3 std::string line = PyUnicode_AsUTF8(value); -#else - std::string line = PyString_AsString(value); -#endif tokenizer > tok(line, e); for(tokenizer >::iterator i = tok.begin(); i != tok.end();++i) @@ -429,11 +416,7 @@ PyObject* SheetPy::getStyle(PyObject *args) PyObject * s = PySet_New(NULL); for (std::set::const_iterator i = style.begin(); i != style.end(); ++i) -#if PY_MAJOR_VERSION >= 3 PySet_Add(s, PyUnicode_FromString((*i).c_str())); -#else - PySet_Add(s, PyString_FromString((*i).c_str())); -#endif return s; } @@ -478,17 +461,7 @@ PyObject* SheetPy::setAlias(PyObject *args) try { address = stringToAddress(strAddress); if (PyUnicode_Check(value)) -#if PY_MAJOR_VERSION >= 3 getSheetPtr()->setAlias(address, PyUnicode_AsUTF8(value)); -#else - { - PyObject* unicode = PyUnicode_AsUTF8String(value); - getSheetPtr()->setAlias(address, PyString_AsString(unicode)); - Py_DECREF(unicode); - } - else if (PyString_Check(value)) - getSheetPtr()->setAlias(address, PyString_AsString(value)); -#endif else if (value == Py_None) getSheetPtr()->setAlias(address, ""); else @@ -594,13 +567,8 @@ PyObject* SheetPy::setAlignment(PyObject *args) while (n-- > 0) { PyObject * item = PySet_Pop(copy); -#if PY_MAJOR_VERSION >= 3 if (PyUnicode_Check(item)) alignment = Cell::decodeAlignment(PyUnicode_AsUTF8(item), alignment); -#else - if (PyString_Check(item)) - alignment = Cell::decodeAlignment(PyString_AsString(item), alignment); -#endif else { std::string error = std::string("type of the key need to be a string, not") + item->ob_type->tp_name; PyErr_SetString(PyExc_TypeError, error.c_str()); @@ -611,20 +579,12 @@ PyObject* SheetPy::setAlignment(PyObject *args) Py_DECREF(copy); } -#if PY_MAJOR_VERSION >= 3 else if (PyUnicode_Check(value)) { -#else - else if (PyString_Check(value)) { -#endif // Argument is a string, combination of alignments, separated by the pipe character using namespace boost; escaped_list_separator e('\0', '|', '\0'); -#if PY_MAJOR_VERSION >= 3 std::string line = PyUnicode_AsUTF8(value); -#else - std::string line = PyString_AsString(value); -#endif tokenizer > tok(line, e); for(tokenizer >::iterator i = tok.begin(); i != tok.end();++i) @@ -691,7 +651,6 @@ PyObject* SheetPy::getAlignment(PyObject *args) if (cell && cell->getAlignment(alignment)) { PyObject * s = PySet_New(NULL); -#if PY_MAJOR_VERSION >= 3 if (alignment & Cell::ALIGNMENT_LEFT) PySet_Add(s, PyUnicode_FromString("left")); if (alignment & Cell::ALIGNMENT_HCENTER) @@ -704,20 +663,6 @@ PyObject* SheetPy::getAlignment(PyObject *args) PySet_Add(s, PyUnicode_FromString("vcenter")); if (alignment & Cell::ALIGNMENT_BOTTOM) PySet_Add(s, PyUnicode_FromString("bottom")); -#else - if (alignment & Cell::ALIGNMENT_LEFT) - PySet_Add(s, PyString_FromString("left")); - if (alignment & Cell::ALIGNMENT_HCENTER) - PySet_Add(s, PyString_FromString("center")); - if (alignment & Cell::ALIGNMENT_RIGHT) - PySet_Add(s, PyString_FromString("right")); - if (alignment & Cell::ALIGNMENT_TOP) - PySet_Add(s, PyString_FromString("top")); - if (alignment & Cell::ALIGNMENT_VCENTER) - PySet_Add(s, PyString_FromString("vcenter")); - if (alignment & Cell::ALIGNMENT_BOTTOM) - PySet_Add(s, PyString_FromString("bottom")); -#endif return s; } @@ -731,13 +676,8 @@ static float decodeFloat(const PyObject * obj) { if (PyFloat_Check(obj)) return PyFloat_AsDouble((PyObject *)obj); -#if PY_MAJOR_VERSION >= 3 else if (PyLong_Check(obj)) return PyLong_AsLong((PyObject *)obj); -#else - else if (PyInt_Check(obj)) - return PyInt_AsLong((PyObject *)obj); -#endif throw Base::TypeError("Float or integer expected"); } From 83dcfae0f67a52aecc6873d0672d0b3691d8de4e Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 26 Apr 2021 11:04:26 +0200 Subject: [PATCH 159/178] Raytracing: remove some more deprecated Py2 code --- src/Mod/Raytracing/App/AppRaytracingPy.cpp | 4 ---- src/Mod/Raytracing/Gui/Command.cpp | 9 +-------- 2 files changed, 1 insertion(+), 12 deletions(-) diff --git a/src/Mod/Raytracing/App/AppRaytracingPy.cpp b/src/Mod/Raytracing/App/AppRaytracingPy.cpp index ff03e60882..5b124e91fc 100644 --- a/src/Mod/Raytracing/App/AppRaytracingPy.cpp +++ b/src/Mod/Raytracing/App/AppRaytracingPy.cpp @@ -203,10 +203,6 @@ private: vecs[i][l] = PyFloat_AsDouble(temp); else if (PyLong_Check(temp)) vecs[i][l] = (double) PyLong_AsLong(temp); -#if PY_MAJOR_VERSION < 3 - else if (PyInt_Check(temp)) - vecs[i][l] = (double) PyInt_AsLong(temp); -#endif else throw Py::ValueError("Wrong parameter format, four Tuple of three floats needed!"); } diff --git a/src/Mod/Raytracing/Gui/Command.cpp b/src/Mod/Raytracing/Gui/Command.cpp index 1f5a72107a..a9f6fbbb8c 100644 --- a/src/Mod/Raytracing/Gui/Command.cpp +++ b/src/Mod/Raytracing/Gui/Command.cpp @@ -261,11 +261,8 @@ void CmdRaytracingWriteView::activated(int) openCommand("Write view"); doCommand(Doc,"import Raytracing,RaytracingGui"); -#if PY_MAJOR_VERSION < 3 - doCommand(Doc,"OutFile = open(unicode(\"%s\",\"utf-8\"),\"w\")",cFullName.c_str()); -#else doCommand(Doc,"OutFile = open(\"%s\",\"w\")",cFullName.c_str()); -#endif + try { doCommand(Doc,"result = open(App.getResourceDir()+'Mod/Raytracing/Templates/ProjectStd.pov').read()"); doCommand(Doc,"content = ''"); @@ -558,11 +555,7 @@ void CmdRaytracingExportProject::activated(int) doCommand(Doc,"PageFile = open(App.activeDocument().%s.PageResult,'r')",Sel[0].FeatName); std::string fname = (const char*)fn.toUtf8(); fname = strToPython(fname); -#if PY_MAJOR_VERSION < 3 - doCommand(Doc,"OutFile = open(unicode('%s','utf-8'),'w')",fname.c_str()); -#else doCommand(Doc,"OutFile = open('%s','w')",fname.c_str()); -#endif doCommand(Doc,"OutFile.write(PageFile.read())"); doCommand(Doc,"del OutFile,PageFile"); From cca3981b3f744136cd495e5ab9f1b41586e01c70 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 26 Apr 2021 11:04:53 +0200 Subject: [PATCH 160/178] Points: remove some more deprecated Py2 code --- src/Mod/Points/App/PointsPyImp.cpp | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/src/Mod/Points/App/PointsPyImp.cpp b/src/Mod/Points/App/PointsPyImp.cpp index bdf6609eda..b65d0ecc15 100644 --- a/src/Mod/Points/App/PointsPyImp.cpp +++ b/src/Mod/Points/App/PointsPyImp.cpp @@ -67,15 +67,9 @@ int PointsPy::PyInit(PyObject* args, PyObject* /*kwd*/) if (!addPoints(args)) return -1; } -#if PY_MAJOR_VERSION >= 3 else if (PyUnicode_Check(pcObj)) { getPointKernelPtr()->load(PyUnicode_AsUTF8(pcObj)); } -#else - else if (PyString_Check(pcObj)) { - getPointKernelPtr()->load(PyString_AsString(pcObj)); - } -#endif else { PyErr_SetString(PyExc_TypeError, "optional argument must be list, tuple or string"); return -1; @@ -188,11 +182,7 @@ PyObject* PointsPy::fromSegment(PyObject * args) pts->reserve(list.size()); int numPoints = static_cast(points->size()); for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) { -#if PY_MAJOR_VERSION < 3 - int index = static_cast(Py::Int(*it)); -#else long index = static_cast(Py::Long(*it)); -#endif if (index >= 0 && index < numPoints) pts->push_back(points->getPoint(index)); } From adc5ffa803bacba951917cfcb9b77c58845733ff Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 26 Apr 2021 11:11:35 +0200 Subject: [PATCH 161/178] Path: remove some more deprecated Py2 code --- src/Mod/Path/App/AreaPyImp.cpp | 6 +----- src/Mod/Path/App/CommandPyImp.cpp | 29 ----------------------------- src/Mod/Path/App/ParamsHelper.h | 22 +++------------------- src/Mod/Path/App/PathPyImp.cpp | 4 ---- src/Mod/Path/App/ToolPyImp.cpp | 15 ++++----------- src/Mod/Path/App/TooltablePyImp.cpp | 15 ++++----------- 6 files changed, 12 insertions(+), 79 deletions(-) diff --git a/src/Mod/Path/App/AreaPyImp.cpp b/src/Mod/Path/App/AreaPyImp.cpp index db6e0b5e54..959f1f8a8b 100644 --- a/src/Mod/Path/App/AreaPyImp.cpp +++ b/src/Mod/Path/App/AreaPyImp.cpp @@ -96,13 +96,9 @@ static PyObject * areaGetParamsDesc(PyObject *, PyObject *args, PyObject *kwd) { if (!PyArg_ParseTupleAndKeywords(args, kwd, "|O",kwlist,&pcObj)) return 0; -#if PY_MAJOR_VERSION < 3 - if(PyObject_IsTrue(pcObj)) - return PyString_FromString(PARAM_PY_DOC(NAME,AREA_PARAMS_STATIC_CONF)); -#else if(PyObject_IsTrue(pcObj)) return PyUnicode_FromString(PARAM_PY_DOC(NAME,AREA_PARAMS_STATIC_CONF)); -#endif + PyObject *dict = PyDict_New(); PARAM_PY_DICT_SET_DOC(dict,NAME,AREA_PARAMS_STATIC_CONF) return dict; diff --git a/src/Mod/Path/App/CommandPyImp.cpp b/src/Mod/Path/App/CommandPyImp.cpp index 88bd30fce5..e4c5f0cc79 100644 --- a/src/Mod/Path/App/CommandPyImp.cpp +++ b/src/Mod/Path/App/CommandPyImp.cpp @@ -90,13 +90,8 @@ int CommandPy::PyInit(PyObject* args, PyObject* kwd) Py_ssize_t pos = 0; while (parameters && PyDict_Next(parameters, &pos, &key, &value)) { std::string ckey; -#if PY_MAJOR_VERSION >= 3 if (PyUnicode_Check(key)) { ckey = PyUnicode_AsUTF8(key); -#else - if (PyString_Check(key)) { - ckey = PyString_AsString(key); -#endif } else { PyErr_SetString(PyExc_TypeError, "The dictionary can only contain string keys"); @@ -105,13 +100,8 @@ int CommandPy::PyInit(PyObject* args, PyObject* kwd) boost::to_upper(ckey); double cvalue; -#if PY_MAJOR_VERSION >= 3 if (PyObject_TypeCheck(value,&(PyLong_Type))) { cvalue = (double)PyLong_AsLong(value); -#else - if (PyObject_TypeCheck(value,&(PyInt_Type))) { - cvalue = (double)PyInt_AsLong(value); -#endif } else if (PyObject_TypeCheck(value, &(PyFloat_Type))) { cvalue = PyFloat_AsDouble(value); @@ -179,13 +169,8 @@ void CommandPy::setParameters(Py::Dict arg) Py_ssize_t pos = 0; while (PyDict_Next(dict_copy, &pos, &key, &value)) { std::string ckey; -#if PY_MAJOR_VERSION >= 3 if (PyUnicode_Check(key)) { ckey = PyUnicode_AsUTF8(key); -#else - if (PyString_Check(key)) { - ckey = PyString_AsString(key); -#endif } else { throw Py::TypeError("The dictionary can only contain string keys"); @@ -193,13 +178,8 @@ void CommandPy::setParameters(Py::Dict arg) boost::to_upper(ckey); double cvalue; -#if PY_MAJOR_VERSION >= 3 if (PyObject_TypeCheck(value,&(PyLong_Type))) { cvalue = (double)PyLong_AsLong(value); -#else - if (PyObject_TypeCheck(value,&(PyInt_Type))) { - cvalue = (double)PyInt_AsLong(value); -#endif } else if (PyObject_TypeCheck(value, &(PyFloat_Type))) { cvalue = PyFloat_AsDouble(value); @@ -217,11 +197,7 @@ void CommandPy::setParameters(Py::Dict arg) PyObject* CommandPy::toGCode(PyObject *args) { if (PyArg_ParseTuple(args, "")) { -#if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(getCommandPtr()->toGCode().c_str()); -#else - return PyString_FromString(getCommandPtr()->toGCode().c_str()); -#endif } throw Py::TypeError("This method accepts no argument"); } @@ -301,13 +277,8 @@ int CommandPy::setCustomAttributes(const char* attr, PyObject* obj) if (isalpha(satt[0])) { boost::to_upper(satt); double cvalue; -#if PY_MAJOR_VERSION >= 3 if (PyObject_TypeCheck(obj,&(PyLong_Type))) { cvalue = (double)PyLong_AsLong(obj); -#else - if (PyObject_TypeCheck(obj,&(PyInt_Type))) { - cvalue = (double)PyInt_AsLong(obj); -#endif } else if (PyObject_TypeCheck(obj,&(PyFloat_Type))) { cvalue = PyFloat_AsDouble(obj); } else { diff --git a/src/Mod/Path/App/ParamsHelper.h b/src/Mod/Path/App/ParamsHelper.h index 88c5d9947c..7f82f7fc44 100644 --- a/src/Mod/Path/App/ParamsHelper.h +++ b/src/Mod/Path/App/ParamsHelper.h @@ -860,13 +860,8 @@ #define PARAM_REF(_src,_seq) \ BOOST_PP_SEQ_FOR_EACH_I(PARAM_REF_,_src,_seq) -#if PY_MAJOR_VERSION < 3 - #define PARAM_CAST_PYOBJ_short(_v) PyInt_FromLong(_v) - #define PARAM_CAST_PYOBJ_long(_v) PyInt_FromLong(_v) -#else - #define PARAM_CAST_PYOBJ_short(_v) PyLong_FromLong(_v) - #define PARAM_CAST_PYOBJ_long(_v) PyLong_FromLong(_v) -#endif +#define PARAM_CAST_PYOBJ_short(_v) PyLong_FromLong(_v) +#define PARAM_CAST_PYOBJ_long(_v) PyLong_FromLong(_v) #define PARAM_CAST_PYOBJ_double(_v) PyFloat_FromDouble(_v) #define PARAM_CAST_PYOBJ_bool(_v) ((_v)?Py_True:Py_False) @@ -877,13 +872,9 @@ /** Stringize field to a Python string * \ingroup ParamPy ParamStringizer */ -#if PY_MAJOR_VERSION < 3 -#define PARAM_PY_STR(_field,_param) \ - PyString_FromString(PARAM_FIELD_STR(_field,_param)) -#else #define PARAM_PY_STR(_field,_param) \ PyUnicode_FromString(PARAM_FIELD_STR(_field,_param)) -#endif + /** Helper for #PARAM_PY_DICT_SET_VALUE */ #define PARAM_PY_DICT_SET_VALUE_(_1,_args,_param) \ PyDict_SetItem(BOOST_PP_TUPLE_ELEM(0,_args), \ @@ -931,17 +922,10 @@ #define PARAM_PY_DICT_DOC_enum2 PARAM_PY_DICT_DOC_enum /** Helper for #PARAM_PY_DICT_SET_DOC */ -#if PY_MAJOR_VERSION < 3 -#define PARAM_PY_DICT_SET_DOC_(_1,_args,_param) \ - PyDict_SetItem(BOOST_PP_TUPLE_ELEM(0,_args), \ - PARAM_PY_STR(BOOST_PP_TUPLE_ELEM(1,_args),_param),\ - PyString_FromString(PARAM_TYPED(PARAM_PY_DICT_DOC_,_param)(_param))); -#else #define PARAM_PY_DICT_SET_DOC_(_1,_args,_param) \ PyDict_SetItem(BOOST_PP_TUPLE_ELEM(0,_args), \ PARAM_PY_STR(BOOST_PP_TUPLE_ELEM(1,_args),_param),\ PyUnicode_FromString(PARAM_TYPED(PARAM_PY_DICT_DOC_,_param)(_param))); -#endif /** Populate a Python dict with the doc field of the parameter sequence * diff --git a/src/Mod/Path/App/PathPyImp.cpp b/src/Mod/Path/App/PathPyImp.cpp index 263fccbb23..3a6e3e94bf 100644 --- a/src/Mod/Path/App/PathPyImp.cpp +++ b/src/Mod/Path/App/PathPyImp.cpp @@ -204,11 +204,7 @@ PyObject* PathPy::toGCode(PyObject * args) { if (PyArg_ParseTuple(args, "")) { std::string result = getToolpathPtr()->toGCode(); -#if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(result.c_str()); -#else - return PyString_FromString(result.c_str()); -#endif } throw Py::TypeError("This method accepts no argument"); } diff --git a/src/Mod/Path/App/ToolPyImp.cpp b/src/Mod/Path/App/ToolPyImp.cpp index 91d42245cb..cc10d6afd3 100644 --- a/src/Mod/Path/App/ToolPyImp.cpp +++ b/src/Mod/Path/App/ToolPyImp.cpp @@ -32,17 +32,10 @@ using namespace Path; -#if PY_MAJOR_VERSION >= 3 -# define PYSTRING_FROMSTRING(str) PyUnicode_FromString(str) -# define PYINT_TYPE PyLong_Type -# define PYINT_FROMLONG(l) PyLong_FromLong(l) -# define PYINT_ASLONG(o) PyLong_AsLong(o) -#else -# define PYSTRING_FROMSTRING(str) PyString_FromString(str) -# define PYINT_TYPE PyInt_Type -# define PYINT_FROMLONG(l) PyInt_FromLong(l) -# define PYINT_ASLONG(o) PyInt_AsLong(o) -#endif +#define PYSTRING_FROMSTRING(str) PyUnicode_FromString(str) +#define PYINT_TYPE PyLong_Type +#define PYINT_FROMLONG(l) PyLong_FromLong(l) +#define PYINT_ASLONG(o) PyLong_AsLong(o) // returns a string which represents the object e.g. when printed in python diff --git a/src/Mod/Path/App/TooltablePyImp.cpp b/src/Mod/Path/App/TooltablePyImp.cpp index b20fb539c3..92da20221e 100644 --- a/src/Mod/Path/App/TooltablePyImp.cpp +++ b/src/Mod/Path/App/TooltablePyImp.cpp @@ -33,17 +33,10 @@ using namespace Path; -#if PY_MAJOR_VERSION >= 3 -# define PYSTRING_FROMSTRING(str) PyUnicode_FromString(str) -# define PYINT_TYPE PyLong_Type -# define PYINT_FROMLONG(l) PyLong_FromLong(l) -# define PYINT_ASLONG(o) PyLong_AsLong(o) -#else -# define PYSTRING_FROMSTRING(str) PyString_FromString(str) -# define PYINT_TYPE PyInt_Type -# define PYINT_FROMLONG(l) PyInt_FromLong(l) -# define PYINT_ASLONG(o) PyInt_AsLong(o) -#endif +#define PYSTRING_FROMSTRING(str) PyUnicode_FromString(str) +#define PYINT_TYPE PyLong_Type +#define PYINT_FROMLONG(l) PyLong_FromLong(l) +#define PYINT_ASLONG(o) PyLong_AsLong(o) // returns a string which represents the object e.g. when printed in python std::string TooltablePy::representation(void) const From 1e589f05dffb09f0aa0af9b77f6822d10dbf4e1d Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 26 Apr 2021 11:12:34 +0200 Subject: [PATCH 162/178] Drawing: remove some more deprecated Py2 code --- src/Mod/Drawing/Gui/Command.cpp | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/Mod/Drawing/Gui/Command.cpp b/src/Mod/Drawing/Gui/Command.cpp index 5114064418..59589ca5e8 100644 --- a/src/Mod/Drawing/Gui/Command.cpp +++ b/src/Mod/Drawing/Gui/Command.cpp @@ -76,11 +76,7 @@ void CmdDrawingOpen::activated(int iMsg) filename = Base::Tools::escapeEncodeFilename(filename); // load the file with the module Command::doCommand(Command::Gui, "import Drawing, DrawingGui"); -#if PY_MAJOR_VERSION < 3 - Command::doCommand(Command::Gui, "DrawingGui.open(unicode(\"%s\",\"utf-8\"))", (const char*)filename.toUtf8()); -#else Command::doCommand(Command::Gui, "DrawingGui.open(\"%s\")", (const char*)filename.toUtf8()); -#endif } } @@ -601,11 +597,7 @@ void CmdDrawingSymbol::activated(int iMsg) filename = Base::Tools::escapeEncodeFilename(filename); openCommand("Create Symbol"); doCommand(Doc,"import Drawing"); -#if PY_MAJOR_VERSION < 3 - doCommand(Doc,"f = open(unicode(\"%s\",'utf-8'),'r')",(const char*)filename.toUtf8()); -#else doCommand(Doc,"f = open(\"%s\",'r')",(const char*)filename.toUtf8()); -#endif doCommand(Doc,"svg = f.read()"); doCommand(Doc,"f.close()"); doCommand(Doc,"App.activeDocument().addObject('Drawing::FeatureViewSymbol','%s')",FeatName.c_str()); @@ -662,11 +654,7 @@ void CmdDrawingExportPage::activated(int iMsg) doCommand(Doc,"PageFile = open(App.activeDocument().%s.PageResult,'r')",Sel[0].FeatName); std::string fname = (const char*)fn.toUtf8(); fname = Base::Tools::escapeEncodeFilename(fname); -#if PY_MAJOR_VERSION < 3 - doCommand(Doc,"OutFile = open(unicode(\"%s\",'utf-8'),'w')",fname.c_str()); -#else doCommand(Doc,"OutFile = open(\"%s\",'w')",fname.c_str()); -#endif doCommand(Doc,"OutFile.write(PageFile.read())"); doCommand(Doc,"del OutFile,PageFile"); From 76fb44c2d8c88e086fe6fbd7312786b1202521cd Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 26 Apr 2021 11:12:51 +0200 Subject: [PATCH 163/178] Image: remove some more deprecated Py2 code --- src/Mod/Image/Gui/Command.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Mod/Image/Gui/Command.cpp b/src/Mod/Image/Gui/Command.cpp index 41ea5fbb2d..d64cfcea79 100644 --- a/src/Mod/Image/Gui/Command.cpp +++ b/src/Mod/Image/Gui/Command.cpp @@ -80,11 +80,7 @@ void CmdImageOpen::activated(int iMsg) s = Base::Tools::escapeEncodeFilename(s); // load the file with the module Command::doCommand(Command::Gui, "import Image, ImageGui"); -#if PY_MAJOR_VERSION < 3 - Command::doCommand(Command::Gui, "ImageGui.open(unicode(\"%s\",\"utf-8\"))", (const char*)s.toUtf8()); -#else Command::doCommand(Command::Gui, "ImageGui.open(\"%s\",\"utf-8\")", (const char*)s.toUtf8()); -#endif } catch (const Base::PyException& e){ // Usually thrown if the file is invalid somehow From 58f72ccc80e6cf929c1411fe73dd4337296be012 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 26 Apr 2021 11:13:22 +0200 Subject: [PATCH 164/178] Part: remove some more deprecated Py2 code --- src/Mod/Part/App/AppPartPy.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Mod/Part/App/AppPartPy.cpp b/src/Mod/Part/App/AppPartPy.cpp index a0d8f59feb..08e3e9fd47 100644 --- a/src/Mod/Part/App/AppPartPy.cpp +++ b/src/Mod/Part/App/AppPartPy.cpp @@ -1913,14 +1913,9 @@ private: } } -#if PY_MAJOR_VERSION >= 3 //FIXME: Test this! if (PyBytes_Check(intext)) { PyObject *p = Base::PyAsUnicodeObject(PyBytes_AsString(intext)); -#else - if (PyString_Check(intext)) { - PyObject *p = Base::PyAsUnicodeObject(PyString_AsString(intext)); -#endif if (!p) { throw Py::TypeError("** makeWireString can't convert PyString."); } From 8371162427759fadc7bfa7ce854ba34cfe18aae9 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 26 Apr 2021 11:20:13 +0200 Subject: [PATCH 165/178] Base: remove obsolete swig source files --- src/Base/CMakeLists.txt | 22 - src/Base/swigpyrun_1.3.25.cpp | 47 - src/Base/swigpyrun_1.3.25.h | 1338 ---------------- src/Base/swigpyrun_1.3.33.cpp | 48 - src/Base/swigpyrun_1.3.33.h | 2502 ------------------------------ src/Base/swigpyrun_1.3.36.cpp | 48 - src/Base/swigpyrun_1.3.36.h | 2527 ------------------------------ src/Base/swigpyrun_1.3.38.cpp | 48 - src/Base/swigpyrun_1.3.38.h | 2667 -------------------------------- src/Base/swigpyrun_1.3.40.cpp | 48 - src/Base/swigpyrun_1.3.40.h | 2706 --------------------------------- 11 files changed, 12001 deletions(-) delete mode 100644 src/Base/swigpyrun_1.3.25.cpp delete mode 100644 src/Base/swigpyrun_1.3.25.h delete mode 100644 src/Base/swigpyrun_1.3.33.cpp delete mode 100644 src/Base/swigpyrun_1.3.33.h delete mode 100644 src/Base/swigpyrun_1.3.36.cpp delete mode 100644 src/Base/swigpyrun_1.3.36.h delete mode 100644 src/Base/swigpyrun_1.3.38.cpp delete mode 100644 src/Base/swigpyrun_1.3.38.h delete mode 100644 src/Base/swigpyrun_1.3.40.cpp delete mode 100644 src/Base/swigpyrun_1.3.40.h diff --git a/src/Base/CMakeLists.txt b/src/Base/CMakeLists.txt index e1206b2228..7412ea22e6 100644 --- a/src/Base/CMakeLists.txt +++ b/src/Base/CMakeLists.txt @@ -208,20 +208,9 @@ SET(FreeCADBase_UNITAPI_SRCS ) SOURCE_GROUP("Units" FILES ${FreeCADBase_UNITAPI_SRCS}) -if(PYTHON_VERSION_MAJOR LESS 3) -SET(SWIG_SRCS - swigpyrun_1.3.25.cpp - swigpyrun_1.3.33.cpp - swigpyrun_1.3.36.cpp - swigpyrun_1.3.38.cpp - swigpyrun_1.3.40.cpp - swigpyrun.cpp -) -else(PYTHON_VERSION_MAJOR LESS 3) SET(SWIG_SRCS swigpyrun.cpp ) -endif(PYTHON_VERSION_MAJOR LESS 3) SET(FreeCADBase_CPP_SRCS Axis.cpp @@ -281,20 +270,9 @@ SET(FreeCADBase_CPP_SRCS XMLTools.cpp ) -if(PYTHON_VERSION_MAJOR LESS 3) -SET(SWIG_HEADERS - swigpyrun_1.3.25.h - swigpyrun_1.3.33.h - swigpyrun_1.3.36.h - swigpyrun_1.3.38.h - swigpyrun_1.3.40.h - swigpyrun.inl -) -else(PYTHON_VERSION_MAJOR LESS 3) SET(SWIG_HEADERS swigpyrun.inl ) -endif(PYTHON_VERSION_MAJOR LESS 3) SET(FreeCADBase_HPP_SRCS Axis.h diff --git a/src/Base/swigpyrun_1.3.25.cpp b/src/Base/swigpyrun_1.3.25.cpp deleted file mode 100644 index 0e83735de0..0000000000 --- a/src/Base/swigpyrun_1.3.25.cpp +++ /dev/null @@ -1,47 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2008 Werner Mayer * - * * - * 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" -#include "PyExport.h" -#include "Exception.h" -#include -#if defined(__clang__) -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wdeprecated-register" -# pragma clang diagnostic ignored "-Wself-assign" -#elif defined (__GNUC__) -# pragma GCC diagnostic push -# if __GNUC__ >= 8 -# pragma GCC diagnostic ignored "-Wcast-function-type" -# endif -#endif -namespace Swig_1_3_25 { -#include "swigpyrun_1.3.25.h" -#include "swigpyrun.inl" -} -#if defined(__clang__) -# pragma clang diagnostic pop -#elif defined (__GNUC__) -# pragma GCC diagnostic pop -#endif - diff --git a/src/Base/swigpyrun_1.3.25.h b/src/Base/swigpyrun_1.3.25.h deleted file mode 100644 index 9ebadbc83a..0000000000 --- a/src/Base/swigpyrun_1.3.25.h +++ /dev/null @@ -1,1338 +0,0 @@ -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.25 - * - * This file is not intended to be easily readable and contains a number of - * coding conventions designed to improve portability and efficiency. Do not make - * changes to this file unless you know what you are doing--modify the SWIG - * interface file instead. - * ----------------------------------------------------------------------------- */ - -/*********************************************************************** - * - * This section contains generic SWIG labels for method/variable - * declarations/attributes, and other compiler dependent labels. - * - ************************************************************************/ - -/* template workaround for compilers that cannot correctly implement the C++ standard */ -#ifndef SWIGTEMPLATEDISAMBIGUATOR -# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) -# define SWIGTEMPLATEDISAMBIGUATOR template -# else -# define SWIGTEMPLATEDISAMBIGUATOR -# endif -#endif - -/* inline attribute */ -#ifndef SWIGINLINE -# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) -# define SWIGINLINE inline -# else -# define SWIGINLINE -# endif -#endif - -/* attribute recognised by some compilers to avoid 'unused' warnings */ -#ifndef SWIGUNUSED -# if defined(__GNUC__) || defined(__ICC) -# define SWIGUNUSED __attribute__ ((unused)) -# else -# define SWIGUNUSED -# endif -#endif - -/* internal SWIG method */ -#ifndef SWIGINTERN -# define SWIGINTERN static SWIGUNUSED -#endif - -/* internal inline SWIG method */ -#ifndef SWIGINTERNINLINE -# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE -#endif - -/* exporting methods for Windows DLLs */ -#ifndef SWIGEXPORT -# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# if defined(STATIC_LINKED) -# define SWIGEXPORT -# else -# define SWIGEXPORT __declspec(dllexport) -# endif -# else -# define SWIGEXPORT -# endif -#endif - -/* calling conventions for Windows */ -#ifndef SWIGSTDCALL -# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# define SWIGSTDCALL __stdcall -# else -# define SWIGSTDCALL -# endif -#endif - - -/*********************************************************************** - * swigrun.swg - * - * This file contains generic CAPI SWIG runtime support for pointer - * type checking. - * - ************************************************************************/ - -/* This should only be incremented when either the layout of swig_type_info changes, - or for whatever reason, the runtime changes incompatibly */ -#define SWIG_RUNTIME_VERSION "2" - -/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ -#ifdef SWIG_TYPE_TABLE -# define SWIG_QUOTE_STRING(x) #x -# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) -# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) -#else -# define SWIG_TYPE_TABLE_NAME -#endif - -/* - You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for - creating a static or dynamic library from the swig runtime code. - In 99.9% of the cases, swig just needs to declare them as 'static'. - - But only do this if is strictly necessary, ie, if you have problems - with your compiler or so. -*/ - -#ifndef SWIGRUNTIME -# define SWIGRUNTIME SWIGINTERN -#endif - -#ifndef SWIGRUNTIMEINLINE -# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE -#endif - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void *(*swig_converter_func)(void *); -typedef struct swig_type_info *(*swig_dycast_func)(void **); - -/* Structure to store inforomation on one type */ -typedef struct swig_type_info { - const char *name; /* mangled name of this type */ - const char *str; /* human readable name of this type */ - swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ - struct swig_cast_info *cast; /* linked list of types that can cast into this type */ - void *clientdata; /* language specific type data */ -} swig_type_info; - -/* Structure to store a type and conversion function used for casting */ -typedef struct swig_cast_info { - swig_type_info *type; /* pointer to type that is equivalent to this type */ - swig_converter_func converter; /* function to cast the void pointers */ - struct swig_cast_info *next; /* pointer to next cast in linked list */ - struct swig_cast_info *prev; /* pointer to the previous cast */ -} swig_cast_info; - -/* Structure used to store module information - * Each module generates one structure like this, and the runtime collects - * all of these structures and stores them in a circularly linked list.*/ -typedef struct swig_module_info { - swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ - size_t size; /* Number of types in this module */ - struct swig_module_info *next; /* Pointer to next element in circularly linked list */ - swig_type_info **type_initial; /* Array of initially generated type structures */ - swig_cast_info **cast_initial; /* Array of initially generated casting structures */ - void *clientdata; /* Language specific module data */ -} swig_module_info; - - -/* - Compare two type names skipping the space characters, therefore - "char*" == "char *" and "Class" == "Class", etc. - - Return 0 when the two name types are equivalent, as in - strncmp, but skipping ' '. -*/ -SWIGRUNTIME int -SWIG_TypeNameComp(const char *f1, const char *l1, - const char *f2, const char *l2) { - for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { - while ((*f1 == ' ') && (f1 != l1)) ++f1; - while ((*f2 == ' ') && (f2 != l2)) ++f2; - if (*f1 != *f2) return (int)(*f1 - *f2); - } - return (l1 - f1) - (l2 - f2); -} - -/* - Check type equivalence in a name list like ||... - Return 0 if not equal, 1 if equal -*/ -SWIGRUNTIME int -SWIG_TypeEquiv(const char *nb, const char *tb) { - int equiv = 0; - const char* te = tb + strlen(tb); - const char* ne = nb; - while (!equiv && *ne) { - for (nb = ne; *ne; ++ne) { - if (*ne == '|') break; - } - equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; - if (*ne) ++ne; - } - return equiv; -} - -/* - Check type equivalence in a name list like ||... - Return 0 if equal, -1 if nb < tb, 1 if nb > tb -*/ -SWIGRUNTIME int -SWIG_TypeCompare(const char *nb, const char *tb) { - int equiv = 0; - const char* te = tb + strlen(tb); - const char* ne = nb; - while (!equiv && *ne) { - for (nb = ne; *ne; ++ne) { - if (*ne == '|') break; - } - equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; - if (*ne) ++ne; - } - return equiv; -} - - -/* think of this as a c++ template<> or a scheme macro */ -#define SWIG_TypeCheck_Template(comparison, ty) \ - if (ty) { \ - swig_cast_info *iter = ty->cast; \ - while (iter) { \ - if (comparison) { \ - if (iter == ty->cast) return iter; \ - /* Move iter to the top of the linked list */ \ - iter->prev->next = iter->next; \ - if (iter->next) \ - iter->next->prev = iter->prev; \ - iter->next = ty->cast; \ - iter->prev = 0; \ - if (ty->cast) ty->cast->prev = iter; \ - ty->cast = iter; \ - return iter; \ - } \ - iter = iter->next; \ - } \ - } \ - return 0 - -/* - Check the typename -*/ -SWIGRUNTIME swig_cast_info * -SWIG_TypeCheck(const char *c, swig_type_info *ty) { - SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty); -} - -/* Same as previous function, except strcmp is replaced with a pointer comparison */ -SWIGRUNTIME swig_cast_info * -SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) { - SWIG_TypeCheck_Template(iter->type == from, into); -} - -/* - Cast a pointer up an inheritance hierarchy -*/ -SWIGRUNTIMEINLINE void * -SWIG_TypeCast(swig_cast_info *ty, void *ptr) { - return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr); -} - -/* - Dynamic pointer casting. Down an inheritance hierarchy -*/ -SWIGRUNTIME swig_type_info * -SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { - swig_type_info *lastty = ty; - if (!ty || !ty->dcast) return ty; - while (ty && (ty->dcast)) { - ty = (*ty->dcast)(ptr); - if (ty) lastty = ty; - } - return lastty; -} - -/* - Return the name associated with this type -*/ -SWIGRUNTIMEINLINE const char * -SWIG_TypeName(const swig_type_info *ty) { - return ty->name; -} - -/* - Return the pretty name associated with this type, - that is an unmangled type name in a form presentable to the user. -*/ -SWIGRUNTIME const char * -SWIG_TypePrettyName(const swig_type_info *type) { - /* The "str" field contains the equivalent pretty names of the - type, separated by vertical-bar characters. We choose - to print the last name, as it is often (?) the most - specific. */ - if (type->str != NULL) { - const char *last_name = type->str; - const char *s; - for (s = type->str; *s; s++) - if (*s == '|') last_name = s+1; - return last_name; - } - else - return type->name; -} - -/* - Set the clientdata field for a type -*/ -SWIGRUNTIME void -SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { - if (!ti->clientdata) { - swig_cast_info *cast = ti->cast; - /* if (ti->clientdata == clientdata) return; */ - ti->clientdata = clientdata; - - while (cast) { - if (!cast->converter) - SWIG_TypeClientData(cast->type, clientdata); - cast = cast->next; - } - } -} - -/* - Search for a swig_type_info structure only by mangled name - Search is a O(log #types) - - We start searching at module start, and finish searching when start == end. - Note: if start == end at the beginning of the function, we go all the way around - the circular list. -*/ -SWIGRUNTIME swig_type_info * -SWIG_MangledTypeQueryModule(swig_module_info *start, - swig_module_info *end, - const char *name) { - swig_module_info *iter = start; - do { - if (iter->size) { - register size_t l = 0; - register size_t r = iter->size - 1; - do { - /* since l+r >= 0, we can (>> 1) instead (/ 2) */ - register size_t i = (l + r) >> 1; - const char *iname = iter->types[i]->name; - if (iname) { - register int compare = strcmp(name, iname); - if (compare == 0) { - return iter->types[i]; - } else if (compare < 0) { - if (i) { - r = i - 1; - } else { - break; - } - } else if (compare > 0) { - l = i + 1; - } - } else { - break; /* should never happen */ - } - } while (l <= r); - } - iter = iter->next; - } while (iter != end); - return 0; -} - -/* - Search for a swig_type_info structure for either a mangled name or a human readable name. - It first searches the mangled names of the types, which is a O(log #types) - If a type is not found it then searches the human readable names, which is O(#types). - - We start searching at module start, and finish searching when start == end. - Note: if start == end at the beginning of the function, we go all the way around - the circular list. -*/ -SWIGRUNTIME swig_type_info * -SWIG_TypeQueryModule(swig_module_info *start, - swig_module_info *end, - const char *name) { - /* STEP 1: Search the name field using binary search */ - swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); - if (ret) { - return ret; - } else { - /* STEP 2: If the type hasn't been found, do a complete search - of the str field (the human readable name) */ - swig_module_info *iter = start; - do { - register size_t i = 0; - for (; i < iter->size; ++i) { - if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) - return iter->types[i]; - } - iter = iter->next; - } while (iter != end); - } - - /* neither found a match */ - return 0; -} - - -/* - Pack binary data into a string -*/ -SWIGRUNTIME char * -SWIG_PackData(char *c, void *ptr, size_t sz) { - static const char hex[17] = "0123456789abcdef"; - register const unsigned char *u = (unsigned char *) ptr; - register const unsigned char *eu = u + sz; - for (; u != eu; ++u) { - register unsigned char uu = *u; - *(c++) = hex[(uu & 0xf0) >> 4]; - *(c++) = hex[uu & 0xf]; - } - return c; -} - -/* - Unpack binary data from a string -*/ -SWIGRUNTIME const char * -SWIG_UnpackData(const char *c, void *ptr, size_t sz) { - register unsigned char *u = (unsigned char *) ptr; - register const unsigned char *eu = u + sz; - for (; u != eu; ++u) { - register char d = *(c++); - register unsigned char uu = 0; - if ((d >= '0') && (d <= '9')) - uu = ((d - '0') << 4); - else if ((d >= 'a') && (d <= 'f')) - uu = ((d - ('a'-10)) << 4); - else - return (char *) 0; - d = *(c++); - if ((d >= '0') && (d <= '9')) - uu |= (d - '0'); - else if ((d >= 'a') && (d <= 'f')) - uu |= (d - ('a'-10)); - else - return (char *) 0; - *u = uu; - } - return c; -} - -/* - Pack 'void *' into a string buffer. -*/ -SWIGRUNTIME char * -SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { - char *r = buff; - if ((2*sizeof(void *) + 2) > bsz) return 0; - *(r++) = '_'; - r = SWIG_PackData(r,&ptr,sizeof(void *)); - if (strlen(name) + 1 > (bsz - (r - buff))) return 0; - strcpy(r,name); - return buff; -} - -SWIGRUNTIME const char * -SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { - if (*c != '_') { - if (strcmp(c,"NULL") == 0) { - *ptr = (void *) 0; - return name; - } else { - return 0; - } - } - return SWIG_UnpackData(++c,ptr,sizeof(void *)); -} - -SWIGRUNTIME char * -SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { - char *r = buff; - size_t lname = (name ? strlen(name) : 0); - if ((2*sz + 2 + lname) > bsz) return 0; - *(r++) = '_'; - r = SWIG_PackData(r,ptr,sz); - if (lname) { - strncpy(r,name,lname+1); - } else { - *r = 0; - } - return buff; -} - -SWIGRUNTIME const char * -SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { - if (*c != '_') { - if (strcmp(c,"NULL") == 0) { - memset(ptr,0,sz); - return name; - } else { - return 0; - } - } - return SWIG_UnpackData(++c,ptr,sz); -} - -#ifdef __cplusplus -} -#endif - -/*********************************************************************** - * pyrun.swg - * - * This file contains the runtime support for Python modules - * and includes code for managing global variables and pointer - * type checking. - * - * Author : David Beazley (beazley@cs.uchicago.edu) - ************************************************************************/ - -/* Common SWIG API */ -#define SWIG_ConvertPtr(obj, pp, type, flags) SWIG_Python_ConvertPtr(obj, pp, type, flags) -#define SWIG_NewPointerObj(p, type, flags) SWIG_Python_NewPointerObj(p, type, flags) -#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags) - - -/* Python-specific SWIG API */ -#define SWIG_ConvertPacked(obj, ptr, sz, ty, flags) SWIG_Python_ConvertPacked(obj, ptr, sz, ty, flags) -#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) - -/* Runtime API */ -#define SWIG_GetModule(clientdata) SWIG_Python_GetModule() -#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) - -/* ----------------------------------------------------------------------------- - * Pointer declarations - * ----------------------------------------------------------------------------- */ -/* - Use SWIG_NO_COBJECT_TYPES to force the use of strings to represent - C/C++ pointers in the python side. Very useful for debugging, but - not always safe. -*/ -#if !defined(SWIG_NO_COBJECT_TYPES) && !defined(SWIG_COBJECT_TYPES) -# define SWIG_COBJECT_TYPES -#endif - -/* Flags for pointer conversion */ -#define SWIG_POINTER_EXCEPTION 0x1 -#define SWIG_POINTER_DISOWN 0x2 - - -/* Add PyOS_snprintf for old Pythons */ -#if PY_VERSION_HEX < 0x02020000 -#define PyOS_snprintf snprintf -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -/* ----------------------------------------------------------------------------- - * Create a new pointer string - * ----------------------------------------------------------------------------- */ -#ifndef SWIG_BUFFER_SIZE -#define SWIG_BUFFER_SIZE 1024 -#endif - -#if defined(SWIG_COBJECT_TYPES) -#if !defined(SWIG_COBJECT_PYTHON) -/* ----------------------------------------------------------------------------- - * Implements a simple Swig Object type, and use it instead of PyCObject - * ----------------------------------------------------------------------------- */ - -typedef struct { - PyObject_HEAD - void *ptr; - const char *desc; -} PySwigObject; - -/* Declarations for objects of type PySwigObject */ - -SWIGRUNTIME int -PySwigObject_print(PySwigObject *v, FILE *fp, int flags) -{ - char result[SWIG_BUFFER_SIZE]; - flags = flags; - if (SWIG_PackVoidPtr(result, v->ptr, v->desc, sizeof(result))) { - fputs("", fp); - return 0; - } else { - return 1; - } -} - -SWIGRUNTIME PyObject * -PySwigObject_repr(PySwigObject *v) -{ - char result[SWIG_BUFFER_SIZE]; - return SWIG_PackVoidPtr(result, v->ptr, v->desc, sizeof(result)) ? - PyString_FromFormat("", result) : 0; -} - -SWIGRUNTIME PyObject * -PySwigObject_str(PySwigObject *v) -{ - char result[SWIG_BUFFER_SIZE]; - return SWIG_PackVoidPtr(result, v->ptr, v->desc, sizeof(result)) ? - PyString_FromString(result) : 0; -} - -SWIGRUNTIME PyObject * -PySwigObject_long(PySwigObject *v) -{ - return PyLong_FromVoidPtr(v->ptr); -} - -SWIGRUNTIME PyObject * -PySwigObject_format(const char* fmt, PySwigObject *v) -{ - PyObject *res = NULL; - PyObject *args = PyTuple_New(1); - if (args && (PyTuple_SetItem(args, 0, PySwigObject_long(v)) == 0)) { - PyObject *ofmt = PyString_FromString(fmt); - if (ofmt) { - res = PyString_Format(ofmt,args); - Py_DECREF(ofmt); - } - Py_DECREF(args); - } - return res; -} - -SWIGRUNTIME PyObject * -PySwigObject_oct(PySwigObject *v) -{ - return PySwigObject_format("%o",v); -} - -SWIGRUNTIME PyObject * -PySwigObject_hex(PySwigObject *v) -{ - return PySwigObject_format("%x",v); -} - -SWIGRUNTIME int -PySwigObject_compare(PySwigObject *v, PySwigObject *w) -{ - int c = strcmp(v->desc, w->desc); - if (c) { - return (c > 0) ? 1 : -1; - } else { - void *i = v->ptr; - void *j = w->ptr; - return (i < j) ? -1 : ((i > j) ? 1 : 0); - } -} - -SWIGRUNTIME void -PySwigObject_dealloc(PySwigObject *self) -{ - PyObject_DEL(self); -} - -SWIGRUNTIME PyTypeObject* -PySwigObject_type(void) { - static char pyswigobject_type__doc__[] = - "Swig object carries a C/C++ instance pointer"; - - static PyNumberMethods PySwigObject_as_number = { - (binaryfunc)0, /*nb_add*/ - (binaryfunc)0, /*nb_subtract*/ - (binaryfunc)0, /*nb_multiply*/ - (binaryfunc)0, /*nb_divide*/ - (binaryfunc)0, /*nb_remainder*/ - (binaryfunc)0, /*nb_divmod*/ - (ternaryfunc)0,/*nb_power*/ - (unaryfunc)0, /*nb_negative*/ - (unaryfunc)0, /*nb_positive*/ - (unaryfunc)0, /*nb_absolute*/ - (inquiry)0, /*nb_nonzero*/ - 0, /*nb_invert*/ - 0, /*nb_lshift*/ - 0, /*nb_rshift*/ - 0, /*nb_and*/ - 0, /*nb_xor*/ - 0, /*nb_or*/ - (coercion)0, /*nb_coerce*/ - (unaryfunc)PySwigObject_long, /*nb_int*/ - (unaryfunc)PySwigObject_long, /*nb_long*/ - (unaryfunc)0, /*nb_float*/ - (unaryfunc)PySwigObject_oct, /*nb_oct*/ - (unaryfunc)PySwigObject_hex, /*nb_hex*/ -#if PY_VERSION_HEX >= 0x02000000 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ -#endif - }; - - static PyTypeObject pyswigobject_type -#if !defined(__cplusplus) - ; - static int type_init = 0; - if (!type_init) { - PyTypeObject tmp -#endif - = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - (char *)"PySwigObject", /*tp_name*/ - sizeof(PySwigObject), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)PySwigObject_dealloc, /*tp_dealloc*/ -#if PY_VERSION_HEX < 0x03080000 - (printfunc)PySwigObject_print, /*tp_print*/ -#else - 0, /*tp_vectorcall_offset*/ -#endif - (getattrfunc)0, /*tp_getattr*/ - (setattrfunc)0, /*tp_setattr*/ - (cmpfunc)PySwigObject_compare, /*tp_compare*/ - (reprfunc)PySwigObject_repr, /*tp_repr*/ - &PySwigObject_as_number, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - (hashfunc)0, /*tp_hash*/ - (ternaryfunc)0, /*tp_call*/ - (reprfunc)PySwigObject_str, /*tp_str*/ - /* Space for future expansion */ - 0,0,0,0, - pyswigobject_type__doc__, /* Documentation string */ -#if PY_VERSION_HEX >= 0x02000000 - 0, /* tp_traverse */ - 0, /* tp_clear */ -#endif -#if PY_VERSION_HEX >= 0x02010000 - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ -#endif -#if PY_VERSION_HEX >= 0x02020000 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ -#endif -#if PY_VERSION_HEX >= 0x02030000 - 0, /* tp_del */ -#endif -#if PY_VERSION_HEX >= 0x02060000 - 0, /* tp_version_tag */ -#endif -#ifdef COUNT_ALLOCS - 0,0,0,0 /* tp_alloc -> tp_next */ -#endif - }; -#if !defined(__cplusplus) - pyswigobject_type = tmp; - type_init = 1; - } -#endif - return &pyswigobject_type; -} - -SWIGRUNTIME PyObject * -PySwigObject_FromVoidPtrAndDesc(void *ptr, const char *desc) -{ - PySwigObject *self = PyObject_NEW(PySwigObject, PySwigObject_type()); - if (self) { - self->ptr = ptr; - self->desc = desc; - } - return (PyObject *)self; -} - -SWIGRUNTIMEINLINE void * -PySwigObject_AsVoidPtr(PyObject *self) -{ - return ((PySwigObject *)self)->ptr; -} - -SWIGRUNTIMEINLINE const char * -PySwigObject_GetDesc(PyObject *self) -{ - return ((PySwigObject *)self)->desc; -} - -SWIGRUNTIMEINLINE int -PySwigObject_Check(PyObject *op) { - return ((op)->ob_type == PySwigObject_type()) - || (strcmp((op)->ob_type->tp_name,"PySwigObject") == 0); -} - -/* ----------------------------------------------------------------------------- - * Implements a simple Swig Packed type, and use it instead of string - * ----------------------------------------------------------------------------- */ - -typedef struct { - PyObject_HEAD - void *pack; - const char *desc; - size_t size; -} PySwigPacked; - -SWIGRUNTIME int -PySwigPacked_print(PySwigPacked *v, FILE *fp, int flags) -{ - char result[SWIG_BUFFER_SIZE]; - flags = flags; - fputs("pack, v->size, 0, sizeof(result))) { - fputs("at ", fp); - fputs(result, fp); - } - fputs(v->desc,fp); - fputs(">", fp); - return 0; -} - -SWIGRUNTIME PyObject * -PySwigPacked_repr(PySwigPacked *v) -{ - char result[SWIG_BUFFER_SIZE]; - if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { - return PyString_FromFormat("", result, v->desc); - } else { - return PyString_FromFormat("", v->desc); - } -} - -SWIGRUNTIME PyObject * -PySwigPacked_str(PySwigPacked *v) -{ - char result[SWIG_BUFFER_SIZE]; - if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ - return PyString_FromFormat("%s%s", result, v->desc); - } else { - return PyString_FromFormat("%s", v->desc); - } -} - -SWIGRUNTIME int -PySwigPacked_compare(PySwigPacked *v, PySwigPacked *w) -{ - int c = strcmp(v->desc, w->desc); - if (c) { - return (c > 0) ? 1 : -1; - } else { - size_t i = v->size; - size_t j = w->size; - int s = (i < j) ? -1 : ((i > j) ? 1 : 0); - return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size); - } -} - -SWIGRUNTIME void -PySwigPacked_dealloc(PySwigPacked *self) -{ - free(self->pack); - PyObject_DEL(self); -} - -SWIGRUNTIME PyTypeObject* -PySwigPacked_type(void) { - static char pyswigpacked_type__doc__[] = - "Swig object carries a C/C++ instance pointer"; - static PyTypeObject pyswigpacked_type -#if !defined(__cplusplus) - ; - static int type_init = 0; - if (!type_init) { - PyTypeObject tmp -#endif - = { - PyObject_HEAD_INIT(&PyType_Type) - 0, /*ob_size*/ - (char *)"PySwigPacked", /*tp_name*/ - sizeof(PySwigPacked), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - /* methods */ - (destructor)PySwigPacked_dealloc, /*tp_dealloc*/ -#if PY_VERSION_HEX < 0x03080000 - (printfunc)PySwigPacked_print, /*tp_print*/ -#else - 0, /*tp_vectorcall_offset*/ -#endif - (getattrfunc)0, /*tp_getattr*/ - (setattrfunc)0, /*tp_setattr*/ - (cmpfunc)PySwigPacked_compare, /*tp_compare*/ - (reprfunc)PySwigPacked_repr, /*tp_repr*/ - 0, /*tp_as_number*/ - 0, /*tp_as_sequence*/ - 0, /*tp_as_mapping*/ - (hashfunc)0, /*tp_hash*/ - (ternaryfunc)0, /*tp_call*/ - (reprfunc)PySwigPacked_str, /*tp_str*/ - /* Space for future expansion */ - 0,0,0,0, - pyswigpacked_type__doc__, /* Documentation string */ -#if PY_VERSION_HEX >= 0x02000000 - 0, /* tp_traverse */ - 0, /* tp_clear */ -#endif -#if PY_VERSION_HEX >= 0x02010000 - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ -#endif -#if PY_VERSION_HEX >= 0x02020000 - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, /* tp_iter -> tp_weaklist */ -#endif -#if PY_VERSION_HEX >= 0x02030000 - 0, /* tp_del */ -#endif -#if PY_VERSION_HEX >= 0x02060000 - 0, /* tp_version_tag */ -#endif -#ifdef COUNT_ALLOCS - 0,0,0,0 /* tp_alloc -> tp_next */ -#endif - }; -#if !defined(__cplusplus) - pyswigpacked_type = tmp; - type_init = 1; - } -#endif - return &pyswigpacked_type; -} - -SWIGRUNTIME PyObject * -PySwigPacked_FromDataAndDesc(void *ptr, size_t size, const char *desc) -{ - PySwigPacked *self = PyObject_NEW(PySwigPacked, PySwigPacked_type()); - if (self == NULL) { - return NULL; - } else { - void *pack = malloc(size); - if (pack) { - memcpy(pack, ptr, size); - self->pack = pack; - self->desc = desc; - self->size = size; - return (PyObject *) self; - } - return NULL; - } -} - -SWIGRUNTIMEINLINE const char * -PySwigPacked_UnpackData(PyObject *obj, void *ptr, size_t size) -{ - PySwigPacked *self = (PySwigPacked *)obj; - if (self->size != size) return 0; - memcpy(ptr, self->pack, size); - return self->desc; -} - -SWIGRUNTIMEINLINE const char * -PySwigPacked_GetDesc(PyObject *self) -{ - return ((PySwigPacked *)self)->desc; -} - -SWIGRUNTIMEINLINE int -PySwigPacked_Check(PyObject *op) { - return ((op)->ob_type == PySwigPacked_type()) - || (strcmp((op)->ob_type->tp_name,"PySwigPacked") == 0); -} - -#else -/* ----------------------------------------------------------------------------- - * Use the old Python PyCObject instead of PySwigObject - * ----------------------------------------------------------------------------- */ - -#define PySwigObject_GetDesc(obj) PyCObject_GetDesc(obj) -#define PySwigObject_Check(obj) PyCObject_Check(obj) -#define PySwigObject_AsVoidPtr(obj) PyCObject_AsVoidPtr(obj) -#define PySwigObject_FromVoidPtrAndDesc(p, d) PyCObject_FromVoidPtrAndDesc(p, d, NULL) - -#endif - -#endif - -/* ----------------------------------------------------------------------------- - * errors manipulation - * ----------------------------------------------------------------------------- */ - -SWIGRUNTIME void -SWIG_Python_TypeError(const char *type, PyObject *obj) -{ - if (type) { -#if defined(SWIG_COBJECT_TYPES) - if (obj && PySwigObject_Check(obj)) { - const char *otype = (const char *) PySwigObject_GetDesc(obj); - if (otype) { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'PySwigObject(%s)' is received", - type, otype); - return; - } - } else -#endif - { - const char *otype = (obj ? obj->ob_type->tp_name : 0); - if (otype) { - PyObject *str = PyObject_Str(obj); - const char *cstr = str ? PyString_AsString(str) : 0; - if (cstr) { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", - type, otype, cstr); - } else { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", - type, otype); - } - Py_XDECREF(str); - return; - } - } - PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); - } else { - PyErr_Format(PyExc_TypeError, "unexpected type is received"); - } -} - -SWIGRUNTIMEINLINE void -SWIG_Python_NullRef(const char *type) -{ - if (type) { - PyErr_Format(PyExc_TypeError, "null reference of type '%s' was received",type); - } else { - PyErr_Format(PyExc_TypeError, "null reference was received"); - } -} - -SWIGRUNTIME int -SWIG_Python_AddErrMesg(const char* mesg, int infront) -{ - if (PyErr_Occurred()) { - PyObject *type = 0; - PyObject *value = 0; - PyObject *traceback = 0; - PyErr_Fetch(&type, &value, &traceback); - if (value) { - PyObject *old_str = PyObject_Str(value); - Py_XINCREF(type); - PyErr_Clear(); - if (infront) { - PyErr_Format(type, "%s %s", mesg, PyString_AsString(old_str)); - } else { - PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg); - } - Py_DECREF(old_str); - } - return 1; - } else { - return 0; - } -} - -SWIGRUNTIME int -SWIG_Python_ArgFail(int argnum) -{ - if (PyErr_Occurred()) { - /* add information about failing argument */ - char mesg[256]; - PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum); - return SWIG_Python_AddErrMesg(mesg, 1); - } else { - return 0; - } -} - - -/* ----------------------------------------------------------------------------- - * pointers/data manipulation - * ----------------------------------------------------------------------------- */ - -/* Convert a pointer value */ -SWIGRUNTIME int -SWIG_Python_ConvertPtr(PyObject *obj, void **ptr, swig_type_info *ty, int flags) { - swig_cast_info *tc; - const char *c = 0; - static PyObject *SWIG_this = 0; - int newref = 0; - PyObject *pyobj = 0; - void *vptr; - - if (!obj) return 0; - if (obj == Py_None) { - *ptr = 0; - return 0; - } - -#ifdef SWIG_COBJECT_TYPES - if (!(PySwigObject_Check(obj))) { - if (!SWIG_this) - SWIG_this = PyString_FromString("this"); - pyobj = obj; - obj = PyObject_GetAttr(obj,SWIG_this); - newref = 1; - if (!obj) goto type_error; - if (!PySwigObject_Check(obj)) { - Py_DECREF(obj); - goto type_error; - } - } - vptr = PySwigObject_AsVoidPtr(obj); - c = (const char *) PySwigObject_GetDesc(obj); - if (newref) { Py_DECREF(obj); } - goto type_check; -#else - if (!(PyString_Check(obj))) { - if (!SWIG_this) - SWIG_this = PyString_FromString("this"); - pyobj = obj; - obj = PyObject_GetAttr(obj,SWIG_this); - newref = 1; - if (!obj) goto type_error; - if (!PyString_Check(obj)) { - Py_DECREF(obj); - goto type_error; - } - } - c = PyString_AS_STRING(obj); - /* Pointer values must start with leading underscore */ - c = SWIG_UnpackVoidPtr(c, &vptr, ty->name); - if (newref) { Py_DECREF(obj); } - if (!c) goto type_error; -#endif - -type_check: - if (ty) { - tc = SWIG_TypeCheck(c,ty); - if (!tc) goto type_error; - *ptr = SWIG_TypeCast(tc,vptr); - } else { - *ptr = vptr; - } - if ((pyobj) && (flags & SWIG_POINTER_DISOWN)) { - PyObject_SetAttrString(pyobj,(char*)"thisown",Py_False); - } - return 0; - -type_error: - PyErr_Clear(); - if (pyobj && !obj) { - obj = pyobj; - if (PyCFunction_Check(obj)) { - /* here we get the method pointer for callbacks */ - const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); - c = doc ? strstr(doc, "swig_ptr: ") : 0; - if (c) { - c = ty ? SWIG_UnpackVoidPtr(c + 10, &vptr, ty->name) : 0; - if (!c) goto type_error; - goto type_check; - } - } - } - if (flags & SWIG_POINTER_EXCEPTION) { - if (ty) { - SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); - } else { - SWIG_Python_TypeError("C/C++ pointer", obj); - } - } - return -1; -} - -/* Convert a pointer value, signal an exception on a type mismatch */ -SWIGRUNTIME void * -SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) { - void *result; - if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { - PyErr_Clear(); - if (flags & SWIG_POINTER_EXCEPTION) { - SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); - SWIG_Python_ArgFail(argnum); - } - } - return result; -} - -/* Convert a packed value value */ -SWIGRUNTIME int -SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty, int flags) { - swig_cast_info *tc; - const char *c = 0; - -#if defined(SWIG_COBJECT_TYPES) && !defined(SWIG_COBJECT_PYTHON) - c = PySwigPacked_UnpackData(obj, ptr, sz); -#else - if ((!obj) || (!PyString_Check(obj))) goto type_error; - c = PyString_AS_STRING(obj); - /* Pointer values must start with leading underscore */ - c = SWIG_UnpackDataName(c, ptr, sz, ty->name); -#endif - if (!c) goto type_error; - if (ty) { - tc = SWIG_TypeCheck(c,ty); - if (!tc) goto type_error; - } - return 0; - -type_error: - PyErr_Clear(); - if (flags & SWIG_POINTER_EXCEPTION) { - if (ty) { - SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); - } else { - SWIG_Python_TypeError("C/C++ packed data", obj); - } - } - return -1; -} - -/* Create a new array object */ -SWIGRUNTIME PyObject * -SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int own) { - PyObject *robj = 0; - if (!type) { - if (!PyErr_Occurred()) { - PyErr_Format(PyExc_TypeError, "Swig: null type passed to NewPointerObj"); - } - return robj; - } - if (!ptr) { - Py_INCREF(Py_None); - return Py_None; - } -#ifdef SWIG_COBJECT_TYPES - robj = PySwigObject_FromVoidPtrAndDesc((void *) ptr, (char *)type->name); -#else - { - char result[SWIG_BUFFER_SIZE]; - robj = SWIG_PackVoidPtr(result, ptr, type->name, sizeof(result)) ? - PyString_FromString(result) : 0; - } -#endif - if (!robj || (robj == Py_None)) return robj; - if (type->clientdata) { - PyObject *inst; - PyObject *args = Py_BuildValue((char*)"(O)", robj); - Py_DECREF(robj); - inst = PyObject_CallObject((PyObject *) type->clientdata, args); - Py_DECREF(args); - if (inst) { - if (own) { - PyObject_SetAttrString(inst,(char*)"thisown",Py_True); - } - robj = inst; - } - } - return robj; -} - -SWIGRUNTIME PyObject * -SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { - PyObject *robj = 0; - if (!ptr) { - Py_INCREF(Py_None); - return Py_None; - } -#if defined(SWIG_COBJECT_TYPES) && !defined(SWIG_COBJECT_PYTHON) - robj = PySwigPacked_FromDataAndDesc((void *) ptr, sz, (char *)type->name); -#else - { - char result[SWIG_BUFFER_SIZE]; - robj = SWIG_PackDataName(result, ptr, sz, type->name, sizeof(result)) ? - PyString_FromString(result) : 0; - } -#endif - return robj; -} - -/* -----------------------------------------------------------------------------* - * Get type list - * -----------------------------------------------------------------------------*/ - -#ifdef SWIG_LINK_RUNTIME -void *SWIG_ReturnGlobalTypeList(void *); -#endif - -SWIGRUNTIME swig_module_info * -SWIG_Python_GetModule(void) { - static void *type_pointer = (void *)0; - /* first check if module already created */ - if (!type_pointer) { -#ifdef SWIG_LINK_RUNTIME - type_pointer = SWIG_ReturnGlobalTypeList((void *)0); -#else - type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, - (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); - if (PyErr_Occurred()) { - PyErr_Clear(); - type_pointer = (void *)0; - } - } -#endif - return (swig_module_info *) type_pointer; -} - -SWIGRUNTIME void -SWIG_Python_SetModule(swig_module_info *swig_module) { - static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */ - - PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, - swig_empty_runtime_method_table); - PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, NULL); - if (pointer && module) { - PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); - } -} - -#ifdef __cplusplus -} -#endif - -/* -----------------------------------------------------------------------------* - Standard SWIG API for use inside user code. - - Don't include this file directly, run the command - swig -python -external-runtime - Also, read the Modules chapter of the SWIG Manual. - - * -----------------------------------------------------------------------------*/ - -#ifdef SWIG_MODULE_CLIENTDATA_TYPE - -SWIGRUNTIMEINLINE swig_type_info * -SWIG_TypeQuery(SWIG_MODULE_CLIENTDATA_TYPE clientdata, const char *name) { - swig_module_info *module = SWIG_GetModule(clientdata); - return SWIG_TypeQueryModule(module, module, name); -} - -SWIGRUNTIMEINLINE swig_type_info * -SWIG_MangledTypeQuery(SWIG_MODULE_CLIENTDATA_TYPE clientdata, const char *name) { - swig_module_info *module = SWIG_GetModule(clientdata); - return SWIG_MangledTypeQueryModule(module, module, name); -} - -#else - -SWIGRUNTIMEINLINE swig_type_info * -SWIG_TypeQuery(const char *name) { - swig_module_info *module = SWIG_GetModule(NULL); - return SWIG_TypeQueryModule(module, module, name); -} - -SWIGRUNTIMEINLINE swig_type_info * -SWIG_MangledTypeQuery(const char *name) { - swig_module_info *module = SWIG_GetModule(NULL); - return SWIG_MangledTypeQueryModule(module, module, name); -} - -#endif - diff --git a/src/Base/swigpyrun_1.3.33.cpp b/src/Base/swigpyrun_1.3.33.cpp deleted file mode 100644 index 9e6c509ec4..0000000000 --- a/src/Base/swigpyrun_1.3.33.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2008 Werner Mayer * - * * - * 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" -#include "PyExport.h" -#include "Exception.h" -#include -#if defined(__clang__) -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wdeprecated-register" -# pragma clang diagnostic ignored "-Wself-assign" -#elif defined (__GNUC__) -# pragma GCC diagnostic push -# if __GNUC__ >= 8 -# pragma GCC diagnostic ignored "-Wcast-function-type" -# endif -#endif -namespace Swig_1_3_33 { -#define SWIG_PYTHON_NO_BUILD_NONE -#include "swigpyrun_1.3.33.h" -#include "swigpyrun.inl" -} -#if defined(__clang__) -# pragma clang diagnostic pop -#elif defined (__GNUC__) -# pragma GCC diagnostic pop -#endif - diff --git a/src/Base/swigpyrun_1.3.33.h b/src/Base/swigpyrun_1.3.33.h deleted file mode 100644 index afd5a8c504..0000000000 --- a/src/Base/swigpyrun_1.3.33.h +++ /dev/null @@ -1,2502 +0,0 @@ -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.33 - * - * This file is not intended to be easily readable and contains a number of - * coding conventions designed to improve portability and efficiency. Do not make - * changes to this file unless you know what you are doing--modify the SWIG - * interface file instead. - * ----------------------------------------------------------------------------- */ - -/* ----------------------------------------------------------------------------- - * This section contains generic SWIG labels for method/variable - * declarations/attributes, and other compiler dependent labels. - * ----------------------------------------------------------------------------- */ - -/* template workaround for compilers that cannot correctly implement the C++ standard */ -#ifndef SWIGTEMPLATEDISAMBIGUATOR -# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) -# define SWIGTEMPLATEDISAMBIGUATOR template -# elif defined(__HP_aCC) -/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ -/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ -# define SWIGTEMPLATEDISAMBIGUATOR template -# else -# define SWIGTEMPLATEDISAMBIGUATOR -# endif -#endif - -/* inline attribute */ -#ifndef SWIGINLINE -# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) -# define SWIGINLINE inline -# else -# define SWIGINLINE -# endif -#endif - -/* attribute recognised by some compilers to avoid 'unused' warnings */ -#ifndef SWIGUNUSED -# if defined(__GNUC__) -# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define SWIGUNUSED __attribute__ ((__unused__)) -# else -# define SWIGUNUSED -# endif -# elif defined(__ICC) -# define SWIGUNUSED __attribute__ ((__unused__)) -# else -# define SWIGUNUSED -# endif -#endif - -#ifndef SWIGUNUSEDPARM -# ifdef __cplusplus -# define SWIGUNUSEDPARM(p) -# else -# define SWIGUNUSEDPARM(p) p SWIGUNUSED -# endif -#endif - -/* internal SWIG method */ -#ifndef SWIGINTERN -# define SWIGINTERN static SWIGUNUSED -#endif - -/* internal inline SWIG method */ -#ifndef SWIGINTERNINLINE -# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE -#endif - -/* exporting methods */ -#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY -# endif -#endif - -#ifndef SWIGEXPORT -# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# if defined(STATIC_LINKED) -# define SWIGEXPORT -# else -# define SWIGEXPORT __declspec(dllexport) -# endif -# else -# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) -# define SWIGEXPORT __attribute__ ((visibility("default"))) -# else -# define SWIGEXPORT -# endif -# endif -#endif - -/* calling conventions for Windows */ -#ifndef SWIGSTDCALL -# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# define SWIGSTDCALL __stdcall -# else -# define SWIGSTDCALL -# endif -#endif - -/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ -#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) -# define _CRT_SECURE_NO_DEPRECATE -#endif - -/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ -#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) -# define _SCL_SECURE_NO_DEPRECATE -#endif - -/* Errors in SWIG */ -#define SWIG_UnknownError -1 -#define SWIG_IOError -2 -#define SWIG_RuntimeError -3 -#define SWIG_IndexError -4 -#define SWIG_TypeError -5 -#define SWIG_DivisionByZero -6 -#define SWIG_OverflowError -7 -#define SWIG_SyntaxError -8 -#define SWIG_ValueError -9 -#define SWIG_SystemError -10 -#define SWIG_AttributeError -11 -#define SWIG_MemoryError -12 -#define SWIG_NullReferenceError -13 - - -/* Errors in SWIG */ -#define SWIG_UnknownError -1 -#define SWIG_IOError -2 -#define SWIG_RuntimeError -3 -#define SWIG_IndexError -4 -#define SWIG_TypeError -5 -#define SWIG_DivisionByZero -6 -#define SWIG_OverflowError -7 -#define SWIG_SyntaxError -8 -#define SWIG_ValueError -9 -#define SWIG_SystemError -10 -#define SWIG_AttributeError -11 -#define SWIG_MemoryError -12 -#define SWIG_NullReferenceError -13 - - -/* ----------------------------------------------------------------------------- - * swigrun.swg - * - * This file contains generic CAPI SWIG runtime support for pointer - * type checking. - * ----------------------------------------------------------------------------- */ - -/* This should only be incremented when either the layout of swig_type_info changes, - or for whatever reason, the runtime changes incompatibly */ -#define SWIG_RUNTIME_VERSION "3" - -/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ -#ifdef SWIG_TYPE_TABLE -# define SWIG_QUOTE_STRING(x) #x -# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) -# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) -#else -# define SWIG_TYPE_TABLE_NAME -#endif - -/* - You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for - creating a static or dynamic library from the swig runtime code. - In 99.9% of the cases, swig just needs to declare them as 'static'. - - But only do this if is strictly necessary, ie, if you have problems - with your compiler or so. -*/ - -#ifndef SWIGRUNTIME -# define SWIGRUNTIME SWIGINTERN -#endif - -#ifndef SWIGRUNTIMEINLINE -# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE -#endif - -/* Generic buffer size */ -#ifndef SWIG_BUFFER_SIZE -# define SWIG_BUFFER_SIZE 1024 -#endif - -/* Flags for pointer conversions */ -#define SWIG_POINTER_DISOWN 0x1 - -/* Flags for new pointer objects */ -#define SWIG_POINTER_OWN 0x1 - - -/* - Flags/methods for returning states. - - The swig conversion methods, as ConvertPtr, return and integer - that tells if the conversion was successful or not. And if not, - an error code can be returned (see swigerrors.swg for the codes). - - Use the following macros/flags to set or process the returning - states. - - In old swig versions, you usually write code as: - - if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { - // success code - } else { - //fail code - } - - Now you can be more explicit as: - - int res = SWIG_ConvertPtr(obj,vptr,ty.flags); - if (SWIG_IsOK(res)) { - // success code - } else { - // fail code - } - - that seems to be the same, but now you can also do - - Type *ptr; - int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); - if (SWIG_IsOK(res)) { - // success code - if (SWIG_IsNewObj(res) { - ... - delete *ptr; - } else { - ... - } - } else { - // fail code - } - - I.e., now SWIG_ConvertPtr can return new objects and you can - identify the case and take care of the deallocation. Of course that - requires also to SWIG_ConvertPtr to return new result values, as - - int SWIG_ConvertPtr(obj, ptr,...) { - if () { - if () { - *ptr = ; - return SWIG_NEWOBJ; - } else { - *ptr = ; - return SWIG_OLDOBJ; - } - } else { - return SWIG_BADOBJ; - } - } - - Of course, returning the plain '0(success)/-1(fail)' still works, but you can be - more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the - swig errors code. - - Finally, if the SWIG_CASTRANK_MODE is enabled, the result code - allows to return the 'cast rank', for example, if you have this - - int food(double) - int fooi(int); - - and you call - - food(1) // cast rank '1' (1 -> 1.0) - fooi(1) // cast rank '0' - - just use the SWIG_AddCast()/SWIG_CheckState() - - - */ -#define SWIG_OK (0) -#define SWIG_ERROR (-1) -#define SWIG_IsOK(r) (r >= 0) -#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) - -/* The CastRankLimit says how many bits are used for the cast rank */ -#define SWIG_CASTRANKLIMIT (1 << 8) -/* The NewMask denotes the object was created (using new/malloc) */ -#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1) -/* The TmpMask is for in/out typemaps that use temporal objects */ -#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1) -/* Simple returning values */ -#define SWIG_BADOBJ (SWIG_ERROR) -#define SWIG_OLDOBJ (SWIG_OK) -#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK) -#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK) -/* Check, add and del mask methods */ -#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r) -#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r) -#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK)) -#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r) -#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) -#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) - - -/* Cast-Rank Mode */ -#if defined(SWIG_CASTRANK_MODE) -# ifndef SWIG_TypeRank -# define SWIG_TypeRank unsigned long -# endif -# ifndef SWIG_MAXCASTRANK /* Default cast allowed */ -# define SWIG_MAXCASTRANK (2) -# endif -# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) -# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) -SWIGINTERNINLINE int SWIG_AddCast(int r) { - return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; -} -SWIGINTERNINLINE int SWIG_CheckState(int r) { - return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; -} -#else /* no cast-rank mode */ -# define SWIG_AddCast -# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) -#endif - - - - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void *(*swig_converter_func)(void *); -typedef struct swig_type_info *(*swig_dycast_func)(void **); - -/* Structure to store inforomation on one type */ -typedef struct swig_type_info { - const char *name; /* mangled name of this type */ - const char *str; /* human readable name of this type */ - swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ - struct swig_cast_info *cast; /* linked list of types that can cast into this type */ - void *clientdata; /* language specific type data */ - int owndata; /* flag if the structure owns the clientdata */ -} swig_type_info; - -/* Structure to store a type and conversion function used for casting */ -typedef struct swig_cast_info { - swig_type_info *type; /* pointer to type that is equivalent to this type */ - swig_converter_func converter; /* function to cast the void pointers */ - struct swig_cast_info *next; /* pointer to next cast in linked list */ - struct swig_cast_info *prev; /* pointer to the previous cast */ -} swig_cast_info; - -/* Structure used to store module information - * Each module generates one structure like this, and the runtime collects - * all of these structures and stores them in a circularly linked list.*/ -typedef struct swig_module_info { - swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ - size_t size; /* Number of types in this module */ - struct swig_module_info *next; /* Pointer to next element in circularly linked list */ - swig_type_info **type_initial; /* Array of initially generated type structures */ - swig_cast_info **cast_initial; /* Array of initially generated casting structures */ - void *clientdata; /* Language specific module data */ -} swig_module_info; - -/* - Compare two type names skipping the space characters, therefore - "char*" == "char *" and "Class" == "Class", etc. - - Return 0 when the two name types are equivalent, as in - strncmp, but skipping ' '. -*/ -SWIGRUNTIME int -SWIG_TypeNameComp(const char *f1, const char *l1, - const char *f2, const char *l2) { - for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { - while ((*f1 == ' ') && (f1 != l1)) ++f1; - while ((*f2 == ' ') && (f2 != l2)) ++f2; - if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; - } - return (int)((l1 - f1) - (l2 - f2)); -} - -/* - Check type equivalence in a name list like ||... - Return 0 if not equal, 1 if equal -*/ -SWIGRUNTIME int -SWIG_TypeEquiv(const char *nb, const char *tb) { - int equiv = 0; - const char* te = tb + strlen(tb); - const char* ne = nb; - while (!equiv && *ne) { - for (nb = ne; *ne; ++ne) { - if (*ne == '|') break; - } - equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; - if (*ne) ++ne; - } - return equiv; -} - -/* - Check type equivalence in a name list like ||... - Return 0 if equal, -1 if nb < tb, 1 if nb > tb -*/ -SWIGRUNTIME int -SWIG_TypeCompare(const char *nb, const char *tb) { - int equiv = 0; - const char* te = tb + strlen(tb); - const char* ne = nb; - while (!equiv && *ne) { - for (nb = ne; *ne; ++ne) { - if (*ne == '|') break; - } - equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; - if (*ne) ++ne; - } - return equiv; -} - - -/* think of this as a c++ template<> or a scheme macro */ -#define SWIG_TypeCheck_Template(comparison, ty) \ - if (ty) { \ - swig_cast_info *iter = ty->cast; \ - while (iter) { \ - if (comparison) { \ - if (iter == ty->cast) return iter; \ - /* Move iter to the top of the linked list */ \ - iter->prev->next = iter->next; \ - if (iter->next) \ - iter->next->prev = iter->prev; \ - iter->next = ty->cast; \ - iter->prev = 0; \ - if (ty->cast) ty->cast->prev = iter; \ - ty->cast = iter; \ - return iter; \ - } \ - iter = iter->next; \ - } \ - } \ - return 0 - -/* - Check the typename -*/ -SWIGRUNTIME swig_cast_info * -SWIG_TypeCheck(const char *c, swig_type_info *ty) { - SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty); -} - -/* Same as previous function, except strcmp is replaced with a pointer comparison */ -SWIGRUNTIME swig_cast_info * -SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) { - SWIG_TypeCheck_Template(iter->type == from, into); -} - -/* - Cast a pointer up an inheritance hierarchy -*/ -SWIGRUNTIMEINLINE void * -SWIG_TypeCast(swig_cast_info *ty, void *ptr) { - return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr); -} - -/* - Dynamic pointer casting. Down an inheritance hierarchy -*/ -SWIGRUNTIME swig_type_info * -SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { - swig_type_info *lastty = ty; - if (!ty || !ty->dcast) return ty; - while (ty && (ty->dcast)) { - ty = (*ty->dcast)(ptr); - if (ty) lastty = ty; - } - return lastty; -} - -/* - Return the name associated with this type -*/ -SWIGRUNTIMEINLINE const char * -SWIG_TypeName(const swig_type_info *ty) { - return ty->name; -} - -/* - Return the pretty name associated with this type, - that is an unmangled type name in a form presentable to the user. -*/ -SWIGRUNTIME const char * -SWIG_TypePrettyName(const swig_type_info *type) { - /* The "str" field contains the equivalent pretty names of the - type, separated by vertical-bar characters. We choose - to print the last name, as it is often (?) the most - specific. */ - if (!type) return NULL; - if (type->str != NULL) { - const char *last_name = type->str; - const char *s; - for (s = type->str; *s; s++) - if (*s == '|') last_name = s+1; - return last_name; - } - else - return type->name; -} - -/* - Set the clientdata field for a type -*/ -SWIGRUNTIME void -SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { - swig_cast_info *cast = ti->cast; - /* if (ti->clientdata == clientdata) return; */ - ti->clientdata = clientdata; - - while (cast) { - if (!cast->converter) { - swig_type_info *tc = cast->type; - if (!tc->clientdata) { - SWIG_TypeClientData(tc, clientdata); - } - } - cast = cast->next; - } -} -SWIGRUNTIME void -SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { - SWIG_TypeClientData(ti, clientdata); - ti->owndata = 1; -} - -/* - Search for a swig_type_info structure only by mangled name - Search is a O(log #types) - - We start searching at module start, and finish searching when start == end. - Note: if start == end at the beginning of the function, we go all the way around - the circular list. -*/ -SWIGRUNTIME swig_type_info * -SWIG_MangledTypeQueryModule(swig_module_info *start, - swig_module_info *end, - const char *name) { - swig_module_info *iter = start; - do { - if (iter->size) { - register size_t l = 0; - register size_t r = iter->size - 1; - do { - /* since l+r >= 0, we can (>> 1) instead (/ 2) */ - register size_t i = (l + r) >> 1; - const char *iname = iter->types[i]->name; - if (iname) { - register int compare = strcmp(name, iname); - if (compare == 0) { - return iter->types[i]; - } else if (compare < 0) { - if (i) { - r = i - 1; - } else { - break; - } - } else if (compare > 0) { - l = i + 1; - } - } else { - break; /* should never happen */ - } - } while (l <= r); - } - iter = iter->next; - } while (iter != end); - return 0; -} - -/* - Search for a swig_type_info structure for either a mangled name or a human readable name. - It first searches the mangled names of the types, which is a O(log #types) - If a type is not found it then searches the human readable names, which is O(#types). - - We start searching at module start, and finish searching when start == end. - Note: if start == end at the beginning of the function, we go all the way around - the circular list. -*/ -SWIGRUNTIME swig_type_info * -SWIG_TypeQueryModule(swig_module_info *start, - swig_module_info *end, - const char *name) { - /* STEP 1: Search the name field using binary search */ - swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); - if (ret) { - return ret; - } else { - /* STEP 2: If the type hasn't been found, do a complete search - of the str field (the human readable name) */ - swig_module_info *iter = start; - do { - register size_t i = 0; - for (; i < iter->size; ++i) { - if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) - return iter->types[i]; - } - iter = iter->next; - } while (iter != end); - } - - /* neither found a match */ - return 0; -} - -/* - Pack binary data into a string -*/ -SWIGRUNTIME char * -SWIG_PackData(char *c, void *ptr, size_t sz) { - static const char hex[17] = "0123456789abcdef"; - register const unsigned char *u = (unsigned char *) ptr; - register const unsigned char *eu = u + sz; - for (; u != eu; ++u) { - register unsigned char uu = *u; - *(c++) = hex[(uu & 0xf0) >> 4]; - *(c++) = hex[uu & 0xf]; - } - return c; -} - -/* - Unpack binary data from a string -*/ -SWIGRUNTIME const char * -SWIG_UnpackData(const char *c, void *ptr, size_t sz) { - register unsigned char *u = (unsigned char *) ptr; - register const unsigned char *eu = u + sz; - for (; u != eu; ++u) { - register char d = *(c++); - register unsigned char uu; - if ((d >= '0') && (d <= '9')) - uu = ((d - '0') << 4); - else if ((d >= 'a') && (d <= 'f')) - uu = ((d - ('a'-10)) << 4); - else - return (char *) 0; - d = *(c++); - if ((d >= '0') && (d <= '9')) - uu |= (d - '0'); - else if ((d >= 'a') && (d <= 'f')) - uu |= (d - ('a'-10)); - else - return (char *) 0; - *u = uu; - } - return c; -} - -/* - Pack 'void *' into a string buffer. -*/ -SWIGRUNTIME char * -SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { - char *r = buff; - if ((2*sizeof(void *) + 2) > bsz) return 0; - *(r++) = '_'; - r = SWIG_PackData(r,&ptr,sizeof(void *)); - if (strlen(name) + 1 > (bsz - (r - buff))) return 0; - strcpy(r,name); - return buff; -} - -SWIGRUNTIME const char * -SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { - if (*c != '_') { - if (strcmp(c,"NULL") == 0) { - *ptr = (void *) 0; - return name; - } else { - return 0; - } - } - return SWIG_UnpackData(++c,ptr,sizeof(void *)); -} - -SWIGRUNTIME char * -SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { - char *r = buff; - size_t lname = (name ? strlen(name) : 0); - if ((2*sz + 2 + lname) > bsz) return 0; - *(r++) = '_'; - r = SWIG_PackData(r,ptr,sz); - if (lname) { - strncpy(r,name,lname+1); - } else { - *r = 0; - } - return buff; -} - -SWIGRUNTIME const char * -SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { - if (*c != '_') { - if (strcmp(c,"NULL") == 0) { - memset(ptr,0,sz); - return name; - } else { - return 0; - } - } - return SWIG_UnpackData(++c,ptr,sz); -} - -#ifdef __cplusplus -} -#endif - -/* Add PyOS_snprintf for old Pythons */ -#if PY_VERSION_HEX < 0x02020000 -# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) -# define PyOS_snprintf _snprintf -# else -# define PyOS_snprintf snprintf -# endif -#endif - -/* A crude PyString_FromFormat implementation for old Pythons */ -#if PY_VERSION_HEX < 0x02020000 - -#ifndef SWIG_PYBUFFER_SIZE -# define SWIG_PYBUFFER_SIZE 1024 -#endif - -static PyObject * -PyString_FromFormat(const char *fmt, ...) { - va_list ap; - char buf[SWIG_PYBUFFER_SIZE * 2]; - int res; - va_start(ap, fmt); - res = vsnprintf(buf, sizeof(buf), fmt, ap); - va_end(ap); - return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf); -} -#endif - -/* Add PyObject_Del for old Pythons */ -#if PY_VERSION_HEX < 0x01060000 -# define PyObject_Del(op) PyMem_DEL((op)) -#endif -#ifndef PyObject_DEL -# define PyObject_DEL PyObject_Del -#endif - -/* A crude PyExc_StopIteration exception for old Pythons */ -#if PY_VERSION_HEX < 0x02020000 -# ifndef PyExc_StopIteration -# define PyExc_StopIteration PyExc_RuntimeError -# endif -# ifndef PyObject_GenericGetAttr -# define PyObject_GenericGetAttr 0 -# endif -#endif -/* Py_NotImplemented is defined in 2.1 and up. */ -#if PY_VERSION_HEX < 0x02010000 -# ifndef Py_NotImplemented -# define Py_NotImplemented PyExc_RuntimeError -# endif -#endif - - -/* A crude PyString_AsStringAndSize implementation for old Pythons */ -#if PY_VERSION_HEX < 0x02010000 -# ifndef PyString_AsStringAndSize -# define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;} -# endif -#endif - -/* PySequence_Size for old Pythons */ -#if PY_VERSION_HEX < 0x02000000 -# ifndef PySequence_Size -# define PySequence_Size PySequence_Length -# endif -#endif - - -/* PyBool_FromLong for old Pythons */ -#if PY_VERSION_HEX < 0x02030000 -static -PyObject *PyBool_FromLong(long ok) -{ - PyObject *result = ok ? Py_True : Py_False; - Py_INCREF(result); - return result; -} -#endif - -/* Py_ssize_t for old Pythons */ -/* This code is as recommended by: */ -/* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */ -#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) -typedef int Py_ssize_t; -# define PY_SSIZE_T_MAX INT_MAX -# define PY_SSIZE_T_MIN INT_MIN -#endif -/* ----------------------------------------------------------------------------- - * error manipulation - * ----------------------------------------------------------------------------- */ - -SWIGRUNTIME PyObject* -SWIG_Python_ErrorType(int code) { - PyObject* type = 0; - switch(code) { - case SWIG_MemoryError: - type = PyExc_MemoryError; - break; - case SWIG_IOError: - type = PyExc_IOError; - break; - case SWIG_RuntimeError: - type = PyExc_RuntimeError; - break; - case SWIG_IndexError: - type = PyExc_IndexError; - break; - case SWIG_TypeError: - type = PyExc_TypeError; - break; - case SWIG_DivisionByZero: - type = PyExc_ZeroDivisionError; - break; - case SWIG_OverflowError: - type = PyExc_OverflowError; - break; - case SWIG_SyntaxError: - type = PyExc_SyntaxError; - break; - case SWIG_ValueError: - type = PyExc_ValueError; - break; - case SWIG_SystemError: - type = PyExc_SystemError; - break; - case SWIG_AttributeError: - type = PyExc_AttributeError; - break; - default: - type = PyExc_RuntimeError; - } - return type; -} - - -SWIGRUNTIME void -SWIG_Python_AddErrorMsg(const char* mesg) -{ - PyObject *type = 0; - PyObject *value = 0; - PyObject *traceback = 0; - - if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback); - if (value) { - PyObject *old_str = PyObject_Str(value); - PyErr_Clear(); - Py_XINCREF(type); - PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg); - Py_DECREF(old_str); - Py_DECREF(value); - } else { - PyErr_Format(PyExc_RuntimeError, "%s",mesg); - } -} - - -#if defined(SWIG_PYTHON_NO_THREADS) -# if defined(SWIG_PYTHON_THREADS) -# undef SWIG_PYTHON_THREADS -# endif -#endif -#if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */ -# if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL) -# if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */ -# define SWIG_PYTHON_USE_GIL -# endif -# endif -# if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */ -# ifndef SWIG_PYTHON_INITIALIZE_THREADS -# define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads() -# endif -# ifdef __cplusplus /* C++ code */ - class SWIG_Python_Thread_Block { - bool status; - PyGILState_STATE state; - public: - void end() { if (status) { PyGILState_Release(state); status = false;} } - SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {} - ~SWIG_Python_Thread_Block() { end(); } - }; - class SWIG_Python_Thread_Allow { - bool status; - PyThreadState *save; - public: - void end() { if (status) { PyEval_RestoreThread(save); status = false; }} - SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {} - ~SWIG_Python_Thread_Allow() { end(); } - }; -# define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block -# define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end() -# define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow -# define SWIG_PYTHON_THREAD_END_ALLOW _swig_thread_allow.end() -# else /* C code */ -# define SWIG_PYTHON_THREAD_BEGIN_BLOCK PyGILState_STATE _swig_thread_block = PyGILState_Ensure() -# define SWIG_PYTHON_THREAD_END_BLOCK PyGILState_Release(_swig_thread_block) -# define SWIG_PYTHON_THREAD_BEGIN_ALLOW PyThreadState *_swig_thread_allow = PyEval_SaveThread() -# define SWIG_PYTHON_THREAD_END_ALLOW PyEval_RestoreThread(_swig_thread_allow) -# endif -# else /* Old thread way, not implemented, user must provide it */ -# if !defined(SWIG_PYTHON_INITIALIZE_THREADS) -# define SWIG_PYTHON_INITIALIZE_THREADS -# endif -# if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK) -# define SWIG_PYTHON_THREAD_BEGIN_BLOCK -# endif -# if !defined(SWIG_PYTHON_THREAD_END_BLOCK) -# define SWIG_PYTHON_THREAD_END_BLOCK -# endif -# if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW) -# define SWIG_PYTHON_THREAD_BEGIN_ALLOW -# endif -# if !defined(SWIG_PYTHON_THREAD_END_ALLOW) -# define SWIG_PYTHON_THREAD_END_ALLOW -# endif -# endif -#else /* No thread support */ -# define SWIG_PYTHON_INITIALIZE_THREADS -# define SWIG_PYTHON_THREAD_BEGIN_BLOCK -# define SWIG_PYTHON_THREAD_END_BLOCK -# define SWIG_PYTHON_THREAD_BEGIN_ALLOW -# define SWIG_PYTHON_THREAD_END_ALLOW -#endif -/* ----------------------------------------------------------------------------- - * Python API portion that goes into the runtime - * ----------------------------------------------------------------------------- */ - -#ifdef __cplusplus -extern "C" { -#if 0 -} /* cc-mode */ -#endif -#endif - -/* ----------------------------------------------------------------------------- - * Constant declarations - * ----------------------------------------------------------------------------- */ - -/* Constant Types */ -#define SWIG_PY_POINTER 4 -#define SWIG_PY_BINARY 5 - -/* Constant information structure */ -typedef struct swig_const_info { - int type; - char *name; - long lvalue; - double dvalue; - void *pvalue; - swig_type_info **ptype; -} swig_const_info; - -#ifdef __cplusplus -#if 0 -{ /* cc-mode */ -#endif -} -#endif - -/* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * - * pyrun.swg - * - * This file contains the runtime support for Python modules - * and includes code for managing global variables and pointer - * type checking. - * - * ----------------------------------------------------------------------------- */ - -/* Common SWIG API */ - -/* for raw pointers */ -#define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0) -#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags) -#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own) -#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(ptr, type, flags) -#define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty) -#define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src) -#define swig_owntype int - -/* for raw packed data */ -#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) -#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) - -/* for class or struct pointers */ -#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) -#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) - -/* for C or C++ function pointers */ -#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type) -#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(ptr, type, 0) - -/* for C++ member pointers, ie, member methods */ -#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) -#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) - - -/* Runtime API */ - -#define SWIG_GetModule(clientdata) SWIG_Python_GetModule() -#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) -#define SWIG_NewClientData(obj) PySwigClientData_New(obj) - -#define SWIG_SetErrorObj SWIG_Python_SetErrorObj -#define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg -#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code) -#define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) -#define SWIG_fail goto fail - - -/* Runtime API implementation */ - -/* Error manipulation */ - -SWIGINTERN void -SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyErr_SetObject(errtype, obj); - Py_DECREF(obj); - SWIG_PYTHON_THREAD_END_BLOCK; -} - -SWIGINTERN void -SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyErr_SetString(errtype, (char *) msg); - SWIG_PYTHON_THREAD_END_BLOCK; -} - -#define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj) - -/* Set a constant value */ - -SWIGINTERN void -SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { - PyDict_SetItemString(d, (char*) name, obj); - Py_DECREF(obj); -} - -/* Append a value to the result obj */ - -SWIGINTERN PyObject* -SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { -#if !defined(SWIG_PYTHON_OUTPUT_TUPLE) - if (!result) { - result = obj; - } else if (result == Py_None) { - Py_DECREF(result); - result = obj; - } else { - if (!PyList_Check(result)) { - PyObject *o2 = result; - result = PyList_New(1); - PyList_SetItem(result, 0, o2); - } - PyList_Append(result,obj); - Py_DECREF(obj); - } - return result; -#else - PyObject* o2; - PyObject* o3; - if (!result) { - result = obj; - } else if (result == Py_None) { - Py_DECREF(result); - result = obj; - } else { - if (!PyTuple_Check(result)) { - o2 = result; - result = PyTuple_New(1); - PyTuple_SET_ITEM(result, 0, o2); - } - o3 = PyTuple_New(1); - PyTuple_SET_ITEM(o3, 0, obj); - o2 = result; - result = PySequence_Concat(o2, o3); - Py_DECREF(o2); - Py_DECREF(o3); - } - return result; -#endif -} - -/* Unpack the argument tuple */ - -SWIGINTERN int -SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs) -{ - if (!args) { - if (!min && !max) { - return 1; - } else { - PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none", - name, (min == max ? "" : "at least "), (int)min); - return 0; - } - } - if (!PyTuple_Check(args)) { - PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple"); - return 0; - } else { - register Py_ssize_t l = PyTuple_GET_SIZE(args); - if (l < min) { - PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", - name, (min == max ? "" : "at least "), (int)min, (int)l); - return 0; - } else if (l > max) { - PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", - name, (min == max ? "" : "at most "), (int)max, (int)l); - return 0; - } else { - register int i; - for (i = 0; i < l; ++i) { - objs[i] = PyTuple_GET_ITEM(args, i); - } - for (; l < max; ++l) { - objs[l] = 0; - } - return i + 1; - } - } -} - -/* A functor is a function object with one single object argument */ -#if PY_VERSION_HEX >= 0x02020000 -#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL); -#else -#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj); -#endif - -/* - Helper for static pointer initialization for both C and C++ code, for example - static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...); -*/ -#ifdef __cplusplus -#define SWIG_STATIC_POINTER(var) var -#else -#define SWIG_STATIC_POINTER(var) var = 0; if (!var) var -#endif - -/* ----------------------------------------------------------------------------- - * Pointer declarations - * ----------------------------------------------------------------------------- */ - -/* Flags for new pointer objects */ -#define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1) -#define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN) - -#define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1) - -#ifdef __cplusplus -extern "C" { -#if 0 -} /* cc-mode */ -#endif -#endif - -/* How to access Py_None */ -#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# ifndef SWIG_PYTHON_NO_BUILD_NONE -# ifndef SWIG_PYTHON_BUILD_NONE -# define SWIG_PYTHON_BUILD_NONE -# endif -# endif -#endif - -#ifdef SWIG_PYTHON_BUILD_NONE -# ifdef Py_None -# undef Py_None -# define Py_None SWIG_Py_None() -# endif -SWIGRUNTIMEINLINE PyObject * -_SWIG_Py_None(void) -{ - PyObject *none = Py_BuildValue((char*)""); - Py_DECREF(none); - return none; -} -SWIGRUNTIME PyObject * -SWIG_Py_None(void) -{ - static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None(); - return none; -} -#endif - -/* The python void return value */ - -SWIGRUNTIMEINLINE PyObject * -SWIG_Py_Void(void) -{ - PyObject *none = Py_None; - Py_INCREF(none); - return none; -} - -/* PySwigClientData */ - -typedef struct { - PyObject *klass; - PyObject *newraw; - PyObject *newargs; - PyObject *destroy; - int delargs; - int implicitconv; -} PySwigClientData; - -SWIGRUNTIMEINLINE int -SWIG_Python_CheckImplicit(swig_type_info *ty) -{ - PySwigClientData *data = (PySwigClientData *)ty->clientdata; - return data ? data->implicitconv : 0; -} - -SWIGRUNTIMEINLINE PyObject * -SWIG_Python_ExceptionType(swig_type_info *desc) { - PySwigClientData *data = desc ? (PySwigClientData *) desc->clientdata : 0; - PyObject *klass = data ? data->klass : 0; - return (klass ? klass : PyExc_RuntimeError); -} - - -SWIGRUNTIME PySwigClientData * -PySwigClientData_New(PyObject* obj) -{ - if (!obj) { - return 0; - } else { - PySwigClientData *data = (PySwigClientData *)malloc(sizeof(PySwigClientData)); - /* the klass element */ - data->klass = obj; - Py_INCREF(data->klass); - /* the newraw method and newargs arguments used to create a new raw instance */ - if (PyClass_Check(obj)) { - data->newraw = 0; - data->newargs = obj; - Py_INCREF(obj); - } else { -#if (PY_VERSION_HEX < 0x02020000) - data->newraw = 0; -#else - data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__"); -#endif - if (data->newraw) { - Py_INCREF(data->newraw); - data->newargs = PyTuple_New(1); - PyTuple_SetItem(data->newargs, 0, obj); - } else { - data->newargs = obj; - } - Py_INCREF(data->newargs); - } - /* the destroy method, aka as the C++ delete method */ - data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__"); - if (PyErr_Occurred()) { - PyErr_Clear(); - data->destroy = 0; - } - if (data->destroy) { - int flags; - Py_INCREF(data->destroy); - flags = PyCFunction_GET_FLAGS(data->destroy); -#ifdef METH_O - data->delargs = !(flags & (METH_O)); -#else - data->delargs = 0; -#endif - } else { - data->delargs = 0; - } - data->implicitconv = 0; - return data; - } -} - -SWIGRUNTIME void -PySwigClientData_Del(PySwigClientData* data) -{ - Py_XDECREF(data->newraw); - Py_XDECREF(data->newargs); - Py_XDECREF(data->destroy); -} - -/* =============== PySwigObject =====================*/ - -typedef struct { - PyObject_HEAD - void *ptr; - swig_type_info *ty; - int own; - PyObject *next; -} PySwigObject; - -SWIGRUNTIME PyObject * -PySwigObject_long(PySwigObject *v) -{ - return PyLong_FromVoidPtr(v->ptr); -} - -SWIGRUNTIME PyObject * -PySwigObject_format(const char* fmt, PySwigObject *v) -{ - PyObject *res = NULL; - PyObject *args = PyTuple_New(1); - if (args) { - if (PyTuple_SetItem(args, 0, PySwigObject_long(v)) == 0) { - PyObject *ofmt = PyString_FromString(fmt); - if (ofmt) { - res = PyString_Format(ofmt,args); - Py_DECREF(ofmt); - } - Py_DECREF(args); - } - } - return res; -} - -SWIGRUNTIME PyObject * -PySwigObject_oct(PySwigObject *v) -{ - return PySwigObject_format("%o",v); -} - -SWIGRUNTIME PyObject * -PySwigObject_hex(PySwigObject *v) -{ - return PySwigObject_format("%x",v); -} - -SWIGRUNTIME PyObject * -#ifdef METH_NOARGS -PySwigObject_repr(PySwigObject *v) -#else -PySwigObject_repr(PySwigObject *v, PyObject *args) -#endif -{ - const char *name = SWIG_TypePrettyName(v->ty); - PyObject *hex = PySwigObject_hex(v); - PyObject *repr = PyString_FromFormat("", name, PyString_AsString(hex)); - Py_DECREF(hex); - if (v->next) { -#ifdef METH_NOARGS - PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next); -#else - PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next, args); -#endif - PyString_ConcatAndDel(&repr,nrep); - } - return repr; -} - -SWIGRUNTIME int -PySwigObject_print(PySwigObject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) -{ -#ifdef METH_NOARGS - PyObject *repr = PySwigObject_repr(v); -#else - PyObject *repr = PySwigObject_repr(v, NULL); -#endif - if (repr) { - fputs(PyString_AsString(repr), fp); - Py_DECREF(repr); - return 0; - } else { - return 1; - } -} - -SWIGRUNTIME PyObject * -PySwigObject_str(PySwigObject *v) -{ - char result[SWIG_BUFFER_SIZE]; - return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ? - PyString_FromString(result) : 0; -} - -SWIGRUNTIME int -PySwigObject_compare(PySwigObject *v, PySwigObject *w) -{ - void *i = v->ptr; - void *j = w->ptr; - return (i < j) ? -1 : ((i > j) ? 1 : 0); -} - -SWIGRUNTIME PyTypeObject* _PySwigObject_type(void); - -SWIGRUNTIME PyTypeObject* -PySwigObject_type(void) { - static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigObject_type(); - return type; -} - -SWIGRUNTIMEINLINE int -PySwigObject_Check(PyObject *op) { - return ((op)->ob_type == PySwigObject_type()) - || (strcmp((op)->ob_type->tp_name,"PySwigObject") == 0); -} - -SWIGRUNTIME PyObject * -PySwigObject_New(void *ptr, swig_type_info *ty, int own); - -SWIGRUNTIME void -PySwigObject_dealloc(PyObject *v) -{ - PySwigObject *sobj = (PySwigObject *) v; - PyObject *next = sobj->next; - if (sobj->own) { - swig_type_info *ty = sobj->ty; - PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0; - PyObject *destroy = data ? data->destroy : 0; - if (destroy) { - /* destroy is always a VARARGS method */ - PyObject *res; - if (data->delargs) { - /* we need to create a temporal object to carry the destroy operation */ - PyObject *tmp = PySwigObject_New(sobj->ptr, ty, 0); - res = SWIG_Python_CallFunctor(destroy, tmp); - Py_DECREF(tmp); - } else { - PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); - PyObject *mself = PyCFunction_GET_SELF(destroy); - res = ((*meth)(mself, v)); - } - Py_XDECREF(res); - } else { - const char *name = SWIG_TypePrettyName(ty); -#if !defined(SWIG_PYTHON_SILENT_MEMLEAK) - printf("swig/python detected a memory leak of type '%s', no destructor found.\n", name); -#endif - } - } - Py_XDECREF(next); - PyObject_DEL(v); -} - -SWIGRUNTIME PyObject* -PySwigObject_append(PyObject* v, PyObject* next) -{ - PySwigObject *sobj = (PySwigObject *) v; -#ifndef METH_O - PyObject *tmp = 0; - if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL; - next = tmp; -#endif - if (!PySwigObject_Check(next)) { - return NULL; - } - sobj->next = next; - Py_INCREF(next); - return SWIG_Py_Void(); -} - -SWIGRUNTIME PyObject* -#ifdef METH_NOARGS -PySwigObject_next(PyObject* v) -#else -PySwigObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) -#endif -{ - PySwigObject *sobj = (PySwigObject *) v; - if (sobj->next) { - Py_INCREF(sobj->next); - return sobj->next; - } else { - return SWIG_Py_Void(); - } -} - -SWIGINTERN PyObject* -#ifdef METH_NOARGS -PySwigObject_disown(PyObject *v) -#else -PySwigObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) -#endif -{ - PySwigObject *sobj = (PySwigObject *)v; - sobj->own = 0; - return SWIG_Py_Void(); -} - -SWIGINTERN PyObject* -#ifdef METH_NOARGS -PySwigObject_acquire(PyObject *v) -#else -PySwigObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) -#endif -{ - PySwigObject *sobj = (PySwigObject *)v; - sobj->own = SWIG_POINTER_OWN; - return SWIG_Py_Void(); -} - -SWIGINTERN PyObject* -PySwigObject_own(PyObject *v, PyObject *args) -{ - PyObject *val = 0; -#if (PY_VERSION_HEX < 0x02020000) - if (!PyArg_ParseTuple(args,(char *)"|O:own",&val)) -#else - if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val)) -#endif - { - return NULL; - } - else - { - PySwigObject *sobj = (PySwigObject *)v; - PyObject *obj = PyBool_FromLong(sobj->own); - if (val) { -#ifdef METH_NOARGS - if (PyObject_IsTrue(val)) { - PySwigObject_acquire(v); - } else { - PySwigObject_disown(v); - } -#else - if (PyObject_IsTrue(val)) { - PySwigObject_acquire(v,args); - } else { - PySwigObject_disown(v,args); - } -#endif - } - return obj; - } -} - -#ifdef METH_O -static PyMethodDef -swigobject_methods[] = { - {(char *)"disown", (PyCFunction)PySwigObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"}, - {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_NOARGS, (char *)"aquires ownership of the pointer"}, - {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, - {(char *)"append", (PyCFunction)PySwigObject_append, METH_O, (char *)"appends another 'this' object"}, - {(char *)"next", (PyCFunction)PySwigObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, - {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_NOARGS, (char *)"returns object representation"}, - {0, 0, 0, 0} -}; -#else -static PyMethodDef -swigobject_methods[] = { - {(char *)"disown", (PyCFunction)PySwigObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"}, - {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"}, - {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, - {(char *)"append", (PyCFunction)PySwigObject_append, METH_VARARGS, (char *)"appends another 'this' object"}, - {(char *)"next", (PyCFunction)PySwigObject_next, METH_VARARGS, (char *)"returns the next 'this' object"}, - {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_VARARGS, (char *)"returns object representation"}, - {0, 0, 0, 0} -}; -#endif - -#if PY_VERSION_HEX < 0x02020000 -SWIGINTERN PyObject * -PySwigObject_getattr(PySwigObject *sobj,char *name) -{ - return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name); -} -#endif - -SWIGRUNTIME PyTypeObject* -_PySwigObject_type(void) { - static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer"; - - static PyNumberMethods PySwigObject_as_number = { - (binaryfunc)0, /*nb_add*/ - (binaryfunc)0, /*nb_subtract*/ - (binaryfunc)0, /*nb_multiply*/ - (binaryfunc)0, /*nb_divide*/ - (binaryfunc)0, /*nb_remainder*/ - (binaryfunc)0, /*nb_divmod*/ - (ternaryfunc)0,/*nb_power*/ - (unaryfunc)0, /*nb_negative*/ - (unaryfunc)0, /*nb_positive*/ - (unaryfunc)0, /*nb_absolute*/ - (inquiry)0, /*nb_nonzero*/ - 0, /*nb_invert*/ - 0, /*nb_lshift*/ - 0, /*nb_rshift*/ - 0, /*nb_and*/ - 0, /*nb_xor*/ - 0, /*nb_or*/ - (coercion)0, /*nb_coerce*/ - (unaryfunc)PySwigObject_long, /*nb_int*/ - (unaryfunc)PySwigObject_long, /*nb_long*/ - (unaryfunc)0, /*nb_float*/ - (unaryfunc)PySwigObject_oct, /*nb_oct*/ - (unaryfunc)PySwigObject_hex, /*nb_hex*/ -#if PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */ -#elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ -#elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */ - 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */ -#endif - }; - - static PyTypeObject pyswigobject_type; - static int type_init = 0; - if (!type_init) { - const PyTypeObject tmp - = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - (char *)"PySwigObject", /* tp_name */ - sizeof(PySwigObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)PySwigObject_dealloc, /* tp_dealloc */ -#if PY_VERSION_HEX < 0x03080000 - (printfunc)PySwigObject_print, /* tp_print */ -#else - 0, /*tp_vectorcall_offset*/ -#endif -#if PY_VERSION_HEX < 0x02020000 - (getattrfunc)PySwigObject_getattr, /* tp_getattr */ -#else - (getattrfunc)0, /* tp_getattr */ -#endif - (setattrfunc)0, /* tp_setattr */ - (cmpfunc)PySwigObject_compare, /* tp_compare */ - (reprfunc)PySwigObject_repr, /* tp_repr */ - &PySwigObject_as_number, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)0, /* tp_hash */ - (ternaryfunc)0, /* tp_call */ - (reprfunc)PySwigObject_str, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - swigobject_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ -#if PY_VERSION_HEX >= 0x02020000 - 0, /* tp_iter */ - 0, /* tp_iternext */ - swigobject_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - 0, /* tp_free */ - 0, /* tp_is_gc */ - 0, /* tp_bases */ - 0, /* tp_mro */ - 0, /* tp_cache */ - 0, /* tp_subclasses */ - 0, /* tp_weaklist */ -#endif -#if PY_VERSION_HEX >= 0x02030000 - 0, /* tp_del */ -#endif -#if PY_VERSION_HEX >= 0x02060000 - 0, /* tp_version_tag */ -#endif -#ifdef COUNT_ALLOCS - 0,0,0,0 /* tp_alloc -> tp_next */ -#endif - }; - pyswigobject_type = tmp; - pyswigobject_type.ob_type = &PyType_Type; - type_init = 1; - } - return &pyswigobject_type; -} - -SWIGRUNTIME PyObject * -PySwigObject_New(void *ptr, swig_type_info *ty, int own) -{ - PySwigObject *sobj = PyObject_NEW(PySwigObject, PySwigObject_type()); - if (sobj) { - sobj->ptr = ptr; - sobj->ty = ty; - sobj->own = own; - sobj->next = 0; - } - return (PyObject *)sobj; -} - -/* ----------------------------------------------------------------------------- - * Implements a simple Swig Packed type, and use it instead of string - * ----------------------------------------------------------------------------- */ - -typedef struct { - PyObject_HEAD - void *pack; - swig_type_info *ty; - size_t size; -} PySwigPacked; - -SWIGRUNTIME int -PySwigPacked_print(PySwigPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags)) -{ - char result[SWIG_BUFFER_SIZE]; - fputs("pack, v->size, 0, sizeof(result))) { - fputs("at ", fp); - fputs(result, fp); - } - fputs(v->ty->name,fp); - fputs(">", fp); - return 0; -} - -SWIGRUNTIME PyObject * -PySwigPacked_repr(PySwigPacked *v) -{ - char result[SWIG_BUFFER_SIZE]; - if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { - return PyString_FromFormat("", result, v->ty->name); - } else { - return PyString_FromFormat("", v->ty->name); - } -} - -SWIGRUNTIME PyObject * -PySwigPacked_str(PySwigPacked *v) -{ - char result[SWIG_BUFFER_SIZE]; - if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ - return PyString_FromFormat("%s%s", result, v->ty->name); - } else { - return PyString_FromString(v->ty->name); - } -} - -SWIGRUNTIME int -PySwigPacked_compare(PySwigPacked *v, PySwigPacked *w) -{ - size_t i = v->size; - size_t j = w->size; - int s = (i < j) ? -1 : ((i > j) ? 1 : 0); - return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size); -} - -SWIGRUNTIME PyTypeObject* _PySwigPacked_type(void); - -SWIGRUNTIME PyTypeObject* -PySwigPacked_type(void) { - static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigPacked_type(); - return type; -} - -SWIGRUNTIMEINLINE int -PySwigPacked_Check(PyObject *op) { - return ((op)->ob_type == _PySwigPacked_type()) - || (strcmp((op)->ob_type->tp_name,"PySwigPacked") == 0); -} - -SWIGRUNTIME void -PySwigPacked_dealloc(PyObject *v) -{ - if (PySwigPacked_Check(v)) { - PySwigPacked *sobj = (PySwigPacked *) v; - free(sobj->pack); - } - PyObject_DEL(v); -} - -SWIGRUNTIME PyTypeObject* -_PySwigPacked_type(void) { - static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer"; - static PyTypeObject pyswigpacked_type; - static int type_init = 0; - if (!type_init) { - const PyTypeObject tmp - = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - (char *)"PySwigPacked", /* tp_name */ - sizeof(PySwigPacked), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)PySwigPacked_dealloc, /* tp_dealloc */ -#if PY_VERSION_HEX < 0x03080000 - (printfunc)PySwigPacked_print, /* tp_print */ -#else - 0, /*tp_vectorcall_offset*/ -#endif - (getattrfunc)0, /* tp_getattr */ - (setattrfunc)0, /* tp_setattr */ - (cmpfunc)PySwigPacked_compare, /* tp_compare */ - (reprfunc)PySwigPacked_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)0, /* tp_hash */ - (ternaryfunc)0, /* tp_call */ - (reprfunc)PySwigPacked_str, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - swigpacked_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ -#if PY_VERSION_HEX >= 0x02020000 - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - 0, /* tp_free */ - 0, /* tp_is_gc */ - 0, /* tp_bases */ - 0, /* tp_mro */ - 0, /* tp_cache */ - 0, /* tp_subclasses */ - 0, /* tp_weaklist */ -#endif -#if PY_VERSION_HEX >= 0x02030000 - 0, /* tp_del */ -#endif -#if PY_VERSION_HEX >= 0x02060000 - 0, /* tp_version_tag */ -#endif -#ifdef COUNT_ALLOCS - 0,0,0,0 /* tp_alloc -> tp_next */ -#endif - }; - pyswigpacked_type = tmp; - pyswigpacked_type.ob_type = &PyType_Type; - type_init = 1; - } - return &pyswigpacked_type; -} - -SWIGRUNTIME PyObject * -PySwigPacked_New(void *ptr, size_t size, swig_type_info *ty) -{ - PySwigPacked *sobj = PyObject_NEW(PySwigPacked, PySwigPacked_type()); - if (sobj) { - void *pack = malloc(size); - if (pack) { - memcpy(pack, ptr, size); - sobj->pack = pack; - sobj->ty = ty; - sobj->size = size; - } else { - PyObject_DEL((PyObject *) sobj); - sobj = 0; - } - } - return (PyObject *) sobj; -} - -SWIGRUNTIME swig_type_info * -PySwigPacked_UnpackData(PyObject *obj, void *ptr, size_t size) -{ - if (PySwigPacked_Check(obj)) { - PySwigPacked *sobj = (PySwigPacked *)obj; - if (sobj->size != size) return 0; - memcpy(ptr, sobj->pack, size); - return sobj->ty; - } else { - return 0; - } -} - -/* ----------------------------------------------------------------------------- - * pointers/data manipulation - * ----------------------------------------------------------------------------- */ - -SWIGRUNTIMEINLINE PyObject * -_SWIG_This(void) -{ - return PyString_FromString("this"); -} - -SWIGRUNTIME PyObject * -SWIG_This(void) -{ - static PyObject *SWIG_STATIC_POINTER(swig_this) = _SWIG_This(); - return swig_this; -} - -/* #define SWIG_PYTHON_SLOW_GETSET_THIS */ - -SWIGRUNTIME PySwigObject * -SWIG_Python_GetSwigThis(PyObject *pyobj) -{ - if (PySwigObject_Check(pyobj)) { - return (PySwigObject *) pyobj; - } else { - PyObject *obj = 0; -#if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000)) - if (PyInstance_Check(pyobj)) { - obj = _PyInstance_Lookup(pyobj, SWIG_This()); - } else { - PyObject **dictptr = _PyObject_GetDictPtr(pyobj); - if (dictptr != NULL) { - PyObject *dict = *dictptr; - obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0; - } else { -#ifdef PyWeakref_CheckProxy - if (PyWeakref_CheckProxy(pyobj)) { - PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); - return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; - } -#endif - obj = PyObject_GetAttr(pyobj,SWIG_This()); - if (obj) { - Py_DECREF(obj); - } else { - if (PyErr_Occurred()) PyErr_Clear(); - return 0; - } - } - } -#else - obj = PyObject_GetAttr(pyobj,SWIG_This()); - if (obj) { - Py_DECREF(obj); - } else { - if (PyErr_Occurred()) PyErr_Clear(); - return 0; - } -#endif - if (obj && !PySwigObject_Check(obj)) { - /* a PyObject is called 'this', try to get the 'real this' - PySwigObject from it */ - return SWIG_Python_GetSwigThis(obj); - } - return (PySwigObject *)obj; - } -} - -/* Acquire a pointer value */ - -SWIGRUNTIME int -SWIG_Python_AcquirePtr(PyObject *obj, int own) { - if (own) { - PySwigObject *sobj = SWIG_Python_GetSwigThis(obj); - if (sobj) { - int oldown = sobj->own; - sobj->own = own; - return oldown; - } - } - return 0; -} - -/* Convert a pointer value */ - -SWIGRUNTIME int -SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) { - if (!obj) return SWIG_ERROR; - if (obj == Py_None) { - if (ptr) *ptr = 0; - return SWIG_OK; - } else { - PySwigObject *sobj = SWIG_Python_GetSwigThis(obj); - while (sobj) { - void *vptr = sobj->ptr; - if (ty) { - swig_type_info *to = sobj->ty; - if (to == ty) { - /* no type cast needed */ - if (ptr) *ptr = vptr; - break; - } else { - swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); - if (!tc) { - sobj = (PySwigObject *)sobj->next; - } else { - if (ptr) *ptr = SWIG_TypeCast(tc,vptr); - break; - } - } - } else { - if (ptr) *ptr = vptr; - break; - } - } - if (sobj) { - if (own) *own = sobj->own; - if (flags & SWIG_POINTER_DISOWN) { - sobj->own = 0; - } - return SWIG_OK; - } else { - int res = SWIG_ERROR; - if (flags & SWIG_POINTER_IMPLICIT_CONV) { - PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0; - if (data && !data->implicitconv) { - PyObject *klass = data->klass; - if (klass) { - PyObject *impconv; - data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/ - impconv = SWIG_Python_CallFunctor(klass, obj); - data->implicitconv = 0; - if (PyErr_Occurred()) { - PyErr_Clear(); - impconv = 0; - } - if (impconv) { - PySwigObject *iobj = SWIG_Python_GetSwigThis(impconv); - if (iobj) { - void *vptr; - res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0); - if (SWIG_IsOK(res)) { - if (ptr) { - *ptr = vptr; - /* transfer the ownership to 'ptr' */ - iobj->own = 0; - res = SWIG_AddCast(res); - res = SWIG_AddNewMask(res); - } else { - res = SWIG_AddCast(res); - } - } - } - Py_DECREF(impconv); - } - } - } - } - return res; - } - } -} - -/* Convert a function ptr value */ - -SWIGRUNTIME int -SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { - if (!PyCFunction_Check(obj)) { - return SWIG_ConvertPtr(obj, ptr, ty, 0); - } else { - void *vptr = 0; - - /* here we get the method pointer for callbacks */ - const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); - const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; - if (desc) { - desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; - if (!desc) return SWIG_ERROR; - } - if (ty) { - swig_cast_info *tc = SWIG_TypeCheck(desc,ty); - if (!tc) return SWIG_ERROR; - *ptr = SWIG_TypeCast(tc,vptr); - } else { - *ptr = vptr; - } - return SWIG_OK; - } -} - -/* Convert a packed value value */ - -SWIGRUNTIME int -SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) { - swig_type_info *to = PySwigPacked_UnpackData(obj, ptr, sz); - if (!to) return SWIG_ERROR; - if (ty) { - if (to != ty) { - /* check type cast? */ - swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); - if (!tc) return SWIG_ERROR; - } - } - return SWIG_OK; -} - -/* ----------------------------------------------------------------------------- - * Create a new pointer object - * ----------------------------------------------------------------------------- */ - -/* - Create a new instance object, whitout calling __init__, and set the - 'this' attribute. -*/ - -SWIGRUNTIME PyObject* -SWIG_Python_NewShadowInstance(PySwigClientData *data, PyObject *swig_this) -{ -#if (PY_VERSION_HEX >= 0x02020000) - PyObject *inst = 0; - PyObject *newraw = data->newraw; - if (newraw) { - inst = PyObject_Call(newraw, data->newargs, NULL); - if (inst) { -#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) - PyObject **dictptr = _PyObject_GetDictPtr(inst); - if (dictptr != NULL) { - PyObject *dict = *dictptr; - if (dict == NULL) { - dict = PyDict_New(); - *dictptr = dict; - PyDict_SetItem(dict, SWIG_This(), swig_this); - } - } -#else - PyObject *key = SWIG_This(); - PyObject_SetAttr(inst, key, swig_this); -#endif - } - } else { - PyObject *dict = PyDict_New(); - PyDict_SetItem(dict, SWIG_This(), swig_this); - inst = PyInstance_NewRaw(data->newargs, dict); - Py_DECREF(dict); - } - return inst; -#else -#if (PY_VERSION_HEX >= 0x02010000) - PyObject *inst; - PyObject *dict = PyDict_New(); - PyDict_SetItem(dict, SWIG_This(), swig_this); - inst = PyInstance_NewRaw(data->newargs, dict); - Py_DECREF(dict); - return (PyObject *) inst; -#else - PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type); - if (inst == NULL) { - return NULL; - } - inst->in_class = (PyClassObject *)data->newargs; - Py_INCREF(inst->in_class); - inst->in_dict = PyDict_New(); - if (inst->in_dict == NULL) { - Py_DECREF(inst); - return NULL; - } -#ifdef Py_TPFLAGS_HAVE_WEAKREFS - inst->in_weakreflist = NULL; -#endif -#ifdef Py_TPFLAGS_GC - PyObject_GC_Init(inst); -#endif - PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this); - return (PyObject *) inst; -#endif -#endif -} - -SWIGRUNTIME void -SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) -{ - PyObject *dict; -#if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS) - PyObject **dictptr = _PyObject_GetDictPtr(inst); - if (dictptr != NULL) { - dict = *dictptr; - if (dict == NULL) { - dict = PyDict_New(); - *dictptr = dict; - } - PyDict_SetItem(dict, SWIG_This(), swig_this); - return; - } -#endif - dict = PyObject_GetAttrString(inst, (char*)"__dict__"); - PyDict_SetItem(dict, SWIG_This(), swig_this); - Py_DECREF(dict); -} - - -SWIGINTERN PyObject * -SWIG_Python_InitShadowInstance(PyObject *args) { - PyObject *obj[2]; - if (!SWIG_Python_UnpackTuple(args,(char*)"swiginit", 2, 2, obj)) { - return NULL; - } else { - PySwigObject *sthis = SWIG_Python_GetSwigThis(obj[0]); - if (sthis) { - PySwigObject_append((PyObject*) sthis, obj[1]); - } else { - SWIG_Python_SetSwigThis(obj[0], obj[1]); - } - return SWIG_Py_Void(); - } -} - -/* Create a new pointer object */ - -SWIGRUNTIME PyObject * -SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int flags) { - if (!ptr) { - return SWIG_Py_Void(); - } else { - int own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0; - PyObject *robj = PySwigObject_New(ptr, type, own); - PySwigClientData *clientdata = type ? (PySwigClientData *)(type->clientdata) : 0; - if (clientdata && !(flags & SWIG_POINTER_NOSHADOW)) { - PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj); - if (inst) { - Py_DECREF(robj); - robj = inst; - } - } - return robj; - } -} - -/* Create a new packed object */ - -SWIGRUNTIMEINLINE PyObject * -SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { - return ptr ? PySwigPacked_New((void *) ptr, sz, type) : SWIG_Py_Void(); -} - -/* -----------------------------------------------------------------------------* - * Get type list - * -----------------------------------------------------------------------------*/ - -#ifdef SWIG_LINK_RUNTIME -void *SWIG_ReturnGlobalTypeList(void *); -#endif - -SWIGRUNTIME swig_module_info * -SWIG_Python_GetModule(void) { - static void *type_pointer = (void *)0; - /* first check if module already created */ - if (!type_pointer) { -#ifdef SWIG_LINK_RUNTIME - type_pointer = SWIG_ReturnGlobalTypeList((void *)0); -#else - type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, - (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); - if (PyErr_Occurred()) { - PyErr_Clear(); - type_pointer = (void *)0; - } -#endif - } - return (swig_module_info *) type_pointer; -} - -#if PY_MAJOR_VERSION < 2 -/* PyModule_AddObject function was introduced in Python 2.0. The following function - is copied out of Python/modsupport.c in python version 2.3.4 */ -SWIGINTERN int -PyModule_AddObject(PyObject *m, char *name, PyObject *o) -{ - PyObject *dict; - if (!PyModule_Check(m)) { - PyErr_SetString(PyExc_TypeError, - "PyModule_AddObject() needs module as first arg"); - return SWIG_ERROR; - } - if (!o) { - PyErr_SetString(PyExc_TypeError, - "PyModule_AddObject() needs non-NULL value"); - return SWIG_ERROR; - } - - dict = PyModule_GetDict(m); - if (dict == NULL) { - /* Internal error -- modules must have a dict! */ - PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", - PyModule_GetName(m)); - return SWIG_ERROR; - } - if (PyDict_SetItemString(dict, name, o)) - return SWIG_ERROR; - Py_DECREF(o); - return SWIG_OK; -} -#endif - -SWIGRUNTIME void -SWIG_Python_DestroyModule(void *vptr) -{ - swig_module_info *swig_module = (swig_module_info *) vptr; - swig_type_info **types = swig_module->types; - size_t i; - for (i =0; i < swig_module->size; ++i) { - swig_type_info *ty = types[i]; - if (ty->owndata) { - PySwigClientData *data = (PySwigClientData *) ty->clientdata; - if (data) PySwigClientData_Del(data); - } - } - Py_DECREF(SWIG_This()); -} - -SWIGRUNTIME void -SWIG_Python_SetModule(swig_module_info *swig_module) { - static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */ - - PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, - swig_empty_runtime_method_table); - PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule); - if (pointer && module) { - PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); - } else { - Py_XDECREF(pointer); - } -} - -/* The python cached type query */ -SWIGRUNTIME PyObject * -SWIG_Python_TypeCache(void) { - static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New(); - return cache; -} - -SWIGRUNTIME swig_type_info * -SWIG_Python_TypeQuery(const char *type) -{ - PyObject *cache = SWIG_Python_TypeCache(); - PyObject *key = PyString_FromString(type); - PyObject *obj = PyDict_GetItem(cache, key); - swig_type_info *descriptor; - if (obj) { - descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj); - } else { - swig_module_info *swig_module = SWIG_Python_GetModule(); - descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); - if (descriptor) { - obj = PyCObject_FromVoidPtr(descriptor, NULL); - PyDict_SetItem(cache, key, obj); - Py_DECREF(obj); - } - } - Py_DECREF(key); - return descriptor; -} - -/* - For backward compatibility only -*/ -#define SWIG_POINTER_EXCEPTION 0 -#define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg) -#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags) - -SWIGRUNTIME int -SWIG_Python_AddErrMesg(const char* mesg, int infront) -{ - if (PyErr_Occurred()) { - PyObject *type = 0; - PyObject *value = 0; - PyObject *traceback = 0; - PyErr_Fetch(&type, &value, &traceback); - if (value) { - PyObject *old_str = PyObject_Str(value); - Py_XINCREF(type); - PyErr_Clear(); - if (infront) { - PyErr_Format(type, "%s %s", mesg, PyString_AsString(old_str)); - } else { - PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg); - } - Py_DECREF(old_str); - } - return 1; - } else { - return 0; - } -} - -SWIGRUNTIME int -SWIG_Python_ArgFail(int argnum) -{ - if (PyErr_Occurred()) { - /* add information about failing argument */ - char mesg[256]; - PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum); - return SWIG_Python_AddErrMesg(mesg, 1); - } else { - return 0; - } -} - -SWIGRUNTIMEINLINE const char * -PySwigObject_GetDesc(PyObject *self) -{ - PySwigObject *v = (PySwigObject *)self; - swig_type_info *ty = v ? v->ty : 0; - return ty ? ty->str : (char*)""; -} - -SWIGRUNTIME void -SWIG_Python_TypeError(const char *type, PyObject *obj) -{ - if (type) { -#if defined(SWIG_COBJECT_TYPES) - if (obj && PySwigObject_Check(obj)) { - const char *otype = (const char *) PySwigObject_GetDesc(obj); - if (otype) { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'PySwigObject(%s)' is received", - type, otype); - return; - } - } else -#endif - { - const char *otype = (obj ? obj->ob_type->tp_name : 0); - if (otype) { - PyObject *str = PyObject_Str(obj); - const char *cstr = str ? PyString_AsString(str) : 0; - if (cstr) { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", - type, otype, cstr); - } else { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", - type, otype); - } - Py_XDECREF(str); - return; - } - } - PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); - } else { - PyErr_Format(PyExc_TypeError, "unexpected type is received"); - } -} - - -/* Convert a pointer value, signal an exception on a type mismatch */ -SWIGRUNTIME void * -SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) { - void *result; - if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { - PyErr_Clear(); - if (flags & SWIG_POINTER_EXCEPTION) { - SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); - SWIG_Python_ArgFail(argnum); - } - } - return result; -} - - -#ifdef __cplusplus -#if 0 -{ /* cc-mode */ -#endif -} -#endif -/* -----------------------------------------------------------------------------* - Standard SWIG API for use inside user code. - - Don't include this file directly, run the command - swig -python -external-runtime - Also, read the Modules chapter of the SWIG Manual. - - * -----------------------------------------------------------------------------*/ - -#ifdef SWIG_MODULE_CLIENTDATA_TYPE - -SWIGRUNTIMEINLINE swig_type_info * -SWIG_TypeQuery(SWIG_MODULE_CLIENTDATA_TYPE clientdata, const char *name) { - swig_module_info *module = SWIG_GetModule(clientdata); - return SWIG_TypeQueryModule(module, module, name); -} - -SWIGRUNTIMEINLINE swig_type_info * -SWIG_MangledTypeQuery(SWIG_MODULE_CLIENTDATA_TYPE clientdata, const char *name) { - swig_module_info *module = SWIG_GetModule(clientdata); - return SWIG_MangledTypeQueryModule(module, module, name); -} - -#else - -SWIGRUNTIMEINLINE swig_type_info * -SWIG_TypeQuery(const char *name) { - swig_module_info *module = SWIG_GetModule(NULL); - return SWIG_TypeQueryModule(module, module, name); -} - -SWIGRUNTIMEINLINE swig_type_info * -SWIG_MangledTypeQuery(const char *name) { - swig_module_info *module = SWIG_GetModule(NULL); - return SWIG_MangledTypeQueryModule(module, module, name); -} - -#endif diff --git a/src/Base/swigpyrun_1.3.36.cpp b/src/Base/swigpyrun_1.3.36.cpp deleted file mode 100644 index 7a35a164f3..0000000000 --- a/src/Base/swigpyrun_1.3.36.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2008 Werner Mayer * - * * - * 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" -#include "PyExport.h" -#include "Exception.h" -#include -#if defined(__clang__) -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wdeprecated-register" -# pragma clang diagnostic ignored "-Wself-assign" -#elif defined (__GNUC__) -# pragma GCC diagnostic push -# if __GNUC__ >= 8 -# pragma GCC diagnostic ignored "-Wcast-function-type" -# endif -#endif -namespace Swig_1_3_36 { -#define SWIG_PYTHON_NO_BUILD_NONE -#include "swigpyrun_1.3.36.h" -#include "swigpyrun.inl" -} -#if defined(__clang__) -# pragma clang diagnostic pop -#elif defined (__GNUC__) -# pragma GCC diagnostic pop -#endif - diff --git a/src/Base/swigpyrun_1.3.36.h b/src/Base/swigpyrun_1.3.36.h deleted file mode 100644 index 12ad41e12a..0000000000 --- a/src/Base/swigpyrun_1.3.36.h +++ /dev/null @@ -1,2527 +0,0 @@ -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.36 - * - * This file is not intended to be easily readable and contains a number of - * coding conventions designed to improve portability and efficiency. Do not make - * changes to this file unless you know what you are doing--modify the SWIG - * interface file instead. - * ----------------------------------------------------------------------------- */ - -/* ----------------------------------------------------------------------------- - * This section contains generic SWIG labels for method/variable - * declarations/attributes, and other compiler dependent labels. - * ----------------------------------------------------------------------------- */ - -/* template workaround for compilers that cannot correctly implement the C++ standard */ -#ifndef SWIGTEMPLATEDISAMBIGUATOR -# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) -# define SWIGTEMPLATEDISAMBIGUATOR template -# elif defined(__HP_aCC) -/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ -/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ -# define SWIGTEMPLATEDISAMBIGUATOR template -# else -# define SWIGTEMPLATEDISAMBIGUATOR -# endif -#endif - -/* inline attribute */ -#ifndef SWIGINLINE -# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) -# define SWIGINLINE inline -# else -# define SWIGINLINE -# endif -#endif - -/* attribute recognised by some compilers to avoid 'unused' warnings */ -#ifndef SWIGUNUSED -# if defined(__GNUC__) -# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define SWIGUNUSED __attribute__ ((__unused__)) -# else -# define SWIGUNUSED -# endif -# elif defined(__ICC) -# define SWIGUNUSED __attribute__ ((__unused__)) -# else -# define SWIGUNUSED -# endif -#endif - -#ifndef SWIG_MSC_UNSUPPRESS_4505 -# if defined(_MSC_VER) -# pragma warning(disable : 4505) /* unreferenced local function has been removed */ -# endif -#endif - -#ifndef SWIGUNUSEDPARM -# ifdef __cplusplus -# define SWIGUNUSEDPARM(p) -# else -# define SWIGUNUSEDPARM(p) p SWIGUNUSED -# endif -#endif - -/* internal SWIG method */ -#ifndef SWIGINTERN -# define SWIGINTERN static SWIGUNUSED -#endif - -/* internal inline SWIG method */ -#ifndef SWIGINTERNINLINE -# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE -#endif - -/* exporting methods */ -#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY -# endif -#endif - -#ifndef SWIGEXPORT -# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# if defined(STATIC_LINKED) -# define SWIGEXPORT -# else -# define SWIGEXPORT __declspec(dllexport) -# endif -# else -# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) -# define SWIGEXPORT __attribute__ ((visibility("default"))) -# else -# define SWIGEXPORT -# endif -# endif -#endif - -/* calling conventions for Windows */ -#ifndef SWIGSTDCALL -# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# define SWIGSTDCALL __stdcall -# else -# define SWIGSTDCALL -# endif -#endif - -/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ -#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) -# define _CRT_SECURE_NO_DEPRECATE -#endif - -/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ -#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) -# define _SCL_SECURE_NO_DEPRECATE -#endif - -/* Errors in SWIG */ -#define SWIG_UnknownError -1 -#define SWIG_IOError -2 -#define SWIG_RuntimeError -3 -#define SWIG_IndexError -4 -#define SWIG_TypeError -5 -#define SWIG_DivisionByZero -6 -#define SWIG_OverflowError -7 -#define SWIG_SyntaxError -8 -#define SWIG_ValueError -9 -#define SWIG_SystemError -10 -#define SWIG_AttributeError -11 -#define SWIG_MemoryError -12 -#define SWIG_NullReferenceError -13 - - -/* Errors in SWIG */ -#define SWIG_UnknownError -1 -#define SWIG_IOError -2 -#define SWIG_RuntimeError -3 -#define SWIG_IndexError -4 -#define SWIG_TypeError -5 -#define SWIG_DivisionByZero -6 -#define SWIG_OverflowError -7 -#define SWIG_SyntaxError -8 -#define SWIG_ValueError -9 -#define SWIG_SystemError -10 -#define SWIG_AttributeError -11 -#define SWIG_MemoryError -12 -#define SWIG_NullReferenceError -13 - - -/* ----------------------------------------------------------------------------- - * swigrun.swg - * - * This file contains generic CAPI SWIG runtime support for pointer - * type checking. - * ----------------------------------------------------------------------------- */ - -/* This should only be incremented when either the layout of swig_type_info changes, - or for whatever reason, the runtime changes incompatibly */ -#define SWIG_RUNTIME_VERSION "4" - -/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ -#ifdef SWIG_TYPE_TABLE -# define SWIG_QUOTE_STRING(x) #x -# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) -# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) -#else -# define SWIG_TYPE_TABLE_NAME -#endif - -/* - You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for - creating a static or dynamic library from the swig runtime code. - In 99.9% of the cases, swig just needs to declare them as 'static'. - - But only do this if is strictly necessary, ie, if you have problems - with your compiler or so. -*/ - -#ifndef SWIGRUNTIME -# define SWIGRUNTIME SWIGINTERN -#endif - -#ifndef SWIGRUNTIMEINLINE -# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE -#endif - -/* Generic buffer size */ -#ifndef SWIG_BUFFER_SIZE -# define SWIG_BUFFER_SIZE 1024 -#endif - -/* Flags for pointer conversions */ -#define SWIG_POINTER_DISOWN 0x1 -#define SWIG_CAST_NEW_MEMORY 0x2 - -/* Flags for new pointer objects */ -#define SWIG_POINTER_OWN 0x1 - - -/* - Flags/methods for returning states. - - The swig conversion methods, as ConvertPtr, return and integer - that tells if the conversion was successful or not. And if not, - an error code can be returned (see swigerrors.swg for the codes). - - Use the following macros/flags to set or process the returning - states. - - In old swig versions, you usually write code as: - - if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { - // success code - } else { - //fail code - } - - Now you can be more explicit as: - - int res = SWIG_ConvertPtr(obj,vptr,ty.flags); - if (SWIG_IsOK(res)) { - // success code - } else { - // fail code - } - - that seems to be the same, but now you can also do - - Type *ptr; - int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); - if (SWIG_IsOK(res)) { - // success code - if (SWIG_IsNewObj(res) { - ... - delete *ptr; - } else { - ... - } - } else { - // fail code - } - - I.e., now SWIG_ConvertPtr can return new objects and you can - identify the case and take care of the deallocation. Of course that - requires also to SWIG_ConvertPtr to return new result values, as - - int SWIG_ConvertPtr(obj, ptr,...) { - if () { - if () { - *ptr = ; - return SWIG_NEWOBJ; - } else { - *ptr = ; - return SWIG_OLDOBJ; - } - } else { - return SWIG_BADOBJ; - } - } - - Of course, returning the plain '0(success)/-1(fail)' still works, but you can be - more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the - swig errors code. - - Finally, if the SWIG_CASTRANK_MODE is enabled, the result code - allows to return the 'cast rank', for example, if you have this - - int food(double) - int fooi(int); - - and you call - - food(1) // cast rank '1' (1 -> 1.0) - fooi(1) // cast rank '0' - - just use the SWIG_AddCast()/SWIG_CheckState() - - - */ -#define SWIG_OK (0) -#define SWIG_ERROR (-1) -#define SWIG_IsOK(r) (r >= 0) -#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) - -/* The CastRankLimit says how many bits are used for the cast rank */ -#define SWIG_CASTRANKLIMIT (1 << 8) -/* The NewMask denotes the object was created (using new/malloc) */ -#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1) -/* The TmpMask is for in/out typemaps that use temporal objects */ -#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1) -/* Simple returning values */ -#define SWIG_BADOBJ (SWIG_ERROR) -#define SWIG_OLDOBJ (SWIG_OK) -#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK) -#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK) -/* Check, add and del mask methods */ -#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r) -#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r) -#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK)) -#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r) -#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) -#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) - - -/* Cast-Rank Mode */ -#if defined(SWIG_CASTRANK_MODE) -# ifndef SWIG_TypeRank -# define SWIG_TypeRank unsigned long -# endif -# ifndef SWIG_MAXCASTRANK /* Default cast allowed */ -# define SWIG_MAXCASTRANK (2) -# endif -# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) -# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) -SWIGINTERNINLINE int SWIG_AddCast(int r) { - return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; -} -SWIGINTERNINLINE int SWIG_CheckState(int r) { - return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; -} -#else /* no cast-rank mode */ -# define SWIG_AddCast -# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) -#endif - - - - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void *(*swig_converter_func)(void *, int *); -typedef struct swig_type_info *(*swig_dycast_func)(void **); - -/* Structure to store information on one type */ -typedef struct swig_type_info { - const char *name; /* mangled name of this type */ - const char *str; /* human readable name of this type */ - swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ - struct swig_cast_info *cast; /* linked list of types that can cast into this type */ - void *clientdata; /* language specific type data */ - int owndata; /* flag if the structure owns the clientdata */ -} swig_type_info; - -/* Structure to store a type and conversion function used for casting */ -typedef struct swig_cast_info { - swig_type_info *type; /* pointer to type that is equivalent to this type */ - swig_converter_func converter; /* function to cast the void pointers */ - struct swig_cast_info *next; /* pointer to next cast in linked list */ - struct swig_cast_info *prev; /* pointer to the previous cast */ -} swig_cast_info; - -/* Structure used to store module information - * Each module generates one structure like this, and the runtime collects - * all of these structures and stores them in a circularly linked list.*/ -typedef struct swig_module_info { - swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ - size_t size; /* Number of types in this module */ - struct swig_module_info *next; /* Pointer to next element in circularly linked list */ - swig_type_info **type_initial; /* Array of initially generated type structures */ - swig_cast_info **cast_initial; /* Array of initially generated casting structures */ - void *clientdata; /* Language specific module data */ -} swig_module_info; - -/* - Compare two type names skipping the space characters, therefore - "char*" == "char *" and "Class" == "Class", etc. - - Return 0 when the two name types are equivalent, as in - strncmp, but skipping ' '. -*/ -SWIGRUNTIME int -SWIG_TypeNameComp(const char *f1, const char *l1, - const char *f2, const char *l2) { - for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { - while ((*f1 == ' ') && (f1 != l1)) ++f1; - while ((*f2 == ' ') && (f2 != l2)) ++f2; - if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; - } - return (int)((l1 - f1) - (l2 - f2)); -} - -/* - Check type equivalence in a name list like ||... - Return 0 if not equal, 1 if equal -*/ -SWIGRUNTIME int -SWIG_TypeEquiv(const char *nb, const char *tb) { - int equiv = 0; - const char* te = tb + strlen(tb); - const char* ne = nb; - while (!equiv && *ne) { - for (nb = ne; *ne; ++ne) { - if (*ne == '|') break; - } - equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; - if (*ne) ++ne; - } - return equiv; -} - -/* - Check type equivalence in a name list like ||... - Return 0 if equal, -1 if nb < tb, 1 if nb > tb -*/ -SWIGRUNTIME int -SWIG_TypeCompare(const char *nb, const char *tb) { - int equiv = 0; - const char* te = tb + strlen(tb); - const char* ne = nb; - while (!equiv && *ne) { - for (nb = ne; *ne; ++ne) { - if (*ne == '|') break; - } - equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; - if (*ne) ++ne; - } - return equiv; -} - - -/* think of this as a c++ template<> or a scheme macro */ -#define SWIG_TypeCheck_Template(comparison, ty) \ - if (ty) { \ - swig_cast_info *iter = ty->cast; \ - while (iter) { \ - if (comparison) { \ - if (iter == ty->cast) return iter; \ - /* Move iter to the top of the linked list */ \ - iter->prev->next = iter->next; \ - if (iter->next) \ - iter->next->prev = iter->prev; \ - iter->next = ty->cast; \ - iter->prev = 0; \ - if (ty->cast) ty->cast->prev = iter; \ - ty->cast = iter; \ - return iter; \ - } \ - iter = iter->next; \ - } \ - } \ - return 0 - -/* - Check the typename -*/ -SWIGRUNTIME swig_cast_info * -SWIG_TypeCheck(const char *c, swig_type_info *ty) { - SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty); -} - -/* Same as previous function, except strcmp is replaced with a pointer comparison */ -SWIGRUNTIME swig_cast_info * -SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) { - SWIG_TypeCheck_Template(iter->type == from, into); -} - -/* - Cast a pointer up an inheritance hierarchy -*/ -SWIGRUNTIMEINLINE void * -SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { - return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); -} - -/* - Dynamic pointer casting. Down an inheritance hierarchy -*/ -SWIGRUNTIME swig_type_info * -SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { - swig_type_info *lastty = ty; - if (!ty || !ty->dcast) return ty; - while (ty && (ty->dcast)) { - ty = (*ty->dcast)(ptr); - if (ty) lastty = ty; - } - return lastty; -} - -/* - Return the name associated with this type -*/ -SWIGRUNTIMEINLINE const char * -SWIG_TypeName(const swig_type_info *ty) { - return ty->name; -} - -/* - Return the pretty name associated with this type, - that is an unmangled type name in a form presentable to the user. -*/ -SWIGRUNTIME const char * -SWIG_TypePrettyName(const swig_type_info *type) { - /* The "str" field contains the equivalent pretty names of the - type, separated by vertical-bar characters. We choose - to print the last name, as it is often (?) the most - specific. */ - if (!type) return NULL; - if (type->str != NULL) { - const char *last_name = type->str; - const char *s; - for (s = type->str; *s; s++) - if (*s == '|') last_name = s+1; - return last_name; - } - else - return type->name; -} - -/* - Set the clientdata field for a type -*/ -SWIGRUNTIME void -SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { - swig_cast_info *cast = ti->cast; - /* if (ti->clientdata == clientdata) return; */ - ti->clientdata = clientdata; - - while (cast) { - if (!cast->converter) { - swig_type_info *tc = cast->type; - if (!tc->clientdata) { - SWIG_TypeClientData(tc, clientdata); - } - } - cast = cast->next; - } -} -SWIGRUNTIME void -SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { - SWIG_TypeClientData(ti, clientdata); - ti->owndata = 1; -} - -/* - Search for a swig_type_info structure only by mangled name - Search is a O(log #types) - - We start searching at module start, and finish searching when start == end. - Note: if start == end at the beginning of the function, we go all the way around - the circular list. -*/ -SWIGRUNTIME swig_type_info * -SWIG_MangledTypeQueryModule(swig_module_info *start, - swig_module_info *end, - const char *name) { - swig_module_info *iter = start; - do { - if (iter->size) { - register size_t l = 0; - register size_t r = iter->size - 1; - do { - /* since l+r >= 0, we can (>> 1) instead (/ 2) */ - register size_t i = (l + r) >> 1; - const char *iname = iter->types[i]->name; - if (iname) { - register int compare = strcmp(name, iname); - if (compare == 0) { - return iter->types[i]; - } else if (compare < 0) { - if (i) { - r = i - 1; - } else { - break; - } - } else if (compare > 0) { - l = i + 1; - } - } else { - break; /* should never happen */ - } - } while (l <= r); - } - iter = iter->next; - } while (iter != end); - return 0; -} - -/* - Search for a swig_type_info structure for either a mangled name or a human readable name. - It first searches the mangled names of the types, which is a O(log #types) - If a type is not found it then searches the human readable names, which is O(#types). - - We start searching at module start, and finish searching when start == end. - Note: if start == end at the beginning of the function, we go all the way around - the circular list. -*/ -SWIGRUNTIME swig_type_info * -SWIG_TypeQueryModule(swig_module_info *start, - swig_module_info *end, - const char *name) { - /* STEP 1: Search the name field using binary search */ - swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); - if (ret) { - return ret; - } else { - /* STEP 2: If the type hasn't been found, do a complete search - of the str field (the human readable name) */ - swig_module_info *iter = start; - do { - register size_t i = 0; - for (; i < iter->size; ++i) { - if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) - return iter->types[i]; - } - iter = iter->next; - } while (iter != end); - } - - /* neither found a match */ - return 0; -} - -/* - Pack binary data into a string -*/ -SWIGRUNTIME char * -SWIG_PackData(char *c, void *ptr, size_t sz) { - static const char hex[17] = "0123456789abcdef"; - register const unsigned char *u = (unsigned char *) ptr; - register const unsigned char *eu = u + sz; - for (; u != eu; ++u) { - register unsigned char uu = *u; - *(c++) = hex[(uu & 0xf0) >> 4]; - *(c++) = hex[uu & 0xf]; - } - return c; -} - -/* - Unpack binary data from a string -*/ -SWIGRUNTIME const char * -SWIG_UnpackData(const char *c, void *ptr, size_t sz) { - register unsigned char *u = (unsigned char *) ptr; - register const unsigned char *eu = u + sz; - for (; u != eu; ++u) { - register char d = *(c++); - register unsigned char uu; - if ((d >= '0') && (d <= '9')) - uu = ((d - '0') << 4); - else if ((d >= 'a') && (d <= 'f')) - uu = ((d - ('a'-10)) << 4); - else - return (char *) 0; - d = *(c++); - if ((d >= '0') && (d <= '9')) - uu |= (d - '0'); - else if ((d >= 'a') && (d <= 'f')) - uu |= (d - ('a'-10)); - else - return (char *) 0; - *u = uu; - } - return c; -} - -/* - Pack 'void *' into a string buffer. -*/ -SWIGRUNTIME char * -SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { - char *r = buff; - if ((2*sizeof(void *) + 2) > bsz) return 0; - *(r++) = '_'; - r = SWIG_PackData(r,&ptr,sizeof(void *)); - if (strlen(name) + 1 > (bsz - (r - buff))) return 0; - strcpy(r,name); - return buff; -} - -SWIGRUNTIME const char * -SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { - if (*c != '_') { - if (strcmp(c,"NULL") == 0) { - *ptr = (void *) 0; - return name; - } else { - return 0; - } - } - return SWIG_UnpackData(++c,ptr,sizeof(void *)); -} - -SWIGRUNTIME char * -SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { - char *r = buff; - size_t lname = (name ? strlen(name) : 0); - if ((2*sz + 2 + lname) > bsz) return 0; - *(r++) = '_'; - r = SWIG_PackData(r,ptr,sz); - if (lname) { - strncpy(r,name,lname+1); - } else { - *r = 0; - } - return buff; -} - -SWIGRUNTIME const char * -SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { - if (*c != '_') { - if (strcmp(c,"NULL") == 0) { - memset(ptr,0,sz); - return name; - } else { - return 0; - } - } - return SWIG_UnpackData(++c,ptr,sz); -} - -#ifdef __cplusplus -} -#endif - -/* Add PyOS_snprintf for old Pythons */ -#if PY_VERSION_HEX < 0x02020000 -# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) -# define PyOS_snprintf _snprintf -# else -# define PyOS_snprintf snprintf -# endif -#endif - -/* A crude PyString_FromFormat implementation for old Pythons */ -#if PY_VERSION_HEX < 0x02020000 - -#ifndef SWIG_PYBUFFER_SIZE -# define SWIG_PYBUFFER_SIZE 1024 -#endif - -static PyObject * -PyString_FromFormat(const char *fmt, ...) { - va_list ap; - char buf[SWIG_PYBUFFER_SIZE * 2]; - int res; - va_start(ap, fmt); - res = vsnprintf(buf, sizeof(buf), fmt, ap); - va_end(ap); - return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf); -} -#endif - -/* Add PyObject_Del for old Pythons */ -#if PY_VERSION_HEX < 0x01060000 -# define PyObject_Del(op) PyMem_DEL((op)) -#endif -#ifndef PyObject_DEL -# define PyObject_DEL PyObject_Del -#endif - -/* A crude PyExc_StopIteration exception for old Pythons */ -#if PY_VERSION_HEX < 0x02020000 -# ifndef PyExc_StopIteration -# define PyExc_StopIteration PyExc_RuntimeError -# endif -# ifndef PyObject_GenericGetAttr -# define PyObject_GenericGetAttr 0 -# endif -#endif -/* Py_NotImplemented is defined in 2.1 and up. */ -#if PY_VERSION_HEX < 0x02010000 -# ifndef Py_NotImplemented -# define Py_NotImplemented PyExc_RuntimeError -# endif -#endif - - -/* A crude PyString_AsStringAndSize implementation for old Pythons */ -#if PY_VERSION_HEX < 0x02010000 -# ifndef PyString_AsStringAndSize -# define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;} -# endif -#endif - -/* PySequence_Size for old Pythons */ -#if PY_VERSION_HEX < 0x02000000 -# ifndef PySequence_Size -# define PySequence_Size PySequence_Length -# endif -#endif - - -/* PyBool_FromLong for old Pythons */ -#if PY_VERSION_HEX < 0x02030000 -static -PyObject *PyBool_FromLong(long ok) -{ - PyObject *result = ok ? Py_True : Py_False; - Py_INCREF(result); - return result; -} -#endif - -/* Py_ssize_t for old Pythons */ -/* This code is as recommended by: */ -/* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */ -#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) -typedef int Py_ssize_t; -# define PY_SSIZE_T_MAX INT_MAX -# define PY_SSIZE_T_MIN INT_MIN -#endif -/* ----------------------------------------------------------------------------- - * error manipulation - * ----------------------------------------------------------------------------- */ - -SWIGRUNTIME PyObject* -SWIG_Python_ErrorType(int code) { - PyObject* type = 0; - switch(code) { - case SWIG_MemoryError: - type = PyExc_MemoryError; - break; - case SWIG_IOError: - type = PyExc_IOError; - break; - case SWIG_RuntimeError: - type = PyExc_RuntimeError; - break; - case SWIG_IndexError: - type = PyExc_IndexError; - break; - case SWIG_TypeError: - type = PyExc_TypeError; - break; - case SWIG_DivisionByZero: - type = PyExc_ZeroDivisionError; - break; - case SWIG_OverflowError: - type = PyExc_OverflowError; - break; - case SWIG_SyntaxError: - type = PyExc_SyntaxError; - break; - case SWIG_ValueError: - type = PyExc_ValueError; - break; - case SWIG_SystemError: - type = PyExc_SystemError; - break; - case SWIG_AttributeError: - type = PyExc_AttributeError; - break; - default: - type = PyExc_RuntimeError; - } - return type; -} - - -SWIGRUNTIME void -SWIG_Python_AddErrorMsg(const char* mesg) -{ - PyObject *type = 0; - PyObject *value = 0; - PyObject *traceback = 0; - - if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback); - if (value) { - PyObject *old_str = PyObject_Str(value); - PyErr_Clear(); - Py_XINCREF(type); - PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg); - Py_DECREF(old_str); - Py_DECREF(value); - } else { - PyErr_SetString(PyExc_RuntimeError, mesg); - } -} - - -#if defined(SWIG_PYTHON_NO_THREADS) -# if defined(SWIG_PYTHON_THREADS) -# undef SWIG_PYTHON_THREADS -# endif -#endif -#if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */ -# if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL) -# if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */ -# define SWIG_PYTHON_USE_GIL -# endif -# endif -# if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */ -# ifndef SWIG_PYTHON_INITIALIZE_THREADS -# define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads() -# endif -# ifdef __cplusplus /* C++ code */ - class SWIG_Python_Thread_Block { - bool status; - PyGILState_STATE state; - public: - void end() { if (status) { PyGILState_Release(state); status = false;} } - SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {} - ~SWIG_Python_Thread_Block() { end(); } - }; - class SWIG_Python_Thread_Allow { - bool status; - PyThreadState *save; - public: - void end() { if (status) { PyEval_RestoreThread(save); status = false; }} - SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {} - ~SWIG_Python_Thread_Allow() { end(); } - }; -# define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block -# define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end() -# define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow -# define SWIG_PYTHON_THREAD_END_ALLOW _swig_thread_allow.end() -# else /* C code */ -# define SWIG_PYTHON_THREAD_BEGIN_BLOCK PyGILState_STATE _swig_thread_block = PyGILState_Ensure() -# define SWIG_PYTHON_THREAD_END_BLOCK PyGILState_Release(_swig_thread_block) -# define SWIG_PYTHON_THREAD_BEGIN_ALLOW PyThreadState *_swig_thread_allow = PyEval_SaveThread() -# define SWIG_PYTHON_THREAD_END_ALLOW PyEval_RestoreThread(_swig_thread_allow) -# endif -# else /* Old thread way, not implemented, user must provide it */ -# if !defined(SWIG_PYTHON_INITIALIZE_THREADS) -# define SWIG_PYTHON_INITIALIZE_THREADS -# endif -# if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK) -# define SWIG_PYTHON_THREAD_BEGIN_BLOCK -# endif -# if !defined(SWIG_PYTHON_THREAD_END_BLOCK) -# define SWIG_PYTHON_THREAD_END_BLOCK -# endif -# if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW) -# define SWIG_PYTHON_THREAD_BEGIN_ALLOW -# endif -# if !defined(SWIG_PYTHON_THREAD_END_ALLOW) -# define SWIG_PYTHON_THREAD_END_ALLOW -# endif -# endif -#else /* No thread support */ -# define SWIG_PYTHON_INITIALIZE_THREADS -# define SWIG_PYTHON_THREAD_BEGIN_BLOCK -# define SWIG_PYTHON_THREAD_END_BLOCK -# define SWIG_PYTHON_THREAD_BEGIN_ALLOW -# define SWIG_PYTHON_THREAD_END_ALLOW -#endif -/* ----------------------------------------------------------------------------- - * Python API portion that goes into the runtime - * ----------------------------------------------------------------------------- */ - -#ifdef __cplusplus -extern "C" { -#if 0 -} /* cc-mode */ -#endif -#endif - -/* ----------------------------------------------------------------------------- - * Constant declarations - * ----------------------------------------------------------------------------- */ - -/* Constant Types */ -#define SWIG_PY_POINTER 4 -#define SWIG_PY_BINARY 5 - -/* Constant information structure */ -typedef struct swig_const_info { - int type; - char *name; - long lvalue; - double dvalue; - void *pvalue; - swig_type_info **ptype; -} swig_const_info; - -#ifdef __cplusplus -#if 0 -{ /* cc-mode */ -#endif -} -#endif - -/* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * - * pyrun.swg - * - * This file contains the runtime support for Python modules - * and includes code for managing global variables and pointer - * type checking. - * - * ----------------------------------------------------------------------------- */ - -/* Common SWIG API */ - -/* for raw pointers */ -#define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0) -#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags) -#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own) -#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(ptr, type, flags) -#define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty) -#define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src) -#define swig_owntype int - -/* for raw packed data */ -#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) -#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) - -/* for class or struct pointers */ -#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) -#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) - -/* for C or C++ function pointers */ -#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type) -#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(ptr, type, 0) - -/* for C++ member pointers, ie, member methods */ -#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) -#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) - - -/* Runtime API */ - -#define SWIG_GetModule(clientdata) SWIG_Python_GetModule() -#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) -#define SWIG_NewClientData(obj) PySwigClientData_New(obj) - -#define SWIG_SetErrorObj SWIG_Python_SetErrorObj -#define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg -#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code) -#define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) -#define SWIG_fail goto fail - - -/* Runtime API implementation */ - -/* Error manipulation */ - -SWIGINTERN void -SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyErr_SetObject(errtype, obj); - Py_DECREF(obj); - SWIG_PYTHON_THREAD_END_BLOCK; -} - -SWIGINTERN void -SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyErr_SetString(errtype, (char *) msg); - SWIG_PYTHON_THREAD_END_BLOCK; -} - -#define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj) - -/* Set a constant value */ - -SWIGINTERN void -SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { - PyDict_SetItemString(d, (char*) name, obj); - Py_DECREF(obj); -} - -/* Append a value to the result obj */ - -SWIGINTERN PyObject* -SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { -#if !defined(SWIG_PYTHON_OUTPUT_TUPLE) - if (!result) { - result = obj; - } else if (result == Py_None) { - Py_DECREF(result); - result = obj; - } else { - if (!PyList_Check(result)) { - PyObject *o2 = result; - result = PyList_New(1); - PyList_SetItem(result, 0, o2); - } - PyList_Append(result,obj); - Py_DECREF(obj); - } - return result; -#else - PyObject* o2; - PyObject* o3; - if (!result) { - result = obj; - } else if (result == Py_None) { - Py_DECREF(result); - result = obj; - } else { - if (!PyTuple_Check(result)) { - o2 = result; - result = PyTuple_New(1); - PyTuple_SET_ITEM(result, 0, o2); - } - o3 = PyTuple_New(1); - PyTuple_SET_ITEM(o3, 0, obj); - o2 = result; - result = PySequence_Concat(o2, o3); - Py_DECREF(o2); - Py_DECREF(o3); - } - return result; -#endif -} - -/* Unpack the argument tuple */ - -SWIGINTERN int -SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs) -{ - if (!args) { - if (!min && !max) { - return 1; - } else { - PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none", - name, (min == max ? "" : "at least "), (int)min); - return 0; - } - } - if (!PyTuple_Check(args)) { - PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple"); - return 0; - } else { - register Py_ssize_t l = PyTuple_GET_SIZE(args); - if (l < min) { - PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", - name, (min == max ? "" : "at least "), (int)min, (int)l); - return 0; - } else if (l > max) { - PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", - name, (min == max ? "" : "at most "), (int)max, (int)l); - return 0; - } else { - register int i; - for (i = 0; i < l; ++i) { - objs[i] = PyTuple_GET_ITEM(args, i); - } - for (; l < max; ++l) { - objs[l] = 0; - } - return i + 1; - } - } -} - -/* A functor is a function object with one single object argument */ -#if PY_VERSION_HEX >= 0x02020000 -#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL); -#else -#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj); -#endif - -/* - Helper for static pointer initialization for both C and C++ code, for example - static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...); -*/ -#ifdef __cplusplus -#define SWIG_STATIC_POINTER(var) var -#else -#define SWIG_STATIC_POINTER(var) var = 0; if (!var) var -#endif - -/* ----------------------------------------------------------------------------- - * Pointer declarations - * ----------------------------------------------------------------------------- */ - -/* Flags for new pointer objects */ -#define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1) -#define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN) - -#define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1) - -#ifdef __cplusplus -extern "C" { -#if 0 -} /* cc-mode */ -#endif -#endif - -/* How to access Py_None */ -#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# ifndef SWIG_PYTHON_NO_BUILD_NONE -# ifndef SWIG_PYTHON_BUILD_NONE -# define SWIG_PYTHON_BUILD_NONE -# endif -# endif -#endif - -#ifdef SWIG_PYTHON_BUILD_NONE -# ifdef Py_None -# undef Py_None -# define Py_None SWIG_Py_None() -# endif -SWIGRUNTIMEINLINE PyObject * -_SWIG_Py_None(void) -{ - PyObject *none = Py_BuildValue((char*)""); - Py_DECREF(none); - return none; -} -SWIGRUNTIME PyObject * -SWIG_Py_None(void) -{ - static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None(); - return none; -} -#endif - -/* The python void return value */ - -SWIGRUNTIMEINLINE PyObject * -SWIG_Py_Void(void) -{ - PyObject *none = Py_None; - Py_INCREF(none); - return none; -} - -/* PySwigClientData */ - -typedef struct { - PyObject *klass; - PyObject *newraw; - PyObject *newargs; - PyObject *destroy; - int delargs; - int implicitconv; -} PySwigClientData; - -SWIGRUNTIMEINLINE int -SWIG_Python_CheckImplicit(swig_type_info *ty) -{ - PySwigClientData *data = (PySwigClientData *)ty->clientdata; - return data ? data->implicitconv : 0; -} - -SWIGRUNTIMEINLINE PyObject * -SWIG_Python_ExceptionType(swig_type_info *desc) { - PySwigClientData *data = desc ? (PySwigClientData *) desc->clientdata : 0; - PyObject *klass = data ? data->klass : 0; - return (klass ? klass : PyExc_RuntimeError); -} - - -SWIGRUNTIME PySwigClientData * -PySwigClientData_New(PyObject* obj) -{ - if (!obj) { - return 0; - } else { - PySwigClientData *data = (PySwigClientData *)malloc(sizeof(PySwigClientData)); - /* the klass element */ - data->klass = obj; - Py_INCREF(data->klass); - /* the newraw method and newargs arguments used to create a new raw instance */ - if (PyClass_Check(obj)) { - data->newraw = 0; - data->newargs = obj; - Py_INCREF(obj); - } else { -#if (PY_VERSION_HEX < 0x02020000) - data->newraw = 0; -#else - data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__"); -#endif - if (data->newraw) { - Py_INCREF(data->newraw); - data->newargs = PyTuple_New(1); - PyTuple_SetItem(data->newargs, 0, obj); - } else { - data->newargs = obj; - } - Py_INCREF(data->newargs); - } - /* the destroy method, aka as the C++ delete method */ - data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__"); - if (PyErr_Occurred()) { - PyErr_Clear(); - data->destroy = 0; - } - if (data->destroy) { - int flags; - Py_INCREF(data->destroy); - flags = PyCFunction_GET_FLAGS(data->destroy); -#ifdef METH_O - data->delargs = !(flags & (METH_O)); -#else - data->delargs = 0; -#endif - } else { - data->delargs = 0; - } - data->implicitconv = 0; - return data; - } -} - -SWIGRUNTIME void -PySwigClientData_Del(PySwigClientData* data) -{ - Py_XDECREF(data->newraw); - Py_XDECREF(data->newargs); - Py_XDECREF(data->destroy); -} - -/* =============== PySwigObject =====================*/ - -typedef struct { - PyObject_HEAD - void *ptr; - swig_type_info *ty; - int own; - PyObject *next; -} PySwigObject; - -SWIGRUNTIME PyObject * -PySwigObject_long(PySwigObject *v) -{ - return PyLong_FromVoidPtr(v->ptr); -} - -SWIGRUNTIME PyObject * -PySwigObject_format(const char* fmt, PySwigObject *v) -{ - PyObject *res = NULL; - PyObject *args = PyTuple_New(1); - if (args) { - if (PyTuple_SetItem(args, 0, PySwigObject_long(v)) == 0) { - PyObject *ofmt = PyString_FromString(fmt); - if (ofmt) { - res = PyString_Format(ofmt,args); - Py_DECREF(ofmt); - } - Py_DECREF(args); - } - } - return res; -} - -SWIGRUNTIME PyObject * -PySwigObject_oct(PySwigObject *v) -{ - return PySwigObject_format("%o",v); -} - -SWIGRUNTIME PyObject * -PySwigObject_hex(PySwigObject *v) -{ - return PySwigObject_format("%x",v); -} - -SWIGRUNTIME PyObject * -#ifdef METH_NOARGS -PySwigObject_repr(PySwigObject *v) -#else -PySwigObject_repr(PySwigObject *v, PyObject *args) -#endif -{ - const char *name = SWIG_TypePrettyName(v->ty); - PyObject *hex = PySwigObject_hex(v); - PyObject *repr = PyString_FromFormat("", name, PyString_AsString(hex)); - Py_DECREF(hex); - if (v->next) { -#ifdef METH_NOARGS - PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next); -#else - PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next, args); -#endif - PyString_ConcatAndDel(&repr,nrep); - } - return repr; -} - -SWIGRUNTIME int -PySwigObject_print(PySwigObject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) -{ -#ifdef METH_NOARGS - PyObject *repr = PySwigObject_repr(v); -#else - PyObject *repr = PySwigObject_repr(v, NULL); -#endif - if (repr) { - fputs(PyString_AsString(repr), fp); - Py_DECREF(repr); - return 0; - } else { - return 1; - } -} - -SWIGRUNTIME PyObject * -PySwigObject_str(PySwigObject *v) -{ - char result[SWIG_BUFFER_SIZE]; - return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ? - PyString_FromString(result) : 0; -} - -SWIGRUNTIME int -PySwigObject_compare(PySwigObject *v, PySwigObject *w) -{ - void *i = v->ptr; - void *j = w->ptr; - return (i < j) ? -1 : ((i > j) ? 1 : 0); -} - -SWIGRUNTIME PyTypeObject* _PySwigObject_type(void); - -SWIGRUNTIME PyTypeObject* -PySwigObject_type(void) { - static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigObject_type(); - return type; -} - -SWIGRUNTIMEINLINE int -PySwigObject_Check(PyObject *op) { - return ((op)->ob_type == PySwigObject_type()) - || (strcmp((op)->ob_type->tp_name,"PySwigObject") == 0); -} - -SWIGRUNTIME PyObject * -PySwigObject_New(void *ptr, swig_type_info *ty, int own); - -SWIGRUNTIME void -PySwigObject_dealloc(PyObject *v) -{ - PySwigObject *sobj = (PySwigObject *) v; - PyObject *next = sobj->next; - if (sobj->own == SWIG_POINTER_OWN) { - swig_type_info *ty = sobj->ty; - PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0; - PyObject *destroy = data ? data->destroy : 0; - if (destroy) { - /* destroy is always a VARARGS method */ - PyObject *res; - if (data->delargs) { - /* we need to create a temporal object to carry the destroy operation */ - PyObject *tmp = PySwigObject_New(sobj->ptr, ty, 0); - res = SWIG_Python_CallFunctor(destroy, tmp); - Py_DECREF(tmp); - } else { - PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); - PyObject *mself = PyCFunction_GET_SELF(destroy); - res = ((*meth)(mself, v)); - } - Py_XDECREF(res); - } -#if !defined(SWIG_PYTHON_SILENT_MEMLEAK) - else { - const char *name = SWIG_TypePrettyName(ty); - printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown")); - } -#endif - } - Py_XDECREF(next); - PyObject_DEL(v); -} - -SWIGRUNTIME PyObject* -PySwigObject_append(PyObject* v, PyObject* next) -{ - PySwigObject *sobj = (PySwigObject *) v; -#ifndef METH_O - PyObject *tmp = 0; - if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL; - next = tmp; -#endif - if (!PySwigObject_Check(next)) { - return NULL; - } - sobj->next = next; - Py_INCREF(next); - return SWIG_Py_Void(); -} - -SWIGRUNTIME PyObject* -#ifdef METH_NOARGS -PySwigObject_next(PyObject* v) -#else -PySwigObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) -#endif -{ - PySwigObject *sobj = (PySwigObject *) v; - if (sobj->next) { - Py_INCREF(sobj->next); - return sobj->next; - } else { - return SWIG_Py_Void(); - } -} - -SWIGINTERN PyObject* -#ifdef METH_NOARGS -PySwigObject_disown(PyObject *v) -#else -PySwigObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) -#endif -{ - PySwigObject *sobj = (PySwigObject *)v; - sobj->own = 0; - return SWIG_Py_Void(); -} - -SWIGINTERN PyObject* -#ifdef METH_NOARGS -PySwigObject_acquire(PyObject *v) -#else -PySwigObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) -#endif -{ - PySwigObject *sobj = (PySwigObject *)v; - sobj->own = SWIG_POINTER_OWN; - return SWIG_Py_Void(); -} - -SWIGINTERN PyObject* -PySwigObject_own(PyObject *v, PyObject *args) -{ - PyObject *val = 0; -#if (PY_VERSION_HEX < 0x02020000) - if (!PyArg_ParseTuple(args,(char *)"|O:own",&val)) -#else - if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val)) -#endif - { - return NULL; - } - else - { - PySwigObject *sobj = (PySwigObject *)v; - PyObject *obj = PyBool_FromLong(sobj->own); - if (val) { -#ifdef METH_NOARGS - if (PyObject_IsTrue(val)) { - PySwigObject_acquire(v); - } else { - PySwigObject_disown(v); - } -#else - if (PyObject_IsTrue(val)) { - PySwigObject_acquire(v,args); - } else { - PySwigObject_disown(v,args); - } -#endif - } - return obj; - } -} - -#ifdef METH_O -static PyMethodDef -swigobject_methods[] = { - {(char *)"disown", (PyCFunction)PySwigObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"}, - {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_NOARGS, (char *)"aquires ownership of the pointer"}, - {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, - {(char *)"append", (PyCFunction)PySwigObject_append, METH_O, (char *)"appends another 'this' object"}, - {(char *)"next", (PyCFunction)PySwigObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, - {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_NOARGS, (char *)"returns object representation"}, - {0, 0, 0, 0} -}; -#else -static PyMethodDef -swigobject_methods[] = { - {(char *)"disown", (PyCFunction)PySwigObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"}, - {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"}, - {(char *)"own", (PyCFunction)PySwigObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, - {(char *)"append", (PyCFunction)PySwigObject_append, METH_VARARGS, (char *)"appends another 'this' object"}, - {(char *)"next", (PyCFunction)PySwigObject_next, METH_VARARGS, (char *)"returns the next 'this' object"}, - {(char *)"__repr__",(PyCFunction)PySwigObject_repr, METH_VARARGS, (char *)"returns object representation"}, - {0, 0, 0, 0} -}; -#endif - -#if PY_VERSION_HEX < 0x02020000 -SWIGINTERN PyObject * -PySwigObject_getattr(PySwigObject *sobj,char *name) -{ - return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name); -} -#endif - -SWIGRUNTIME PyTypeObject* -_PySwigObject_type(void) { - static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer"; - - static PyNumberMethods PySwigObject_as_number = { - (binaryfunc)0, /*nb_add*/ - (binaryfunc)0, /*nb_subtract*/ - (binaryfunc)0, /*nb_multiply*/ - (binaryfunc)0, /*nb_divide*/ - (binaryfunc)0, /*nb_remainder*/ - (binaryfunc)0, /*nb_divmod*/ - (ternaryfunc)0,/*nb_power*/ - (unaryfunc)0, /*nb_negative*/ - (unaryfunc)0, /*nb_positive*/ - (unaryfunc)0, /*nb_absolute*/ - (inquiry)0, /*nb_nonzero*/ - 0, /*nb_invert*/ - 0, /*nb_lshift*/ - 0, /*nb_rshift*/ - 0, /*nb_and*/ - 0, /*nb_xor*/ - 0, /*nb_or*/ - (coercion)0, /*nb_coerce*/ - (unaryfunc)PySwigObject_long, /*nb_int*/ - (unaryfunc)PySwigObject_long, /*nb_long*/ - (unaryfunc)0, /*nb_float*/ - (unaryfunc)PySwigObject_oct, /*nb_oct*/ - (unaryfunc)PySwigObject_hex, /*nb_hex*/ -#if PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */ -#elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ -#elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */ - 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */ -#endif - }; - - static PyTypeObject pyswigobject_type; - static int type_init = 0; - if (!type_init) { - const PyTypeObject tmp - = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - (char *)"PySwigObject", /* tp_name */ - sizeof(PySwigObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)PySwigObject_dealloc, /* tp_dealloc */ -#if PY_VERSION_HEX < 0x03080000 - (printfunc)PySwigObject_print, /* tp_print */ -#else - 0, /*tp_vectorcall_offset*/ -#endif - -#if PY_VERSION_HEX < 0x02020000 - (getattrfunc)PySwigObject_getattr, /* tp_getattr */ -#else - (getattrfunc)0, /* tp_getattr */ -#endif - (setattrfunc)0, /* tp_setattr */ - (cmpfunc)PySwigObject_compare, /* tp_compare */ - (reprfunc)PySwigObject_repr, /* tp_repr */ - &PySwigObject_as_number, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)0, /* tp_hash */ - (ternaryfunc)0, /* tp_call */ - (reprfunc)PySwigObject_str, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - swigobject_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ -#if PY_VERSION_HEX >= 0x02020000 - 0, /* tp_iter */ - 0, /* tp_iternext */ - swigobject_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - 0, /* tp_free */ - 0, /* tp_is_gc */ - 0, /* tp_bases */ - 0, /* tp_mro */ - 0, /* tp_cache */ - 0, /* tp_subclasses */ - 0, /* tp_weaklist */ -#endif -#if PY_VERSION_HEX >= 0x02030000 - 0, /* tp_del */ -#endif -#if PY_VERSION_HEX >= 0x02060000 - 0, /* tp_version_tag */ -#endif -#ifdef COUNT_ALLOCS - 0,0,0,0 /* tp_alloc -> tp_next */ -#endif - }; - pyswigobject_type = tmp; - pyswigobject_type.ob_type = &PyType_Type; - type_init = 1; - } - return &pyswigobject_type; -} - -SWIGRUNTIME PyObject * -PySwigObject_New(void *ptr, swig_type_info *ty, int own) -{ - PySwigObject *sobj = PyObject_NEW(PySwigObject, PySwigObject_type()); - if (sobj) { - sobj->ptr = ptr; - sobj->ty = ty; - sobj->own = own; - sobj->next = 0; - } - return (PyObject *)sobj; -} - -/* ----------------------------------------------------------------------------- - * Implements a simple Swig Packed type, and use it instead of string - * ----------------------------------------------------------------------------- */ - -typedef struct { - PyObject_HEAD - void *pack; - swig_type_info *ty; - size_t size; -} PySwigPacked; - -SWIGRUNTIME int -PySwigPacked_print(PySwigPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags)) -{ - char result[SWIG_BUFFER_SIZE]; - fputs("pack, v->size, 0, sizeof(result))) { - fputs("at ", fp); - fputs(result, fp); - } - fputs(v->ty->name,fp); - fputs(">", fp); - return 0; -} - -SWIGRUNTIME PyObject * -PySwigPacked_repr(PySwigPacked *v) -{ - char result[SWIG_BUFFER_SIZE]; - if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { - return PyString_FromFormat("", result, v->ty->name); - } else { - return PyString_FromFormat("", v->ty->name); - } -} - -SWIGRUNTIME PyObject * -PySwigPacked_str(PySwigPacked *v) -{ - char result[SWIG_BUFFER_SIZE]; - if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ - return PyString_FromFormat("%s%s", result, v->ty->name); - } else { - return PyString_FromString(v->ty->name); - } -} - -SWIGRUNTIME int -PySwigPacked_compare(PySwigPacked *v, PySwigPacked *w) -{ - size_t i = v->size; - size_t j = w->size; - int s = (i < j) ? -1 : ((i > j) ? 1 : 0); - return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size); -} - -SWIGRUNTIME PyTypeObject* _PySwigPacked_type(void); - -SWIGRUNTIME PyTypeObject* -PySwigPacked_type(void) { - static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigPacked_type(); - return type; -} - -SWIGRUNTIMEINLINE int -PySwigPacked_Check(PyObject *op) { - return ((op)->ob_type == _PySwigPacked_type()) - || (strcmp((op)->ob_type->tp_name,"PySwigPacked") == 0); -} - -SWIGRUNTIME void -PySwigPacked_dealloc(PyObject *v) -{ - if (PySwigPacked_Check(v)) { - PySwigPacked *sobj = (PySwigPacked *) v; - free(sobj->pack); - } - PyObject_DEL(v); -} - -SWIGRUNTIME PyTypeObject* -_PySwigPacked_type(void) { - static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer"; - static PyTypeObject pyswigpacked_type; - static int type_init = 0; - if (!type_init) { - const PyTypeObject tmp - = { - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ - (char *)"PySwigPacked", /* tp_name */ - sizeof(PySwigPacked), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)PySwigPacked_dealloc, /* tp_dealloc */ -#if PY_VERSION_HEX < 0x03080000 - (printfunc)PySwigPacked_print, /* tp_print */ -#else - 0, /*tp_vectorcall_offset*/ -#endif - (getattrfunc)0, /* tp_getattr */ - (setattrfunc)0, /* tp_setattr */ - (cmpfunc)PySwigPacked_compare, /* tp_compare */ - (reprfunc)PySwigPacked_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)0, /* tp_hash */ - (ternaryfunc)0, /* tp_call */ - (reprfunc)PySwigPacked_str, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - swigpacked_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ -#if PY_VERSION_HEX >= 0x02020000 - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - 0, /* tp_free */ - 0, /* tp_is_gc */ - 0, /* tp_bases */ - 0, /* tp_mro */ - 0, /* tp_cache */ - 0, /* tp_subclasses */ - 0, /* tp_weaklist */ -#endif -#if PY_VERSION_HEX >= 0x02030000 - 0, /* tp_del */ -#endif -#if PY_VERSION_HEX >= 0x02060000 - 0, /* tp_version_tag */ -#endif -#ifdef COUNT_ALLOCS - 0,0,0,0 /* tp_alloc -> tp_next */ -#endif - }; - pyswigpacked_type = tmp; - pyswigpacked_type.ob_type = &PyType_Type; - type_init = 1; - } - return &pyswigpacked_type; -} - -SWIGRUNTIME PyObject * -PySwigPacked_New(void *ptr, size_t size, swig_type_info *ty) -{ - PySwigPacked *sobj = PyObject_NEW(PySwigPacked, PySwigPacked_type()); - if (sobj) { - void *pack = malloc(size); - if (pack) { - memcpy(pack, ptr, size); - sobj->pack = pack; - sobj->ty = ty; - sobj->size = size; - } else { - PyObject_DEL((PyObject *) sobj); - sobj = 0; - } - } - return (PyObject *) sobj; -} - -SWIGRUNTIME swig_type_info * -PySwigPacked_UnpackData(PyObject *obj, void *ptr, size_t size) -{ - if (PySwigPacked_Check(obj)) { - PySwigPacked *sobj = (PySwigPacked *)obj; - if (sobj->size != size) return 0; - memcpy(ptr, sobj->pack, size); - return sobj->ty; - } else { - return 0; - } -} - -/* ----------------------------------------------------------------------------- - * pointers/data manipulation - * ----------------------------------------------------------------------------- */ - -SWIGRUNTIMEINLINE PyObject * -_SWIG_This(void) -{ - return PyString_FromString("this"); -} - -SWIGRUNTIME PyObject * -SWIG_This(void) -{ - static PyObject *SWIG_STATIC_POINTER(swig_this) = _SWIG_This(); - return swig_this; -} - -/* #define SWIG_PYTHON_SLOW_GETSET_THIS */ - -SWIGRUNTIME PySwigObject * -SWIG_Python_GetSwigThis(PyObject *pyobj) -{ - if (PySwigObject_Check(pyobj)) { - return (PySwigObject *) pyobj; - } else { - PyObject *obj = 0; -#if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000)) - if (PyInstance_Check(pyobj)) { - obj = _PyInstance_Lookup(pyobj, SWIG_This()); - } else { - PyObject **dictptr = _PyObject_GetDictPtr(pyobj); - if (dictptr != NULL) { - PyObject *dict = *dictptr; - obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0; - } else { -#ifdef PyWeakref_CheckProxy - if (PyWeakref_CheckProxy(pyobj)) { - PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); - return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; - } -#endif - obj = PyObject_GetAttr(pyobj,SWIG_This()); - if (obj) { - Py_DECREF(obj); - } else { - if (PyErr_Occurred()) PyErr_Clear(); - return 0; - } - } - } -#else - obj = PyObject_GetAttr(pyobj,SWIG_This()); - if (obj) { - Py_DECREF(obj); - } else { - if (PyErr_Occurred()) PyErr_Clear(); - return 0; - } -#endif - if (obj && !PySwigObject_Check(obj)) { - /* a PyObject is called 'this', try to get the 'real this' - PySwigObject from it */ - return SWIG_Python_GetSwigThis(obj); - } - return (PySwigObject *)obj; - } -} - -/* Acquire a pointer value */ - -SWIGRUNTIME int -SWIG_Python_AcquirePtr(PyObject *obj, int own) { - if (own == SWIG_POINTER_OWN) { - PySwigObject *sobj = SWIG_Python_GetSwigThis(obj); - if (sobj) { - int oldown = sobj->own; - sobj->own = own; - return oldown; - } - } - return 0; -} - -/* Convert a pointer value */ - -SWIGRUNTIME int -SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) { - if (!obj) return SWIG_ERROR; - if (obj == Py_None) { - if (ptr) *ptr = 0; - return SWIG_OK; - } else { - PySwigObject *sobj = SWIG_Python_GetSwigThis(obj); - if (own) - *own = 0; - while (sobj) { - void *vptr = sobj->ptr; - if (ty) { - swig_type_info *to = sobj->ty; - if (to == ty) { - /* no type cast needed */ - if (ptr) *ptr = vptr; - break; - } else { - swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); - if (!tc) { - sobj = (PySwigObject *)sobj->next; - } else { - if (ptr) { - int newmemory = 0; - *ptr = SWIG_TypeCast(tc,vptr,&newmemory); - if (newmemory == SWIG_CAST_NEW_MEMORY) { - assert(own); - if (own) - *own = *own | SWIG_CAST_NEW_MEMORY; - } - } - break; - } - } - } else { - if (ptr) *ptr = vptr; - break; - } - } - if (sobj) { - if (own) - *own = *own | sobj->own; - if (flags & SWIG_POINTER_DISOWN) { - sobj->own = 0; - } - return SWIG_OK; - } else { - int res = SWIG_ERROR; - if (flags & SWIG_POINTER_IMPLICIT_CONV) { - PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0; - if (data && !data->implicitconv) { - PyObject *klass = data->klass; - if (klass) { - PyObject *impconv; - data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/ - impconv = SWIG_Python_CallFunctor(klass, obj); - data->implicitconv = 0; - if (PyErr_Occurred()) { - PyErr_Clear(); - impconv = 0; - } - if (impconv) { - PySwigObject *iobj = SWIG_Python_GetSwigThis(impconv); - if (iobj) { - void *vptr; - res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0); - if (SWIG_IsOK(res)) { - if (ptr) { - *ptr = vptr; - /* transfer the ownership to 'ptr' */ - iobj->own = 0; - res = SWIG_AddCast(res); - res = SWIG_AddNewMask(res); - } else { - res = SWIG_AddCast(res); - } - } - } - Py_DECREF(impconv); - } - } - } - } - return res; - } - } -} - -/* Convert a function ptr value */ - -SWIGRUNTIME int -SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { - if (!PyCFunction_Check(obj)) { - return SWIG_ConvertPtr(obj, ptr, ty, 0); - } else { - void *vptr = 0; - - /* here we get the method pointer for callbacks */ - const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); - const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; - if (desc) { - desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; - if (!desc) return SWIG_ERROR; - } - if (ty) { - swig_cast_info *tc = SWIG_TypeCheck(desc,ty); - if (tc) { - int newmemory = 0; - *ptr = SWIG_TypeCast(tc,vptr,&newmemory); - assert(!newmemory); /* newmemory handling not yet implemented */ - } else { - return SWIG_ERROR; - } - } else { - *ptr = vptr; - } - return SWIG_OK; - } -} - -/* Convert a packed value value */ - -SWIGRUNTIME int -SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) { - swig_type_info *to = PySwigPacked_UnpackData(obj, ptr, sz); - if (!to) return SWIG_ERROR; - if (ty) { - if (to != ty) { - /* check type cast? */ - swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); - if (!tc) return SWIG_ERROR; - } - } - return SWIG_OK; -} - -/* ----------------------------------------------------------------------------- - * Create a new pointer object - * ----------------------------------------------------------------------------- */ - -/* - Create a new instance object, whitout calling __init__, and set the - 'this' attribute. -*/ - -SWIGRUNTIME PyObject* -SWIG_Python_NewShadowInstance(PySwigClientData *data, PyObject *swig_this) -{ -#if (PY_VERSION_HEX >= 0x02020000) - PyObject *inst = 0; - PyObject *newraw = data->newraw; - if (newraw) { - inst = PyObject_Call(newraw, data->newargs, NULL); - if (inst) { -#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) - PyObject **dictptr = _PyObject_GetDictPtr(inst); - if (dictptr != NULL) { - PyObject *dict = *dictptr; - if (dict == NULL) { - dict = PyDict_New(); - *dictptr = dict; - PyDict_SetItem(dict, SWIG_This(), swig_this); - } - } -#else - PyObject *key = SWIG_This(); - PyObject_SetAttr(inst, key, swig_this); -#endif - } - } else { - PyObject *dict = PyDict_New(); - PyDict_SetItem(dict, SWIG_This(), swig_this); - inst = PyInstance_NewRaw(data->newargs, dict); - Py_DECREF(dict); - } - return inst; -#else -#if (PY_VERSION_HEX >= 0x02010000) - PyObject *inst; - PyObject *dict = PyDict_New(); - PyDict_SetItem(dict, SWIG_This(), swig_this); - inst = PyInstance_NewRaw(data->newargs, dict); - Py_DECREF(dict); - return (PyObject *) inst; -#else - PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type); - if (inst == NULL) { - return NULL; - } - inst->in_class = (PyClassObject *)data->newargs; - Py_INCREF(inst->in_class); - inst->in_dict = PyDict_New(); - if (inst->in_dict == NULL) { - Py_DECREF(inst); - return NULL; - } -#ifdef Py_TPFLAGS_HAVE_WEAKREFS - inst->in_weakreflist = NULL; -#endif -#ifdef Py_TPFLAGS_GC - PyObject_GC_Init(inst); -#endif - PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this); - return (PyObject *) inst; -#endif -#endif -} - -SWIGRUNTIME void -SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) -{ - PyObject *dict; -#if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS) - PyObject **dictptr = _PyObject_GetDictPtr(inst); - if (dictptr != NULL) { - dict = *dictptr; - if (dict == NULL) { - dict = PyDict_New(); - *dictptr = dict; - } - PyDict_SetItem(dict, SWIG_This(), swig_this); - return; - } -#endif - dict = PyObject_GetAttrString(inst, (char*)"__dict__"); - PyDict_SetItem(dict, SWIG_This(), swig_this); - Py_DECREF(dict); -} - - -SWIGINTERN PyObject * -SWIG_Python_InitShadowInstance(PyObject *args) { - PyObject *obj[2]; - if (!SWIG_Python_UnpackTuple(args,(char*)"swiginit", 2, 2, obj)) { - return NULL; - } else { - PySwigObject *sthis = SWIG_Python_GetSwigThis(obj[0]); - if (sthis) { - PySwigObject_append((PyObject*) sthis, obj[1]); - } else { - SWIG_Python_SetSwigThis(obj[0], obj[1]); - } - return SWIG_Py_Void(); - } -} - -/* Create a new pointer object */ - -SWIGRUNTIME PyObject * -SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int flags) { - if (!ptr) { - return SWIG_Py_Void(); - } else { - int own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0; - PyObject *robj = PySwigObject_New(ptr, type, own); - PySwigClientData *clientdata = type ? (PySwigClientData *)(type->clientdata) : 0; - if (clientdata && !(flags & SWIG_POINTER_NOSHADOW)) { - PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj); - if (inst) { - Py_DECREF(robj); - robj = inst; - } - } - return robj; - } -} - -/* Create a new packed object */ - -SWIGRUNTIMEINLINE PyObject * -SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { - return ptr ? PySwigPacked_New((void *) ptr, sz, type) : SWIG_Py_Void(); -} - -/* -----------------------------------------------------------------------------* - * Get type list - * -----------------------------------------------------------------------------*/ - -#ifdef SWIG_LINK_RUNTIME -void *SWIG_ReturnGlobalTypeList(void *); -#endif - -SWIGRUNTIME swig_module_info * -SWIG_Python_GetModule(void) { - static void *type_pointer = (void *)0; - /* first check if module already created */ - if (!type_pointer) { -#ifdef SWIG_LINK_RUNTIME - type_pointer = SWIG_ReturnGlobalTypeList((void *)0); -#else - type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, - (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); - if (PyErr_Occurred()) { - PyErr_Clear(); - type_pointer = (void *)0; - } -#endif - } - return (swig_module_info *) type_pointer; -} - -#if PY_MAJOR_VERSION < 2 -/* PyModule_AddObject function was introduced in Python 2.0. The following function - is copied out of Python/modsupport.c in python version 2.3.4 */ -SWIGINTERN int -PyModule_AddObject(PyObject *m, char *name, PyObject *o) -{ - PyObject *dict; - if (!PyModule_Check(m)) { - PyErr_SetString(PyExc_TypeError, - "PyModule_AddObject() needs module as first arg"); - return SWIG_ERROR; - } - if (!o) { - PyErr_SetString(PyExc_TypeError, - "PyModule_AddObject() needs non-NULL value"); - return SWIG_ERROR; - } - - dict = PyModule_GetDict(m); - if (dict == NULL) { - /* Internal error -- modules must have a dict! */ - PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", - PyModule_GetName(m)); - return SWIG_ERROR; - } - if (PyDict_SetItemString(dict, name, o)) - return SWIG_ERROR; - Py_DECREF(o); - return SWIG_OK; -} -#endif - -SWIGRUNTIME void -SWIG_Python_DestroyModule(void *vptr) -{ - swig_module_info *swig_module = (swig_module_info *) vptr; - swig_type_info **types = swig_module->types; - size_t i; - for (i =0; i < swig_module->size; ++i) { - swig_type_info *ty = types[i]; - if (ty->owndata) { - PySwigClientData *data = (PySwigClientData *) ty->clientdata; - if (data) PySwigClientData_Del(data); - } - } - Py_DECREF(SWIG_This()); -} - -SWIGRUNTIME void -SWIG_Python_SetModule(swig_module_info *swig_module) { - static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */ - - PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, - swig_empty_runtime_method_table); - PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule); - if (pointer && module) { - PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); - } else { - Py_XDECREF(pointer); - } -} - -/* The python cached type query */ -SWIGRUNTIME PyObject * -SWIG_Python_TypeCache(void) { - static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New(); - return cache; -} - -SWIGRUNTIME swig_type_info * -SWIG_Python_TypeQuery(const char *type) -{ - PyObject *cache = SWIG_Python_TypeCache(); - PyObject *key = PyString_FromString(type); - PyObject *obj = PyDict_GetItem(cache, key); - swig_type_info *descriptor; - if (obj) { - descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj); - } else { - swig_module_info *swig_module = SWIG_Python_GetModule(); - descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); - if (descriptor) { - obj = PyCObject_FromVoidPtr(descriptor, NULL); - PyDict_SetItem(cache, key, obj); - Py_DECREF(obj); - } - } - Py_DECREF(key); - return descriptor; -} - -/* - For backward compatibility only -*/ -#define SWIG_POINTER_EXCEPTION 0 -#define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg) -#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags) - -SWIGRUNTIME int -SWIG_Python_AddErrMesg(const char* mesg, int infront) -{ - if (PyErr_Occurred()) { - PyObject *type = 0; - PyObject *value = 0; - PyObject *traceback = 0; - PyErr_Fetch(&type, &value, &traceback); - if (value) { - PyObject *old_str = PyObject_Str(value); - Py_XINCREF(type); - PyErr_Clear(); - if (infront) { - PyErr_Format(type, "%s %s", mesg, PyString_AsString(old_str)); - } else { - PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg); - } - Py_DECREF(old_str); - } - return 1; - } else { - return 0; - } -} - -SWIGRUNTIME int -SWIG_Python_ArgFail(int argnum) -{ - if (PyErr_Occurred()) { - /* add information about failing argument */ - char mesg[256]; - PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum); - return SWIG_Python_AddErrMesg(mesg, 1); - } else { - return 0; - } -} - -SWIGRUNTIMEINLINE const char * -PySwigObject_GetDesc(PyObject *self) -{ - PySwigObject *v = (PySwigObject *)self; - swig_type_info *ty = v ? v->ty : 0; - return ty ? ty->str : (char*)""; -} - -SWIGRUNTIME void -SWIG_Python_TypeError(const char *type, PyObject *obj) -{ - if (type) { -#if defined(SWIG_COBJECT_TYPES) - if (obj && PySwigObject_Check(obj)) { - const char *otype = (const char *) PySwigObject_GetDesc(obj); - if (otype) { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'PySwigObject(%s)' is received", - type, otype); - return; - } - } else -#endif - { - const char *otype = (obj ? obj->ob_type->tp_name : 0); - if (otype) { - PyObject *str = PyObject_Str(obj); - const char *cstr = str ? PyString_AsString(str) : 0; - if (cstr) { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", - type, otype, cstr); - } else { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", - type, otype); - } - Py_XDECREF(str); - return; - } - } - PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); - } else { - PyErr_Format(PyExc_TypeError, "unexpected type is received"); - } -} - - -/* Convert a pointer value, signal an exception on a type mismatch */ -SWIGRUNTIME void * -SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) { - void *result; - if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { - PyErr_Clear(); - if (flags & SWIG_POINTER_EXCEPTION) { - SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); - SWIG_Python_ArgFail(argnum); - } - } - return result; -} - - -#ifdef __cplusplus -#if 0 -{ /* cc-mode */ -#endif -} -#endif -/* -----------------------------------------------------------------------------* - Standard SWIG API for use inside user code. - - Don't include this file directly, run the command - swig -python -external-runtime - Also, read the Modules chapter of the SWIG Manual. - - * -----------------------------------------------------------------------------*/ - -#ifdef SWIG_MODULE_CLIENTDATA_TYPE - -SWIGRUNTIMEINLINE swig_type_info * -SWIG_TypeQuery(SWIG_MODULE_CLIENTDATA_TYPE clientdata, const char *name) { - swig_module_info *module = SWIG_GetModule(clientdata); - return SWIG_TypeQueryModule(module, module, name); -} - -SWIGRUNTIMEINLINE swig_type_info * -SWIG_MangledTypeQuery(SWIG_MODULE_CLIENTDATA_TYPE clientdata, const char *name) { - swig_module_info *module = SWIG_GetModule(clientdata); - return SWIG_MangledTypeQueryModule(module, module, name); -} - -#else - -SWIGRUNTIMEINLINE swig_type_info * -SWIG_TypeQuery(const char *name) { - swig_module_info *module = SWIG_GetModule(NULL); - return SWIG_TypeQueryModule(module, module, name); -} - -SWIGRUNTIMEINLINE swig_type_info * -SWIG_MangledTypeQuery(const char *name) { - swig_module_info *module = SWIG_GetModule(NULL); - return SWIG_MangledTypeQueryModule(module, module, name); -} - -#endif diff --git a/src/Base/swigpyrun_1.3.38.cpp b/src/Base/swigpyrun_1.3.38.cpp deleted file mode 100644 index 59d0f41d40..0000000000 --- a/src/Base/swigpyrun_1.3.38.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2008 Werner Mayer * - * * - * 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" -#include "PyExport.h" -#include "Exception.h" -#include -#if defined(__clang__) -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wdeprecated-register" -# pragma clang diagnostic ignored "-Wself-assign" -#elif defined (__GNUC__) -# pragma GCC diagnostic push -# if __GNUC__ >= 8 -# pragma GCC diagnostic ignored "-Wcast-function-type" -# endif -#endif -namespace Swig_1_3_38 { -#define SWIG_PYTHON_NO_BUILD_NONE -#include "swigpyrun_1.3.38.h" -#include "swigpyrun.inl" -} -#if defined(__clang__) -# pragma clang diagnostic pop -#elif defined (__GNUC__) -# pragma GCC diagnostic pop -#endif - diff --git a/src/Base/swigpyrun_1.3.38.h b/src/Base/swigpyrun_1.3.38.h deleted file mode 100644 index 7cacc15797..0000000000 --- a/src/Base/swigpyrun_1.3.38.h +++ /dev/null @@ -1,2667 +0,0 @@ -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.38 - * - * This file is not intended to be easily readable and contains a number of - * coding conventions designed to improve portability and efficiency. Do not make - * changes to this file unless you know what you are doing--modify the SWIG - * interface file instead. - * ----------------------------------------------------------------------------- */ - -/* ----------------------------------------------------------------------------- - * This section contains generic SWIG labels for method/variable - * declarations/attributes, and other compiler dependent labels. - * ----------------------------------------------------------------------------- */ - -/* template workaround for compilers that cannot correctly implement the C++ standard */ -#ifndef SWIGTEMPLATEDISAMBIGUATOR -# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) -# define SWIGTEMPLATEDISAMBIGUATOR template -# elif defined(__HP_aCC) -/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ -/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ -# define SWIGTEMPLATEDISAMBIGUATOR template -# else -# define SWIGTEMPLATEDISAMBIGUATOR -# endif -#endif - -/* inline attribute */ -#ifndef SWIGINLINE -# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) -# define SWIGINLINE inline -# else -# define SWIGINLINE -# endif -#endif - -/* attribute recognised by some compilers to avoid 'unused' warnings */ -#ifndef SWIGUNUSED -# if defined(__GNUC__) -# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define SWIGUNUSED __attribute__ ((__unused__)) -# else -# define SWIGUNUSED -# endif -# elif defined(__ICC) -# define SWIGUNUSED __attribute__ ((__unused__)) -# else -# define SWIGUNUSED -# endif -#endif - -#ifndef SWIG_MSC_UNSUPPRESS_4505 -# if defined(_MSC_VER) -# pragma warning(disable : 4505) /* unreferenced local function has been removed */ -# endif -#endif - -#ifndef SWIGUNUSEDPARM -# ifdef __cplusplus -# define SWIGUNUSEDPARM(p) -# else -# define SWIGUNUSEDPARM(p) p SWIGUNUSED -# endif -#endif - -/* internal SWIG method */ -#ifndef SWIGINTERN -# define SWIGINTERN static SWIGUNUSED -#endif - -/* internal inline SWIG method */ -#ifndef SWIGINTERNINLINE -# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE -#endif - -/* exporting methods */ -#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY -# endif -#endif - -#ifndef SWIGEXPORT -# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# if defined(STATIC_LINKED) -# define SWIGEXPORT -# else -# define SWIGEXPORT __declspec(dllexport) -# endif -# else -# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) -# define SWIGEXPORT __attribute__ ((visibility("default"))) -# else -# define SWIGEXPORT -# endif -# endif -#endif - -/* calling conventions for Windows */ -#ifndef SWIGSTDCALL -# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# define SWIGSTDCALL __stdcall -# else -# define SWIGSTDCALL -# endif -#endif - -/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ -#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) -# define _CRT_SECURE_NO_DEPRECATE -#endif - -/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ -#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) -# define _SCL_SECURE_NO_DEPRECATE -#endif - -/* Errors in SWIG */ -#define SWIG_UnknownError -1 -#define SWIG_IOError -2 -#define SWIG_RuntimeError -3 -#define SWIG_IndexError -4 -#define SWIG_TypeError -5 -#define SWIG_DivisionByZero -6 -#define SWIG_OverflowError -7 -#define SWIG_SyntaxError -8 -#define SWIG_ValueError -9 -#define SWIG_SystemError -10 -#define SWIG_AttributeError -11 -#define SWIG_MemoryError -12 -#define SWIG_NullReferenceError -13 - - -/* Errors in SWIG */ -#define SWIG_UnknownError -1 -#define SWIG_IOError -2 -#define SWIG_RuntimeError -3 -#define SWIG_IndexError -4 -#define SWIG_TypeError -5 -#define SWIG_DivisionByZero -6 -#define SWIG_OverflowError -7 -#define SWIG_SyntaxError -8 -#define SWIG_ValueError -9 -#define SWIG_SystemError -10 -#define SWIG_AttributeError -11 -#define SWIG_MemoryError -12 -#define SWIG_NullReferenceError -13 - - -/* ----------------------------------------------------------------------------- - * swigrun.swg - * - * This file contains generic C API SWIG runtime support for pointer - * type checking. - * ----------------------------------------------------------------------------- */ - -/* This should only be incremented when either the layout of swig_type_info changes, - or for whatever reason, the runtime changes incompatibly */ -#define SWIG_RUNTIME_VERSION "4" - -/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ -#ifdef SWIG_TYPE_TABLE -# define SWIG_QUOTE_STRING(x) #x -# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) -# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) -#else -# define SWIG_TYPE_TABLE_NAME -#endif - -/* - You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for - creating a static or dynamic library from the SWIG runtime code. - In 99.9% of the cases, SWIG just needs to declare them as 'static'. - - But only do this if strictly necessary, ie, if you have problems - with your compiler or suchlike. -*/ - -#ifndef SWIGRUNTIME -# define SWIGRUNTIME SWIGINTERN -#endif - -#ifndef SWIGRUNTIMEINLINE -# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE -#endif - -/* Generic buffer size */ -#ifndef SWIG_BUFFER_SIZE -# define SWIG_BUFFER_SIZE 1024 -#endif - -/* Flags for pointer conversions */ -#define SWIG_POINTER_DISOWN 0x1 -#define SWIG_CAST_NEW_MEMORY 0x2 - -/* Flags for new pointer objects */ -#define SWIG_POINTER_OWN 0x1 - - -/* - Flags/methods for returning states. - - The SWIG conversion methods, as ConvertPtr, return and integer - that tells if the conversion was successful or not. And if not, - an error code can be returned (see swigerrors.swg for the codes). - - Use the following macros/flags to set or process the returning - states. - - In old versions of SWIG, code such as the following was usually written: - - if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { - // success code - } else { - //fail code - } - - Now you can be more explicit: - - int res = SWIG_ConvertPtr(obj,vptr,ty.flags); - if (SWIG_IsOK(res)) { - // success code - } else { - // fail code - } - - which is the same really, but now you can also do - - Type *ptr; - int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); - if (SWIG_IsOK(res)) { - // success code - if (SWIG_IsNewObj(res) { - ... - delete *ptr; - } else { - ... - } - } else { - // fail code - } - - I.e., now SWIG_ConvertPtr can return new objects and you can - identify the case and take care of the deallocation. Of course that - also requires SWIG_ConvertPtr to return new result values, such as - - int SWIG_ConvertPtr(obj, ptr,...) { - if () { - if () { - *ptr = ; - return SWIG_NEWOBJ; - } else { - *ptr = ; - return SWIG_OLDOBJ; - } - } else { - return SWIG_BADOBJ; - } - } - - Of course, returning the plain '0(success)/-1(fail)' still works, but you can be - more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the - SWIG errors code. - - Finally, if the SWIG_CASTRANK_MODE is enabled, the result code - allows to return the 'cast rank', for example, if you have this - - int food(double) - int fooi(int); - - and you call - - food(1) // cast rank '1' (1 -> 1.0) - fooi(1) // cast rank '0' - - just use the SWIG_AddCast()/SWIG_CheckState() -*/ - -#define SWIG_OK (0) -#define SWIG_ERROR (-1) -#define SWIG_IsOK(r) (r >= 0) -#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) - -/* The CastRankLimit says how many bits are used for the cast rank */ -#define SWIG_CASTRANKLIMIT (1 << 8) -/* The NewMask denotes the object was created (using new/malloc) */ -#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1) -/* The TmpMask is for in/out typemaps that use temporal objects */ -#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1) -/* Simple returning values */ -#define SWIG_BADOBJ (SWIG_ERROR) -#define SWIG_OLDOBJ (SWIG_OK) -#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK) -#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK) -/* Check, add and del mask methods */ -#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r) -#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r) -#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK)) -#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r) -#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) -#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) - -/* Cast-Rank Mode */ -#if defined(SWIG_CASTRANK_MODE) -# ifndef SWIG_TypeRank -# define SWIG_TypeRank unsigned long -# endif -# ifndef SWIG_MAXCASTRANK /* Default cast allowed */ -# define SWIG_MAXCASTRANK (2) -# endif -# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) -# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) -SWIGINTERNINLINE int SWIG_AddCast(int r) { - return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; -} -SWIGINTERNINLINE int SWIG_CheckState(int r) { - return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; -} -#else /* no cast-rank mode */ -# define SWIG_AddCast -# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) -#endif - - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void *(*swig_converter_func)(void *, int *); -typedef struct swig_type_info *(*swig_dycast_func)(void **); - -/* Structure to store information on one type */ -typedef struct swig_type_info { - const char *name; /* mangled name of this type */ - const char *str; /* human readable name of this type */ - swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ - struct swig_cast_info *cast; /* linked list of types that can cast into this type */ - void *clientdata; /* language specific type data */ - int owndata; /* flag if the structure owns the clientdata */ -} swig_type_info; - -/* Structure to store a type and conversion function used for casting */ -typedef struct swig_cast_info { - swig_type_info *type; /* pointer to type that is equivalent to this type */ - swig_converter_func converter; /* function to cast the void pointers */ - struct swig_cast_info *next; /* pointer to next cast in linked list */ - struct swig_cast_info *prev; /* pointer to the previous cast */ -} swig_cast_info; - -/* Structure used to store module information - * Each module generates one structure like this, and the runtime collects - * all of these structures and stores them in a circularly linked list.*/ -typedef struct swig_module_info { - swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ - size_t size; /* Number of types in this module */ - struct swig_module_info *next; /* Pointer to next element in circularly linked list */ - swig_type_info **type_initial; /* Array of initially generated type structures */ - swig_cast_info **cast_initial; /* Array of initially generated casting structures */ - void *clientdata; /* Language specific module data */ -} swig_module_info; - -/* - Compare two type names skipping the space characters, therefore - "char*" == "char *" and "Class" == "Class", etc. - - Return 0 when the two name types are equivalent, as in - strncmp, but skipping ' '. -*/ -SWIGRUNTIME int -SWIG_TypeNameComp(const char *f1, const char *l1, - const char *f2, const char *l2) { - for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { - while ((*f1 == ' ') && (f1 != l1)) ++f1; - while ((*f2 == ' ') && (f2 != l2)) ++f2; - if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; - } - return (int)((l1 - f1) - (l2 - f2)); -} - -/* - Check type equivalence in a name list like ||... - Return 0 if not equal, 1 if equal -*/ -SWIGRUNTIME int -SWIG_TypeEquiv(const char *nb, const char *tb) { - int equiv = 0; - const char* te = tb + strlen(tb); - const char* ne = nb; - while (!equiv && *ne) { - for (nb = ne; *ne; ++ne) { - if (*ne == '|') break; - } - equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; - if (*ne) ++ne; - } - return equiv; -} - -/* - Check type equivalence in a name list like ||... - Return 0 if equal, -1 if nb < tb, 1 if nb > tb -*/ -SWIGRUNTIME int -SWIG_TypeCompare(const char *nb, const char *tb) { - int equiv = 0; - const char* te = tb + strlen(tb); - const char* ne = nb; - while (!equiv && *ne) { - for (nb = ne; *ne; ++ne) { - if (*ne == '|') break; - } - equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; - if (*ne) ++ne; - } - return equiv; -} - - -/* - Check the typename -*/ -SWIGRUNTIME swig_cast_info * -SWIG_TypeCheck(const char *c, swig_type_info *ty) { - if (ty) { - swig_cast_info *iter = ty->cast; - while (iter) { - if (strcmp(iter->type->name, c) == 0) { - if (iter == ty->cast) - return iter; - /* Move iter to the top of the linked list */ - iter->prev->next = iter->next; - if (iter->next) - iter->next->prev = iter->prev; - iter->next = ty->cast; - iter->prev = 0; - if (ty->cast) ty->cast->prev = iter; - ty->cast = iter; - return iter; - } - iter = iter->next; - } - } - return 0; -} - -/* - Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison -*/ -SWIGRUNTIME swig_cast_info * -SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) { - if (ty) { - swig_cast_info *iter = ty->cast; - while (iter) { - if (iter->type == from) { - if (iter == ty->cast) - return iter; - /* Move iter to the top of the linked list */ - iter->prev->next = iter->next; - if (iter->next) - iter->next->prev = iter->prev; - iter->next = ty->cast; - iter->prev = 0; - if (ty->cast) ty->cast->prev = iter; - ty->cast = iter; - return iter; - } - iter = iter->next; - } - } - return 0; -} - -/* - Cast a pointer up an inheritance hierarchy -*/ -SWIGRUNTIMEINLINE void * -SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { - return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); -} - -/* - Dynamic pointer casting. Down an inheritance hierarchy -*/ -SWIGRUNTIME swig_type_info * -SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { - swig_type_info *lastty = ty; - if (!ty || !ty->dcast) return ty; - while (ty && (ty->dcast)) { - ty = (*ty->dcast)(ptr); - if (ty) lastty = ty; - } - return lastty; -} - -/* - Return the name associated with this type -*/ -SWIGRUNTIMEINLINE const char * -SWIG_TypeName(const swig_type_info *ty) { - return ty->name; -} - -/* - Return the pretty name associated with this type, - that is an unmangled type name in a form presentable to the user. -*/ -SWIGRUNTIME const char * -SWIG_TypePrettyName(const swig_type_info *type) { - /* The "str" field contains the equivalent pretty names of the - type, separated by vertical-bar characters. We choose - to print the last name, as it is often (?) the most - specific. */ - if (!type) return NULL; - if (type->str != NULL) { - const char *last_name = type->str; - const char *s; - for (s = type->str; *s; s++) - if (*s == '|') last_name = s+1; - return last_name; - } - else - return type->name; -} - -/* - Set the clientdata field for a type -*/ -SWIGRUNTIME void -SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { - swig_cast_info *cast = ti->cast; - /* if (ti->clientdata == clientdata) return; */ - ti->clientdata = clientdata; - - while (cast) { - if (!cast->converter) { - swig_type_info *tc = cast->type; - if (!tc->clientdata) { - SWIG_TypeClientData(tc, clientdata); - } - } - cast = cast->next; - } -} -SWIGRUNTIME void -SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { - SWIG_TypeClientData(ti, clientdata); - ti->owndata = 1; -} - -/* - Search for a swig_type_info structure only by mangled name - Search is a O(log #types) - - We start searching at module start, and finish searching when start == end. - Note: if start == end at the beginning of the function, we go all the way around - the circular list. -*/ -SWIGRUNTIME swig_type_info * -SWIG_MangledTypeQueryModule(swig_module_info *start, - swig_module_info *end, - const char *name) { - swig_module_info *iter = start; - do { - if (iter->size) { - register size_t l = 0; - register size_t r = iter->size - 1; - do { - /* since l+r >= 0, we can (>> 1) instead (/ 2) */ - register size_t i = (l + r) >> 1; - const char *iname = iter->types[i]->name; - if (iname) { - register int compare = strcmp(name, iname); - if (compare == 0) { - return iter->types[i]; - } else if (compare < 0) { - if (i) { - r = i - 1; - } else { - break; - } - } else if (compare > 0) { - l = i + 1; - } - } else { - break; /* should never happen */ - } - } while (l <= r); - } - iter = iter->next; - } while (iter != end); - return 0; -} - -/* - Search for a swig_type_info structure for either a mangled name or a human readable name. - It first searches the mangled names of the types, which is a O(log #types) - If a type is not found it then searches the human readable names, which is O(#types). - - We start searching at module start, and finish searching when start == end. - Note: if start == end at the beginning of the function, we go all the way around - the circular list. -*/ -SWIGRUNTIME swig_type_info * -SWIG_TypeQueryModule(swig_module_info *start, - swig_module_info *end, - const char *name) { - /* STEP 1: Search the name field using binary search */ - swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); - if (ret) { - return ret; - } else { - /* STEP 2: If the type hasn't been found, do a complete search - of the str field (the human readable name) */ - swig_module_info *iter = start; - do { - register size_t i = 0; - for (; i < iter->size; ++i) { - if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) - return iter->types[i]; - } - iter = iter->next; - } while (iter != end); - } - - /* neither found a match */ - return 0; -} - -/* - Pack binary data into a string -*/ -SWIGRUNTIME char * -SWIG_PackData(char *c, void *ptr, size_t sz) { - static const char hex[17] = "0123456789abcdef"; - register const unsigned char *u = (unsigned char *) ptr; - register const unsigned char *eu = u + sz; - for (; u != eu; ++u) { - register unsigned char uu = *u; - *(c++) = hex[(uu & 0xf0) >> 4]; - *(c++) = hex[uu & 0xf]; - } - return c; -} - -/* - Unpack binary data from a string -*/ -SWIGRUNTIME const char * -SWIG_UnpackData(const char *c, void *ptr, size_t sz) { - register unsigned char *u = (unsigned char *) ptr; - register const unsigned char *eu = u + sz; - for (; u != eu; ++u) { - register char d = *(c++); - register unsigned char uu; - if ((d >= '0') && (d <= '9')) - uu = ((d - '0') << 4); - else if ((d >= 'a') && (d <= 'f')) - uu = ((d - ('a'-10)) << 4); - else - return (char *) 0; - d = *(c++); - if ((d >= '0') && (d <= '9')) - uu |= (d - '0'); - else if ((d >= 'a') && (d <= 'f')) - uu |= (d - ('a'-10)); - else - return (char *) 0; - *u = uu; - } - return c; -} - -/* - Pack 'void *' into a string buffer. -*/ -SWIGRUNTIME char * -SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { - char *r = buff; - if ((2*sizeof(void *) + 2) > bsz) return 0; - *(r++) = '_'; - r = SWIG_PackData(r,&ptr,sizeof(void *)); - if (strlen(name) + 1 > (bsz - (r - buff))) return 0; - strcpy(r,name); - return buff; -} - -SWIGRUNTIME const char * -SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { - if (*c != '_') { - if (strcmp(c,"NULL") == 0) { - *ptr = (void *) 0; - return name; - } else { - return 0; - } - } - return SWIG_UnpackData(++c,ptr,sizeof(void *)); -} - -SWIGRUNTIME char * -SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { - char *r = buff; - size_t lname = (name ? strlen(name) : 0); - if ((2*sz + 2 + lname) > bsz) return 0; - *(r++) = '_'; - r = SWIG_PackData(r,ptr,sz); - if (lname) { - strncpy(r,name,lname+1); - } else { - *r = 0; - } - return buff; -} - -SWIGRUNTIME const char * -SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { - if (*c != '_') { - if (strcmp(c,"NULL") == 0) { - memset(ptr,0,sz); - return name; - } else { - return 0; - } - } - return SWIG_UnpackData(++c,ptr,sz); -} - -#ifdef __cplusplus -} -#endif -/* Compatibility marcos for Python 3 */ -#if PY_VERSION_HEX >= 0x03000000 - -#define PyClass_Check(obj) PyObject_IsInstance(obj, (PyObject *)&PyType_Type) -#define PyInt_Check(x) PyLong_Check(x) -#define PyInt_AsLong(x) PyLong_AsLong(x) -#define PyInt_FromLong(x) PyLong_FromLong(x) -#define PyString_Format(fmt, args) PyUnicode_Format(fmt, args) - -#endif - -#ifndef Py_TYPE -# define Py_TYPE(op) ((op)->ob_type) -#endif - -/* SWIG APIs for compatibility of both Python 2 & 3 */ - -#if PY_VERSION_HEX >= 0x03000000 -# define SWIG_Python_str_FromFormat PyUnicode_FromFormat -#else -# define SWIG_Python_str_FromFormat PyString_FromFormat -#endif - -SWIGINTERN char* -SWIG_Python_str_AsChar(PyObject *str) -{ -#if PY_VERSION_HEX >= 0x03000000 - str = PyUnicode_AsUTF8String(str); - return PyBytes_AsString(str); -#else - return PyString_AsString(str); -#endif -} - -SWIGINTERN PyObject* -SWIG_Python_str_FromChar(const char *c) -{ -#if PY_VERSION_HEX >= 0x03000000 - return PyUnicode_FromString(c); -#else - return PyString_FromString(c); -#endif -} - -/* Add PyOS_snprintf for old Pythons */ -#if PY_VERSION_HEX < 0x02020000 -# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) -# define PyOS_snprintf _snprintf -# else -# define PyOS_snprintf snprintf -# endif -#endif - -/* A crude PyString_FromFormat implementation for old Pythons */ -#if PY_VERSION_HEX < 0x02020000 - -#ifndef SWIG_PYBUFFER_SIZE -# define SWIG_PYBUFFER_SIZE 1024 -#endif - -static PyObject * -PyString_FromFormat(const char *fmt, ...) { - va_list ap; - char buf[SWIG_PYBUFFER_SIZE * 2]; - int res; - va_start(ap, fmt); - res = vsnprintf(buf, sizeof(buf), fmt, ap); - va_end(ap); - return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf); -} -#endif - -/* Add PyObject_Del for old Pythons */ -#if PY_VERSION_HEX < 0x01060000 -# define PyObject_Del(op) PyMem_DEL((op)) -#endif -#ifndef PyObject_DEL -# define PyObject_DEL PyObject_Del -#endif - -/* A crude PyExc_StopIteration exception for old Pythons */ -#if PY_VERSION_HEX < 0x02020000 -# ifndef PyExc_StopIteration -# define PyExc_StopIteration PyExc_RuntimeError -# endif -# ifndef PyObject_GenericGetAttr -# define PyObject_GenericGetAttr 0 -# endif -#endif - -/* Py_NotImplemented is defined in 2.1 and up. */ -#if PY_VERSION_HEX < 0x02010000 -# ifndef Py_NotImplemented -# define Py_NotImplemented PyExc_RuntimeError -# endif -#endif - -/* A crude PyString_AsStringAndSize implementation for old Pythons */ -#if PY_VERSION_HEX < 0x02010000 -# ifndef PyString_AsStringAndSize -# define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;} -# endif -#endif - -/* PySequence_Size for old Pythons */ -#if PY_VERSION_HEX < 0x02000000 -# ifndef PySequence_Size -# define PySequence_Size PySequence_Length -# endif -#endif - -/* PyBool_FromLong for old Pythons */ -#if PY_VERSION_HEX < 0x02030000 -static -PyObject *PyBool_FromLong(long ok) -{ - PyObject *result = ok ? Py_True : Py_False; - Py_INCREF(result); - return result; -} -#endif - -/* Py_ssize_t for old Pythons */ -/* This code is as recommended by: */ -/* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */ -#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) -typedef int Py_ssize_t; -# define PY_SSIZE_T_MAX INT_MAX -# define PY_SSIZE_T_MIN INT_MIN -#endif -/* ----------------------------------------------------------------------------- - * error manipulation - * ----------------------------------------------------------------------------- */ - -SWIGRUNTIME PyObject* -SWIG_Python_ErrorType(int code) { - PyObject* type = 0; - switch(code) { - case SWIG_MemoryError: - type = PyExc_MemoryError; - break; - case SWIG_IOError: - type = PyExc_IOError; - break; - case SWIG_RuntimeError: - type = PyExc_RuntimeError; - break; - case SWIG_IndexError: - type = PyExc_IndexError; - break; - case SWIG_TypeError: - type = PyExc_TypeError; - break; - case SWIG_DivisionByZero: - type = PyExc_ZeroDivisionError; - break; - case SWIG_OverflowError: - type = PyExc_OverflowError; - break; - case SWIG_SyntaxError: - type = PyExc_SyntaxError; - break; - case SWIG_ValueError: - type = PyExc_ValueError; - break; - case SWIG_SystemError: - type = PyExc_SystemError; - break; - case SWIG_AttributeError: - type = PyExc_AttributeError; - break; - default: - type = PyExc_RuntimeError; - } - return type; -} - - -SWIGRUNTIME void -SWIG_Python_AddErrorMsg(const char* mesg) -{ - PyObject *type = 0; - PyObject *value = 0; - PyObject *traceback = 0; - - if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback); - if (value) { - PyObject *old_str = PyObject_Str(value); - PyErr_Clear(); - Py_XINCREF(type); - - PyErr_Format(type, "%s %s", SWIG_Python_str_AsChar(old_str), mesg); - Py_DECREF(old_str); - Py_DECREF(value); - } else { - PyErr_SetString(PyExc_RuntimeError, mesg); - } -} -#if defined(SWIG_PYTHON_NO_THREADS) -# if defined(SWIG_PYTHON_THREADS) -# undef SWIG_PYTHON_THREADS -# endif -#endif -#if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */ -# if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL) -# if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */ -# define SWIG_PYTHON_USE_GIL -# endif -# endif -# if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */ -# ifndef SWIG_PYTHON_INITIALIZE_THREADS -# define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads() -# endif -# ifdef __cplusplus /* C++ code */ - class SWIG_Python_Thread_Block { - bool status; - PyGILState_STATE state; - public: - void end() { if (status) { PyGILState_Release(state); status = false;} } - SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {} - ~SWIG_Python_Thread_Block() { end(); } - }; - class SWIG_Python_Thread_Allow { - bool status; - PyThreadState *save; - public: - void end() { if (status) { PyEval_RestoreThread(save); status = false; }} - SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {} - ~SWIG_Python_Thread_Allow() { end(); } - }; -# define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block -# define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end() -# define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow -# define SWIG_PYTHON_THREAD_END_ALLOW _swig_thread_allow.end() -# else /* C code */ -# define SWIG_PYTHON_THREAD_BEGIN_BLOCK PyGILState_STATE _swig_thread_block = PyGILState_Ensure() -# define SWIG_PYTHON_THREAD_END_BLOCK PyGILState_Release(_swig_thread_block) -# define SWIG_PYTHON_THREAD_BEGIN_ALLOW PyThreadState *_swig_thread_allow = PyEval_SaveThread() -# define SWIG_PYTHON_THREAD_END_ALLOW PyEval_RestoreThread(_swig_thread_allow) -# endif -# else /* Old thread way, not implemented, user must provide it */ -# if !defined(SWIG_PYTHON_INITIALIZE_THREADS) -# define SWIG_PYTHON_INITIALIZE_THREADS -# endif -# if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK) -# define SWIG_PYTHON_THREAD_BEGIN_BLOCK -# endif -# if !defined(SWIG_PYTHON_THREAD_END_BLOCK) -# define SWIG_PYTHON_THREAD_END_BLOCK -# endif -# if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW) -# define SWIG_PYTHON_THREAD_BEGIN_ALLOW -# endif -# if !defined(SWIG_PYTHON_THREAD_END_ALLOW) -# define SWIG_PYTHON_THREAD_END_ALLOW -# endif -# endif -#else /* No thread support */ -# define SWIG_PYTHON_INITIALIZE_THREADS -# define SWIG_PYTHON_THREAD_BEGIN_BLOCK -# define SWIG_PYTHON_THREAD_END_BLOCK -# define SWIG_PYTHON_THREAD_BEGIN_ALLOW -# define SWIG_PYTHON_THREAD_END_ALLOW -#endif -/* ----------------------------------------------------------------------------- - * Python API portion that goes into the runtime - * ----------------------------------------------------------------------------- */ - -#ifdef __cplusplus -extern "C" { -#if 0 -} /* cc-mode */ -#endif -#endif - -/* ----------------------------------------------------------------------------- - * Constant declarations - * ----------------------------------------------------------------------------- */ - -/* Constant Types */ -#define SWIG_PY_POINTER 4 -#define SWIG_PY_BINARY 5 - -/* Constant information structure */ -typedef struct swig_const_info { - int type; - char *name; - long lvalue; - double dvalue; - void *pvalue; - swig_type_info **ptype; -} swig_const_info; - - -/* ----------------------------------------------------------------------------- - * Wrapper of PyInstanceMethod_New() used in Python 3 - * It is exported to the generated module, used for -fastproxy - * ----------------------------------------------------------------------------- */ -SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject * /*self*/, PyObject *func) -{ -#if PY_VERSION_HEX >= 0x03000000 - return PyInstanceMethod_New(func); -#else - (void)func; - return NULL; -#endif -} - -#ifdef __cplusplus -#if 0 -{ /* cc-mode */ -#endif -} -#endif - -/* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * - * pyrun.swg - * - * This file contains the runtime support for Python modules - * and includes code for managing global variables and pointer - * type checking. - * - * ----------------------------------------------------------------------------- */ - -/* Common SWIG API */ - -/* for raw pointers */ -#define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0) -#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags) -#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own) -#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(ptr, type, flags) -#define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty) -#define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src) -#define swig_owntype int - -/* for raw packed data */ -#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) -#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) - -/* for class or struct pointers */ -#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) -#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) - -/* for C or C++ function pointers */ -#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type) -#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(ptr, type, 0) - -/* for C++ member pointers, ie, member methods */ -#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) -#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) - - -/* Runtime API */ - -#define SWIG_GetModule(clientdata) SWIG_Python_GetModule() -#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) -#define SWIG_NewClientData(obj) SwigPyClientData_New(obj) - -#define SWIG_SetErrorObj SWIG_Python_SetErrorObj -#define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg -#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code) -#define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) -#define SWIG_fail goto fail - - -/* Runtime API implementation */ - -/* Error manipulation */ - -SWIGINTERN void -SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyErr_SetObject(errtype, obj); - Py_DECREF(obj); - SWIG_PYTHON_THREAD_END_BLOCK; -} - -SWIGINTERN void -SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyErr_SetString(errtype, (char *) msg); - SWIG_PYTHON_THREAD_END_BLOCK; -} - -#define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj) - -/* Set a constant value */ - -SWIGINTERN void -SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { - PyDict_SetItemString(d, (char*) name, obj); - Py_DECREF(obj); -} - -/* Append a value to the result obj */ - -SWIGINTERN PyObject* -SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { -#if !defined(SWIG_PYTHON_OUTPUT_TUPLE) - if (!result) { - result = obj; - } else if (result == Py_None) { - Py_DECREF(result); - result = obj; - } else { - if (!PyList_Check(result)) { - PyObject *o2 = result; - result = PyList_New(1); - PyList_SetItem(result, 0, o2); - } - PyList_Append(result,obj); - Py_DECREF(obj); - } - return result; -#else - PyObject* o2; - PyObject* o3; - if (!result) { - result = obj; - } else if (result == Py_None) { - Py_DECREF(result); - result = obj; - } else { - if (!PyTuple_Check(result)) { - o2 = result; - result = PyTuple_New(1); - PyTuple_SET_ITEM(result, 0, o2); - } - o3 = PyTuple_New(1); - PyTuple_SET_ITEM(o3, 0, obj); - o2 = result; - result = PySequence_Concat(o2, o3); - Py_DECREF(o2); - Py_DECREF(o3); - } - return result; -#endif -} - -/* Unpack the argument tuple */ - -SWIGINTERN int -SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs) -{ - if (!args) { - if (!min && !max) { - return 1; - } else { - PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none", - name, (min == max ? "" : "at least "), (int)min); - return 0; - } - } - if (!PyTuple_Check(args)) { - PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple"); - return 0; - } else { - register Py_ssize_t l = PyTuple_GET_SIZE(args); - if (l < min) { - PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", - name, (min == max ? "" : "at least "), (int)min, (int)l); - return 0; - } else if (l > max) { - PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", - name, (min == max ? "" : "at most "), (int)max, (int)l); - return 0; - } else { - register int i; - for (i = 0; i < l; ++i) { - objs[i] = PyTuple_GET_ITEM(args, i); - } - for (; l < max; ++l) { - objs[l] = 0; - } - return i + 1; - } - } -} - -/* A functor is a function object with one single object argument */ -#if PY_VERSION_HEX >= 0x02020000 -#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL); -#else -#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj); -#endif - -/* - Helper for static pointer initialization for both C and C++ code, for example - static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...); -*/ -#ifdef __cplusplus -#define SWIG_STATIC_POINTER(var) var -#else -#define SWIG_STATIC_POINTER(var) var = 0; if (!var) var -#endif - -/* ----------------------------------------------------------------------------- - * Pointer declarations - * ----------------------------------------------------------------------------- */ - -/* Flags for new pointer objects */ -#define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1) -#define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN) - -#define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1) - -#ifdef __cplusplus -extern "C" { -#if 0 -} /* cc-mode */ -#endif -#endif - -/* How to access Py_None */ -#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# ifndef SWIG_PYTHON_NO_BUILD_NONE -# ifndef SWIG_PYTHON_BUILD_NONE -# define SWIG_PYTHON_BUILD_NONE -# endif -# endif -#endif - -#ifdef SWIG_PYTHON_BUILD_NONE -# ifdef Py_None -# undef Py_None -# define Py_None SWIG_Py_None() -# endif -SWIGRUNTIMEINLINE PyObject * -_SWIG_Py_None(void) -{ - PyObject *none = Py_BuildValue((char*)""); - Py_DECREF(none); - return none; -} -SWIGRUNTIME PyObject * -SWIG_Py_None(void) -{ - static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None(); - return none; -} -#endif - -/* The python void return value */ - -SWIGRUNTIMEINLINE PyObject * -SWIG_Py_Void(void) -{ - PyObject *none = Py_None; - Py_INCREF(none); - return none; -} - -/* SwigPyClientData */ - -typedef struct { - PyObject *klass; - PyObject *newraw; - PyObject *newargs; - PyObject *destroy; - int delargs; - int implicitconv; -} SwigPyClientData; - -SWIGRUNTIMEINLINE int -SWIG_Python_CheckImplicit(swig_type_info *ty) -{ - SwigPyClientData *data = (SwigPyClientData *)ty->clientdata; - return data ? data->implicitconv : 0; -} - -SWIGRUNTIMEINLINE PyObject * -SWIG_Python_ExceptionType(swig_type_info *desc) { - SwigPyClientData *data = desc ? (SwigPyClientData *) desc->clientdata : 0; - PyObject *klass = data ? data->klass : 0; - return (klass ? klass : PyExc_RuntimeError); -} - - -SWIGRUNTIME SwigPyClientData * -SwigPyClientData_New(PyObject* obj) -{ - if (!obj) { - return 0; - } else { - SwigPyClientData *data = (SwigPyClientData *)malloc(sizeof(SwigPyClientData)); - /* the klass element */ - data->klass = obj; - Py_INCREF(data->klass); - /* the newraw method and newargs arguments used to create a new raw instance */ - if (PyClass_Check(obj)) { - data->newraw = 0; - data->newargs = obj; - Py_INCREF(obj); - } else { -#if (PY_VERSION_HEX < 0x02020000) - data->newraw = 0; -#else - data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__"); -#endif - if (data->newraw) { - Py_INCREF(data->newraw); - data->newargs = PyTuple_New(1); - PyTuple_SetItem(data->newargs, 0, obj); - } else { - data->newargs = obj; - } - Py_INCREF(data->newargs); - } - /* the destroy method, aka as the C++ delete method */ - data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__"); - if (PyErr_Occurred()) { - PyErr_Clear(); - data->destroy = 0; - } - if (data->destroy) { - int flags; - Py_INCREF(data->destroy); - flags = PyCFunction_GET_FLAGS(data->destroy); -#ifdef METH_O - data->delargs = !(flags & (METH_O)); -#else - data->delargs = 0; -#endif - } else { - data->delargs = 0; - } - data->implicitconv = 0; - return data; - } -} - -SWIGRUNTIME void -SwigPyClientData_Del(SwigPyClientData* data) -{ - Py_XDECREF(data->newraw); - Py_XDECREF(data->newargs); - Py_XDECREF(data->destroy); -} - -/* =============== SwigPyObject =====================*/ - -typedef struct { - PyObject_HEAD - void *ptr; - swig_type_info *ty; - int own; - PyObject *next; -} SwigPyObject; - -SWIGRUNTIME PyObject * -SwigPyObject_long(SwigPyObject *v) -{ - return PyLong_FromVoidPtr(v->ptr); -} - -SWIGRUNTIME PyObject * -SwigPyObject_format(const char* fmt, SwigPyObject *v) -{ - PyObject *res = NULL; - PyObject *args = PyTuple_New(1); - if (args) { - if (PyTuple_SetItem(args, 0, SwigPyObject_long(v)) == 0) { - PyObject *ofmt = SWIG_Python_str_FromChar(fmt); - if (ofmt) { -#if PY_VERSION_HEX >= 0x03000000 - res = PyUnicode_Format(ofmt,args); -#else - res = PyString_Format(ofmt,args); -#endif - Py_DECREF(ofmt); - } - Py_DECREF(args); - } - } - return res; -} - -SWIGRUNTIME PyObject * -SwigPyObject_oct(SwigPyObject *v) -{ - return SwigPyObject_format("%o",v); -} - -SWIGRUNTIME PyObject * -SwigPyObject_hex(SwigPyObject *v) -{ - return SwigPyObject_format("%x",v); -} - -SWIGRUNTIME PyObject * -#ifdef METH_NOARGS -SwigPyObject_repr(SwigPyObject *v) -#else -SwigPyObject_repr(SwigPyObject *v, PyObject *args) -#endif -{ - const char *name = SWIG_TypePrettyName(v->ty); - PyObject *hex = SwigPyObject_hex(v); - PyObject *repr = SWIG_Python_str_FromFormat("", name, hex); - Py_DECREF(hex); - if (v->next) { -#ifdef METH_NOARGS - PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next); -#else - PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next, args); -#endif -#if PY_VERSION_HEX >= 0x03000000 - PyObject *joined = PyUnicode_Concat(repr, nrep); - Py_DecRef(repr); - Py_DecRef(nrep); - repr = joined; -#else - PyString_ConcatAndDel(&repr,nrep); -#endif - } - return repr; -} - -SWIGRUNTIME int -SwigPyObject_print(SwigPyObject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) -{ -#ifdef METH_NOARGS - PyObject *repr = SwigPyObject_repr(v); -#else - PyObject *repr = SwigPyObject_repr(v, NULL); -#endif - if (repr) { - fputs(SWIG_Python_str_AsChar(repr), fp); - Py_DECREF(repr); - return 0; - } else { - return 1; - } -} - -SWIGRUNTIME PyObject * -SwigPyObject_str(SwigPyObject *v) -{ - char result[SWIG_BUFFER_SIZE]; - return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ? - SWIG_Python_str_FromChar(result) : 0; -} - -SWIGRUNTIME int -SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w) -{ - void *i = v->ptr; - void *j = w->ptr; - return (i < j) ? -1 : ((i > j) ? 1 : 0); -} - -/* Added for Python 3.x, whould it also useful for Python 2.x? */ -SWIGRUNTIME PyObject* -SwigPyObject_richcompare(SwigPyObject *v, SwigPyObject *w, int op) -{ - PyObject* res; - if( op != Py_EQ && op != Py_NE ) { - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; - } - if( (SwigPyObject_compare(v, w)==0) == (op == Py_EQ) ) - res = Py_True; - else - res = Py_False; - Py_INCREF(res); - return res; -} - - -SWIGRUNTIME PyTypeObject* _PySwigObject_type(void); - -SWIGRUNTIME PyTypeObject* -SwigPyObject_type(void) { - static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigObject_type(); - return type; -} - -SWIGRUNTIMEINLINE int -SwigPyObject_Check(PyObject *op) { - return (Py_TYPE(op) == SwigPyObject_type()) - || (strcmp(Py_TYPE(op)->tp_name,"SwigPyObject") == 0); -} - -SWIGRUNTIME PyObject * -SwigPyObject_New(void *ptr, swig_type_info *ty, int own); - -SWIGRUNTIME void -SwigPyObject_dealloc(PyObject *v) -{ - SwigPyObject *sobj = (SwigPyObject *) v; - PyObject *next = sobj->next; - if (sobj->own == SWIG_POINTER_OWN) { - swig_type_info *ty = sobj->ty; - SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; - PyObject *destroy = data ? data->destroy : 0; - if (destroy) { - /* destroy is always a VARARGS method */ - PyObject *res; - if (data->delargs) { - /* we need to create a temporal object to carry the destroy operation */ - PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0); - res = SWIG_Python_CallFunctor(destroy, tmp); - Py_DECREF(tmp); - } else { - PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); - PyObject *mself = PyCFunction_GET_SELF(destroy); - res = ((*meth)(mself, v)); - } - Py_XDECREF(res); - } -#if !defined(SWIG_PYTHON_SILENT_MEMLEAK) - else { - const char *name = SWIG_TypePrettyName(ty); - printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown")); - } -#endif - } - Py_XDECREF(next); - PyObject_DEL(v); -} - -SWIGRUNTIME PyObject* -SwigPyObject_append(PyObject* v, PyObject* next) -{ - SwigPyObject *sobj = (SwigPyObject *) v; -#ifndef METH_O - PyObject *tmp = 0; - if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL; - next = tmp; -#endif - if (!SwigPyObject_Check(next)) { - return NULL; - } - sobj->next = next; - Py_INCREF(next); - return SWIG_Py_Void(); -} - -SWIGRUNTIME PyObject* -#ifdef METH_NOARGS -SwigPyObject_next(PyObject* v) -#else -SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) -#endif -{ - SwigPyObject *sobj = (SwigPyObject *) v; - if (sobj->next) { - Py_INCREF(sobj->next); - return sobj->next; - } else { - return SWIG_Py_Void(); - } -} - -SWIGINTERN PyObject* -#ifdef METH_NOARGS -SwigPyObject_disown(PyObject *v) -#else -SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) -#endif -{ - SwigPyObject *sobj = (SwigPyObject *)v; - sobj->own = 0; - return SWIG_Py_Void(); -} - -SWIGINTERN PyObject* -#ifdef METH_NOARGS -SwigPyObject_acquire(PyObject *v) -#else -SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) -#endif -{ - SwigPyObject *sobj = (SwigPyObject *)v; - sobj->own = SWIG_POINTER_OWN; - return SWIG_Py_Void(); -} - -SWIGINTERN PyObject* -SwigPyObject_own(PyObject *v, PyObject *args) -{ - PyObject *val = 0; -#if (PY_VERSION_HEX < 0x02020000) - if (!PyArg_ParseTuple(args,(char *)"|O:own",&val)) -#else - if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val)) -#endif - { - return NULL; - } - else - { - SwigPyObject *sobj = (SwigPyObject *)v; - PyObject *obj = PyBool_FromLong(sobj->own); - if (val) { -#ifdef METH_NOARGS - if (PyObject_IsTrue(val)) { - SwigPyObject_acquire(v); - } else { - SwigPyObject_disown(v); - } -#else - if (PyObject_IsTrue(val)) { - SwigPyObject_acquire(v,args); - } else { - SwigPyObject_disown(v,args); - } -#endif - } - return obj; - } -} - -#ifdef METH_O -static PyMethodDef -swigobject_methods[] = { - {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"}, - {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, (char *)"aquires ownership of the pointer"}, - {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, - {(char *)"append", (PyCFunction)SwigPyObject_append, METH_O, (char *)"appends another 'this' object"}, - {(char *)"next", (PyCFunction)SwigPyObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, - {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_NOARGS, (char *)"returns object representation"}, - {0, 0, 0, 0} -}; -#else -static PyMethodDef -swigobject_methods[] = { - {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"}, - {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"}, - {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, - {(char *)"append", (PyCFunction)SwigPyObject_append, METH_VARARGS, (char *)"appends another 'this' object"}, - {(char *)"next", (PyCFunction)SwigPyObject_next, METH_VARARGS, (char *)"returns the next 'this' object"}, - {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_VARARGS, (char *)"returns object representation"}, - {0, 0, 0, 0} -}; -#endif - -#if PY_VERSION_HEX < 0x02020000 -SWIGINTERN PyObject * -SwigPyObject_getattr(SwigPyObject *sobj,char *name) -{ - return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name); -} -#endif - -SWIGRUNTIME PyTypeObject* -_PySwigObject_type(void) { - static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer"; - - static PyNumberMethods SwigPyObject_as_number = { - (binaryfunc)0, /*nb_add*/ - (binaryfunc)0, /*nb_subtract*/ - (binaryfunc)0, /*nb_multiply*/ - /* nb_divide removed in Python 3 */ -#if PY_VERSION_HEX < 0x03000000 - (binaryfunc)0, /*nb_divide*/ -#endif - (binaryfunc)0, /*nb_remainder*/ - (binaryfunc)0, /*nb_divmod*/ - (ternaryfunc)0,/*nb_power*/ - (unaryfunc)0, /*nb_negative*/ - (unaryfunc)0, /*nb_positive*/ - (unaryfunc)0, /*nb_absolute*/ - (inquiry)0, /*nb_nonzero*/ - 0, /*nb_invert*/ - 0, /*nb_lshift*/ - 0, /*nb_rshift*/ - 0, /*nb_and*/ - 0, /*nb_xor*/ - 0, /*nb_or*/ -#if PY_VERSION_HEX < 0x03000000 - 0, /*nb_coerce*/ -#endif - (unaryfunc)SwigPyObject_long, /*nb_int*/ - (unaryfunc)SwigPyObject_long, /*nb_long*/ - (unaryfunc)0, /*nb_float*/ -#if PY_VERSION_HEX < 0x03000000 - (unaryfunc)SwigPyObject_oct, /*nb_oct*/ - (unaryfunc)SwigPyObject_hex, /*nb_hex*/ -#endif -#if PY_VERSION_HEX >= 0x03000000 /* 3.0 */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */ -#elif PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */ -#elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ -#elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */ - 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */ -#endif - }; - - static PyTypeObject swigpyobject_type; - static int type_init = 0; - if (!type_init) { - const PyTypeObject tmp - = { - /* PyOjbect header changed in Python 3 */ -#if PY_VERSION_HEX >= 0x03000000 - PyVarObject_HEAD_INIT(&PyType_Type, 0) -#else - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ -#endif - (char *)"SwigPyObject", /* tp_name */ - sizeof(SwigPyObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)SwigPyObject_dealloc, /* tp_dealloc */ -#if PY_VERSION_HEX < 0x03080000 - (printfunc)SwigPyObject_print, /* tp_print */ -#else - 0, /*tp_vectorcall_offset*/ -#endif -#if PY_VERSION_HEX < 0x02020000 - (getattrfunc)SwigPyObject_getattr, /* tp_getattr */ -#else - (getattrfunc)0, /* tp_getattr */ -#endif - (setattrfunc)0, /* tp_setattr */ - (cmpfunc)SwigPyObject_compare, /* tp_compare */ - (reprfunc)SwigPyObject_repr, /* tp_repr */ - &SwigPyObject_as_number, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)0, /* tp_hash */ - (ternaryfunc)0, /* tp_call */ - (reprfunc)SwigPyObject_str, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - swigobject_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - (richcmpfunc)SwigPyObject_richcompare, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ -#if PY_VERSION_HEX >= 0x02020000 - 0, /* tp_iter */ - 0, /* tp_iternext */ - swigobject_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - 0, /* tp_free */ - 0, /* tp_is_gc */ - 0, /* tp_bases */ - 0, /* tp_mro */ - 0, /* tp_cache */ - 0, /* tp_subclasses */ - 0, /* tp_weaklist */ -#endif -#if PY_VERSION_HEX >= 0x02030000 - 0, /* tp_del */ -#endif -#if PY_VERSION_HEX >= 0x02060000 - 0, /* tp_version_tag */ -#endif -#ifdef COUNT_ALLOCS - 0,0,0,0 /* tp_alloc -> tp_next */ -#endif - }; - swigpyobject_type = tmp; - /* for Python 3 we already assigned the ob_type in PyVarObject_HEAD_INIT() */ -#if PY_VERSION_HEX < 0x03000000 - swigpyobject_type.ob_type = &PyType_Type; -#endif - type_init = 1; - } - return &swigpyobject_type; -} - -SWIGRUNTIME PyObject * -SwigPyObject_New(void *ptr, swig_type_info *ty, int own) -{ - SwigPyObject *sobj = PyObject_NEW(SwigPyObject, SwigPyObject_type()); - if (sobj) { - sobj->ptr = ptr; - sobj->ty = ty; - sobj->own = own; - sobj->next = 0; - } - return (PyObject *)sobj; -} - -/* ----------------------------------------------------------------------------- - * Implements a simple Swig Packed type, and use it instead of string - * ----------------------------------------------------------------------------- */ - -typedef struct { - PyObject_HEAD - void *pack; - swig_type_info *ty; - size_t size; -} SwigPyPacked; - -SWIGRUNTIME int -SwigPyPacked_print(SwigPyPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags)) -{ - char result[SWIG_BUFFER_SIZE]; - fputs("pack, v->size, 0, sizeof(result))) { - fputs("at ", fp); - fputs(result, fp); - } - fputs(v->ty->name,fp); - fputs(">", fp); - return 0; -} - -SWIGRUNTIME PyObject * -SwigPyPacked_repr(SwigPyPacked *v) -{ - char result[SWIG_BUFFER_SIZE]; - if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { - return SWIG_Python_str_FromFormat("", result, v->ty->name); - } else { - return SWIG_Python_str_FromFormat("", v->ty->name); - } -} - -SWIGRUNTIME PyObject * -SwigPyPacked_str(SwigPyPacked *v) -{ - char result[SWIG_BUFFER_SIZE]; - if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ - return SWIG_Python_str_FromFormat("%s%s", result, v->ty->name); - } else { - return SWIG_Python_str_FromChar(v->ty->name); - } -} - -SWIGRUNTIME int -SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w) -{ - size_t i = v->size; - size_t j = w->size; - int s = (i < j) ? -1 : ((i > j) ? 1 : 0); - return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size); -} - -SWIGRUNTIME PyTypeObject* _PySwigPacked_type(void); - -SWIGRUNTIME PyTypeObject* -SwigPyPacked_type(void) { - static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigPacked_type(); - return type; -} - -SWIGRUNTIMEINLINE int -SwigPyPacked_Check(PyObject *op) { - return ((op)->ob_type == _PySwigPacked_type()) - || (strcmp((op)->ob_type->tp_name,"SwigPyPacked") == 0); -} - -SWIGRUNTIME void -SwigPyPacked_dealloc(PyObject *v) -{ - if (SwigPyPacked_Check(v)) { - SwigPyPacked *sobj = (SwigPyPacked *) v; - free(sobj->pack); - } - PyObject_DEL(v); -} - -SWIGRUNTIME PyTypeObject* -_PySwigPacked_type(void) { - static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer"; - static PyTypeObject swigpypacked_type; - static int type_init = 0; - if (!type_init) { - const PyTypeObject tmp - = { - /* PyObject header changed in Python 3 */ -#if PY_VERSION_HEX>=0x03000000 - PyVarObject_HEAD_INIT(&PyType_Type, 0) -#else - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ -#endif - (char *)"SwigPyPacked", /* tp_name */ - sizeof(SwigPyPacked), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)SwigPyPacked_dealloc, /* tp_dealloc */ -#if PY_VERSION_HEX < 0x03080000 - (printfunc)SwigPyPacked_print, /* tp_print */ -#else - 0, /*tp_vectorcall_offset*/ -#endif - (getattrfunc)0, /* tp_getattr */ - (setattrfunc)0, /* tp_setattr */ - (cmpfunc)SwigPyPacked_compare, /* tp_compare */ - (reprfunc)SwigPyPacked_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)0, /* tp_hash */ - (ternaryfunc)0, /* tp_call */ - (reprfunc)SwigPyPacked_str, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - swigpacked_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ -#if PY_VERSION_HEX >= 0x02020000 - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - 0, /* tp_free */ - 0, /* tp_is_gc */ - 0, /* tp_bases */ - 0, /* tp_mro */ - 0, /* tp_cache */ - 0, /* tp_subclasses */ - 0, /* tp_weaklist */ -#endif -#if PY_VERSION_HEX >= 0x02030000 - 0, /* tp_del */ -#endif -#if PY_VERSION_HEX >= 0x02060000 - 0, /* tp_version_tag */ -#endif -#ifdef COUNT_ALLOCS - 0,0,0,0 /* tp_alloc -> tp_next */ -#endif - }; - swigpypacked_type = tmp; - /* for Python 3 the ob_type already assigned in PyVarObject_HEAD_INIT() */ -#if PY_VERSION_HEX < 0x03000000 - swigpypacked_type.ob_type = &PyType_Type; -#endif - type_init = 1; - } - return &swigpypacked_type; -} - -SWIGRUNTIME PyObject * -SwigPyPacked_New(void *ptr, size_t size, swig_type_info *ty) -{ - SwigPyPacked *sobj = PyObject_NEW(SwigPyPacked, SwigPyPacked_type()); - if (sobj) { - void *pack = malloc(size); - if (pack) { - memcpy(pack, ptr, size); - sobj->pack = pack; - sobj->ty = ty; - sobj->size = size; - } else { - PyObject_DEL((PyObject *) sobj); - sobj = 0; - } - } - return (PyObject *) sobj; -} - -SWIGRUNTIME swig_type_info * -SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size) -{ - if (SwigPyPacked_Check(obj)) { - SwigPyPacked *sobj = (SwigPyPacked *)obj; - if (sobj->size != size) return 0; - memcpy(ptr, sobj->pack, size); - return sobj->ty; - } else { - return 0; - } -} - -/* ----------------------------------------------------------------------------- - * pointers/data manipulation - * ----------------------------------------------------------------------------- */ - -SWIGRUNTIMEINLINE PyObject * -_SWIG_This(void) -{ - return SWIG_Python_str_FromChar("this"); -} - -SWIGRUNTIME PyObject * -SWIG_This(void) -{ - static PyObject *SWIG_STATIC_POINTER(swig_this) = _SWIG_This(); - return swig_this; -} - -/* #define SWIG_PYTHON_SLOW_GETSET_THIS */ - -/* TODO: I don't know how to implement the fast getset in Python 3 right now */ -#if PY_VERSION_HEX>=0x03000000 -#define SWIG_PYTHON_SLOW_GETSET_THIS -#endif - -SWIGRUNTIME SwigPyObject * -SWIG_Python_GetSwigThis(PyObject *pyobj) -{ - if (SwigPyObject_Check(pyobj)) { - return (SwigPyObject *) pyobj; - } else { - PyObject *obj = 0; -#if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000)) - if (PyInstance_Check(pyobj)) { - obj = _PyInstance_Lookup(pyobj, SWIG_This()); - } else { - PyObject **dictptr = _PyObject_GetDictPtr(pyobj); - if (dictptr != NULL) { - PyObject *dict = *dictptr; - obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0; - } else { -#ifdef PyWeakref_CheckProxy - if (PyWeakref_CheckProxy(pyobj)) { - PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); - return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; - } -#endif - obj = PyObject_GetAttr(pyobj,SWIG_This()); - if (obj) { - Py_DECREF(obj); - } else { - if (PyErr_Occurred()) PyErr_Clear(); - return 0; - } - } - } -#else - obj = PyObject_GetAttr(pyobj,SWIG_This()); - if (obj) { - Py_DECREF(obj); - } else { - if (PyErr_Occurred()) PyErr_Clear(); - return 0; - } -#endif - if (obj && !SwigPyObject_Check(obj)) { - /* a PyObject is called 'this', try to get the 'real this' - SwigPyObject from it */ - return SWIG_Python_GetSwigThis(obj); - } - return (SwigPyObject *)obj; - } -} - -/* Acquire a pointer value */ - -SWIGRUNTIME int -SWIG_Python_AcquirePtr(PyObject *obj, int own) { - if (own == SWIG_POINTER_OWN) { - SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj); - if (sobj) { - int oldown = sobj->own; - sobj->own = own; - return oldown; - } - } - return 0; -} - -/* Convert a pointer value */ - -SWIGRUNTIME int -SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) { - if (!obj) return SWIG_ERROR; - if (obj == Py_None) { - if (ptr) *ptr = 0; - return SWIG_OK; - } else { - SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj); - if (own) - *own = 0; - while (sobj) { - void *vptr = sobj->ptr; - if (ty) { - swig_type_info *to = sobj->ty; - if (to == ty) { - /* no type cast needed */ - if (ptr) *ptr = vptr; - break; - } else { - swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); - if (!tc) { - sobj = (SwigPyObject *)sobj->next; - } else { - if (ptr) { - int newmemory = 0; - *ptr = SWIG_TypeCast(tc,vptr,&newmemory); - if (newmemory == SWIG_CAST_NEW_MEMORY) { - assert(own); - if (own) - *own = *own | SWIG_CAST_NEW_MEMORY; - } - } - break; - } - } - } else { - if (ptr) *ptr = vptr; - break; - } - } - if (sobj) { - if (own) - *own = *own | sobj->own; - if (flags & SWIG_POINTER_DISOWN) { - sobj->own = 0; - } - return SWIG_OK; - } else { - int res = SWIG_ERROR; - if (flags & SWIG_POINTER_IMPLICIT_CONV) { - SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; - if (data && !data->implicitconv) { - PyObject *klass = data->klass; - if (klass) { - PyObject *impconv; - data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/ - impconv = SWIG_Python_CallFunctor(klass, obj); - data->implicitconv = 0; - if (PyErr_Occurred()) { - PyErr_Clear(); - impconv = 0; - } - if (impconv) { - SwigPyObject *iobj = SWIG_Python_GetSwigThis(impconv); - if (iobj) { - void *vptr; - res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0); - if (SWIG_IsOK(res)) { - if (ptr) { - *ptr = vptr; - /* transfer the ownership to 'ptr' */ - iobj->own = 0; - res = SWIG_AddCast(res); - res = SWIG_AddNewMask(res); - } else { - res = SWIG_AddCast(res); - } - } - } - Py_DECREF(impconv); - } - } - } - } - return res; - } - } -} - -/* Convert a function ptr value */ - -SWIGRUNTIME int -SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { - if (!PyCFunction_Check(obj)) { - return SWIG_ConvertPtr(obj, ptr, ty, 0); - } else { - void *vptr = 0; - - /* here we get the method pointer for callbacks */ - const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); - const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; - if (desc) { - desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; - if (!desc) return SWIG_ERROR; - } - if (ty) { - swig_cast_info *tc = SWIG_TypeCheck(desc,ty); - if (tc) { - int newmemory = 0; - *ptr = SWIG_TypeCast(tc,vptr,&newmemory); - assert(!newmemory); /* newmemory handling not yet implemented */ - } else { - return SWIG_ERROR; - } - } else { - *ptr = vptr; - } - return SWIG_OK; - } -} - -/* Convert a packed value value */ - -SWIGRUNTIME int -SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) { - swig_type_info *to = SwigPyPacked_UnpackData(obj, ptr, sz); - if (!to) return SWIG_ERROR; - if (ty) { - if (to != ty) { - /* check type cast? */ - swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); - if (!tc) return SWIG_ERROR; - } - } - return SWIG_OK; -} - -/* ----------------------------------------------------------------------------- - * Create a new pointer object - * ----------------------------------------------------------------------------- */ - -/* - Create a new instance object, whitout calling __init__, and set the - 'this' attribute. -*/ - -SWIGRUNTIME PyObject* -SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) -{ -#if (PY_VERSION_HEX >= 0x02020000) - PyObject *inst = 0; - PyObject *newraw = data->newraw; - if (newraw) { - inst = PyObject_Call(newraw, data->newargs, NULL); - if (inst) { -#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) - PyObject **dictptr = _PyObject_GetDictPtr(inst); - if (dictptr != NULL) { - PyObject *dict = *dictptr; - if (dict == NULL) { - dict = PyDict_New(); - *dictptr = dict; - PyDict_SetItem(dict, SWIG_This(), swig_this); - } - } -#else - PyObject *key = SWIG_This(); - PyObject_SetAttr(inst, key, swig_this); -#endif - } - } else { -#if PY_VERSION_HEX >= 0x03000000 - inst = PyBaseObject_Type.tp_new((PyTypeObject*) data->newargs, Py_None, Py_None); - Py_INCREF(data->newargs); - PyObject_SetAttr(inst, SWIG_This(), swig_this); - Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; -#else - PyObject *dict = PyDict_New(); - PyDict_SetItem(dict, SWIG_This(), swig_this); - inst = PyInstance_NewRaw(data->newargs, dict); - Py_DECREF(dict); -#endif - } - return inst; -#else -#if (PY_VERSION_HEX >= 0x02010000) - PyObject *inst; - PyObject *dict = PyDict_New(); - PyDict_SetItem(dict, SWIG_This(), swig_this); - inst = PyInstance_NewRaw(data->newargs, dict); - Py_DECREF(dict); - return (PyObject *) inst; -#else - PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type); - if (inst == NULL) { - return NULL; - } - inst->in_class = (PyClassObject *)data->newargs; - Py_INCREF(inst->in_class); - inst->in_dict = PyDict_New(); - if (inst->in_dict == NULL) { - Py_DECREF(inst); - return NULL; - } -#ifdef Py_TPFLAGS_HAVE_WEAKREFS - inst->in_weakreflist = NULL; -#endif -#ifdef Py_TPFLAGS_GC - PyObject_GC_Init(inst); -#endif - PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this); - return (PyObject *) inst; -#endif -#endif -} - -SWIGRUNTIME void -SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) -{ - PyObject *dict; -#if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS) - PyObject **dictptr = _PyObject_GetDictPtr(inst); - if (dictptr != NULL) { - dict = *dictptr; - if (dict == NULL) { - dict = PyDict_New(); - *dictptr = dict; - } - PyDict_SetItem(dict, SWIG_This(), swig_this); - return; - } -#endif - dict = PyObject_GetAttrString(inst, (char*)"__dict__"); - PyDict_SetItem(dict, SWIG_This(), swig_this); - Py_DECREF(dict); -} - - -SWIGINTERN PyObject * -SWIG_Python_InitShadowInstance(PyObject *args) { - PyObject *obj[2]; - if (!SWIG_Python_UnpackTuple(args,(char*)"swiginit", 2, 2, obj)) { - return NULL; - } else { - SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]); - if (sthis) { - SwigPyObject_append((PyObject*) sthis, obj[1]); - } else { - SWIG_Python_SetSwigThis(obj[0], obj[1]); - } - return SWIG_Py_Void(); - } -} - -/* Create a new pointer object */ - -SWIGRUNTIME PyObject * -SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int flags) { - if (!ptr) { - return SWIG_Py_Void(); - } else { - int own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0; - PyObject *robj = SwigPyObject_New(ptr, type, own); - SwigPyClientData *clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0; - if (clientdata && !(flags & SWIG_POINTER_NOSHADOW)) { - PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj); - if (inst) { - Py_DECREF(robj); - robj = inst; - } - } - return robj; - } -} - -/* Create a new packed object */ - -SWIGRUNTIMEINLINE PyObject * -SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { - return ptr ? SwigPyPacked_New((void *) ptr, sz, type) : SWIG_Py_Void(); -} - -/* -----------------------------------------------------------------------------* - * Get type list - * -----------------------------------------------------------------------------*/ - -#ifdef SWIG_LINK_RUNTIME -void *SWIG_ReturnGlobalTypeList(void *); -#endif - -SWIGRUNTIME swig_module_info * -SWIG_Python_GetModule(void) { - static void *type_pointer = (void *)0; - /* first check if module already created */ - if (!type_pointer) { -#ifdef SWIG_LINK_RUNTIME - type_pointer = SWIG_ReturnGlobalTypeList((void *)0); -#else - type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, - (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); - if (PyErr_Occurred()) { - PyErr_Clear(); - type_pointer = (void *)0; - } -#endif - } - return (swig_module_info *) type_pointer; -} - -#if PY_MAJOR_VERSION < 2 -/* PyModule_AddObject function was introduced in Python 2.0. The following function - is copied out of Python/modsupport.c in python version 2.3.4 */ -SWIGINTERN int -PyModule_AddObject(PyObject *m, char *name, PyObject *o) -{ - PyObject *dict; - if (!PyModule_Check(m)) { - PyErr_SetString(PyExc_TypeError, - "PyModule_AddObject() needs module as first arg"); - return SWIG_ERROR; - } - if (!o) { - PyErr_SetString(PyExc_TypeError, - "PyModule_AddObject() needs non-NULL value"); - return SWIG_ERROR; - } - - dict = PyModule_GetDict(m); - if (dict == NULL) { - /* Internal error -- modules must have a dict! */ - PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", - PyModule_GetName(m)); - return SWIG_ERROR; - } - if (PyDict_SetItemString(dict, name, o)) - return SWIG_ERROR; - Py_DECREF(o); - return SWIG_OK; -} -#endif - -SWIGRUNTIME void -SWIG_Python_DestroyModule(void *vptr) -{ - swig_module_info *swig_module = (swig_module_info *) vptr; - swig_type_info **types = swig_module->types; - size_t i; - for (i =0; i < swig_module->size; ++i) { - swig_type_info *ty = types[i]; - if (ty->owndata) { - SwigPyClientData *data = (SwigPyClientData *) ty->clientdata; - if (data) SwigPyClientData_Del(data); - } - } - Py_DECREF(SWIG_This()); -} - -SWIGRUNTIME void -SWIG_Python_SetModule(swig_module_info *swig_module) { - static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */ - -#if PY_VERSION_HEX >= 0x03000000 - /* Add a dummy module object into sys.modules */ - PyObject *module = PyImport_AddModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION); -#else - PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, - swig_empty_runtime_method_table); -#endif - PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule); - if (pointer && module) { - PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); - } else { - Py_XDECREF(pointer); - } -} - -/* The python cached type query */ -SWIGRUNTIME PyObject * -SWIG_Python_TypeCache(void) { - static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New(); - return cache; -} - -SWIGRUNTIME swig_type_info * -SWIG_Python_TypeQuery(const char *type) -{ - PyObject *cache = SWIG_Python_TypeCache(); - PyObject *key = SWIG_Python_str_FromChar(type); - PyObject *obj = PyDict_GetItem(cache, key); - swig_type_info *descriptor; - if (obj) { - descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj); - } else { - swig_module_info *swig_module = SWIG_Python_GetModule(); - descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); - if (descriptor) { - obj = PyCObject_FromVoidPtr(descriptor, NULL); - PyDict_SetItem(cache, key, obj); - Py_DECREF(obj); - } - } - Py_DECREF(key); - return descriptor; -} - -/* - For backward compatibility only -*/ -#define SWIG_POINTER_EXCEPTION 0 -#define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg) -#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags) - -SWIGRUNTIME int -SWIG_Python_AddErrMesg(const char* mesg, int infront) -{ - if (PyErr_Occurred()) { - PyObject *type = 0; - PyObject *value = 0; - PyObject *traceback = 0; - PyErr_Fetch(&type, &value, &traceback); - if (value) { - PyObject *old_str = PyObject_Str(value); - Py_XINCREF(type); - PyErr_Clear(); - if (infront) { - PyErr_Format(type, "%s %s", mesg, SWIG_Python_str_AsChar(old_str)); - } else { - PyErr_Format(type, "%s %s", SWIG_Python_str_AsChar(old_str), mesg); - } - Py_DECREF(old_str); - } - return 1; - } else { - return 0; - } -} - -SWIGRUNTIME int -SWIG_Python_ArgFail(int argnum) -{ - if (PyErr_Occurred()) { - /* add information about failing argument */ - char mesg[256]; - PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum); - return SWIG_Python_AddErrMesg(mesg, 1); - } else { - return 0; - } -} - -SWIGRUNTIMEINLINE const char * -SwigPyObject_GetDesc(PyObject *self) -{ - SwigPyObject *v = (SwigPyObject *)self; - swig_type_info *ty = v ? v->ty : 0; - return ty ? ty->str : (char*)""; -} - -SWIGRUNTIME void -SWIG_Python_TypeError(const char *type, PyObject *obj) -{ - if (type) { -#if defined(SWIG_COBJECT_TYPES) - if (obj && SwigPyObject_Check(obj)) { - const char *otype = (const char *) SwigPyObject_GetDesc(obj); - if (otype) { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received", - type, otype); - return; - } - } else -#endif - { - const char *otype = (obj ? obj->ob_type->tp_name : 0); - if (otype) { - PyObject *str = PyObject_Str(obj); - const char *cstr = str ? SWIG_Python_str_AsChar(str) : 0; - if (cstr) { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", - type, otype, cstr); - } else { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", - type, otype); - } - Py_XDECREF(str); - return; - } - } - PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); - } else { - PyErr_Format(PyExc_TypeError, "unexpected type is received"); - } -} - - -/* Convert a pointer value, signal an exception on a type mismatch */ -SWIGRUNTIME void * -SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) { - void *result; - if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { - PyErr_Clear(); - if (flags & SWIG_POINTER_EXCEPTION) { - SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); - SWIG_Python_ArgFail(argnum); - } - } - return result; -} - - -#ifdef __cplusplus -#if 0 -{ /* cc-mode */ -#endif -} -#endif -/* -----------------------------------------------------------------------------* - Standard SWIG API for use inside user code. - - Don't include this file directly, run the command - swig -python -external-runtime - Also, read the Modules chapter of the SWIG Manual. - - * -----------------------------------------------------------------------------*/ - -#ifdef SWIG_MODULE_CLIENTDATA_TYPE - -SWIGRUNTIMEINLINE swig_type_info * -SWIG_TypeQuery(SWIG_MODULE_CLIENTDATA_TYPE clientdata, const char *name) { - swig_module_info *module = SWIG_GetModule(clientdata); - return SWIG_TypeQueryModule(module, module, name); -} - -SWIGRUNTIMEINLINE swig_type_info * -SWIG_MangledTypeQuery(SWIG_MODULE_CLIENTDATA_TYPE clientdata, const char *name) { - swig_module_info *module = SWIG_GetModule(clientdata); - return SWIG_MangledTypeQueryModule(module, module, name); -} - -#else - -SWIGRUNTIMEINLINE swig_type_info * -SWIG_TypeQuery(const char *name) { - swig_module_info *module = SWIG_GetModule(NULL); - return SWIG_TypeQueryModule(module, module, name); -} - -SWIGRUNTIMEINLINE swig_type_info * -SWIG_MangledTypeQuery(const char *name) { - swig_module_info *module = SWIG_GetModule(NULL); - return SWIG_MangledTypeQueryModule(module, module, name); -} - -#endif diff --git a/src/Base/swigpyrun_1.3.40.cpp b/src/Base/swigpyrun_1.3.40.cpp deleted file mode 100644 index 09e87c88b9..0000000000 --- a/src/Base/swigpyrun_1.3.40.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/*************************************************************************** - * Copyright (c) 2010 Werner Mayer * - * * - * 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" -#include "PyExport.h" -#include "Exception.h" -#include -#if defined(__clang__) -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wdeprecated-register" -# pragma clang diagnostic ignored "-Wself-assign" -#elif defined (__GNUC__) -# pragma GCC diagnostic push -# if __GNUC__ >= 8 -# pragma GCC diagnostic ignored "-Wcast-function-type" -# endif -#endif -namespace Swig_1_3_40 { -#define SWIG_PYTHON_NO_BUILD_NONE -#include "swigpyrun_1.3.40.h" -#include "swigpyrun.inl" -} -#if defined(__clang__) -# pragma clang diagnostic pop -#elif defined (__GNUC__) -# pragma GCC diagnostic pop -#endif - diff --git a/src/Base/swigpyrun_1.3.40.h b/src/Base/swigpyrun_1.3.40.h deleted file mode 100644 index 400db8b478..0000000000 --- a/src/Base/swigpyrun_1.3.40.h +++ /dev/null @@ -1,2706 +0,0 @@ -/* ---------------------------------------------------------------------------- - * This file was automatically generated by SWIG (http://www.swig.org). - * Version 1.3.40 - * - * This file is not intended to be easily readable and contains a number of - * coding conventions designed to improve portability and efficiency. Do not make - * changes to this file unless you know what you are doing--modify the SWIG - * interface file instead. - * ----------------------------------------------------------------------------- */ - -/* ----------------------------------------------------------------------------- - * This section contains generic SWIG labels for method/variable - * declarations/attributes, and other compiler dependent labels. - * ----------------------------------------------------------------------------- */ - -/* template workaround for compilers that cannot correctly implement the C++ standard */ -#ifndef SWIGTEMPLATEDISAMBIGUATOR -# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560) -# define SWIGTEMPLATEDISAMBIGUATOR template -# elif defined(__HP_aCC) -/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */ -/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */ -# define SWIGTEMPLATEDISAMBIGUATOR template -# else -# define SWIGTEMPLATEDISAMBIGUATOR -# endif -#endif - -/* inline attribute */ -#ifndef SWIGINLINE -# if defined(__cplusplus) || (defined(__GNUC__) && !defined(__STRICT_ANSI__)) -# define SWIGINLINE inline -# else -# define SWIGINLINE -# endif -#endif - -/* attribute recognised by some compilers to avoid 'unused' warnings */ -#ifndef SWIGUNUSED -# if defined(__GNUC__) -# if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4)) -# define SWIGUNUSED __attribute__ ((__unused__)) -# else -# define SWIGUNUSED -# endif -# elif defined(__ICC) -# define SWIGUNUSED __attribute__ ((__unused__)) -# else -# define SWIGUNUSED -# endif -#endif - -#ifndef SWIG_MSC_UNSUPPRESS_4505 -# if defined(_MSC_VER) -# pragma warning(disable : 4505) /* unreferenced local function has been removed */ -# endif -#endif - -#ifndef SWIGUNUSEDPARM -# ifdef __cplusplus -# define SWIGUNUSEDPARM(p) -# else -# define SWIGUNUSEDPARM(p) p SWIGUNUSED -# endif -#endif - -/* internal SWIG method */ -#ifndef SWIGINTERN -# define SWIGINTERN static SWIGUNUSED -#endif - -/* internal inline SWIG method */ -#ifndef SWIGINTERNINLINE -# define SWIGINTERNINLINE SWIGINTERN SWIGINLINE -#endif - -/* exporting methods */ -#if (__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# ifndef GCC_HASCLASSVISIBILITY -# define GCC_HASCLASSVISIBILITY -# endif -#endif - -#ifndef SWIGEXPORT -# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# if defined(STATIC_LINKED) -# define SWIGEXPORT -# else -# define SWIGEXPORT __declspec(dllexport) -# endif -# else -# if defined(__GNUC__) && defined(GCC_HASCLASSVISIBILITY) -# define SWIGEXPORT __attribute__ ((visibility("default"))) -# else -# define SWIGEXPORT -# endif -# endif -#endif - -/* calling conventions for Windows */ -#ifndef SWIGSTDCALL -# if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# define SWIGSTDCALL __stdcall -# else -# define SWIGSTDCALL -# endif -#endif - -/* Deal with Microsoft's attempt at deprecating C standard runtime functions */ -#if !defined(SWIG_NO_CRT_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_CRT_SECURE_NO_DEPRECATE) -# define _CRT_SECURE_NO_DEPRECATE -#endif - -/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */ -#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE) -# define _SCL_SECURE_NO_DEPRECATE -#endif - -/* Errors in SWIG */ -#define SWIG_UnknownError -1 -#define SWIG_IOError -2 -#define SWIG_RuntimeError -3 -#define SWIG_IndexError -4 -#define SWIG_TypeError -5 -#define SWIG_DivisionByZero -6 -#define SWIG_OverflowError -7 -#define SWIG_SyntaxError -8 -#define SWIG_ValueError -9 -#define SWIG_SystemError -10 -#define SWIG_AttributeError -11 -#define SWIG_MemoryError -12 -#define SWIG_NullReferenceError -13 - - -/* Errors in SWIG */ -#define SWIG_UnknownError -1 -#define SWIG_IOError -2 -#define SWIG_RuntimeError -3 -#define SWIG_IndexError -4 -#define SWIG_TypeError -5 -#define SWIG_DivisionByZero -6 -#define SWIG_OverflowError -7 -#define SWIG_SyntaxError -8 -#define SWIG_ValueError -9 -#define SWIG_SystemError -10 -#define SWIG_AttributeError -11 -#define SWIG_MemoryError -12 -#define SWIG_NullReferenceError -13 - - -/* ----------------------------------------------------------------------------- - * swigrun.swg - * - * This file contains generic C API SWIG runtime support for pointer - * type checking. - * ----------------------------------------------------------------------------- */ - -/* This should only be incremented when either the layout of swig_type_info changes, - or for whatever reason, the runtime changes incompatibly */ -#define SWIG_RUNTIME_VERSION "4" - -/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */ -#ifdef SWIG_TYPE_TABLE -# define SWIG_QUOTE_STRING(x) #x -# define SWIG_EXPAND_AND_QUOTE_STRING(x) SWIG_QUOTE_STRING(x) -# define SWIG_TYPE_TABLE_NAME SWIG_EXPAND_AND_QUOTE_STRING(SWIG_TYPE_TABLE) -#else -# define SWIG_TYPE_TABLE_NAME -#endif - -/* - You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for - creating a static or dynamic library from the SWIG runtime code. - In 99.9% of the cases, SWIG just needs to declare them as 'static'. - - But only do this if strictly necessary, ie, if you have problems - with your compiler or suchlike. -*/ - -#ifndef SWIGRUNTIME -# define SWIGRUNTIME SWIGINTERN -#endif - -#ifndef SWIGRUNTIMEINLINE -# define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE -#endif - -/* Generic buffer size */ -#ifndef SWIG_BUFFER_SIZE -# define SWIG_BUFFER_SIZE 1024 -#endif - -/* Flags for pointer conversions */ -#define SWIG_POINTER_DISOWN 0x1 -#define SWIG_CAST_NEW_MEMORY 0x2 - -/* Flags for new pointer objects */ -#define SWIG_POINTER_OWN 0x1 - - -/* - Flags/methods for returning states. - - The SWIG conversion methods, as ConvertPtr, return and integer - that tells if the conversion was successful or not. And if not, - an error code can be returned (see swigerrors.swg for the codes). - - Use the following macros/flags to set or process the returning - states. - - In old versions of SWIG, code such as the following was usually written: - - if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) { - // success code - } else { - //fail code - } - - Now you can be more explicit: - - int res = SWIG_ConvertPtr(obj,vptr,ty.flags); - if (SWIG_IsOK(res)) { - // success code - } else { - // fail code - } - - which is the same really, but now you can also do - - Type *ptr; - int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags); - if (SWIG_IsOK(res)) { - // success code - if (SWIG_IsNewObj(res) { - ... - delete *ptr; - } else { - ... - } - } else { - // fail code - } - - I.e., now SWIG_ConvertPtr can return new objects and you can - identify the case and take care of the deallocation. Of course that - also requires SWIG_ConvertPtr to return new result values, such as - - int SWIG_ConvertPtr(obj, ptr,...) { - if () { - if () { - *ptr = ; - return SWIG_NEWOBJ; - } else { - *ptr = ; - return SWIG_OLDOBJ; - } - } else { - return SWIG_BADOBJ; - } - } - - Of course, returning the plain '0(success)/-1(fail)' still works, but you can be - more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the - SWIG errors code. - - Finally, if the SWIG_CASTRANK_MODE is enabled, the result code - allows to return the 'cast rank', for example, if you have this - - int food(double) - int fooi(int); - - and you call - - food(1) // cast rank '1' (1 -> 1.0) - fooi(1) // cast rank '0' - - just use the SWIG_AddCast()/SWIG_CheckState() -*/ - -#define SWIG_OK (0) -#define SWIG_ERROR (-1) -#define SWIG_IsOK(r) (r >= 0) -#define SWIG_ArgError(r) ((r != SWIG_ERROR) ? r : SWIG_TypeError) - -/* The CastRankLimit says how many bits are used for the cast rank */ -#define SWIG_CASTRANKLIMIT (1 << 8) -/* The NewMask denotes the object was created (using new/malloc) */ -#define SWIG_NEWOBJMASK (SWIG_CASTRANKLIMIT << 1) -/* The TmpMask is for in/out typemaps that use temporal objects */ -#define SWIG_TMPOBJMASK (SWIG_NEWOBJMASK << 1) -/* Simple returning values */ -#define SWIG_BADOBJ (SWIG_ERROR) -#define SWIG_OLDOBJ (SWIG_OK) -#define SWIG_NEWOBJ (SWIG_OK | SWIG_NEWOBJMASK) -#define SWIG_TMPOBJ (SWIG_OK | SWIG_TMPOBJMASK) -/* Check, add and del mask methods */ -#define SWIG_AddNewMask(r) (SWIG_IsOK(r) ? (r | SWIG_NEWOBJMASK) : r) -#define SWIG_DelNewMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_NEWOBJMASK) : r) -#define SWIG_IsNewObj(r) (SWIG_IsOK(r) && (r & SWIG_NEWOBJMASK)) -#define SWIG_AddTmpMask(r) (SWIG_IsOK(r) ? (r | SWIG_TMPOBJMASK) : r) -#define SWIG_DelTmpMask(r) (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r) -#define SWIG_IsTmpObj(r) (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK)) - -/* Cast-Rank Mode */ -#if defined(SWIG_CASTRANK_MODE) -# ifndef SWIG_TypeRank -# define SWIG_TypeRank unsigned long -# endif -# ifndef SWIG_MAXCASTRANK /* Default cast allowed */ -# define SWIG_MAXCASTRANK (2) -# endif -# define SWIG_CASTRANKMASK ((SWIG_CASTRANKLIMIT) -1) -# define SWIG_CastRank(r) (r & SWIG_CASTRANKMASK) -SWIGINTERNINLINE int SWIG_AddCast(int r) { - return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r; -} -SWIGINTERNINLINE int SWIG_CheckState(int r) { - return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; -} -#else /* no cast-rank mode */ -# define SWIG_AddCast -# define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0) -#endif - - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void *(*swig_converter_func)(void *, int *); -typedef struct swig_type_info *(*swig_dycast_func)(void **); - -/* Structure to store information on one type */ -typedef struct swig_type_info { - const char *name; /* mangled name of this type */ - const char *str; /* human readable name of this type */ - swig_dycast_func dcast; /* dynamic cast function down a hierarchy */ - struct swig_cast_info *cast; /* linked list of types that can cast into this type */ - void *clientdata; /* language specific type data */ - int owndata; /* flag if the structure owns the clientdata */ -} swig_type_info; - -/* Structure to store a type and conversion function used for casting */ -typedef struct swig_cast_info { - swig_type_info *type; /* pointer to type that is equivalent to this type */ - swig_converter_func converter; /* function to cast the void pointers */ - struct swig_cast_info *next; /* pointer to next cast in linked list */ - struct swig_cast_info *prev; /* pointer to the previous cast */ -} swig_cast_info; - -/* Structure used to store module information - * Each module generates one structure like this, and the runtime collects - * all of these structures and stores them in a circularly linked list.*/ -typedef struct swig_module_info { - swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */ - size_t size; /* Number of types in this module */ - struct swig_module_info *next; /* Pointer to next element in circularly linked list */ - swig_type_info **type_initial; /* Array of initially generated type structures */ - swig_cast_info **cast_initial; /* Array of initially generated casting structures */ - void *clientdata; /* Language specific module data */ -} swig_module_info; - -/* - Compare two type names skipping the space characters, therefore - "char*" == "char *" and "Class" == "Class", etc. - - Return 0 when the two name types are equivalent, as in - strncmp, but skipping ' '. -*/ -SWIGRUNTIME int -SWIG_TypeNameComp(const char *f1, const char *l1, - const char *f2, const char *l2) { - for (;(f1 != l1) && (f2 != l2); ++f1, ++f2) { - while ((*f1 == ' ') && (f1 != l1)) ++f1; - while ((*f2 == ' ') && (f2 != l2)) ++f2; - if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1; - } - return (int)((l1 - f1) - (l2 - f2)); -} - -/* - Check type equivalence in a name list like ||... - Return 0 if not equal, 1 if equal -*/ -SWIGRUNTIME int -SWIG_TypeEquiv(const char *nb, const char *tb) { - int equiv = 0; - const char* te = tb + strlen(tb); - const char* ne = nb; - while (!equiv && *ne) { - for (nb = ne; *ne; ++ne) { - if (*ne == '|') break; - } - equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; - if (*ne) ++ne; - } - return equiv; -} - -/* - Check type equivalence in a name list like ||... - Return 0 if equal, -1 if nb < tb, 1 if nb > tb -*/ -SWIGRUNTIME int -SWIG_TypeCompare(const char *nb, const char *tb) { - int equiv = 0; - const char* te = tb + strlen(tb); - const char* ne = nb; - while (!equiv && *ne) { - for (nb = ne; *ne; ++ne) { - if (*ne == '|') break; - } - equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0; - if (*ne) ++ne; - } - return equiv; -} - - -/* - Check the typename -*/ -SWIGRUNTIME swig_cast_info * -SWIG_TypeCheck(const char *c, swig_type_info *ty) { - if (ty) { - swig_cast_info *iter = ty->cast; - while (iter) { - if (strcmp(iter->type->name, c) == 0) { - if (iter == ty->cast) - return iter; - /* Move iter to the top of the linked list */ - iter->prev->next = iter->next; - if (iter->next) - iter->next->prev = iter->prev; - iter->next = ty->cast; - iter->prev = 0; - if (ty->cast) ty->cast->prev = iter; - ty->cast = iter; - return iter; - } - iter = iter->next; - } - } - return 0; -} - -/* - Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison -*/ -SWIGRUNTIME swig_cast_info * -SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) { - if (ty) { - swig_cast_info *iter = ty->cast; - while (iter) { - if (iter->type == from) { - if (iter == ty->cast) - return iter; - /* Move iter to the top of the linked list */ - iter->prev->next = iter->next; - if (iter->next) - iter->next->prev = iter->prev; - iter->next = ty->cast; - iter->prev = 0; - if (ty->cast) ty->cast->prev = iter; - ty->cast = iter; - return iter; - } - iter = iter->next; - } - } - return 0; -} - -/* - Cast a pointer up an inheritance hierarchy -*/ -SWIGRUNTIMEINLINE void * -SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) { - return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory); -} - -/* - Dynamic pointer casting. Down an inheritance hierarchy -*/ -SWIGRUNTIME swig_type_info * -SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr) { - swig_type_info *lastty = ty; - if (!ty || !ty->dcast) return ty; - while (ty && (ty->dcast)) { - ty = (*ty->dcast)(ptr); - if (ty) lastty = ty; - } - return lastty; -} - -/* - Return the name associated with this type -*/ -SWIGRUNTIMEINLINE const char * -SWIG_TypeName(const swig_type_info *ty) { - return ty->name; -} - -/* - Return the pretty name associated with this type, - that is an unmangled type name in a form presentable to the user. -*/ -SWIGRUNTIME const char * -SWIG_TypePrettyName(const swig_type_info *type) { - /* The "str" field contains the equivalent pretty names of the - type, separated by vertical-bar characters. We choose - to print the last name, as it is often (?) the most - specific. */ - if (!type) return NULL; - if (type->str != NULL) { - const char *last_name = type->str; - const char *s; - for (s = type->str; *s; s++) - if (*s == '|') last_name = s+1; - return last_name; - } - else - return type->name; -} - -/* - Set the clientdata field for a type -*/ -SWIGRUNTIME void -SWIG_TypeClientData(swig_type_info *ti, void *clientdata) { - swig_cast_info *cast = ti->cast; - /* if (ti->clientdata == clientdata) return; */ - ti->clientdata = clientdata; - - while (cast) { - if (!cast->converter) { - swig_type_info *tc = cast->type; - if (!tc->clientdata) { - SWIG_TypeClientData(tc, clientdata); - } - } - cast = cast->next; - } -} -SWIGRUNTIME void -SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) { - SWIG_TypeClientData(ti, clientdata); - ti->owndata = 1; -} - -/* - Search for a swig_type_info structure only by mangled name - Search is a O(log #types) - - We start searching at module start, and finish searching when start == end. - Note: if start == end at the beginning of the function, we go all the way around - the circular list. -*/ -SWIGRUNTIME swig_type_info * -SWIG_MangledTypeQueryModule(swig_module_info *start, - swig_module_info *end, - const char *name) { - swig_module_info *iter = start; - do { - if (iter->size) { - register size_t l = 0; - register size_t r = iter->size - 1; - do { - /* since l+r >= 0, we can (>> 1) instead (/ 2) */ - register size_t i = (l + r) >> 1; - const char *iname = iter->types[i]->name; - if (iname) { - register int compare = strcmp(name, iname); - if (compare == 0) { - return iter->types[i]; - } else if (compare < 0) { - if (i) { - r = i - 1; - } else { - break; - } - } else if (compare > 0) { - l = i + 1; - } - } else { - break; /* should never happen */ - } - } while (l <= r); - } - iter = iter->next; - } while (iter != end); - return 0; -} - -/* - Search for a swig_type_info structure for either a mangled name or a human readable name. - It first searches the mangled names of the types, which is a O(log #types) - If a type is not found it then searches the human readable names, which is O(#types). - - We start searching at module start, and finish searching when start == end. - Note: if start == end at the beginning of the function, we go all the way around - the circular list. -*/ -SWIGRUNTIME swig_type_info * -SWIG_TypeQueryModule(swig_module_info *start, - swig_module_info *end, - const char *name) { - /* STEP 1: Search the name field using binary search */ - swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name); - if (ret) { - return ret; - } else { - /* STEP 2: If the type hasn't been found, do a complete search - of the str field (the human readable name) */ - swig_module_info *iter = start; - do { - register size_t i = 0; - for (; i < iter->size; ++i) { - if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name))) - return iter->types[i]; - } - iter = iter->next; - } while (iter != end); - } - - /* neither found a match */ - return 0; -} - -/* - Pack binary data into a string -*/ -SWIGRUNTIME char * -SWIG_PackData(char *c, void *ptr, size_t sz) { - static const char hex[17] = "0123456789abcdef"; - register const unsigned char *u = (unsigned char *) ptr; - register const unsigned char *eu = u + sz; - for (; u != eu; ++u) { - register unsigned char uu = *u; - *(c++) = hex[(uu & 0xf0) >> 4]; - *(c++) = hex[uu & 0xf]; - } - return c; -} - -/* - Unpack binary data from a string -*/ -SWIGRUNTIME const char * -SWIG_UnpackData(const char *c, void *ptr, size_t sz) { - register unsigned char *u = (unsigned char *) ptr; - register const unsigned char *eu = u + sz; - for (; u != eu; ++u) { - register char d = *(c++); - register unsigned char uu; - if ((d >= '0') && (d <= '9')) - uu = ((d - '0') << 4); - else if ((d >= 'a') && (d <= 'f')) - uu = ((d - ('a'-10)) << 4); - else - return (char *) 0; - d = *(c++); - if ((d >= '0') && (d <= '9')) - uu |= (d - '0'); - else if ((d >= 'a') && (d <= 'f')) - uu |= (d - ('a'-10)); - else - return (char *) 0; - *u = uu; - } - return c; -} - -/* - Pack 'void *' into a string buffer. -*/ -SWIGRUNTIME char * -SWIG_PackVoidPtr(char *buff, void *ptr, const char *name, size_t bsz) { - char *r = buff; - if ((2*sizeof(void *) + 2) > bsz) return 0; - *(r++) = '_'; - r = SWIG_PackData(r,&ptr,sizeof(void *)); - if (strlen(name) + 1 > (bsz - (r - buff))) return 0; - strcpy(r,name); - return buff; -} - -SWIGRUNTIME const char * -SWIG_UnpackVoidPtr(const char *c, void **ptr, const char *name) { - if (*c != '_') { - if (strcmp(c,"NULL") == 0) { - *ptr = (void *) 0; - return name; - } else { - return 0; - } - } - return SWIG_UnpackData(++c,ptr,sizeof(void *)); -} - -SWIGRUNTIME char * -SWIG_PackDataName(char *buff, void *ptr, size_t sz, const char *name, size_t bsz) { - char *r = buff; - size_t lname = (name ? strlen(name) : 0); - if ((2*sz + 2 + lname) > bsz) return 0; - *(r++) = '_'; - r = SWIG_PackData(r,ptr,sz); - if (lname) { - strncpy(r,name,lname+1); - } else { - *r = 0; - } - return buff; -} - -SWIGRUNTIME const char * -SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) { - if (*c != '_') { - if (strcmp(c,"NULL") == 0) { - memset(ptr,0,sz); - return name; - } else { - return 0; - } - } - return SWIG_UnpackData(++c,ptr,sz); -} - -#ifdef __cplusplus -} -#endif -/* Compatibility macros for Python 3 */ -#if PY_VERSION_HEX >= 0x03000000 - -#define PyClass_Check(obj) PyObject_IsInstance(obj, (PyObject *)&PyType_Type) -#define PyInt_Check(x) PyLong_Check(x) -#define PyInt_AsLong(x) PyLong_AsLong(x) -#define PyInt_FromLong(x) PyLong_FromLong(x) -#define PyString_Format(fmt, args) PyUnicode_Format(fmt, args) - -#endif - -#ifndef Py_TYPE -# define Py_TYPE(op) ((op)->ob_type) -#endif - -/* SWIG APIs for compatibility of both Python 2 & 3 */ - -#if PY_VERSION_HEX >= 0x03000000 -# define SWIG_Python_str_FromFormat PyUnicode_FromFormat -#else -# define SWIG_Python_str_FromFormat PyString_FromFormat -#endif - - -/* Warning: This function will allocate a new string in Python 3, - * so please call SWIG_Python_str_DelForPy3(x) to free the space. - */ -SWIGINTERN char* -SWIG_Python_str_AsChar(PyObject *str) -{ -#if PY_VERSION_HEX >= 0x03000000 - char *cstr; - char *newstr; - Py_ssize_t len; - str = PyUnicode_AsUTF8String(str); - PyBytes_AsStringAndSize(str, &cstr, &len); - newstr = (char *) malloc(len+1); - memcpy(newstr, cstr, len+1); - Py_XDECREF(str); - return newstr; -#else - return PyString_AsString(str); -#endif -} - -#if PY_VERSION_HEX >= 0x03000000 -# define SWIG_Python_str_DelForPy3(x) free( (void*) (x) ) -#else -# define SWIG_Python_str_DelForPy3(x) -#endif - - -SWIGINTERN PyObject* -SWIG_Python_str_FromChar(const char *c) -{ -#if PY_VERSION_HEX >= 0x03000000 - return PyUnicode_FromString(c); -#else - return PyString_FromString(c); -#endif -} - -/* Add PyOS_snprintf for old Pythons */ -#if PY_VERSION_HEX < 0x02020000 -# if defined(_MSC_VER) || defined(__BORLANDC__) || defined(_WATCOM) -# define PyOS_snprintf _snprintf -# else -# define PyOS_snprintf snprintf -# endif -#endif - -/* A crude PyString_FromFormat implementation for old Pythons */ -#if PY_VERSION_HEX < 0x02020000 - -#ifndef SWIG_PYBUFFER_SIZE -# define SWIG_PYBUFFER_SIZE 1024 -#endif - -static PyObject * -PyString_FromFormat(const char *fmt, ...) { - va_list ap; - char buf[SWIG_PYBUFFER_SIZE * 2]; - int res; - va_start(ap, fmt); - res = vsnprintf(buf, sizeof(buf), fmt, ap); - va_end(ap); - return (res < 0 || res >= (int)sizeof(buf)) ? 0 : PyString_FromString(buf); -} -#endif - -/* Add PyObject_Del for old Pythons */ -#if PY_VERSION_HEX < 0x01060000 -# define PyObject_Del(op) PyMem_DEL((op)) -#endif -#ifndef PyObject_DEL -# define PyObject_DEL PyObject_Del -#endif - -/* A crude PyExc_StopIteration exception for old Pythons */ -#if PY_VERSION_HEX < 0x02020000 -# ifndef PyExc_StopIteration -# define PyExc_StopIteration PyExc_RuntimeError -# endif -# ifndef PyObject_GenericGetAttr -# define PyObject_GenericGetAttr 0 -# endif -#endif - -/* Py_NotImplemented is defined in 2.1 and up. */ -#if PY_VERSION_HEX < 0x02010000 -# ifndef Py_NotImplemented -# define Py_NotImplemented PyExc_RuntimeError -# endif -#endif - -/* A crude PyString_AsStringAndSize implementation for old Pythons */ -#if PY_VERSION_HEX < 0x02010000 -# ifndef PyString_AsStringAndSize -# define PyString_AsStringAndSize(obj, s, len) {*s = PyString_AsString(obj); *len = *s ? strlen(*s) : 0;} -# endif -#endif - -/* PySequence_Size for old Pythons */ -#if PY_VERSION_HEX < 0x02000000 -# ifndef PySequence_Size -# define PySequence_Size PySequence_Length -# endif -#endif - -/* PyBool_FromLong for old Pythons */ -#if PY_VERSION_HEX < 0x02030000 -static -PyObject *PyBool_FromLong(long ok) -{ - PyObject *result = ok ? Py_True : Py_False; - Py_INCREF(result); - return result; -} -#endif - -/* Py_ssize_t for old Pythons */ -/* This code is as recommended by: */ -/* http://www.python.org/dev/peps/pep-0353/#conversion-guidelines */ -#if PY_VERSION_HEX < 0x02050000 && !defined(PY_SSIZE_T_MIN) -typedef int Py_ssize_t; -# define PY_SSIZE_T_MAX INT_MAX -# define PY_SSIZE_T_MIN INT_MIN -#endif -/* ----------------------------------------------------------------------------- - * error manipulation - * ----------------------------------------------------------------------------- */ - -SWIGRUNTIME PyObject* -SWIG_Python_ErrorType(int code) { - PyObject* type = 0; - switch(code) { - case SWIG_MemoryError: - type = PyExc_MemoryError; - break; - case SWIG_IOError: - type = PyExc_IOError; - break; - case SWIG_RuntimeError: - type = PyExc_RuntimeError; - break; - case SWIG_IndexError: - type = PyExc_IndexError; - break; - case SWIG_TypeError: - type = PyExc_TypeError; - break; - case SWIG_DivisionByZero: - type = PyExc_ZeroDivisionError; - break; - case SWIG_OverflowError: - type = PyExc_OverflowError; - break; - case SWIG_SyntaxError: - type = PyExc_SyntaxError; - break; - case SWIG_ValueError: - type = PyExc_ValueError; - break; - case SWIG_SystemError: - type = PyExc_SystemError; - break; - case SWIG_AttributeError: - type = PyExc_AttributeError; - break; - default: - type = PyExc_RuntimeError; - } - return type; -} - - -SWIGRUNTIME void -SWIG_Python_AddErrorMsg(const char* mesg) -{ - PyObject *type = 0; - PyObject *value = 0; - PyObject *traceback = 0; - - if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback); - if (value) { - char *tmp; - PyObject *old_str = PyObject_Str(value); - PyErr_Clear(); - Py_XINCREF(type); - - PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); - SWIG_Python_str_DelForPy3(tmp); - Py_DECREF(old_str); - Py_DECREF(value); - } else { - PyErr_SetString(PyExc_RuntimeError, mesg); - } -} -#if defined(SWIG_PYTHON_NO_THREADS) -# if defined(SWIG_PYTHON_THREADS) -# undef SWIG_PYTHON_THREADS -# endif -#endif -#if defined(SWIG_PYTHON_THREADS) /* Threading support is enabled */ -# if !defined(SWIG_PYTHON_USE_GIL) && !defined(SWIG_PYTHON_NO_USE_GIL) -# if (PY_VERSION_HEX >= 0x02030000) /* For 2.3 or later, use the PyGILState calls */ -# define SWIG_PYTHON_USE_GIL -# endif -# endif -# if defined(SWIG_PYTHON_USE_GIL) /* Use PyGILState threads calls */ -# ifndef SWIG_PYTHON_INITIALIZE_THREADS -# define SWIG_PYTHON_INITIALIZE_THREADS PyEval_InitThreads() -# endif -# ifdef __cplusplus /* C++ code */ - class SWIG_Python_Thread_Block { - bool status; - PyGILState_STATE state; - public: - void end() { if (status) { PyGILState_Release(state); status = false;} } - SWIG_Python_Thread_Block() : status(true), state(PyGILState_Ensure()) {} - ~SWIG_Python_Thread_Block() { end(); } - }; - class SWIG_Python_Thread_Allow { - bool status; - PyThreadState *save; - public: - void end() { if (status) { PyEval_RestoreThread(save); status = false; }} - SWIG_Python_Thread_Allow() : status(true), save(PyEval_SaveThread()) {} - ~SWIG_Python_Thread_Allow() { end(); } - }; -# define SWIG_PYTHON_THREAD_BEGIN_BLOCK SWIG_Python_Thread_Block _swig_thread_block -# define SWIG_PYTHON_THREAD_END_BLOCK _swig_thread_block.end() -# define SWIG_PYTHON_THREAD_BEGIN_ALLOW SWIG_Python_Thread_Allow _swig_thread_allow -# define SWIG_PYTHON_THREAD_END_ALLOW _swig_thread_allow.end() -# else /* C code */ -# define SWIG_PYTHON_THREAD_BEGIN_BLOCK PyGILState_STATE _swig_thread_block = PyGILState_Ensure() -# define SWIG_PYTHON_THREAD_END_BLOCK PyGILState_Release(_swig_thread_block) -# define SWIG_PYTHON_THREAD_BEGIN_ALLOW PyThreadState *_swig_thread_allow = PyEval_SaveThread() -# define SWIG_PYTHON_THREAD_END_ALLOW PyEval_RestoreThread(_swig_thread_allow) -# endif -# else /* Old thread way, not implemented, user must provide it */ -# if !defined(SWIG_PYTHON_INITIALIZE_THREADS) -# define SWIG_PYTHON_INITIALIZE_THREADS -# endif -# if !defined(SWIG_PYTHON_THREAD_BEGIN_BLOCK) -# define SWIG_PYTHON_THREAD_BEGIN_BLOCK -# endif -# if !defined(SWIG_PYTHON_THREAD_END_BLOCK) -# define SWIG_PYTHON_THREAD_END_BLOCK -# endif -# if !defined(SWIG_PYTHON_THREAD_BEGIN_ALLOW) -# define SWIG_PYTHON_THREAD_BEGIN_ALLOW -# endif -# if !defined(SWIG_PYTHON_THREAD_END_ALLOW) -# define SWIG_PYTHON_THREAD_END_ALLOW -# endif -# endif -#else /* No thread support */ -# define SWIG_PYTHON_INITIALIZE_THREADS -# define SWIG_PYTHON_THREAD_BEGIN_BLOCK -# define SWIG_PYTHON_THREAD_END_BLOCK -# define SWIG_PYTHON_THREAD_BEGIN_ALLOW -# define SWIG_PYTHON_THREAD_END_ALLOW -#endif -/* ----------------------------------------------------------------------------- - * Python API portion that goes into the runtime - * ----------------------------------------------------------------------------- */ - -#ifdef __cplusplus -extern "C" { -#if 0 -} /* cc-mode */ -#endif -#endif - -/* ----------------------------------------------------------------------------- - * Constant declarations - * ----------------------------------------------------------------------------- */ - -/* Constant Types */ -#define SWIG_PY_POINTER 4 -#define SWIG_PY_BINARY 5 - -/* Constant information structure */ -typedef struct swig_const_info { - int type; - char *name; - long lvalue; - double dvalue; - void *pvalue; - swig_type_info **ptype; -} swig_const_info; - - -/* ----------------------------------------------------------------------------- - * Wrapper of PyInstanceMethod_New() used in Python 3 - * It is exported to the generated module, used for -fastproxy - * ----------------------------------------------------------------------------- */ -SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject * /*self*/, PyObject *func) -{ -#if PY_VERSION_HEX >= 0x03000000 - return PyInstanceMethod_New(func); -#else - (void)func; - return NULL; -#endif -} - -#ifdef __cplusplus -#if 0 -{ /* cc-mode */ -#endif -} -#endif - -/* ----------------------------------------------------------------------------- - * See the LICENSE file for information on copyright, usage and redistribution - * of SWIG, and the README file for authors - http://www.swig.org/release.html. - * - * pyrun.swg - * - * This file contains the runtime support for Python modules - * and includes code for managing global variables and pointer - * type checking. - * - * ----------------------------------------------------------------------------- */ - -/* Common SWIG API */ - -/* for raw pointers */ -#define SWIG_Python_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0) -#define SWIG_ConvertPtr(obj, pptr, type, flags) SWIG_Python_ConvertPtr(obj, pptr, type, flags) -#define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own) SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own) -#define SWIG_NewPointerObj(ptr, type, flags) SWIG_Python_NewPointerObj(ptr, type, flags) -#define SWIG_CheckImplicit(ty) SWIG_Python_CheckImplicit(ty) -#define SWIG_AcquirePtr(ptr, src) SWIG_Python_AcquirePtr(ptr, src) -#define swig_owntype int - -/* for raw packed data */ -#define SWIG_ConvertPacked(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) -#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) - -/* for class or struct pointers */ -#define SWIG_ConvertInstance(obj, pptr, type, flags) SWIG_ConvertPtr(obj, pptr, type, flags) -#define SWIG_NewInstanceObj(ptr, type, flags) SWIG_NewPointerObj(ptr, type, flags) - -/* for C or C++ function pointers */ -#define SWIG_ConvertFunctionPtr(obj, pptr, type) SWIG_Python_ConvertFunctionPtr(obj, pptr, type) -#define SWIG_NewFunctionPtrObj(ptr, type) SWIG_Python_NewPointerObj(ptr, type, 0) - -/* for C++ member pointers, ie, member methods */ -#define SWIG_ConvertMember(obj, ptr, sz, ty) SWIG_Python_ConvertPacked(obj, ptr, sz, ty) -#define SWIG_NewMemberObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type) - - -/* Runtime API */ - -#define SWIG_GetModule(clientdata) SWIG_Python_GetModule() -#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer) -#define SWIG_NewClientData(obj) SwigPyClientData_New(obj) - -#define SWIG_SetErrorObj SWIG_Python_SetErrorObj -#define SWIG_SetErrorMsg SWIG_Python_SetErrorMsg -#define SWIG_ErrorType(code) SWIG_Python_ErrorType(code) -#define SWIG_Error(code, msg) SWIG_Python_SetErrorMsg(SWIG_ErrorType(code), msg) -#define SWIG_fail goto fail - - -/* Runtime API implementation */ - -/* Error manipulation */ - -SWIGINTERN void -SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyErr_SetObject(errtype, obj); - Py_DECREF(obj); - SWIG_PYTHON_THREAD_END_BLOCK; -} - -SWIGINTERN void -SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) { - SWIG_PYTHON_THREAD_BEGIN_BLOCK; - PyErr_SetString(errtype, (char *) msg); - SWIG_PYTHON_THREAD_END_BLOCK; -} - -#define SWIG_Python_Raise(obj, type, desc) SWIG_Python_SetErrorObj(SWIG_Python_ExceptionType(desc), obj) - -/* Set a constant value */ - -SWIGINTERN void -SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) { - PyDict_SetItemString(d, (char*) name, obj); - Py_DECREF(obj); -} - -/* Append a value to the result obj */ - -SWIGINTERN PyObject* -SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) { -#if !defined(SWIG_PYTHON_OUTPUT_TUPLE) - if (!result) { - result = obj; - } else if (result == Py_None) { - Py_DECREF(result); - result = obj; - } else { - if (!PyList_Check(result)) { - PyObject *o2 = result; - result = PyList_New(1); - PyList_SetItem(result, 0, o2); - } - PyList_Append(result,obj); - Py_DECREF(obj); - } - return result; -#else - PyObject* o2; - PyObject* o3; - if (!result) { - result = obj; - } else if (result == Py_None) { - Py_DECREF(result); - result = obj; - } else { - if (!PyTuple_Check(result)) { - o2 = result; - result = PyTuple_New(1); - PyTuple_SET_ITEM(result, 0, o2); - } - o3 = PyTuple_New(1); - PyTuple_SET_ITEM(o3, 0, obj); - o2 = result; - result = PySequence_Concat(o2, o3); - Py_DECREF(o2); - Py_DECREF(o3); - } - return result; -#endif -} - -/* Unpack the argument tuple */ - -SWIGINTERN int -SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs) -{ - if (!args) { - if (!min && !max) { - return 1; - } else { - PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none", - name, (min == max ? "" : "at least "), (int)min); - return 0; - } - } - if (!PyTuple_Check(args)) { - PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple"); - return 0; - } else { - register Py_ssize_t l = PyTuple_GET_SIZE(args); - if (l < min) { - PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", - name, (min == max ? "" : "at least "), (int)min, (int)l); - return 0; - } else if (l > max) { - PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", - name, (min == max ? "" : "at most "), (int)max, (int)l); - return 0; - } else { - register int i; - for (i = 0; i < l; ++i) { - objs[i] = PyTuple_GET_ITEM(args, i); - } - for (; l < max; ++l) { - objs[l] = 0; - } - return i + 1; - } - } -} - -/* A functor is a function object with one single object argument */ -#if PY_VERSION_HEX >= 0x02020000 -#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunctionObjArgs(functor, obj, NULL); -#else -#define SWIG_Python_CallFunctor(functor, obj) PyObject_CallFunction(functor, "O", obj); -#endif - -/* - Helper for static pointer initialization for both C and C++ code, for example - static PyObject *SWIG_STATIC_POINTER(MyVar) = NewSomething(...); -*/ -#ifdef __cplusplus -#define SWIG_STATIC_POINTER(var) var -#else -#define SWIG_STATIC_POINTER(var) var = 0; if (!var) var -#endif - -/* ----------------------------------------------------------------------------- - * Pointer declarations - * ----------------------------------------------------------------------------- */ - -/* Flags for new pointer objects */ -#define SWIG_POINTER_NOSHADOW (SWIG_POINTER_OWN << 1) -#define SWIG_POINTER_NEW (SWIG_POINTER_NOSHADOW | SWIG_POINTER_OWN) - -#define SWIG_POINTER_IMPLICIT_CONV (SWIG_POINTER_DISOWN << 1) - -#ifdef __cplusplus -extern "C" { -#if 0 -} /* cc-mode */ -#endif -#endif - -/* How to access Py_None */ -#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) -# ifndef SWIG_PYTHON_NO_BUILD_NONE -# ifndef SWIG_PYTHON_BUILD_NONE -# define SWIG_PYTHON_BUILD_NONE -# endif -# endif -#endif - -#ifdef SWIG_PYTHON_BUILD_NONE -# ifdef Py_None -# undef Py_None -# define Py_None SWIG_Py_None() -# endif -SWIGRUNTIMEINLINE PyObject * -_SWIG_Py_None(void) -{ - PyObject *none = Py_BuildValue((char*)""); - Py_DECREF(none); - return none; -} -SWIGRUNTIME PyObject * -SWIG_Py_None(void) -{ - static PyObject *SWIG_STATIC_POINTER(none) = _SWIG_Py_None(); - return none; -} -#endif - -/* The python void return value */ - -SWIGRUNTIMEINLINE PyObject * -SWIG_Py_Void(void) -{ - PyObject *none = Py_None; - Py_INCREF(none); - return none; -} - -/* SwigPyClientData */ - -typedef struct { - PyObject *klass; - PyObject *newraw; - PyObject *newargs; - PyObject *destroy; - int delargs; - int implicitconv; -} SwigPyClientData; - -SWIGRUNTIMEINLINE int -SWIG_Python_CheckImplicit(swig_type_info *ty) -{ - SwigPyClientData *data = (SwigPyClientData *)ty->clientdata; - return data ? data->implicitconv : 0; -} - -SWIGRUNTIMEINLINE PyObject * -SWIG_Python_ExceptionType(swig_type_info *desc) { - SwigPyClientData *data = desc ? (SwigPyClientData *) desc->clientdata : 0; - PyObject *klass = data ? data->klass : 0; - return (klass ? klass : PyExc_RuntimeError); -} - - -SWIGRUNTIME SwigPyClientData * -SwigPyClientData_New(PyObject* obj) -{ - if (!obj) { - return 0; - } else { - SwigPyClientData *data = (SwigPyClientData *)malloc(sizeof(SwigPyClientData)); - /* the klass element */ - data->klass = obj; - Py_INCREF(data->klass); - /* the newraw method and newargs arguments used to create a new raw instance */ - if (PyClass_Check(obj)) { - data->newraw = 0; - data->newargs = obj; - Py_INCREF(obj); - } else { -#if (PY_VERSION_HEX < 0x02020000) - data->newraw = 0; -#else - data->newraw = PyObject_GetAttrString(data->klass, (char *)"__new__"); -#endif - if (data->newraw) { - Py_INCREF(data->newraw); - data->newargs = PyTuple_New(1); - PyTuple_SetItem(data->newargs, 0, obj); - } else { - data->newargs = obj; - } - Py_INCREF(data->newargs); - } - /* the destroy method, aka as the C++ delete method */ - data->destroy = PyObject_GetAttrString(data->klass, (char *)"__swig_destroy__"); - if (PyErr_Occurred()) { - PyErr_Clear(); - data->destroy = 0; - } - if (data->destroy) { - int flags; - Py_INCREF(data->destroy); - flags = PyCFunction_GET_FLAGS(data->destroy); -#ifdef METH_O - data->delargs = !(flags & (METH_O)); -#else - data->delargs = 0; -#endif - } else { - data->delargs = 0; - } - data->implicitconv = 0; - return data; - } -} - -SWIGRUNTIME void -SwigPyClientData_Del(SwigPyClientData* data) -{ - Py_XDECREF(data->newraw); - Py_XDECREF(data->newargs); - Py_XDECREF(data->destroy); -} - -/* =============== SwigPyObject =====================*/ - -typedef struct { - PyObject_HEAD - void *ptr; - swig_type_info *ty; - int own; - PyObject *next; -} SwigPyObject; - -SWIGRUNTIME PyObject * -SwigPyObject_long(SwigPyObject *v) -{ - return PyLong_FromVoidPtr(v->ptr); -} - -SWIGRUNTIME PyObject * -SwigPyObject_format(const char* fmt, SwigPyObject *v) -{ - PyObject *res = NULL; - PyObject *args = PyTuple_New(1); - if (args) { - if (PyTuple_SetItem(args, 0, SwigPyObject_long(v)) == 0) { - PyObject *ofmt = SWIG_Python_str_FromChar(fmt); - if (ofmt) { -#if PY_VERSION_HEX >= 0x03000000 - res = PyUnicode_Format(ofmt,args); -#else - res = PyString_Format(ofmt,args); -#endif - Py_DECREF(ofmt); - } - Py_DECREF(args); - } - } - return res; -} - -SWIGRUNTIME PyObject * -SwigPyObject_oct(SwigPyObject *v) -{ - return SwigPyObject_format("%o",v); -} - -SWIGRUNTIME PyObject * -SwigPyObject_hex(SwigPyObject *v) -{ - return SwigPyObject_format("%x",v); -} - -SWIGRUNTIME PyObject * -#ifdef METH_NOARGS -SwigPyObject_repr(SwigPyObject *v) -#else -SwigPyObject_repr(SwigPyObject *v, PyObject *args) -#endif -{ - const char *name = SWIG_TypePrettyName(v->ty); - PyObject *repr = SWIG_Python_str_FromFormat("", name, v); - if (v->next) { -#ifdef METH_NOARGS - PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next); -#else - PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next, args); -#endif -#if PY_VERSION_HEX >= 0x03000000 - PyObject *joined = PyUnicode_Concat(repr, nrep); - Py_DecRef(repr); - Py_DecRef(nrep); - repr = joined; -#else - PyString_ConcatAndDel(&repr,nrep); -#endif - } - return repr; -} - -SWIGRUNTIME int -SwigPyObject_print(SwigPyObject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) -{ - char *str; -#ifdef METH_NOARGS - PyObject *repr = SwigPyObject_repr(v); -#else - PyObject *repr = SwigPyObject_repr(v, NULL); -#endif - if (repr) { - str = SWIG_Python_str_AsChar(repr); - fputs(str, fp); - SWIG_Python_str_DelForPy3(str); - Py_DECREF(repr); - return 0; - } else { - return 1; - } -} - -SWIGRUNTIME PyObject * -SwigPyObject_str(SwigPyObject *v) -{ - char result[SWIG_BUFFER_SIZE]; - return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ? - SWIG_Python_str_FromChar(result) : 0; -} - -SWIGRUNTIME int -SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w) -{ - void *i = v->ptr; - void *j = w->ptr; - return (i < j) ? -1 : ((i > j) ? 1 : 0); -} - -/* Added for Python 3.x, would it also be useful for Python 2.x? */ -SWIGRUNTIME PyObject* -SwigPyObject_richcompare(SwigPyObject *v, SwigPyObject *w, int op) -{ - PyObject* res; - if( op != Py_EQ && op != Py_NE ) { - Py_INCREF(Py_NotImplemented); - return Py_NotImplemented; - } - if( (SwigPyObject_compare(v, w)==0) == (op == Py_EQ) ) - res = Py_True; - else - res = Py_False; - Py_INCREF(res); - return res; -} - - -SWIGRUNTIME PyTypeObject* _PySwigObject_type(void); - -SWIGRUNTIME PyTypeObject* -SwigPyObject_type(void) { - static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigObject_type(); - return type; -} - -SWIGRUNTIMEINLINE int -SwigPyObject_Check(PyObject *op) { - return (Py_TYPE(op) == SwigPyObject_type()) - || (strcmp(Py_TYPE(op)->tp_name,"SwigPyObject") == 0); -} - -SWIGRUNTIME PyObject * -SwigPyObject_New(void *ptr, swig_type_info *ty, int own); - -SWIGRUNTIME void -SwigPyObject_dealloc(PyObject *v) -{ - SwigPyObject *sobj = (SwigPyObject *) v; - PyObject *next = sobj->next; - if (sobj->own == SWIG_POINTER_OWN) { - swig_type_info *ty = sobj->ty; - SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; - PyObject *destroy = data ? data->destroy : 0; - if (destroy) { - /* destroy is always a VARARGS method */ - PyObject *res; - if (data->delargs) { - /* we need to create a temporary object to carry the destroy operation */ - PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0); - res = SWIG_Python_CallFunctor(destroy, tmp); - Py_DECREF(tmp); - } else { - PyCFunction meth = PyCFunction_GET_FUNCTION(destroy); - PyObject *mself = PyCFunction_GET_SELF(destroy); - res = ((*meth)(mself, v)); - } - Py_XDECREF(res); - } -#if !defined(SWIG_PYTHON_SILENT_MEMLEAK) - else { - const char *name = SWIG_TypePrettyName(ty); - printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown")); - } -#endif - } - Py_XDECREF(next); - PyObject_DEL(v); -} - -SWIGRUNTIME PyObject* -SwigPyObject_append(PyObject* v, PyObject* next) -{ - SwigPyObject *sobj = (SwigPyObject *) v; -#ifndef METH_O - PyObject *tmp = 0; - if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL; - next = tmp; -#endif - if (!SwigPyObject_Check(next)) { - return NULL; - } - sobj->next = next; - Py_INCREF(next); - return SWIG_Py_Void(); -} - -SWIGRUNTIME PyObject* -#ifdef METH_NOARGS -SwigPyObject_next(PyObject* v) -#else -SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) -#endif -{ - SwigPyObject *sobj = (SwigPyObject *) v; - if (sobj->next) { - Py_INCREF(sobj->next); - return sobj->next; - } else { - return SWIG_Py_Void(); - } -} - -SWIGINTERN PyObject* -#ifdef METH_NOARGS -SwigPyObject_disown(PyObject *v) -#else -SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) -#endif -{ - SwigPyObject *sobj = (SwigPyObject *)v; - sobj->own = 0; - return SWIG_Py_Void(); -} - -SWIGINTERN PyObject* -#ifdef METH_NOARGS -SwigPyObject_acquire(PyObject *v) -#else -SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args)) -#endif -{ - SwigPyObject *sobj = (SwigPyObject *)v; - sobj->own = SWIG_POINTER_OWN; - return SWIG_Py_Void(); -} - -SWIGINTERN PyObject* -SwigPyObject_own(PyObject *v, PyObject *args) -{ - PyObject *val = 0; -#if (PY_VERSION_HEX < 0x02020000) - if (!PyArg_ParseTuple(args,(char *)"|O:own",&val)) -#else - if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val)) -#endif - { - return NULL; - } - else - { - SwigPyObject *sobj = (SwigPyObject *)v; - PyObject *obj = PyBool_FromLong(sobj->own); - if (val) { -#ifdef METH_NOARGS - if (PyObject_IsTrue(val)) { - SwigPyObject_acquire(v); - } else { - SwigPyObject_disown(v); - } -#else - if (PyObject_IsTrue(val)) { - SwigPyObject_acquire(v,args); - } else { - SwigPyObject_disown(v,args); - } -#endif - } - return obj; - } -} - -#ifdef METH_O -static PyMethodDef -swigobject_methods[] = { - {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_NOARGS, (char *)"releases ownership of the pointer"}, - {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS, (char *)"aquires ownership of the pointer"}, - {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, - {(char *)"append", (PyCFunction)SwigPyObject_append, METH_O, (char *)"appends another 'this' object"}, - {(char *)"next", (PyCFunction)SwigPyObject_next, METH_NOARGS, (char *)"returns the next 'this' object"}, - {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_NOARGS, (char *)"returns object representation"}, - {0, 0, 0, 0} -}; -#else -static PyMethodDef -swigobject_methods[] = { - {(char *)"disown", (PyCFunction)SwigPyObject_disown, METH_VARARGS, (char *)"releases ownership of the pointer"}, - {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_VARARGS, (char *)"aquires ownership of the pointer"}, - {(char *)"own", (PyCFunction)SwigPyObject_own, METH_VARARGS, (char *)"returns/sets ownership of the pointer"}, - {(char *)"append", (PyCFunction)SwigPyObject_append, METH_VARARGS, (char *)"appends another 'this' object"}, - {(char *)"next", (PyCFunction)SwigPyObject_next, METH_VARARGS, (char *)"returns the next 'this' object"}, - {(char *)"__repr__",(PyCFunction)SwigPyObject_repr, METH_VARARGS, (char *)"returns object representation"}, - {0, 0, 0, 0} -}; -#endif - -#if PY_VERSION_HEX < 0x02020000 -SWIGINTERN PyObject * -SwigPyObject_getattr(SwigPyObject *sobj,char *name) -{ - return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name); -} -#endif - -SWIGRUNTIME PyTypeObject* -_PySwigObject_type(void) { - static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer"; - - static PyNumberMethods SwigPyObject_as_number = { - (binaryfunc)0, /*nb_add*/ - (binaryfunc)0, /*nb_subtract*/ - (binaryfunc)0, /*nb_multiply*/ - /* nb_divide removed in Python 3 */ -#if PY_VERSION_HEX < 0x03000000 - (binaryfunc)0, /*nb_divide*/ -#endif - (binaryfunc)0, /*nb_remainder*/ - (binaryfunc)0, /*nb_divmod*/ - (ternaryfunc)0,/*nb_power*/ - (unaryfunc)0, /*nb_negative*/ - (unaryfunc)0, /*nb_positive*/ - (unaryfunc)0, /*nb_absolute*/ - (inquiry)0, /*nb_nonzero*/ - 0, /*nb_invert*/ - 0, /*nb_lshift*/ - 0, /*nb_rshift*/ - 0, /*nb_and*/ - 0, /*nb_xor*/ - 0, /*nb_or*/ -#if PY_VERSION_HEX < 0x03000000 - 0, /*nb_coerce*/ -#endif - (unaryfunc)SwigPyObject_long, /*nb_int*/ -#if PY_VERSION_HEX < 0x03000000 - (unaryfunc)SwigPyObject_long, /*nb_long*/ -#else - 0, /*nb_reserved*/ -#endif - (unaryfunc)0, /*nb_float*/ -#if PY_VERSION_HEX < 0x03000000 - (unaryfunc)SwigPyObject_oct, /*nb_oct*/ - (unaryfunc)SwigPyObject_hex, /*nb_hex*/ -#endif -#if PY_VERSION_HEX >= 0x03000000 /* 3.0 */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */ -#elif PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */ -#elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */ - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ -#elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */ - 0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */ -#endif - }; - - static PyTypeObject swigpyobject_type; - static int type_init = 0; - if (!type_init) { - const PyTypeObject tmp - = { - /* PyObject header changed in Python 3 */ -#if PY_VERSION_HEX >= 0x03000000 - PyVarObject_HEAD_INIT(&PyType_Type, 0) -#else - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ -#endif - (char *)"SwigPyObject", /* tp_name */ - sizeof(SwigPyObject), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)SwigPyObject_dealloc, /* tp_dealloc */ -#if PY_VERSION_HEX < 0x03080000 - (printfunc)SwigPyObject_print, /* tp_print */ -#else - 0, /*tp_vectorcall_offset*/ -#endif -#if PY_VERSION_HEX < 0x02020000 - (getattrfunc)SwigPyObject_getattr, /* tp_getattr */ -#else - (getattrfunc)0, /* tp_getattr */ -#endif - (setattrfunc)0, /* tp_setattr */ -#if PY_VERSION_HEX >= 0x03000000 - 0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */ -#else - (cmpfunc)SwigPyObject_compare, /* tp_compare */ -#endif - (reprfunc)SwigPyObject_repr, /* tp_repr */ - &SwigPyObject_as_number, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)0, /* tp_hash */ - (ternaryfunc)0, /* tp_call */ - (reprfunc)SwigPyObject_str, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - swigobject_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - (richcmpfunc)SwigPyObject_richcompare, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ -#if PY_VERSION_HEX >= 0x02020000 - 0, /* tp_iter */ - 0, /* tp_iternext */ - swigobject_methods, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - 0, /* tp_free */ - 0, /* tp_is_gc */ - 0, /* tp_bases */ - 0, /* tp_mro */ - 0, /* tp_cache */ - 0, /* tp_subclasses */ - 0, /* tp_weaklist */ -#endif -#if PY_VERSION_HEX >= 0x02030000 - 0, /* tp_del */ -#endif -#if PY_VERSION_HEX >= 0x02060000 - 0, /* tp_version_tag */ -#endif -#ifdef COUNT_ALLOCS - 0,0,0,0 /* tp_alloc -> tp_next */ -#endif - }; - swigpyobject_type = tmp; - /* for Python 3 we already assigned ob_type in PyVarObject_HEAD_INIT() */ -#if PY_VERSION_HEX < 0x03000000 - swigpyobject_type.ob_type = &PyType_Type; -#endif - type_init = 1; - } - return &swigpyobject_type; -} - -SWIGRUNTIME PyObject * -SwigPyObject_New(void *ptr, swig_type_info *ty, int own) -{ - SwigPyObject *sobj = PyObject_NEW(SwigPyObject, SwigPyObject_type()); - if (sobj) { - sobj->ptr = ptr; - sobj->ty = ty; - sobj->own = own; - sobj->next = 0; - } - return (PyObject *)sobj; -} - -/* ----------------------------------------------------------------------------- - * Implements a simple Swig Packed type, and use it instead of string - * ----------------------------------------------------------------------------- */ - -typedef struct { - PyObject_HEAD - void *pack; - swig_type_info *ty; - size_t size; -} SwigPyPacked; - -SWIGRUNTIME int -SwigPyPacked_print(SwigPyPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags)) -{ - char result[SWIG_BUFFER_SIZE]; - fputs("pack, v->size, 0, sizeof(result))) { - fputs("at ", fp); - fputs(result, fp); - } - fputs(v->ty->name,fp); - fputs(">", fp); - return 0; -} - -SWIGRUNTIME PyObject * -SwigPyPacked_repr(SwigPyPacked *v) -{ - char result[SWIG_BUFFER_SIZE]; - if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) { - return SWIG_Python_str_FromFormat("", result, v->ty->name); - } else { - return SWIG_Python_str_FromFormat("", v->ty->name); - } -} - -SWIGRUNTIME PyObject * -SwigPyPacked_str(SwigPyPacked *v) -{ - char result[SWIG_BUFFER_SIZE]; - if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){ - return SWIG_Python_str_FromFormat("%s%s", result, v->ty->name); - } else { - return SWIG_Python_str_FromChar(v->ty->name); - } -} - -SWIGRUNTIME int -SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w) -{ - size_t i = v->size; - size_t j = w->size; - int s = (i < j) ? -1 : ((i > j) ? 1 : 0); - return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size); -} - -SWIGRUNTIME PyTypeObject* _PySwigPacked_type(void); - -SWIGRUNTIME PyTypeObject* -SwigPyPacked_type(void) { - static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigPacked_type(); - return type; -} - -SWIGRUNTIMEINLINE int -SwigPyPacked_Check(PyObject *op) { - return ((op)->ob_type == _PySwigPacked_type()) - || (strcmp((op)->ob_type->tp_name,"SwigPyPacked") == 0); -} - -SWIGRUNTIME void -SwigPyPacked_dealloc(PyObject *v) -{ - if (SwigPyPacked_Check(v)) { - SwigPyPacked *sobj = (SwigPyPacked *) v; - free(sobj->pack); - } - PyObject_DEL(v); -} - -SWIGRUNTIME PyTypeObject* -_PySwigPacked_type(void) { - static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer"; - static PyTypeObject swigpypacked_type; - static int type_init = 0; - if (!type_init) { - const PyTypeObject tmp - = { - /* PyObject header changed in Python 3 */ -#if PY_VERSION_HEX>=0x03000000 - PyVarObject_HEAD_INIT(&PyType_Type, 0) -#else - PyObject_HEAD_INIT(NULL) - 0, /* ob_size */ -#endif - (char *)"SwigPyPacked", /* tp_name */ - sizeof(SwigPyPacked), /* tp_basicsize */ - 0, /* tp_itemsize */ - (destructor)SwigPyPacked_dealloc, /* tp_dealloc */ -#if PY_VERSION_HEX < 0x03080000 - (printfunc)SwigPyPacked_print, /* tp_print */ -#else - 0, /*tp_vectorcall_offset*/ -#endif - (getattrfunc)0, /* tp_getattr */ - (setattrfunc)0, /* tp_setattr */ -#if PY_VERSION_HEX>=0x03000000 - 0, /* tp_reserved in 3.0.1 */ -#else - (cmpfunc)SwigPyPacked_compare, /* tp_compare */ -#endif - (reprfunc)SwigPyPacked_repr, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - (hashfunc)0, /* tp_hash */ - (ternaryfunc)0, /* tp_call */ - (reprfunc)SwigPyPacked_str, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - 0, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - swigpacked_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ -#if PY_VERSION_HEX >= 0x02020000 - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - 0, /* tp_members */ - 0, /* tp_getset */ - 0, /* tp_base */ - 0, /* tp_dict */ - 0, /* tp_descr_get */ - 0, /* tp_descr_set */ - 0, /* tp_dictoffset */ - 0, /* tp_init */ - 0, /* tp_alloc */ - 0, /* tp_new */ - 0, /* tp_free */ - 0, /* tp_is_gc */ - 0, /* tp_bases */ - 0, /* tp_mro */ - 0, /* tp_cache */ - 0, /* tp_subclasses */ - 0, /* tp_weaklist */ -#endif -#if PY_VERSION_HEX >= 0x02030000 - 0, /* tp_del */ -#endif -#if PY_VERSION_HEX >= 0x02060000 - 0, /* tp_version_tag */ -#endif -#ifdef COUNT_ALLOCS - 0,0,0,0 /* tp_alloc -> tp_next */ -#endif - }; - swigpypacked_type = tmp; - /* for Python 3 the ob_type already assigned in PyVarObject_HEAD_INIT() */ -#if PY_VERSION_HEX < 0x03000000 - swigpypacked_type.ob_type = &PyType_Type; -#endif - type_init = 1; - } - return &swigpypacked_type; -} - -SWIGRUNTIME PyObject * -SwigPyPacked_New(void *ptr, size_t size, swig_type_info *ty) -{ - SwigPyPacked *sobj = PyObject_NEW(SwigPyPacked, SwigPyPacked_type()); - if (sobj) { - void *pack = malloc(size); - if (pack) { - memcpy(pack, ptr, size); - sobj->pack = pack; - sobj->ty = ty; - sobj->size = size; - } else { - PyObject_DEL((PyObject *) sobj); - sobj = 0; - } - } - return (PyObject *) sobj; -} - -SWIGRUNTIME swig_type_info * -SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size) -{ - if (SwigPyPacked_Check(obj)) { - SwigPyPacked *sobj = (SwigPyPacked *)obj; - if (sobj->size != size) return 0; - memcpy(ptr, sobj->pack, size); - return sobj->ty; - } else { - return 0; - } -} - -/* ----------------------------------------------------------------------------- - * pointers/data manipulation - * ----------------------------------------------------------------------------- */ - -SWIGRUNTIMEINLINE PyObject * -_SWIG_This(void) -{ - return SWIG_Python_str_FromChar("this"); -} - -SWIGRUNTIME PyObject * -SWIG_This(void) -{ - static PyObject *SWIG_STATIC_POINTER(swig_this) = _SWIG_This(); - return swig_this; -} - -/* #define SWIG_PYTHON_SLOW_GETSET_THIS */ - -/* TODO: I don't know how to implement the fast getset in Python 3 right now */ -#if PY_VERSION_HEX>=0x03000000 -#define SWIG_PYTHON_SLOW_GETSET_THIS -#endif - -SWIGRUNTIME SwigPyObject * -SWIG_Python_GetSwigThis(PyObject *pyobj) -{ - if (SwigPyObject_Check(pyobj)) { - return (SwigPyObject *) pyobj; - } else { - PyObject *obj = 0; -#if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000)) - if (PyInstance_Check(pyobj)) { - obj = _PyInstance_Lookup(pyobj, SWIG_This()); - } else { - PyObject **dictptr = _PyObject_GetDictPtr(pyobj); - if (dictptr != NULL) { - PyObject *dict = *dictptr; - obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0; - } else { -#ifdef PyWeakref_CheckProxy - if (PyWeakref_CheckProxy(pyobj)) { - PyObject *wobj = PyWeakref_GET_OBJECT(pyobj); - return wobj ? SWIG_Python_GetSwigThis(wobj) : 0; - } -#endif - obj = PyObject_GetAttr(pyobj,SWIG_This()); - if (obj) { - Py_DECREF(obj); - } else { - if (PyErr_Occurred()) PyErr_Clear(); - return 0; - } - } - } -#else - obj = PyObject_GetAttr(pyobj,SWIG_This()); - if (obj) { - Py_DECREF(obj); - } else { - if (PyErr_Occurred()) PyErr_Clear(); - return 0; - } -#endif - if (obj && !SwigPyObject_Check(obj)) { - /* a PyObject is called 'this', try to get the 'real this' - SwigPyObject from it */ - return SWIG_Python_GetSwigThis(obj); - } - return (SwigPyObject *)obj; - } -} - -/* Acquire a pointer value */ - -SWIGRUNTIME int -SWIG_Python_AcquirePtr(PyObject *obj, int own) { - if (own == SWIG_POINTER_OWN) { - SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj); - if (sobj) { - int oldown = sobj->own; - sobj->own = own; - return oldown; - } - } - return 0; -} - -/* Convert a pointer value */ - -SWIGRUNTIME int -SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) { - if (!obj) return SWIG_ERROR; - if (obj == Py_None) { - if (ptr) *ptr = 0; - return SWIG_OK; - } else { - SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj); - if (own) - *own = 0; - while (sobj) { - void *vptr = sobj->ptr; - if (ty) { - swig_type_info *to = sobj->ty; - if (to == ty) { - /* no type cast needed */ - if (ptr) *ptr = vptr; - break; - } else { - swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); - if (!tc) { - sobj = (SwigPyObject *)sobj->next; - } else { - if (ptr) { - int newmemory = 0; - *ptr = SWIG_TypeCast(tc,vptr,&newmemory); - if (newmemory == SWIG_CAST_NEW_MEMORY) { - assert(own); - if (own) - *own = *own | SWIG_CAST_NEW_MEMORY; - } - } - break; - } - } - } else { - if (ptr) *ptr = vptr; - break; - } - } - if (sobj) { - if (own) - *own = *own | sobj->own; - if (flags & SWIG_POINTER_DISOWN) { - sobj->own = 0; - } - return SWIG_OK; - } else { - int res = SWIG_ERROR; - if (flags & SWIG_POINTER_IMPLICIT_CONV) { - SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0; - if (data && !data->implicitconv) { - PyObject *klass = data->klass; - if (klass) { - PyObject *impconv; - data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/ - impconv = SWIG_Python_CallFunctor(klass, obj); - data->implicitconv = 0; - if (PyErr_Occurred()) { - PyErr_Clear(); - impconv = 0; - } - if (impconv) { - SwigPyObject *iobj = SWIG_Python_GetSwigThis(impconv); - if (iobj) { - void *vptr; - res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0); - if (SWIG_IsOK(res)) { - if (ptr) { - *ptr = vptr; - /* transfer the ownership to 'ptr' */ - iobj->own = 0; - res = SWIG_AddCast(res); - res = SWIG_AddNewMask(res); - } else { - res = SWIG_AddCast(res); - } - } - } - Py_DECREF(impconv); - } - } - } - } - return res; - } - } -} - -/* Convert a function ptr value */ - -SWIGRUNTIME int -SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) { - if (!PyCFunction_Check(obj)) { - return SWIG_ConvertPtr(obj, ptr, ty, 0); - } else { - void *vptr = 0; - - /* here we get the method pointer for callbacks */ - const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc); - const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0; - if (desc) - desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0; - if (!desc) - return SWIG_ERROR; - if (ty) { - swig_cast_info *tc = SWIG_TypeCheck(desc,ty); - if (tc) { - int newmemory = 0; - *ptr = SWIG_TypeCast(tc,vptr,&newmemory); - assert(!newmemory); /* newmemory handling not yet implemented */ - } else { - return SWIG_ERROR; - } - } else { - *ptr = vptr; - } - return SWIG_OK; - } -} - -/* Convert a packed value value */ - -SWIGRUNTIME int -SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) { - swig_type_info *to = SwigPyPacked_UnpackData(obj, ptr, sz); - if (!to) return SWIG_ERROR; - if (ty) { - if (to != ty) { - /* check type cast? */ - swig_cast_info *tc = SWIG_TypeCheck(to->name,ty); - if (!tc) return SWIG_ERROR; - } - } - return SWIG_OK; -} - -/* ----------------------------------------------------------------------------- - * Create a new pointer object - * ----------------------------------------------------------------------------- */ - -/* - Create a new instance object, without calling __init__, and set the - 'this' attribute. -*/ - -SWIGRUNTIME PyObject* -SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this) -{ -#if (PY_VERSION_HEX >= 0x02020000) - PyObject *inst = 0; - PyObject *newraw = data->newraw; - if (newraw) { - inst = PyObject_Call(newraw, data->newargs, NULL); - if (inst) { -#if !defined(SWIG_PYTHON_SLOW_GETSET_THIS) - PyObject **dictptr = _PyObject_GetDictPtr(inst); - if (dictptr != NULL) { - PyObject *dict = *dictptr; - if (dict == NULL) { - dict = PyDict_New(); - *dictptr = dict; - PyDict_SetItem(dict, SWIG_This(), swig_this); - } - } -#else - PyObject *key = SWIG_This(); - PyObject_SetAttr(inst, key, swig_this); -#endif - } - } else { -#if PY_VERSION_HEX >= 0x03000000 - inst = PyBaseObject_Type.tp_new((PyTypeObject*) data->newargs, Py_None, Py_None); - PyObject_SetAttr(inst, SWIG_This(), swig_this); - Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG; -#else - PyObject *dict = PyDict_New(); - PyDict_SetItem(dict, SWIG_This(), swig_this); - inst = PyInstance_NewRaw(data->newargs, dict); - Py_DECREF(dict); -#endif - } - return inst; -#else -#if (PY_VERSION_HEX >= 0x02010000) - PyObject *inst; - PyObject *dict = PyDict_New(); - PyDict_SetItem(dict, SWIG_This(), swig_this); - inst = PyInstance_NewRaw(data->newargs, dict); - Py_DECREF(dict); - return (PyObject *) inst; -#else - PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type); - if (inst == NULL) { - return NULL; - } - inst->in_class = (PyClassObject *)data->newargs; - Py_INCREF(inst->in_class); - inst->in_dict = PyDict_New(); - if (inst->in_dict == NULL) { - Py_DECREF(inst); - return NULL; - } -#ifdef Py_TPFLAGS_HAVE_WEAKREFS - inst->in_weakreflist = NULL; -#endif -#ifdef Py_TPFLAGS_GC - PyObject_GC_Init(inst); -#endif - PyDict_SetItem(inst->in_dict, SWIG_This(), swig_this); - return (PyObject *) inst; -#endif -#endif -} - -SWIGRUNTIME void -SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this) -{ - PyObject *dict; -#if (PY_VERSION_HEX >= 0x02020000) && !defined(SWIG_PYTHON_SLOW_GETSET_THIS) - PyObject **dictptr = _PyObject_GetDictPtr(inst); - if (dictptr != NULL) { - dict = *dictptr; - if (dict == NULL) { - dict = PyDict_New(); - *dictptr = dict; - } - PyDict_SetItem(dict, SWIG_This(), swig_this); - return; - } -#endif - dict = PyObject_GetAttrString(inst, (char*)"__dict__"); - PyDict_SetItem(dict, SWIG_This(), swig_this); - Py_DECREF(dict); -} - - -SWIGINTERN PyObject * -SWIG_Python_InitShadowInstance(PyObject *args) { - PyObject *obj[2]; - if (!SWIG_Python_UnpackTuple(args,(char*)"swiginit", 2, 2, obj)) { - return NULL; - } else { - SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]); - if (sthis) { - SwigPyObject_append((PyObject*) sthis, obj[1]); - } else { - SWIG_Python_SetSwigThis(obj[0], obj[1]); - } - return SWIG_Py_Void(); - } -} - -/* Create a new pointer object */ - -SWIGRUNTIME PyObject * -SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int flags) { - if (!ptr) { - return SWIG_Py_Void(); - } else { - int own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0; - PyObject *robj = SwigPyObject_New(ptr, type, own); - SwigPyClientData *clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0; - if (clientdata && !(flags & SWIG_POINTER_NOSHADOW)) { - PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj); - if (inst) { - Py_DECREF(robj); - robj = inst; - } - } - return robj; - } -} - -/* Create a new packed object */ - -SWIGRUNTIMEINLINE PyObject * -SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) { - return ptr ? SwigPyPacked_New((void *) ptr, sz, type) : SWIG_Py_Void(); -} - -/* -----------------------------------------------------------------------------* - * Get type list - * -----------------------------------------------------------------------------*/ - -#ifdef SWIG_LINK_RUNTIME -void *SWIG_ReturnGlobalTypeList(void *); -#endif - -SWIGRUNTIME swig_module_info * -SWIG_Python_GetModule(void) { - static void *type_pointer = (void *)0; - /* first check if module already created */ - if (!type_pointer) { -#ifdef SWIG_LINK_RUNTIME - type_pointer = SWIG_ReturnGlobalTypeList((void *)0); -#else - type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, - (char*)"type_pointer" SWIG_TYPE_TABLE_NAME); - if (PyErr_Occurred()) { - PyErr_Clear(); - type_pointer = (void *)0; - } -#endif - } - return (swig_module_info *) type_pointer; -} - -#if PY_MAJOR_VERSION < 2 -/* PyModule_AddObject function was introduced in Python 2.0. The following function - is copied out of Python/modsupport.c in python version 2.3.4 */ -SWIGINTERN int -PyModule_AddObject(PyObject *m, char *name, PyObject *o) -{ - PyObject *dict; - if (!PyModule_Check(m)) { - PyErr_SetString(PyExc_TypeError, - "PyModule_AddObject() needs module as first arg"); - return SWIG_ERROR; - } - if (!o) { - PyErr_SetString(PyExc_TypeError, - "PyModule_AddObject() needs non-NULL value"); - return SWIG_ERROR; - } - - dict = PyModule_GetDict(m); - if (dict == NULL) { - /* Internal error -- modules must have a dict! */ - PyErr_Format(PyExc_SystemError, "module '%s' has no __dict__", - PyModule_GetName(m)); - return SWIG_ERROR; - } - if (PyDict_SetItemString(dict, name, o)) - return SWIG_ERROR; - Py_DECREF(o); - return SWIG_OK; -} -#endif - -SWIGRUNTIME void -SWIG_Python_DestroyModule(void *vptr) -{ - swig_module_info *swig_module = (swig_module_info *) vptr; - swig_type_info **types = swig_module->types; - size_t i; - for (i =0; i < swig_module->size; ++i) { - swig_type_info *ty = types[i]; - if (ty->owndata) { - SwigPyClientData *data = (SwigPyClientData *) ty->clientdata; - if (data) SwigPyClientData_Del(data); - } - } - Py_DECREF(SWIG_This()); -} - -SWIGRUNTIME void -SWIG_Python_SetModule(swig_module_info *swig_module) { - static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */ - -#if PY_VERSION_HEX >= 0x03000000 - /* Add a dummy module object into sys.modules */ - PyObject *module = PyImport_AddModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION); -#else - PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, - swig_empty_runtime_method_table); -#endif - PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule); - if (pointer && module) { - PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer); - } else { - Py_XDECREF(pointer); - } -} - -/* The python cached type query */ -SWIGRUNTIME PyObject * -SWIG_Python_TypeCache(void) { - static PyObject *SWIG_STATIC_POINTER(cache) = PyDict_New(); - return cache; -} - -SWIGRUNTIME swig_type_info * -SWIG_Python_TypeQuery(const char *type) -{ - PyObject *cache = SWIG_Python_TypeCache(); - PyObject *key = SWIG_Python_str_FromChar(type); - PyObject *obj = PyDict_GetItem(cache, key); - swig_type_info *descriptor; - if (obj) { - descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj); - } else { - swig_module_info *swig_module = SWIG_Python_GetModule(); - descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type); - if (descriptor) { - obj = PyCObject_FromVoidPtr(descriptor, NULL); - PyDict_SetItem(cache, key, obj); - Py_DECREF(obj); - } - } - Py_DECREF(key); - return descriptor; -} - -/* - For backward compatibility only -*/ -#define SWIG_POINTER_EXCEPTION 0 -#define SWIG_arg_fail(arg) SWIG_Python_ArgFail(arg) -#define SWIG_MustGetPtr(p, type, argnum, flags) SWIG_Python_MustGetPtr(p, type, argnum, flags) - -SWIGRUNTIME int -SWIG_Python_AddErrMesg(const char* mesg, int infront) -{ - if (PyErr_Occurred()) { - PyObject *type = 0; - PyObject *value = 0; - PyObject *traceback = 0; - PyErr_Fetch(&type, &value, &traceback); - if (value) { - char *tmp; - PyObject *old_str = PyObject_Str(value); - Py_XINCREF(type); - PyErr_Clear(); - if (infront) { - PyErr_Format(type, "%s %s", mesg, tmp = SWIG_Python_str_AsChar(old_str)); - } else { - PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg); - } - SWIG_Python_str_DelForPy3(tmp); - Py_DECREF(old_str); - } - return 1; - } else { - return 0; - } -} - -SWIGRUNTIME int -SWIG_Python_ArgFail(int argnum) -{ - if (PyErr_Occurred()) { - /* add information about failing argument */ - char mesg[256]; - PyOS_snprintf(mesg, sizeof(mesg), "argument number %d:", argnum); - return SWIG_Python_AddErrMesg(mesg, 1); - } else { - return 0; - } -} - -SWIGRUNTIMEINLINE const char * -SwigPyObject_GetDesc(PyObject *self) -{ - SwigPyObject *v = (SwigPyObject *)self; - swig_type_info *ty = v ? v->ty : 0; - return ty ? ty->str : (char*)""; -} - -SWIGRUNTIME void -SWIG_Python_TypeError(const char *type, PyObject *obj) -{ - if (type) { -#if defined(SWIG_COBJECT_TYPES) - if (obj && SwigPyObject_Check(obj)) { - const char *otype = (const char *) SwigPyObject_GetDesc(obj); - if (otype) { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received", - type, otype); - return; - } - } else -#endif - { - const char *otype = (obj ? obj->ob_type->tp_name : 0); - if (otype) { - PyObject *str = PyObject_Str(obj); - const char *cstr = str ? SWIG_Python_str_AsChar(str) : 0; - if (cstr) { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received", - type, otype, cstr); - SWIG_Python_str_DelForPy3(cstr); - } else { - PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received", - type, otype); - } - Py_XDECREF(str); - return; - } - } - PyErr_Format(PyExc_TypeError, "a '%s' is expected", type); - } else { - PyErr_Format(PyExc_TypeError, "unexpected type is received"); - } -} - - -/* Convert a pointer value, signal an exception on a type mismatch */ -SWIGRUNTIME void * -SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) { - void *result; - if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) { - PyErr_Clear(); -#if SWIG_POINTER_EXCEPTION - if (flags) { - SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj); - SWIG_Python_ArgFail(argnum); - } -#else - (void)argnum; -#endif - } - return result; -} - - -#ifdef __cplusplus -#if 0 -{ /* cc-mode */ -#endif -} -#endif -/* -----------------------------------------------------------------------------* - Standard SWIG API for use inside user code. - - Don't include this file directly, run the command - swig -python -external-runtime - Also, read the Modules chapter of the SWIG Manual. - - * -----------------------------------------------------------------------------*/ - -#ifdef SWIG_MODULE_CLIENTDATA_TYPE - -SWIGRUNTIMEINLINE swig_type_info * -SWIG_TypeQuery(SWIG_MODULE_CLIENTDATA_TYPE clientdata, const char *name) { - swig_module_info *module = SWIG_GetModule(clientdata); - return SWIG_TypeQueryModule(module, module, name); -} - -SWIGRUNTIMEINLINE swig_type_info * -SWIG_MangledTypeQuery(SWIG_MODULE_CLIENTDATA_TYPE clientdata, const char *name) { - swig_module_info *module = SWIG_GetModule(clientdata); - return SWIG_MangledTypeQueryModule(module, module, name); -} - -#else - -SWIGRUNTIMEINLINE swig_type_info * -SWIG_TypeQuery(const char *name) { - swig_module_info *module = SWIG_GetModule(NULL); - return SWIG_TypeQueryModule(module, module, name); -} - -SWIGRUNTIMEINLINE swig_type_info * -SWIG_MangledTypeQuery(const char *name) { - swig_module_info *module = SWIG_GetModule(NULL); - return SWIG_MangledTypeQueryModule(module, module, name); -} - -#endif From 01d621406f1576294d8a395c89c84efee5cc225a Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 26 Apr 2021 12:30:02 +0200 Subject: [PATCH 166/178] Sketcher: [skip ci] fix memory leak in GeometryFacadePy --- src/Mod/Sketcher/App/GeometryFacadePy.xml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Mod/Sketcher/App/GeometryFacadePy.xml b/src/Mod/Sketcher/App/GeometryFacadePy.xml index 846db8c421..55e299f08a 100644 --- a/src/Mod/Sketcher/App/GeometryFacadePy.xml +++ b/src/Mod/Sketcher/App/GeometryFacadePy.xml @@ -10,7 +10,8 @@ Namespace="Sketcher" FatherInclude="Base/BaseClassPy.h" FatherNamespace="Base" - Constructor="true"> + Constructor="true" + Delete="true"> Describes a GeometryFacade From 3a3fe0c77858138fdc1da4c319f7c3f62b45e168 Mon Sep 17 00:00:00 2001 From: Yorik van Havre Date: Mon, 26 Apr 2021 12:55:57 +0200 Subject: [PATCH 167/178] Added KiCAD Corp to the credits --- src/Doc/CONTRIBUTORS | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Doc/CONTRIBUTORS b/src/Doc/CONTRIBUTORS index a191bacb5a..a56bdfbcc9 100644 --- a/src/Doc/CONTRIBUTORS +++ b/src/Doc/CONTRIBUTORS @@ -213,3 +213,4 @@ Zheng Lei (realthunder) Firms Imetric 3D AlephObjects +KiCad Services Corporation From 3347c5e6328440af6537d8ed845e4954579e2231 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 26 Apr 2021 15:57:17 +0200 Subject: [PATCH 168/178] Base: [skip ci] do not make PyBaseProxy class declaration dependent on ATTR_TRACKING --- src/Base/PyObjectBase.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Base/PyObjectBase.cpp b/src/Base/PyObjectBase.cpp index 7bc5e31f8c..dd9ac4e471 100644 --- a/src/Base/PyObjectBase.cpp +++ b/src/Base/PyObjectBase.cpp @@ -39,13 +39,11 @@ using namespace Base; PyObject* Base::BaseExceptionFreeCADError = nullptr; PyObject* Base::BaseExceptionFreeCADAbort = nullptr; -#ifdef ATTR_TRACKING typedef struct { PyObject_HEAD PyObject* baseobject; PyObject* weakreflist; /* List of weak references */ } PyBaseProxy; -#endif // Constructor PyObjectBase::PyObjectBase(void* p,PyTypeObject *T) @@ -224,7 +222,6 @@ PyTypeObject PyObjectBase::Type = { # pragma clang diagnostic pop #endif -#ifdef ATTR_TRACKING PyObject* createWeakRef(PyObjectBase* ptr) { static bool init = false; @@ -255,7 +252,6 @@ PyObjectBase* getFromWeakRef(PyObject* ref) return nullptr; } -#endif /*------------------------------ * PyObjectBase Methods -- Every class, even the abstract one should have a Methods From 5e2abd4f80846cb9e061535c88d3c1650bfe6e97 Mon Sep 17 00:00:00 2001 From: wmayer Date: Mon, 26 Apr 2021 23:05:18 +0200 Subject: [PATCH 169/178] Sketcher: [skip ci] remove superfluous semicolons --- src/Mod/Sketcher/App/GeometryFacade.h | 46 +++++++++++++-------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/Mod/Sketcher/App/GeometryFacade.h b/src/Mod/Sketcher/App/GeometryFacade.h index 88acb6538b..7fac1e70f4 100644 --- a/src/Mod/Sketcher/App/GeometryFacade.h +++ b/src/Mod/Sketcher/App/GeometryFacade.h @@ -134,8 +134,8 @@ public: bool getBlocked() const { return this->testGeometryMode(GeometryMode::Blocked);} void setBlocked(bool status = true) {this->setGeometryMode(GeometryMode::Blocked, status);} - inline bool getConstruction(void) const {return this->testGeometryMode(GeometryMode::Construction);}; - inline void setConstruction(bool construction) {this->setGeometryMode(GeometryMode::Construction, construction);}; + inline bool getConstruction(void) const {return this->testGeometryMode(GeometryMode::Construction);} + inline void setConstruction(bool construction) {this->setGeometryMode(GeometryMode::Construction, construction);} bool isInternalAligned() const { return this->getInternalType() != InternalType::None; } @@ -161,27 +161,27 @@ public: virtual PyObject *getPyObject(void) override; // Geometry Interface - TopoDS_Shape toShape() const {return getGeo()->toShape();}; - const Handle(Geom_Geometry)& handle() const {return getGeo()->handle();}; - Part::Geometry *copy(void) const {return getGeo()->copy();}; - Part::Geometry *clone(void) const {return getGeo()->clone();}; - boost::uuids::uuid getTag() const {return getGeo()->getTag();}; + TopoDS_Shape toShape() const {return getGeo()->toShape();} + const Handle(Geom_Geometry)& handle() const {return getGeo()->handle();} + Part::Geometry *copy(void) const {return getGeo()->copy();} + Part::Geometry *clone(void) const {return getGeo()->clone();} + boost::uuids::uuid getTag() const {return getGeo()->getTag();} - std::vector> getExtensions() const {return getGeo()->getExtensions();}; - bool hasExtension(Base::Type type) const {return getGeo()->hasExtension(type);}; - bool hasExtension(std::string name) const {return getGeo()->hasExtension(name);}; - std::weak_ptr getExtension(Base::Type type) const {return getGeo()->getExtension(type);}; - std::weak_ptr getExtension(std::string name) const {return getGeo()->getExtension(name);}; - void setExtension(std::unique_ptr &&geo) {return getGeo()->setExtension(std::move(geo));}; - void deleteExtension(Base::Type type) {return getGeo()->deleteExtension(type);}; - void deleteExtension(std::string name) {return getGeo()->deleteExtension(name);}; + std::vector> getExtensions() const {return getGeo()->getExtensions();} + bool hasExtension(Base::Type type) const {return getGeo()->hasExtension(type);} + bool hasExtension(std::string name) const {return getGeo()->hasExtension(name);} + std::weak_ptr getExtension(Base::Type type) const {return getGeo()->getExtension(type);} + std::weak_ptr getExtension(std::string name) const {return getGeo()->getExtension(name);} + void setExtension(std::unique_ptr &&geo) {return getGeo()->setExtension(std::move(geo));} + void deleteExtension(Base::Type type) {return getGeo()->deleteExtension(type);} + void deleteExtension(std::string name) {return getGeo()->deleteExtension(name);} - void mirror(Base::Vector3d point) {return getGeo()->mirror(point);}; - void mirror(Base::Vector3d point, Base::Vector3d dir) {return getGeo()->mirror(point, dir);}; - void rotate(Base::Placement plm) {return getGeo()->rotate(plm);}; - void scale(Base::Vector3d vec, double scale) {return getGeo()->scale(vec, scale);}; - void transform(Base::Matrix4D mat) {return getGeo()->transform(mat);}; - void translate(Base::Vector3d vec) {return getGeo()->translate(vec);}; + void mirror(Base::Vector3d point) {return getGeo()->mirror(point);} + void mirror(Base::Vector3d point, Base::Vector3d dir) {return getGeo()->mirror(point, dir);} + void rotate(Base::Placement plm) {return getGeo()->rotate(plm);} + void scale(Base::Vector3d vec, double scale) {return getGeo()->scale(vec, scale);} + void transform(Base::Matrix4D mat) {return getGeo()->transform(mat);} + void translate(Base::Vector3d vec) {return getGeo()->translate(vec);} // convenience GeometryFunctions bool isGeoType(const Base::Type &type) const { return getGeo()->getTypeId() == type;} @@ -232,8 +232,8 @@ class SketcherExport GeometryTypedFacade : public GeometryFacade static_assert( std::is_base_of::type>::value && !std::is_same::type>::value, "Only for classes derived from Geometry!"); private: - GeometryTypedFacade(const Part::Geometry * geometry):GeometryFacade(geometry) {}; - GeometryTypedFacade():GeometryFacade() {}; + GeometryTypedFacade(const Part::Geometry * geometry):GeometryFacade(geometry) {} + GeometryTypedFacade():GeometryFacade() {} public: // Factory methods static std::unique_ptr> getTypedFacade(GeometryT * geometry) { From 0ff70c61ed5a9eb23fd965355756df507be36a4c Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 27 Apr 2021 00:20:57 +0200 Subject: [PATCH 170/178] Sketcher: [skip ci] fix memory leak in GeometryFacade --- src/Mod/Sketcher/App/GeometryFacade.cpp | 10 ++++++++-- src/Mod/Sketcher/App/GeometryFacade.h | 5 +++++ src/Mod/Sketcher/App/SketchObjectPyImp.cpp | 1 + 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Mod/Sketcher/App/GeometryFacade.cpp b/src/Mod/Sketcher/App/GeometryFacade.cpp index 971ffa27ec..a5f0b5bb8d 100644 --- a/src/Mod/Sketcher/App/GeometryFacade.cpp +++ b/src/Mod/Sketcher/App/GeometryFacade.cpp @@ -38,13 +38,13 @@ using namespace Sketcher; TYPESYSTEM_SOURCE(Sketcher::GeometryFacade,Base::BaseClass) -GeometryFacade::GeometryFacade(): Geo(nullptr), SketchGeoExtension(nullptr) +GeometryFacade::GeometryFacade(): Geo(nullptr), OwnerGeo(false), SketchGeoExtension(nullptr) { } GeometryFacade::GeometryFacade(const Part::Geometry * geometry) -: Geo(geometry) +: Geo(geometry), OwnerGeo(false) { if(geometry != nullptr) initExtension(); @@ -53,6 +53,12 @@ GeometryFacade::GeometryFacade(const Part::Geometry * geometry) } +GeometryFacade::~GeometryFacade() +{ + if (OwnerGeo) + delete Geo; +} + std::unique_ptr GeometryFacade::getFacade(Part::Geometry * geometry) { if(geometry != nullptr) diff --git a/src/Mod/Sketcher/App/GeometryFacade.h b/src/Mod/Sketcher/App/GeometryFacade.h index 7fac1e70f4..be8d806c34 100644 --- a/src/Mod/Sketcher/App/GeometryFacade.h +++ b/src/Mod/Sketcher/App/GeometryFacade.h @@ -118,7 +118,11 @@ public: // Utility methods static bool getBlocked(const Part::Geometry * geometry); public: + ~GeometryFacade(); void setGeometry(Part::Geometry *geometry); + void setOwner(bool owner) { + OwnerGeo = owner; + } // Geometry Extension Interface inline virtual long getId() const override {return getGeoExt()->getId();} @@ -198,6 +202,7 @@ private: private: const Part::Geometry * Geo; + bool OwnerGeo; std::shared_ptr SketchGeoExtension; }; diff --git a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp index d466d72cf1..7f9d330a40 100644 --- a/src/Mod/Sketcher/App/SketchObjectPyImp.cpp +++ b/src/Mod/Sketcher/App/SketchObjectPyImp.cpp @@ -1824,6 +1824,7 @@ Py::List SketchObjectPy::getGeometryFacadeList(void) const // we create a python copy and add it to the list std::unique_ptr geofacade = GeometryFacade::getFacade(getSketchObjectPtr()->Geometry[i]->clone()); + geofacade->setOwner(true); Py::Object gfp = Py::Object(new GeometryFacadePy(geofacade.release()),true); From d6fa0b1d181ef4dd4f44edb450fe690eb92d54dd Mon Sep 17 00:00:00 2001 From: markus Date: Mon, 26 Apr 2021 12:36:36 -0700 Subject: [PATCH 171/178] Fix generation and build of python classes for 3.9 --- src/Base/PyObjectBase.cpp | 8 ++++++++ src/Tools/generateTemplates/templateClassPyExport.py | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/src/Base/PyObjectBase.cpp b/src/Base/PyObjectBase.cpp index dd9ac4e471..5f8108c4ea 100644 --- a/src/Base/PyObjectBase.cpp +++ b/src/Base/PyObjectBase.cpp @@ -105,7 +105,11 @@ static PyTypeObject PyBaseProxyType = { sizeof(PyBaseProxy), /*tp_basicsize*/ 0, /*tp_itemsize*/ PyBaseProxy_dealloc, /*tp_dealloc*/ +#if PY_VERSION_HEX >= 0x03090000 + 0, /*tp_vectorcall_offset*/ +#else nullptr, /*tp_print*/ +#endif nullptr, /*tp_getattr*/ nullptr, /*tp_setattr*/ nullptr, /*tp_compare*/ @@ -164,7 +168,11 @@ PyTypeObject PyObjectBase::Type = { 0, /*tp_itemsize*/ /* --- methods ---------------------------------------------- */ PyDestructor, /*tp_dealloc*/ +#if PY_VERSION_HEX >= 0x03090000 + 0, /*tp_vectorcall_offset*/ +#else nullptr, /*tp_print*/ +#endif nullptr, /*tp_getattr*/ nullptr, /*tp_setattr*/ nullptr, /*tp_compare*/ diff --git a/src/Tools/generateTemplates/templateClassPyExport.py b/src/Tools/generateTemplates/templateClassPyExport.py index 52c06e41c9..75a1eb2204 100644 --- a/src/Tools/generateTemplates/templateClassPyExport.py +++ b/src/Tools/generateTemplates/templateClassPyExport.py @@ -285,7 +285,11 @@ PyTypeObject @self.export.Name@::Type = { 0, /*tp_itemsize*/ /* methods */ PyDestructor, /*tp_dealloc*/ +#if PY_VERSION_HEX >= 0x03090000 + 0, /*tp_vectorcall_offset*/ +#else nullptr, /*tp_print*/ +#endif nullptr, /*tp_getattr*/ nullptr, /*tp_setattr*/ nullptr, /*tp_compare*/ From 0e7d9171db3aa7ca351fcd4d09a62786516bae2e Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 27 Apr 2021 13:02:57 +0200 Subject: [PATCH 172/178] Path: [skip ci] fix memory leaks --- src/Mod/Path/App/AreaPyImp.cpp | 8 ++++++-- src/Mod/Path/App/VoronoiEdgePyImp.cpp | 20 ++++++++++---------- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/Mod/Path/App/AreaPyImp.cpp b/src/Mod/Path/App/AreaPyImp.cpp index 959f1f8a8b..a02642a71e 100644 --- a/src/Mod/Path/App/AreaPyImp.cpp +++ b/src/Mod/Path/App/AreaPyImp.cpp @@ -206,8 +206,12 @@ PyObject *AreaPy::PyMake(struct _typeobject *, PyObject *args, PyObject *kwd) / AreaPy* ret = new AreaPy(new Area); if(!ret->setParams(args,kwd)) { Py_DecRef(ret); - return 0; + return nullptr; } + + // If setParams() was successful it increments the ref counter. + // So, it must be decremented again. + Py_DecRef(ret); return ret; } @@ -402,7 +406,7 @@ PyObject* AreaPy::setParams(PyObject *args, PyObject *keywds) if (!PyArg_ParseTupleAndKeywords(args, keywds, "|" PARAM_PY_KWDS(AREA_PARAMS_CONF), kwlist, PARAM_REF(PARAM_FNAME,AREA_PARAMS_CONF))) - return 0; + return nullptr; PY_TRY { //populate 'params' with the CONF variables diff --git a/src/Mod/Path/App/VoronoiEdgePyImp.cpp b/src/Mod/Path/App/VoronoiEdgePyImp.cpp index 158616b8a2..52537a58a6 100644 --- a/src/Mod/Path/App/VoronoiEdgePyImp.cpp +++ b/src/Mod/Path/App/VoronoiEdgePyImp.cpp @@ -412,9 +412,9 @@ PyObject* VoronoiEdgePy::toShape(PyObject *args) auto v0 = e->ptr->vertex0(); auto v1 = e->ptr->vertex1(); if (v0 && v1) { - auto p = new Part::GeomLineSegment; - p->setPoints(e->dia->scaledVector(*v0, z0), e->dia->scaledVector(*v1, z1)); - Handle(Geom_Curve) h = Handle(Geom_Curve)::DownCast(p->handle()); + Part::GeomLineSegment p; + p.setPoints(e->dia->scaledVector(*v0, z0), e->dia->scaledVector(*v1, z1)); + Handle(Geom_Curve) h = Handle(Geom_Curve)::DownCast(p.handle()); BRepBuilderAPI_MakeEdge mkBuilder(h, h->FirstParameter(), h->LastParameter()); return new Part::TopoShapeEdgePy(new Part::TopoShape(mkBuilder.Shape())); } @@ -461,9 +461,9 @@ PyObject* VoronoiEdgePy::toShape(PyObject *args) end.x(origin.x() + direction.x() * k); end.y(origin.y() + direction.y() * k); } - auto p = new Part::GeomLineSegment; - p->setPoints(e->dia->scaledVector(begin, z0), e->dia->scaledVector(end, z1)); - Handle(Geom_Curve) h = Handle(Geom_Curve)::DownCast(p->handle()); + Part::GeomLineSegment p; + p.setPoints(e->dia->scaledVector(begin, z0), e->dia->scaledVector(end, z1)); + Handle(Geom_Curve) h = Handle(Geom_Curve)::DownCast(p.handle()); BRepBuilderAPI_MakeEdge mkBuilder(h, h->FirstParameter(), h->LastParameter()); return new Part::TopoShapeEdgePy(new Part::TopoShape(mkBuilder.Shape())); } @@ -574,12 +574,12 @@ PyObject* VoronoiEdgePy::toShape(PyObject *args) gp_Ax2 pb(pbLocn, pbNorm, pbXdir); Handle(Geom_Parabola) parabola = new Geom_Parabola(pb, focal); - auto arc = new Part::GeomArcOfParabola; - arc->setHandle(parabola); - arc->setRange(dist0, dist1, false); + Part::GeomArcOfParabola arc; + arc.setHandle(parabola); + arc.setRange(dist0, dist1, false); // get a shape for the parabola arc - Handle(Geom_Curve) h = Handle(Geom_Curve)::DownCast(arc->handle()); + Handle(Geom_Curve) h = Handle(Geom_Curve)::DownCast(arc.handle()); BRepBuilderAPI_MakeEdge mkBuilder(h, h->FirstParameter(), h->LastParameter()); return new Part::TopoShapeEdgePy(new Part::TopoShape(mkBuilder.Shape())); } From f439e62639e34d6a59fff6af32d9c0ed5077f992 Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 27 Apr 2021 14:32:35 +0200 Subject: [PATCH 173/178] Path: [skip ci] fix memory leaks --- src/Mod/Path/App/Tool.h | 3 +++ src/Mod/Path/App/Tooltable.cpp | 12 ++++++------ src/Mod/Path/App/Tooltable.h | 6 +++--- src/Mod/Path/App/TooltablePyImp.cpp | 4 ++-- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/Mod/Path/App/Tool.h b/src/Mod/Path/App/Tool.h index 01b3b73712..7be4d9d857 100644 --- a/src/Mod/Path/App/Tool.h +++ b/src/Mod/Path/App/Tool.h @@ -23,6 +23,7 @@ #ifndef PATH_TOOL_H #define PATH_TOOL_H +#include #include #include #include @@ -99,6 +100,8 @@ namespace Path static ToolMaterial getToolMaterial(std::string mat); static const char* MaterialName(ToolMaterial mat); }; + + using ToolPtr = std::shared_ptr; } //namespace Path #endif // PATH_TOOL_H diff --git a/src/Mod/Path/App/Tooltable.cpp b/src/Mod/Path/App/Tooltable.cpp index bc2c7e592b..504a8c09ea 100644 --- a/src/Mod/Path/App/Tooltable.cpp +++ b/src/Mod/Path/App/Tooltable.cpp @@ -47,10 +47,10 @@ Tooltable::~Tooltable() void Tooltable::addTool(const Tool &tool) { - Tool *tmp = new Tool(tool); + ToolPtr tmp = std::make_shared(tool); if (!Tools.empty()) { int max = 0; - for(std::map::const_iterator i = Tools.begin(); i != Tools.end(); ++i) { + for(std::map::const_iterator i = Tools.begin(); i != Tools.end(); ++i) { int k = i->first; if (k > max) max = k; @@ -65,7 +65,7 @@ void Tooltable::setTool(const Tool &tool, int pos) if (pos == -1) { addTool(tool); } else { - Tool *tmp = new Tool(tool); + ToolPtr tmp = std::make_shared(tool); Tools[pos] = tmp; } } @@ -88,9 +88,9 @@ void Tooltable::Save (Writer &writer) const { writer.Stream() << writer.ind() << "" << std::endl; writer.incInd(); - for(std::map::const_iterator i = Tools.begin(); i != Tools.end(); ++i) { + for(std::map::const_iterator i = Tools.begin(); i != Tools.end(); ++i) { int k = i->first; - Tool *v = i->second; + ToolPtr v = i->second; writer.Stream() << writer.ind() << "" << std::endl; writer.incInd(); v->Save(writer); @@ -110,7 +110,7 @@ void Tooltable::Restore (XMLReader &reader) for (int i = 0; i < count; i++) { reader.readElement("Toolslot"); int id = reader.getAttributeAsInteger("number"); - Tool *tmp = new Tool(); + ToolPtr tmp = std::make_shared(); tmp->Restore(reader); Tools[id] = tmp; } diff --git a/src/Mod/Path/App/Tooltable.h b/src/Mod/Path/App/Tooltable.h index 104aafde0a..bdfbe27fba 100644 --- a/src/Mod/Path/App/Tooltable.h +++ b/src/Mod/Path/App/Tooltable.h @@ -53,12 +53,12 @@ namespace Path // auto unsigned int getSize(void) const {return Tools.size();} - const Tool &getTool(int pos) {return *Tools[pos];} - const std::map &getTools(void) const {return Tools;} + const Tool &getTool(int pos) {return *Tools.at(pos);} + const std::map &getTools(void) const {return Tools;} bool hasTool(int pos) const {return (Tools.count(pos) != 0);} // attributes - std::map Tools; + std::map Tools; int Version; std::string Name; }; diff --git a/src/Mod/Path/App/TooltablePyImp.cpp b/src/Mod/Path/App/TooltablePyImp.cpp index 92da20221e..1facaab295 100644 --- a/src/Mod/Path/App/TooltablePyImp.cpp +++ b/src/Mod/Path/App/TooltablePyImp.cpp @@ -97,7 +97,7 @@ int TooltablePy::PyInit(PyObject* args, PyObject* /*kwd*/) Py::Dict TooltablePy::getTools(void) const { Py::Dict dict; - for(std::map::iterator i = getTooltablePtr()->Tools.begin(); i != getTooltablePtr()->Tools.end(); ++i) { + for(std::map::iterator i = getTooltablePtr()->Tools.begin(); i != getTooltablePtr()->Tools.end(); ++i) { PyObject *tool = new Path::ToolPy(new Tool(*i->second)); dict.setItem(Py::Long(i->first), Py::asObject(tool)); } @@ -267,7 +267,7 @@ PyObject* TooltablePy::templateAttrs(PyObject * args) { (void)args; PyObject *dict = PyDict_New(); - for(std::map::iterator i = getTooltablePtr()->Tools.begin(); i != getTooltablePtr()->Tools.end(); ++i) { + for(std::map::iterator i = getTooltablePtr()->Tools.begin(); i != getTooltablePtr()->Tools.end(); ++i) { // The 'tool' object must be created on the heap otherwise Python // will fail to properly track the reference counts and aborts // in debug mode. From 56c92d11989967f7d85e822293c6db5d90b96d78 Mon Sep 17 00:00:00 2001 From: wmayer Date: Tue, 27 Apr 2021 14:35:34 +0200 Subject: [PATCH 174/178] Fix generation and build of python classes for 3.8 --- src/Base/PyObjectBase.cpp | 4 ++-- src/Tools/generateTemplates/templateClassPyExport.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Base/PyObjectBase.cpp b/src/Base/PyObjectBase.cpp index 5f8108c4ea..6af4326050 100644 --- a/src/Base/PyObjectBase.cpp +++ b/src/Base/PyObjectBase.cpp @@ -105,7 +105,7 @@ static PyTypeObject PyBaseProxyType = { sizeof(PyBaseProxy), /*tp_basicsize*/ 0, /*tp_itemsize*/ PyBaseProxy_dealloc, /*tp_dealloc*/ -#if PY_VERSION_HEX >= 0x03090000 +#if PY_VERSION_HEX >= 0x03080000 0, /*tp_vectorcall_offset*/ #else nullptr, /*tp_print*/ @@ -168,7 +168,7 @@ PyTypeObject PyObjectBase::Type = { 0, /*tp_itemsize*/ /* --- methods ---------------------------------------------- */ PyDestructor, /*tp_dealloc*/ -#if PY_VERSION_HEX >= 0x03090000 +#if PY_VERSION_HEX >= 0x03080000 0, /*tp_vectorcall_offset*/ #else nullptr, /*tp_print*/ diff --git a/src/Tools/generateTemplates/templateClassPyExport.py b/src/Tools/generateTemplates/templateClassPyExport.py index 75a1eb2204..f027c61247 100644 --- a/src/Tools/generateTemplates/templateClassPyExport.py +++ b/src/Tools/generateTemplates/templateClassPyExport.py @@ -285,7 +285,7 @@ PyTypeObject @self.export.Name@::Type = { 0, /*tp_itemsize*/ /* methods */ PyDestructor, /*tp_dealloc*/ -#if PY_VERSION_HEX >= 0x03090000 +#if PY_VERSION_HEX >= 0x03080000 0, /*tp_vectorcall_offset*/ #else nullptr, /*tp_print*/ From 985cbad2fa609c6d77d3be81a502f484b69280ba Mon Sep 17 00:00:00 2001 From: Keith Sloan Date: Tue, 27 Apr 2021 17:42:06 +0100 Subject: [PATCH 175/178] Add Load/Save/Refresh to add OpenSCAD Elements --- src/Mod/OpenSCAD/OpenSCADCommands.py | 41 ++++++++++++++++++---------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/src/Mod/OpenSCAD/OpenSCADCommands.py b/src/Mod/OpenSCAD/OpenSCADCommands.py index 22fd7efced..86b5d8bbbc 100644 --- a/src/Mod/OpenSCAD/OpenSCADCommands.py +++ b/src/Mod/OpenSCAD/OpenSCADCommands.py @@ -327,7 +327,17 @@ class RemoveSubtree: class AddSCADWidget(QtGui.QWidget): def __init__(self,*args): QtGui.QWidget.__init__(self,*args) + # Main text area self.textEdit=QtGui.QTextEdit() + self.textEdit.setAcceptRichText(False) + #print(self.textEdit.maximumHeight()) + #print(self.textEdit.maximumViewportSize()) + # Message Area + self.textMsg=QtGui.QPlainTextEdit() + self.textMsg.setReadOnly(True) + h = int(2.5 * self.textMsg.fontMetrics().height()) + self.textMsg.setMaximumHeight(h) + self.textMsg.resize(self.textMsg.width(),h) self.buttonadd = QtGui.QPushButton(translate('OpenSCAD','Add')) self.buttonclear = QtGui.QPushButton(translate('OpenSCAD','Clear')) self.buttonload = QtGui.QPushButton(translate('OpenSCAD','Load')) @@ -344,6 +354,7 @@ class AddSCADWidget(QtGui.QWidget): layout.addLayout(layouth) layout.addWidget(self.checkboxmesh) layout.addWidget(self.textEdit) + layout.addWidget(self.textMsg) self.setLayout(layout) self.setWindowTitle(translate('OpenSCAD','Add OpenSCAD Element')) self.textEdit.setText(u'cube();') @@ -351,6 +362,9 @@ class AddSCADWidget(QtGui.QWidget): def retranslateUi(self, widget=None): self.buttonadd.setText(translate('OpenSCAD','Add')) + self.buttonload.setText(translate('OpenSCAD','Load')) + self.buttonsave.setText(translate('OpenSCAD','Save')) + self.buttonrefresh.setText(translate('OpenSCAD','Refesh')) self.buttonclear.setText(translate('OpenSCAD','Clear')) self.checkboxmesh.setText(translate('OpenSCAD','as Mesh')) self.setWindowTitle(translate('OpenSCAD','Add OpenSCAD Element')) @@ -362,6 +376,7 @@ class AddSCADTask: self.form.buttonload.clicked.connect(self.loadelement) self.form.buttonsave.clicked.connect(self.saveelement) self.form.buttonrefresh.clicked.connect(self.refreshelement) + def getStandardButtons(self): return int(QtGui.QDialogButtonBox.Close) @@ -394,10 +409,11 @@ class AddSCADTask: pass except OpenSCADUtils.OpenSCADError as e: + self.form.textMsg.setPlainText(e.value) FreeCAD.Console.PrintError(e.value) def refreshelement(self): - print('Refresh Element') + self.form.textMsg.setPlainText('') doc=FreeCAD.activeDocument() if doc : for obj in doc.Objects : @@ -405,32 +421,22 @@ class AddSCADTask: self.addelement() def loadelement(self): - print('Load Element') - print('Load Element') filename, filter = QtGui.QFileDialog.getOpenFileName(parent=self.form, caption='Open file', dir='.', filter='OpenSCAD Files (*.scad)',selectedFilter='',option=0) if filename: print('filename :'+filename) - fp = open(filename,'r') - with fp: - data = fp.read() - self.form.textEdit.setText(data) + with open(filename,'r') as fp : + data = fp.read() + self.form.textEdit.setText(data) def saveelement(self) : - print('Save Element') filename, filter = QtGui.QFileDialog.getSaveFileName(parent=self.form, caption='Open file', dir='.', filter='OpenSCAD Files (*.scad)',selectedFilter='',option=0) if filename: - print('filename :'+filename) Text = self.form.textEdit.toPlainText() - fp = open(filename,'w') - with fp: + with open(filename,'w') as fp : fp.write(Text) -class OpenSCADMeshBooleanWidget(QtGui.QWidget): - def __init__(self,*args): - QtGui.QWidget.__init__(self,*args) - #self.textEdit=QtGui.QTextEdit() class OpenSCADMeshBooleanWidget(QtGui.QWidget): def __init__(self,*args): QtGui.QWidget.__init__(self,*args) @@ -471,6 +477,7 @@ class OpenSCADMeshBooleanTask: def __init__(self): self.form = OpenSCADMeshBooleanWidget() self.form.buttonadd.clicked.connect(self.doboolean) + def getStandardButtons(self): return int(QtGui.QDialogButtonBox.Close) @@ -500,9 +507,11 @@ class OpenSCADMeshBooleanTask: class AddOpenSCADElement: def IsActive(self): return not FreeCADGui.Control.activeDialog() + def Activated(self): panel = AddSCADTask() FreeCADGui.Control.showDialog(panel) + def GetResources(self): return {'Pixmap' : 'OpenSCAD_AddOpenSCADElement', 'MenuText': QtCore.QT_TRANSLATE_NOOP('OpenSCAD_AddOpenSCADElement', 'Add OpenSCAD Element...'), @@ -513,9 +522,11 @@ class OpenSCADMeshBoolean: def IsActive(self): return not FreeCADGui.Control.activeDialog() and \ len(FreeCADGui.Selection.getSelection()) >= 1 + def Activated(self): panel = OpenSCADMeshBooleanTask() FreeCADGui.Control.showDialog(panel) + def GetResources(self): return {'Pixmap' : 'OpenSCAD_MeshBooleans', 'MenuText': QtCore.QT_TRANSLATE_NOOP('OpenSCAD_MeshBoolean','Mesh Boolean...'), From 63cd79538e460d17612c134621ec84effc84185c Mon Sep 17 00:00:00 2001 From: luz paz Date: Mon, 26 Apr 2021 18:58:07 -0400 Subject: [PATCH 176/178] Misc: remove py2 code --- src/Mod/Assembly/App/AppAssembly.cpp | 4 ---- src/Mod/Assembly/Gui/AppAssemblyGui.cpp | 4 ---- src/Mod/JtReader/App/AppJtReader.cpp | 4 ---- src/Tools/generateTemplates/templateClassPyExport.py | 12 ------------ 4 files changed, 24 deletions(-) diff --git a/src/Mod/Assembly/App/AppAssembly.cpp b/src/Mod/Assembly/App/AppAssembly.cpp index 5a8bd4a9d4..15703cc430 100644 --- a/src/Mod/Assembly/App/AppAssembly.cpp +++ b/src/Mod/Assembly/App/AppAssembly.cpp @@ -57,16 +57,12 @@ void AssemblyExport initAssembly() PyErr_SetString(PyExc_ImportError, e.what()); return; } -#if PY_MAJOR_VERSION >= 3 static struct PyModuleDef AssemblyAPIDef = { PyModuleDef_HEAD_INIT, "Assembly", module_Assembly_doc, -1, Assembly_methods, NULL, NULL, NULL, NULL }; PyModule_Create(&AssemblyAPIDef); -#else - Py_InitModule3("Assembly", Assembly_methods, module_Assembly_doc); /* mod name, table ptr */ -#endif Base::Console().Log("Loading Assembly module... done\n"); diff --git a/src/Mod/Assembly/Gui/AppAssemblyGui.cpp b/src/Mod/Assembly/Gui/AppAssemblyGui.cpp index b671bb18fb..1ff44d567d 100644 --- a/src/Mod/Assembly/Gui/AppAssemblyGui.cpp +++ b/src/Mod/Assembly/Gui/AppAssemblyGui.cpp @@ -68,16 +68,12 @@ void AssemblyGuiExport initAssemblyGui() return; } -#if PY_MAJOR_VERSION >= 3 static struct PyModuleDef AssemblyGuiAPIDef = { PyModuleDef_HEAD_INIT, "AssemblyGui", 0, -1, AssemblyGui_Import_methods, NULL, NULL, NULL, NULL }; PyModule_Create(&AssemblyGuiAPIDef); -#else - (void) Py_InitModule("AssemblyGui", AssemblyGui_Import_methods); /* mod name, table ptr */ -#endif Base::Console().Log("Loading GUI of Assembly module... done\n"); // directly load the module for usage in commands diff --git a/src/Mod/JtReader/App/AppJtReader.cpp b/src/Mod/JtReader/App/AppJtReader.cpp index 1d7390638c..bd621e5d12 100644 --- a/src/Mod/JtReader/App/AppJtReader.cpp +++ b/src/Mod/JtReader/App/AppJtReader.cpp @@ -37,16 +37,12 @@ extern struct PyMethodDef JtReader_methods[]; extern "C" { void AppJtReaderExport initJtReader() { -#if PY_MAJOR_VERSION >= 3 static struct PyModuleDef JtReaderAPIDef = { PyModuleDef_HEAD_INIT, "JtReader", 0, -1, JtReader_methods, NULL, NULL, NULL, NULL }; PyModule_Create(&JtReaderAPIDef); -#else - (void) Py_InitModule("JtReader", JtReader_methods); /* mod name, table ptr */ -#endif // load dependent module Base::Interpreter().loadModule("Mesh"); diff --git a/src/Tools/generateTemplates/templateClassPyExport.py b/src/Tools/generateTemplates/templateClassPyExport.py index f027c61247..13fd564532 100644 --- a/src/Tools/generateTemplates/templateClassPyExport.py +++ b/src/Tools/generateTemplates/templateClassPyExport.py @@ -314,19 +314,7 @@ PyTypeObject @self.export.Name@::Type = { /* --- Functions to access object as input/output buffer ---------*/ nullptr, /* tp_as_buffer */ /* --- Flags to define presence of optional/expanded features */ -#if PY_MAJOR_VERSION >= 3 Py_TPFLAGS_BASETYPE|Py_TPFLAGS_DEFAULT, /*tp_flags */ -#else -+ if (self.export.RichCompare and self.export.NumberProtocol): - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_RICHCOMPARE|Py_TPFLAGS_CHECKTYPES, /*tp_flags */ -= elif (self.export.RichCompare): - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_RICHCOMPARE, /*tp_flags */ -= elif (self.export.NumberProtocol): - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES, /*tp_flags */ -= else: - Py_TPFLAGS_DEFAULT, /*tp_flags */ -- -#endif "@self.export.Documentation.UserDocu.replace('\\n','\\\\n\\"\\n \\"')@", /*tp_doc */ nullptr, /*tp_traverse */ nullptr, /*tp_clear */ From 0909fa76aa254ec6a547e4f2cb72c9e2e1171671 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 28 Apr 2021 10:54:26 +0200 Subject: [PATCH 177/178] Base: allow to use the classes XUTF8Str and StrXUTF8 outside FreeCADBase --- src/Base/Parameter.cpp | 3 +- src/Base/XMLTools.cpp | 97 +++++++++++++++++++++++++++++++++--- src/Base/XMLTools.h | 109 ++++++----------------------------------- 3 files changed, 104 insertions(+), 105 deletions(-) diff --git a/src/Base/Parameter.cpp b/src/Base/Parameter.cpp index e78ccf46c0..377a669410 100644 --- a/src/Base/Parameter.cpp +++ b/src/Base/Parameter.cpp @@ -1213,8 +1213,7 @@ void ParameterManager::Init(void) void ParameterManager::Terminate(void) { - StrXUTF8::terminate(); - XUTF8Str::terminate(); + XMLTools::terminate(); XMLPlatformUtils::Terminate(); } diff --git a/src/Base/XMLTools.cpp b/src/Base/XMLTools.cpp index fc6814373f..1b65ad26e8 100644 --- a/src/Base/XMLTools.cpp +++ b/src/Base/XMLTools.cpp @@ -32,15 +32,96 @@ using namespace Base; -std::unique_ptr StrXUTF8::transcoder; -std::unique_ptr XUTF8Str::transcoder; +std::unique_ptr XMLTools::transcoder; -void StrXUTF8::terminate() -{ - transcoder.reset(); -} - -void XUTF8Str::terminate() +void XMLTools::initialize() +{ + XERCES_CPP_NAMESPACE_USE; + if (!transcoder.get()) { + XMLTransService::Codes res; + transcoder.reset(XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::fgTransService->makeNewTranscoderFor(XERCES_CPP_NAMESPACE_QUALIFIER XMLRecognizer::UTF_8, res, 4096, XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::fgMemoryManager)); + if (res != XMLTransService::Ok) + throw Base::UnicodeError("Can\'t create transcoder"); + } +} + +std::string XMLTools::toStdString(const XMLCh* const toTranscode) +{ + std::string str; + + XERCES_CPP_NAMESPACE_USE; + initialize(); + + //char outBuff[128]; + static XMLByte outBuff[128]; +#if (XERCES_VERSION_MAJOR == 2) + unsigned int outputLength; + unsigned int eaten = 0; + unsigned int offset = 0; + unsigned int inputLength = XMLString::stringLen(toTranscode); +#else + XMLSize_t outputLength; + XMLSize_t eaten = 0; + XMLSize_t offset = 0; + XMLSize_t inputLength = XMLString::stringLen(toTranscode); +#endif + + while (inputLength) + { + outputLength = transcoder->transcodeTo(toTranscode + offset, inputLength, outBuff, 128, eaten, XMLTranscoder::UnRep_RepChar); + str.append(reinterpret_cast(outBuff), outputLength); + offset += eaten; + inputLength -= eaten; + + // Bail out if nothing more was produced + if (outputLength == 0) + break; + } + + return str; +} + +std::basic_string XMLTools::toXMLString(const char* const fromTranscode) +{ + std::basic_string str; + if (!fromTranscode) + return str; + + XERCES_CPP_NAMESPACE_USE; + initialize(); + + static XMLCh outBuff[128]; + const XMLByte* xmlBytes = reinterpret_cast(fromTranscode); +#if (XERCES_VERSION_MAJOR == 2) + unsigned int outputLength; + unsigned int eaten = 0; + unsigned int offset = 0; + unsigned int inputLength = std::string(fromTranscode).size(); +#else + XMLSize_t outputLength; + XMLSize_t eaten = 0; + XMLSize_t offset = 0; + XMLSize_t inputLength = std::string(fromTranscode).size(); +#endif + + unsigned char* charSizes = new unsigned char[inputLength]; + while (inputLength) + { + outputLength = transcoder->transcodeFrom(xmlBytes + offset, inputLength, outBuff, 128, eaten, charSizes); + str.append(outBuff, outputLength); + offset += eaten; + inputLength -= eaten; + + // Bail out if nothing more was produced + if (outputLength == 0) + break; + } + + delete[] charSizes; + return str; +} + +void XMLTools::terminate() { transcoder.reset(); } diff --git a/src/Base/XMLTools.h b/src/Base/XMLTools.h index 4fb347f8d2..68590af933 100644 --- a/src/Base/XMLTools.h +++ b/src/Base/XMLTools.h @@ -45,6 +45,18 @@ XERCES_CPP_NAMESPACE_BEGIN class DOMDocument; XERCES_CPP_NAMESPACE_END +// Helper class +class BaseExport XMLTools +{ +public: + static std::string toStdString(const XMLCh* const toTranscode); + static std::basic_string toXMLString(const char* const fromTranscode); + static void initialize(); + static void terminate(); + +private: + static std::unique_ptr transcoder; +}; //************************************************************************** //************************************************************************** @@ -75,17 +87,10 @@ inline StrX::StrX(const XMLCh* const toTranscode) { // Call the private transcoding method fLocalForm = XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode(toTranscode); -//#ifdef FC_OS_WIN32 -// assert(0) -// WideCharToMultiByte(CP_UTF8,0,toTranscode,-1,fLocaleForm) -//#else -// fUnicodeForm = XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode(toTranscode); -//#endif } inline StrX::~StrX() { - //delete [] fLocalForm; // don't work on VC7.1 XERCES_CPP_NAMESPACE_QUALIFIER XMLString::release(&fLocalForm); } @@ -112,12 +117,6 @@ public : const char* c_str() const; /// string which holds the UTF-8 form std::string str; - - static void terminate(); - -private : - static std::unique_ptr transcoder; - // This is the local code page form of the string. }; inline std::ostream& operator<<(std::ostream& target, const StrXUTF8& toDump) @@ -128,39 +127,7 @@ inline std::ostream& operator<<(std::ostream& target, const StrXUTF8& toDump) inline StrXUTF8::StrXUTF8(const XMLCh* const toTranscode) { - XERCES_CPP_NAMESPACE_USE; - if(!transcoder.get()){ - XMLTransService::Codes res; - transcoder.reset(XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::fgTransService->makeNewTranscoderFor(XERCES_CPP_NAMESPACE_QUALIFIER XMLRecognizer::UTF_8, res, 4096, XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::fgMemoryManager)); - if (res != XMLTransService::Ok) - throw Base::UnicodeError("Can\'t create UTF-8 encoder in StrXUTF8::StrXUTF8()"); - } - - //char outBuff[128]; - static XMLByte outBuff[128]; -#if (XERCES_VERSION_MAJOR == 2) - unsigned int outputLength; - unsigned int eaten = 0; - unsigned int offset = 0; - unsigned int inputLength = XMLString::stringLen(toTranscode); -#else - XMLSize_t outputLength; - XMLSize_t eaten = 0; - XMLSize_t offset = 0; - XMLSize_t inputLength = XMLString::stringLen(toTranscode); -#endif - - while (inputLength) - { - outputLength = transcoder->transcodeTo(toTranscode + offset, inputLength, outBuff, 128, eaten, XMLTranscoder::UnRep_RepChar); - str.append(reinterpret_cast(outBuff), outputLength); - offset += eaten; - inputLength -= eaten; - - // Bail out if nothing more was produced - if (outputLength == 0) - break; - } + str = XMLTools::toStdString(toTranscode); } // ----------------------------------------------------------------------- @@ -198,18 +165,11 @@ private : inline XStr::XStr(const char* const toTranscode) { - // Call the private transcoding method -//#ifdef FC_OS_WIN32 -// assert(0) -// WideCharToMultiByte() -//#else fUnicodeForm = XERCES_CPP_NAMESPACE_QUALIFIER XMLString::transcode(toTranscode); -//#endif } inline XStr::~XStr() { - //delete [] fUnicodeForm; XERCES_CPP_NAMESPACE_QUALIFIER XMLString::release(&fUnicodeForm); } @@ -236,54 +196,13 @@ public : /// Getter method const XMLCh* unicodeForm() const; - static void terminate(); - private : std::basic_string str; - static std::unique_ptr transcoder; }; inline XUTF8Str::XUTF8Str(const char* const fromTranscode) { - if (!fromTranscode) - return; - - XERCES_CPP_NAMESPACE_USE; - if(!transcoder.get()){ - XMLTransService::Codes res; - transcoder.reset(XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::fgTransService->makeNewTranscoderFor(XERCES_CPP_NAMESPACE_QUALIFIER XMLRecognizer::UTF_8, res, 4096, XERCES_CPP_NAMESPACE_QUALIFIER XMLPlatformUtils::fgMemoryManager)); - if (res != XMLTransService::Ok) - throw Base::UnicodeError("Can\'t create UTF-8 decoder in XUTF8Str::XUTF8Str()"); - } - - static XMLCh outBuff[128]; - const XMLByte* xmlBytes = reinterpret_cast(fromTranscode); -#if (XERCES_VERSION_MAJOR == 2) - unsigned int outputLength; - unsigned int eaten = 0; - unsigned int offset = 0; - unsigned int inputLength = std::string(fromTranscode).size(); -#else - XMLSize_t outputLength; - XMLSize_t eaten = 0; - XMLSize_t offset = 0; - XMLSize_t inputLength = std::string(fromTranscode).size(); -#endif - - unsigned char* charSizes = new unsigned char[inputLength]; - while (inputLength) - { - outputLength = transcoder->transcodeFrom(xmlBytes + offset, inputLength, outBuff, 128, eaten, charSizes); - str.append(outBuff, outputLength); - offset += eaten; - inputLength -= eaten; - - // Bail out if nothing more was produced - if (outputLength == 0) - break; - } - - delete[] charSizes; + str = XMLTools::toXMLString(fromTranscode); } inline XUTF8Str::~XUTF8Str() From 545d0557661c948da38c190b60b9fd5217b6da0a Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 28 Apr 2021 12:02:52 +0200 Subject: [PATCH 178/178] Gui: [skip ci] fix crash in SequencerBar::setProgress or SequencerDialog::setProgress when used in worker threads --- src/Gui/ProgressBar.cpp | 10 +++++++++- src/Gui/ProgressDialog.cpp | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/Gui/ProgressBar.cpp b/src/Gui/ProgressBar.cpp index fcaff6adb5..9225d24bf3 100644 --- a/src/Gui/ProgressBar.cpp +++ b/src/Gui/ProgressBar.cpp @@ -226,7 +226,15 @@ void SequencerBar::nextStep(bool canAbort) void SequencerBar::setProgress(size_t step) { - d->bar->show(); + QThread* currentThread = QThread::currentThread(); + QThread* thr = d->bar->thread(); // this is the main thread + if (thr != currentThread) { + QMetaObject::invokeMethod(d->bar, "show", Qt::QueuedConnection); + } + else { + d->bar->show(); + } + setValue((int)step); } diff --git a/src/Gui/ProgressDialog.cpp b/src/Gui/ProgressDialog.cpp index 519ad2e72e..81cec75712 100644 --- a/src/Gui/ProgressDialog.cpp +++ b/src/Gui/ProgressDialog.cpp @@ -152,7 +152,15 @@ void SequencerDialog::nextStep(bool canAbort) void SequencerDialog::setProgress(size_t step) { - d->dlg->show(); + QThread* currentThread = QThread::currentThread(); + QThread* thr = d->dlg->thread(); // this is the main thread + if (thr != currentThread) { + QMetaObject::invokeMethod(d->dlg, "show", Qt::QueuedConnection); + } + else { + d->dlg->show(); + } + setValue((int)step); }