better reset and init state

This commit is contained in:
Maxime Gimeno 2020-09-04 14:29:06 +02:00
parent 004e76d764
commit fc8d134d56
2 changed files with 60 additions and 14 deletions

View File

@ -72,7 +72,7 @@ public :
timer.stop();
});
connect(&timer, SIGNAL (timeout()), this, SLOT (next_frame()));
frame = 0;
frame = -1;
}
bool applicable(QAction*) const override
@ -168,15 +168,17 @@ public Q_SLOTS:
}
position = frame_pos[++frame];
dock_widget->frameSlider->setValue(frame);
dock_widget->frameLabel->setText(QString("%1/%2").arg(frame).arg(frame_pos.size()-1));
read_frame();
}
void prev_frame()
{
if(frame == 0)
if(frame <= 0)
return;
position = frame_pos[--frame];
dock_widget->frameSlider->setValue(frame);
dock_widget->frameLabel->setText(QString("%1/%2").arg(frame).arg(frame_pos.size()-1));
read_frame();
}
@ -187,8 +189,10 @@ public Q_SLOTS:
void reset_animation()
{
frame=0;
timer.stop();
frame=-1;
dock_widget->frameSlider->setValue(frame);
dock_widget->frameLabel->setText(QString("%1/%2").arg(frame).arg(frame_pos.size()-1));
for(std::size_t id = 0; id<initial_points.size();++id)
{
sm_item->face_graph()->points()[SMesh::Vertex_index(id)]=initial_points[id];
@ -210,7 +214,7 @@ public Q_SLOTS:
position=0;
frame_pos.clear();
filepath="";
frame = 0;
frame = -1;
dock_widget->resetButton->setEnabled(false);
dock_widget->startButton->setEnabled(false);
dock_widget->prevButton->setEnabled(false);
@ -267,6 +271,7 @@ public Q_SLOTS:
}
is.close();
dock_widget->frameSlider->setMaximum(frame_pos.size()-1);
dock_widget->frameLabel->setText(QString("%1/%2").arg(frame).arg(frame_pos.size()-1));
QApplication::restoreOverrideCursor();
}
@ -285,7 +290,7 @@ private:
Scene_surface_mesh_item* sm_item;
std::vector<std::streampos> frame_pos;
QTimer timer;
std::size_t frame;
int frame;
std::vector<SMesh::Point> initial_points;
}; //end of plugin class
#include "Animate_mesh_plugin.moc"

View File

@ -7,7 +7,7 @@
<x>0</x>
<y>0</y>
<width>444</width>
<height>120</height>
<height>150</height>
</rect>
</property>
<property name="windowTitle">
@ -43,14 +43,55 @@
</layout>
</item>
<item>
<widget class="QSlider" name="frameSlider">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksAbove</enum>
</property>
</widget>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QSlider" name="frameSlider">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="tickPosition">
<enum>QSlider::TicksAbove</enum>
</property>
</widget>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item>
<widget class="QLabel" name="frameLabel">
<property name="text">
<string>0/N</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">