~ubuntu-branches/ubuntu/vivid/regina-normal/vivid

« back to all changes in this revision

Viewing changes to qtui/src/packettypes/ntrisurfaces.cpp

  • Committer: Package Import Robot
  • Author(s): Ben Burton
  • Date: 2013-11-02 11:44:32 UTC
  • mfrom: (1.2.8)
  • Revision ID: package-import@ubuntu.com-20131102114432-acgci6b1pb2hjl8q
Tags: 4.95-1
* New upstream release.
* The python module is now installed in a standard location beneath
  /usr/lib/python2.7/dist-packages.
* Switched python packaging from python-support to dh_python2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
49
49
#include <QToolTip>
50
50
#include <QWhatsThis>
51
51
 
52
 
#define THREE_SPHERE_AUTO_CALC_ADJUSTMENT 2
 
52
#define HAKEN_AUTO_CALC_ADJUSTMENT 2
53
53
 
54
54
using regina::NPacket;
55
55
using regina::NTriangulation;
124
124
    label->setWhatsThis(msg);
125
125
    splitting->setWhatsThis(msg);
126
126
 
 
127
    titleIrreducible = new QLabel(tr("Irreducible?"), ui);
 
128
    grid->addWidget(titleIrreducible, 5, 1);
 
129
    irreducible = new QLabel(ui);
 
130
    grid->addWidget(irreducible, 5, 3);
 
131
    msg = tr("<qt>Does this triangulation represent an "
 
132
        "irreducible 3-manifold?  A closed orientable 3-manifold is "
 
133
        "<i>irreducible</i> if every embedded sphere bounds a ball.</qt>");
 
134
    titleIrreducible->setWhatsThis(msg);
 
135
    irreducible->setWhatsThis(msg);
 
136
 
 
137
    titleHaken = new QLabel(tr("Haken?"), ui);
 
138
    grid->addWidget(titleHaken, 6, 1);
 
139
    haken = new QLabel(ui);
 
140
    grid->addWidget(haken, 6, 3);
 
141
    msg = tr("<qt>Does this triangulation represent a Haken 3-manifold?  "
 
142
        "A closed orientable irreducible 3-manifold is "
 
143
        "<i>Haken</i> if it contains an embedded closed two-sided "
 
144
        "incompressible surface.<p>"
 
145
        "Hakenness testing is only available for irreducible "
 
146
        "3-manifolds.</qt>");
 
147
    titleHaken->setWhatsThis(msg);
 
148
    haken->setWhatsThis(msg);
 
149
 
127
150
    btnThreeSphere = new QPushButton(ReginaSupport::themeIcon("system-run"),
128
151
        tr("Calculate"), ui);
129
152
    btnThreeSphere->setToolTip(tr("Calculate whether this is a 3-sphere"));
154
177
    btnSolidTorus->setToolTip(tr("Calculate whether this is a solid torus"));
