コード例 #1
0
def run():
    parser = argparse.ArgumentParser(description='Generate TOC for JShop')
    parser.add_argument('doi_file', help='Input DOI deposit file')
    parser.add_argument('pdf_file', help='Input PDF deposit file')
    parser.add_argument('-l',
                        '--level',
                        default=1,
                        help='TOC level to which to parse to')

    args = parser.parse_args()

    # Get a (simple) list of the chapters
    outline = Outline(path.abspath(args.pdf_file), args.level)
    chapters = outline.get_chapter_list()

    # Make a dictionary with chapters with DOI and related info
    # (author name(s), chapter title and PDF URL)
    doi_chapters = get_doi_chapters(path.abspath(args.doi_file))

    # Merge in data the information of the first list
    # and the dictionary
    data = []

    for chapter in chapters:
        for doi_chapter in doi_chapters:
            # Find (fuzzy) string matches
            if check_match(chapter, doi_chapter) > 90:
                data.append({doi_chapter: doi_chapters[doi_chapter]})
                break

        else:
            data.append(chapter)

    generate_toc(data)
コード例 #2
0
ファイル: doneshapes.py プロジェクト: VanHulleOne/DogBoneV2
def rect(lowerLeftX: float, lowerLeftY: float, width: float, height: float) ->Outline:
    rect = [Point(lowerLeftX, lowerLeftY)]
    rect.append(Point(lowerLeftX+width, lowerLeftY))
    rect.append(Point(lowerLeftX+width, lowerLeftY+height))
    rect.append(Point(lowerLeftX, lowerLeftY+height))
    rectLG = Outline(None)
    rectLG.addLinesFromPoints(rect)
    rectLG.closeShape()
    return rectLG
コード例 #3
0
def testSimpleDogBone() -> Outline:
    temp = Outline(None)
    temp.addLinesFromCoordinateList([[82.5, 0], [82.5, 9.5], [49.642, 9.5],
                                     [28.5, 6.5], [0, 6.5]])
    temp.addLineGroup(temp.mirror(c.Y))
    temp.addLineGroup(temp.mirror(c.X))
    temp = temp.translate(82.5, 9.5)
    temp.finishOutline()
    return temp
コード例 #4
0
ファイル: doneshapes.py プロジェクト: VanHulleOne/DogBoneV2
def testSimpleDogBone():# ->Outline:
    temp = Outline(None)
    temp.addLinesFromCoordinateList([[82.5,0],[82.5,9.5],[49.642, 9.5], [28.5,6.5],[0,6.5]])
    temp.addLineGroup(temp.mirror(c.Y))
    temp.addLineGroup(temp.mirror(c.X))
    temp = temp.translate(82.5, 9.5)
    temp.finishOutline()
    return temp
コード例 #5
0
ファイル: main.py プロジェクト: TheoDevelopers/pyTalkManager
    def add_outline(self):
        """
        Adds the contents of the AddOtlineWindow to the database.
        """

        outline = Outline()

        outline_number = self.line_number.displayText()
        outline_title = self.line_title.displayText()

        submission = outline.add_outline(outline_number, outline_title)

        if submission[0] == "True":
            self.done(True)
        else:
            error = QtGui.QMessageBox.critical(self, 'Error', submission[1])
コード例 #6
0
ファイル: main.py プロジェクト: hoverdj/pyTalkManager
    def add_outline(self):
        """
        Adds the contents of the AddOtlineWindow to the database.
        """

        outline = Outline()

        outline_number = self.line_number.displayText()
        outline_title = self.line_title.displayText()

        submission = outline.add_outline(outline_number, outline_title)

        if submission[0] == "True":
            self.done(True)
        else:
            error = QtGui.QMessageBox.critical(self, 'Error', submission[1])
コード例 #7
0
ファイル: infill.py プロジェクト: VanHulleOne/DogBoneV2
    def __init__(self, trimOutline, pathWidth, angleDegrees, shiftX=0, shiftY=0,
                 design=None, designType=c.PARTIAL_ROW):
        LineGroup.__init__(self, None)
        self.shiftX = shiftX
        self.shiftY = shiftY
        self.designType = designType
        self.trimOutline = Outline(trimOutline)
        self.angleRad = (angleDegrees/360.0*2*np.pi)
        self.pathWidth = pathWidth
        lowerLeft = Point(self.trimOutline.minX, self.trimOutline.minY)
        upperRight = Point(self.trimOutline.maxX, self.trimOutline.maxY)
        
        self.trimDiagonal = (lowerLeft - upperRight)*1.1       
        self.operations = (self.extendDesign, self.createField,
                           self.centerAndRotateField, self.trimField)
        
        try:
            self.design = design(space = self.pathWidth,
                                 length = self.trimDiagonal,
                                 height = self.trimDiagonal,
                                 ) 
            self.designType = c.FULL_FIELD
        except Exception:
            self.design = LineGroup(design)
        
#        print('\nInfill times:') 
        for i in range(self.designType, c.TRIMMED_FIELD):
            startTime = time.time()
            self.operations[i]();
コード例 #8
0
ファイル: main.py プロジェクト: TheoDevelopers/pyTalkManager
    def save_edit(self):
        """
        Save edits made by the user to the selected outline.
        """

        number = self.line_number.displayText()
        title = self.line_title.displayText()

        outline = Outline()
        submission = outline.edit_outline(self.edited_item[0][1],
                                          self.edited_item[0][2], number, title,
                                          self.edited_item[0][0])

        if submission[0] == 'True':
            self.done(True)
        else:
            error = QtGui.QMessageBox.critical(self, 'Error', submission[1])
