6 #ifndef OPENMESHAPPS_VIEWERWIDGET_HH
7 #define OPENMESHAPPS_VIEWERWIDGET_HH
12 #include <QFileDialog>
13 #include <QPushButton>
15 #include <QColorDialog>
16 #include <OpenMesh/Tools/Utils/getopt.h>
17 #include <OpenMesh/Tools/Utils/Timer.hh>
19 #include <OpenMesh/Core/Mesh/TriMesh_ArrayKernelT.hh>
22 #include <QVBoxLayout>
23 #include <QHBoxLayout>
24 #include <qpushbutton.h>
30 using namespace OpenMesh;
31 using namespace OpenMesh::Attributes;
47 mhMesh->mesh = &mesh_;
50 OpenMesh::IO::Options& options() {
return _options; }
51 const OpenMesh::IO::Options& options()
const {
return _options; }
52 void setOptions(
const OpenMesh::IO::Options& opts) { _options = opts; }
54 void open_mesh_gui(QString fname)
56 OpenMesh::Utils::Timer t;
58 LoadMeshErr err = open_mesh(fname.toLocal8Bit(), _options);
60 if ( fname.isEmpty() || err==
UNKNOWN)
62 QString msg =
"Cannot read mesh from file:\n '";
65 QMessageBox::critical( NULL, windowTitle(), msg);
68 QString msg =
"Your mesh must have at least 64 vertices!";
69 QMessageBox::information( NULL, windowTitle(), msg);
72 QString msg =
"Computing the manifold harmonics of a mesh with n vertices includes ";
73 msg+=
"computing the eigenvectors of an nxn-matrix, which has a complexity of O(n^3). ";
74 msg+=
"So, for your own good, please try to load a mesh with less than 1000 vertices.";
75 QMessageBox::information( NULL, windowTitle(), msg);
78 QString msg =
"Your mesh should be manifold and closed in order to look good after reconstruction.";
79 QMessageBox::information( NULL, windowTitle(), msg);
83 std::cout <<
"Loaded mesh in ~" << t.as_string() << std::endl;
87 void open_audio_gui(QString fname)
89 if ( fname.isEmpty() || !open_audio( fname.toLocal8Bit() ) )
91 QString msg =
"Cannot load audio file from file:\n '";
93 QMessageBox::warning( NULL, windowTitle(), msg );
99 void query_open_mesh_file() {
100 QString fileName = QFileDialog::getOpenFileName(
this,
101 tr(
"Open mesh file"),
103 tr(
"OBJ Files (*.obj);;"
104 "OFF Files (*.off);;"
105 "STL Files (*.stl);;"
107 if (!fileName.isEmpty())
108 open_mesh_gui(fileName);
110 void query_open_audio_file() {
111 QString fileName = QFileDialog::getOpenFileName(
this,
112 tr(
"Open audio file"),
114 tr(
"Mp3 Files (*.mp3);;"
116 if (!fileName.isEmpty())
117 open_audio_gui(fileName);
119 void changeFreqs(
int freqs)
121 int newfreqs = (int)pow((
double)2,freqs);
122 if(newfreqs > mhMesh->mesh->n_vertices()){
125 Config::numFreqs = newfreqs;
126 audio.setFreqs(Config::numFreqs);
128 void changeSmoothing(
int s)
130 Config::smoothing = s;
142 audio.updateEQ(LOW, val);
145 audio.updateEQ(MID, val);
147 void eqHigh(
int val){
148 audio.updateEQ(HIGH, val);
150 void query_change_color(){
151 QColor c = QColorDialog::getColor();
152 float r = (float)c.red()/255;
153 float g = (float)c.green()/255;
154 float b = (float)c.blue()/255;
160 OpenMesh::IO::Options _options;