From 95f4182f00b1a3eb813d18b82e88508be1170a19 Mon Sep 17 00:00:00 2001 From: nicopietroni Date: Wed, 6 Oct 2004 16:23:14 +0000 Subject: [PATCH] minor changes --- apps/tetraviewer/MainFrame.ui | 619 ++++++++++++++++++++++++++++++++ apps/tetraviewer/main.cpp | 7 +- apps/tetraviewer/mainframe.ui.h | 10 +- apps/tetraviewer/myglwidget.cpp | 94 +++-- 4 files changed, 685 insertions(+), 45 deletions(-) create mode 100644 apps/tetraviewer/MainFrame.ui diff --git a/apps/tetraviewer/MainFrame.ui b/apps/tetraviewer/MainFrame.ui new file mode 100644 index 00000000..eb3c2f3b --- /dev/null +++ b/apps/tetraviewer/MainFrame.ui @@ -0,0 +1,619 @@ + +MainFrame + + + MainFrame + + + + 0 + 0 + 908 + 846 + + + + TetraView + + + + file + + + + 70 + 0 + 90 + 80 + + + + + + + + OpenButton + + + + 10 + 10 + 70 + 60 + + + + + + + + + + buttonGroup1 + + + + 160 + 0 + 470 + 80 + + + + + + + true + + + + BoxButton + + + + 10 + 30 + 51 + 31 + + + + box + + + true + + + + + WireButton + + + + 80 + 30 + 40 + 30 + + + + Wire + + + true + + + + + HiddenButton + + + + 130 + 30 + 60 + 31 + + + + Hidden + + + true + + + + + FlatWireButton + + + + 260 + 30 + 61 + 31 + + + + FlatWire + + + true + + + + + SmoothButton + + + + 330 + 30 + 50 + 30 + + + + Smooth + + + true + + + + + SmallTetraButton + + + + 390 + 30 + 60 + 30 + + + + SmallTetra + + + true + + + + + FlatButton + + + + 200 + 30 + 50 + 30 + + + + Flat + + + true + + + true + + + false + + + false + + + + + + buttonGroup2 + + + + 630 + 0 + 230 + 80 + + + + + + + true + + + + TrackButton + + + + 140 + 20 + 61 + 31 + + + + Trackball + + + true + + + true + + + false + + + + + SectionButton + + + + 40 + 20 + 71 + 31 + + + + Section + + + true + + + + + + myGLWidget + + + + 70 + 70 + 790 + 720 + + + + + + + MenuBar + + + + + + + + + + + + + + + + + + + + + + + + + MyGLWidget +
D:/sf/apps/tetraviewer/myglwidget.h
+ + -1 + -1 + + 0 + + 5 + 5 + 0 + 0 + + image0 + signal() + setBox() + setWire() + setHidden() + setFlat() + setFlatWire() + setSmallTetra() + setSmooth() + TrackMouseModality() + SectionMouseModality() + slot() + slot() + SwitchTextSimplex() + slot() + SwitchTextPhysics() + slot() + SwitchTextQuality() +
+
+ + + + fileOpenAction + + + false + + + false + + + + + + Open + + + &Open... + + + Ctrl+O + + + + + fileExitAction + + + Exit + + + E&xit + + + + + + + + helpContentsAction + + + Contents + + + &Contents... + + + + + + + + helpIndexAction + + + Index + + + &Index... + + + + + + + + helpAboutAction + + + About + + + &About + + + + + + + + new_menunew_itemAction + + + + + + + + + + + infoSimplexAction + + + true + + + true + + + Simplex + + + Simplex + + + + + infoQualityAction + + + true + + + Quality + + + Quality + + + + + infoPhysicsAction + + + true + + + Physics + + + Physics + + + + + + 89504e470d0a1a0a0000000d4948445200000016000000160806000000c4b46c3b000003b149444154789cad94514c5b5518c77fe7dc4b7b4b6150bb96324418ca32358bee6192609c51d883892ce083f1718b3ebb185f8dc91e972cf39d2d6a78d0b027b3cd07d9e68c81c625a6c139408a4384f416100aed6d4b7bdb7b8e0fc0921a70c6ed7b3ae7e43bbff3fffedfc927e2f138bbd1dbdbab7902118fc785d8058f8d8de9aeae2e72b91cb66de338ce7f82e47239666767492412b8aefbf0dcdc553a323242f4501d918e2d3a8f15a9784584100809a609526eafd1a0f54e6142e029c5c21f3ef41583bb77a805efbe1ce9d86279e32619678eaab7853fa0f02a16abb64166ad0cdac75307eb3874b84cb0a14aa5a24108cc0688c48c9a4a1e826ddbe6f0b12219678e8ace610502ccdfafe3f68d3c33bf6c01c59dcc209d472c4e0d35d2f3ba81d205d06005e4de60c77170bd2255af80150870f70e8c0eaf009260a349577714e913a4175d16925b5cbe50607931cc3b677c68ca28a5f7066f5b26f00760febec9e8f032a0e81b68a17fc0201415989647a9d8c4c498cbe8f05f5cff3a4d4bac8bfe210b290b35e01afd428257b1b875cd01aaf4bd1de5dd0fea688e1530ad1c1bab16b7af17393558cf997311c0e49bafd670d6258621f6576c9ab09a3248fe5ae6c08103f49f36517213d33070369bf8e2529ee9c90ceb2b2eef7f14617c2c48722a4b7226845143fa87622905ebeb6514253a9eb5084504a66950c88618bee0303d99217cb09e9ed71a09369538fa523d00e9a50a42eed3bc6d8f41281fa0903e8561796cac86f8f2b33c33930ea0f0fb4d5adbeb30ad22866ffbbad226d2a805d7ee0484220208925aaa50deaa67e27b97e9c90ccdcdf5c462cdd8a94d2e7e62f3603244ea410989a4ed191f52a8fd156b056d9d553a9e0bf0e7ef45c6bf7339fd5e90ec7a88575e6d20d6e6e7e2a755ec854dce7fb8885b2cd014f6f3c2714d3a550bae55ac35c1068fb7061b00b87a7995899b25ce9e0b73e24d8fae97b37c7cbe9370b499fce6066eb54adf6098f6ee2a9a7ff9c70841a5023d270deca510d746537c7e29cdf8ad20475fb4307c82d4fc324ec6859d66fdfc6381e44014b36e9fe6e572393ca54068aa22cfd0598b686b3737aeae90bc9725796f0350802414b6e81b7c9a9f7e70708a2e6e5991cfeee3f1ecec2c0b0b3e8c068142a2a8d23728397132c6dc6f2e2b8b0a8da4b5ddc7f3c735ed47146f0cb4502983693a4c25ca7b83138904fa8a412466e00f48b4271086c2901263676c4a6990b615b6ade15b85694af239984a94585bf6f606bbae5b334f1f37e4a3531e031c8fc7c5a312ff17f849c3e3f1b8f81b8be6900aca9b61c90000000049454e44ae426082 + + + + + fileOpenAction + activated() + MainFrame + fileOpen() + + + helpAboutAction + activated() + MainFrame + helpAbout() + + + helpContentsAction + activated() + MainFrame + helpContents() + + + helpIndexAction + activated() + MainFrame + helpIndex() + + + BoxButton + pressed() + myGLWidget + setBox() + + + WireButton + pressed() + myGLWidget + setWire() + + + HiddenButton + pressed() + myGLWidget + setHidden() + + + FlatButton + pressed() + myGLWidget + setFlat() + + + FlatWireButton + pressed() + myGLWidget + setFlatWire() + + + SmoothButton + pressed() + myGLWidget + setSmooth() + + + SmallTetraButton + pressed() + myGLWidget + setSmallTetra() + + + OpenButton + clicked() + MainFrame + fileOpen() + + + SectionButton + pressed() + myGLWidget + SectionMouseModality() + + + TrackButton + pressed() + myGLWidget + TrackMouseModality() + + + infoPhysicsAction + activated() + myGLWidget + SwitchTextPhysics() + + + infoQualityAction + activated() + myGLWidget + SwitchTextQuality() + + + infoSimplexAction + activated() + myGLWidget + SwitchTextSimplex() + + + fileExitAction + activated() + MainFrame + close() + + + + MainFrame.ui.h + + + fileNew() + fileOpen() + fileSave() + fileSaveAs() + fileExit() + helpIndex() + helpContents() + helpAbout() + setWire() + + + + + myglwidget.h + +
diff --git a/apps/tetraviewer/main.cpp b/apps/tetraviewer/main.cpp index 2ae70b92..de12cc38 100644 --- a/apps/tetraviewer/main.cpp +++ b/apps/tetraviewer/main.cpp @@ -21,6 +21,8 @@ typedef vcg::tetra::UpdateNormals UN; typedef vcg::tetra::UpdateBounding UB; +//MainFrame *wp; + void openTetraMesh(const char* filename) { //opening the tetrahedral mesh @@ -52,10 +54,11 @@ int main( int argc, char ** argv ) QApplication a( argc, argv ); MainFrame w; +// wp=&w; + w.show(); - w.show(); - a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) ); + return a.exec(); } diff --git a/apps/tetraviewer/mainframe.ui.h b/apps/tetraviewer/mainframe.ui.h index a678dc56..ac83a54c 100644 --- a/apps/tetraviewer/mainframe.ui.h +++ b/apps/tetraviewer/mainframe.ui.h @@ -31,9 +31,11 @@ void MainFrame::fileOpen() this, "open file dialog" "Choose a TS Tetrahedral mesh file" ); - - const char *path=filename.ascii(); - openTetraMesh(path); + if (filename!=NULL) + { + const char *path=filename.ascii(); + openTetraMesh(path); + } } @@ -52,7 +54,7 @@ void MainFrame::fileSaveAs() void MainFrame::fileExit() { - + } diff --git a/apps/tetraviewer/myglwidget.cpp b/apps/tetraviewer/myglwidget.cpp index 849462d7..086ee1df 100644 --- a/apps/tetraviewer/myglwidget.cpp +++ b/apps/tetraviewer/myglwidget.cpp @@ -1,8 +1,11 @@ #include "myglwidget.h" #include #include +#include "mainframe.h" + extern MyTetraMesh *tm; extern TetraStats Stats; +//extern MainFrame *wp; bool MyGLWidget::ShowTextSimplex() { @@ -29,6 +32,7 @@ QGLWidget(parent, name) modality=3; mouse_modality=MMTrackball; _ShowBar=SIMPLEX; + grabKeyboard(); } @@ -66,7 +70,7 @@ void MyGLWidget::DrawTextInfo() renderText( (width() - 10) / 2, 15, "a" ); - QFont f( "arial", 8 ); + QFont f( "arial", 12 ); QFontMetrics fmc( f ); glColor3d(1,1,1); @@ -109,8 +113,6 @@ void MyGLWidget::DrawTextInfo() glDisable(GL_BLEND); //write values of the tetrahedron - glLineWidth(0.5); - glColor3d(1,0,0); for (int i=0;i<4;i++) { double x=Stats.TCurrent()->V(i)->P().V(0);//x value of vertex @@ -119,23 +121,23 @@ void MyGLWidget::DrawTextInfo() str.sprintf("%i",i); renderText(x,y,z,str,f); } - - //show the tetrahedron - glBegin(GL_LINE_LOOP); - for (int i=0;i<4;i++) - { - glVertex(Stats.TCurrent()->V(i)->P()); - } - glEnd(); - glBegin(GL_LINE_LOOP); - glVertex(Stats.TCurrent()->V(0)->P()); - glVertex(Stats.TCurrent()->V(2)->P()); - glEnd(); - glBegin(GL_LINE_LOOP); - glVertex(Stats.TCurrent()->V(1)->P()); - glVertex(Stats.TCurrent()->V(3)->P()); - glEnd(); - //end drawing + Stats.TCurrent()->SetS(); + ////show the tetrahedron + //glBegin(GL_LINE_LOOP); + //for (int i=0;i<4;i++) + //{ + // glVertex(Stats.TCurrent()->V(i)->P()); + //} + //glEnd(); + //glBegin(GL_LINE_LOOP); + // glVertex(Stats.TCurrent()->V(0)->P()); + // glVertex(Stats.TCurrent()->V(2)->P()); + //glEnd(); + //glBegin(GL_LINE_LOOP); + // glVertex(Stats.TCurrent()->V(1)->P()); + // glVertex(Stats.TCurrent()->V(3)->P()); + //glEnd(); + ////end drawing } glPopAttrib(); } @@ -271,28 +273,29 @@ void MyGLWidget::mousePressEvent ( QMouseEvent * e ) { if (e->button()==Qt::LeftButton) { - if (mouse_modality==MMTrackball) - { + MyTetraMesh::TetraIterator ti; + int face; + switch(mouse_modality) + { + case MMTrackball: Track.MouseDown(e->x(),_H-e->y(),vcg::Trackball::BUTTON_LEFT); - repaint(); - } - else - if (mouse_modality==MMSection) - { + break; + + case MMSection: LoadMatrix(); - MyTetraMesh::TetraIterator ti; - vcg::GLPickTetra::PickNearestTetra(e->x(),_H-e->y(),*tm,ti); + vcg::GLPickTetra::PickNearestTetraFace(e->x(),_H-e->y(),*tm,ti,face); if (ti!=0) { - ///find exterbnal face - int face=0; - while (!ti->IsBorderF(face)) - face++; - + ///find external face + + /*while (!ti->IsBorderF(face)) + face++;*/ + /*ti->SetS();*/ vcg::Point3d p0=ti->V(vcg::Tetra::VofF(face,0))->P(); vcg::Point3d p1=ti->V(vcg::Tetra::VofF(face,1))->P(); vcg::Point3d p2=ti->V(vcg::Tetra::VofF(face,2))->P(); - + + //put the trackball on the barycenter of the face MyTetraMesh::VertexType::CoordType b=(p0+p1+p2)/3.f; WT->AddClipSection(p0,p1,p2); @@ -304,19 +307,28 @@ if (e->button()==Qt::LeftButton) mouse_modality=MMNavigateSection; TrackClip.MouseDown(e->x(),_H-e->y(),vcg::Trackball::BUTTON_LEFT); } - } + break; + + case MMNavigateSection: + TrackClip.MouseDown(e->x(),_H-e->y(),vcg::Trackball::BUTTON_LEFT); + break; + + } } + else if (e->button()==Qt::RightButton) { MyTetraMesh::TetraIterator ti; LoadMatrix(); - //WT->section.GlClip(); + WT->section.GlClip(); vcg::GLPickTetra::PickNearestTetra(e->x(),_H-e->y(),*tm,ti); if (ti!=0) { Stats.TetraInfo(&*ti); } } + +repaint(); } void MyGLWidget::mouseReleaseEvent(QMouseEvent * e ) @@ -333,7 +345,7 @@ void MyGLWidget::mouseMoveEvent ( QMouseEvent * e ) repaint(); } else - if (mouse_modality==MMNavigateSection) + if ((mouse_modality==MMNavigateSection)&&(e->state() & Qt::LeftButton)) { LoadMatrix(); TrackClip.MouseMove(e->x(),_H-e->y()); @@ -367,12 +379,16 @@ void MyGLWidget::wheelEvent ( QWheelEvent * e ){ } } + void MyGLWidget::keyPressEvent(QKeyEvent *k) { mouse_modality=MMTrackball; if ((k->key()==Qt::Key_Escape)&&((mouse_modality==MMNavigateSection)||(mouse_modality==MMSection))) + { mouse_modality=MMTrackball; - + /*wp->SectionButton->setOn(false); + QString p=wp->TrackButton->text();*/ + } } void MyGLWidget::initializeGL(){