コード例 #9
0
 def __init__(self):
     self._objectNumber = 0
     self.objects = list()
     self.catalog = Catalog(self)
     self.outline = Outline(self)
     self.pageTree = PageTree(self)
     self.catalog.outlinesNumber = self.outline.objectNumber
     self.catalog.pageTreeNumber = self.pageTree.objectNumber
コード例 #10
0
def submitJob(jobData):
    """Submit the job using the PyOutline API."""
    outline = Outline(jobData['name'], shot=jobData['shot'], show=jobData['show'],
                      user=jobData['username'])
    lastLayer = None
    for layerData in jobData['layers']:
        if layerData.layerType == JobTypes.JobTypes.MAYA:
            layer = buildMayaLayer(layerData, lastLayer)
        elif layerData.layerType == JobTypes.JobTypes.SHELL:
            layer = buildShellLayer(layerData, lastLayer)
        elif layerData.layerType == JobTypes.JobTypes.NUKE:
            layer = buildNukeLayer(layerData, lastLayer)
        else:
            raise ValueError('unrecognized layer type %s' % layerData.layerType)
        outline.add_layer(layer)
        lastLayer = layer
    return cuerun.launch(outline, use_pycuerun=False)
コード例 #11
0
def squareWithHole() -> Outline:
    outline = Outline(None)
    outline.addLinesFromCoordinateList([[0, 0], [50, 0], [50, 50], [0, 50],
                                        [0, 0]])
    circle = a.Arc(Point(35, 25), Point(35, 25), c.CW, Point(25, 25))
    outline.addLineGroup(circle)
    return outline
コード例 #12
0
ファイル: main.py プロジェクト: bmbigbang/Directory
 def __init__(self):
     self.main = Corrector()
     self.match = ""
     self.matchgeo = ""
     self.commands = []
     self.option = Options()
     self.display = Chunks("")
     self.display.create_Chunks()
     self.last_Display = ""
     self.find = Chunks("")
     self.find.create_Chunks()
     self.table = Outline()
     self.location_History = {}
コード例 #13
0
    def __init__(self,
                 trimOutline,
                 pathWidth,
                 angleDegrees,
                 shiftX=0,
                 shiftY=0,
                 design=None,
                 designType=c.PARTIAL_ROW):
        LineGroup.__init__(self, None)
        self.shiftX = shiftX
        self.shiftY = shiftY
        self.designType = designType
        self.trimOutline = Outline(trimOutline)
        self.angleRad = (angleDegrees / 360.0 * 2 * np.pi)
        self.pathWidth = pathWidth
        lowerLeft = Point(self.trimOutline.minX, self.trimOutline.minY)
        upperRight = Point(self.trimOutline.maxX, self.trimOutline.maxY)

        self.trimDiagonal = (lowerLeft - upperRight) * 1.1
        self.operations = (self.extendDesign, self.createField,
                           self.centerAndRotateField, self.trimField)

        try:
            self.design = design(
                space=self.pathWidth,
                length=self.trimDiagonal,
                height=self.trimDiagonal,
            )
            self.designType = c.FULL_FIELD
        except Exception:
            self.design = LineGroup(design)

#        print('\nInfill times:')
        for i in range(self.designType, c.TRIMMED_FIELD):
            startTime = time.time()
            self.operations[i]()
コード例 #14
0
def main(input_path, fps, crf, chunk, output_path):
    """
    Sends a job to opencue that will compress an image sequence to
    an H.264 file using multiple render nodes in parallel
    :input_path: str - path to the first frame of the image sequence
    :fps: float - framerate of the desired encoded file
    :crf: int - quality of the desired encoded file

    """
    input_path = os.path.abspath(input_path)
    shot_name = os.path.basename(input_path)
    job_name = "dpx_to_mov"
    show_name = "testing"
    user = getpass.getuser()
    outline = Outline(job_name, shot=shot_name, show=show_name, user=user)

    # Create the MakeMov Layer
    layer_name = "seq_to_mov"
    threads = 1.0
    threadable = False
    frame_start, frame_end = get_imgseq_framerange(input_path)
    range_len = int(frame_end) - int(frame_start)
    frame_range = frame_start + "-" + frame_end
    input_path_ffmpeg = translate_imgseq_ffmpeg(input_path)
    output_chunk_path_template = create_chunk_path_template(input_path)

    seqtomov_layer = SeqToMov(layer_name,
                              chunk=chunk,
                              threads=threads,
                              range=frame_range,
                              threadable=threadable,
                              crf=crf,
                              fps=fps)
    seqtomov_layer.add_input("main", input_path_ffmpeg)
    seqtomov_layer.add_output("main", output_chunk_path_template)

    outline.add_layer(seqtomov_layer)

    # Create the ConcatMov Layer
    layer_name = "concat_mov"
    concatmov_layer = ConcatMov(layer_name,
                                chunk=1,
                                threads=threads,
                                range=1,
                                threadable=threadable)
    chunk_paths = get_chunk_paths(output_chunk_path_template, chunk,
                                  frame_start, frame_end)
    for chunk_path in enumerate(chunk_paths):
        concatmov_layer.add_input("", chunk_path)
    concatmov_layer.add_output("main", output_path)
    concatmov_layer.depend_all(seqtomov_layer)

    outline.add_layer(concatmov_layer)

    # Submit job
    cuerun.launch(outline, use_pycuerun=False)
