Changeset 2576 for GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface
- Timestamp:
- 01/07/08 02:23:52 (17 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface
- Files:
-
- 2 added
- 2 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
r2572 r2576 1 #include "glInterface.h" 2 #include "QtGlRenderer.h" 1 3 #include "Mesh.h" 2 #include "glInterface.h"3 4 #include "OcclusionQuery.h" 4 #include "QtGlRenderer.h"5 5 #include "ViewCellsManager.h" 6 6 #include "SceneGraph.h" … … 1245 1245 #endif 1246 1246 1247 void 1248 QtGlRendererWidget::RenderViewCells() 1247 1248 1249 void QtGlRendererWidget::ComputeMaxValues(const ViewCellContainer &viewCells, 1250 int &maxPvs, 1251 int &maxPiercingRays, 1252 float &maxRelativeRays, 1253 float &maxRcCost) 1254 { 1255 maxPvs = -1; 1256 maxPiercingRays = 1; // not zero for savety 1257 maxRelativeRays = Limits::Small; // not zero for savety 1258 maxRcCost = Limits::Small; 1259 1260 for (size_t i = 0; i < viewCells.size(); ++ i) 1261 { 1262 ViewCell *vc = viewCells[i]; 1263 1264 if (mShowPvsSizes) // pvs size 1265 { 1266 //const int p = vc->GetPvs().CountObjectsInPvs(); 1267 const int p = vc->GetPvs().GetSize(); 1268 if (p > maxPvs) 1269 maxPvs = p; 1270 } 1271 else if (mShowPiercingRays) // relative number of rays 1272 { 1273 const int piercingRays = vc->GetNumPiercingRays(); 1274 1275 if (piercingRays > maxPiercingRays) 1276 maxPiercingRays = piercingRays; 1277 } 1278 else if (mShowWeightedRays) 1279 { 1280 const int piercingRays = vc->GetNumPiercingRays(); 1281 1282 const float relativeArea = 1283 vc->GetBox().SurfaceArea() / mViewCellsManager->GetViewSpaceBox().SurfaceArea(); 1284 1285 if ((float)piercingRays / relativeArea > maxRelativeRays) 1286 maxRelativeRays = (float)piercingRays / relativeArea; 1287 } 1288 else if (mShowWeightedCost) 1289 { 1290 const float rcCost = ComputeRenderCost(vc); 1291 mViewCellsManager->UpdateScalarPvsCost(vc, rcCost); 1292 1293 if (rcCost > maxRcCost) 1294 maxRcCost = rcCost; 1295 } 1296 } 1297 } 1298 1299 1300 void QtGlRendererWidget::RenderViewCells() 1249 1301 { 1250 1302 mUseFalseColors = true; … … 1272 1324 ViewCellContainer &viewcells = mViewCellsManager->GetViewCells(); 1273 1325 1274 int maxPvs = -1; 1275 int maxPiercingRays = 1; // not zero for savety 1276 float maxRelativeRays = Limits::Small; // not zero for savety 1277 float maxRcCost = Limits::Small; 1278 1279 for (i = 0; i < viewcells.size(); ++ i) 1280 { 1281 ViewCell *vc = viewcells[i]; 1282 1283 if (mShowPvsSizes) // pvs size 1284 { 1285 //const int p = vc->GetPvs().CountObjectsInPvs(); 1286 const int p = vc->GetPvs().GetSize(); 1287 if (p > maxPvs) 1288 maxPvs = p; 1289 } 1290 else if (mShowPiercingRays) // relative number of rays 1291 { 1292 const int piercingRays = vc->GetNumPiercingRays(); 1293 1294 if (piercingRays > maxPiercingRays) 1295 maxPiercingRays = piercingRays; 1296 } 1297 else if (mShowWeightedRays) 1298 { 1299 const int piercingRays = vc->GetNumPiercingRays(); 1300 1301 const float relativeArea = 1302 vc->GetBox().SurfaceArea() / mViewCellsManager->GetViewSpaceBox().SurfaceArea(); 1303 1304 if ((float)piercingRays / relativeArea > maxRelativeRays) 1305 maxRelativeRays = (float)piercingRays / relativeArea; 1306 } 1307 else if (mShowWeightedCost) 1308 { 1309 const float rcCost = ComputeRenderCost(vc); 1310 mViewCellsManager->UpdateScalarPvsCost(vc, rcCost); 1311 1312 if (rcCost > maxRcCost) 1313 maxRcCost = rcCost; 1314 } 1315 } 1326 int maxPvs, maxPiercingRays; 1327 float maxRelativeRays, maxRcCost; 1328 1329 ComputeMaxValues(viewcells, maxPvs, maxPiercingRays, maxRelativeRays, maxRcCost); 1330 1316 1331 1317 1332 if (!mShowPvsSizes && !mShowPiercingRays && !mShowWeightedRays && !mShowWeightedCost) … … 1338 1353 else 1339 1354 { 1340 //glDisable(GL_CULL_FACE); 1341 //glCullFace(GL_BACK); 1342 1355 // transparency 1343 1356 if (!mUseTransparency) 1344 1357 { … … 1365 1378 } 1366 1379 1367 for (i = 0; i < viewcells.size(); ++ i) 1368 { 1369 RgbColor c; 1370 ViewCell *vc = viewcells[i]; 1371 1372 float importance; 1373 1374 if (mShowPiercingRays) 1375 { 1376 importance = mTransferFunction * 1377 ((float)vc->GetNumPiercingRays() / (float)maxPiercingRays); 1378 } 1379 else if (mShowWeightedRays) // relative number of rays 1380 { 1381 float relativeArea = vc->GetBox().SurfaceArea() / mViewCellsManager->GetViewSpaceBox().SurfaceArea(); 1382 1383 if (relativeArea < Limits::Small) 1384 relativeArea = Limits::Small; 1385 1386 importance = mTransferFunction * ((float)vc->GetNumPiercingRays() / relativeArea) / maxRelativeRays; 1387 } 1388 else if (mShowPvsSizes) // pvs size 1389 { 1390 importance = mTransferFunction * 1391 ((float)vc->GetPvs().GetSize() / (float)maxPvs); 1392 } // weighted render cost 1393 else if (mShowWeightedCost) 1394 { 1395 const float rcCost = mTransferFunction * ComputeRenderCost(vc); 1396 importance = rcCost / maxRcCost; 1397 } 1398 1399 // c = RgbColor(importance, 1.0f - importance, 0.0f); 1400 c = RainbowColorMapping(importance); 1401 1402 glColor4f(c.r, c.g, c.b, 1.0f - mTransparency); 1403 1404 if (!mHideByCost || (mHidingCost < importance)) 1405 { 1406 RenderViewCell(vc); 1407 } 1408 } 1380 ViewCellInfoContainer *infos1 = mCurrentInfos[mCurrentSamples]; 1381 ViewCellInfoContainer *infos2 = mCompareInfos[mCurrentSamples]; 1382 1383 if (mAssignImportanceByRelativeValue) 1384 AssignImportanceByRelativeValue(viewcells, maxPvs, maxPiercingRays, maxRelativeRays, maxRcCost); 1385 else 1386 AssignColorByComparison(viewcells, *infos1, *infos2); 1409 1387 1410 1388 glEnable(GL_DEPTH_TEST); … … 1423 1401 1424 1402 1425 1426 /*********************************************************************/ 1427 /* QtGlDebuggerWidget implementation */ 1428 /*********************************************************************/ 1429 1430 1431 QtGlDebuggerWidget::QtGlDebuggerWidget(QtGlRendererBuffer *buf, QWidget *parent) 1432 : QGLWidget(QGLFormat(QGL::SampleBuffers), parent), mRenderBuffer(buf) 1433 { 1434 // create the pbuffer 1435 //pbuffer = new QGLPixelBuffer(QSize(512, 512), format(), this); 1436 timerId = startTimer(20); 1437 setWindowTitle(("OpenGL pbuffers")); 1438 } 1439 1440 1441 QtGlDebuggerWidget::~QtGlDebuggerWidget() 1442 { 1443 mRenderBuffer->releaseFromDynamicTexture(); 1444 glDeleteTextures(1, &dynamicTexture); 1445 1446 DEL_PTR(mRenderBuffer); 1447 } 1448 1449 1403 void QtGlRendererWidget::AssignImportanceByRelativeValue(const ViewCellContainer &viewCells, 1404 int &maxPvs, 1405 int &maxPiercingRays, 1406 float &maxRelativeRays, 1407 float &maxRcCost) 1408 { 1409 for (size_t i = 0; i < viewCells.size(); ++ i) 1410 { 1411 RgbColor c; 1412 ViewCell *vc = viewCells[i]; 1413 1414 float importance; 1415 1416 if (mShowPiercingRays) 1417 { 1418 importance = mTransferFunction * 1419 ((float)vc->GetNumPiercingRays() / (float)maxPiercingRays); 1420 } 1421 else if (mShowWeightedRays) // relative number of rays 1422 { 1423 float relativeArea = vc->GetBox().SurfaceArea() / mViewCellsManager->GetViewSpaceBox().SurfaceArea(); 1424 1425 if (relativeArea < Limits::Small) 1426 relativeArea = Limits::Small; 1427 1428 importance = mTransferFunction * ((float)vc->GetNumPiercingRays() / relativeArea) / maxRelativeRays; 1429 } 1430 else if (mShowPvsSizes) // pvs size 1431 { 1432 importance = mTransferFunction * 1433 ((float)vc->GetPvs().GetSize() / (float)maxPvs); 1434 } // weighted render cost 1435 else if (mShowWeightedCost) 1436 { 1437 const float rcCost = mTransferFunction * ComputeRenderCost(vc); 1438 importance = rcCost / maxRcCost; 1439 } 1440 1441 // c = RgbColor(importance, 1.0f - importance, 0.0f); 1442 c = RainbowColorMapping(importance); 1443 1444 glColor4f(c.r, c.g, c.b, 1.0f - mTransparency); 1445 1446 if (!mHideByCost || (mHidingCost < importance)) 1447 { 1448 RenderViewCell(vc); 1449 } 1450 } 1451 } 1452 1453 1454 void QtGlRendererWidget::AssignColorByComparison(const ViewCellContainer &viewcells, 1455 const ViewCellInfoContainer &infos1, 1456 const ViewCellInfoContainer &infos2) 1457 { 1458 1459 const float maxRatio = 2; 1460 const float minRatio = 0.5; 1461 1462 const float scale = 1.0f / (maxRatio - minRatio); 1463 1464 for (size_t i = 0; i < viewcells.size(); ++ i) 1465 { 1466 RgbColor c; 1467 ViewCell *vc = viewcells[i]; 1468 1469 ViewCellInfo vc1Info = infos1[i]; 1470 ViewCellInfo vc2Info = infos2[i]; 1471 1472 const float vcRatio = vc1Info.mPiercingRays / vc2Info.mPiercingRays + Limits::Small; 1473 1474 const float importance = (vcRatio - minRatio) * scale; 1475 1476 // c = RgbColor(importance, 1.0f - importance, 0.0f); 1477 c = RainbowColorMapping(importance); 1478 1479 glColor4f(c.r, c.g, c.b, 1.0f); 1480 1481 if (1)//!mHideByCost || (mHidingCost < importance)) 1482 { 1483 RenderViewCell(vc); 1484 } 1485 } 1486 } 1487 1488 1489 1490 /**********************************************************************/ 1491 /* QtRendererControlWidget implementation */ 1492 /**********************************************************************/ 1493 1494 #if 1 1450 1495 QGroupBox *QtRendererControlWidget::CreateVisualizationPanel(QWidget *parent) 1451 1496 { … … 1527 1572 } 1528 1573 1574 1529 1575 QtRendererControlWidget::QtRendererControlWidget(QWidget * parent, Qt::WFlags f): 1530 1576 QWidget(parent, f) … … 1843 1889 void 1844 1890 QtRendererControlWidget::FocusNextPvsErrorFrame(void) 1845 { 1846 1847 1848 } 1891 {} 1849 1892 1850 1893 void … … 1865 1908 1866 1909 1910 1911 #endif 1912 1913 1914 /*********************************************************************/ 1915 /* QtGlDebuggerWidget implementation */ 1916 /*********************************************************************/ 1917 1918 1919 QtGlDebuggerWidget::QtGlDebuggerWidget(QtGlRendererBuffer *buf, QWidget *parent) 1920 : QGLWidget(QGLFormat(QGL::SampleBuffers), parent), mRenderBuffer(buf) 1921 { 1922 // create the pbuffer 1923 //pbuffer = new QGLPixelBuffer(QSize(512, 512), format(), this); 1924 timerId = startTimer(20); 1925 setWindowTitle(("OpenGL pbuffers")); 1926 } 1927 1928 1929 QtGlDebuggerWidget::~QtGlDebuggerWidget() 1930 { 1931 mRenderBuffer->releaseFromDynamicTexture(); 1932 glDeleteTextures(1, &dynamicTexture); 1933 1934 DEL_PTR(mRenderBuffer); 1935 } 1936 1937 1867 1938 void QtGlDebuggerWidget::initializeGL() 1868 1939 { … … 1945 2016 } 1946 2017 2018 1947 2019 void QtGlDebuggerWidget::initCommon() 1948 2020 { … … 1954 2026 1955 2027 1956 1957 } 2028 } -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h
r2569 r2576 13 13 #include "Beam.h" 14 14 #include "QtPreprocessorThread.h" 15 #include "LogReader.h" 15 16 16 17 … … 20 21 21 22 namespace GtpVisibilityPreprocessor { 23 22 24 23 25 class SceneGraph; … … 137 139 138 140 139 class QtGlRendererWidget 141 class QtGlRendererWidget: public QGLWidget, public GlRendererWidget 140 142 { 141 143 Q_OBJECT … … 184 186 unsigned int mIndexBufferSize; 185 187 188 bool mAssignImportanceByRelativeValue; 189 186 190 Vector3 mDummyViewPoint; 187 191 … … 189 193 190 194 QtPreprocessorThread *mPreprocessorThread; 195 196 int mCurrentSamples; 197 198 ViewCellHistoryContainer mCurrentInfos; 199 ViewCellHistoryContainer mCompareInfos; 200 191 201 192 202 QtGlRendererWidget(SceneGraph *sceneGraph, … … 201 211 mPreprocessorThread = t; 202 212 } 203 void 204 RenderRenderCost(); 213 void RenderRenderCost(); 205 214 206 215 virtual void SetupCamera(); … … 245 254 bool PvsChanged(ViewCell *viewcell) const; 246 255 256 void ComputeMaxValues(const ViewCellContainer &viewCells, 257 int &maxPvs, 258 int &maxPiercingRays, 259 float &maxRelativeRays, 260 float &maxRcCost); 261 262 void AssignImportanceByRelativeValue(const ViewCellContainer &viewCells, 263 int &maxPvs, 264 int &maxPiercingRays, 265 float &maxRelativeRays, 266 float &maxRcCost); 267 268 void AssignColorByComparison(const ViewCellContainer &viewcells, 269 const ViewCellInfoContainer &info1, 270 const ViewCellInfoContainer &info2); 271 272 247 273 ///////// 248 274 … … 411 437 412 438 413 class QtGlDebuggerWidget 439 class QtGlDebuggerWidget: public QGLWidget 414 440 { 415 441 Q_OBJECT -
GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtInterface.vcproj
r2560 r2576 205 205 UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"> 206 206 <File 207 RelativePath=".\LogReader.cpp"> 208 </File> 209 <File 210 RelativePath=".\LogWriter.cpp"> 211 </File> 212 <File 207 213 RelativePath=".\moc_QtGlRenderer.cpp"> 208 214 </File> … … 224 230 Filter="h;hpp;hxx;hm;inl;inc;xsd" 225 231 UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"> 232 <File 233 RelativePath=".\LogReader.h"> 234 </File> 235 <File 236 RelativePath=".\LogWriter.h"> 237 </File> 226 238 <File 227 239 RelativePath=".\QtGlRenderer.h">
Note: See TracChangeset
for help on using the changeset viewer.