Compare commits

...

25 Commits

Author SHA1 Message Date
wmayer 5d0ff3556a Apply fix for #0001013 and SketchObjectPy::fillet() from master 2013-03-03 12:53:34 +01:00
wmayer ec7636d7aa Set FREECAD_USE_EXTERNAL_ZIPIOS if zipios++ sources are missing 2013-02-02 18:09:17 +01:00
wmayer 30d655f9aa Set FREECAD_USE_EXTERNAL_ZIPIOS if zipios++ sources are missing 2013-02-02 17:54:06 +01:00
jriegel 63578ee1ea switch to release 2013-01-28 18:36:23 +01:00
Yorik van Havre d41b40eece 0000963: Draft polar array 2013-01-23 16:31:57 -02:00
Sebastian Hoogen d3ea50fd6a process OpenSCADs stdout and allow os.unlink to fail 2013-01-21 13:55:45 +01:00
Sebastian Hoogen c3b11b531e 0000962: Attempting to import an SVG file fails
with "invalid literal for int() with base 16"
2013-01-21 10:46:55 -02:00
Yorik van Havre 0c1bc4c18f Updated license info for sphinx and start module 2013-01-17 13:34:52 -02:00
logari81 e4fc1c7e03 small fix from cherry picking 2013-01-12 15:10:36 +01:00
logari81 56e448d161 PartDesign: Deactivate nesting of original features in patterns
Conflicts:

	src/Mod/PartDesign/Gui/ViewProviderMultiTransform.cpp
	src/Mod/PartDesign/Gui/ViewProviderTransformed.cpp
	src/Mod/PartDesign/Gui/ViewProviderTransformed.h
2013-01-12 14:45:38 +01:00
logari81 4ed9b1c284 PartDesign: Refactor pattern features and gui
- remove StdDirection,StdAxis and StdMirrorPlane properties
- support sketch H_Axis, V_Axis, N_axis as valid references in patterns
- polish reference selection gui (unified for standard axes and custom references)
2013-01-12 14:42:07 +01:00
logari81 7da2ecacbd Sketcher, 0000944: Fix crash when the equality constraint is activated with a wrong selection 2013-01-12 14:41:23 +01:00
wmayer bb967df728 License issues 2013-01-09 15:26:55 +01:00
Sebastian Hoogen d4fc3a5463 add license notice to ply/setup.py 2013-01-09 15:16:57 +01:00
Sebastian Hoogen 45e10d80d2 added licences for OpenSCAD module 2013-01-09 15:16:57 +01:00
Sebastian Hoogen 8e2ae905dd importCSG reverse polyhedra if they have negative volume 2013-01-09 15:16:56 +01:00
wmayer f1f7238d73 License issues 2013-01-09 14:31:03 +01:00
jriegel 171a8db4d0 Deactivate Nesting of Transform features 2013-01-07 22:13:45 +01:00
wmayer 546ab0feb5 Fix box selection in sketcher 2013-01-05 13:30:50 +01:00
wmayer f4ff92ce15 0000942: Crash when 2xdouble-click on part 2013-01-05 11:27:17 +01:00
jriegel b6f284f553 Apply shoogens partly patch for #935
Merge branch 'bugfix-importsvg' of git://github.com/5263/FreeCAD into releases/FreeCAD-0-13

Conflicts:
	src/Base/PreCompiled.h