コード例 #15
0
def rectangle(lowerLeftX: float, lowerLeftY: float, X_width: float,
              Y_height: float) -> Outline:
    rect = [Point(lowerLeftX, lowerLeftY)]
    rect.append(Point(lowerLeftX + X_width, lowerLeftY))
    rect.append(Point(lowerLeftX + X_width, lowerLeftY + Y_height))
    rect.append(Point(lowerLeftX, lowerLeftY + Y_height))
    rectLG = Outline(None)
    rectLG.addLinesFromPoints(rect)
    rectLG.closeShape()
    return rectLG
コード例 #16
0
def polygon(centerX: float, centerY: float, radius: float,
            numCorners: int) -> Outline:
    angle = 1.5 * math.pi
    points = []
    incAngle = 2 * math.pi / numCorners
    for i in range(numCorners):
        x = math.cos(angle + incAngle * i) * radius + centerX
        y = math.sin(angle + incAngle * i) * radius + centerY
        points.append(Point(x, y))
    poly = Outline(None)
    poly.addLinesFromPoints(points)
    poly.closeShape()
    poly = poly.rotate(incAngle / 2.0, Point(centerX, centerY))
    return poly
コード例 #17
0
ファイル: doneshapes.py プロジェクト: VanHulleOne/DogBoneV2
def polygon(centerX: float, centerY: float, radius: float, numCorners: int) ->Outline:
    angle = 1.5*math.pi
    points = []
    incAngle = 2*math.pi/numCorners
    for i in range(numCorners):
        x = math.cos(angle+incAngle*i)*radius+centerX
        y = math.sin(angle+incAngle*i)*radius+centerY
        points.append(Point(x,y))
    poly = Outline(None)
    poly.addLinesFromPoints(points)
    poly.closeShape()
    poly = poly.rotate(incAngle/2.0, Point(centerX, centerY))
    return poly
コード例 #18
0
    def _doDispatch(self, rootBatch):

        # Construct an object to track everything we need
        # to generate the job. I have a suspicion that at
        # some point we'll want a Dispatcher::Job base class
        # which _doDispatch() must return, in which case this
        # might just be member data for a subclass of one of those.
        dispatchData = {}
        dispatchData["scriptNode"] = rootBatch.preTasks()[0].node().scriptNode(
        )
        dispatchData["scriptFile"] = Gaffer.Context.current(
        )["dispatcher:scriptFileName"]
        dispatchData["batchesToLayers"] = {}

        # Create an OpenCue outline and set its basic properties.

        context = Gaffer.Context.current()

        outline = Outline(
            context.substitute(self["jobName"].getValue()) or "untitled",
            show=context.substitute(self["showName"].getValue()) or "show",
            shot=context.substitute(self["shotName"].getValue()) or "shot",
            user=context.substitute(self["userName"].getValue()) or "user",
        )

        # Populate the job with tasks from the batch tree
        # that was prepared by our base class.

        for upstreamBatch in rootBatch.preTasks():
            self.__buildOutlineWalk(outline, upstreamBatch, dispatchData)

        # Signal anyone who might want to make just-in-time
        # modifications to the job.

        self.preSpoolSignal()(self, outline)

        # Finally, we can spool the job.

        cuerun.launch(outline, use_pycuerun=False)
コード例 #19
0
#!/bin/env python2.5

#  Copyright (c) 2018 Sony Pictures Imageworks Inc.
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.



from outline import Outline, cuerun
from outline.modules.tutorial import HelloModule

ol = Outline("my_job")
ol.add_layer(HelloModule("my_layer"))

cuerun.launch(ol, range="1-10", pause=True)
コード例 #20
0
ファイル: doneshapes.py プロジェクト: VanHulleOne/DogBoneV2
def regularDogBone() ->Outline:    
    dogBone = Outline(None)
    dogBone.addLinesFromCoordinateList([[82.5, 0], [82.5, 9.5], [49.642, 9.5]])
    arc = a.Arc(Point(49.642, 9.5), Point(28.5, 6.5), c.CW, Point(28.5, 82.5), 20)
    dogBone.addLineGroup(arc)
    dogBone.addLinesFromCoordinateList([[28.5, 6.5], [0, 6.5]])
    dogBone.addLineGroup(dogBone.mirror(c.Y))
    dogBone.addLineGroup(dogBone.mirror(c.X))
    dogBone = dogBone.translate(82.5, 9.5)
    dogBone.finishOutline()
    return dogBone
