##############################################################################
# ThanCad 0.0.9 "DoesSomething": 2dimensional CAD with raster support for engineers.
#
# Copyright (c) 2001-2009 Thanasis Stamos, August 23, 2009
# URL: http://thancad.sourceforge.net
# e-mail: cyberthanasis@excite.com
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# 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 General Public License for more details (www.gnu.org/licenses/gpl.html).
#
# You should have received a copy of the GNU 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
##############################################################################
"""\
ThanCad 0.0.9 "DoesSomething": 2dimensional CAD with raster support for engineers.
Package which processes commands entered by the user.
This module defines various constants.
"""
import os
import thandr
import thancomsel, thancommod, thancomedit, thancomdraw, thancomfile, thancomvar
import thancomview, thancomedu, thancomtool, thancomhatch, thancomeng
__all__ = "thanComFun",
def thanComFun(com):
"Tries to match com to a command, and returns the command's function."
try: return thanComs[com]
except KeyError: return None, None
dr = thancomdraw.thanTkDrawElem
coms = \
[ ("arc", lambda w, cl=thandr.ThanArc, dr=dr: dr(w, cl)),
("about", thancomvar.thanHelpAbout),
("angle", thancomtool.thanToolAngle),
("area", thancomtool.thanToolArea),
("break", thancommod.thanModBreak),
("brkin", thancomfile.thanFileImpBrk),
("brkout", thancomfile.thanFileExpBrk),
("centroid", thancomtool.thanToolCen),
("chprop", thancommod.thanModChlayer),
("circle", lambda w, cl=thandr.ThanCircle,dr=dr: dr(w, cl)),
("close", thancomfile.thanFileClose),
("continueline",thancommod.thanModContline),
("copy", thancommod.thanModCopy),
("copybase", thancomedit.thanClipCopybase),
("copyclip", thancomedit.thanClipCopy),
("curve", thancomdraw.thanCurveMake),
("cutclip", thancomedit.thanClipCut),
("ddedit", thancommod.thanModDDedit),
("ddlmodes", thancomvar.thanFormLay),
("devcm", thancomvar.thanDevCm),
("devcmd", thancomvar.thanDevCmdsave),
("devfont", thancomvar.thanDevFont),
("devtrans", thancomvar.thanDevTrans),
("dimali", lambda w, cl=thandr.ThanDimali,dr=dr: dr(w, cl)),
("dist", thancomtool.thanToolDist),
("dsettings", thancomtool.thanToolOsnap),
("dtext", thancomdraw.thanTkDrawText),
("dtmline", thancomeng.thanEngDtmline),
("dtmmake", thancomeng.thanEngDtmmake),
("dtmpoints", thancomeng.thanEngDtmpoints),
("dtmz", thancomeng.thanEngDtmpoint1),
("dxfin", thancomfile.thanFileImpDxf),
("dxfout", thancomfile.thanFileExpDxf),
("eduedit", thancomedu.thanEduEdit),
("edurectangle",thancomedu.thanEduRect),
("eduproject", thancomedu.thanEduPointProject),
("elevation", thancomvar.thanVarElev),
("erase", thancommod.thanModErase),
("enggrid", thancomeng.thanEngGrid),
("engmaprect", thancomeng.thanEngMaprect),
("engprofile", thancomeng.thanEngLineprofile),
("engtrace", thancomeng.thanEngTrace),
("exit", thancomfile.thanFileExit),
("explode", thancommod.thanModExplode),
("extendline", thancommod.thanModExtendline),
("filet", thancommod.thanModFilet),
("fill", thancomvar.thanVarFill),
("find", thancomtool.thanToolTextfind),
("gpl", thancomvar.thanHelpGpl),
("hatchopen", thancomhatch.thanHatchOpen),
("help", thancomvar.thanHelpHelp),
("highlight", thancomview.thanHiwin),
("hull", thancomtool.thanToolHull),
("id", thancomtool.thanToolId),
("imageattach", lambda w, cl=thandr.ThanImage, dr=dr: dr(w, cl)),
("join", thancommod.thanModJoin),
("line", lambda w, cl=thandr.ThanLine, dr=dr: dr(w, cl)),
("list", thancomvar.thanList),
("mhkin", thancomfile.thanFileImpMhk),
("mirror", thancommod.thanModMirror),
("move", thancommod.thanModMove),
("new", thancomfile.thanFileNew),
("osnap", thancomtool.thanToolOsnap),
("open", thancomfile.thanFileOpen),
("panrealtime", thancomview.thanPanRT),
("panpagedown", lambda win: thancomview.thanPanPage(win, 0, -1)),
("panpageleft", lambda win: thancomview.thanPanPage(win, -1, 0)),
("panpageright",lambda win: thancomview.thanPanPage(win, 1, 0)),
("panpageup", lambda win: thancomview.thanPanPage(win, 0, 1)),
("panrelative", thancomview.thanPanRel),
("pasteorig", thancomedit.thanClipPasteorig),
("pasteclip", thancomedit.thanClipPaste),
("pdfout", thancomfile.thanPlotPdf),
("pilout", thancomfile.thanPlotPil),
("pline", lambda w, cl=thandr.ThanLine, dr=dr: dr(w, cl)),
("point", thancomdraw.thanTkDrawPoint),
("pointnamed", thancomdraw.thanTkDrawPointNamed),
("pointreplace",thancomdraw.thanPointNamedReplace),
("polygon", thancomdraw.thanTkDrawPolygon),
("pnamed", thancomdraw.thanTkDrawPointNamed),
("purge", thancommod.thanModPurge),
("quit", thancomfile.thanFileExit),
("offset", thancommod.thanModOffset),
("redraw", thancomview.thanRedraw),
("regen", thancomview.thanRegen),
("rectangle", thancomdraw.thanTkDrawRect),
("redo", thancomedit.thanModRedo),
("reverse", thancommod.thanModReverse),
("road", lambda w, cl=thandr.ThanRoad,dr=dr: dr(w, cl)),
("rotate", thancommod.thanModRotate),
("save", thancomfile.thanFileSave),
("scale", thancommod.thanModScale),
("script", thancomvar.thanVarScript),
("select", thancomsel.thanSelectGen),
("simplify", thancomtool.thanToolSimplif),
("solid", thancomdraw.thanTkDrawSolid),
("style", thancomvar.thanFormTstyle),
("synin", thancomfile.thanFileImpSyn),
("sykin", thancomfile.thanFileImpSyk),
("sudup", thancomvar.thanVarSudup),
("sykout", thancomfile.thanFileExpSyk),
("thancad", thancomvar.thanHelpVer),
("triangulation", thancomeng.thanEngTri),
("trim", thancommod.thanModTrim),
("undo", thancomedit.thanModUndo),
("zoom", thancomview.thanZoom),
("zoomrealtime",thancomview.thanZoomRT),
("zoomall", thancomview.thanZoomExt),
("zoomext", thancomview.thanZoomExt),
("zoomin2", lambda win: thancomview.thanZoomFact(win, -2.0)),
("zoomout2", lambda win: thancomview.thanZoomFact(win, -0.5)),
("zoomrelative",thancomview.thanZoomFact),
("zoomsel", thancomview.thanZoomSel),
("zoomwin", thancomview.thanZoomWin),
]
abbrevs = \
( ("c", "circle"),
("cl", "continueline"),
("e", "erase"),
("el", "extendline"),
("m", "move"),
("plot", "pilout"),
("pr", "pointreplace"),
("re", "regen"),
("x", "explode"),
("zw", "zoomwin"),
)
coms.reverse()
thanComs = {}
for c,f in coms:
thanComs[c] = c, f
for i in xrange(1, min(len(c), 10)):
thanComs[c[:i]] = c, f
for c,f in abbrevs: thanComs[c] = thanComs[f]
del dr, coms, abbrevs, c, f
|