Add icon to wizard shaft, error handling of missing python modules, slight changes to the wizard shaft command

This commit is contained in:
wmayer 2012-12-02 15:24:55 +01:00
parent 179f526cd2
commit 6dddb653d3
6 changed files with 450 additions and 14 deletions

View File

@ -31,12 +31,13 @@ INSTALL(
SET(WizardShaft_SRCS
WizardShaft/__init__.py
WizardShaft/WizardShaft.py
WizardShaft/WizardShaftTable.py
WizardShaft/Shaft.py
WizardShaft/ShaftFeature.py
WizardShaft/ShaftDiagram.py
WizardShaft/SegmentFunction.py
WizardShaft/WizardShaft.svg
WizardShaft/WizardShaft.py
WizardShaft/WizardShaftTable.py
WizardShaft/Shaft.py
WizardShaft/ShaftFeature.py
WizardShaft/ShaftDiagram.py
WizardShaft/SegmentFunction.py
)
SOURCE_GROUP("wizardshaft" FILES ${WizardShaft_SRCS})

View File

@ -28,6 +28,8 @@
#endif
#include "Workbench.h"
#include <Gui/Application.h>
#include <Gui/Command.h>
#include <Gui/MenuManager.h>
#include <Gui/ToolBarManager.h>
#include <Gui/Control.h>
@ -214,9 +216,13 @@ Gui::MenuItem* Workbench::setupMenuBar() const
<< "PartDesign_LinearPattern"
<< "PartDesign_PolarPattern"
// << "PartDesign_Scaled"
<< "PartDesign_MultiTransform"
<< "Separator"
<< "PartDesign_WizardShaft";
<< "PartDesign_MultiTransform";
// For 0.13 a couple of python packages like numpy, matplotlib and others
// are not deployed with the installer on Windows. Thus, the WizardShaft is
// not deployed either hence the check for the existence of the command.
if (Gui::Application::Instance->commandManager().getCommandByName("PartDesign_WizardShaft")) {
*part << "Separator" << "PartDesign_WizardShaft";
}
return root;
}

View File