コード例 #21
0
ファイル: main.py プロジェクト: bmbigbang/Directory
class Main(object):
    def __init__(self):
        self.main = Corrector()
        self.match = ""
        self.matchgeo = ""
        self.commands = []
        self.option = Options()
        self.display = Chunks("")
        self.display.create_Chunks()
        self.last_Display = ""
        self.find = Chunks("")
        self.find.create_Chunks()
        self.table = Outline()
        self.location_History = {}

    def run(self):
        hlp = Helper();br=True;results={};resultsort=[];correcting = False
        while br:  
            if correcting or self.matchgeo:
                pass
            else:
                command = raw_input("SMS in: ")
            if not self.matchgeo:
                t,option,word = self.process(unicode(command))
                words = t[0];disting = t[1][-1]
            if option and len(resultsort)==0:
                self.option = option;self.match = word
                if len(self.display) > 0 :
                    self.last_Display = self.display
                self.display = Chunks(self.option.print_Options())
                self.display.create_Chunks(heading="By ({0}) Did you mean: ".format(word),
                           footing="Please choose.")
                print self.display.goto_Chunk(); continue
            
            if len(self.option)>0 and len(words[0])==1:
                ch = self.option.select_Option(words[0])
                if ch!=None and len(resultsort)==0:
                    self.main.correctedHistory[self.match]=self.option[ch][2]
                    disting = t[1][-2]; 
                    k = disting['tokens'].index(self.match)
                    disting['tokens'][k] = self.option[ch][2]
                    try:
                        k = disting['words'].index(self.match)
                        disting['words'][k] = self.option[ch][2]
                        words = disting['words']
                    except:
                        disting['words'].append(self.option[ch][2])
                        words = disting['words']
                    if self.option[ch][2] == "find":
                        word = "find";self.option = Options()
                    else:
                        self.option = Options();correcting = True
                        command = " ".join(disting['tokens']); continue
                if ch!=None and type(resultsort)!=unicode:
                    text = "{0} - Ratings : {1}".format(resultsort[ch][0],resultsort[ch][1])
                    text += "\n" +" Telephone Number: " + results[resultsort[ch][0]][1]
                    text += "\n Address: "+results[resultsort[ch][0]][0]
                    self.display = Chunks(text)
                    self.display.create_Chunks()
                    print self.display.goto_Chunk()
                    self.option = Options();continue
                if ch!=None and type(resultsort)==unicode:
                    self.matchgeo = [results[ch]]; self.location_History[resultsort] = [results[ch]]
                    disting = t[1][-2]; words = disting['words'];self.option = Options()
                    continue

            correcting = False
                               
            if word == "find" or "find" in words:
                if word == "find":
                    self.find = self.last_Display
                else:
                    self.find = self.display
                expand = self.find.find_Chunks(" ".join([i for i in disting['tokens'] if i!="find"]))
                if expand!=False:
                    self.find.chunk_list = expand
                    print self.find.goto_Chunk()
                else:
                    print "No results found"
                continue
            
            for k in range(len(words)):
                dirfin = finder(r'directory|places',words[k])   
                if dirfin.found():
                    if "list" in words:
                        self.display = Chunks(",".join(hlp.dirtypes()).replace("_"," "))
                        self.display.create_Chunks(heading="List of types of places:")
                        print self.display.goto_Chunk(); break
                    direc=Directory([i for i in words if i!="directory" or i!="places"])
                    if len(self.matchgeo) > 0:
                        direc.locs=self.matchgeo; self.matchgeo = ""
                    results,resultsort = direc.run(disting,self.location_History)
                    if results == None:
                        break
                    elif type(resultsort) == unicode:
                        for i in results:
                            self.option.add_Option(content="{0}".format(i[0].encode('utf-8')))
                        self.display = Chunks(self.option.print_Options())
                        self.display.create_Chunks(heading="By {0} did you mean:".format(str(resultsort)),
                              footing="Please choose a location. ")
                        print self.display.goto_Chunk(); break                        
                            
                    for i in resultsort:
                        self.option.add_Option(content="{0} - Ratings : {1}".format(i[0].encode('utf-8'),str(i[1])))
                    self.display = Chunks(self.option.print_Options())
                    self.display.create_Chunks(heading="Nearby places:",
                              footing="Choose for more details. ")
                    print self.display.goto_Chunk(); break     
                        
                outfin = finder(r'outline',words[k])
                if outfin.found():
                    with open("textblock.txt","rb") as f:
                        textblock= f.read().decode("string_escape")
                    for i in range(len(textblock)):
                        if textblock[i:i+2] == "\u":   
                            textblock= textblock[:i]+unichr(int(textblock[i+2:i+6],base=16)).encode("utf-8")  +textblock[i+6:]
                    f.close()
                    self.table.add_TxtBlock(textblock)
                    if self.table.run([i for i in words if i !="outline"],disting['numbers']) != False:
                        self.display = self.table.run([i for i in words if i !="outline"],disting['numbers'])
                        print self.display.goto_Chunk(); break
                
                exifin = finder(r'exit',words[k])
                if exifin.found():
                    br=False;break   
                helpfin = finder(r'help',words[k])
                if helpfin.found():
                    print hlp;break
                
                if "next" in words[k]:
                    print self.display.next_Chunk(); break
                
                if "goto" in words[k]:
                    try:
                        n = disting['numbers'][0]
                        num = int(n)
                    except:
                        num = -1
                    print self.display.goto_Chunk(num); break

    def process(self,command):
        opts = [];self.main.disting(command)
        for i in self.main.cur()['words']+self.main.cur()['splits']:
            for j in self.main.match(i):
                if j[0]=='None':
                    continue
                if j[1]==0:
                    try:
                        k = self.main.cur()['words'].index(i)
                        self.main.cur()['words'][k] = j[0]
                    except:
                        self.main.cur()['words'].append(j[0])
                    continue
                        
                if opts == []:
                    opts = Options()
                opts.add_Option(content="{0}".format(j[0]))
            
            if opts:
                return [self.main.cur()['words'],self.main.history],opts,i
                
        return [self.main.cur()['words'],self.main.history],opts,""
コード例 #22
0
ファイル: multiregion.py プロジェクト: GokberkSERIN/deneme
secAngs = []
meshes = []

with open(path + paramFile, 'r') as fp:
    data = json.load(fp)

params = Parameters(data[0], data[1])

for fname, color, angle in zip(fnames, colors, angles):
    mesh = trimesh.load_mesh(path + fname)
    meshes.append(mesh)
    section = mesh.section(plane_origin=[0, 0, 0.01], plane_normal=[0, 0, 1])
    loops = section.discrete
    for loop in loops:
        outline = Outline()
        outline._name = fname
        outline.addCoordLoop(loop * 1000)  # 1000 to convert from meters to mm
        outline = outline.translate(-50, -12)
        secAngs.append(SecAng(Section(outline), angle))
        plt.plot(loop[:, 0] - 0.050, loop[:, 1] - 0.012, color)

