@@ -79,10 +79,15 @@ IsingWidget::IsingWidget (unsigned M, unsigned N, double J,
79
79
setFixedWidth (M);
80
80
setFixedHeight (N);
81
81
82
+ render_timer = new QTimer (this );
83
+ connect (render_timer, SIGNAL (timeout ()), this , SLOT (update ()) );
84
+ render_timer->start (100 );
85
+
82
86
}
83
87
84
88
IsingWidget::~IsingWidget () {
85
89
delete imc;
90
+ delete render_timer;
86
91
}
87
92
88
93
void IsingWidget::paintEvent (QPaintEvent *e) {
@@ -93,12 +98,6 @@ void IsingWidget::paintEvent (QPaintEvent *e) {
93
98
unsigned PenSize = 1 ;
94
99
unsigned offset = PenSize ? PenSize : 1 ;
95
100
96
- // std::cout << imc->Energy() << std::endl;
97
-
98
- // std::cout << "Energy: " << imc->Energy()
99
- // << " Magnetization: " << imc->Magnetization()
100
- // << std::endl;
101
-
102
101
QPen WhitePen (Qt::white, PenSize, Qt::SolidLine),
103
102
BlackPen (Qt::black, PenSize, Qt::SolidLine);
104
103
for (unsigned i = 0 ; i < imc->XSize (); i++) {
@@ -123,13 +122,10 @@ void IsingWidget::simulationThread(unsigned num) {
123
122
for (unsigned i = 0 ; i < num; i++) {
124
123
imc->Step ();
125
124
}
126
- // emit paintEvent(0);
127
- update ();
128
125
}
129
126
}
130
127
131
128
void IsingWidget::ToggleSimulation (bool sstate) {
132
- std::cout << " state of simulation before changing: " << running << std::endl;
133
129
if (sstate) { startSimulation (); }
134
130
else { stopSimulation (); }
135
131
}
0 commit comments