Skip to content

Commit

Permalink
added function playMovie()
Browse files Browse the repository at this point in the history
  • Loading branch information
by408 committed Feb 19, 2024
1 parent d1f7270 commit ce07f0d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 13 deletions.
1 change: 1 addition & 0 deletions gui/appWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ void appWindow::createMenusAndMainWidget(){
view->addAction("Move down", this, SLOT(shiftDown()), Qt::Key_Down);
view->addAction("Reset view", m_poly, SLOT(resetView()), Qt::Key_R);
view->addAction("Change display order", m_poly, SLOT(changeOrder()), Qt::Key_O);
view->addAction("Movie mode", m_poly, SLOT([playMovie()), Qt::Key_M);
view->addAction("Toggle annotations", m_poly, SLOT(toggleAnno()), Qt::Key_A);
view->addAction("Toggle filled", m_poly, SLOT(toggleFilled()), Qt::Key_F);
view->addAction("Toggle points display",
Expand Down
46 changes: 35 additions & 11 deletions gui/polyView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ polyView::polyView(QWidget *parent, chooseFilesDlg * chooseFiles,
m_showLayerAnno = false;
m_showFilledPolys = false;
m_changeDisplayOrder = false;
m_movie_frame_id = -1;

m_emptyRubberBand = QRect(-10, -10, 0, 0); // off-screen rubberband
m_rubberBand = m_emptyRubberBand;
Expand Down Expand Up @@ -477,7 +478,7 @@ bool polyView::hasSelectedPolygons() const{
}
// Plot the current data. See worldToPixelCoords() for how to convert
// from world to screen coordinates.
void polyView::displayData(QPainter *paint) {
void polyView::displayData(QPainter *paint, int pol_id) {

//utils::Timer my_clock("polyView::displayData");
setupViewingWindow(); // Must happen before anything else
Expand Down Expand Up @@ -525,6 +526,7 @@ void polyView::displayData(QPainter *paint) {
// Plot the images and polygons
for (int vi = 0; vi < (int)m_polyVec.size(); vi++) {

if (pol_id >= 0 && pol_id != vi) continue;
int vecIter = m_polyVecOrder[vi];

// Skip the files the user does not want to see
Expand Down Expand Up @@ -1678,19 +1680,19 @@ void polyView::refreshPixmap() {
// directly. Later we'll display the pixmap without redrawing
// whenever possible for reasons of speed.

m_pixmap = QPixmap(size());
m_pixmap.fill(QColor(m_prefs.bgColor.c_str()));
m_pixmap = QPixmap(size());
m_pixmap.fill(QColor(m_prefs.bgColor.c_str()));

QPainter paint(&m_pixmap);
paint.initFrom(this);
QPainter paint(&m_pixmap);
paint.initFrom(this);

QFont F;
F.setPointSize(m_prefs.fontSize);
//F.setStyleStrategy(QFont::NoAntialias);
paint.setFont(F);
QFont F;
F.setPointSize(m_prefs.fontSize);
//F.setStyleStrategy(QFont::NoAntialias);
paint.setFont(F);

displayData(&paint);
update();
displayData(&paint);
update();

return;
}
Expand Down Expand Up @@ -2492,6 +2494,28 @@ void polyView::drawMark(int x0, int y0, QColor color, int lineWidth,

}

void polyView::playMovie(){

cout <<"in playMovie: "<< m_movie_frame_id<<endl;
m_movie_frame_id++;

if ((int)m_polyVec.size() == m_movie_frame_id) m_movie_frame_id = -1;

m_pixmap = QPixmap(size());
m_pixmap.fill(QColor(m_prefs.bgColor.c_str()));

QPainter paint(&m_pixmap);
paint.initFrom(this);

QFont F;
F.setPointSize(m_prefs.fontSize);
//F.setStyleStrategy(QFont::NoAntialias);
paint.setFont(F);

displayData(&paint, m_movie_frame_id);
update();
}

void polyView::toggleAnno() {
m_showAnnotations = !m_showAnnotations;
m_showVertOrPolyIndexAnno = 0;
Expand Down
5 changes: 3 additions & 2 deletions gui/polyView.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ public slots:
bool getStringVectorFromGui(std::string title,
std::string description,
std::vector<std::string> & values);
void playMovie();
void toggleAnno();
void toggleFilled();
void toggleShowGrid();
Expand Down Expand Up @@ -232,7 +233,7 @@ public slots:

bool hasSelectedPolygons() const;

void displayData( QPainter *paint );
void displayData( QPainter *paint, int i = -1 );
void drawMarks(QPainter *paint);

void plotDPoly(bool plotPoints, bool plotEdges,
Expand Down Expand Up @@ -331,7 +332,7 @@ public slots:

bool m_showAnnotations;
bool m_showFilledPolys;

int m_movie_frame_id;
std::vector<utils::dPoly> m_highlights;

int m_showEdges, m_showPoints, m_showPointsEdges, m_displayMode;
Expand Down

0 comments on commit ce07f0d

Please sign in to comment.