params.outline = [tuple(secAngs)]
gCode = Gcode(params)

plt.show()


def run():
    startTime = time.time()
    print('\nGenerating code, please wait...')
コード例 #23
0
ファイル: doneshapes.py プロジェクト: VanHulleOne/DogBoneV2
def wideDogBone(gageWidth: float) ->Outline:
    halfWidth = gageWidth / 2.0    
    wideDogBone = Outline(None)
    wideDogBone.addLinesFromCoordinateList([[82.5, 0], [82.5, 9.5 + halfWidth],
                                            [49.642, 9.5 + halfWidth]])
    wideArc = a.Arc(Point(49.642, 9.5 + halfWidth),
                    Point(28.5, 6.5 + halfWidth), c.CW,
                    Point(28.5, 82.5 + halfWidth), 20)
    wideDogBone.addLineGroup(wideArc)
    wideDogBone.addLinesFromCoordinateList([[28.5, 6.5 + halfWidth], [0, 6.5 + halfWidth]])
    wideDogBone.addLineGroup(wideDogBone.mirror(c.Y))
    wideDogBone.addLineGroup(wideDogBone.mirror(c.X))
    return wideDogBone.translate(82.5, 9.5 + halfWidth)
コード例 #24
0
ファイル: doneshapes.py プロジェクト: VanHulleOne/DogBoneV2
def rightGrip():# ->Outline:
    outline = Outline(None)
    outline.addLinesFromCoordinateList([[82.5, 0], [82.5, 9.5], [49.642, 9.5]])
    arc = a.Arc(Point(49.642, 9.5), Point(28.5, 6.5), c.CW, Point(28.5, 82.5), 20)
    outline.addLineGroup(arc)
    outline.addLinesFromCoordinateList([[28.5, 6.5], [28.5, 0]])
    outline.addLineGroup(outline.mirror(c.X)) 
    return outline.translate(82.5, 9.5)
コード例 #25
0
def main():
    global images_clusters
    global frame_rhs

    root = Tk()
    root.title("Etsy")
    root.configure(background="white")
    # style configuration
    style = ttk.Style(root)
    style.configure('TLabel', background='white')
    style.configure('TFrame', background='white')

    screen_height = monitor_height(root)
    WINDOW_HEIGHT = screen_height - 130
    print(f"Screen height: {screen_height} window height: {WINDOW_HEIGHT}")

    if False:
        image_files = glob.glob(IMAGE_FOLDER + "/*/*/*.jpg")
        print(f"Found {len(image_files)}")
        print(image_files[0], image_files[550])

    dpi_value = root.winfo_fpixels('1i')
    print(f"Default dpi: {dpi_value}")
    # dpi_value = 400
    # root.tk.call('tk', 'scaling', '-displayof', '.', dpi_value / 72.0)
    root.tk.call('tk', 'scaling', '-displayof', '.', 4.0)
    # root.maxsize(1500, 400)
    root.grid_rowconfigure(0, weight=1)
    root.columnconfigure(0, weight=1)

    # content = Frame(root, bg="white", borderwidth=0, highlightbackground="white", highlightcolor="white")
    content, canvas = create_frame_with_scroll(root, 0, 0, WINDOW_WIDTH,
                                               WINDOW_HEIGHT)

    etsy_top_frame = Frame(content,
                           borderwidth=0,
                           width=RHS_WIDTH,
                           height=200,
                           bg="white")
    frame_lhs = ttk.Frame(content, borderwidth=0, width=LHS_WIDTH, height=400)
    # frame_lhs = create_frame_with_scroll(content, 0, 1, LHS_WIDTH, WINDOW_HEIGHT)
    frame_lhs_outlines = Frame(frame_lhs, bg="white", borderwidth=0)
    etsy_lhs_frame = Frame(frame_lhs,
                           borderwidth=0,
                           highlightbackground="white",
                           highlightcolor="white",
                           width=LHS_WIDTH,
                           height=200,
                           bg="white")

    # frame_rhs = create_frame_with_scroll(content, 2, 1, RHS_WIDTH, WINDOW_HEIGHT)
    frame_rhs = Frame(content, bg="white")

    # This commented line screws up the scrolling
    # content.grid(column=0, row=0)
    etsy_top_frame.grid(column=0, row=0, columnspan=5, sticky='NW')
    frame_lhs.grid(column=0, row=1, padx=0, pady=0, sticky='N')
    frame_lhs_outlines.grid(column=0, row=1, sticky=N + S + E + W)
    etsy_lhs_frame.grid(column=0, row=0, sticky='N')
    frame_rhs.grid(column=2, row=1, sticky='N')

    num_outlines = len(get_files_in_folder(OUTLINE_FOLDER, '.jpg'))
    num_outlines_per_col = round(num_outlines / NUM_OUTLINE_COLS)
    print(f"Num outlines per col: {num_outlines_per_col}")

    images_clusters = read_outline_json()
    Outline.set_canvas(canvas)
    Outline.set_clusters(images_clusters)
    Outline.set_frame(frame_rhs)
    display_outlines(frame_lhs_outlines, OUTLINE_FOLDER, num_outlines_per_col,
                     NUM_OUTLINE_COLS, Outline)

    add_tile_to_frame(etsy_top_frame, 'etsyFrame/topFrame.png')
    add_tile_to_frame(etsy_lhs_frame, 'etsyFrame/Etsy-Filter-version2.png')
    add_image_to_frame(frame_rhs, 'etsyFrame/etsy-num-results.png', 0, 0)
    add_image_to_frame(frame_rhs, 'etsyFrame/1st-background-small.png', 1, 0)
    add_image_to_frame(frame_rhs, 'etsyFrame/2nd-background-small.png', 2, 0)
    add_image_to_frame(frame_rhs, 'etsyFrame/3rd-background-small.png', 3, 0)
    add_image_to_frame(frame_rhs, 'etsyFrame/4th-background-small.png', 4, 0)
    # display_images(frame_rhs, images_clusters['outline21.jpg'], 15, 4)

    root.mainloop()
