27 #include "compute-homology.hh"
29 #include <QtGui/QGridLayout>
30 #include <QtGui/QHBoxLayout>
31 #include <QtGui/QLabel>
32 #include <Qt3Support/Q3Accel>
48 setWindowTitle(
"Homology") ;
52 Q3Accel * Raccourci =
new Q3Accel(
this) ;
53 Raccourci -> insertItem(QKeySequence(Qt :: Key_Space) , 9) ;
54 Raccourci -> connectItem(9 ,
this , SLOT(close())) ;
56 QVBoxLayout * placement =
new QVBoxLayout(
this) ;
59 FGenerators =
new QGroupBox(
"Generators") ;
60 QGridLayout * global =
new QGridLayout(FGenerators) ;
62 Fh0 =
new QLabel(
"") ;
63 Fh1free =
new QLabel(
"") ;
64 Fh1torsion =
new QLabel(
"") ;
65 Fh2 =
new QLabel(
"") ;
67 FButtonH0 =
new QPushButton(
"H0:");
68 FButtonH1free =
new QPushButton(
"free:");
69 FButtonH1torsion =
new QPushButton(
"torsion:");
70 FButtonH2 =
new QPushButton(
"H2:");
72 FButtonH0->setCheckable(
true);
73 connect(FButtonH0, SIGNAL(toggled(
bool)),
this,
74 SLOT(callbackToggleH0(
bool)));
76 FButtonH1free->setCheckable(
true);
77 connect(FButtonH1free, SIGNAL(toggled(
bool)),
this,
78 SLOT(callbackToggleH1free(
bool)));
80 FButtonH1torsion->setCheckable(
true);
81 connect(FButtonH1torsion, SIGNAL(toggled(
bool)),
this,
82 SLOT(callbackToggleH1torsion(
bool)));
84 FButtonH2->setCheckable(
true);
85 connect(FButtonH2, SIGNAL(toggled(
bool)),
this,
86 SLOT(callbackToggleH2(
bool)));
88 global->addWidget(FButtonH0 , 1 , 0) ;
89 global->addWidget(Fh0 , 1 , 1) ;
91 global->addWidget(
new QLabel(
"H1:") , 2 , 0) ;
93 global->addWidget(FButtonH1free , 2 , 1) ;
94 global->addWidget(Fh1free , 2 , 2) ;
96 global->addWidget(FButtonH1torsion , 2 , 3) ;
97 global->addWidget(Fh1torsion , 2 , 4) ;
99 global->addWidget(FButtonH2 , 3 , 0) ;
100 global->addWidget(Fh2 , 3 , 1) ;
103 FInfo =
new QGroupBox(
"Performances") ;
104 QGridLayout * pointed =
new QGridLayout(FInfo) ;
106 FTime =
new QLabel(
"") ;
107 FMemory =
new QLabel(
"") ;
109 pointed->addWidget(
new QLabel(
"time:") , 1 , 0);
110 pointed->addWidget(FTime , 1 , 1) ;
112 pointed->addWidget(
new QLabel(
"memory:") , 2 , 0);
113 pointed->addWidget(FMemory , 2 , 1) ;
116 placement -> addWidget(FGenerators) ;
117 placement -> addWidget(FInfo) ;
125 void OptionsSurfacicHomology::closeEvent(QCloseEvent *event)
128 delete FHomology; FHomology=NULL;
132 void OptionsSurfacicHomology::restoreAlpha3()
134 if ( FIndexAlpha3==-1 )
return;
136 for (CDynamicCoverageAll it(FParent->
getControler()->getMap());
140 getDirectInfoAsDart(*it, FIndexAlpha3));
143 FParent->
getControler()->getMap()->freeDirectInfo(FIndexAlpha3);
147 void OptionsSurfacicHomology::removeAlpha3()
149 if ( FIndexAlpha3!=-1 )
return;
151 FIndexAlpha3 = FParent->
getControler()->getMap()->getNewDirectInfo();
152 for (CDynamicCoverageAll it(FParent->
getControler()->getMap());
156 setDirectInfo(*it, FIndexAlpha3, (*it)->getAlpha3());
166 std::ostringstream os;
169 CChrono c; c.setMode(PUS_MODE); c.start();
172 FHomology =
new GMap3d::CHomology(FParent->
getControler()->getMap(),
175 if ( FHomology!=NULL && FHomology->computeSurfacicHomology() )
176 FParent->
getControler()->setMessage(
"Surfacic homology computed.");
179 setMessage(
"Impossible to compute Homology: not enough memory.");
187 os<<FHomology->getH0FreeGenerators();
188 Fh0->setText(os.str().c_str()) ;
192 os<<FHomology->getH1FreeGenerators();
193 Fh1free->setText(os.str().c_str()) ;
197 os<<FHomology->getH1TorsionGenerators();
198 Fh1torsion->setText(os.str().c_str()) ;
202 os<<FHomology->getH2FreeGenerators();
203 Fh2->setText(os.str().c_str()) ;
207 unsigned long s = FHomology->size();
208 std::string unit(
" bytes");
212 unit =
" kilo-bytes";
216 unit =
" mega-bytes";
221 FMemory->setText(os.str().c_str()) ;
228 FTime->setText(os.str().c_str()) ;
230 FButtonH0->setChecked(FHomology->getShowH0());
231 FButtonH1free->setChecked(FHomology->getShowH1free());
232 FButtonH1torsion->setChecked(FHomology->getShowH1torsion());
233 FButtonH2->setChecked(FHomology->getShowH2free());
236 FParent -> repaint() ;
245 void OptionsSurfacicHomology::callbackToggleH0(
bool ADraw)
247 FHomology->setShowH0(ADraw);
249 FParent -> repaint() ;
252 void OptionsSurfacicHomology::callbackToggleH1free(
bool ADraw)
254 FHomology->setShowH1free(ADraw);
256 FParent -> repaint() ;
259 void OptionsSurfacicHomology::callbackToggleH1torsion(
bool ADraw)
261 FHomology->setShowH1torsion(ADraw);
263 FParent -> repaint() ;
266 void OptionsSurfacicHomology::callbackToggleH2(
bool ADraw)
268 FHomology->setShowH2free(ADraw);
270 FParent -> repaint() ;