27 #include "compute-homology.hh"
29 #include <QtGui/QGridLayout>
30 #include <QtGui/QHBoxLayout>
31 #include <QtGui/QLabel>
32 #include <Qt3Support/Q3Accel>
47 setWindowTitle(
"Homology") ;
51 Q3Accel * Raccourci =
new Q3Accel(
this) ;
52 Raccourci -> insertItem(QKeySequence(Qt :: Key_Space) , 9) ;
53 Raccourci -> connectItem(9 ,
this , SLOT(close())) ;
55 QVBoxLayout * placement =
new QVBoxLayout(
this) ;
58 FGenerators =
new QGroupBox(
"Generators") ;
59 QGridLayout * global =
new QGridLayout(FGenerators) ;
61 Fh0 =
new QLabel(
"") ;
62 Fh1free =
new QLabel(
"") ;
63 Fh1torsion =
new QLabel(
"") ;
64 Fh2free =
new QLabel(
"") ;
65 Fh2torsion =
new QLabel(
"") ;
66 Fh3 =
new QLabel(
"") ;
68 FButtonH0 =
new QPushButton(
"H0:");
69 FButtonH1free =
new QPushButton(
"free:");
70 FButtonH1torsion =
new QPushButton(
"torsion:");
71 FButtonH2free =
new QPushButton(
"free:");
72 FButtonH2torsion =
new QPushButton(
"torsion:");
73 FButtonH3 =
new QPushButton(
"H3:");
75 FButtonH0->setCheckable(
true);
76 connect(FButtonH0, SIGNAL(toggled(
bool)),
this,
77 SLOT(callbackToggleH0(
bool)));
79 FButtonH1free->setCheckable(
true);
80 connect(FButtonH1free, SIGNAL(toggled(
bool)),
this,
81 SLOT(callbackToggleH1free(
bool)));
83 FButtonH1torsion->setCheckable(
true);
84 connect(FButtonH1torsion, SIGNAL(toggled(
bool)),
this,
85 SLOT(callbackToggleH1torsion(
bool)));
87 FButtonH2free->setCheckable(
true);
88 connect(FButtonH2free, SIGNAL(toggled(
bool)),
this,
89 SLOT(callbackToggleH2free(
bool)));
91 FButtonH2torsion->setCheckable(
true);
92 connect(FButtonH2torsion, SIGNAL(toggled(
bool)),
this,
93 SLOT(callbackToggleH2torsion(
bool)));
95 FButtonH3->setCheckable(
true);
96 connect(FButtonH3, SIGNAL(toggled(
bool)),
this,
97 SLOT(callbackToggleH3(
bool)));
99 global->addWidget(FButtonH0 , 1 , 0) ;
100 global->addWidget(Fh0 , 1 , 1) ;
102 global->addWidget(
new QLabel(
"H1:") , 2 , 0) ;
104 global->addWidget(FButtonH1free , 2 , 1) ;
105 global->addWidget(Fh1free , 2 , 2) ;
107 global->addWidget(FButtonH1torsion , 2 , 3) ;
108 global->addWidget(Fh1torsion , 2 , 4) ;
110 global->addWidget(
new QLabel(
"H2:") , 3 , 0) ;
112 global->addWidget(FButtonH2free , 3 , 1) ;
113 global->addWidget(Fh2free , 3 , 2) ;
115 global->addWidget(FButtonH2torsion , 3 , 3) ;
116 global->addWidget(Fh2torsion , 3 , 4) ;
118 global->addWidget(FButtonH3 , 4 , 0) ;
119 global->addWidget(Fh3 , 4 , 1) ;
122 FInfo =
new QGroupBox(
"Performances") ;
123 QGridLayout * pointed =
new QGridLayout(FInfo) ;
125 FTime =
new QLabel(
"") ;
126 FMemory =
new QLabel(
"") ;
128 pointed->addWidget(
new QLabel(
"time:") , 1 , 0);
129 pointed->addWidget(FTime , 1 , 1) ;
131 pointed->addWidget(
new QLabel(
"memory:") , 2 , 0);
132 pointed->addWidget(FMemory , 2 , 1) ;
135 placement -> addWidget(FGenerators) ;
136 placement -> addWidget(FInfo) ;
142 {
delete FHomology; }
148 std::ostringstream os;
151 CChrono c; c.setMode(PUS_MODE); c.start();
154 FHomology =
new GMap3d::CHomology(FParent->
getControler()->getMap(),
157 if ( FHomology!=NULL && FHomology->computeVolumicHomology() )
158 FParent->
getControler()->setMessage(
"Homology computed.");
161 setMessage(
"Impossible to compute Homology: not enough memory.");
169 os<<FHomology->getH0FreeGenerators();
170 Fh0->setText(os.str().c_str()) ;
174 os<<FHomology->getH1FreeGenerators();
175 Fh1free->setText(os.str().c_str()) ;
179 os<<FHomology->getH1TorsionGenerators();
180 Fh1torsion->setText(os.str().c_str()) ;
184 os<<FHomology->getH2FreeGenerators();
185 Fh2free->setText(os.str().c_str()) ;
189 os<<FHomology->getH2TorsionGenerators();
190 Fh2torsion->setText(os.str().c_str()) ;
194 os<<FHomology->getH3FreeGenerators();
195 Fh3->setText(os.str().c_str()) ;
199 unsigned long s = FHomology->size();
200 std::string unit(
" bytes");
204 unit =
" kilo-bytes";
208 unit =
" mega-bytes";
213 FMemory->setText(os.str().c_str()) ;
220 FTime->setText(os.str().c_str()) ;
222 FButtonH0->setChecked(FHomology->getShowH0());
223 FButtonH1free->setChecked(FHomology->getShowH1free());
224 FButtonH1torsion->setChecked(FHomology->getShowH1torsion());
225 FButtonH2free->setChecked(FHomology->getShowH2free());
226 FButtonH2torsion->setChecked(FHomology->getShowH2torsion());
227 FButtonH3->setChecked(FHomology->getShowH3());
230 FParent -> repaint() ;
239 void OptionsVolumicHomology::callbackToggleH0(
bool ADraw)
241 FHomology->setShowH0(ADraw);
243 FParent -> repaint() ;
246 void OptionsVolumicHomology::callbackToggleH1free(
bool ADraw)
248 FHomology->setShowH1free(ADraw);
250 FParent -> repaint() ;
253 void OptionsVolumicHomology::callbackToggleH1torsion(
bool ADraw)
255 FHomology->setShowH1torsion(ADraw);
257 FParent -> repaint() ;
260 void OptionsVolumicHomology::callbackToggleH2free(
bool ADraw)
262 FHomology->setShowH2free(ADraw);
264 FParent -> repaint() ;
267 void OptionsVolumicHomology::callbackToggleH2torsion(
bool ADraw)
269 FHomology->setShowH2torsion(ADraw);
271 FParent -> repaint() ;
274 void OptionsVolumicHomology::callbackToggleH3(
bool ADraw)
276 FHomology->setShowH3(ADraw);
278 FParent -> repaint() ;