Ejemplo n.º 1
0
 def initValues(self):
     self.objs = None
     self.dir = Vector(0.0,0.0,1.0)
     self.r = 0.0
     self.face = None
     self.selObj  = Geometry.getSelectedObj()
     if not self.selObj:
         msg = Translator.translate("At least 1 surface must be selected (Any selected object)")
         App.Console.PrintError(msg)
         return True
     self.face = Geometry.getFaces()
     if not self.face:
         msg = Translator.translate("At least 1 surface must be selected (Any face object found into selected objects)")
         App.Console.PrintError(msg)
         return True
     bound = self.face[0].BoundBox
     self.bound = [bound.XMin, bound.XMax, bound.YMin, bound.YMax, bound.ZMin, bound.ZMax]
     for i in range(1,len(self.face)):
         face = self.face[i]
         bound = face.BoundBox
         self.bound[0] = min(self.bound[0],bound.XMin)
         self.bound[1] = min(self.bound[1],bound.XMax)
         self.bound[2] = min(self.bound[2],bound.YMin)
         self.bound[3] = min(self.bound[3],bound.YMax)
         self.bound[4] = min(self.bound[4],bound.ZMin)
         self.bound[5] = min(self.bound[5],bound.ZMax)
     self.r = max(self.r, self.bound[4])        
     self.r = min(self.r, self.bound[5])
     msg = Translator.translate("Ready to work")
     App.Console.PrintMessage(msg)
     return False
Ejemplo n.º 2
0
 def initValues(self):
     """ Setup initial values. """
     # Objects to work
     self.objs = Gui.Selection.getSelection()
     if not self.objs:
         msg = Translator.translate("4 connected edges and at least 1 surface must be selected (Any object has been selected)")
         App.Console.PrintError(msg)
         return True
     if len(self.objs) < 5:
         msg = Translator.translate("4 connected edges and at least 1 surface must be selected (Less than 5 objects selected)")
         App.Console.PrintError(msg)
         return True
     # Separate edge objects and face objects to work with them separately.
     if self.getEdgesFaces():
         return True
     # Ensure that closed edges given
     if not self.isClosed():
         return True
     # Sort edges (as connect chain)
     if self.sortEdges():
         return True
     # First surface draft
     if self.getPoints():
         return True
     if self.createSurface():
         return True
     # On screen data
     self.preview = Preview.Preview(self.edges[0],self.edges[1])
     msg = Translator.translate("Ready to work\n")
     App.Console.PrintMessage(msg)
     return False
Ejemplo n.º 3
0
 def retranslateUi(self):
     """ Set user interface locale strings. 
     """
     self.form.setWindowTitle(Translator.translate("Convert to 4 side surface"))
     nUString = Translator.translate("Points at U")
     self.form.findChild(QtGui.QLabel, "nULabel").setText("<font color=#0000ff>" + nUString + "</font>")
     nVString = Translator.translate("Points at V2")
     self.form.findChild(QtGui.QLabel, "nVLabel").setText("<font color=#ff0000>" + nVString + "</font>")
     self.form.findChild(QtGui.QLabel, "degLabel").setText(Translator.translate("Surface degree"))        
Ejemplo n.º 4
0
 def selectDirection(self):
     self.dirId = self.form.direction.currentIndex()
     self.obj = self.preview.update(self.surf, self.dirId, self.uv)
     if not self.obj:
         msg = Translator.translate(
             "Can't get the curve from selected object")
         App.Console.PrintWarning(msg)
Ejemplo n.º 5
0
class SurfWorkbench ( Workbench ):
    """ @brief Workbench of Ship design module. Here toolbars & icons are append. """
    from surfUtils import Paths, Translator
    import SurfGui

    Icon     = Paths.iconsPath() + "/Ico.png"
    MenuText = str(Translator.translate("Surface tools"))
    ToolTip  = str(Translator.translate("Surface tools"))

    def Initialize(self):
        # ToolBar
        list = ["Surf_IsoCurve", "Surf_SliceCurve", "Surf_Border", "Surf_Convert"]
        self.appendToolbar("Surface tools",list)
        
        # Menu
        list = ["Surf_IsoCurve", "Surf_SliceCurve", "Surf_Border", "Surf_Convert"]
        self.appendMenu("Surface tools",list)
