コード例 #1
0
def screen_capture(material, fname, camera=None, render_options=None):
    from Renderers import RenderOptions, SimpleRenderer
    from Canvas import Canvas
    from wx import PySimpleApp, Frame

    if render_options:
        options = render_options
    else:
        options = RenderOptions()
    shapes = SimpleRenderer(material.geo, options)

    app = PySimpleApp()
    if camera:
        win = Frame(None, -1, "empty", size=camera.get_size())
        glc = Canvas(win, -1)
        glc.SetClientSize(camera.get_size())
        glc.OnSize()
    else:
        win = Frame(None, -1, "empty", size=(400, 400))
        glc = Canvas(win, -1)
    win.Show()
    glc.Hide()
    win.Hide()
    glc.setup_lights()
    if camera:
        glc.camera = camera
        glc.newshapes(shapes, 0)
    else:
        glc.newshapes(shapes, 1)
    glc.setup_camera()
    glc.OnDraw()
    glc.dump_to_file(fname)
    return
コード例 #2
0
ファイル: tests.py プロジェクト: enra64/iot-ledmatrix
def test_canvas_font():
    print(inspect.currentframe().f_code.co_name)
    c = Canvas(10, 10, 0)
    c.set_font("helvetica.otf", 13)
    blue = Color(0, 0, 255)
    c.draw_text("h", 0, 0, blue)
    print(repr(c))
コード例 #3
0
    def test_adjust_axes_2(self):
        '''
        load 'clt.nc', load 'u' variable, load 'v' variable, adjust sliders, load, and plot.
        '''
        print("\n\n...test_adjust_axes_2...")

        left_side_bar = self.load_data_file("clt.nc")

        load_variable_pop_up = LoadVariablePopUp(self.driver)
        load_variable_pop_up.click_on_var('u')
        load_variable_pop_up.click_on_var_axes('u')
        # adjust the min slider by 20 percent and max slider by 20 percent.
        load_variable_pop_up.adjust_var_axes_slider('u', 'longitude1', 20, -20)

        load_variable_pop_up.click_on_var('v')
        load_variable_pop_up.click_on_var_axes('v')
        # adjust the min slider by 20 percent and max slider by 20 percent.
        load_variable_pop_up.adjust_var_axes_slider('v', 'longitude2', 20, -20)

        load_variable_pop_up.load()
        left_side_bar.select_plot_type("streamline (default)")

        left_side_bar.click_on_plot()
        canvas = Canvas(self.driver)
        canvas.check_plot()
コード例 #4
0
ファイル: test_canvas.py プロジェクト: OptimumDev/Vanilla
def test_canvas_flip_vertically():
    canvas = Canvas(1, 2)
    canvas.paint_pixel(0, 0, red)
    canvas.paint_pixel(0, 1, blue)
    canvas.select(0, 0, 0, 1)
    canvas.flip_vertically()
    assert canvas.pixels[0][0] == blue
コード例 #5
0
def main(argv):
    print('Start Working...')
    LabelID = LoadLabelsFromFile(argv[-3])
    SubLabelID = LoadLabelsFromFile(argv[-2])
    cv2.namedWindow(winName, cv2.WINDOW_AUTOSIZE)

    caps = []
    for v in argv[:-4]:
        caps.append(LoadVideo(v))

    recordsList = ReadAllRecordsIntoList(argv[-4])
    start = 0
    if len(recordsList) != 0:
        start = recordsList[-1][0] + 1

    updateFramesFlag = False

    canvas = Canvas(2150, 900, caps, 30, 2, winName, LabelID, SubLabelID,
                    updateFramesFlag)
    canvas.DumpRecordsToFrames(recordsList)
    canvas.LoadVideos()
    test = canvas.GetFrames()
    canvas.TestFrames()

    #while start < len(test):
    #for t in test:
    #	tuplet = test[start].constructTuple()
    #	recordsList.append(tuplet)
    #	start+=1
    recordsList = canvas.ConvertFramesToSimpleList()
    if updateFramesFlag:
        WriteToFile(recordsList, argv[-4], updateFramesFlag)
    else:
        WriteToFile(recordsList, argv[-1], updateFramesFlag)