2013-01-04 11:11:58 +01:00
wmayer ef1190bf03 0000939: Pressing Escape while pivoting a box crashes 2013-01-03 16:48:27 +01:00
Sebastian Hoogen d374054f2f bugfix for handling of elipses in importSVG 2013-01-03 14:46:26 +01:00
wmayer a7e2d50fb2 Applay fix from master using Qt's QUuid class 2013-01-02 14:37:08 +01:00
wmayer b77b59f090 Apply bug fix from master 2012-12-31 14:47:59 +01:00
72 changed files with 1142 additions and 595 deletions
+4
View File
@@ -116,6 +116,10 @@ if (FREECAD_BUILD_DEBIAN)
set(FREECAD_USE_EXTERNAL_PIVY ON)
endif (FREECAD_BUILD_DEBIAN)
if (NOT EXISTS ${CMAKE_SOURCE_DIR}/src/zipios++)
set(FREECAD_USE_EXTERNAL_ZIPIOS ON)
endif ()
# ==============================================================================
if(FREECAD_LIBPACK_USE)
+1 -1
View File
@@ -68,7 +68,7 @@ if(SWIG_FOUND)
add_definitions(-DHAVE_SWIG=1)
endif(SWIG_FOUND)
if (EXISTS ${CMAKE_SOURCE_DIR}/src/zipios++ AND NOT FREECAD_USE_EXTERNAL_ZIPIOS)
if (NOT FREECAD_USE_EXTERNAL_ZIPIOS)
SET(zipios_SRCS
../zipios++/backbuffer.h
../zipios++/basicentry.cpp
+10 -10
View File
@@ -97,18 +97,18 @@
#include <xercesc/sax2/SAX2XMLReader.hpp>
#include <xercesc/sax2/XMLReaderFactory.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/exception.hpp>
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/filesystem/exception.hpp>
#include <boost/regex.hpp>
// QtCore
#include <QBuffer>
#include <QByteArray>
// QtCore
#include <QBuffer>
#include <QByteArray>
#include <QCoreApplication>
#include <QEvent>
#include <QIODevice>
#include <QDataStream>
#include <QIODevice>
#include <QDataStream>
#include <QWriteLocker>
#include <QReadLocker>
#include <QReadWriteLock>
@@ -116,7 +116,7 @@
#include <QMutexLocker>
#include <QUuid>
#endif //_PreComp_
#endif // BASE_PRECOMPILED_H
+24
View File
@@ -1,4 +1,28 @@
# -*- coding: utf-8 -*-
#***************************************************************************
#* *
#* Copyright (c) 2012 *
#* Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser 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 *
#* *
#***************************************************************************
#
# FreeCAD documentation build configuration file, created by
# sphinx-quickstart on Wed Nov 30 10:49:09 2011.
+5
View File
@@ -290,6 +290,11 @@ void ViewProviderGeometryObject::unsetEdit(int ModNum)
// The manipulator has a sensor as user data and this sensor contains the view provider
SoCenterballManip * manip = static_cast<SoCenterballManip*>(path->getTail());
SoNodeSensor* sensor = reinterpret_cast<SoNodeSensor*>(manip->getUserData());
// #0000939: Pressing Escape while pivoting a box crashes
// #0000942: Crash when 2xdouble-click on part
SoDragger* dragger = manip->getDragger();
if (dragger && dragger->getHandleEventAction())
dragger->grabEventsCleanup();
// detach sensor
sensor->detach();
@@ -1,3 +1,10 @@
/***************************************************************************
* *
* Copyright: http://www.ii-system.com *
* License: LGPL *
* *
***************************************************************************/
#include <QtGui/QApplication>
#include "styles.h"
@@ -1,3 +1,10 @@
/***************************************************************************
* *
* Copyright: http://www.ii-system.com *
* License: LGPL *
* *
***************************************************************************/
#include "styles.h"
#include <iisTaskPanel>
@@ -1,3 +1,10 @@
/***************************************************************************
* *
* Copyright: http://www.ii-system.com *
* License: LGPL *
* *
***************************************************************************/
#ifndef TEST_H
#define TEST_H
+7
View File
@@ -1,3 +1,10 @@
/***************************************************************************
* *
* Copyright: http://www.ii-system.com *
* License: LGPL *
* *
***************************************************************************/
#include <QtGui/QApplication>
#include "test.h"
+7
View File
@@ -1,3 +1,10 @@
/***************************************************************************
* *
* Copyright: http://www.ii-system.com *
* License: LGPL *
* *
***************************************************************************/
#include "test.h"
#include <iisTaskPanel>
+7
View File
@@ -1,3 +1,10 @@
/***************************************************************************
* *
* Copyright: http://www.ii-system.com *
* License: LGPL *
* *
***************************************************************************/
#ifndef TEST_H
#define TEST_H
+8 -2
View File
@@ -3017,10 +3017,16 @@ class _Array(_DraftObject):
return Part.makeCompound(base)
def polarArray(self,shape,center,angle,num,axis):
print "angle ",angle," num ",num
import Part
fraction = angle/num
if angle == 360:
fraction = angle/num
else:
if num == 0:
return shape
fraction = angle/(num-1)
base = [shape.copy()]
for i in range(num):
for i in range(num-1):
currangle = fraction + (i*fraction)
nshape = shape.copy()
nshape.rotate(DraftVecUtils.tup(center), DraftVecUtils.tup(axis), currangle)
+29 -14
View File
@@ -200,21 +200,35 @@ svgcolors = {
'MediumAquamarine': (102, 205, 170),
'OldLace': (253, 245, 230)
}
svgcolorslower = dict((key.lower(),value) for key,value in \
svgcolors.items())
def getcolor(color):
"checks if the given string is a RGB value, or if it is a named color. returns 1-based RGBA tuple."
if (color[:1] == "#"):
r = float(int(color[1:3],16)/255.0)
g = float(int(color[3:5],16)/255.0)
b = float(int(color[5:],16)/255.0)
return (r,g,b,0.0)
else:
for k,v in svgcolors.iteritems():
if (k.lower() == color.lower()):
r = float(v[0]/255.0)
g = float(v[1]/255.0)
b = float(v[2]/255.0)
return (r,g,b,0.0)
"checks if the given string is a RGB value, or if it is a named color. returns 1-based RGBA tuple."
if (color[0] == "#"):
if len(color) == 7:
r = float(int(color[1:3],16)/255.0)
g = float(int(color[3:5],16)/255.0)
b = float(int(color[5:],16)/255.0)
elif len(color) == 4: #expand the hex digits
r = float(int(color[1],16)*17/255.0)
g = float(int(color[2],16)*17/255.0)
b = float(int(color[3],16)*17/255.0)
return (r,g,b,0.0)
elif color.lower().startswith('rgb('):
cvalues=color[3:].lstrip('(').rstrip(')').replace('%',' ').split(',')
if '%' in color:
r,g,b = [int(cv)/100.0 for cv in cvalues]
else:
r,g,b = [int(cv)/255.0 for cv in cvalues]
return (r,g,b,0.0)
else:
v=svgcolorslower.get(color.lower())
if v:
r,g,b = [float(vf)/255.0 for vf in v]
return (r,g,b,0.0)
#for k,v in svgcolors.iteritems():
# if (k.lower() == color.lower()): pass
def getsize(length,mode='discard',base=1):
"""parses length values containing number and unit
@@ -887,7 +901,8 @@ class svgHandler(xml.sax.ContentHandler):
rot90=FreeCAD.Matrix(0,-1,0,0,1,0) #90
m3=m3.multiply(rot90)
m3.move(c.multiply(-1))
sh.transform(m3)
sh.transformShape(m3)
#sh = sh.transformGeometry(m3)
if self.fill:
sh = Part.Wire([sh])
sh = Part.Face(sh)
+23 -23
View File
@@ -4,29 +4,29 @@
# This is the second one of three init scripts, the third one
# runs when the gui is up
#***************************************************************************
#* (c) Juergen Riegel (juergen.riegel@web.de) 2002
#* *
#* This file is part of the FreeCAD CAx development system. *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU General Public License (GPL) *
#* 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. *
#* *
#* FreeCAD 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 FreeCAD; if not, write to the Free Software *
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
#* USA *
#* *
#* Juergen Riegel 2002 *
#***************************************************************************/
#***************************************************************************
#* (c) Juergen Riegel (juergen.riegel@web.de) 2002 *
#* *
#* This file is part of the FreeCAD CAx development system. *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser 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. *
#* *
#* FreeCAD 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 Lesser General Public License for more details. *
#* *
#* You should have received a copy of the GNU Library General Public *
#* License along with FreeCAD; if not, write to the Free Software *
#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
#* USA *
#* *
#* Juergen Riegel 2002 *
#***************************************************************************/
import FreeCAD
param = FreeCAD.ParamGet(\
+1 -1
View File
@@ -1,6 +1,6 @@
#***************************************************************************
#* *
#* Copyright (c) 2012 Sebastian Hoogen <github@sebastianhoogen.de> *
#* Copyright (c) 2012 Sebastian Hoogen <github@sebastianhoogen.de> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
+34 -4
View File
@@ -1,3 +1,33 @@
#***************************************************************************
#* *
#* Copyright (c) 2012 Sebastian Hoogen <github@sebastianhoogen.de> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser 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 *
#* *
#***************************************************************************
__title__="FreeCAD OpenSCAD Workbench - GUI Commands"
__author__ = "Sebastian Hoogen"
__url__ = ["http://free-cad.sourceforge.net"]
'''
This Script includes the GUI Commands of the OpenSCAD module
'''
import FreeCAD,FreeCADGui
from PyQt4 import QtGui, QtCore
@@ -185,8 +215,8 @@ class AddSCADTask:
asmesh=self.form.checkboxmesh.checkState()
import OpenSCADUtils, os
extension= 'stl' if asmesh else 'csg'
tmpfilename=OpenSCADUtils.callopenscadstring(scadstr,extension)
if tmpfilename:
try:
tmpfilename=OpenSCADUtils.callopenscadstring(scadstr,extension)
doc=FreeCAD.activeDocument() or FreeCAD.newDocument()
if asmesh:
import Mesh
@@ -195,8 +225,8 @@ class AddSCADTask:
import importCSG
importCSG.insert(tmpfilename,doc.Name)
os.unlink(tmpfilename)
else:
FreeCAD.Console.PrintError(unicode(translate('OpenSCAD','Running OpenSCAD failed'))+u'\n')
except OpenSCADUtils.OpenSCADError, e:
FreeCAD.Console.PrintError(e.value)
class AddOpenSCADElement:
def IsActive(self):
+1 -1
View File
@@ -1,6 +1,6 @@
#***************************************************************************
#* *
#* Copyright (c) 2012 Sebastian Hoogen <github@sebastianhoogen.de> *
#* Copyright (c) 2012 Sebastian Hoogen <github@sebastianhoogen.de> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
+59 -8
View File
@@ -1,6 +1,6 @@
#***************************************************************************
#* *
#* Copyright (c) 2012 Sebastian Hoogen <github@sebastianhoogen.de> *
#* Copyright (c) 2012 Sebastian Hoogen <github@sebastianhoogen.de> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
@@ -28,22 +28,71 @@ __url__ = ["http://free-cad.sourceforge.net"]
This Script includes various pyhton helper functions that are shared across
the module
'''
class OpenSCADError(Exception):
def __init__(self,value):
self.value= value
#def __repr__(self):
# return self.msg
def __str__(self):
return repr(self.value)
def workaroundforissue128needed():
'''sets the import path depending on the OpenSCAD Verion
for versions <= 2012.06.23 to the current working dir
for versions above to the inputfile dir
see https://github.com/openscad/openscad/issues/128'''
vdate=getopenscadversion().split(' ')[2].split('.')
year,mon=int(vdate[0]),int(vdate[1])
return (year<2012 or (year==2012 and (mon <6 or (mon == 6 and \
(len(vdate)<3 or int(vdate[2]) <=23)))))
#ifdate=int(vdate[0])+(int(vdate[1])-1)/12.0
#if len(vdate)>2:
# fdate+=int((vdate[2])-1)/12.0/31.0
#return fdate < 2012.4759
def getopenscadversion():
import FreeCAD,os,subprocess,tempfile,time
osfilename = FreeCAD.ParamGet(\
"User parameter:BaseApp/Preferences/Mod/OpenSCAD").\
GetString('openscadexecutable')
if osfilename and os.path.isfile(osfilename):
p=subprocess.Popen([osfilename,'-v'],\
stdout=subprocess.PIPE,universal_newlines=True)
p.wait()
return p.stdout.read().strip()
def callopenscad(inputfilename,outputfilename=None,outputext='csg',keepname=False):
'''call the open scad binary
returns the filename of the result (or None),
please delete the file afterwards'''
import FreeCAD,os,subprocess,tempfile,time
osfilename = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/OpenSCAD").\
def check_output2(*args,**kwargs):
kwargs.update({'stdout':subprocess.PIPE})
p=subprocess.Popen(*args,**kwargs)
stdoutd,stderrd = p.communicate()
if p.returncode != 0:
raise OpenSCADError('%s\n' % stdoutd.strip())
#raise Exception,'stdout %s\n stderr%s' %(stdoutd,stderrd)
if stdoutd.strip():
FreeCAD.Console.PrintWarning(stdoutd+u'\n')
return stdoutd
osfilename = FreeCAD.ParamGet(\
"User parameter:BaseApp/Preferences/Mod/OpenSCAD").\
GetString('openscadexecutable')
if osfilename and os.path.isfile(osfilename):
if not outputfilename:
dir1=tempfile.gettempdir()
if keepname:
outputfilename=os.path.join(dir1,'%s.%s' % (os.path.split(inputfilename)[1].rsplit('.',1)[0],outputext))
outputfilename=os.path.join(dir1,'%s.%s' % (os.path.split(\
inputfilename)[1].rsplit('.',1)[0],outputext))
else:
outputfilename=os.path.join(dir1,'output-%d.%s' % (int(time.time()*10) % 1000000,outputext))
if subprocess.call([osfilename,'-o',outputfilename,inputfilename]) == 0:
return outputfilename
outputfilename=os.path.join(dir1,'output-%d.%s' % \
(int(time.time()*100) % 1000000,outputext))
check_output2([osfilename,'-o',outputfilename, inputfilename],\
stderr=subprocess.STDOUT)
return outputfilename
def callopenscadstring(scadstr,outputext='csg'):
'''create a tempfile and call the open scad binary
@@ -51,11 +100,13 @@ def callopenscadstring(scadstr,outputext='csg'):
please delete the file afterwards'''
import os,tempfile,time
dir1=tempfile.gettempdir()
inputfilename=os.path.join(dir1,'input-%d.scad' % (int(time.time()*10) % 1000000))
inputfilename=os.path.join(dir1,'input-%d.scad' % \
(int(time.time()*10) % 1000000))
inputfile = open(inputfilename,'w')
inputfile.write(scadstr)
inputfile.close()
outputfilename = callopenscad(inputfilename,outputext=outputext,keepname=True)
outputfilename = callopenscad(inputfilename,outputext=outputext,\
keepname=True)
os.unlink(inputfilename)
return outputfilename
+31
View File
@@ -1,3 +1,34 @@
#***************************************************************************
#* *
#* Copyright (c) 2012 Sebastian Hoogen <github@sebastianhoogen.de> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser 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 *
#* *
#***************************************************************************
__title__="FreeCAD OpenSCAD Workbench - 2D helper fuctions"
__author__ = "Sebastian Hoogen"
__url__ = ["http://free-cad.sourceforge.net"]
'''
This Script includes python functions to ifind out the most basic shape type
in a compound and to change the color of shapes according to thier shape type
'''
import FreeCAD
def shapedict(shapelst):
return dict([(shape.hashCode(),shape) for shape in shapelst])
+31
View File
@@ -1,3 +1,34 @@
#***************************************************************************
#* *
#* Copyright (c) 2012 Sebastian Hoogen <github@sebastianhoogen.de> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser 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 *
#* *
#***************************************************************************
__title__="FreeCAD OpenSCAD Workbench - expand placements and matrices fuctions"
__author__ = "Sebastian Hoogen"
__url__ = ["http://free-cad.sourceforge.net"]
'''
This Script includes python functions to shift all placements down the
feature tree to the most baisc objects
'''
import FreeCAD
from OpenSCADFeatures import *
from OpenSCADUtils import isspecialorthogonalpython,isspecialorthogonal
+20 -8
View File
@@ -73,10 +73,16 @@ def open(filename):
doc = FreeCAD.newDocument(docname)
if filename.lower().endswith('.scad'):
tmpfile=callopenscad(filename)
pathName = '' #https://github.com/openscad/openscad/issues/128
#pathName = os.getcwd() #https://github.com/openscad/openscad/issues/128
if workaroundforissue128needed():
pathName = '' #https://github.com/openscad/openscad/issues/128
#pathName = os.getcwd() #https://github.com/openscad/openscad/issues/128
else:
pathName = os.path.dirname(os.path.normpath(filename))
processcsg(tmpfile)
os.unlink(tmpfile)
try:
os.unlink(tmpfile)
except OSError:
pass
else:
pathName = os.path.dirname(os.path.normpath(filename))
processcsg(filename)
@@ -97,7 +103,10 @@ def insert(filename,docname):
pathName = '' #https://github.com/openscad/openscad/issues/128
#pathName = os.getcwd() #https://github.com/openscad/openscad/issues/128
processcsg(tmpfile)
os.unlink(tmpfile)
try:
os.unlink(tmpfile)
except OSError:
pass
else:
pathName = os.path.dirname(os.path.normpath(filename))
processcsg(filename)
@@ -416,12 +425,12 @@ def p_difference_action(p):
print "difference"
print len(p[5])
print p[5]
mycut = doc.addObject('Part::Cut',p[1])
mycut.Base = p[5][0]
if (len(p[5]) == 1 ): #single object
p[0] = p[5]
else:
# Cut using Fuse
mycut = doc.addObject('Part::Cut',p[1])
mycut.Base = p[5][0]
# Can only Cut two objects do we need to fuse extras
if (len(p[5]) > 2 ):
print "Need to Fuse Extra First"
@@ -803,7 +812,7 @@ def p_cylinder_action(p):
mycyl.Height = h
mycyl.Radius1 = r1
mycyl.Radius2 = r2
print "Center = ",center
print "Center = ",tocenter
if tocenter=='true' :
center(mycyl,0,0,h)
if False :
@@ -939,7 +948,10 @@ def p_polyhedron_action(p) :
f = make_face(v[int(i[0])],v[int(i[1])],v[int(i[2])])
faces_list.append(f)
shell=Part.makeShell(faces_list)
mypolyhed.Shape=Part.Solid(shell)
solid=Part.Solid(shell).removeSplitter()
if solid.Volume < 0:
solid.reverse()
mypolyhed.Shape=solid
p[0] = [mypolyhed]
def p_projection_action(p) :
+32
View File
@@ -1,3 +1,35 @@
# -----------------------------------------------------------------------------
# ply: __init__.py
#
# Copyright (C) 2001-2011,
# David M. Beazley (Dabeaz LLC)
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the David Beazley or Dabeaz LLC may be used to
# endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -----------------------------------------------------------------------------
# PLY package
# Author: David Beazley (dave@dabeaz.com)
+33
View File
@@ -1,3 +1,36 @@
# -----------------------------------------------------------------------------
# ply: setup.py
#
# Copyright (C) 2001-2011,
# David M. Beazley (Dabeaz LLC)
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# * Redistributions in binary form must reproduce the above copyright notice,
# this list of conditions and the following disclaimer in the documentation
# and/or other materials provided with the distribution.
# * Neither the name of the David Beazley or Dabeaz LLC may be used to
# endorse or promote products derived from this software without
# specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
# -----------------------------------------------------------------------------
try:
from setuptools import setup
except ImportError:
+7 -4
View File
@@ -659,14 +659,18 @@ def readfile(filename):
isopenscad = relname.lower().endswith('.scad')
if isopenscad:
tmpfile=callopenscad(filename)
lastimportpath = os.getcwd() #https://github.com/openscad/openscad/issues/128
if OpenSCADUtils.workaroundforissue128needed():
lastimportpath = os.getcwd() #https://github.com/openscad/openscad/issues/128
f = pythonopen(tmpfile)
else:
f = pythonopen(filename)
rootnode=parsenode(f.read())[0]
f.close()
if isopenscad:
os.unlink(tmpfile)
if isopenscad and tmpfile:
try:
os.unlink(tmpfile)
except OSError:
pass
return rootnode.flattengroups()
def open(filename):
@@ -687,7 +691,6 @@ def insert(filename,docname):
#doc.recompute()
import FreeCAD
global dxfcache
dxfcache = {}
+30
View File
@@ -1,3 +1,33 @@
#***************************************************************************
#* *
#* Copyright (c) 2012 Sebastian Hoogen <github@sebastianhoogen.de> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser 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 *
#* *
#***************************************************************************
__title__="FreeCAD OpenSCAD Workbench - replace object fuction"
__author__ = "Sebastian Hoogen"
__url__ = ["http://free-cad.sourceforge.net"]
'''
This fucntions allows to replace an object in the feature hierarchy
'''
def replaceobj(parent,oldchild,newchild):
for propname in parent.PropertiesList:
propvalue=parent.getPropertyByName(propname)
+4
View File
@@ -53,6 +53,7 @@ using namespace Part;
const int Part2DObject::H_Axis = -1;
const int Part2DObject::V_Axis = -2;
const int Part2DObject::N_Axis = -3;
PROPERTY_SOURCE(Part::Part2DObject, Part::Feature)
@@ -215,6 +216,9 @@ Base::Axis Part2DObject::getAxis(int axId) const
else if (axId == V_Axis) {
return Base::Axis(Base::Vector3d(0,0,0), Base::Vector3d(0,1,0));
}
else if (axId == N_Axis) {
return Base::Axis(Base::Vector3d(0,0,0), Base::Vector3d(0,0,1));
}
return Base::Axis();
}
+1
View File
@@ -92,6 +92,7 @@ public:
static const int H_Axis;
static const int V_Axis;
static const int N_Axis;
/** @name methods overide Feature */
//@{
+30 -46
View File
@@ -34,8 +34,9 @@
#include "FeatureLinearPattern.h"
#include <Mod/Part/App/TopoShape.h>
#include <Base/Axis.h>
#include <Mod/Part/App/TopoShape.h>
#include <Mod/Part/App/Part2DObject.h>
using namespace PartDesign;
@@ -47,7 +48,6 @@ PROPERTY_SOURCE(PartDesign::LinearPattern, PartDesign::Transformed)
LinearPattern::LinearPattern()
{
ADD_PROPERTY_TYPE(Direction,(0),"LinearPattern",(App::PropertyType)(App::Prop_None),"Direction");
ADD_PROPERTY(StdDirection,(""));
ADD_PROPERTY(Reversed,(0));
ADD_PROPERTY(Length,(100.0));
ADD_PROPERTY(Occurrences,(3));
@@ -56,7 +56,6 @@ LinearPattern::LinearPattern()
short LinearPattern::mustExecute() const
{
if (Direction.isTouched() ||
StdDirection.isTouched() ||
Reversed.isTouched() ||
Length.isTouched() ||
Occurrences.isTouched())
@@ -66,7 +65,6 @@ short LinearPattern::mustExecute() const
const std::list<gp_Trsf> LinearPattern::getTransformations(const std::vector<App::DocumentObject*>)
{
std::string stdDirection = StdDirection.getValue();
float distance = Length.getValue();
if (distance < Precision::Confusion())
throw Base::Exception("Pattern length too small");
@@ -75,37 +73,35 @@ const std::list<gp_Trsf> LinearPattern::getTransformations(const std::vector<App
throw Base::Exception("At least two occurrences required");
bool reversed = Reversed.getValue();
gp_Dir dir;
double offset = distance / (occurrences - 1);
if (!stdDirection.empty()) {
// Note: The placement code commented out below had the defect of working always on the
// absolute X,Y,Z direction, not on the relative coordinate system of the Body feature.
// It requires positionBySupport() to be called in Transformed::Execute() AFTER
// the call to getTransformations()
// New code thanks to logari81
if (stdDirection == "X") {
//dir = Base::Axis(Base::Vector3d(0,0,0), Base::Vector3d(1,0,0));
dir = gp_Dir(1,0,0);
} else if (stdDirection == "Y") {
//dir = Base::Axis(Base::Vector3d(0,0,0), Base::Vector3d(0,1,0));
dir = gp_Dir(0,1,0);
} else if(stdDirection == "Z") {
//dir = Base::Axis(Base::Vector3d(0,0,0), Base::Vector3d(0,0,1));
dir = gp_Dir(0,0,1);
} else {
throw Base::Exception("Invalid direction (must be X, Y or Z)");
}
} else {
App::DocumentObject* refObject = Direction.getValue();
if (refObject == NULL)
throw Base::Exception("No direction specified");
if (!refObject->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
throw Base::Exception("Direction reference must be edge or face of a feature");
std::vector<std::string> subStrings = Direction.getSubValues();
if (subStrings.empty() || subStrings[0].empty())
throw Base::Exception("No direction reference specified");
App::DocumentObject* refObject = Direction.getValue();
if (refObject == NULL)
throw Base::Exception("No direction reference specified");
if (!refObject->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
throw Base::Exception("Direction reference must be edge or face of a feature");
std::vector<std::string> subStrings = Direction.getSubValues();
if (subStrings.empty() || subStrings[0].empty())
throw Base::Exception("No direction reference specified");
gp_Dir dir;
if (refObject->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId())) {
Part::Part2DObject* refSketch = static_cast<Part::Part2DObject*>(refObject);
Base::Axis axis;
if (subStrings[0] == "H_Axis")
axis = refSketch->getAxis(Part::Part2DObject::H_Axis);
else if (subStrings[0] == "V_Axis")
axis = refSketch->getAxis(Part::Part2DObject::V_Axis);
else if (subStrings[0] == "N_Axis")
axis = refSketch->getAxis(Part::Part2DObject::N_Axis);
else if (subStrings[0].size() > 4 && subStrings[0].substr(0,4) == "Axis") {
int AxId = std::atoi(subStrings[0].substr(4,4000).c_str());
if (AxId >= 0 && AxId < refSketch->getAxisCount())
axis = refSketch->getAxis(AxId);
}
axis *= refSketch->Placement.getValue();
dir = gp_Dir(axis.getDirection().x, axis.getDirection().y, axis.getDirection().z);
} else {
Part::Feature* refFeature = static_cast<Part::Feature*>(refObject);
Part::TopoShape refShape = refFeature->Shape.getShape();
TopoDS_Shape ref = refShape.getSubShape(subStrings[0].c_str());
@@ -119,8 +115,6 @@ const std::list<gp_Trsf> LinearPattern::getTransformations(const std::vector<App
throw Base::Exception("Direction face must be planar");
dir = adapt.Plane().Axis().Direction();
//gp_Dir d = adapt.Plane().Axis().Direction();
//dir = Base::Axis(Base::Vector3d(0,0,0), Base::Vector3d(d.X(), d.Y(), d.Z()));
} else if (ref.ShapeType() == TopAbs_EDGE) {
TopoDS_Edge refEdge = TopoDS::Edge(ref);
if (refEdge.IsNull())
@@ -129,24 +123,14 @@ const std::list<gp_Trsf> LinearPattern::getTransformations(const std::vector<App
if (adapt.GetType() != GeomAbs_Line)
throw Base::Exception("Direction edge must be a straight line");
//gp_Dir d = adapt.Line().Direction();
//dir = Base::Axis(Base::Vector3d(0,0,0), Base::Vector3d(d.X(), d.Y(), d.Z()));
dir = adapt.Line().Direction();
} else {
throw Base::Exception("Direction reference must be edge or face");
}
TopLoc_Location invObjLoc = this->getLocation().Inverted();
dir.Transform(invObjLoc.Transformation());
}
TopLoc_Location invObjLoc = this->getLocation().Inverted();
dir.Transform(invObjLoc.Transformation());
// get the support placement
// TODO: Check for NULL pointer
/*Part::Feature* supportFeature = static_cast<Part::Feature*>(originals.front());
if (supportFeature == NULL)
throw Base::Exception("Cannot work on invalid support shape");
Base::Placement supportPlacement = supportFeature->Placement.getValue();
dir *= supportPlacement;
gp_Vec direction(dir.getDirection().x, dir.getDirection().y, dir.getDirection().z);*/
gp_Vec direction(dir.X(), dir.Y(), dir.Z());
if (reversed)
@@ -39,7 +39,6 @@ public:
LinearPattern();
App::PropertyLinkSub Direction;
App::PropertyString StdDirection;
App::PropertyBool Reversed;
App::PropertyFloat Length;
App::PropertyInteger Occurrences;
@@ -58,8 +57,6 @@ public:
* Returns a list of (Occurrences - 1) transformations since the first, untransformed instance
* is not counted. Each transformation will move the shape it is applied to by the distance
* (Length / (Occurrences - 1)) so that the transformations will cover the total Length.
* If StdDirection is "X", "Y" or "Z" then the transformation direction will be parallel to the
* corresponding axis
* If Direction contains a feature and a face name, then the transformation direction will be
* the normal of the given face, which must be planar. If it contains an edge name, then the
* transformation direction will be parallel to the given edge, which must be linear
+34 -39
View File
@@ -33,6 +33,7 @@
#include "FeatureMirrored.h"
#include <Mod/Part/App/TopoShape.h>
#include <Mod/Part/App/Part2DObject.h>
using namespace PartDesign;
@@ -44,45 +45,47 @@ PROPERTY_SOURCE(PartDesign::Mirrored, PartDesign::Transformed)
Mirrored::Mirrored()
{
ADD_PROPERTY_TYPE(MirrorPlane,(0),"Mirrored",(App::PropertyType)(App::Prop_None),"Mirror plane");
ADD_PROPERTY(StdMirrorPlane,(""));
}
short Mirrored::mustExecute() const
{
if (MirrorPlane.isTouched() ||
StdMirrorPlane.isTouched())
if (MirrorPlane.isTouched())
return 1;
return Transformed::mustExecute();
}
const std::list<gp_Trsf> Mirrored::getTransformations(const std::vector<App::DocumentObject*>)
{
App::DocumentObject* ref = MirrorPlane.getValue();
App::DocumentObject* refObject = MirrorPlane.getValue();
if (refObject == NULL)
throw Base::Exception("No mirror plane reference specified");
if (!refObject->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
throw Base::Exception("Mirror plane reference must be face of a feature");
std::vector<std::string> subStrings = MirrorPlane.getSubValues();
std::string stdPlane = StdMirrorPlane.getValue();
if (subStrings.empty() || subStrings[0].empty())
throw Base::Exception("No mirror plane reference specified");
gp_Pnt p;
gp_Dir d;
if (!stdPlane.empty()) {
p = gp_Pnt(0,0,0);
if (stdPlane == "XY") {
d = gp_Dir(0,0,1);
} else if (stdPlane == "XZ") {
d = gp_Dir(0,1,0);
} else if(stdPlane == "YZ") {
d = gp_Dir(1,0,0);
} else {
throw Base::Exception("Invalid mirror plane (must be XY, XZ or YZ)");
gp_Pnt axbase;
gp_Dir axdir;
if (refObject->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId())) {
Part::Part2DObject* refSketch = static_cast<Part::Part2DObject*>(refObject);
Base::Axis axis;
if (subStrings[0] == "H_Axis")
axis = refSketch->getAxis(Part::Part2DObject::V_Axis);
else if (subStrings[0] == "V_Axis")
axis = refSketch->getAxis(Part::Part2DObject::H_Axis);
else if (subStrings[0] == "")
axis = refSketch->getAxis(Part::Part2DObject::N_Axis);
else if (subStrings[0].size() > 4 && subStrings[0].substr(0,4) == "Axis") {
int AxId = std::atoi(subStrings[0].substr(4,4000).c_str());
if (AxId >= 0 && AxId < refSketch->getAxisCount())
axis = refSketch->getAxis(AxId);
}
axis *= refSketch->Placement.getValue();
axbase = gp_Pnt(axis.getBase().x, axis.getBase().y, axis.getBase().z);
axdir = gp_Dir(axis.getDirection().x, axis.getDirection().y, axis.getDirection().z);
} else {
if (ref == NULL)
throw Base::Exception("No mirror plane selected");
if (!ref->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
throw Base::Exception("Mirror plane must be face of a feature");
Part::TopoShape baseShape = static_cast<Part::Feature*>(ref)->Shape.getShape();
if (subStrings.empty() || subStrings[0].empty())
throw Base::Exception("No mirror plane defined");
Part::TopoShape baseShape = static_cast<Part::Feature*>(refObject)->Shape.getShape();
// TODO: Check for multiple mirror planes?
TopoDS_Face face = TopoDS::Face(baseShape.getSubShape(subStrings[0].c_str()));
@@ -92,22 +95,14 @@ const std::list<gp_Trsf> Mirrored::getTransformations(const std::vector<App::Doc
if (adapt.GetType() != GeomAbs_Plane)
throw Base::Exception("Mirror face must be planar");
p = getPointFromFace(face);
d = adapt.Plane().Axis().Direction();
TopLoc_Location invObjLoc = this->getLocation().Inverted();
p.Transform(invObjLoc.Transformation());
d.Transform(invObjLoc.Transformation());
axbase = getPointFromFace(face);
axdir = adapt.Plane().Axis().Direction();
}
TopLoc_Location invObjLoc = this->getLocation().Inverted();
axbase.Transform(invObjLoc.Transformation());
axdir.Transform(invObjLoc.Transformation());
// get the support placement
// TODO: Check for NULL pointer
/*Part::Feature* supportFeature = static_cast<Part::Feature*>(originals.front());
if (supportFeature == NULL)
throw Base::Exception("Cannot work on invalid support shape");
Base::Placement supportPlacement = supportFeature->Placement.getValue();
ax *= supportPlacement;
gp_Ax2 mirrorAxis(gp_Pnt(ax.getBase().x, ax.getBase().y, ax.getBase().z), gp_Dir(ax.getDirection().x, ax.getDirection().y, ax.getDirection().z));*/
gp_Ax2 mirrorAxis(p, d);
gp_Ax2 mirrorAxis(axbase, axdir);
std::list<gp_Trsf> transformations;
gp_Trsf trans;
-2
View File
@@ -39,7 +39,6 @@ public:
Mirrored();
App::PropertyLinkSub MirrorPlane;
App::PropertyString StdMirrorPlane;
/** @name methods override feature */
//@{
@@ -54,7 +53,6 @@ public:
/** Create transformations
* Returns a list containing one transformation since the first, untransformed instance
* is not counted. The transformation will mirror the shape it is applied to on a plane
* If StdMirrorPlane is "XY", "YZ" or "YZ" then the mirror plane will the corresponding plane
* If MirrorPlane contains a feature and an face name, then the mirror plane will be
* the the given face, which must be planar
*/
+30 -38
View File
@@ -32,9 +32,10 @@
#include "FeaturePolarPattern.h"
#include <Base/Tools.h>
#include <Base/Axis.h>
#include <Base/Tools.h>
#include <Mod/Part/App/TopoShape.h>
#include <Mod/Part/App/Part2DObject.h>
using namespace PartDesign;
@@ -46,7 +47,6 @@ PROPERTY_SOURCE(PartDesign::PolarPattern, PartDesign::Transformed)
PolarPattern::PolarPattern()
{
ADD_PROPERTY_TYPE(Axis,(0),"PolarPattern",(App::PropertyType)(App::Prop_None),"Direction");
ADD_PROPERTY(StdAxis,(""));
ADD_PROPERTY(Reversed,(0));
ADD_PROPERTY(Angle,(360.0));
ADD_PROPERTY(Occurrences,(3));
@@ -55,7 +55,6 @@ PolarPattern::PolarPattern()
short PolarPattern::mustExecute() const
{
if (Axis.isTouched() ||
StdAxis.isTouched() ||
Reversed.isTouched() ||
Angle.isTouched() ||
Occurrences.isTouched())
@@ -65,7 +64,6 @@ short PolarPattern::mustExecute() const
const std::list<gp_Trsf> PolarPattern::getTransformations(const std::vector<App::DocumentObject*>)
{
std::string stdAxis = StdAxis.getValue();
float angle = Angle.getValue();
if (angle < Precision::Confusion())
throw Base::Exception("Pattern angle too small");
@@ -80,32 +78,35 @@ const std::list<gp_Trsf> PolarPattern::getTransformations(const std::vector<App:
else
offset = Base::toRadians<double>(angle) / (occurrences - 1);
App::DocumentObject* refObject = Axis.getValue();
if (refObject == NULL)
throw Base::Exception("No axis reference specified");
if (!refObject->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
throw Base::Exception("Axis reference must be edge of a feature");
std::vector<std::string> subStrings = Axis.getSubValues();
if (subStrings.empty() || subStrings[0].empty())
throw Base::Exception("No axis reference specified");
gp_Pnt axbase;
gp_Dir axdir;
if (!stdAxis.empty()) {
axbase = gp_Pnt(0,0,0);
if (stdAxis == "X") {
axdir = gp_Dir(1,0,0);
//ax = Base::Axis(Base::Vector3d(0,0,0), Base::Vector3d(1,0,0));
} else if (stdAxis == "Y") {
axdir = gp_Dir(0,1,0);
//ax = Base::Axis(Base::Vector3d(0,0,0), Base::Vector3d(0,1,0));
} else if(stdAxis == "Z") {
axdir = gp_Dir(0,0,1);
//ax = Base::Axis(Base::Vector3d(0,0,0), Base::Vector3d(0,0,1));
} else {
throw Base::Exception("Invalid axis (must be X, Y or Z)");
if (refObject->getTypeId().isDerivedFrom(Part::Part2DObject::getClassTypeId())) {
Part::Part2DObject* refSketch = static_cast<Part::Part2DObject*>(refObject);
Base::Axis axis;
if (subStrings[0] == "H_Axis")
axis = refSketch->getAxis(Part::Part2DObject::H_Axis);
else if (subStrings[0] == "V_Axis")
axis = refSketch->getAxis(Part::Part2DObject::V_Axis);
else if (subStrings[0] == "N_Axis")
axis = refSketch->getAxis(Part::Part2DObject::N_Axis);
else if (subStrings[0].size() > 4 && subStrings[0].substr(0,4) == "Axis") {
int AxId = std::atoi(subStrings[0].substr(4,4000).c_str());
if (AxId >= 0 && AxId < refSketch->getAxisCount())
axis = refSketch->getAxis(AxId);
}
axis *= refSketch->Placement.getValue();
axbase = gp_Pnt(axis.getBase().x, axis.getBase().y, axis.getBase().z);
axdir = gp_Dir(axis.getDirection().x, axis.getDirection().y, axis.getDirection().z);
} else {
App::DocumentObject* refObject = Axis.getValue();
if (refObject == NULL)
throw Base::Exception("No axis specified");
if (!refObject->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
throw Base::Exception("Axis reference must be edge of a feature");
std::vector<std::string> subStrings = Axis.getSubValues();
if (subStrings.empty() || subStrings[0].empty())
throw Base::Exception("No axis reference specified");
Part::Feature* refFeature = static_cast<Part::Feature*>(refObject);
Part::TopoShape refShape = refFeature->Shape.getShape();
TopoDS_Shape ref = refShape.getSubShape(subStrings[0].c_str());
@@ -123,20 +124,11 @@ const std::list<gp_Trsf> PolarPattern::getTransformations(const std::vector<App:
} else {
throw Base::Exception("Axis reference must be an edge");
}
TopLoc_Location invObjLoc = this->getLocation().Inverted();
axbase.Transform(invObjLoc.Transformation());
axdir.Transform(invObjLoc.Transformation());
}
TopLoc_Location invObjLoc = this->getLocation().Inverted();
axbase.Transform(invObjLoc.Transformation());
axdir.Transform(invObjLoc.Transformation());
// get the support placement
// TODO: Check for NULL pointer
/*Part::Feature* supportFeature = static_cast<Part::Feature*>(originals.front());
if (supportFeature == NULL)
throw Base::Exception("Cannot work on invalid support shape");
Base::Placement supportPlacement = supportFeature->Placement.getValue();
ax *= supportPlacement;
gp_Ax2 axis(gp_Pnt(ax.getBase().x, ax.getBase().y, ax.getBase().z), gp_Dir(ax.getDirection().x, ax.getDirection().y, ax.getDirection().z));*/
gp_Ax2 axis(axbase, axdir);
if (reversed)
@@ -39,7 +39,6 @@ public:
PolarPattern();
App::PropertyLinkSub Axis;
App::PropertyString StdAxis;
App::PropertyBool Reversed;
App::PropertyFloat Angle;
App::PropertyInteger Occurrences;
@@ -60,7 +59,6 @@ public:
* (Angle / (Occurrences - 1)) so that the transformations will cover the total Angle. The only
* exception is Angle = 360 degrees in which case the transformation angle will be
* (Angle / Occurrences) so that the last transformed shape is not identical with the original shape
* If StdAxis is "X", "Y" or "Z" then the transformation axis will the corresponding axis
* If Axis contains a feature and an edge name, then the transformation axis will be
* the the given edge, which must be linear
* If Reversed is true, the direction of rotation will be opposite
@@ -65,7 +65,6 @@
#include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
#include "FeatureSketchBased.h"
#include <Mod/Part/App/Part2DObject.h>
using namespace PartDesign;
@@ -198,6 +197,8 @@ const TopoDS_Face SketchBased::getSupportFace() const {
Part::Feature* SketchBased::getSupport() const {
// get the support of the Sketch if any
if (!Sketch.getValue())
return 0;
App::DocumentObject* SupportLink = static_cast<Part::Part2DObject*>(Sketch.getValue())->Support.getValue();
Part::Feature* SupportObject = NULL;
if (SupportLink && SupportLink->getTypeId().isDerivedFrom(Part::Feature::getClassTypeId()))
@@ -80,6 +80,15 @@ App::DocumentObject* Transformed::getSupportObject() const
return NULL;
}
App::DocumentObject* Transformed::getSketchObject() const
{
std::vector<DocumentObject*> originals = Originals.getValues();
if (!originals.empty() && originals.front()->getTypeId().isDerivedFrom(PartDesign::SketchBased::getClassTypeId()))
return (static_cast<PartDesign::SketchBased*>(originals.front()))->getVerifiedSketch();
else
return NULL;
}
short Transformed::mustExecute() const
{
if (Originals.isTouched())
@@ -52,6 +52,9 @@ public:
/// Return first original, which serves as "Support" until Body feature becomes functional
App::DocumentObject* getSupportObject() const;
/// Return the sketch of the first original
App::DocumentObject* getSketchObject() const;
/// Get the list of transformations describing the members of the pattern
// Note: Only the Scaled feature requires the originals
virtual const std::list<gp_Trsf> getTransformations(const std::vector<App::DocumentObject*> originals) {
+12 -3
View File
@@ -895,7 +895,10 @@ void CmdPartDesignMirrored::activated(int iMsg)
// Exception (Thu Sep 6 11:52:01 2012): 'App.Document' object has no attribute 'Mirrored'
updateActive(); // Helps to ensure that the object already exists when the next command comes up
doCommand(Doc,str.str().c_str());
doCommand(Doc,"App.activeDocument().%s.StdMirrorPlane = \"XY\"", FeatName.c_str());
Part::Part2DObject *sketch = (static_cast<PartDesign::SketchBased*>(features.front()))->getVerifiedSketch();
if (sketch)
doCommand(Doc,"App.activeDocument().%s.MirrorPlane = (App.activeDocument().%s, [\"V_Axis\"])",
FeatName.c_str(), sketch->getNameInDocument());
for (std::vector<std::string>::iterator it = tempSelNames.begin(); it != tempSelNames.end(); ++it)
doCommand(Gui,"Gui.activeDocument().%s.Visibility=False",it->c_str());
@@ -967,7 +970,10 @@ void CmdPartDesignLinearPattern::activated(int iMsg)
doCommand(Doc,"App.activeDocument().addObject(\"PartDesign::LinearPattern\",\"%s\")",FeatName.c_str());
updateActive();
doCommand(Doc,str.str().c_str());
doCommand(Doc,"App.activeDocument().%s.StdDirection = \"X\"", FeatName.c_str());
Part::Part2DObject *sketch = (static_cast<PartDesign::SketchBased*>(features.front()))->getVerifiedSketch();
if (sketch)
doCommand(Doc,"App.activeDocument().%s.Direction = (App.activeDocument().%s, [\"H_Axis\"])",
FeatName.c_str(), sketch->getNameInDocument());
doCommand(Doc,"App.activeDocument().%s.Length = 100", FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.Occurrences = 2", FeatName.c_str());
for (std::vector<std::string>::iterator it = tempSelNames.begin(); it != tempSelNames.end(); ++it)
@@ -1041,7 +1047,10 @@ void CmdPartDesignPolarPattern::activated(int iMsg)
doCommand(Doc,"App.activeDocument().addObject(\"PartDesign::PolarPattern\",\"%s\")",FeatName.c_str());
updateActive();
doCommand(Doc,str.str().c_str());
doCommand(Doc,"App.activeDocument().%s.StdAxis = \"X\"", FeatName.c_str());
Part::Part2DObject *sketch = (static_cast<PartDesign::SketchBased*>(features.front()))->getVerifiedSketch();
if (sketch)
doCommand(Doc,"App.activeDocument().%s.Axis = (App.activeDocument().%s, [\"N_Axis\"])",
FeatName.c_str(), sketch->getNameInDocument());
doCommand(Doc,"App.activeDocument().%s.Angle = 360", FeatName.c_str());
doCommand(Doc,"App.activeDocument().%s.Occurrences = 2", FeatName.c_str());
for (std::vector<std::string>::iterator it = tempSelNames.begin(); it != tempSelNames.end(); ++it)
@@ -93,14 +93,14 @@ TaskLinearPatternParameters::TaskLinearPatternParameters(TaskMultiTransformParam
void TaskLinearPatternParameters::setupUI()
{
connect(ui->comboDirection, SIGNAL(activated(int)),
this, SLOT(onDirectionChanged(int)));
connect(ui->checkReverse, SIGNAL(toggled(bool)),
this, SLOT(onCheckReverse(bool)));
connect(ui->spinLength, SIGNAL(valueChanged(double)),
this, SLOT(onLength(double)));
connect(ui->spinOccurrences, SIGNAL(valueChanged(int)),
this, SLOT(onOccurrences(int)));
connect(ui->buttonReference, SIGNAL(toggled(bool)),
this, SLOT(onButtonReference(bool)));
connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)),
this, SLOT(onUpdateView(bool)));
@@ -119,14 +119,10 @@ void TaskLinearPatternParameters::setupUI()
}
// ---------------------
//ui->buttonX->setEnabled(true);
//ui->buttonY->setEnabled(true);
//ui->buttonZ->setEnabled(true);
ui->comboDirection->setEnabled(true);
ui->checkReverse->setEnabled(true);
ui->spinLength->setEnabled(true);
ui->spinOccurrences->setEnabled(true);
ui->buttonReference->setEnabled(true);
ui->lineReference->setEnabled(false); // This is never enabled since it is for optical feed-back only
updateUI();
}
@@ -140,35 +136,31 @@ void TaskLinearPatternParameters::updateUI()
App::DocumentObject* directionFeature = pcLinearPattern->Direction.getValue();
std::vector<std::string> directions = pcLinearPattern->Direction.getSubValues();
std::string stdDirection = pcLinearPattern->StdDirection.getValue();
bool reverse = pcLinearPattern->Reversed.getValue();
double length = pcLinearPattern->Length.getValue();
unsigned occurrences = pcLinearPattern->Occurrences.getValue();
ui->buttonReference->setChecked(referenceSelectionMode);
if (!stdDirection.empty())
{
//ui->buttonX->setAutoExclusive(true);
//ui->buttonY->setAutoExclusive(true);
//ui->buttonZ->setAutoExclusive(true);
//ui->buttonX->setChecked(stdDirection == "X");
//ui->buttonY->setChecked(stdDirection == "Y");
//ui->buttonZ->setChecked(stdDirection == "Z");
ui->lineReference->setText(tr(""));
} else if (directionFeature != NULL && !directions.empty()) {
//ui->buttonX->setAutoExclusive(false);
//ui->buttonY->setAutoExclusive(false);
//ui->buttonZ->setAutoExclusive(false);
//ui->buttonX->setChecked(false);
//ui->buttonY->setChecked(false);
//ui->buttonZ->setChecked(false);
ui->lineReference->setText(QString::fromAscii(directions.front().c_str()));
for (int i=ui->comboDirection->count()-1; i >= 2; i--)
ui->comboDirection->removeItem(i);
if (directionFeature != NULL && !directions.empty()) {
if (directions.front() == "H_Axis")
ui->comboDirection->setCurrentIndex(0);
else if (directions.front() == "V_Axis")
ui->comboDirection->setCurrentIndex(1);
else if (directionFeature != NULL && !directions.empty()) {
ui->comboDirection->addItem(QString::fromAscii(directions.front().c_str()));
ui->comboDirection->setCurrentIndex(2);
}
} else {
// Error message?
ui->lineReference->setText(tr(""));
}
if (referenceSelectionMode)
ui->lineReference->setText(tr("Select an edge or a face"));
if (referenceSelectionMode) {
ui->comboDirection->addItem(tr("Select an edge or a face"));
ui->comboDirection->setCurrentIndex(ui->comboDirection->count() - 1);
} else
ui->comboDirection->addItem(tr("Select reference..."));
// Note: These three lines would trigger onLength(), on Occurrences() and another updateUI() if we
// didn't check for blockUpdate
@@ -201,31 +193,22 @@ void TaskLinearPatternParameters::onSelectionChanged(const Gui::SelectionChanges
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
std::vector<std::string> directions(1,subName);
pcLinearPattern->Direction.setValue(getSupportObject(), directions);
pcLinearPattern->StdDirection.setValue("");
recomputeFeature();
updateUI();
}
else {
ui->buttonReference->setChecked(referenceSelectionMode);
ui->lineReference->setText(QString::fromAscii(subName.c_str()));
for (int i=ui->comboDirection->count()-1; i >= 2; i--)
ui->comboDirection->removeItem(i);
ui->comboDirection->addItem(QString::fromAscii(subName.c_str()));
ui->comboDirection->setCurrentIndex(2);
ui->comboDirection->addItem(tr("Select reference..."));
}
}
}
}
//void TaskLinearPatternParameters::onButtonX() {
// onStdDirection("X");
//}
//
//void TaskLinearPatternParameters::onButtonY() {
// onStdDirection("Y");
//}
//
//void TaskLinearPatternParameters::onButtonZ() {
// onStdDirection("Z");
//}
void TaskLinearPatternParameters::onCheckReverse(const bool on) {
if (blockUpdate)
return;
@@ -259,30 +242,32 @@ void TaskLinearPatternParameters::onOccurrences(const int n) {
recomputeFeature();
}
void TaskLinearPatternParameters::onStdDirection(const std::string& dir) {
void TaskLinearPatternParameters::onDirectionChanged(int num) {
if (blockUpdate)
return;
PartDesign::LinearPattern* pcLinearPattern = static_cast<PartDesign::LinearPattern*>(getObject());
pcLinearPattern->StdDirection.setValue(dir.c_str());
pcLinearPattern->Direction.setValue(NULL);
exitSelectionMode();
updateUI();
recomputeFeature();
}
void TaskLinearPatternParameters::onButtonReference(bool checked)
{
if (checked ) {
if (num == 0) {
pcLinearPattern->Direction.setValue(getSketchObject(), std::vector<std::string>(1,"H_Axis"));
exitSelectionMode();
}
else if (num == 1) {
pcLinearPattern->Direction.setValue(getSketchObject(), std::vector<std::string>(1,"V_Axis"));
exitSelectionMode();
}
else if (num == ui->comboDirection->count() - 1) {
// enter reference selection mode
hideObject();
showOriginals();
referenceSelectionMode = true;
Gui::Selection().clearSelection();
addReferenceSelectionGate(true, true);
} else {
exitSelectionMode();
}
else if (num == 2)
exitSelectionMode();
updateUI();
recomputeFeature();
}
void TaskLinearPatternParameters::onUpdateView(bool on)
@@ -295,16 +280,13 @@ void TaskLinearPatternParameters::onUpdateView(bool on)
std::string direction = getDirection();
if (!direction.empty()) {
std::vector<std::string> directions(1,direction);
pcLinearPattern->Direction.setValue(getSupportObject(), directions);
if (direction == "H_Axis" || direction == "V_Axis")
pcLinearPattern->Direction.setValue(getSketchObject(), directions);
else
pcLinearPattern->Direction.setValue(getSupportObject(), directions);
} else
pcLinearPattern->Direction.setValue(NULL);
std::string stdDirection = getStdDirection();
if (!stdDirection.empty())
pcLinearPattern->StdDirection.setValue(stdDirection.c_str());
else
pcLinearPattern->StdDirection.setValue(NULL);
pcLinearPattern->Reversed.setValue(getReverse());
pcLinearPattern->Length.setValue(getLength());
pcLinearPattern->Occurrences.setValue(getOccurrences());
@@ -313,20 +295,15 @@ void TaskLinearPatternParameters::onUpdateView(bool on)
}
}
const std::string TaskLinearPatternParameters::getStdDirection(void) const
{
//if (ui->buttonX->isChecked())
// return std::string("X");
//else if (ui->buttonY->isChecked())
// return std::string("Y");
//else if (ui->buttonZ->isChecked())
// return std::string("Z");
return std::string("");
}
const std::string TaskLinearPatternParameters::getDirection(void) const
{
return ui->lineReference->text().toStdString();
{
if (ui->comboDirection->currentIndex() == 0)
return "H_Axis";
else if (ui->comboDirection->currentIndex() == 1)
return "V_Axis";
else if (ui->comboDirection->count() > 3 && ui->comboDirection->currentIndex() == 2)
return ui->comboDirection->currentText().toStdString();
return std::string("");
}
const bool TaskLinearPatternParameters::getReverse(void) const
@@ -388,13 +365,14 @@ bool TaskDlgLinearPatternParameters::accept()
std::string direction = linearpatternParameter->getDirection();
if (!direction.empty()) {
QString buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])");
buf = buf.arg(QString::fromUtf8(linearpatternParameter->getSupportObject()->getNameInDocument()));
if (direction == "H_Axis" || direction == "V_Axis")
buf = buf.arg(QString::fromUtf8(linearpatternParameter->getSketchObject()->getNameInDocument()));
else
buf = buf.arg(QString::fromUtf8(linearpatternParameter->getSupportObject()->getNameInDocument()));
buf = buf.arg(QString::fromUtf8(direction.c_str()));
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Direction = %s", name.c_str(), buf.toStdString().c_str());
} else
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Direction = None", name.c_str());
std::string stdDirection = linearpatternParameter->getStdDirection();
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.StdDirection = \"%s\"",name.c_str(),stdDirection.c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %u",name.c_str(),linearpatternParameter->getReverse());
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Length = %f",name.c_str(),linearpatternParameter->getLength());
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Occurrences = %u",name.c_str(),linearpatternParameter->getOccurrences());
@@ -56,21 +56,16 @@ public:
TaskLinearPatternParameters(TaskMultiTransformParameters *parentTask, QLayout *layout);
virtual ~TaskLinearPatternParameters();
const std::string getStdDirection(void) const;
const std::string getDirection(void) const;
const bool getReverse(void) const;
const double getLength(void) const;
const unsigned getOccurrences(void) const;
private Q_SLOTS:
void onStdDirection(const std::string& dir);
//void onButtonX();
//void onButtonY();
//void onButtonZ();
void onDirectionChanged(int num);
void onCheckReverse(const bool on);
void onLength(const double l);
void onOccurrences(const int n);
void onButtonReference(const bool checked);
virtual void onUpdateView(bool);
protected:
@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
<width>225</width>
<width>260</width>
<height>402</height>
</rect>
</property>
@@ -31,17 +31,30 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QToolButton" name="buttonReference">
<widget class="QLabel" name="labelDirection">
<property name="text">
<string>Direction</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineReference"/>
<widget class="QComboBox" name="comboDirection">
<item>
<property name="text">
<string>Horizontal sketch axis</string>
</property>
</item>
<item>
<property name="text">
<string>Vertical sketch axis</string>
</property>
</item>
<item>
<property name="text">
<string>Select reference...</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
@@ -69,9 +82,6 @@
<property name="maximum">
<double>999999.000000000000000</double>
</property>
<property name="singleStep">
<double>5.000000000000000</double>
</property>
<property name="value">
<double>100.000000000000000</double>
</property>
@@ -93,14 +93,8 @@ TaskMirroredParameters::TaskMirroredParameters(TaskMultiTransformParameters *par
void TaskMirroredParameters::setupUI()
{
connect(ui->buttonXY, SIGNAL(pressed()),
this, SLOT(onButtonXY()));
connect(ui->buttonXZ, SIGNAL(pressed()),
this, SLOT(onButtonXZ()));
connect(ui->buttonYZ, SIGNAL(pressed()),
this, SLOT(onButtonYZ()));
connect(ui->buttonReference, SIGNAL(toggled(bool)),
this, SLOT(onButtonReference(bool)));
connect(ui->comboPlane, SIGNAL(activated(int)),
this, SLOT(onPlaneChanged(int)));
connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)),
this, SLOT(onUpdateView(bool)));
@@ -119,11 +113,7 @@ void TaskMirroredParameters::setupUI()
}
// ---------------------
ui->buttonXY->setEnabled(true);
ui->buttonXZ->setEnabled(true);
ui->buttonYZ->setEnabled(true);
ui->buttonReference->setEnabled(true);
ui->lineReference->setEnabled(false); // This is never enabled since it is for optical feed-back only
ui->comboPlane->setEnabled(true);
updateUI();
}
@@ -132,35 +122,33 @@ void TaskMirroredParameters::updateUI()
if (blockUpdate)
return;
blockUpdate = true;
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
App::DocumentObject* mirrorPlaneFeature = pcMirrored->MirrorPlane.getValue();
std::vector<std::string> mirrorPlanes = pcMirrored->MirrorPlane.getSubValues();
std::string stdMirrorPlane = pcMirrored->StdMirrorPlane.getValue();
for (int i=ui->comboPlane->count()-1; i >= 2; i--)
ui->comboPlane->removeItem(i);
ui->buttonReference->setChecked(referenceSelectionMode);
if (!stdMirrorPlane.empty())
{
ui->buttonXY->setAutoExclusive(true);
ui->buttonXZ->setAutoExclusive(true);
ui->buttonYZ->setAutoExclusive(true);
ui->buttonXY->setChecked(stdMirrorPlane == "XY");
ui->buttonXZ->setChecked(stdMirrorPlane == "XZ");
ui->buttonYZ->setChecked(stdMirrorPlane == "YZ");
ui->lineReference->setText(tr(""));
} else if (mirrorPlaneFeature != NULL && !mirrorPlanes.empty()) {
ui->buttonXY->setAutoExclusive(false);
ui->buttonXZ->setAutoExclusive(false);
ui->buttonYZ->setAutoExclusive(false);
ui->buttonXY->setChecked(false);
ui->buttonXZ->setChecked(false);
ui->buttonYZ->setChecked(false);
ui->lineReference->setText(QString::fromAscii(mirrorPlanes.front().c_str()));
if (mirrorPlaneFeature != NULL && !mirrorPlanes.empty()) {
if (mirrorPlanes.front() == "H_Axis")
ui->comboPlane->setCurrentIndex(0);
else if (mirrorPlanes.front() == "V_Axis")
ui->comboPlane->setCurrentIndex(1);
else if (mirrorPlaneFeature != NULL && !mirrorPlanes.empty()) {
ui->comboPlane->addItem(QString::fromAscii(mirrorPlanes.front().c_str()));
ui->comboPlane->setCurrentIndex(2);
}
} else {
// Error message?
ui->lineReference->setText(tr(""));
}
if (referenceSelectionMode)
ui->lineReference->setText(tr("Select a plane"));
if (referenceSelectionMode) {
ui->comboPlane->addItem(tr("Select a face"));
ui->comboPlane->setCurrentIndex(ui->comboPlane->count() - 1);
} else
ui->comboPlane->addItem(tr("Select reference..."));
blockUpdate = false;
}
@@ -186,55 +174,48 @@ void TaskMirroredParameters::onSelectionChanged(const Gui::SelectionChanges& msg
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
std::vector<std::string> mirrorPlanes(1,subName);
pcMirrored->MirrorPlane.setValue(getSupportObject(), mirrorPlanes);
pcMirrored->StdMirrorPlane.setValue("");
recomputeFeature();
updateUI();
}
else {
ui->buttonReference->setChecked(referenceSelectionMode);
ui->lineReference->setText(QString::fromAscii(subName.c_str()));
for (int i=ui->comboPlane->count()-1; i >= 2; i--)
ui->comboPlane->removeItem(i);
ui->comboPlane->addItem(QString::fromAscii(subName.c_str()));
ui->comboPlane->setCurrentIndex(2);
ui->comboPlane->addItem(tr("Select reference..."));
}
}
}
}
void TaskMirroredParameters::onStdMirrorPlane(const std::string &plane) {
void TaskMirroredParameters::onPlaneChanged(int num) {
if (blockUpdate)
return;
PartDesign::Mirrored* pcMirrored = static_cast<PartDesign::Mirrored*>(getObject());
pcMirrored->StdMirrorPlane.setValue(plane.c_str());
pcMirrored->MirrorPlane.setValue(NULL);
exitSelectionMode();
updateUI();
recomputeFeature();
}
void TaskMirroredParameters::onButtonXY() {
onStdMirrorPlane("XY");
}
void TaskMirroredParameters::onButtonXZ() {
onStdMirrorPlane("XZ");
}
void TaskMirroredParameters::onButtonYZ() {
onStdMirrorPlane("YZ");
}
void TaskMirroredParameters::onButtonReference(bool checked)
{
if (checked ) {
if (num == 0) {
pcMirrored->MirrorPlane.setValue(getSketchObject(), std::vector<std::string>(1,"H_Axis"));
exitSelectionMode();
}
else if (num == 1) {
pcMirrored->MirrorPlane.setValue(getSketchObject(), std::vector<std::string>(1,"V_Axis"));
exitSelectionMode();
}
else if (num == ui->comboPlane->count() - 1) {
// enter reference selection mode
hideObject();
showOriginals();
referenceSelectionMode = true;
Gui::Selection().clearSelection();
addReferenceSelectionGate(false, true);
} else {
exitSelectionMode();
}
else if (num == 2)
exitSelectionMode();
updateUI();
recomputeFeature();
}
void TaskMirroredParameters::onUpdateView(bool on)
@@ -247,37 +228,28 @@ void TaskMirroredParameters::onUpdateView(bool on)
std::string mirrorPlane = getMirrorPlane();
if (!mirrorPlane.empty()) {
std::vector<std::string> planes(1,mirrorPlane);
pcMirrored->MirrorPlane.setValue(getSupportObject(),planes);
if (mirrorPlane == "H_Axis" || mirrorPlane == "V_Axis")
pcMirrored->MirrorPlane.setValue(getSketchObject(),planes);
else
pcMirrored->MirrorPlane.setValue(getSupportObject(),planes);
} else
pcMirrored->MirrorPlane.setValue(NULL);
std::string stdMirrorPlane = getStdMirrorPlane();
if (!stdMirrorPlane.empty())
pcMirrored->StdMirrorPlane.setValue(stdMirrorPlane.c_str());
else
pcMirrored->StdMirrorPlane.setValue(NULL);
recomputeFeature();
}
}
const std::string TaskMirroredParameters::getStdMirrorPlane(void) const
{
if (ui->buttonXY->isChecked())
return std::string("XY");
else if (ui->buttonYZ->isChecked())
return std::string("YZ");
else if (ui->buttonXZ->isChecked())
return std::string("XZ");
return std::string("");
}
const std::string TaskMirroredParameters::getMirrorPlane(void) const
{
return ui->lineReference->text().toStdString();
if (ui->comboPlane->currentIndex() == 0)
return "H_Axis";
else if (ui->comboPlane->currentIndex() == 1)
return "V_Axis";
else if (ui->comboPlane->count() > 3 && ui->comboPlane->currentIndex() == 2)
return ui->comboPlane->currentText().toStdString();
return std::string("");
}
TaskMirroredParameters::~TaskMirroredParameters()
{
delete ui;
@@ -321,13 +293,14 @@ bool TaskDlgMirroredParameters::accept()
std::string mirrorPlane = mirrorParameter->getMirrorPlane();
if (!mirrorPlane.empty()) {
QString buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])");
buf = buf.arg(QString::fromUtf8(mirrorParameter->getSupportObject()->getNameInDocument()));
if (mirrorPlane == "H_Axis" || mirrorPlane == "V_Axis")
buf = buf.arg(QString::fromUtf8(mirrorParameter->getSketchObject()->getNameInDocument()));
else
buf = buf.arg(QString::fromUtf8(mirrorParameter->getSupportObject()->getNameInDocument()));
buf = buf.arg(QString::fromUtf8(mirrorPlane.c_str()));
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.MirrorPlane = %s", name.c_str(), buf.toStdString().c_str());
} else
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.MirrorPlane = None", name.c_str());
std::string stdMirrorPlane = mirrorParameter->getStdMirrorPlane();
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.StdMirrorPlane = \"%s\"",name.c_str(),stdMirrorPlane.c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.recompute()");
if (!TransformedView->getObject()->isValid())
throw Base::Exception(TransformedView->getObject()->getStatusString());
@@ -57,14 +57,10 @@ public:
virtual ~TaskMirroredParameters();
const std::string getStdMirrorPlane(void) const;
const std::string getMirrorPlane(void) const;
private Q_SLOTS:
void onButtonXY();
void onButtonXZ();
void onButtonYZ();
void onButtonReference(const bool checked);
void onPlaneChanged(int num);
virtual void onUpdateView(bool);
protected:
@@ -72,7 +68,6 @@ protected:
virtual void onSelectionChanged(const Gui::SelectionChanges& msg);
private:
void onStdMirrorPlane(const std::string& plane);
void setupUI();
void updateUI();
@@ -28,48 +28,33 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QRadioButton" name="buttonXY">
<property name="text">
<string>XY</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="buttonXZ">
<property name="text">
<string>XZ</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="buttonYZ">
<property name="text">
<string>YZ</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QToolButton" name="buttonReference">
<widget class="QLabel" name="labelPlane">
<property name="text">
<string>Plane</string>
</property>
<property name="checkable">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineReference"/>
<widget class="QComboBox" name="comboPlane">
<item>
<property name="text">
<string>Horizontal sketch axis</string>
</property>
</item>
<item>
<property name="text">
<string>Vertical sketch axis</string>
</property>
</item>
<item>
<property name="text">
<string>Select reference...</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
@@ -218,7 +218,10 @@ void TaskMultiTransformParameters::onTransformAddMirrored()
Gui::Command::openCommand("Mirrored");
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject(\"PartDesign::Mirrored\",\"%s\")",newFeatName.c_str());
//Gui::Command::updateActive();
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.StdMirrorPlane = \"XY\"", newFeatName.c_str());
App::DocumentObject* sketch = getSketchObject();
if (sketch)
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.MirrorPlane = (App.activeDocument().%s, [\"V_Axis\"])",
newFeatName.c_str(), sketch->getNameInDocument());
finishAdd(newFeatName);
}
@@ -231,7 +234,10 @@ void TaskMultiTransformParameters::onTransformAddLinearPattern()
Gui::Command::openCommand("LinearPattern");
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject(\"PartDesign::LinearPattern\",\"%s\")",newFeatName.c_str());
//Gui::Command::updateActive();
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.StdDirection = \"X\"", newFeatName.c_str());
App::DocumentObject* sketch = getSketchObject();
if (sketch)
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.Direction = (App.activeDocument().%s, [\"H_Axis\"])",
newFeatName.c_str(), sketch->getNameInDocument());
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.Length = 100", newFeatName.c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.Occurrences = 2", newFeatName.c_str());
@@ -246,7 +252,10 @@ void TaskMultiTransformParameters::onTransformAddPolarPattern()
Gui::Command::openCommand("PolarPattern");
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().addObject(\"PartDesign::PolarPattern\",\"%s\")",newFeatName.c_str());
//Gui::Command::updateActive();
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.StdAxis = \"X\"", newFeatName.c_str());
App::DocumentObject* sketch = getSketchObject();
if (sketch)
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.Axis = (App.activeDocument().%s, [\"N_Axis\"])",
newFeatName.c_str(), sketch->getNameInDocument());
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.Angle = 360", newFeatName.c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.activeDocument().%s.Occurrences = 2", newFeatName.c_str());
@@ -93,20 +93,14 @@ TaskPolarPatternParameters::TaskPolarPatternParameters(TaskMultiTransformParamet
void TaskPolarPatternParameters::setupUI()
{
connect(ui->buttonX, SIGNAL(pressed()),
this, SLOT(onButtonX()));
connect(ui->buttonY, SIGNAL(pressed()),
this, SLOT(onButtonY()));
connect(ui->buttonZ, SIGNAL(pressed()),
this, SLOT(onButtonZ()));
connect(ui->comboAxis, SIGNAL(activated(int)),
this, SLOT(onAxisChanged(int)));
connect(ui->checkReverse, SIGNAL(toggled(bool)),
this, SLOT(onCheckReverse(bool)));
connect(ui->spinAngle, SIGNAL(valueChanged(double)),
this, SLOT(onAngle(double)));
connect(ui->spinOccurrences, SIGNAL(valueChanged(int)),
this, SLOT(onOccurrences(int)));
connect(ui->buttonReference, SIGNAL(toggled(bool)),
this, SLOT(onButtonReference(bool)));
connect(ui->checkBoxUpdateView, SIGNAL(toggled(bool)),
this, SLOT(onUpdateView(bool)));
@@ -125,14 +119,10 @@ void TaskPolarPatternParameters::setupUI()
}
// ---------------------
ui->buttonX->setEnabled(true);
ui->buttonY->setEnabled(true);
ui->buttonZ->setEnabled(true);
ui->comboAxis->setEnabled(true);
ui->checkReverse->setEnabled(true);
ui->spinAngle->setEnabled(true);
ui->spinOccurrences->setEnabled(true);
ui->buttonReference->setEnabled(true);
ui->lineReference->setEnabled(false); // This is never enabled since it is for optical feed-back only
updateUI();
}
@@ -146,36 +136,32 @@ void TaskPolarPatternParameters::updateUI()
App::DocumentObject* axisFeature = pcPolarPattern->Axis.getValue();
std::vector<std::string> axes = pcPolarPattern->Axis.getSubValues();
std::string stdAxis = pcPolarPattern->StdAxis.getValue();
bool reverse = pcPolarPattern->Reversed.getValue();
double angle = pcPolarPattern->Angle.getValue();
unsigned occurrences = pcPolarPattern->Occurrences.getValue();
ui->buttonReference->setChecked(referenceSelectionMode);
if (!stdAxis.empty())
{
ui->buttonX->setAutoExclusive(true);
ui->buttonY->setAutoExclusive(true);
ui->buttonZ->setAutoExclusive(true);
ui->buttonX->setChecked(stdAxis == "X");
ui->buttonY->setChecked(stdAxis == "Y");
ui->buttonZ->setChecked(stdAxis == "Z");
ui->lineReference->setText(tr(""));
} else if (axisFeature != NULL && !axes.empty()) {
ui->buttonX->setAutoExclusive(false);
ui->buttonY->setAutoExclusive(false);
ui->buttonZ->setAutoExclusive(false);
ui->buttonX->setChecked(false);
ui->buttonY->setChecked(false);
ui->buttonZ->setChecked(false);
ui->lineReference->setText(QString::fromAscii(axes.front().c_str()));
for (int i=ui->comboAxis->count()-1; i >= 1; i--)
ui->comboAxis->removeItem(i);
if (axisFeature != NULL && !axes.empty()) {
if (axes.front() == "N_Axis")
ui->comboAxis->setCurrentIndex(0);
else if (axisFeature != NULL && !axes.empty()) {
ui->comboAxis->addItem(QString::fromAscii(axes.front().c_str()));
ui->comboAxis->setCurrentIndex(1);
}
} else {
// Error message?
ui->lineReference->setText(tr(""));
}
if (referenceSelectionMode)
ui->lineReference->setText(tr("Select an edge"));
if (referenceSelectionMode) {
ui->comboAxis->addItem(tr("Select an edge"));
ui->comboAxis->setCurrentIndex(ui->comboAxis->count() - 1);
} else
ui->comboAxis->addItem(tr("Select reference..."));
// Note: These three lines would trigger onLength(), on Occurrences() and another updateUI() if we
// didn't check for blockUpdate
ui->checkReverse->setChecked(reverse);
ui->spinAngle->setValue(angle);
ui->spinOccurrences->setValue(occurrences);
@@ -204,31 +190,22 @@ void TaskPolarPatternParameters::onSelectionChanged(const Gui::SelectionChanges&
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
std::vector<std::string> axes(1,subName);
pcPolarPattern->Axis.setValue(getSupportObject(), axes);
pcPolarPattern->StdAxis.setValue("");
recomputeFeature();
updateUI();
}
else {
ui->buttonReference->setChecked(referenceSelectionMode);
ui->lineReference->setText(QString::fromAscii(subName.c_str()));
for (int i=ui->comboAxis->count()-1; i >= 1; i--)
ui->comboAxis->removeItem(i);
ui->comboAxis->addItem(QString::fromAscii(subName.c_str()));
ui->comboAxis->setCurrentIndex(1);
ui->comboAxis->addItem(tr("Select reference..."));
}
}
}
}
void TaskPolarPatternParameters::onButtonX() {
onStdAxis("X");
}
void TaskPolarPatternParameters::onButtonY() {
onStdAxis("Y");
}
void TaskPolarPatternParameters::onButtonZ() {
onStdAxis("Z");
}
void TaskPolarPatternParameters::onCheckReverse(const bool on) {
if (blockUpdate)
return;
@@ -262,30 +239,28 @@ void TaskPolarPatternParameters::onOccurrences(const int n) {
recomputeFeature();
}
void TaskPolarPatternParameters::onStdAxis(const std::string& axis) {
void TaskPolarPatternParameters::onAxisChanged(int num) {
if (blockUpdate)
return;
PartDesign::PolarPattern* pcPolarPattern = static_cast<PartDesign::PolarPattern*>(getObject());
pcPolarPattern->StdAxis.setValue(axis.c_str());
pcPolarPattern->Axis.setValue(NULL);
exitSelectionMode();
updateUI();
recomputeFeature();
}
void TaskPolarPatternParameters::onButtonReference(bool checked)
{
if (checked ) {
if (num == 0) {
pcPolarPattern->Axis.setValue(getSketchObject(), std::vector<std::string>(1,"N_Axis"));
exitSelectionMode();
}
else if (num == ui->comboAxis->count() - 1) {
// enter reference selection mode
hideObject();
showOriginals();
referenceSelectionMode = true;
Gui::Selection().clearSelection();
addReferenceSelectionGate(true, false);
} else {
exitSelectionMode();
}
else if (num == 1)
exitSelectionMode();
updateUI();
recomputeFeature();
}
void TaskPolarPatternParameters::onUpdateView(bool on)
@@ -298,16 +273,13 @@ void TaskPolarPatternParameters::onUpdateView(bool on)
std::string axis = getAxis();
if (!axis.empty()) {
std::vector<std::string> axes(1,axis);
pcPolarPattern->Axis.setValue(getSupportObject(),axes);
if (axis == "N_Axis")
pcPolarPattern->Axis.setValue(getSketchObject(), axes);
else
pcPolarPattern->Axis.setValue(getSupportObject(), axes);
} else
pcPolarPattern->Axis.setValue(NULL);
std::string stdAxis = getStdAxis();
if (!stdAxis.empty())
pcPolarPattern->StdAxis.setValue(stdAxis.c_str());
else
pcPolarPattern->StdAxis.setValue(NULL);
pcPolarPattern->Reversed.setValue(getReverse());
pcPolarPattern->Angle.setValue(getAngle());
pcPolarPattern->Occurrences.setValue(getOccurrences());
@@ -316,22 +288,15 @@ void TaskPolarPatternParameters::onUpdateView(bool on)
}
}
const std::string TaskPolarPatternParameters::getStdAxis(void) const
const std::string TaskPolarPatternParameters::getAxis(void) const
{
if (ui->buttonX->isChecked())
return std::string("X");
else if (ui->buttonY->isChecked())
return std::string("Y");
else if (ui->buttonZ->isChecked())
return std::string("Z");
if (ui->comboAxis->currentIndex() == 0)
return "N_Axis";
else if (ui->comboAxis->count() > 2 && ui->comboAxis->currentIndex() == 1)
return ui->comboAxis->currentText().toStdString();
return std::string("");
}
const std::string TaskPolarPatternParameters::getAxis(void) const
{
return ui->lineReference->text().toStdString();
}
const bool TaskPolarPatternParameters::getReverse(void) const
{
return ui->checkReverse->isChecked();
@@ -391,13 +356,14 @@ bool TaskDlgPolarPatternParameters::accept()
std::string axis = polarpatternParameter->getAxis();
if (!axis.empty()) {
QString buf = QString::fromUtf8("(App.ActiveDocument.%1,[\"%2\"])");
buf = buf.arg(QString::fromUtf8(polarpatternParameter->getSupportObject()->getNameInDocument()));
if (axis == "N_Axis")
buf = buf.arg(QString::fromUtf8(polarpatternParameter->getSketchObject()->getNameInDocument()));
else
buf = buf.arg(QString::fromUtf8(polarpatternParameter->getSupportObject()->getNameInDocument()));
buf = buf.arg(QString::fromUtf8(axis.c_str()));
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Axis = %s", name.c_str(), buf.toStdString().c_str());
} else
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Axis = None", name.c_str());
std::string stdAxis = polarpatternParameter->getStdAxis();
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.StdAxis = \"%s\"",name.c_str(),stdAxis.c_str());
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Reversed = %u",name.c_str(),polarpatternParameter->getReverse());
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Angle = %f",name.c_str(),polarpatternParameter->getAngle());
Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Occurrences = %u",name.c_str(),polarpatternParameter->getOccurrences());
@@ -63,14 +63,10 @@ public:
const unsigned getOccurrences(void) const;
private Q_SLOTS:
void onStdAxis(const std::string& axis);
void onButtonX();
void onButtonY();
void onButtonZ();
void onAxisChanged(int num);
void onCheckReverse(const bool on);
void onAngle(const double a);
void onOccurrences(const int n);
void onButtonReference(const bool checked);
virtual void onUpdateView(bool);
protected:
@@ -28,48 +28,28 @@
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<widget class="QRadioButton" name="buttonX">
<property name="text">
<string>X</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="buttonY">
<property name="text">
<string>Y</string>
</property>
</widget>
</item>
<item>
<widget class="QRadioButton" name="buttonZ">
<property name="text">
<string>Z</string>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QToolButton" name="buttonReference">
<widget class="QLabel" name="labelAxis">
<property name="text">
<string>Direction</string>
</property>
<property name="checkable">
<bool>true</bool>
<string>Axis</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineReference"/>
<widget class="QComboBox" name="comboAxis">
<item>
<property name="text">
<string>Normal sketch axis</string>
</property>
</item>
<item>
<property name="text">
<string>Select reference...</string>
</property>
</item>
</widget>
</item>
</layout>
</item>
@@ -148,6 +148,16 @@ App::DocumentObject* TaskTransformedParameters::getSupportObject() const
}
}
App::DocumentObject* TaskTransformedParameters::getSketchObject() const
{
if (insideMultiTransform) {
return parentTask->getSketchObject();
} else {
PartDesign::Transformed* pcTransformed = static_cast<PartDesign::Transformed*>(TransformedView->getObject());
return pcTransformed->getSketchObject();
}
}
void TaskTransformedParameters::hideObject()
{
Gui::Document* doc = Gui::Application::Instance->activeDocument();
@@ -61,7 +61,8 @@ public:
const std::vector<App::DocumentObject*> getOriginals(void) const;
/// Get the support object either of the object associated with this feature or with the parent feature (MultiTransform mode)
App::DocumentObject* getSupportObject() const;
/// Get the sketch object of the first original either of the object associated with this feature or with the parent feature (MultiTransform mode)
App::DocumentObject* getSketchObject() const;
protected Q_SLOTS:
/// Connect the subTask OK button to the MultiTransform task
@@ -62,16 +62,12 @@ bool ViewProviderMultiTransform::setEdit(int ModNum)
std::vector<App::DocumentObject*> ViewProviderMultiTransform::claimChildren(void) const
{
std::vector<App::DocumentObject*> result = ViewProviderTransformed::claimChildren();
PartDesign::MultiTransform* pcMultiTransform = static_cast<PartDesign::MultiTransform*>(getObject());
if (pcMultiTransform == NULL)
return std::vector<App::DocumentObject*>(); // TODO: Show error?
std::vector<App::DocumentObject*> transformFeatures = pcMultiTransform->Transformations.getValues();
result.insert(result.end(), transformFeatures.begin(), transformFeatures.end());
return result;
return transformFeatures;
}
bool ViewProviderMultiTransform::onDelete(const std::vector<std::string> &svec) {
@@ -38,17 +38,6 @@ using namespace PartDesignGui;
PROPERTY_SOURCE(PartDesignGui::ViewProviderTransformed,PartDesignGui::ViewProvider)
std::vector<App::DocumentObject*> ViewProviderTransformed::claimChildren(void)const
{
PartDesign::Transformed* pcTransformed = static_cast<PartDesign::Transformed*>(getObject());
if (pcTransformed == NULL)
return std::vector<App::DocumentObject*>(); // TODO: Show error?
std::vector<App::DocumentObject*> originals = pcTransformed->Originals.getValues();
return originals;
}
void ViewProviderTransformed::setupContextMenu(QMenu* menu, QObject* receiver, const char* member)
{
QAction* act;
@@ -42,8 +42,6 @@ public:
virtual ~ViewProviderTransformed()
{}
/// grouping handling
std::vector<App::DocumentObject*> claimChildren(void) const;
void setupContextMenu(QMenu*, QObject*, const char*);
virtual bool onDelete(const std::vector<std::string> &);
@@ -1,3 +1,7 @@
#! python
# -*- coding: utf-8 -*-
# (c) 2011 Werner Mayer LGPL
#
from __future__ import division # allows floating point division from integers
import FreeCAD, Part, math
+3 -7
View File
@@ -274,14 +274,10 @@ int SketchObject::getAxisCount(void) const
Base::Axis SketchObject::getAxis(int axId) const
{
const std::vector< Part::Geometry * > &vals = getInternalGeometry();
if (axId == H_Axis) {
return Base::Axis(Base::Vector3d(0,0,0), Base::Vector3d(1,0,0));
}
else if (axId == V_Axis) {
return Base::Axis(Base::Vector3d(0,0,0), Base::Vector3d(0,1,0));
}
if (axId == H_Axis || axId == V_Axis || axId == N_Axis)
return Part::Part2DObject::getAxis(axId);
const std::vector< Part::Geometry * > &vals = getInternalGeometry();
int count=0;
for (std::vector<Part::Geometry *>::const_iterator geo=vals.begin();
geo != vals.end(); geo++)
+9 -3
View File
@@ -284,10 +284,11 @@ PyObject* SketchObjectPy::fillet(PyObject *args)
PyErr_SetString(PyExc_ValueError, str.str().c_str());
return 0;
}
// Point, radius
Py_Return;
}
PyErr_Clear();
PyErr_Clear();
// Point, radius
if (PyArg_ParseTuple(args, "iid|i", &geoId1, &posId1, &radius, &trim)) {
if (this->getSketchObjectPtr()->fillet(geoId1, (Sketcher::PointPos) posId1, radius, trim?true:false)) {
std::stringstream str;
@@ -295,8 +296,13 @@ PyObject* SketchObjectPy::fillet(PyObject *args)
PyErr_SetString(PyExc_ValueError, str.str().c_str());
return 0;
}
Py_Return;
}
Py_Return;
PyErr_SetString(PyExc_TypeError, "fillet() method accepts:\n"
"-- int,int,Vector,Vector,float,[int]\n"
"-- int,int,float,[int]\n");
return 0;
}
PyObject* SketchObjectPy::trim(PyObject *args)
+1 -1
View File
@@ -1721,7 +1721,7 @@ void CmdSketcherConstrainEqual::activated(int iMsg)
Sketcher::PointPos PosId;
getIdsFromName(*it, Obj, GeoId, PosId);
if (isVertex(GeoId,PosId)) {
if (!isEdge(GeoId,PosId)) {
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"),
QObject::tr("Select two or more compatible edges"));
return;
+2 -6
View File
@@ -1464,12 +1464,8 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s &startPos, const SbVec2s &
Gui::ViewVolumeProjection proj(viewer->getCamera()->getViewVolume());
App::Document* doc = App::GetApplication().getActiveDocument();
Sketcher::SketchObject *sketchObject = NULL;
if (doc)
sketchObject = dynamic_cast<Sketcher::SketchObject *>(doc->getActiveObject());
if (!sketchObject)
return;
Sketcher::SketchObject *sketchObject = getSketchObject();
App::Document *doc = sketchObject->getDocument();
Base::Placement Plm = sketchObject->Placement.getValue();
+23
View File
@@ -1,3 +1,26 @@
#***************************************************************************
#* *
#* Copyright (c) 2012 *
#* Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser 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 *
#* *
#***************************************************************************
import FreeCADGui
FreeCADGui.activateWorkbench("ArchWorkbench")
App.newDocument()
@@ -1,3 +1,26 @@
#***************************************************************************
#* *
#* Copyright (c) 2012 *
#* Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser 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 *
#* *
#***************************************************************************
import FreeCAD, FreeCADGui
workbench = FreeCAD.ConfigGet("DefaultWorkbench")
if not workbench: workbench = "CompleteWorkbench"
@@ -1,3 +1,26 @@
#***************************************************************************
#* *
#* Copyright (c) 2012 *
#* Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser 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 *
#* *
#***************************************************************************
import FreeCAD,FreeCADGui
FreeCAD.open(FreeCAD.getResourceDir()+"examples/ArchDetail.FCStd")
FreeCADGui.activeDocument().sendMsgToViews("ViewFit")
@@ -1,3 +1,26 @@
#***************************************************************************
#* *
#* Copyright (c) 2012 *
#* Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser 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 *
#* *
#***************************************************************************
import FreeCAD,FreeCADGui
FreeCADGui.activateWorkbench("DrawingWorkbench")
FreeCAD.open(FreeCAD.getResourceDir()+"examples/DrawingExample.FCStd")
+23
View File
@@ -1,3 +1,26 @@
#***************************************************************************
#* *
#* Copyright (c) 2012 *
#* Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser 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 *
#* *
#***************************************************************************
import FreeCAD,FreeCADGui,sys
rf=FreeCAD.ParamGet("User parameter:BaseApp/Preferences/RecentFiles")
FreeCAD.loadFile(rf.GetString("MRU0"))
+23
View File
@@ -1,3 +1,26 @@
#***************************************************************************
#* *
#* Copyright (c) 2012 *
#* Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser 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 *
#* *
#***************************************************************************
import FreeCAD,FreeCADGui,sys
rf=FreeCAD.ParamGet("User parameter:BaseApp/Preferences/RecentFiles")
FreeCAD.loadFile(rf.GetString("MRU1"))
+23
View File
@@ -1,3 +1,26 @@
#***************************************************************************
#* *
#* Copyright (c) 2012 *
#* Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser 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 *
#* *
#***************************************************************************
import FreeCAD,FreeCADGui,sys
rf=FreeCAD.ParamGet("User parameter:BaseApp/Preferences/RecentFiles")
FreeCAD.loadFile(rf.GetString("MRU2"))
@@ -1,3 +1,26 @@
#***************************************************************************
#* *
#* Copyright (c) 2012 *
#* Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser 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 *
#* *
#***************************************************************************
import FreeCAD,FreeCADGui
FreeCAD.open(FreeCAD.getResourceDir()+"examples/PartDesignExample.FCStd")
FreeCADGui.activeDocument().sendMsgToViews("ViewFit")
@@ -1,3 +1,26 @@
#***************************************************************************
#* *
#* Copyright (c) 2012 *
#* Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser 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 *
#* *
#***************************************************************************
import FreeCAD,FreeCADGui
FreeCAD.open(FreeCAD.getResourceDir()+"examples/RobotExample.FCStd")
FreeCADGui.activeDocument().sendMsgToViews("ViewFit")
+23
View File
@@ -1,3 +1,26 @@
#***************************************************************************
#* *
#* Copyright (c) 2012 *
#* Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser 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 *
#* *
#***************************************************************************
import FreeCAD,FreeCADGui,Part
Part.open(FreeCAD.getResourceDir()+"examples/Schenkel.stp")
FreeCADGui.activeDocument().sendMsgToViews("ViewFit")
+23
View File
@@ -1,3 +1,26 @@
#***************************************************************************
#* *
#* Copyright (c) 2012 *
#* Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser 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 *
#* *
#***************************************************************************
import FreeCADGui
FreeCADGui.activateWorkbench("MeshWorkbench")
App.newDocument()
+23
View File
@@ -1,3 +1,26 @@
#***************************************************************************
#* *
#* Copyright (c) 2012 *
#* Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser 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 *
#* *
#***************************************************************************
import FreeCADGui
FreeCADGui.activateWorkbench("PartDesignWorkbench")
App.newDocument()
+23
View File
@@ -1,3 +1,26 @@
#***************************************************************************
#* *
#* Copyright (c) 2012 *
#* Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser 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 *
#* *
#***************************************************************************
import FreeCADGui
FreeCADGui.activateWorkbench("ShipWorkbench")
App.newDocument()
+25
View File
@@ -1,3 +1,28 @@
#***************************************************************************
#* *
#* Copyright (c) 2012 *
#* Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser 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 *
#* *
#***************************************************************************
# This is the start page template
import os,FreeCAD,FreeCADGui,tempfile,time,zipfile,urllib,re,cStringIO
from PyQt4 import QtGui
from xml.etree.ElementTree import parse
+2 -2
View File
@@ -1,4 +1,4 @@
copy FreeCAD.msi FreeCAD_0.13.$WCREV$_x86_RC_setup.msi
copy FreeCAD.7z FreeCAD_0.13.$WCREV$_x86_RC_bin.7z
copy FreeCAD.msi FreeCAD_0.13.$WCREV$_x86_setup.msi
copy FreeCAD.7z FreeCAD_0.13.$WCREV$_x86_bin.7z