Ejemplo n.º 6
0
 def initValues(self):
     self.obj = None
     self.dirId = 0
     self.uv = 0
     self.surf = None
     self.selObj  = Geometry.getSelectedObj()
     if not self.selObj:
         msg = Translator.translate("1 surface must be selected (Any object has been selected)")
         App.Console.PrintError(msg)
         return True
     self.surf = Geometry.getSelectedSurface()
     if not self.surf:
         msg = Translator.translate("1 surface must be selected (Any face object found into selected objects)")
         App.Console.PrintError(msg)
         return True
     msg = Translator.translate("Ready to work")
     App.Console.PrintMessage(msg)
     return False
Ejemplo n.º 7
0
 def setUV(self, uv):
     self.form.uv.setValue(uv*self.form.uv.maximum())
     self.form.uvText.setValue(uv)
     self.uv = uv
     if not self.surf:
         return
     self.obj = self.preview.update(self.surf, self.dirId, self.uv)
     if not self.obj:
         msg = Translator.translate("Can't get the curve from selected object")
         App.Console.PrintWarning(msg)
Ejemplo n.º 8
0
 def setUV(self, uv):
     self.form.uv.setValue(uv * self.form.uv.maximum())
     self.form.uvText.setValue(uv)
     self.uv = uv
     if not self.surf:
         return
     self.obj = self.preview.update(self.surf, self.dirId, self.uv)
     if not self.obj:
         msg = Translator.translate(
             "Can't get the curve from selected object")
         App.Console.PrintWarning(msg)
Ejemplo n.º 9
0
 def setR(self, r):
     self.form.rText.setValue(r)
     self.r = max(self.form.rText.minimum(), min(self.form.rText.maximum(), r))
     dr = self.form.rText.maximum()-self.form.rText.minimum()
     r = (r - self.form.rText.minimum())/dr*self.form.r.maximum()
     self.form.r.setValue(r)
     if not self.face:
         return
     self.objs = self.preview.update(self.face, self.dir, self.r)
     if not self.objs:
         msg = Translator.translate("Can't calculate section")
         App.Console.PrintWarning(msg)
Ejemplo n.º 10
0
 def initValues(self):
     self.obj = None
     self.dirId = 0
     self.uv = 0
     self.surf = None
     self.selObj = Geometry.getSelectedObj()
     if not self.selObj:
         msg = Translator.translate(
             "1 surface must be selected (Any object has been selected)")
         App.Console.PrintError(msg)
         return True
     self.surf = Geometry.getSelectedSurface()
     if not self.surf:
         msg = Translator.translate(
             "1 surface must be selected (Any face object found into selected objects)"
         )
         App.Console.PrintError(msg)
         return True
     msg = Translator.translate("Ready to work")
     App.Console.PrintMessage(msg)
     return False
Ejemplo n.º 11
0
 def setR(self, r):
     self.form.rText.setValue(r)
     self.r = max(self.form.rText.minimum(),
                  min(self.form.rText.maximum(), r))
     dr = self.form.rText.maximum() - self.form.rText.minimum()
     r = (r - self.form.rText.minimum()) / dr * self.form.r.maximum()
     self.form.r.setValue(r)
     if not self.face:
         return
     self.objs = self.preview.update(self.face, self.dir, self.r)
     if not self.objs:
         msg = Translator.translate("Can't calculate section")
         App.Console.PrintWarning(msg)
Ejemplo n.º 12
0
 def initValues(self):
     self.objs = None
     self.dir = Vector(0.0, 0.0, 1.0)
     self.r = 0.0
     self.face = None
     self.selObj = Geometry.getSelectedObj()
     if not self.selObj:
         msg = Translator.translate(
             "At least 1 surface must be selected (Any selected object)")
         App.Console.PrintError(msg)
         return True
     self.face = Geometry.getFaces()
     if not self.face:
         msg = Translator.translate(
             "At least 1 surface must be selected (Any face object found into selected objects)"
         )
         App.Console.PrintError(msg)
         return True
     bound = self.face[0].BoundBox
     self.bound = [
         bound.XMin, bound.XMax, bound.YMin, bound.YMax, bound.ZMin,
         bound.ZMax
     ]
     for i in range(1, len(self.face)):
         face = self.face[i]
         bound = face.BoundBox
         self.bound[0] = min(self.bound[0], bound.XMin)
         self.bound[1] = min(self.bound[1], bound.XMax)
         self.bound[2] = min(self.bound[2], bound.YMin)
         self.bound[3] = min(self.bound[3], bound.YMax)
         self.bound[4] = min(self.bound[4], bound.ZMin)
         self.bound[5] = min(self.bound[5], bound.ZMax)
     self.r = max(self.r, self.bound[4])
     self.r = min(self.r, self.bound[5])
     msg = Translator.translate("Ready to work")
     App.Console.PrintMessage(msg)
     return False