コード例 #6
0
def main():
    robot = Robot()
    canvas = Canvas()
    navigator = WaypointNavigator(robot);
    
    while True:
        navigator.navigateToWaypoint(*getWayPoint())
コード例 #7
0
 def _import_txt_triggered(self):
     path = QFileDialog.getOpenFileName(self)[0]
     self._mesh = FileHandler.load_mesh(path)
     self._width.setText(str(self._mesh.get_size().width()))
     self._height.setText(str(self._mesh.get_size().height()))
     self._canvas = Canvas(self.get_canvas__geometry(), self._mesh)
     self._canvas.show()
コード例 #8
0
ファイル: test_canvas.py プロジェクト: OptimumDev/Vanilla
def test_canvas_flip_horizontally():
    canvas = Canvas(2, 1)
    canvas.paint_pixel(0, 0, red)
    canvas.paint_pixel(1, 0, blue)
    canvas.select(0, 0, 1, 0)
    canvas.flip_horizontally()
    assert canvas.pixels[0][0] == blue
コード例 #9
0
ファイル: RoarAssetsWindow.py プロジェクト: lalbornoz/roar
 def _removeAsset(self, idx):
     del self.canvasList[idx]
     self.listView.DeleteItem(idx)
     itemCount = self.listView.GetItemCount()
     if itemCount > 0:
         self.listView.Select(self.currentIndex, on=0)
         for numCanvas in [
                 n for n in sorted(self.canvasList.keys()) if n >= idx
         ]:
             self.canvasList[numCanvas - 1] = self.canvasList[numCanvas]
             del self.canvasList[numCanvas]
         [
             self.listView.SetColumnWidth(col, wx.LIST_AUTOSIZE)
             for col in (0, 1)
         ]
         if (idx == 0) or (idx >= itemCount):
             idx = 0 if itemCount > 0 else None
         else:
             idx = idx if idx < itemCount else None
         self.currentIndex = idx
         if self.currentIndex != None:
             self.listView.Select(self.currentIndex, on=1)
             self.drawCanvas(self.canvasList[self.currentIndex][0])
     else:
         self.currentIndex = None
         [
             self.listView.SetColumnWidth(col, wx.LIST_AUTOSIZE_USEHEADER)
             for col in (0, 1)
         ]
         self.drawCanvas(Canvas((0, 0)))
     return self.currentIndex
コード例 #10
0
ファイル: test_canvas.py プロジェクト: OptimumDev/Vanilla
def test_turn_right():
    canvas = Canvas(3, 3)
    canvas.paint_pixel(1, 0)
    canvas.paint_pixel(1, 1)
    canvas.paint_pixel(1, 2)
    canvas.select(0, 0, 2, 2)
    canvas.turn_selection_right()
    assert canvas.pixels[0][1] == canvas.current_color
コード例 #11
0
ファイル: Engine.py プロジェクト: MannyIOI/Air-Hockey-Game-Py
 def __init__(self):
     self.canvas = Canvas(self)
     self.p1 = Circle(pos=[0, 0.8, 0], radius=0.2, color=[1, 0, 0])
     self.p2 = Circle(pos=[0, -0.8, 0], radius=0.2, color=[0, 0, 1])
     self.ball = Circle(pos=[0, 0, 0], radius=0.1, color=[0, 1, 1])
     # self.canvas = canvas
     self.movePuck = False
     self.deg = 0
コード例 #12
0
ファイル: tests.py プロジェクト: enra64/iot-ledmatrix
def test_canvas_rect():
    print(inspect.currentframe().f_code.co_name)
    c = Canvas(10, 10, 0)

    blue = Color(0, 0, 255)

    c.draw_rect(2, 2, 4, 4, blue)
    print(repr(c))
