mirror of
https://github.com/wassname/sloth.git
synced 2026-07-16 11:21:45 +08:00
integrate annotation model and scene
This commit is contained in:
+19
-9
@@ -3,6 +3,7 @@ import sys, os
|
||||
from PyQt4.QtGui import *
|
||||
from PyQt4.QtCore import *
|
||||
from annotationscene import *
|
||||
from annotationmodel import *
|
||||
|
||||
class MainWindow(QMainWindow):
|
||||
def __init__(self, argv, parent=None):
|
||||
@@ -15,9 +16,6 @@ class MainWindow(QMainWindow):
|
||||
buttonPoint = QPushButton("Point")
|
||||
buttonPoint.clicked.connect(self.clickedPoint)
|
||||
vlayout.addWidget(buttonPoint)
|
||||
buttonLine = QPushButton("Line")
|
||||
buttonLine.clicked.connect(self.clickedLine)
|
||||
vlayout.addWidget(buttonLine)
|
||||
buttonRectangle = QPushButton("Rectangle")
|
||||
buttonRectangle.clicked.connect(self.clickedRectangle)
|
||||
vlayout.addWidget(buttonRectangle)
|
||||
@@ -28,9 +26,11 @@ class MainWindow(QMainWindow):
|
||||
|
||||
hlayout = QHBoxLayout()
|
||||
self.view_ = QGraphicsView()
|
||||
self.annotree_ = AnnotationTreeView()
|
||||
hlayout.addLayout(vlayout)
|
||||
hlayout.addWidget(self.view_, 1)
|
||||
|
||||
hlayout.addWidget(self.annotree_)
|
||||
|
||||
self.scene_ = AnnotationScene(self)
|
||||
self.view_.setScene(self.scene_)
|
||||
|
||||
@@ -38,27 +38,37 @@ class MainWindow(QMainWindow):
|
||||
central.setLayout(hlayout)
|
||||
self.setCentralWidget(central)
|
||||
|
||||
def setModel(self, model):
|
||||
self.annotree_.setModel(model)
|
||||
self.scene_.setModel(model)
|
||||
|
||||
file_index = model.index(0, 0, QModelIndex())
|
||||
frame_index = model.index(0, 0, file_index)
|
||||
self.scene_.setRoot(frame_index)
|
||||
|
||||
def clickedSelect(self):
|
||||
self.scene_.setMode(None)
|
||||
|
||||
def clickedPoint(self):
|
||||
self.scene_.setMode({'type': 'point'})
|
||||
self.scene_.setMode({'type': 'point'})
|
||||
|
||||
def clickedRectangle(self):
|
||||
self.scene_.setMode({'type': 'rect'})
|
||||
|
||||
def clickedLine(self):
|
||||
self.scene_.setMode(LINE)
|
||||
|
||||
def clickedPolygon(self):
|
||||
self.scene_.setMode({'type': 'polygon'})
|
||||
|
||||
|
||||
def main():
|
||||
import sys
|
||||
app = QApplication(sys.argv)
|
||||
|
||||
annotations = defaultAnnotations()
|
||||
model = AnnotationModel(annotations)
|
||||
|
||||
wnd = MainWindow(sys.argv[1:])
|
||||
wnd.resize(800,600)
|
||||
wnd.resize(800, 600)
|
||||
wnd.setModel(model)
|
||||
wnd.show()
|
||||
|
||||
return app.exec_()
|
||||
|
||||
Reference in New Issue
Block a user