Ejemplo n.º 13
0
 def getEdgesFaces(self):
     """ Returns two arrays filled with the edges and faces selected.
     @return True if error happens. False otherwise
     """
     self.edges = []
     self.faces = []
     for i in range(0,len(self.objs)):
         objFaces = Geometry.getFaces(self.objs[i])
         if not objFaces:
             objEdges = Geometry.getEdges([self.objs[i]])
             if not objEdges:
                 msg = Translator.translate("4 connected edges and at least 1 surface must be selected (Any edge found)")
                 App.Console.PrintError(msg)
                 return True
             for j in range(0, len(objEdges)):
                 self.edges.append(objEdges[j])
         else:
             for j in range(0, len(objFaces)):
                 self.faces.append(objFaces[j])
     if len(self.edges) != 4:
         msg = Translator.translate("4 connected edges and at least 1 surface must be selected (More/less edges not allowed)")
         App.Console.PrintError(msg)
         return True
     return False
Ejemplo n.º 14
0
def load():
    """ Loads the tool. Getting the border don't require any
     option, so can be executed directly without any task panel. """
    edges = Geometry.getBorders()
    if not edges:
        wrn = Translator.translate("Can't get any edge from selected objects")
        FreeCAD.Console.PrintWarning(wrn)
        return
    obj = edges[0]
    for i in range(0,len(edges)):
        obj = obj.oldFuse(edges[i])
    Part.show(obj)
    objs = FreeCAD.ActiveDocument.Objects
    obj = objs[len(objs)-1]
    obj.Label = 'Border'
Ejemplo n.º 15
0
def load():
    """ Loads the tool. Getting the border don't require any
     option, so can be executed directly without any task panel. """
    edges = Geometry.getBorders()
    if not edges:
        wrn = Translator.translate("Can't get any edge from selected objects")
        FreeCAD.Console.PrintWarning(wrn)
        return
    obj = edges[0]
    for i in range(0, len(edges)):
        obj = obj.oldFuse(edges[i])
    Part.show(obj)
    objs = FreeCAD.ActiveDocument.Objects
    obj = objs[len(objs) - 1]
    obj.Label = 'Border'
Ejemplo n.º 16
0
 def selectDirection(self):
     if(self.form.direction.currentIndex() == 0):    # XY
         self.dir = Vector(0.0,0.0,1.0)
         self.r = max(self.r, self.bound[4])
         self.r = min(self.r, self.bound[5])
         self.form.rText.setMinimum(self.bound[4])
         self.form.rText.setMaximum(self.bound[5])
     if(self.form.direction.currentIndex() == 1):    # XZ
         self.dir = Vector(0.0,1.0,0.0)
         self.r = max(self.r, self.bound[2])
         self.r = min(self.r, self.bound[3])
         self.form.rText.setMinimum(self.bound[2])
         self.form.rText.setMaximum(self.bound[3])
     if(self.form.direction.currentIndex() == 2):    # YZ
         self.dir = Vector(1.0,0.0,0.0)
         self.r = max(self.r, self.bound[0])
         self.r = min(self.r, self.bound[1])
         self.form.rText.setMinimum(self.bound[0])
         self.form.rText.setMaximum(self.bound[1])
     self.objs = self.preview.update(self.face, self.dir, self.r)
     if not self.objs:
         msg = Translator.translate("Can't calculate section")
         App.Console.PrintWarning(msg)
Ejemplo n.º 17
0
 def selectDirection(self):
     if (self.form.direction.currentIndex() == 0):  # XY
         self.dir = Vector(0.0, 0.0, 1.0)
         self.r = max(self.r, self.bound[4])
         self.r = min(self.r, self.bound[5])
         self.form.rText.setMinimum(self.bound[4])
         self.form.rText.setMaximum(self.bound[5])
     if (self.form.direction.currentIndex() == 1):  # XZ
         self.dir = Vector(0.0, 1.0, 0.0)
         self.r = max(self.r, self.bound[2])
         self.r = min(self.r, self.bound[3])
         self.form.rText.setMinimum(self.bound[2])
         self.form.rText.setMaximum(self.bound[3])
     if (self.form.direction.currentIndex() == 2):  # YZ
         self.dir = Vector(1.0, 0.0, 0.0)
         self.r = max(self.r, self.bound[0])
         self.r = min(self.r, self.bound[1])
         self.form.rText.setMinimum(self.bound[0])
         self.form.rText.setMaximum(self.bound[1])
     self.objs = self.preview.update(self.face, self.dir, self.r)
     if not self.objs:
         msg = Translator.translate("Can't calculate section")
         App.Console.PrintWarning(msg)