コード例 #13
0
 def _gen_space_btn_clicked(self):
     width = int(self._width.text())
     height = int(self._height.text())
     if self._canvas:
         self._canvas.close()
     self._mesh = Mesh(width, height, PROB)
     self._canvas = Canvas(self.get_canvas__geometry(), self._mesh)
     self._canvas.show()
コード例 #14
0
 def clear_btn_clicked(self):
     width = int(self._width.text())
     height = int(self._height.text())
     prob_rule4 = int(self._prob_rule4.text())
     self._mesh = Mesh(width, height, prob_rule4)
     self._canvas.close()
     self._canvas = Canvas(self.get_canvas__geometry(), self._mesh)
     self._canvas.show()
     self._canvas.repaint()
コード例 #15
0
ファイル: tests.py プロジェクト: enra64/iot-ledmatrix
def test_canvas_pixel_line():
    print(inspect.currentframe().f_code.co_name)
    c = Canvas(10, 10, 0)

    blue = Color(0, 0, 255)

    for i in range(c.width - 1, 0 - 1, -1):
        c.draw_pixel(9 - i, i, blue)
        print(repr(c))
コード例 #16
0
    def open(self):
       
        fileName, _ = QFileDialog.getOpenFileName(self, "Open Geotiff File",
                 QDir.currentPath(),"tif (*.tif*);;TIFF (*.TIF*)")

        if fileName:
            dsr = gdal.Open(fileName)
            np_array = np.array(dsr.ReadAsArray())
            if np_array.shape[0]==4:
                np_array=np_array[0]
            np_array_uint8 = (np_array).astype(np.uint8)

            self.geotiffScale=dsr.GetGeoTransform()[1]
            print(self.geotiffScale)

            self.setToAllBt(True)
            width,height=dsr.RasterXSize,dsr.RasterYSize
            self.aspect=Decimal(float(height)/float(width))
            minabs=100
            if width>height:
                minh=3450
                for i in range(3450,3550,1):
                   if  abs(Decimal(i*self.aspect)-int(i*self.aspect))<minabs:
                       minabs=abs(Decimal(i*self.aspect)-int(i*self.aspect))
                       minh=i
                newHeight=minh
                newWidth=Decimal(newHeight*self.aspect)       
            else:
                minw=3450
                for i in range(3450,3550,1):
                   if  abs(Decimal(i*self.aspect)-int(i*self.aspect))<minabs:
                       minabs=abs(Decimal(i*self.aspect)-int(i*self.aspect))
                       minw=i
                newWidth=minw
                newHeight=Decimal(newWidth*self.aspect)
            self.resizeFactorWidth=Decimal(width/newWidth)
            self.resizeFactorHeight=Decimal(height/newHeight)  
            self.imageLabel =Canvas(np_array_uint8,newWidth,newHeight,self.resizeFactorWidth,self.resizeFactorHeight,self.geotiffScale)
            self.imageLabel.setScale(1)
            self.imageLabel.setMouseTracking(True)
            widget = QWidget(self)
            layout = QHBoxLayout(widget)
            self.leftScroll = Pane(
            Qt.AlignTop | Qt.AlignLeft, self)
            self.leftScroll.setWidgetResizable(True)
            self.scrollBars = {
            Qt.Vertical:  self.leftScroll.verticalScrollBar(),
            Qt.Horizontal: self.leftScroll.horizontalScrollBar()
           }
            self.leftScroll.addWidget(self.imageLabel)
            self.scaleFactor = 1.0
            layout.addWidget(self.leftScroll)

            self.setCentralWidget(widget)
            self.imageLabel.update()
            self.ruler.setEnabled(True)