コード例 #26
0
def regularDogBoneFillet(scale: float) -> Outline:
    dogBoneF = Outline(None)
    dogBoneF.addLinesFromCoordinateList([[82.5, 0], [82.5, 4.5]])
    arc = a.Arc(Point(82.5, 4.5), Point(77.5, 9.5), c.CCW, Point(77.5, 4.5),
                6)  #5mm fillet
    dogBoneF.addLineGroup(arc)
    dogBoneF.addLinesFromCoordinateList([[77.5, 9.5], [49.642, 9.5]])
    arc = a.Arc(Point(49.642, 9.5), Point(28.5, 6.5), c.CW, Point(28.5, 82.5),
                20)
    dogBoneF.addLineGroup(arc)
    dogBoneF.addLinesFromCoordinateList([[28.5, 6.5], [0, 6.5]])
    dogBoneF.addLineGroup(dogBoneF.mirror(c.Y))
    dogBoneF.addLineGroup(dogBoneF.mirror(c.X))
    dogBoneF = dogBoneF.translate(82.5, 9.5)
    dogBoneF.finishOutline()
    dogBoneF = dogBoneF.scale(scale)
    dogBoneF._name = 'regularDogBoneFillet'
    return dogBoneF
コード例 #27
0
ファイル: infill.py プロジェクト: VanHulleOne/DogBoneV2
class Infill(LineGroup):
    
   
    
    def __init__(self, trimOutline, pathWidth, angleDegrees, shiftX=0, shiftY=0,
                 design=None, designType=c.PARTIAL_ROW):
        LineGroup.__init__(self, None)
        self.shiftX = shiftX
        self.shiftY = shiftY
        self.designType = designType
        self.trimOutline = Outline(trimOutline)
        self.angleRad = (angleDegrees/360.0*2*np.pi)
        self.pathWidth = pathWidth
        lowerLeft = Point(self.trimOutline.minX, self.trimOutline.minY)
        upperRight = Point(self.trimOutline.maxX, self.trimOutline.maxY)
        
        self.trimDiagonal = (lowerLeft - upperRight)*1.1       
        self.operations = (self.extendDesign, self.createField,
                           self.centerAndRotateField, self.trimField)
        
        try:
            self.design = design(space = self.pathWidth,
                                 length = self.trimDiagonal,
                                 height = self.trimDiagonal,
                                 ) 
            self.designType = c.FULL_FIELD
        except Exception:
            self.design = LineGroup(design)
        
#        print('\nInfill times:') 
        for i in range(self.designType, c.TRIMMED_FIELD):
            startTime = time.time()
            self.operations[i]();
#            print((self.operations[i].__name__ +
#                    ''.ljust(maxLength - len(self.operations[i].__name__)) +
#                    '%.2f sec' %(time.time()-startTime)))
        
    def extendDesign(self):
        tempDesign = LineGroup(self.design.lines)
        designWidth = self.design.maxX - self.design.minX        
        while(designWidth <= self.trimDiagonal):
            shiftX = self.design[-1].end.x - tempDesign[0].start.x
            shiftY = self.design[-1].end.y - tempDesign[0].start.y
            self.design.addLineGroup(tempDesign.translate(shiftX, shiftY))
            designWidth = self.design.maxX - self.design.minX
        
    def createField(self):
        tempDesign = self.design.translate(0, self.pathWidth)
        designHeight = 0 # abs(self.design.maxY - self.design.minY)
        while(designHeight < self.trimDiagonal):
            self.design.addLineGroup(tempDesign)
            tempDesign = tempDesign.translate(0, self.pathWidth)
            designHeight += self.pathWidth
    
    def centerAndRotateField(self):
        designCP = self.design.getMidPoint()
        trimOutlineCP = self.trimOutline.getMidPoint()
        transX = trimOutlineCP.x - designCP.x
        transY = trimOutlineCP.y - designCP.y
        self.design = self.design.transform(mt.combineTransformations(
                        [mt.translateMatrix(transX+self.shiftX, transY+self.shiftY),
                         mt.rotateMatrix(self.angleRad, trimOutlineCP)]))
                         
    def trimField(self):
        trimStarts = self.trimOutline.starts
        trimVectors = self.trimOutline.vectors
        fieldStarts = self.design.starts
        fieldVectors = self.design.vectors
        trimLen = len(self.trimOutline)
        fieldLen = len(self.design)
        Q_Less_P = fieldStarts - trimStarts.reshape(trimLen,1,2)
        denom = np.cross(trimVectors, fieldVectors.reshape(fieldLen,1,2))
        all_t = np.cross(Q_Less_P, trimVectors.reshape(trimLen,1,2)).transpose()/denom
        all_u = np.cross(Q_Less_P, fieldVectors).transpose()/denom
        
        for t, u, line in zip(all_t, all_u, self.design):
            if not self.trimOutline.lineOutsideBoundingBox(line):
                pointSet = set([line.start])
                t = t[(0 <= u) & (u <= 1) & (0 <= t) & (t <= 1)]

                pointSet |= set(Point(line.start.x + line.vector[c.X]*value,
                                    line.start.y+line.vector[c.Y]*value)
                                    for value in t)

                pointSet.add(line.end)
                pointList = sorted(list(pointSet))
                pointVectors = np.array([point.normalVector for point in pointList])
                
                """ Calculation for midPoints from here:
                http://stackoverflow.com/questions/23855976/middle-point-of-each-pair-of-an-numpy-array
                """
                midPoints = (pointVectors[1:] + pointVectors[:-1])/2.0
                for i in range(len(midPoints)):
                    if self.trimOutline.isInside(midPoints[i]):
                        self.append(Line(pointList[i], pointList[i+1]))