Ejemplo n.º 18
0
 def isClosed(self):
     """ Returns if the edges objects are a closed curve.
     @return True if a closed curve can be built with edge objects.
     False otherwise
     """
     edges = self.edges
     for i in range(0,len(edges)):
         edge = edges[i]
         vertex1 = edge.Vertexes
         count = [0,0]
         for j in range(0,len(edges)):
             if j== i:
                 continue
             vertex2 = edges[j].Vertexes
             for k in range(0,2):
                 if Math.isSameVertex(vertex1[0],vertex2[k]):
                     count[0] = count[0]+1
                 if Math.isSameVertex(vertex1[1],vertex2[k]):
                     count[1] = count[1]+1
         if count != [1,1]:
             msg = Translator.translate("4 Edges curve must be closed")
             App.Console.PrintError(msg)
             return False
     return True
Ejemplo n.º 19
0
 def selectDirection(self):
     self.dirId = self.form.direction.currentIndex()
     self.obj = self.preview.update(self.surf, self.dirId, self.uv)
     if not self.obj:
         msg = Translator.translate("Can't get the curve from selected object")
         App.Console.PrintWarning(msg)
Ejemplo n.º 20
0
 def GetResources(self):
     from surfUtils import Paths, Translator
     IconPath = Paths.iconsPath() + "/ConvertIco.png"
     MenuText = str(Translator.translate('Convert to 4 sides surface'))
     ToolTip  = str(Translator.translate('Convert a surface (or couple of them) into 4 sides surface'))
     return {'Pixmap' : IconPath, 'MenuText': MenuText, 'ToolTip': ToolTip} 
Ejemplo n.º 21
0
 def GetResources(self):
     from surfUtils import Paths, Translator
     IconPath = Paths.iconsPath() + "/BorderIco.png"
     MenuText = str(Translator.translate('Get border'))
     ToolTip  = str(Translator.translate('Get edges from objects'))
     return {'Pixmap' : IconPath, 'MenuText': MenuText, 'ToolTip': ToolTip} 
Ejemplo n.º 22
0
 def GetResources(self):
     from surfUtils import Paths, Translator
     IconPath = Paths.iconsPath() + "/SliceIco.png"
     MenuText = str(Translator.translate('Get surface slice'))
     ToolTip  = str(Translator.translate('Get surface intersection with coordinates planes'))
     return {'Pixmap' : IconPath, 'MenuText': MenuText, 'ToolTip': ToolTip} 
Ejemplo n.º 23
0
 def GetResources(self):
     from surfUtils import Paths, Translator
     IconPath = Paths.iconsPath() + "/IsoCurveIco.png"
     MenuText = str(Translator.translate('Get ISO curve'))
     ToolTip  = str(Translator.translate('Get ISO curve from surface'))
     return {'Pixmap' : IconPath, 'MenuText': MenuText, 'ToolTip': ToolTip} 
Ejemplo n.º 24
0
 def retranslateUi(self):
     """ Set user interface locale strings. 
     """
     self.form.setWindowTitle(Translator.translate("Get surface slice"))
Ejemplo n.º 25
0
 def retranslateUi(self):
     """ Set user interface locale strings. 
     """
     self.form.setWindowTitle(Translator.translate("Get surface slice"))
Ejemplo n.º 26
0
 def retranslateUi(self):
     """ Set user interface locale strings. 
     """
     self.form.setWindowTitle(Translator.translate("Get surface ISO curve"))
     self.form.direction.setItemText(0, Translator.translate("U direction"))
     self.form.direction.setItemText(1, Translator.translate("V direction"))
Ejemplo n.º 27
0
 def retranslateUi(self):
     """ Set user interface locale strings. 
     """
     self.form.setWindowTitle(Translator.translate("Get surface ISO curve"))
     self.form.direction.setItemText(0, Translator.translate("U direction"))
     self.form.direction.setItemText(1, Translator.translate("V direction"))