コード例 #17
0
def generate(
        course_name, quiz_number, output_dir, template_file, recipients_file, token_file, s
):
    """Driver/interface function for generating a report.
    """
    # Create directories if needed
    figures_dir = Path(output_dir / "figures")
    for d in [output_dir, figures_dir]:
        export.create_dir(d)

    # Use a stale dataset, or grab a fresh one
    if s is True:
        print("Loading contents from file...")
        with open("contents.json", "r") as f:
            contents = json.load(f)
    else:
        print("Fetching data from Canvas...")
        with token_file.open("r") as f:
            token = f.read()
        c = Canvas("asu.instructure.com", "v1", token)
        report_df = c.get_quiz_report(course_name, quiz_number)
        print("Fetch complete.")
        contents = data_processing.generate_report_contents(
            c, report_df, quiz_number, figures_dir, recipients_file
        )
        with open("contents.json", "w+") as f:
            json.dump(contents, f)

    # Render LaTeX template
    print("Rendering LaTeX Template...")
    env = make_env(loader=FileSystemLoader(str(template_file.parent)))
    tpl = env.get_template(str(template_file.name))
    rendered_latex = tpl.render(contents=contents)
    print("Render complete.")

    # Typeset PDF
    print("Typesetting PDF...")
    base_filename = f"muddy_points_{contents.get('quiz_number')}"
    pdf_filename = Path(output_dir / f"{base_filename}.pdf")
    pdf = build_pdf(rendered_latex, texinputs=[str(Path.cwd()), ""])
    pdf.save_to(str(pdf_filename))
    print("Typesetting complete.")

    # Export to Microsoft Word and LaTeX formats for further editing
    docx_filename = Path(output_dir / f"{base_filename}.docx")
    latex_filename = Path(output_dir / f"{base_filename}.tex")
    export.make_texfile(rendered_latex, latex_filename)
    export.make_docx(latex_filename, docx_filename)

    # Create archive
    print("Creating archive...")
    zip_filename = Path(output_dir / f"{base_filename}.zip")
    export.make_archive(
        zip_filename, [pdf_filename, docx_filename, latex_filename], figures_dir
    )
    print(f"Created archive: {zip_filename}")
コード例 #18
0
ファイル: tests.py プロジェクト: enra64/iot-ledmatrix
def test_canvas_draw_pixel_line(serial):
    print(inspect.currentframe().f_code.co_name)
    c = Canvas(156, 1, 0)

    blue = Color(0, 0, 255)

    while True:
        for i in range(c.width):
            c.draw_pixel(i, 0, blue)
            serial.update(c.get_buffer_for_arduino())
コード例 #19
0
ファイル: Player.py プロジェクト: superduperpacman42/SideKick
 def die(self):
     self.game.state = 2
     if not self.dead:
         self.progress = 0
         self.game.finalscore = self.game.score
         self.game.finalcounts = self.game.counts[:]
         self.game.stars.append(
             Canvas(self.game, "EmptySplash", (self.game.x / 2, 0)))
         self.dead = True
         self.game.playMusic("Partners_in_Crimefighting.wav")
コード例 #20
0
    def __init__(self, defaultCrypto='BTC', defaultExchange='USD'):
        super().__init__()

        self.setAutoFillBackground(True)

        fontSize = 10

        cryptoX = 320
        cryptoY = 30
        cryptoWidth = 70
        cryptoHeight = 25

        horizontalTextBoxSpace = 30

        exchangeX = cryptoX + cryptoWidth + horizontalTextBoxSpace
        exchangeY = cryptoY + cryptoHeight + 25
        exchangeWidth = cryptoWidth
        exchangeHeight = cryptoHeight

        self.canvas = Canvas(self)
        self.canvas.move(0, 0)
        self.canvas.resize(315, 300)

        labelWidth = 30
        labelCrypto = QLabel(self)
        labelCrypto.setText('Crypto')
        labelCrypto.move(cryptoX + (cryptoWidth - labelWidth) / 2.5,
                         cryptoY - 20)

        labelExchange = QLabel(self)
        labelExchange.setText('Exchange')
        labelExchange.move(cryptoX + (cryptoWidth - labelWidth) / 2.5 - 2,
                           exchangeY - 20)

        self.cryptoTextBox = TextBox(self,
                                     defaultText=defaultCrypto,
                                     placeholder='Crypto',
                                     fontSize=fontSize,
                                     x=cryptoX,
                                     y=cryptoY,
                                     width=cryptoWidth,
                                     height=cryptoHeight)
        self.exchangeTextBox = TextBox(self,
                                       defaultText=defaultExchange,
                                       placeholder='Exchange',
                                       fontSize=fontSize,
                                       x=cryptoX,
                                       y=exchangeY,
                                       width=cryptoWidth,
                                       height=exchangeHeight)

        buttonGo = QPushButton('Go', self)
        buttonGo.move(cryptoX - 2, exchangeY + exchangeHeight + 20)
        buttonGo.clicked.connect(self.updateGraph)
