Changeset 2614 for GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface
- Timestamp:
- 01/18/08 16:28:30 (16 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
r2613 r2614 386 386 for (dit = mDynamicObjects.begin(); dit != dit_end; ++ dit) 387 387 { 388 //cerr << "here45\n****"<<endl; 388 389 RenderIntersectable(*dit); 389 390 } … … 659 660 int diffy = -(mousePoint.y - y); 660 661 662 const float t = 1.0f; 663 661 664 if (e->modifiers() & Qt::ControlModifier) 662 665 { … … 664 667 mViewPoint.x += (x-mousePoint.x)*MOVE_SENSITIVITY / 2.0; 665 668 } 666 else 669 else if (e->modifiers() & Qt::AltModifier) 670 { 671 if (mCurrentDynamicObjectIdx >= 0) 672 { 673 Matrix4x4 tm; 674 TransformedMeshInstance *tmi; 675 676 switch (mTrafoType) 677 { 678 case 0: 679 { 680 const Vector3 transl(diffx, 0, diffy); 681 tmi = mViewCellsManager->GetPreprocessor()->mDynamicObjects[mCurrentDynamicObjectIdx]; 682 tm = TranslationMatrix(transl); 683 } 684 break; 685 case 1: 686 { 687 float scalef = 1.0f + 0.01f * (diffx + diffy); 688 if (scalef < 0.9) scalef = 0.9f; 689 else if (scalef > 1.1f) scalef = 1.1f; 690 tmi = mViewCellsManager->GetPreprocessor()->mDynamicObjects[mCurrentDynamicObjectIdx]; 691 tm = ScaleMatrix(scalef, scalef, scalef); 692 } 693 break; 694 case 2: 695 { 696 tmi = mViewCellsManager->GetPreprocessor()->mDynamicObjects[mCurrentDynamicObjectIdx]; 697 tm = RotationXMatrix(diffx) * RotationYMatrix(diffy); 698 } 699 break; 700 default: 701 cerr << "not implemented" << endl; 702 } 703 704 tmi->ApplyWorldTransform(tm); 705 updateGL(); 706 } 707 } 708 else 667 709 { 668 710 mViewPoint += mViewDirection*((mousePoint.y - y)*MOVE_SENSITIVITY); … … 889 931 mShowWeightedTriangles = false; 890 932 mShowDistribution = 15; 933 mCurrentDynamicObjectIdx = -1; 891 934 892 935 mSpatialFilterSize = 0.01; 893 936 mPvsSize = 0; 894 937 mRayVisualizationMethod = 0; 938 mTrafoType = 0; 939 895 940 mRenderError = 0.0f; 896 941 mShowRays = false; … … 950 995 connect(mControlWidget, SIGNAL(SetShowDistribution4(bool)), this, SLOT(SetShowDistribution4(bool))); 951 996 952 953 997 connect(mControlWidget, SIGNAL(SetShowRays(bool)), this, SLOT(SetShowRays(bool))); 954 998 999 connect(mControlWidget, SIGNAL(SetTranslation(bool)), this, SLOT(SetTranslation(bool))); 1000 connect(mControlWidget, SIGNAL(SetRotation(bool)), this, SLOT(SetRotation(bool))); 1001 connect(mControlWidget, SIGNAL(SetScale(bool)), this, SLOT(SetScale(bool))); 1002 955 1003 // setting the size here 956 1004 resize(800, 600); … … 1009 1057 void QtGlRendererWidget::LoadObject() 1010 1058 { 1011 string filename("../data/ bunny.bn");1059 string filename("../data/teapot.bn"); 1012 1060 1013 1061 cout << "Loading model << " << filename << endl; 1062 1063 ++ mCurrentDynamicObjectIdx; 1014 1064 1015 1065 if (mViewCellsManager->GetPreprocessor()->LoadDynamicGeometry(filename)) … … 1587 1637 1588 1638 rb1 = new QRadioButton("random colors", parent); 1589 rb1->setText(" wireframe");1639 rb1->setText("random"); 1590 1640 connect(rb1, SIGNAL(toggled(bool)), SIGNAL(SetShowWireFrame(bool))); 1591 1641 … … 1627 1677 1628 1678 1679 QGroupBox *QtRendererControlWidget::CreateTrafoPanel(QWidget *parent) 1680 { 1681 QRadioButton *rb1, *rb2, *rb3; 1682 1683 rb1 = new QRadioButton("translation", parent); 1684 rb1->setText("translation"); 1685 connect(rb1, SIGNAL(toggled(bool)), SIGNAL(SetTranslation(bool))); 1686 1687 // Create a check box to be in the group box 1688 rb2 = new QRadioButton("scale", parent); 1689 rb2->setText("scale"); 1690 //vl->addWidget(rb1); 1691 connect(rb2, SIGNAL(toggled(bool)), SIGNAL(SetScale(bool))); 1692 1693 rb3 = new QRadioButton("rotation", parent); 1694 rb3->setText("rotation"); 1695 connect(rb3, SIGNAL(toggled(bool)), SIGNAL(SetRotation(bool))); 1696 1697 QVBoxLayout *vbox2 = new QVBoxLayout; 1698 QGroupBox *groupBox = new QGroupBox("Trafo types"); 1699 1700 vbox2->addWidget(rb1); 1701 vbox2->addWidget(rb2); 1702 vbox2->addWidget(rb3); 1703 1704 rb1->setChecked(true); 1705 1706 vbox2->addStretch(1); 1707 groupBox->setLayout(vbox2); 1708 1709 return groupBox; 1710 } 1711 1712 1629 1713 1630 1714 QGroupBox *QtRendererControlWidget::CreateRenderCostPanel(QWidget *parent) … … 1646 1730 1647 1731 QGroupBox *groupBox = new QGroupBox("Render cost options"); 1648 1649 1732 QVBoxLayout *vbox2 = new QVBoxLayout; 1650 1733 … … 1857 1940 QGroupBox *groupBox3 = CreateRayVisualizationPanel(hbox); 1858 1941 vh->addWidget(groupBox3, 0, 0); 1942 1943 QGroupBox *groupBox4 = CreateTrafoPanel(hbox); 1944 vh->addWidget(groupBox4, 0, 0); 1859 1945 1860 1946 ////////////////////////////////// … … 2032 2118 cb->setChecked(false); 2033 2119 connect(cb, SIGNAL(toggled(bool)), SIGNAL(StoreStatistics()));*/ 2120 2034 2121 if (0) 2035 2122 { -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h
r2609 r2614 91 91 92 92 QGroupBox *CreateVisualizationPanel(QWidget *parent); 93 QGroupBox *CreateTrafoPanel(QWidget *parent); 93 94 94 95 public slots: … … 156 157 void SetShowDistribution3(bool); 157 158 void SetShowDistribution4(bool); 159 160 void SetTranslation(bool); 161 void SetRotation(bool); 162 void SetScale(bool); 158 163 }; 159 164 … … 204 209 int mShowDistribution; 205 210 211 int mCurrentDynamicObjectIdx; 212 206 213 // some statistics 207 214 int mPvsSize; … … 214 221 215 222 int mRayVisualizationMethod; 223 int mTrafoType; 216 224 217 225 QtRendererControlWidget *mControlWidget; … … 267 275 virtual int GetHeight() const { return height(); } 268 276 269 // virtual void270 // SetupProjection(const int w, const int h, const float angle = 70.0f);271 272 277 virtual void 273 278 SetupCameraProjection(const int w, const int h, const float angle = 70.0f); … … 479 484 mRayVisualizationMethod = 3; 480 485 } 481 486 487 void SetTranslation(bool b) 488 { 489 mTrafoType = 0; 490 } 491 492 void SetScale(bool b) 493 { 494 mTrafoType = 1; 495 } 496 497 void SetRotation(bool b) 498 { 499 mTrafoType = 2; 500 } 501 482 502 void SetShowDistribution1(bool b) 483 503 { -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.cpp
r2609 r2614 242 242 QtGlViewer::mouseMoveEvent(QMouseEvent *event) 243 243 { 244 int dx = event->x() - lastPos.x(); 245 int dy = event->y() - lastPos.y(); 246 247 if (event->modifiers() & Qt::CTRL) 248 { 249 scale = scale*(1.0f - dy/(float)height()); 250 if (scale < 0.01f) 251 scale = 0.01f; 252 updateGL(); 253 } 254 else { 244 int dx = event->x() - lastPos.x(); 245 int dy = event->y() - lastPos.y(); 246 247 if (event->modifiers() & Qt::CTRL) 248 { 249 scale = scale*(1.0f - dy/(float)height()); 250 if (scale < 0.01f) 251 scale = 0.01f; 252 updateGL(); 253 } 254 else 255 { 255 256 float W = width(); 256 257 float H = height(); … … 259 260 int y = event->y(); 260 261 int lastY = lastPos.y(); 261 262 262 263 float quat[4]; 263 264 trackball(quat, 264 265 266 267 268 265 (2.0 * lastX - W) / W, 266 (H - 2.0 * lastY) / H, 267 (2.0 * x - W) / W, 268 (H - 2.0 * y) / H 269 ); 269 270 270 271 add_quats(quat, manipulatorLastQuat, manipulatorLastQuat); 271 272 273 274 275 } 276 277 void QtGlViewer::timerEvent(QTimerEvent *event)278 {279 update();280 }281 282 283 } 284 272 } 273 274 lastPos = event->pos(); 275 updateGL(); 276 } 277 278 void QtGlViewer::timerEvent(QTimerEvent *event) 279 { 280 update(); 281 } 282 283 284 } 285 -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.h
r2567 r2614 58 58 float scale; 59 59 QPoint lastPos; 60 61 60 }; 62 61
Note: See TracChangeset
for help on using the changeset viewer.