コード例 #28
0
def typeVDogBone(scale: float) -> Outline:
    typeV = Outline(None)
    typeV.addLinesFromCoordinateList([[31.75, 0], [31.75, 3.77]])
    arc = a.Arc(Point(31.75, 3.77), Point(30.75, 4.77), c.CCW,
                Point(30.75, 3.77), 5)  #1mm fillet
    typeV.addLineGroup(arc)
    typeV.addLinesFromCoordinateList([[30.75, 4.77], [13.17, 4.77]])
    arc = a.Arc(Point(13.17, 4.77), Point(4.77, 1.59), c.CW,
                Point(4.77, 14.29))
    typeV.addLineGroup(arc)
    typeV.addLinesFromCoordinateList([[4.77, 1.59], [0, 1.59]])
    typeV.addLineGroup(typeV.mirror(c.Y))
    typeV.addLineGroup(typeV.mirror(c.X))
    typeV = typeV.translate(31.75, 4.77)
    typeV.finishOutline()
    typeV = typeV.scale(scale)
    typeV._name = 'typeVDogBone'
    return typeV
コード例 #29
0
def circle(centerX: float, centerY: float, radius: float) -> Outline:
    startPoint = Point(centerX + radius, centerY)
    center = Point(centerX, centerY)
    return Outline(a.Arc(startPoint, startPoint, c.CW, center, numPoints=40))
コード例 #30
0
class Infill(LineGroup):
    def __init__(self,
                 trimOutline,
                 pathWidth,
                 angleDegrees,
                 shiftX=0,
                 shiftY=0,
                 design=None,
                 designType=c.PARTIAL_ROW):
        LineGroup.__init__(self, None)
        self.shiftX = shiftX
        self.shiftY = shiftY
        self.designType = designType
        self.trimOutline = Outline(trimOutline)
        self.angleRad = (angleDegrees / 360.0 * 2 * np.pi)
        self.pathWidth = pathWidth
        lowerLeft = Point(self.trimOutline.minX, self.trimOutline.minY)
        upperRight = Point(self.trimOutline.maxX, self.trimOutline.maxY)

        self.trimDiagonal = (lowerLeft - upperRight) * 1.1
        self.operations = (self.extendDesign, self.createField,
                           self.centerAndRotateField, self.trimField)

        try:
            self.design = design(
                space=self.pathWidth,
                length=self.trimDiagonal,
                height=self.trimDiagonal,
            )
            self.designType = c.FULL_FIELD
        except Exception:
            self.design = LineGroup(design)

#        print('\nInfill times:')
        for i in range(self.designType, c.TRIMMED_FIELD):
            startTime = time.time()
            self.operations[i]()
#            print((self.operations[i].__name__ +
#                    ''.ljust(maxLength - len(self.operations[i].__name__)) +
#                    '%.2f sec' %(time.time()-startTime)))

    def extendDesign(self):
        tempDesign = LineGroup(self.design.lines)
        designWidth = self.design.maxX - self.design.minX
        while (designWidth <= self.trimDiagonal):
            shiftX = self.design[-1].end.x - tempDesign[0].start.x
            shiftY = self.design[-1].end.y - tempDesign[0].start.y
            self.design.addLineGroup(tempDesign.translate(shiftX, shiftY))
            designWidth = self.design.maxX - self.design.minX

    def createField(self):
        tempDesign = self.design.translate(0, self.pathWidth)
        designHeight = 0  # abs(self.design.maxY - self.design.minY)
        while (designHeight < self.trimDiagonal):
            self.design.addLineGroup(tempDesign)
            tempDesign = tempDesign.translate(0, self.pathWidth)
            designHeight += self.pathWidth

    def centerAndRotateField(self):
        designCP = self.design.getMidPoint()
        trimOutlineCP = self.trimOutline.getMidPoint()
        transX = trimOutlineCP.x - designCP.x
        transY = trimOutlineCP.y - designCP.y
        self.design = self.design.transform(
            mt.combineTransformations([
                mt.translateMatrix(transX + self.shiftX, transY + self.shiftY),
                mt.rotateMatrix(self.angleRad, trimOutlineCP)
            ]))

    def trimField(self):
        trimStarts = self.trimOutline.starts
        trimVectors = self.trimOutline.vectors
        fieldStarts = self.design.starts
        fieldVectors = self.design.vectors
        trimLen = len(self.trimOutline)
        fieldLen = len(self.design)
        Q_Less_P = fieldStarts - trimStarts.reshape(trimLen, 1, 2)
        denom = np.cross(trimVectors, fieldVectors.reshape(fieldLen, 1, 2))
        all_t = np.cross(Q_Less_P, trimVectors.reshape(trimLen, 1,
                                                       2)).transpose() / denom
        all_u = np.cross(Q_Less_P, fieldVectors).transpose() / denom

        for t, u, line in zip(all_t, all_u, self.design):
            if not self.trimOutline.lineOutsideBoundingBox(line):
                pointSet = set([line.start])
                t = t[(0 <= u) & (u <= 1) & (0 <= t) & (t <= 1)]

                pointSet |= set(
                    Point(line.start.x +
                          line.vector[c.X] * value, line.start.y +
                          line.vector[c.Y] * value) for value in t)

                pointSet.add(line.end)
                pointList = sorted(list(pointSet))
                pointVectors = np.array(
                    [point.normalVector for point in pointList])
                """ Calculation for midPoints from here:
                http://stackoverflow.com/questions/23855976/middle-point-of-each-pair-of-an-numpy-array
                """
                midPoints = (pointVectors[1:] + pointVectors[:-1]) / 2.0
                for i in range(len(midPoints)):
                    if self.trimOutline.isInside(midPoints[i]):
                        self.append(Line(pointList[i], pointList[i + 1]))