コード例 #21
0
    def _setupUI(self):
        # Setup sidebar
        self.sidebar = Sidebar.Sidebar(self)

        # Setup canvas
        self.canvas = Canvas(self)

        self.layout.addWidget(self.sidebar.scrollArea)
        self.layout.addWidget(self.canvas.label)

        self.sidebar.setStyleSheet(self.css.content)
コード例 #22
0
ファイル: tests.py プロジェクト: enra64/iot-ledmatrix
def test_script_handler():
    print(inspect.currentframe().f_code.co_name)
    c = Canvas(10, 10, 0)
    handler = ScriptHandler(
        c, lambda: print("draw cycle finished"),
        lambda data, client_id: print("sending " + data + " to " + client_id),
        lambda data: print("sending " + data + " to all"), __return_list)

    handler.start_script("_CustomScriptTester", "test_script_handler")
    time.sleep(.5)
    handler.stop_current_script()
コード例 #23
0
ファイル: DataManager.py プロジェクト: luoguohengcn/ignifuga
    def getImage(self, url):
        if url not in self.cache:
            if url.startswith('embedded:'):
                data = Gilbert().getEmbedded(url[9:])
                if data != None:
                    self.cache[url] = Canvas(embedded=data)
                else:
                    error('Error loading embedded data with id: %s', url)
                    return None
            else:
                self.cache[url] = Canvas(srcURL=join(ROOT_DIR, url))

#if DEBUG and (__LINUX__ or __OSX__ or __MINGW__)
                watchURL = self._urlToWatchUrl(url)
                if watchURL not in self.watches:
                    Gilbert().gameLoop.addWatch(watchURL)
                    self.watches.append(watchURL)
#endif

        return self.cache[url]
コード例 #24
0
ファイル: main.py プロジェクト: ebagirma/My_Own_QGC
 def sub_btn(self):
     #print(Canvas().chosen_points)
     perivous_x = None
     perivous_y = None
     for pos in Canvas().chosen_points:
         current_x = pos.x()
         current_y = pos.y()
         if perivous_y and perivous_x:
             plt.plot([current_x, current_y], [perivous_x, perivous_y])
         perivous_x = current_x
         perivous_y = current_y
     plt.show()
コード例 #25
0
 def __init__(self, app):
     super().__init__()
     self._app = app
     MainWindow.geometry = QRect(app.desktop().screenGeometry().width() - MENU_WIDTH, 300, MENU_WIDTH, MENU_HEIGHT)
     self._init_ui()
     self._started = False
     self._mesh = Mesh(DEF_POINTS_SIZE.width(), DEF_POINTS_SIZE.height(), PROB)
     self._canvas = Canvas(self.get_canvas__geometry(), self._mesh)
     self._nhood = NHOODS[0]
     self._periodic = False
     self._canvas.show()
     self._thread = None
