Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2638)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2643)
@@ -307,4 +307,12 @@
 	GlRenderer::InitGL();
 
+	//glEnable(GL_FOG);
+	//glFogi(GL_FOG_MODE, GL_EXP);
+	glFogi(GL_FOG_MODE, GL_LINEAR);
+
+//	glFogf(GL_FOG_DENSITY, .2f);
+	glFogf(GL_FOG_START, 50.f);
+	glFogf(GL_FOG_END, 500.f);
+
 	GLfloat light_ambient[] = {0.3, 0.3, 0.3, 1.0};
     GLfloat light_diffuse[] = {0.6, 0.6, 0.6, 1.0};
@@ -440,5 +448,5 @@
 	int indexBufferSize = 0;
 	
-	KdNode::NewMail();
+	KdNode::NewMail2();
 	//Intersectable::NewMail();
 
@@ -506,5 +514,5 @@
 	if (viewcell) 
 	{
-#if 1
+#if 0
 		// copy the pvs so that it can be filtered ...
 		if (PvsChanged(viewcell)) 
@@ -518,10 +526,9 @@
 				//mMutex.lock();
 				// mSpatialFilter size is in range 0.001 - 0.1
-			  mViewCellsManager->ApplyFilter2(viewcell,
-					                            mUseFilter,
-					                            100.0f * mSpatialFilterSize,
-					                            //pvs,
-												mPvsCache.mPvs,		
-					                            &mPvsCache.filteredBoxes);
+				mViewCellsManager->ApplyFilter2(viewcell,
+					mUseFilter,
+					100.0f * mSpatialFilterSize,
+					mPvsCache.mPvs,		
+					&mPvsCache.filteredBoxes);
 				//mPvsCache.mPvs = pvs;
 				//mMutex.unlock();
@@ -535,10 +542,12 @@
 			// update the indices for rendering
 			PreparePvs2(mPvsCache.mPvs);
-			
 			emit PvsUpdated();
+			mCurrentPvsCost = mPvsCache.mPvs.EvalPvsCost();
 		}
 #else
+	
 		PreparePvs2(viewcell->GetPvs());
 		emit PvsUpdated();
+
 #endif
 
@@ -577,4 +586,5 @@
 			mWireFrame = false;
 		}
+		mCurrentPvsCost = viewcell->GetPvs().EvalPvsCost();
 	} 
 	else 
@@ -585,4 +595,6 @@
 		RenderScene();
 	}
+
+	//cout << "vp: " << mViewPoint << " vd: " << mViewDirection << endl;
 }
 
@@ -794,5 +806,5 @@
 		}
 
-		if (1 && mShowRays) 
+		if (mShowRays) 
 		{
 			RenderRays(mViewCellsManager->mVizBuffer.GetRays(), mRayVisualizationMethod, mShowDistribution, 1);
@@ -937,4 +949,5 @@
 	//mRenderVisibilityEstimates = true;
 
+	mComputeGVS = false;
 	mUseRandomColorPerPvsObject = false;
 
@@ -980,5 +993,5 @@
 	mShowRays = false;
 
-	SetSceneCut(0);
+	SetSceneCut(1000);
 	mControlWidget = new QtRendererControlWidget(NULL);
 
@@ -991,4 +1004,5 @@
 	connect(mControlWidget, SIGNAL(SetRandomViewPoint()), this,	SLOT(SetRandomViewPoint()));
 	connect(mControlWidget, SIGNAL(StoreStatistics(void)), this, SLOT(StoreStatistics(void)));
+	connect(mControlWidget, SIGNAL(ComputeGVS(void)), this, SLOT(ComputeGVS(void)));
 	connect(mControlWidget, SIGNAL(LoadObject(void)), this, SLOT(LoadObject(void)));
 
@@ -1270,11 +1284,17 @@
 #if 0
 	QFont font40; font40.setPointSize(30);
-	s.sprintf("PVS: %04d", mPvsSize);
-	renderText(20, 40, s, font40);
+	//s.sprintf("PVS: %04d", mPvsSize);
+	//renderText(20, 40, s, font40);
 #endif
 	
-/*	QFont font40; font40.setPointSize(30);
-	s.sprintf("New triangles: %04d", 100);
-	renderText(200, 40, s, font40);*/
+	//s.sprintf("RAW TRI: %07d", mViewCellsManager->GetPreprocessor()->mGenericStats);
+	//renderText(290, 40, s, font40);
+	//s.sprintf("PVS TRI: %07d", mViewCellsManager->GetPreprocessor()->mGenericStats2);
+	//renderText(290, 70, s, font40);
+
+	s.sprintf("PVS TRI: %07d", (int)mCurrentPvsCost);
+	renderText(290, 70, s, font40);
+	//renderText(290, 70, s, font40);
+
 }
 
@@ -1283,6 +1303,7 @@
 QtGlRendererWidget::SetViewCellGranularity(int number)
 {
-	if (mViewCellsManager) {
-		//  	mViewCellsManager->SetMaxFilterSize(number);
+	if (mViewCellsManager)
+	{
+		//	mViewCellsManager->SetMaxFilterSize(number);
 
 		// $$ tmp off
@@ -1301,4 +1322,5 @@
 	if (mViewCellsManager) 
 		mViewCellsManager->SetMaxFilterSize(number);
+
 	mPvsCache.Reset();
 	updateGL();
@@ -1324,5 +1346,5 @@
 		AxisAlignedBox3 box = mViewCellsManager->GetViewSpaceBox();
 		Vector3 p = (1.0f - f) * box.Min() + f * box.Max();
-		mSceneCutPlane.mNormal = Vector3(0,-1,0);
+		mSceneCutPlane.mNormal = Vector3(0, -1, 0);
 		mSceneCutPlane.mD = -DotProd(mSceneCutPlane.mNormal, p);
 
@@ -1996,8 +2018,9 @@
 	QGroupBox *groupBox = CreateVisualizationPanel(hbox);
 	vh->addWidget(groupBox, 0, 0);
+
 #if REMOVE_TEMPORARY
 	QGroupBox *groupBox2 = CreateRenderCostPanel(hbox);
 	vh->addWidget(groupBox2, 0, 0);
-#endif
+	
 	QGroupBox *groupBox3 = CreateRayVisualizationPanel(hbox);
 	vh->addWidget(groupBox3, 0, 0);
@@ -2005,13 +2028,8 @@
 	QGroupBox *groupBox4 = CreateTrafoPanel(hbox);
 	vh->addWidget(groupBox4, 0, 0);
+#endif
 
 	//////////////////////////////////
 
-
-	/*cb = new QRadiobox("Top View", vbox);
-	vl->addWidget(cb);
-	cb->setChecked(false);
-	connect(cb, SIGNAL(toggled(bool)), SIGNAL(SetTopView(bool)));
-*/
 
 	//vbox->resize(800,150);
@@ -2168,4 +2186,8 @@
 #endif
 
+	button = new QPushButton("Compute GVS", vbox);
+	vbox->layout()->addWidget(button);
+	connect(button, SIGNAL(clicked()), SIGNAL(ComputeGVS()));
+
 #if DYNAMIC_OBJECTS_HACK
 
@@ -2202,6 +2224,6 @@
 	
 	//connect(button, SIGNAL(clicked(void)), SLOT(StoreStatistics(void)));
-	//mHidingCost = 0.1f;
-//////////////////////////////////////////
+	
+	//////////////////////////////////////////
 
 	label = new QLabel("Spatial Filter size");
