//
// File: coordinates.cc
//
// (C) 2000-2008 Helmut Cantzler
//
// Licensed under the terms of the Lesser General Public License.
//
#include <QtGui>
#include "mview.h"
#include "coordinates.h"
CoordinatesWindow::CoordinatesWindow(QWidget *parent, Mesh *mesh) :
QMainWindow(parent)
{
CoordinatesWindow::mesh = mesh;
QWidget *vbox = new QWidget(this);
QVBoxLayout *layout = new QVBoxLayout(vbox);
layout->setMargin(5);
layout->setSpacing(5);
vbox->setLayout(layout);
/// Display area for the coordinates ///
textfield = new QTextEdit(vbox);
textfield->setFrameStyle(QFrame::Panel | QFrame::Plain);
textfield->setReadOnly(TRUE);
layout->addWidget(textfield);
/// Control buttons ///
QWidget *buttons = new QWidget(vbox);
QHBoxLayout *blayout = new QHBoxLayout(buttons);
blayout->setMargin(5);
blayout->setSpacing(5);
buttons->setLayout(blayout);
blayout->addStretch( 10 );
QPushButton* clear = new QPushButton("Clear", buttons);
connect(clear, SIGNAL(clicked()), textfield, SLOT(clear()));
blayout->addWidget( clear );
QPushButton* close = new QPushButton("Close", buttons);
connect(close, SIGNAL(clicked()), parent, SLOT(closePick()));
blayout->addWidget( close );
layout->addWidget(buttons);
setCentralWidget( vbox );
resize(350, 250);
setWindowTitle("Coordinates");
close->setFocus();
}
void CoordinatesWindow::printResult(const Vertex *v, const Edge *e,
const Triangle *t)
{
Vertex org;
if (v != NULL)
{
textfield->append( tr("Point:") );
mesh->calcOriginalCoordinates(v, &org);
textfield->append(
tr(" %1 %2 %3").arg(org.x()).arg(org.y()).arg(org.z()) );
textfield->append("");
}
if (e != NULL)
{
textfield->append( tr("Edge:") );
for (int i=0; i < 2; i++)
{
mesh->calcOriginalCoordinates(e->vertices[i], &org);
textfield->append(
tr(" %1 %2 %3").arg(org.x()).arg(org.y()).arg(org.z()) );
}
textfield->append("");
}
if (t != NULL)
{
textfield->append( tr("Triangle:") );
for (int i=0; i < 3; i++)
{
mesh->calcOriginalCoordinates(t->vertices[i], &org);
textfield->append(
tr(" %1 %2 %3").arg(org.x()).arg(org.y()).arg(org.z()) );
}
textfield->append("");
}
}