コード例 #31
0
def center() -> Outline:
    outline = Outline(None)
    outline.addLinesFromCoordinateList([[28.5, 6.5], [-28.5,
                                                      6.5], [-28.5, -6.5],
                                        [28.5, -6.5], [28.5, 6.5]])
    return outline.translate(82.5, 9.5)
コード例 #32
0
def rightGrip() -> Outline:
    outline = Outline(None)
    outline.addLinesFromCoordinateList([[82.5, 0], [82.5, 9.5], [49.642, 9.5]])
    arc = a.Arc(Point(49.642, 9.5), Point(28.5, 6.5), c.CW, Point(28.5, 82.5),
                20)
    outline.addLineGroup(arc)
    outline.addLinesFromCoordinateList([[28.5, 6.5], [28.5, 0]])
    outline.addLineGroup(outline.mirror(c.X))
    return outline.translate(82.5, 9.5)
コード例 #33
0
        return cv.divide(gray, 255 - blur, scale=256)


# Open the image
img = Image.open(filename)

# Get the image after applying the Drawing class to it
# This will create the image as a lighter pencil sketch, with background noise nor major edge detection applied
drawing = Drawing(filename).drawing()
cv.imwrite("drawing.png", drawing)

# Apply background noise to image (see background_noise.py for process)
background = BackgroundNoise(img.size, levels=6).background_noise()

# Apply outline to image (see outline.py for process)
outline = Outline(filename).outline()

# Set the mask as the third matrix created by the outline function
mask = outline[3]

# Combine the outline (major edges) with the light pencil sketch to accentuate the major edges
drawing = cv.bitwise_and(drawing, outline, outline)

# Threshold is set to each pixel in the drawing. If the pixel value is set below the threshold (240) assigned 0. 255 is the max which is assigned to pixel values
# exceeding the threshold. THRESH_BINARY applies a simple piece-wise function to apply the threshold:
# dst(x,y) = {maxval    if src(x,y) > threshold}
#            {0         otherwise}
(threshold, drawing) = cv.threshold(drawing, 240, 255, cv.THRESH_BINARY)

# The height and width are set to the current image dimensions
height, width = drawing.shape[:2]
コード例 #34
0
ファイル: doneshapes.py プロジェクト: VanHulleOne/DogBoneV2
def squareWithHole() ->Outline:
    outline = Outline(None)
    outline.addLinesFromCoordinateList([[0,0], [50,0], [50,50], [0,50], [0,0]])
    circle = a.Arc(Point(35,25), Point(35,25), c.CW, Point(25,25))
    outline.addLineGroup(circle)
    return outline
コード例 #35
0
ファイル: doneshapes.py プロジェクト: VanHulleOne/DogBoneV2
def center():# ->Outline:
    outline = Outline(None)
    outline.addLinesFromCoordinateList([[28.5, 6.5], [-28.5, 6.5], [-28.5, -6.5],
                                      [28.5, -6.5], [28.5, 6.5]])
    return outline.translate(82.5, 9.5)
コード例 #36
0
def wideDogBone(gageWidth: float) -> Outline:
    halfWidth = gageWidth / 2.0
    wideDogBone = Outline(None)
    wideDogBone.addLinesFromCoordinateList([[82.5, 0], [82.5, 9.5 + halfWidth],
                                            [49.642, 9.5 + halfWidth]])
    wideArc = a.Arc(Point(49.642, 9.5 + halfWidth),
                    Point(28.5, 6.5 + halfWidth), c.CW,
                    Point(28.5, 82.5 + halfWidth), 20)
    wideDogBone.addLineGroup(wideArc)
    wideDogBone.addLinesFromCoordinateList([[28.5, 6.5 + halfWidth],
                                            [0, 6.5 + halfWidth]])
    wideDogBone.addLineGroup(wideDogBone.mirror(c.Y))
    wideDogBone.addLineGroup(wideDogBone.mirror(c.X))
    return wideDogBone.translate(82.5, 9.5 + halfWidth)
コード例 #37
0
def regularDogBone() -> Outline:
    dogBone = Outline(None)
    dogBone.addLinesFromCoordinateList([[82.5, 0], [82.5, 9.5], [49.642, 9.5]])
    arc = a.Arc(Point(49.642, 9.5), Point(28.5, 6.5), c.CW, Point(28.5, 82.5),
                20)
    dogBone.addLineGroup(arc)
    dogBone.addLinesFromCoordinateList([[28.5, 6.5], [0, 6.5]])
    dogBone.addLineGroup(dogBone.mirror(c.Y))
    dogBone.addLineGroup(dogBone.mirror(c.X))
    dogBone = dogBone.translate(82.5, 9.5)
    dogBone.finishOutline()
    dogBone._name = 'regularDogBone'
    return dogBone