155
178
    btnSolidTorus->setWhatsThis(tr("<qt>Calculate whether this "
156
179
        "is a triangulation of the solid torus (i.e., the unknot "
157
 
        "complement).  The triangulation may have real boundary faces, "
 
180
        "complement).  The triangulation may have real boundary triangles, "
158
181
        "or it may be ideal (in which case I will assume that "
159
182
        "any ideal vertices are truncated).<p>"
160
183
        "<b>Warning:</b> This calculation is occasionally quite slow for "
187
210
    grid->addWidget(btnSplitting, 4, 5);
188
211
    connect(btnSplitting, SIGNAL(clicked()), this, SLOT(calculateSplitting()));
189
212
 
 
213
    btnIrreducible = new QPushButton(ReginaSupport::themeIcon("system-run"),
 
214
        tr("Calculate"), ui);
 
215
    btnIrreducible->setToolTip(tr("Calculate whether this 3-manifold "
 
216
        "is irreducible"));
 
217
    btnIrreducible->setWhatsThis(tr("<qt>Calculate whether this "
 
218
        "triangulation represents an irreducible 3-manifold.<p>"
 
219
        "<b>Warning:</b> This calculation can be quite slow for larger "
 
220
        "triangulations (which is why irreducibility is not always "
 
221
        "tested automatically).</qt>"));
 
222
    grid->addWidget(btnIrreducible, 5, 5);
 
223
    connect(btnIrreducible, SIGNAL(clicked()), this,
 
224
        SLOT(calculateIrreducible()));
 
225
 
 
226
    btnHaken = new QPushButton(ReginaSupport::themeIcon("system-run"),
 
227
        tr("Calculate"), ui);
 
228
    btnHaken->setToolTip(tr("Calculate whether this 3-manifold is Haken"));
 
229
    btnHaken->setWhatsThis(tr("<qt>Calculate whether this "
 
230
        "triangulation represents a Haken 3-manifold.<p>"
 
231
        "Hakenness testing is only available for irreducible 3-manifolds.<p>"
 
232
        "<b>Warning:</b> This calculation can be quite slow for larger "
 
233
        "triangulations (which is why Hakenness is not always "
 
234
        "tested automatically).</qt>"));
 
235
    grid->addWidget(btnHaken, 6, 5);
 
236
    connect(btnHaken, SIGNAL(clicked()), this, SLOT(calculateHaken()));
 
237
 
190
238
    layout->addStretch(1);
191
239
 
192
240
    QBoxLayout* mfdArea = new QHBoxLayout();
284
332
    }
285
333
 
286
334
    if (tri->knowsThreeSphere() ||
287
 
            tri->getNumberOfTetrahedra() + THREE_SPHERE_AUTO_CALC_ADJUSTMENT
288
 
            <= autoCalcThreshold) {
 
335
            tri->getNumberOfTetrahedra() <= autoCalcThreshold) {
289
336
        if (tri->isThreeSphere()) {
290
337
            threeSphere->setText(tr("True"));
291
338
            QPalette pal = threeSphere->palette();
307
354
        btnThreeSphere->setEnabled(true);
308
355
    }
309
356
 
310
 
    // Use the same threshold adjustment as for 3-sphere recognition.
311
357
    if (tri->knowsBall() ||
312
 
            tri->getNumberOfTetrahedra() + THREE_SPHERE_AUTO_CALC_ADJUSTMENT
313
 
            <= autoCalcThreshold) {
 
358
            tri->getNumberOfTetrahedra() <= autoCalcThreshold) {
314
359
        if (tri->isBall()) {
315
360
            threeBall->setText(tr("True"));
316
361
            QPalette pal = threeBall->palette();
332
377
        btnThreeBall->setEnabled(true);
333
378
    }
334
379
 
335
 
    // Use the same threshold adjustment as for 3-sphere recognition.
336
380
    if (tri->knowsSolidTorus() ||
337
 
            tri->getNumberOfTetrahedra() + THREE_SPHERE_AUTO_CALC_ADJUSTMENT
338
 
            <= autoCalcThreshold) {
 
381
            tri->getNumberOfTetrahedra() <= autoCalcThreshold) {
339
382
        if (tri->isSolidTorus()) {
340
383
            solidTorus->setText(tr("True"));
341
384
            QPalette pal = solidTorus->palette();
357
400
        btnSolidTorus->setEnabled(true);
358
401
    }
359
402
 
 
403
    if (tri->isOrientable() && tri->isClosed() && tri->isValid() &&
 
404
            tri->isConnected()) {
 
405
        titleIrreducible->setVisible(true);
 
406
        irreducible->setVisible(true);
 
407
        btnIrreducible->setVisible(true);
 
408
 
 
409
        if (tri->knowsIrreducible() ||
 
410
                tri->getNumberOfTetrahedra() <= autoCalcThreshold) {
 
411
            if (tri->isIrreducible()) {
 
412
                irreducible->setText(tr("True"));
 
413
                QPalette pal = irreducible->palette();
 
414
                pal.setColor(irreducible->foregroundRole(), Qt::darkGreen);
 
415
                irreducible->setPalette(pal);
 
416
            } else {
 
417
                irreducible->setText(tr("False"));
 
418
                QPalette pal = irreducible->palette();
 
419
                pal.setColor(irreducible->foregroundRole(), Qt::darkRed);
 
420
                irreducible->setPalette(pal);
 
421
            }
 
422
            btnIrreducible->setEnabled(false);
 
423
        } else {
 
424
            irreducible->setText(tr("Unknown"));
 
425
            irreducible->setPalette(QPalette());
 
426
            btnIrreducible->setEnabled(true);
 
427
        }
 
428
    } else {
 
429
        titleIrreducible->setVisible(false);
 
430
        irreducible->setVisible(false);
 
431
        btnIrreducible->setVisible(false);
 
432
    }
 
433
 
 
434
    // Use the same threshold adjustment as for 3-sphere recognition.
 
435
    if (tri->isOrientable() && tri->isClosed() && tri->isValid() &&
 
436
            tri->isConnected()) {
 
437
        titleHaken->setVisible(true);
 
438
        haken->setVisible(true);
 
439
        btnHaken->setVisible(true);
 
440
 
 
441
        if (tri->knowsIrreducible() && ! tri->isIrreducible()) {
 
442
            // We are not allowed to test Hakenness in this situation.
 
443
            haken->setText(tr("N/A"));
 
444
            QPalette pal = haken->palette();
 
445
            pal.setColor(haken->foregroundRole(), Qt::darkYellow);
 
446
            haken->setPalette(pal);
 
447
            btnHaken->setEnabled(false);
 
448
        } else if (tri->knowsHaken() ||
 
449
                tri->getNumberOfTetrahedra() + HAKEN_AUTO_CALC_ADJUSTMENT
 
450
                <= autoCalcThreshold) {
 
451
            // This will not trigger new knowledge about irreducibility,
 
452
            // since if the triangulation has few tetrahedra we would
 
453
            // have just run an irreducibility test in the previous section.
 
454
            if (tri->isHaken()) {
 
455
                haken->setText(tr("True"));
 
456
                QPalette pal = haken->palette();
 
457
                pal.setColor(haken->foregroundRole(), Qt::darkGreen);
 
458
                haken->setPalette(pal);
 
459
            } else {
 
460
                haken->setText(tr("False"));
 
461
                QPalette pal = haken->palette();
 
462
                pal.setColor(haken->foregroundRole(), Qt::darkRed);
 
463
                haken->setPalette(pal);
 
464
            }
 
465
            btnHaken->setEnabled(false);
 
466
        } else {
 
467
            haken->setText(tr("Unknown"));
 
468
            haken->setPalette(QPalette());
 
469
            btnHaken->setEnabled(true);
 
470
        }
 
471
    } else {
 
472
        titleHaken->setVisible(false);
 
473
        haken->setVisible(false);
 
474
        btnHaken->setVisible(false);
 
475
    }
 
476
 
360
477
    if (! name.empty()) {
361
478
        manifold->setText(tr("Manifold:  %1").arg(name.c_str()));
362
479
    } else {
376
493
    threeBall->setPalette(QPalette());
377
494
    solidTorus->setText(msg);
378
495
    solidTorus->setPalette(QPalette());
 
496
    irreducible->setText(msg);
 
497
    irreducible->setPalette(QPalette());
 
498
    haken->setText(msg);
 
499
    haken->setPalette(QPalette());
379
500
    manifold->setText(msg);
380
501
 
381
502
    btnZeroEff->setEnabled(false);
383
504
    btnThreeSphere->setEnabled(false);
384
505
    btnThreeBall->setEnabled(false);
385
506
    btnSolidTorus->setEnabled(false);
 
507
    btnIrreducible->setEnabled(false);
 
508
    btnHaken->setEnabled(false);
386
509
}
387
510
 
388
511
void NTriSurfacesUI::calculateZeroEff() {
440
563
    refresh();
441
564
}
442
565
 
 
566
void NTriSurfacesUI::calculateIrreducible() {
 
567
    PatienceDialog* dlg = PatienceDialog::warn(tr(
 
568
        "Testing irreducibility can be quite slow\n"
 
569
        "for larger triangulations.\n\n"
 
570
        "Please be patient."), ui);
 
571
    tri->isIrreducible();
 
572
    delete dlg;
 
573
 
 
574
    refresh();
 
575
}
 
576
 
 
577
void NTriSurfacesUI::calculateHaken() {
 
578
    PatienceDialog* dlg = PatienceDialog::warn(tr(
 
579
        "Hakenness testing can be quite slow\n"
 
580
        "for larger triangulations.\n\n"
 
581
        "Please be patient."), ui);
 
582
    tri->isHaken();
 
583
    delete dlg;
 
584
 
 
585
    refresh();
 
586
}
 
587