コード例 #26
0
ファイル: tests.py プロジェクト: enra64/iot-ledmatrix
def test_invalid_script_name():
    print(inspect.currentframe().f_code.co_name)
    print(
        "should print or have printed an error about \"invalid-script**dafsdf\" not existing..."
    )
    c = Canvas(10, 10, 0)
    handler = ScriptHandler(
        c, lambda: print("draw cycle finished"),
        lambda data, client_id: print("sending " + data + " to " + client_id),
        lambda data: print("sending " + data + " to all"), __return_list())

    handler.start_script("invalid-script**dafsdf", "test_script_handler")
コード例 #27
0
ファイル: UI.py プロジェクト: liboyang19/stamp_fold
 def __init__(self, master=None):
     super().__init__(master)
     self.master = master
     self.pack()
     self.interface = Canvas(self)
     # Basic parameters.
     self.room_height = 0
     self.room_width = 0
     # Draw_surface
     self.draw_interface()
     # Generate room
     self.generate_room()
コード例 #28
0
ファイル: RoarAssetsWindow.py プロジェクト: lalbornoz/roar
 def _import(self, f, pathName):
     rc = False
     self.SetCursor(wx.Cursor(wx.CURSOR_WAIT))
     try:
         canvas = Canvas((0, 0))
         rc, error, newMap, newPathName, newSize = f(canvas, pathName)
         if rc:
             self.update(canvas, newSize, newMap)
     except FileNotFoundError as e:
         rc, error, newMap, newPathName, newSize = False, str(
             e), None, None, None
     self.SetCursor(wx.Cursor(wx.NullCursor))
     return rc, error, canvas, newMap, newPathName, newSize
コード例 #29
0
ファイル: main.py プロジェクト: ebagirma/My_Own_QGC
    def __init__(self):
        QMainWindow.__init__(self)
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self)

        self.ui.Canvas_box.removeWidget(self.ui.Canvas_label)
        self.ui.Canvas_label = Canvas()
        self.ui.Canvas_label.initialize()
        # We need to enable mouse tracking to follow the mouse without the button pressed.
        # self.ui.Canvas_label.setMouseTracking(True)
        # Enable focus to capture key inputs.
        #self.ui.Canvas_label.setFocusPolicy(Qt.StrongFocus)

        self.ui.Canvas_box.addWidget(self.ui.Canvas_label)

        self.ui.stackedWidget.setCurrentWidget(self.ui.Drawing_page)

        # For the Drawing page
        self.ui.Drawing.clicked.connect(self.Drawing_page)

        # For the Home Page
        self.ui.Home.clicked.connect(self.Home_page)

        # For the Video
        self.ui.Video.clicked.connect(self.Camera_feed)

        #This is for the subition on the Canvas
        self.ui.sub.clicked.connect(self.sub_btn)

        # MOVE WINDOW
        def moveWindow(event):
            # RESTORE BEFORE MOVE
            if UIFunctions.returnStatus() == 1:
                UIFunctions.maximize_restore(self)

            # IF LEFT CLICK MOVE WINDOW
            if event.buttons() == Qt.RightButton:
                self.move(self.pos() + event.globalPos() - self.dragPos)
                self.dragPos = event.globalPos()
                event.accept()

        # SET TITLE BAR
        self.ui.title_bar.mouseMoveEvent = moveWindow

        ## ==> SET UI DEFINITIONS
        UIFunctions.uiDefinitions(self)

        ## SHOW ==> MAIN WINDOW
        ########################################################################
        self.show()
コード例 #30
0
ファイル: tests.py プロジェクト: enra64/iot-ledmatrix
def test_script_handler_exception_handling():
    print(inspect.currentframe().f_code.co_name)
    print("various exceptions in the code are commented to avoid early aborts")
    print(
        "the following should only log the exceptions and abort executing the script, not die.\n"
    )
    c = Canvas(10, 10, 0)
    handler = ScriptHandler(
        c, lambda: print("draw cycle finished"),
        lambda data, client_id: print("sending " + data + " to " + client_id),
        lambda data: print("sending " + data + " to all"), __return_list)

    handler.start_script("_CustomScriptThrowExceptionsEverywhere",
                         "test_script_handler")