Index: GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
===================================================================
--- GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2565)
+++ GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2566)
@@ -865,4 +865,6 @@
 	mShowPvsSizes = false;
 	mShowPiercingRays = false;
+	mShowWeightedRays = false;
+
 	mSpatialFilterSize = 0.01;
 	mPvsSize = 0;
@@ -902,10 +904,9 @@
 	connect(mControlWidget, SIGNAL(SetRenderBoxes(bool)), this, SLOT(SetRenderBoxes(bool)));
 	connect(mControlWidget, SIGNAL(SetRenderFilter(bool)), this, SLOT(SetRenderFilter(bool)));
-	connect(mControlWidget, SIGNAL(SetRenderVisibilityEstimates(bool)),
-		this, SLOT(SetRenderVisibilityEstimates(bool)));
+	connect(mControlWidget, SIGNAL(SetRenderVisibilityEstimates(bool)), this, SLOT(SetRenderVisibilityEstimates(bool)));
 	connect(mControlWidget, SIGNAL(SetUseFilter(bool)), this, SLOT(SetUseFilter(bool)));
-	connect(mControlWidget, SIGNAL(SetUseSpatialFilter(bool)),
-		this, SLOT(SetUseSpatialFilter(bool)));
+	connect(mControlWidget, SIGNAL(SetUseSpatialFilter(bool)), this, SLOT(SetUseSpatialFilter(bool)));
 	connect(mControlWidget, SIGNAL(SetShowPiercingRays(bool)), this, SLOT(SetShowPiercingRays(bool)));
+	connect(mControlWidget, SIGNAL(SetShowWeightedRays(bool)), this, SLOT(SetShowWeightedRays(bool)));
 
 	connect(mControlWidget,
@@ -1198,5 +1199,6 @@
 	ViewCellContainer &viewcells = mViewCellsManager->GetViewCells();
 	int maxPvs = -1;
-	int maxPiercingRays = 1; // for savety
+	int maxPiercingRays = 1; // not zero for savety
+	float maxRelativeRays = Limits::Small; // not zero for savety
 
 	for (i = 0; i < viewcells.size(); ++ i) 
@@ -1213,7 +1215,12 @@
 		if (piercingRays > maxPiercingRays)
 			maxPiercingRays = piercingRays;
-	}
-
-	if (!mShowPvsSizes && !mShowPiercingRays)
+
+		const float relativeArea = vc->GetBox().SurfaceArea() / mViewCellsManager->GetViewSpaceBox().SurfaceArea();
+
+		if ((float)piercingRays / relativeArea > maxRelativeRays)
+			maxRelativeRays = (float)piercingRays / relativeArea;
+	}
+
+	if (!mShowPvsSizes && !mShowPiercingRays && !mShowWeightedRays)
 	{
 		for (i = 0; i < viewcells.size(); ++ i) 
@@ -1260,6 +1267,6 @@
 			{
 				ViewCell *vc = viewcells[i];
-				const Vector3 dummyViewPoint(0.0, 0.0, 1.0);
-				const float dist = SqrDistance(dummyViewPoint, vc->GetBox().Center());
+
+				const float dist = SqrDistance(mDummyViewPoint, vc->GetBox().Center());
 
 				vc->SetDistance(dist);
@@ -1269,8 +1276,7 @@
 		}
 
-		RgbColor c;
-
-        for (i = 0; i < viewcells.size(); ++ i) 
+		for (i = 0; i < viewcells.size(); ++ i) 
 		{
+			RgbColor c;
             ViewCell *vc = viewcells[i];
 			
@@ -1283,11 +1289,19 @@
 					((float)vc->GetNumPiercingRays() / (float)maxPiercingRays);
 			}
-			else
+			else if (mShowWeightedRays) // relative number of rays
+			{
+				// importance = 5.0f*mTransferFunction * ((float)vc->GetPvs().CountObjectsInPvs() / (float)maxPvs);
+				float relativeArea = vc->GetBox().SurfaceArea() / mViewCellsManager->GetViewSpaceBox().SurfaceArea();
+
+				if (relativeArea < Limits::Small)
+					relativeArea = Limits::Small;
+
+				importance = mTransferFunction * ((float)vc->GetNumPiercingRays() / relativeArea) / maxRelativeRays;
+			}
+			else // pvs size
 			{
 				//importance = 5.0f*mTransferFunction * ((float)vc->GetPvs().CountObjectsInPvs() / (float)maxPvs);
 				importance = mTransferFunction *
 					((float)vc->GetPvs().GetSize() / (float)maxPvs);
-				// c = RgbColor(importance, 1.0f - importance, 0.0f);
-				c = RainbowColorMapping(5.0f * importance);
 			}
 
@@ -1452,5 +1466,5 @@
 
 
-	QRadioButton *rb1, *rb2, *rb3;
+	QRadioButton *rb1, *rb2, *rb3, *rb4;
 
 	// Create a check box to be in the group box
@@ -1468,4 +1482,9 @@
 	rb3 = new QRadioButton("wireframe", hbox);
 	rb3->setText("wireframe");
+	
+	rb4 = new QRadioButton("weighted rays", hbox);
+	rb4->setText("weighted rays");
+	connect(rb4, SIGNAL(toggled(bool)), SIGNAL(SetShowWeightedRays(bool)));
+
 	//vl->addWidget(rb2);
 	//connect(rb2, SIGNAL(toggled(bool)), SIGNAL(SetShowPvsSizes(bool)));
@@ -1478,5 +1497,6 @@
 	vbox2->addWidget(rb1);
 	vbox2->addWidget(rb2);
-	rb2->setChecked(true);
+	vbox2->addWidget(rb4);
+	rb3->setChecked(true);
 
 	vbox2->addStretch(1);