@ -31,7 +31,6 @@
class PartDesignWorkbench ( Workbench ):
"PartDesign workbench object"
from WizardShaft import WizardShaft
Icon = """
/* XPM */
static char * partdesign_xpm[] = {
@ -67,6 +66,10 @@ class PartDesignWorkbench ( Workbench ):
def Initialize(self):
# load the module
try:
from WizardShaft import WizardShaft
except:
print "Wizard shaft not installed"
import PartDesignGui
import PartDesign
def GetClassName(self):

View File

@ -201,7 +201,11 @@ class Shaft:
self.printEquilibrium(variableNames, coefficientsMbz)
# Build matrix and vector for linear algebra solving algorithm
import numpy as np
try:
import numpy as np
except ImportError:
FreeCAD.Console.PrintMessage("numpy is not installed on your system\n")
raise ImportError("numpy not installed")
if (len(coefficientsFy) < 3) or (len(coefficientsMbz) < 3):
return
A = np.array([coefficientsFy[1:], coefficientsMbz[1:]])

View File

@ -49,7 +49,7 @@ class TaskWizardShaft:
# updateSketch() slot will be activated and it relies on finding a valid document
if self.doc == None:
self.Gui.activateWorkbench("PartDesignWorkbench")
self.doc = self.App.newDocument()
self.doc = self.App.ActiveDocument
# Grab the newly created feature window
featureWindow = cw.subWindowList()[-1]
else:
@ -80,11 +80,14 @@ class WizardShaftGui:
FreeCADGui.Control.showDialog(TaskWizardShaft())
def GetResources(self):
IconPath = FreeCAD.ConfigGet("AppHomePath") + "Mod/PartDesign/Gui/Resources/icons/WizardShaftIcon.png"
MenuText = 'Start the shaft design wizard'
IconPath = FreeCAD.ConfigGet("AppHomePath") + "Mod/PartDesign/WizardShaft/WizardShaft.svg"
MenuText = 'Shaft design wizard...'
ToolTip = 'Start the shaft design wizard'
return {'Pixmap' : IconPath, 'MenuText': MenuText, 'ToolTip': ToolTip}
def IsActive(self):
return FreeCAD.ActiveDocument != None
FreeCADGui.addCommand('PartDesign_WizardShaft', WizardShaftGui())
#Note: Start wizard in Python Console with

View File

@ -0,0 +1,419 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
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: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="64px"
height="64px"
id="svg2901"
sodipodi:version="0.32"
inkscape:version="0.48.0 r9654"
sodipodi:docname="PartDesign_Groove.svg"
inkscape:output_extension="org.inkscape.output.svg.inkscape"
version="1.1"
inkscape:export-filename="/home/yorik/PartDesign_Groove.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90">
<defs
id="defs2903">
<linearGradient
id="linearGradient4237">
<stop
id="stop4239"
offset="0"
style="stop-color:#f82b39;stop-opacity:1;" />
<stop
id="stop4241"
offset="1"
style="stop-color:#520001;stop-opacity:1;" />
</linearGradient>
<linearGradient
id="linearGradient4052">
<stop
style="stop-color:#0090ff;stop-opacity:1;"
offset="0"
id="stop4054" />
<stop
id="stop4060"
offset="0.5"
style="stop-color:#f0f1f1;stop-opacity:1;" />
<stop
style="stop-color:#0046ff;stop-opacity:1;"
offset="1"
id="stop4056" />
</linearGradient>
<linearGradient
id="linearGradient4044">
<stop
style="stop-color:#0090ff;stop-opacity:1;"
offset="0"
id="stop4046" />
<stop
style="stop-color:#061aff;stop-opacity:1;"
offset="1"
id="stop4048" />
</linearGradient>
<linearGradient
id="linearGradient3273">
<stop
id="stop3275"
offset="0"
style="stop-color:#c8e0f9;stop-opacity:1;" />
<stop
id="stop3277"
offset="1"
style="stop-color:#f7f9fa;stop-opacity:0.09649123;" />
</linearGradient>
<linearGradient
id="linearGradient3377">
<stop
id="stop3379"
offset="0"
style="stop-color:#c8e0f9;stop-opacity:1;" />
<stop
id="stop3381"
offset="1"
style="stop-color:#002795;stop-opacity:1;" />
</linearGradient>
<inkscape:perspective
sodipodi:type="inkscape:persp3d"
inkscape:vp_x="0 : 32 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_z="64 : 32 : 1"
inkscape:persp3d-origin="32 : 21.333333 : 1"
id="perspective2909" />
<inkscape:perspective
id="perspective3674"
inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
inkscape:vp_z="1 : 0.5 : 1"
inkscape:vp_y="0 : 1000 : 0"
inkscape:vp_x="0 : 0.5 : 1"
sodipodi:type="inkscape:persp3d" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4044"
id="linearGradient4050"
x1="44.858215"
y1="14.016123"
x2="33.928684"
y2="33.216251"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.97680237,0,0,0.96003508,1.4694319,0.12765765)" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4052"
id="linearGradient4058"
x1="42.373707"
y1="5.7974987"
x2="52.323219"
y2="22.675821"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.97680237,0,0,0.96003508,1.4694319,0.12765765)" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4052-1"
id="linearGradient4058-6"
x1="42.373707"
y1="5.7974987"
x2="52.323219"
y2="22.675821"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.97680237,0,0,0.96003508,1.4694319,0.12765765)" />
<linearGradient
id="linearGradient4052-1">
<stop
style="stop-color:#0090ff;stop-opacity:1;"
offset="0"
id="stop4054-5" />
<stop
id="stop4060-8"
offset="0.5"
style="stop-color:#f0f1f1;stop-opacity:1;" />
<stop
style="stop-color:#0046ff;stop-opacity:1;"
offset="1"
id="stop4056-4" />
</linearGradient>
<linearGradient
gradientTransform="translate(-30.295225,-2.9287147)"
y2="22.675821"
x2="52.323219"
y1="5.7974987"
x1="42.373707"
gradientUnits="userSpaceOnUse"
id="linearGradient4078"
xlink:href="#linearGradient4052-1"
inkscape:collect="always" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4044"
id="linearGradient3885"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.97680237,0,0,0.96003508,107.10579,-22.235978)"
x1="44.858215"
y1="14.016123"
x2="33.928684"
y2="33.216251" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4052-1"
id="linearGradient3890"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.97680237,0,0,0.96003508,107.10579,-22.235978)"
x1="42.373707"
y1="5.7974987"
x2="52.323219"
y2="22.675821" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4052"
id="linearGradient3893"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.97680237,0,0,0.96003508,107.10579,-22.235978)"
x1="42.373707"
y1="5.7974987"
x2="52.323219"
y2="22.675821" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4052-1-0"
id="linearGradient3890-3"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.55370638,0,0,0.55364331,74.680363,-24.12284)"
x1="42.373707"
y1="5.7974987"
x2="52.323219"
y2="22.675821" />
<linearGradient
id="linearGradient4052-1-0">
<stop
style="stop-color:#0090ff;stop-opacity:1;"
offset="0"
id="stop4054-5-5" />
<stop
id="stop4060-8-6"
offset="0.5"
style="stop-color:#f0f1f1;stop-opacity:1;" />
<stop
style="stop-color:#0046ff;stop-opacity:1;"
offset="1"
id="stop4056-4-6" />
</linearGradient>
<linearGradient
y2="22.675821"
x2="52.323219"
y1="5.7974987"
x1="42.373707"
gradientTransform="matrix(0.97680237,0,0,0.96003508,-3.3630199,-18.322982)"
gradientUnits="userSpaceOnUse"
id="linearGradient3912"
xlink:href="#linearGradient4052-1-0"
inkscape:collect="always" />
<linearGradient
id="linearGradient4052-1-0-0">
<stop
style="stop-color:#0090ff;stop-opacity:1;"
offset="0"
id="stop4054-5-5-9" />
<stop
id="stop4060-8-6-8"
offset="0.5"
style="stop-color:#f0f1f1;stop-opacity:1;" />
<stop
style="stop-color:#0046ff;stop-opacity:1;"
offset="1"
id="stop4056-4-6-4" />
</linearGradient>
<linearGradient
y2="22.675821"
x2="52.323219"
y1="5.7974987"
x1="42.373707"
gradientTransform="matrix(0.97680237,0,0,0.96003508,126.73769,-70.092683)"
gradientUnits="userSpaceOnUse"
id="linearGradient3985"
xlink:href="#linearGradient4052-1-0-0"
inkscape:collect="always" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4044"
id="linearGradient3885-6"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.55370638,0,0,0.55364331,60.929239,37.280914)"
x1="44.858215"
y1="14.016123"
x2="33.928684"
y2="33.216251" />
<linearGradient
id="linearGradient4044-8">
<stop
style="stop-color:#0090ff;stop-opacity:1;"
offset="0"
id="stop4046-2" />
<stop
style="stop-color:#061aff;stop-opacity:1;"
offset="1"
id="stop4048-1" />
</linearGradient>
<linearGradient
y2="33.216251"
x2="33.928684"
y1="14.016123"
x1="44.858215"
gradientTransform="matrix(0.97680237,0,0,0.96003508,-26.24677,-8.4607595)"
gradientUnits="userSpaceOnUse"
id="linearGradient4072"
xlink:href="#linearGradient4044-8"
inkscape:collect="always" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4044-8-4"
id="linearGradient3885-6-5"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.97680237,0,0,0.96003508,58.307367,54.671469)"
x1="44.858215"
y1="14.016123"
x2="33.928684"
y2="33.216251" />
<linearGradient
id="linearGradient4044-8-4">
<stop
style="stop-color:#0090ff;stop-opacity:1;"
offset="0"
id="stop4046-2-0" />
<stop
style="stop-color:#061aff;stop-opacity:1;"
offset="1"
id="stop4048-1-9" />
</linearGradient>
<linearGradient
y2="33.216251"
x2="33.928684"
y1="14.016123"
x1="44.858215"
gradientTransform="matrix(0.97680237,0,0,0.96003508,145.41299,94.782221)"
gradientUnits="userSpaceOnUse"
id="linearGradient4163"
xlink:href="#linearGradient4044-8-4"
inkscape:collect="always" />
<linearGradient
inkscape:collect="always"
xlink:href="#linearGradient4052-1-0-9"
id="linearGradient3890-3-5"
gradientUnits="userSpaceOnUse"
gradientTransform="matrix(0.55370638,0,0,0.55364331,74.680363,-24.12284)"
x1="42.373707"
y1="5.7974987"
x2="52.323219"
y2="22.675821" />
<linearGradient
id="linearGradient4052-1-0-9">
<stop
style="stop-color:#0090ff;stop-opacity:1;"
offset="0"
id="stop4054-5-5-2" />
<stop
id="stop4060-8-6-5"
offset="0.5"
style="stop-color:#f0f1f1;stop-opacity:1;" />
<stop
style="stop-color:#0046ff;stop-opacity:1;"
offset="1"
id="stop4056-4-6-5" />
</linearGradient>
<linearGradient
y2="22.675821"
x2="52.323219"
y1="5.7974987"
x1="42.373707"
gradientTransform="matrix(0.97680237,0,0,0.96003508,126.73769,-70.092687)"
gradientUnits="userSpaceOnUse"
id="linearGradient4217"
xlink:href="#linearGradient4052-1-0-9"
inkscape:collect="always" />
</defs>
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="3.8890873"
inkscape:cx="38.625766"
inkscape:cy="12.657788"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:document-units="px"
inkscape:grid-bbox="true"
inkscape:window-width="1920"
inkscape:window-height="1018"
inkscape:window-x="-8"
inkscape:window-y="-8"
inkscape:window-maximized="1"
inkscape:snap-global="true"
inkscape:snap-nodes="true"
inkscape:object-paths="true"
inkscape:object-nodes="true"
inkscape:snap-intersection-paths="true" />
<metadata
id="metadata2906">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
inkscape:label="Layer 1"
inkscape:groupmode="layer">
<path
style="color:#000000;fill:none;stroke:#ff0d00;stroke-width:5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
d="M 60.033553,11.624146 2.9356835,49.895439"
id="path4129"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cc" />
<path
style="color:#000000;fill:url(#linearGradient3885-6);fill-opacity:1.0;fill-rule:evenodd;stroke:#000137;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
d="m 33.589321,8.1499488 c 0.310719,0.4348594 0.568952,0.924885 0.761713,1.4417267 1.54209,4.1347065 -1.513953,9.1431885 -6.819987,11.1914025 -1.079148,0.416568 -2.160312,0.657262 -3.223995,0.774928 7.099799,4.804046 13.087612,12.269737 15.251972,21.806117 0.674062,-1.709016 1.803272,-3.374523 3.365708,-4.775719 2.394689,-2.147563 5.276855,-3.22083 7.847415,-3.153778 1.999324,0.05215 3.808695,0.783303 5.066276,2.234677 0.431584,0.49809 0.762456,1.065523 1.027427,1.657986 C 57.308292,21.656223 46.249275,12.722898 33.589321,8.1499488 z"
id="path3832-2"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cssccssscc" />
<path
style="color:#000000;fill:none;stroke:#000137;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
d="m 33.595667,8.1588471 c 0.31072,0.4348652 0.568952,0.9248908 0.761713,1.4417268 1.542089,4.1347081 -1.513952,9.1431901 -6.819987,11.1914041 -1.079148,0.416568 -2.160311,0.657262 -3.223994,0.774928 m 15.251974,21.806118 c 0.67406,-1.709017 1.803271,-3.374523 3.365708,-4.77572 2.394689,-2.147563 5.276852,-3.22083 7.847414,-3.153778 1.999324,0.05215 3.808695,0.783303 5.066277,2.234677 0.431581,0.49809 0.762455,1.065523 1.027426,1.657986"
id="path3832-2-9"
inkscape:connector-curvature="0"
sodipodi:nodetypes="cssccsssc" />
<path
id="path3846-3"
style="color:#000000;fill:url(#linearGradient3890-3);fill-opacity:1;fill-rule:evenodd;stroke:#000137;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
d="m 3.536174,22.642207 c 18.022131,7.741361 26.381756,27.136035 26.236001,37.96079 L 40.42899,51.501192 C 40.591405,33.650608 27.82732,21.231698 15.136181,17.008914 z"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccc" />
<path
id="path3842-6"
style="color:#000000;fill:url(#linearGradient3890-3-5);fill-opacity:1;fill-rule:evenodd;stroke:#000137;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
d="M 56.874841,39.325295 C 57.306666,21.656073 46.253772,12.727686 33.592842,8.1578264 L 39.537797,5.2929423 C 56.829323,9.1025668 61.692642,25.014757 61.692642,35.542943 z"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccc" />
<path
id="path3852-7"
style="color:#000000;fill:#8bd2f7;fill-opacity:1;fill-rule:evenodd;stroke:#000137;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;marker:none;visibility:visible;display:inline;overflow:visible;enable-background:accumulate"
d="M 29.772175,60.602996 C 29.91793,49.77824 21.558305,30.383568 3.5361734,22.642207 L 3.97344,30.797845 c 7.619318,3.028308 17.782178,14.976717 18.219445,24.911767 z"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccc" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 16 KiB