Changeset 2569 for GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface
- Timestamp:
- 12/17/07 18:39:12 (17 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
r2567 r2569 845 845 mUseTransparency = false; 846 846 847 mTransferFunction = 0.2f;847 mTransferFunction = 1.0f; 848 848 mIndexBufferSize = 0; 849 849 … … 866 866 mShowPiercingRays = false; 867 867 mShowWeightedRays = false; 868 mShowWeightedCost = false; 869 870 mShowDistanceWeightedPvs = true; 871 mShowDistanceWeightedTriangles = false; 872 mShowWeightedTriangles = false; 868 873 869 874 mSpatialFilterSize = 0.01; … … 909 914 connect(mControlWidget, SIGNAL(SetShowPiercingRays(bool)), this, SLOT(SetShowPiercingRays(bool))); 910 915 connect(mControlWidget, SIGNAL(SetShowWeightedRays(bool)), this, SLOT(SetShowWeightedRays(bool))); 916 connect(mControlWidget, SIGNAL(SetShowWeightedCost(bool)), this, SLOT(SetShowWeightedCost(bool))); 917 918 connect(mControlWidget, SIGNAL(SetShowDistanceWeightedTriangles(bool)), this, SLOT(SetShowDistanceWeightedTriangles(bool))); 919 connect(mControlWidget, SIGNAL(SetShowDistanceWeightedPvs(bool)), this, SLOT(SetShowDistanceWeightedPvs(bool))); 920 connect(mControlWidget, SIGNAL(SetShowWeightedTriangles(bool)), this, SLOT(SetShowWeightedTriangles(bool))); 911 921 912 922 connect(mControlWidget, … … 1154 1164 { 1155 1165 mHidingCost = (float)number / 1000.0f; 1156 //cout << "hiding cost " << mHidingCost << endl;1157 1166 } 1158 1167 … … 1161 1170 QtGlRendererWidget::SetTopDistance(int number) 1162 1171 { 1163 mTopDistance = number /1000.0f;1172 mTopDistance = number / 1000.0f; 1164 1173 updateGL(); 1165 1174 } 1166 1175 1167 void 1168 QtGlRendererWidget::SetTransparency(int number) 1169 { 1170 mTransparency = number/1000.0f; 1176 void QtGlRendererWidget::SetTransparency(int number) 1177 { 1178 mTransparency = number / 1000.0f; 1171 1179 updateGL(); 1172 1180 } 1181 1182 1183 float QtGlRendererWidget::ComputeRenderCost(ViewCell *vc) 1184 { 1185 ObjectPvs basePvs; 1186 1187 basePvs = vc->CopyPvs(); 1188 ObjectPvsIterator pit = basePvs.GetIterator(); 1189 1190 float renderCost = 0; 1191 1192 //cout << "cost vis: " << mShowDistanceWeightedPvs << " " << " " << mShowDistanceWeightedTriangles << " " << mShowWeightedTriangles << endl; 1193 1194 // first mark all objects from this pvs 1195 while (pit.HasMoreEntries()) 1196 { 1197 if (mShowDistanceWeightedPvs) 1198 { 1199 KdIntersectable *kdObj = static_cast<KdIntersectable *>(pit.Next()); 1200 const AxisAlignedBox3 box = kdObj->GetBox(); 1201 1202 const float dist = SqrDistance(vc->GetBox().Center(), box.Center()); 1203 renderCost += 1.0f / dist; 1204 } 1205 else if (mShowDistanceWeightedTriangles) 1206 { 1207 KdIntersectable *kdObj = static_cast<KdIntersectable *>(pit.Next()); 1208 const AxisAlignedBox3 box = kdObj->GetBox(); 1209 1210 const float dist = SqrDistance(vc->GetBox().Center(), box.Center()); 1211 renderCost += kdObj->ComputeNumTriangles() / dist; 1212 } 1213 else //if (mShowWeightedTriangles) 1214 { 1215 KdIntersectable *kdObj = static_cast<KdIntersectable *>(pit.Next()); 1216 renderCost += kdObj->ComputeNumTriangles(); 1217 } 1218 //if (pit.Next()->Mail(); 1219 } 1220 1221 return renderCost; 1222 } 1223 1173 1224 1174 1225 void … … 1198 1249 1199 1250 ViewCellContainer &viewcells = mViewCellsManager->GetViewCells(); 1251 1200 1252 int maxPvs = -1; 1201 1253 int maxPiercingRays = 1; // not zero for savety 1202 1254 float maxRelativeRays = Limits::Small; // not zero for savety 1255 float maxRcCost = Limits::Small; 1203 1256 1204 1257 for (i = 0; i < viewcells.size(); ++ i) … … 1206 1259 ViewCell *vc = viewcells[i]; 1207 1260 1208 //const int p = vc->GetPvs().CountObjectsInPvs(); 1209 const int p = vc->GetPvs().GetSize(); 1210 if (p > maxPvs) 1211 maxPvs = p; 1212 1213 const int piercingRays = vc->GetNumPiercingRays(); 1214 1215 if (piercingRays > maxPiercingRays) 1216 maxPiercingRays = piercingRays; 1217 1218 const float relativeArea = vc->GetBox().SurfaceArea() / mViewCellsManager->GetViewSpaceBox().SurfaceArea(); 1219 1220 if ((float)piercingRays / relativeArea > maxRelativeRays) 1221 maxRelativeRays = (float)piercingRays / relativeArea; 1222 } 1223 1224 if (!mShowPvsSizes && !mShowPiercingRays && !mShowWeightedRays) 1261 if (mShowPvsSizes) // pv 1262 { 1263 //const int p = vc->GetPvs().CountObjectsInPvs(); 1264 const int p = vc->GetPvs().GetSize(); 1265 if (p > maxPvs) 1266 maxPvs = p; 1267 } 1268 else if (mShowPiercingRays) // relative number of rays 1269 { 1270 const int piercingRays = vc->GetNumPiercingRays(); 1271 1272 if (piercingRays > maxPiercingRays) 1273 maxPiercingRays = piercingRays; 1274 } 1275 else if (mShowWeightedRays) 1276 { 1277 const int piercingRays = vc->GetNumPiercingRays(); 1278 1279 const float relativeArea = 1280 vc->GetBox().SurfaceArea() / mViewCellsManager->GetViewSpaceBox().SurfaceArea(); 1281 1282 if ((float)piercingRays / relativeArea > maxRelativeRays) 1283 maxRelativeRays = (float)piercingRays / relativeArea; 1284 } 1285 else if (mShowWeightedCost) 1286 { 1287 const float rcCost = ComputeRenderCost(vc); 1288 mViewCellsManager->UpdateScalarPvsCost(vc, rcCost); 1289 1290 if (rcCost > maxRcCost) 1291 maxRcCost = rcCost; 1292 } 1293 } 1294 1295 if (!mShowPvsSizes && !mShowPiercingRays && !mShowWeightedRays && !mShowWeightedCost) 1225 1296 { 1226 1297 for (i = 0; i < viewcells.size(); ++ i) … … 1237 1308 glColor3f(c.r, c.g, c.b); 1238 1309 1239 if (!mHideByCost || (mHidingCost < vc->GetNumPiercingRays() / (float)maxPiercingRays))1310 if (!mHideByCost || (mHidingCost < (vc->GetNumPiercingRays() / (float)maxPiercingRays))) 1240 1311 { 1241 1312 RenderViewCell(vc); … … 1269 1340 1270 1341 const float dist = SqrDistance(mDummyViewPoint, vc->GetBox().Center()); 1271 1272 1342 vc->SetDistance(dist); 1273 1343 } … … 1285 1355 if (mShowPiercingRays) 1286 1356 { 1287 // importance = 5.0f*mTransferFunction * ((float)vc->GetPvs().CountObjectsInPvs() / (float)maxPvs);1288 1357 importance = mTransferFunction * 1289 1358 ((float)vc->GetNumPiercingRays() / (float)maxPiercingRays); … … 1291 1360 else if (mShowWeightedRays) // relative number of rays 1292 1361 { 1293 // importance = 5.0f*mTransferFunction * ((float)vc->GetPvs().CountObjectsInPvs() / (float)maxPvs);1294 1362 float relativeArea = vc->GetBox().SurfaceArea() / mViewCellsManager->GetViewSpaceBox().SurfaceArea(); 1295 1363 … … 1301 1369 else if (mShowPvsSizes) // pvs size 1302 1370 { 1303 //importance = 5.0f*mTransferFunction * ((float)vc->GetPvs().CountObjectsInPvs() / (float)maxPvs);1304 1371 importance = mTransferFunction * 1305 1372 ((float)vc->GetPvs().GetSize() / (float)maxPvs); 1306 1373 } // weighted render cost 1307 /* else1374 else if (mShowWeightedCost) 1308 1375 { 1309 ObjectPvs basePvs = viewCell->GetPvs(); 1310 ObjectPvsIterator pit = basePvs.GetIterator(); 1311 1312 // first mark all objects from this pvs 1313 while (pit.HasMoreEntries()) 1314 { 1315 if (pit.Next()->Mail(); 1316 } 1317 }*/ 1376 const float rcCost = mTransferFunction * vc->GetTrianglesInPvs(); 1377 importance = rcCost / maxRcCost; 1378 } 1318 1379 1319 1380 // c = RgbColor(importance, 1.0f - importance, 0.0f); 1320 c = RainbowColorMapping( 5.0f *importance);1381 c = RainbowColorMapping(importance); 1321 1382 1322 1383 glColor4f(c.r, c.g, c.b, 1.0f - mTransparency); … … 1362 1423 } 1363 1424 1425 1426 QGroupBox *QtRendererControlWidget::CreateVisualizationPanel(QWidget *parent) 1427 { 1428 QRadioButton *rb1, *rb2, *rb3, *rb4, *rb5; 1429 1430 // Create a check box to be in the group box 1431 rb1 = new QRadioButton("piercing rays", parent); 1432 rb1->setText("piercing rays"); 1433 //vl->addWidget(rb1); 1434 connect(rb1, SIGNAL(toggled(bool)), SIGNAL(SetShowPiercingRays(bool))); 1435 1436 rb2 = new QRadioButton("pvs size", parent); 1437 rb2->setText("pvs size"); 1438 connect(rb2, SIGNAL(toggled(bool)), SIGNAL(SetShowPvsSizes(bool))); 1439 1440 rb3 = new QRadioButton("wireframe", parent); 1441 rb3->setText("wireframe"); 1442 1443 rb4 = new QRadioButton("weighted rays", parent); 1444 rb4->setText("weighted rays"); 1445 connect(rb4, SIGNAL(toggled(bool)), SIGNAL(SetShowWeightedRays(bool))); 1446 1447 rb5 = new QRadioButton("pvs cost", parent); 1448 rb5->setText("pvs cost"); 1449 connect(rb5, SIGNAL(toggled(bool)), SIGNAL(SetShowWeightedCost(bool))); 1450 1451 QGroupBox *groupBox = new QGroupBox("Visualization options"); 1452 1453 QVBoxLayout *vbox2 = new QVBoxLayout; 1454 1455 vbox2->addWidget(rb3); 1456 vbox2->addWidget(rb1); 1457 vbox2->addWidget(rb2); 1458 vbox2->addWidget(rb4); 1459 vbox2->addWidget(rb5); 1460 1461 rb3->setChecked(true); 1462 1463 vbox2->addStretch(1); 1464 groupBox->setLayout(vbox2); 1465 1466 return groupBox; 1467 } 1468 1469 1470 1471 QGroupBox *QtRendererControlWidget::CreateRenderCostPanel(QWidget *parent) 1472 { 1473 QRadioButton *rb1, *rb2, *rb3; 1474 1475 // Create a check box to be in the group box 1476 rb1 = new QRadioButton("triangles", parent); 1477 rb1->setText("triangles"); 1478 //vl->addWidget(rb1); 1479 connect(rb1, SIGNAL(toggled(bool)), SIGNAL(SetShowWeightedTriangles(bool))); 1480 1481 rb2 = new QRadioButton("distance weighted pvs", parent); 1482 rb2->setText("distance weighted"); 1483 connect(rb2, SIGNAL(toggled(bool)), SIGNAL(SetShowDistanceWeightedPvs(bool))); 1484 1485 rb3 = new QRadioButton("distance weighted triangles", parent); 1486 rb3->setText("distance weighted triangles"); 1487 connect(rb3, SIGNAL(toggled(bool)), SIGNAL(SetShowDistanceWeightedTriangles(bool))); 1488 1489 QGroupBox *groupBox = new QGroupBox("Render cost options"); 1490 1491 QVBoxLayout *vbox2 = new QVBoxLayout; 1492 1493 vbox2->addWidget(rb1); 1494 vbox2->addWidget(rb2); 1495 vbox2->addWidget(rb3); 1496 1497 rb2->setChecked(true); 1498 1499 vbox2->addStretch(1); 1500 groupBox->setLayout(vbox2); 1501 1502 return groupBox; 1503 } 1364 1504 1365 1505 QtRendererControlWidget::QtRendererControlWidget(QWidget * parent, Qt::WFlags f): … … 1459 1599 connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetShowRenderCost(bool))); 1460 1600 1461 /*cb = new QCheckBox("Show render cost", hbox);1462 hlayout->addWidget(cb);1463 cb->setChecked(false);1464 connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetShowPvsSizes(bool)));1465 */1466 1467 1601 cb = new QCheckBox("Show rays", hbox); 1468 1602 hlayout->addWidget(cb); … … 1470 1604 connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetShowRays(bool))); 1471 1605 1472 /*cb = new QCheckBox("Show piercing rays", hbox); 1473 hlayout->addWidget(cb); 1474 cb->setChecked(false); 1475 connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetShowPiercingRays(bool))); 1476 */ 1477 1478 1479 QRadioButton *rb1, *rb2, *rb3, *rb4; 1480 1481 // Create a check box to be in the group box 1482 1483 rb1 = new QRadioButton("piercing rays", hbox); 1484 rb1->setText("piercing rays"); 1485 //vl->addWidget(rb1); 1486 connect(rb1, SIGNAL(toggled(bool)), SIGNAL(SetShowPiercingRays(bool))); 1487 1488 rb2 = new QRadioButton("render cost", hbox); 1489 rb2->setText("render cost"); 1490 //vl->addWidget(rb2); 1491 connect(rb2, SIGNAL(toggled(bool)), SIGNAL(SetShowPvsSizes(bool))); 1492 1493 rb3 = new QRadioButton("wireframe", hbox); 1494 rb3->setText("wireframe"); 1495 1496 rb4 = new QRadioButton("weighted rays", hbox); 1497 rb4->setText("weighted rays"); 1498 connect(rb4, SIGNAL(toggled(bool)), SIGNAL(SetShowWeightedRays(bool))); 1499 1500 //vl->addWidget(rb2); 1501 //connect(rb2, SIGNAL(toggled(bool)), SIGNAL(SetShowPvsSizes(bool))); 1502 1503 QGroupBox *groupBox = new QGroupBox("Visualization options"); 1504 1505 QVBoxLayout *vbox2 = new QVBoxLayout; 1506 1507 vbox2->addWidget(rb3); 1508 vbox2->addWidget(rb1); 1509 vbox2->addWidget(rb2); 1510 vbox2->addWidget(rb4); 1511 rb3->setChecked(true); 1512 1513 vbox2->addStretch(1); 1514 groupBox->setLayout(vbox2); 1515 1516 vl->addWidget(groupBox, 0, 0); 1606 1607 ////////////////// 1608 1609 QHBoxLayout *vh = new QHBoxLayout; 1610 1611 QGroupBox *myBox = new QGroupBox("Visualization"); 1612 1613 myBox->setLayout(vh); 1614 1615 vl->addWidget(myBox, 0, 0); 1616 1617 QGroupBox *groupBox = CreateVisualizationPanel(hbox); 1618 1619 vh->addWidget(groupBox, 0, 0); 1620 1621 QGroupBox *groupBox2 = CreateRenderCostPanel(hbox); 1622 1623 vh->addWidget(groupBox2, 0, 0); 1517 1624 1518 1625 ////////////////////////////////// … … 1680 1787 1681 1788 1682 if (0) { 1789 if (0) 1790 { 1683 1791 vbox = new QGroupBox("PVS Errors", this); 1684 1792 layout()->addWidget(vbox); … … 1699 1807 connect(button, SIGNAL(clicked(void)), SLOT(FocusNextPvsErrorFrame(void))); 1700 1808 } 1701 1702 1809 1703 1810 //mHidingCost = 0.1f; -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h
r2566 r2569 83 83 QtRendererControlWidget(QWidget * parent = 0, Qt::WFlags f = 0); 84 84 85 QGroupBox *CreateVisualizationPanel(QWidget *parent); 86 85 87 public slots: 86 88 … … 88 90 void UpdatePvsErrorItem(int i, 89 91 GlRendererBuffer::PvsErrorEntry &); 92 93 94 QGroupBox *CreateRenderCostPanel(QWidget *parent); 95 90 96 91 97 signals: … … 116 122 void SetShowPiercingRays(bool); 117 123 void SetShowWeightedRays(bool); 124 void SetShowWeightedCost(bool); 125 118 126 void SetTopView(bool); 119 127 void SetCutViewCells(bool); … … 122 130 void SetHideByCost(bool); 123 131 void SetUseTransparency(bool); 132 133 void SetShowDistanceWeightedTriangles(bool); 134 void SetShowWeightedTriangles(bool); 135 void SetShowDistanceWeightedPvs(bool); 124 136 }; 125 137 … … 159 171 bool mUseTransparency; 160 172 173 bool mShowWeightedCost; 174 175 bool mShowDistanceWeightedTriangles; 176 bool mShowDistanceWeightedPvs; 177 bool mShowWeightedTriangles; 178 161 179 // some statistics 162 180 int mPvsSize; … … 352 370 } 353 371 372 void SetShowWeightedCost(bool b) 373 { 374 mShowWeightedCost = b; 375 updateGL(); 376 } 377 378 void SetShowDistanceWeightedPvs(bool b) 379 { 380 mShowDistanceWeightedPvs = b; 381 updateGL(); 382 } 383 384 385 void SetShowDistanceWeightedTriangles(bool b) 386 { 387 mShowDistanceWeightedTriangles = b; 388 updateGL(); 389 } 390 391 void SetShowWeightedTriangles(bool b) 392 { 393 mShowWeightedTriangles = b; 394 updateGL(); 395 } 396 397 354 398 void _RenderPvs(); 355 399 … … 358 402 void _UpdatePvsIndices(KdNode *node, int &indexBufferSize); 359 403 360 404 float ComputeRenderCost(ViewCell *vc); 361 405 362 406 ///////// -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlViewer.cpp
r2567 r2569 125 125 glScalef(s, s, s); 126 126 127 // TODO: determine model matrix for establishing right rendering order for transparency 127 128 Vector3 t = -mRenderer->mSceneGraph->GetBox().Center(); 128 129 glTranslatef(t.x, t.y, t.z);
Note: See TracChangeset
for help on using the changeset viewer.