//
// File: mview.cc
//
// (C) 2000-2008 Helmut Cantzler
//
// Licensed under the terms of the Lesser General Public License.
//
#include <QtGui>
#include <QString>
#include "mesh.h"
#include "mview.h"
#include "viewpointdialog.h"
#include "coordinates.h"
#include "p_mesh.h"
#include "gts_mesh.h"
#include "geomview_mesh.h"
#include "vrml1_mesh.h"
#include "vrml2_mesh.h"
#include "list_mesh.h"
#include "feature_mesh.h"
#include "ply_mesh.h"
#include "obj_mesh.h"
#include "vtk_mesh.h"
#include "x3d_mesh.h"
#include "shallo_mesh.h"
#include "icons/icon_fileopen.xpm"
#include "icons/icon_texture.xpm"
#include "icons/icon_solid.xpm"
#include "icons/icon_wire.xpm"
#include "icons/icon_point.xpm"
#include "icons/icon_front.xpm"
#include "icons/icon_feature.xpm"
#include "icons/icon_coordinates.xpm"
QProgressDialog *pd;
int updateProgress(int pos)
{
static int q=0;
if (q % 100 == 0)
pd->setValue(pos);
q++;
return pd->wasCanceled();
}
void setTotal(int size)
{
pd->setMaximum(size);
}
MView::MView(int argc, char **argv)
{
//// Set OpenGL options ////
QGLFormat f;
f.setDoubleBuffer(TRUE);
f.setDepth(TRUE);
f.setStencil(TRUE);
QGLFormat::setDefaultFormat(f);
//// Init mesh display options ////
settings = new GLMeshSettings();
//// Open 3D model file, if specified in command line argument ////
if (argc >= 2)
{
name = argv[1];
loadModelFile(argv[1], &settings->mesh);
if (settings->mesh != NULL)
{
// Map vertices and triangle centroids to mesh centroid
settings->mesh->moveToCentre();
settings->mesh->scaleIntoNormalSphere();
}
}
if (argc >= 3)
{
loadModelFile(argv[2], &settings->features);
if (settings->features != NULL)
{
settings->features->scaleAccordingToReferenceMesh(settings->mesh);
}
}
//// Set-up main window
setWindowTitle("Mesh Viewer");
resize(580, 620);
//// Set-up main widgets ////
QWidget *hbox = new QWidget;
QHBoxLayout *layout = new QHBoxLayout;
layout->setMargin(10);
layout->setSpacing(10);
hbox->setLayout(layout);
glmesh = new GLMesh(hbox, settings);
layout->addWidget(glmesh);
clipping = new QSlider(hbox);
clipping->setMinimum(-20);
clipping->setMaximum(60);
clipping->setValue(0);
clipping->setToolTip("Clipping");
connect(clipping, SIGNAL(valueChanged(int)), glmesh, SLOT(setClipping(int)));
layout->addWidget(clipping);
setCentralWidget(hbox);
//// Set-up menus, toolbar and statusbar ////
createActions();
createMenus();
createToolBars();
createStatusBar();
setStatus();
// start timer for updating labelFPS every 3 seconds
startTimer(3000);
// set default display options
setDefaultConfig();
/*
// Display OpenGL information
printf("depth: %d\n", glmesh->format().depth() ? 1 : 0);
printf("rgba: %d\n", glmesh->format().rgba() ? 1 : 0);
printf("alpha: %d\n", glmesh->format().alpha() ? 1 : 0);
printf("accum: %d\n", glmesh->format().accum() ? 1 : 0);
printf("stencil: %d\n", glmesh->format().stencil() ? 1 : 0);
printf("stereo: %d\n", glmesh->format().stereo() ? 1 : 0);
printf("directRendering: %d\n", glmesh->format().directRendering() ? 1 : 0);
printf("hasOverlay: %d\n", glmesh->format().hasOverlay() ? 1 : 0);
*/
}
MView::~MView()
{
settings->clear();
delete settings;
}
void MView::createActions()
{
openAct = new QAction(QIcon(icon_fileopen), tr("&Open model"), this);
openAct->setShortcut(tr("O"));
connect(openAct, SIGNAL(triggered()), this, SLOT(loadModel()) );
openFeatAct = new QAction(tr("Open &features"), this);
connect(openFeatAct, SIGNAL(triggered()), this, SLOT(loadFeatures()) );
screenshotActs = new QActionGroup(this);
QList<QByteArray> formats = QImageWriter::supportedImageFormats();
for (int i = 0; i < formats.size(); ++i) {
screenshotActs->addAction(formats.at(i).constData());
}
connect(screenshotActs, SIGNAL(triggered(QAction*)),
this, SLOT(takeShot(QAction*)) );
saveActs = new QActionGroup(this);
saveActs->addAction("P Mesh");
saveActs->addAction("GTS");
saveActs->addAction("Geomview");
saveActs->addAction("VRML 1");
saveActs->addAction("VRML 2");
saveActs->addAction("PLY");
saveActs->addAction("OBJ");
saveActs->addAction("VTK");
saveActs->addAction("X3D");
saveActs->addAction("Shallo");
connect(saveActs, SIGNAL(triggered(QAction*)),
this, SLOT(saveAs(QAction*)) );
exitAct = new QAction(tr("&Quit"), this);
exitAct->setShortcut(Qt::Key_Escape);
connect(exitAct, SIGNAL(triggered()), qApp, SLOT(closeAllWindows()));
dTextAct = new QAction(QIcon(icon_texture), tr("&Texture"), this);
dTextAct->setCheckable(true);
dTextAct->setShortcut(tr("1"));
dSolidAct = new QAction(QIcon(icon_solid), tr("S&olid"), this);
dSolidAct->setCheckable(true);
dSolidAct->setShortcut(tr("2"));
dFrontAct = new QAction(QIcon(icon_front), tr("F&rontlines"), this);
dFrontAct->setCheckable(true);
dFrontAct->setShortcut(tr("3"));
dWireAct = new QAction(QIcon(icon_wire), tr("&Wireframe"), this);
dWireAct->setCheckable(true);
dWireAct->setShortcut(tr("4"));
dPointAct = new QAction(QIcon(icon_point), tr("Po&ints"), this);
dPointAct->setCheckable(true);
dPointAct->setShortcut(tr("5"));
dFeatAct = new QAction(QIcon(icon_feature), tr("F&eature"), this);
dFeatAct->setCheckable(true);
dFeatAct->setShortcut(tr("6"));
displayActs = new QActionGroup(this);
displayActs->addAction(dTextAct);
displayActs->addAction(dSolidAct);
displayActs->addAction(dFrontAct);
displayActs->addAction(dWireAct);
displayActs->addAction(dPointAct);
displayActs->addAction(dFeatAct);
connect(displayActs, SIGNAL(triggered(QAction*)),
glmesh, SLOT(setDisplayMode(QAction*)) );
pickAct = new QAction(QIcon(icon_coordinates), tr("&Pick objects"), this);
pickAct->setCheckable(true);
pickAct->setShortcut(tr("P"));
connect(pickAct, SIGNAL(triggered(bool)), this, SLOT(togglePick(bool)) );
lightAct = new QAction(tr("Lighting"), this);
lightAct->setCheckable(true);
lightAct->setShortcut(tr("L"));
connect(lightAct, SIGNAL(triggered(bool)),
glmesh, SLOT(setLight(bool)) );
polyAct = new QAction(tr("Show polygons"), this);
polyAct->setCheckable(true);
polyAct->setShortcut(tr("Y"));
connect(polyAct, SIGNAL(triggered(bool)),
glmesh, SLOT(setPolygons(bool)) );
shapeAct = new QAction(tr("Shape colours"), this);
shapeAct->setCheckable(true);
shapeAct->setShortcut(tr("S"));
connect(shapeAct, SIGNAL(triggered(bool)),
glmesh, SLOT(setShapeColors(bool)) );
normAct = new QAction(tr("Surface normals"), this);
normAct->setCheckable(true);
normAct->setShortcut(tr("N"));
connect(normAct, SIGNAL(triggered(bool)),
glmesh, SLOT(setNormals(bool)) );
boundingAct = new QAction(tr("Bounding Box"), this);
boundingAct->setCheckable(true);
boundingAct->setShortcut(tr("B"));
connect(boundingAct, SIGNAL(triggered(bool)),
glmesh, SLOT(setBoundingBox(bool)) );
cutAct = new QAction(tr("Cut back faces"), this);
cutAct->setCheckable(true);
cutAct->setShortcut(tr("C"));
connect(cutAct, SIGNAL(triggered(bool)),
glmesh, SLOT(setBackFaces(bool)) );
filtAct = new QAction(tr("Bilinear filtering"), this);
filtAct->setCheckable(true);
filtAct->setShortcut(tr("T"));
connect(filtAct, SIGNAL(triggered(bool)),
glmesh, SLOT(setTextureFiltering(bool)) );
featAct = new QAction(tr("Features"), this);
featAct->setCheckable(true);
featAct->setShortcut(tr("F"));
connect(featAct, SIGNAL(triggered(bool)),
glmesh, SLOT(setFeatures(bool)) );
keepAct = new QAction(tr("Keep aspect ratio"), this);
keepAct->setCheckable(true);
keepAct->setShortcut(tr("K"));
connect(keepAct, SIGNAL(triggered(bool)),
没有合适的资源?快使用搜索试试~ 我知道了~
mview-src-0.3.2.tar.gz
需积分: 10 13 下载量 139 浏览量
2009-12-09
21:56:36
上传
评论
收藏 444KB GZ 举报
温馨提示
共140个文件
cpp:47个
h:42个
jpg:19个
mview-src-0.3.2.tar.gz 一个简单的查看三维图形工具源码
资源推荐
资源详情
资源评论
收起资源包目录
mview-src-0.3.2.tar.gz (140个子文件)
AUTHORS 1KB
CHANGELOG 33B
COPYING 26KB
mview.cpp 19KB
mview.cpp 18KB
mesh.cpp 17KB
glmesh.cpp 17KB
glmesh.cpp 17KB
vrml2_mesh.cpp 13KB
glmesh.cpp 13KB
glmesh_common.cpp 13KB
glmesh_common.cpp 13KB
glmesh_common.cpp 13KB
glmesh.moc.cpp 7KB
triangle.cpp 7KB
mview.moc.cpp 5KB
mathvector.cpp 5KB
vrml1_mesh.cpp 5KB
geomview_mesh.cpp 5KB
ply_mesh.cpp 4KB
vtk_mesh.cpp 4KB
obj_mesh.cpp 4KB
main.cpp 4KB
glmesh.moc.cpp 4KB
shallo_mesh.cpp 4KB
p_mesh.cpp 4KB
gts_mesh.cpp 4KB
image.cpp 3KB
viewpointdialog.cpp 3KB
mview.moc.cpp 3KB
viewpointdialog.cpp 3KB
x3d_mesh.cpp 3KB
viewpointdialog.moc.cpp 3KB
vertex.cpp 3KB
edge.cpp 3KB
coordinates.moc.cpp 3KB
shape.cpp 2KB
feature_mesh.cpp 2KB
coordinates.cpp 2KB
coordinates.cpp 2KB
list_mesh.cpp 2KB
viewpointdialog.moc.cpp 2KB
texture.cpp 2KB
coordinates.moc.cpp 2KB
texture.cpp 2KB
texture.cpp 2KB
image.cpp 1KB
image.cpp 1KB
main.cpp 549B
main.cpp 508B
style.css 344B
Doxyfile 10KB
matrix3.h 3KB
matrix3.h 3KB
glmesh.h 3KB
glmesh.h 3KB
mesh.h 3KB
glmesh.h 2KB
mathvector.h 2KB
mview.h 2KB
mview.h 2KB
triangle.h 2KB
vertex.h 2KB
timeval.h 1KB
timeval.h 1KB
timeval.h 1KB
shape.h 1KB
edge.h 1KB
array3d.h 949B
array3d.h 949B
array3d.h 949B
misc.h 891B
vrml2_mesh.h 841B
viewpointdialog.h 751B
list_mesh.h 695B
image.h 635B
texture.h 587B
texture.h 587B
texture.h 587B
image.h 575B
image.h 575B
viewpointdialog.h 555B
coordinates.h 545B
coordinates.h 517B
shallo_mesh.h 447B
gts_mesh.h 443B
geomview_mesh.h 426B
feature_mesh.h 422B
ply_mesh.h 421B
obj_mesh.h 421B
vrml1_mesh.h 414B
x3d_mesh.h 403B
vtk_mesh.h 403B
p_mesh.h 399B
index.html 10KB
formats.html 5KB
changelog.html 5KB
build.html 4KB
bunny.html 969B
mummy.html 943B
共 140 条
- 1
- 2
资源评论
morre
- 粉丝: 187
- 资源: 2337
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功