Commit 3349848a authored by Dirk Wilden's avatar Dirk Wilden

good looking info plugin ;)

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@7352 383ad7c9-94d9-4d36-a494-682f7c89f535
parent a0b96be9
include (plugin)
openflipper_plugin ( TRANSLATION_LANGUAGES de_DE )
openflipper_plugin ( TRANSLATION_LANGUAGES de_DE)
......@@ -82,7 +82,7 @@ void InfoPlugin::pluginsInitialized() {
//-----------------------------------------------------------------------------
template< class MeshT >
void InfoPlugin::printMeshInfo( MeshT* _mesh , int _id, unsigned int _face ) {
void InfoPlugin::printMeshInfo( MeshT* _mesh , int _id, unsigned int _face, ACG::Vec3d& _hitPoint ) {
QLocale locale;
......@@ -94,54 +94,50 @@ void InfoPlugin::printMeshInfo( MeshT* _mesh , int _id, unsigned int _face ) {
int closest_e_idx = getClosestEdge(_mesh, _face);
// ID
info_->id->setText( tr("<B>Object ID:</B> ") + locale.toString(_id) );
info_->id->setText( locale.toString(_id) );
// Vertices
info_->vertices->setText( tr("<B>Vertices:</B> ") + locale.toString( _mesh->n_vertices() ) );
info_->vertices->setText( locale.toString( _mesh->n_vertices() ) );
// Faces
info_->faces->setText( tr("<B>Faces:</B> ") + locale.toString( _mesh->n_faces() ) );
info_->faces->setText( locale.toString( _mesh->n_faces() ) );
// Edges
info_->edges->setText( tr("<B>Edges:</B> ") + locale.toString( _mesh->n_edges() ) );
info_->edges->setText( locale.toString( _mesh->n_edges() ) );
// Closest Vertex
info_->closestv->setText( tr("<B>Closest vertex:</B> ") + locale.toString( closest_v_idx ) );
info_->vertexHandle->setText( locale.toString( closest_v_idx ) );
// Closest Edge
info_->closeste->setText( tr("<B>Closest edge:</B> ") + locale.toString( closest_e_idx ) );
info_->edgeHandle->setText( locale.toString( closest_e_idx ) );
// Picked Vertex
info_->pickedFace->setText( tr("<B>Picked face:</B> ") + locale.toString( _face ) );
info_->faceHandle->setText( locale.toString( _face ) );
// Components
info_->components->setText( tr("<B>Components:</B> ") + locale.toString(MeshInfo::componentCount(_mesh)));
info_->components->setText( locale.toString(MeshInfo::componentCount(_mesh)));
// Boundaries
info_->boundaries->setText( tr("<B>Boundaries:</B> ") + locale.toString(MeshInfo::boundaryCount(_mesh)) );
info_->boundaries->setText( locale.toString(MeshInfo::boundaryCount(_mesh)) );
// Genus
int genus = 1 - (_mesh->n_vertices() - _mesh->n_edges() + _mesh->n_faces() ) / 2;
info_->genus->setText( tr("<B>Genus:</B> ") + QString::number(genus) );
info_->genus->setText( QString::number(genus) );
info_->table->clear();
info_->table->setColumnCount ( 3 );
info_->table->setRowCount ( 8 );
info_->table->setRowCount ( 5 );
QStringList headerdata;
headerdata << tr("Min") << tr("Mean") << tr("Max");
headerdata << tr("Minimum") << tr("Mean") << tr("Maximum");
info_->table->setHorizontalHeaderLabels(headerdata);
headerdata.clear();
headerdata << tr("X Coordinate") << tr("Y Coordinate") << tr("Z Coordinate") << tr("Vertex Valence") << tr("Edge Length") << tr("Aspect Ratio");
headerdata << tr("Inner Face Angles") << tr("Dihedral Angles");
headerdata << tr("Vertex Valence") << tr("Edge Length") << tr("Aspect Ratio") << tr("Inner Face Angles") << tr("Dihedral Angles");
info_->table->setVerticalHeaderLabels(headerdata);
//set tooltips
info_->table->verticalHeaderItem(0)->setToolTip(tr("minimum, maximum and arithmetic mean of the vertex x-coordinates"));
info_->table->verticalHeaderItem(1)->setToolTip(tr("minimum, maximum and arithmetic mean of the vertex y-coordinates"));
info_->table->verticalHeaderItem(2)->setToolTip(tr("minimum, maximum and arithmetic mean of the vertex z-coordinates"));
info_->table->verticalHeaderItem(3)->setToolTip(tr("minimum, maximum and arithmetic mean of the vertex valences"));
info_->table->verticalHeaderItem(4)->setToolTip(tr("minimum, maximum and arithmetic mean of the edge lengthes"));
info_->table->verticalHeaderItem(5)->setToolTip(tr("minimum, maximum and arithmetic mean of the aspect ratio."
info_->table->verticalHeaderItem(0)->setToolTip(tr("minimum, maximum and arithmetic mean of the vertex valences"));
info_->table->verticalHeaderItem(1)->setToolTip(tr("minimum, maximum and arithmetic mean of the edge lengthes"));
info_->table->verticalHeaderItem(2)->setToolTip(tr("minimum, maximum and arithmetic mean of the aspect ratio."
" i.e. the ratio between longest and shortest edge in a triangle."));
info_->table->verticalHeaderItem(6)->setToolTip(tr("minimum, maximum and arithmetic mean of the inner angles in a face."));
info_->table->verticalHeaderItem(7)->setToolTip(tr("minimum, maximum and arithmetic mean of the dihedral angles"
info_->table->verticalHeaderItem(3)->setToolTip(tr("minimum, maximum and arithmetic mean of the inner angles in a face."));
info_->table->verticalHeaderItem(4)->setToolTip(tr("minimum, maximum and arithmetic mean of the dihedral angles"
" i.e. the angles between neighboring faces."));
// Coordinates
......@@ -200,18 +196,6 @@ void InfoPlugin::printMeshInfo( MeshT* _mesh , int _id, unsigned int _face ) {
}
int row=0;
info_->table->setItem(row,0, new QTableWidgetItem( QString::number(minX,'f') ) );
info_->table->setItem(row,1, new QTableWidgetItem( QString::number( sumX / _mesh->n_vertices(),'f' )) );
info_->table->setItem(row,2, new QTableWidgetItem( QString::number(maxX,'f') ) );
row++;
info_->table->setItem(row,0, new QTableWidgetItem( QString::number(minY,'f') ) );
info_->table->setItem(row,1, new QTableWidgetItem( QString::number( sumY / _mesh->n_vertices(),'f' )) );
info_->table->setItem(row,2, new QTableWidgetItem( QString::number(maxY,'f') ) );
row++;
info_->table->setItem(row,0, new QTableWidgetItem( QString::number(minZ,'f') ) );
info_->table->setItem(row,1, new QTableWidgetItem( QString::number( sumZ / _mesh->n_vertices(),'f' )) );
info_->table->setItem(row,2, new QTableWidgetItem( QString::number(maxZ,'f') ) );
row++;
info_->table->setItem(row,0, new QTableWidgetItem( QString::number(minV) ) );
info_->table->setItem(row,1, new QTableWidgetItem( QString::number( sumV / (float)_mesh->n_vertices(),'f' )) );
info_->table->setItem(row,2, new QTableWidgetItem( QString::number(maxV) ) );
......@@ -305,41 +289,23 @@ void InfoPlugin::printMeshInfo( MeshT* _mesh , int _id, unsigned int _face ) {
info_->table->resizeColumnsToContents();
info_->table3->clear();
info_->table3->setColumnCount ( 3 );
headerdata.clear();
headerdata << "X" << "Y" << "Z";
info_->table3->setHorizontalHeaderLabels(headerdata);
typename MeshT::FaceHandle fh = _mesh->face_handle(_face);
headerdata.clear();
headerdata << tr("Bounding Box (Minimum)") << tr("Bounding Box (Maximum)") << tr("BoundingBox (Size)") << tr("Center of Gravity");
headerdata << tr("Picked Face Normal (Handle %1 )" ).arg(fh.idx());
//adjacent vertex handles
typename MeshT::FaceVertexIter fv_it = _mesh->fv_iter(fh);
int vertexCount = 0;
while( fv_it ){
headerdata << tr("Adjacent Vertex (Handle %1 )").arg(fv_it.handle().idx());
QString adjacentVertices;
if ( fv_it ){
adjacentVertices = QString::number( fv_it.handle().idx() );
++fv_it;
vertexCount++;
}
info_->table3->setRowCount ( 5 + vertexCount );
info_->table3->setVerticalHeaderLabels(headerdata);
while( fv_it ){
adjacentVertices += "," + QString::number( fv_it.handle().idx() );
++fv_it;
}
//set tooltips
info_->table3->verticalHeaderItem(0)->setToolTip(tr("minimum corner coordinates of the bounding box"));
info_->table3->verticalHeaderItem(1)->setToolTip(tr("maximum corner coordinates of the bounding box"));
info_->table3->verticalHeaderItem(2)->setToolTip(tr("diagonal size of the bounding box"));
info_->table3->verticalHeaderItem(3)->setToolTip(tr("coordinates of the center of gravity"));
info_->table3->verticalHeaderItem(4)->setToolTip(tr("direction of the face normal that was picked"));
for (int i=0; i < vertexCount; i++)
info_->table3->verticalHeaderItem(5 + i)->setToolTip(tr("Coordinates of a vertex which is adjacent to the picked face"));
info_->adjVertexHandles->setText( adjacentVertices );
//Calculate Bounding Box(min,max,cog)
ACG::Vec3d min;
......@@ -349,45 +315,41 @@ void InfoPlugin::printMeshInfo( MeshT* _mesh , int _id, unsigned int _face ) {
//Bounding Box Size
ACG::Vec3d diff = max-min;
row=0;
info_->table3->setItem(row,0, new QTableWidgetItem( QString::number(min[0],'f') ) );
info_->table3->setItem(row,1, new QTableWidgetItem( QString::number(min[1],'f') ) );
info_->table3->setItem(row,2, new QTableWidgetItem( QString::number(min[2],'f') ) );
row++;
info_->table3->setItem(row,0, new QTableWidgetItem( QString::number(max[0],'f') ) );
info_->table3->setItem(row,1, new QTableWidgetItem( QString::number(max[1],'f') ) );
info_->table3->setItem(row,2, new QTableWidgetItem( QString::number(max[2],'f') ) );
row++;
info_->table3->setItem(row,0, new QTableWidgetItem( QString::number(diff[0],'f') ) );
info_->table3->setItem(row,1, new QTableWidgetItem( QString::number(diff[1],'f') ) );
info_->table3->setItem(row,2, new QTableWidgetItem( QString::number(diff[2],'f') ) );
info_->bbMinX->setText( QString::number(min[0],'f') );
info_->bbMinY->setText( QString::number(min[1],'f') );
info_->bbMinZ->setText( QString::number(min[2],'f') );
info_->bbMaxX->setText( QString::number(max[0],'f') );
info_->bbMaxY->setText( QString::number(max[1],'f') );
info_->bbMaxZ->setText( QString::number(max[2],'f') );
info_->bbSizeX->setText( QString::number(diff[0],'f') );
info_->bbSizeY->setText( QString::number(diff[1],'f') );
info_->bbSizeZ->setText( QString::number(diff[2],'f') );
//COG
ACG::Vec3d cog = MeshInfo::cog(*_mesh);
row++;
info_->table3->setItem(row,0, new QTableWidgetItem( QString::number(cog[0],'f') ) );
info_->table3->setItem(row,1, new QTableWidgetItem( QString::number(cog[1],'f') ) );
info_->table3->setItem(row,2, new QTableWidgetItem( QString::number(cog[2],'f') ) );
info_->cogX->setText( QString::number(cog[0],'f') );
info_->cogY->setText( QString::number(cog[1],'f') );
info_->cogZ->setText( QString::number(cog[2],'f') );
//face-normal
row++;
info_->table3->setItem(row,0, new QTableWidgetItem( QString::number( _mesh->normal(fh)[0],'f' ) ) );
info_->table3->setItem(row,1, new QTableWidgetItem( QString::number( _mesh->normal(fh)[1],'f' ) ) );
info_->table3->setItem(row,2, new QTableWidgetItem( QString::number( _mesh->normal(fh)[2],'f' ) ) );
info_->normalX->setText( QString::number( _mesh->normal(fh)[0],'f' ) );
info_->normalY->setText( QString::number( _mesh->normal(fh)[1],'f' ) );
info_->normalZ->setText( QString::number( _mesh->normal(fh)[2],'f' ) );
fv_it = _mesh->fv_iter(fh);
while( fv_it )
{
row++;
info_->table3->setItem(row,0, new QTableWidgetItem( QString::number( _mesh->point(fv_it)[0],'f' ) ) );
info_->table3->setItem(row,1, new QTableWidgetItem( QString::number( _mesh->point(fv_it)[1],'f' ) ) );
info_->table3->setItem(row,2, new QTableWidgetItem( QString::number( _mesh->point(fv_it)[2],'f' ) ) );
//hitpoint
info_->pointX->setText( QString::number( _hitPoint[0],'f' ) );
info_->pointY->setText( QString::number( _hitPoint[1],'f' ) );
info_->pointZ->setText( QString::number( _hitPoint[2],'f' ) );
++fv_it;
}
info_->table3->resizeColumnsToContents();
//closest vertex
info_->vertexX->setText( QString::number( _mesh->point( _mesh->vertex_handle(closest_v_idx) )[0],'f' ) );
info_->vertexY->setText( QString::number( _mesh->point( _mesh->vertex_handle(closest_v_idx) )[1],'f' ) );
info_->vertexZ->setText( QString::number( _mesh->point( _mesh->vertex_handle(closest_v_idx) )[2],'f' ) );
info_->setWindowFlags(info_->windowFlags() | Qt::WindowStaysOnTopHint);
......@@ -416,16 +378,16 @@ int InfoPlugin::getClosestVertex(MeshT* _mesh, int _face_idx) {
for (fv_it = _mesh->fv_iter(_mesh->face_handle(_face_idx)); fv_it; ++fv_it){
p = _mesh->point( fv_it.handle() );
p = _mesh->point( fv_it.handle() );
// Find closest vertex to selection
vTemp = ACG::Vec3d(p[0], p[1], p[2]);
temp_dist = (vTemp - hit_point_).length();
// Find closest vertex to selection
vTemp = ACG::Vec3d(p[0], p[1], p[2]);
temp_dist = (vTemp - hit_point_).length();
if (temp_dist < dist) {
dist = temp_dist;
closest_v_idx = fv_it.handle().idx();
}
if (temp_dist < dist) {
dist = temp_dist;
closest_v_idx = fv_it.handle().idx();
}
}
return closest_v_idx;
......@@ -453,26 +415,26 @@ int InfoPlugin::getClosestEdge(MeshT* _mesh, int _face_idx) {
for (fh_it = _mesh->fh_iter(_mesh->face_handle(_face_idx)); fh_it; ++fh_it){
v1 = _mesh->from_vertex_handle(fh_it);
v2 = _mesh->to_vertex_handle(fh_it);
v1 = _mesh->from_vertex_handle(fh_it);
v2 = _mesh->to_vertex_handle(fh_it);
p1 = _mesh->point(v1);
p2 = _mesh->point(v2);
p1 = _mesh->point(v1);
p2 = _mesh->point(v2);
vp1 = ACG::Vec3d(p1[0], p1[1], p1[2]);
vp2 = ACG::Vec3d(p2[0], p2[1], p2[2]);
vp1 = ACG::Vec3d(p1[0], p1[1], p1[2]);
vp2 = ACG::Vec3d(p2[0], p2[1], p2[2]);
e = vp2 - vp1;
e.normalize();
g = click - vp1;
x = g | e;
e = vp2 - vp1;
e.normalize();
g = click - vp1;
x = g | e;
temp_dist = (click - (vp1 + x * e)).length();
temp_dist = (click - (vp1 + x * e)).length();
if (temp_dist < dist) {
dist = temp_dist;
closest_e_handle = _mesh->edge_handle(fh_it.handle()).idx();
}
if (temp_dist < dist) {
dist = temp_dist;
closest_e_handle = _mesh->edge_handle(fh_it.handle()).idx();
}
}
return closest_e_handle;
......@@ -497,14 +459,14 @@ InfoPlugin::
emit log( LOGINFO , object->getObjectinfo() );
// Set hit point
hit_point_ = ACG::Vec3d(hit_point[0], hit_point[1], hit_point[2]);
// Set hit point
hit_point_ = ACG::Vec3d(hit_point[0], hit_point[1], hit_point[2]);
if ( object->picked(node_idx) && object->dataType(DATA_TRIANGLE_MESH) )
printMeshInfo( PluginFunctions::triMesh(object) , object->id(), target_idx );
printMeshInfo( PluginFunctions::triMesh(object) , object->id(), target_idx, hit_point_ );
if ( object->picked(node_idx) && object->dataType(DATA_POLY_MESH) )
printMeshInfo( PluginFunctions::polyMesh(object) , object->id(), target_idx );
printMeshInfo( PluginFunctions::polyMesh(object) , object->id(), target_idx, hit_point_ );
} else return;
}
......
......@@ -112,7 +112,7 @@ class InfoPlugin : public QObject, BaseInterface, MouseInterface, LoggingInterfa
InfoDialog* info_;
template< class MeshT >
void printMeshInfo( MeshT* _mesh, int _id, unsigned int _face );
void printMeshInfo( MeshT* _mesh, int _id, unsigned int _face, ACG::Vec3d& _hitPoint );
//===========================================================================
......
<RCC>
<qresource prefix="info" >
<file>dialogIcons/info_boundaries.png</file>
<file>dialogIcons/info_boundingbox.png</file>
<file>dialogIcons/info_bracketA.png</file>
<file>dialogIcons/info_bracketB.png</file>
<file>dialogIcons/info_components.png</file>
<file>dialogIcons/info_edges.png</file>
<file>dialogIcons/info_faces.png</file>
<file>dialogIcons/info_genus.png</file>
<file>dialogIcons/info_vertices.png</file>
</qresource>
</RCC>
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment