Index: /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2689)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.cpp	(revision 2693)
@@ -2519,3 +2519,30 @@
 }
 
-}
+
+
+Vector3 QtGlRendererWidget::Unproject(int x, int y)
+{
+	// swap y coordinate
+	//y = GetHeight() - y;
+
+	// HACK: should come from camera!
+	double projection[16]; 
+	glGetDoublev(GL_PROJECTION_MATRIX, projection); 
+	double modelview[16];
+	glGetDoublev(GL_MODELVIEW_MATRIX, modelview); 
+
+	const int viewport[4] = {0,0, GetWidth(), GetHeight()};
+
+	float z;
+	glReadPixels(x, y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &z);
+
+	RenderScene();
+
+	GLdouble rx, ry, rz;
+	gluUnProject(x, y, z, modelview, projection, viewport, &rx, &ry, &rz);
+
+	return Vector3(rx, ry, rz);
+}
+
+
+}
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/ObjectPlacer.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/ObjectPlacer.h	(revision 2693)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/ObjectPlacer.h	(revision 2693)
@@ -0,0 +1,55 @@
+ #ifndef OBJECTPLACER_H
+#define OBJECTPLACER_H
+
+namespace GtpVisibilityPreprocessor {
+
+class Vector3;
+
+
+/** A class for managing interactive object placement
+ */
+class ObjectPlacer
+{
+public:
+	ObjectPlacer();
+
+	/// sets library objects
+	//void SetLibrary(BranchGroup *library);
+	/// selects the next library object
+	void NextObject();
+	/// selects the previous library object
+	void PreviousObject();
+	/// adds an object at the indicated position
+	void AddObject(const Vector3 &p);
+	/// remove the last added object
+	void RemoveLastObject();
+
+	/// Clear all objects
+	void Clear();
+
+	/// Save the objects
+	/*void SaveObjects(const std::string &filename);
+
+	/// Get a node to visualize from the library
+	BranchGroup *GetLibraryVisualization();
+
+	/// Get the nodes that have already been placed
+	BranchGroup *GetPlacedNodeVisualization();
+
+*/	
+	virtual ~ObjectPlacer() {}
+
+protected:
+	/*SceneBasePtr<BranchGroup> mLibrary;
+	SceneBasePtr<BranchGroup> mPlacedNodes;
+	SceneBasePtr<BranchGroup> mLibraryViz;
+	int mCurrentLibaryObject;
+
+	/// Get a link to an object in the library
+	void UpdateLibraryViz();
+*/
+};
+
+}
+
+#endif // OBJECTPLACER_H
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h	(revision 2686)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtGlRenderer.h	(revision 2693)
@@ -313,4 +313,7 @@
 	void WriteViewCellInfos();
 
+	/** Unproject x/y screen coordinates.
+	*/
+	Vector3 Unproject(int x, int y);
 	
 
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtInterface05.vcproj
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtInterface05.vcproj	(revision 2681)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/QtInterface05.vcproj	(revision 2693)
@@ -225,4 +225,8 @@
 			</File>
 			<File
+				RelativePath=".\ObjectPlacer.h"
+				>
+			</File>
+			<File
 				RelativePath="QtGlRenderer.cpp"
 				>
@@ -248,4 +252,8 @@
 			<File
 				RelativePath="LogWriter.h"
+				>
+			</File>
+			<File
+				RelativePath=".\ObjectPlacer.cpp"
 				>
 			</File>
Index: /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/ObjectPlacer.cpp
===================================================================
--- /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/ObjectPlacer.cpp	(revision 2693)
+++ /GTP/trunk/Lib/Vis/Preprocessing/src/QtInterface/ObjectPlacer.cpp	(revision 2693)
@@ -0,0 +1,198 @@
+#include "ObjectPlacer.h"
+
+namespace GtpVisibilityPreprocessor {
+
+// ---------------------------------------------------------------------------
+//  ObjectPlacer implementation
+// ---------------------------------------------------------------------------
+#if 0
+ObjectPlacer::ObjectPlacer()
+	:mCurrentLibaryObject(0), mPlacedNodes(new BranchGroup), mLibraryViz(new BranchGroup)
+{
+	mLibraryViz->addChild(new BranchGroup);
+
+	BranchGroup *bg = new BranchGroup;
+	bg->addChild(new Box);
+	SetLibrary(bg);
+}
+
+
+void ObjectPlacer::SetLibrary(BranchGroup *library)
+{
+	mLibrary = new BranchGroup;
+	if (!library)
+	{
+		mLibrary->addChild(new Box);
+	}
+	else
+	{
+		for (int i = 0; i < library->numChildren(); i ++)
+		{	
+			Node *n = library->getChild(i);
+			SharedGroup *s = new SharedGroup;
+			s->addChild(n);
+			
+			Link *l = new Link;
+			l->setSharedGroup(s);
+			mLibrary->addChild(l);
+		}
+	}
+	
+	UpdateLibraryViz();
+}
+
+void ObjectPlacer::UpdateLibraryViz()
+{
+	Link *l = new Link;
+	l->setSharedGroup(((Link *)mLibrary->getChild(mCurrentLibaryObject))->getSharedGroup());
+
+	mLibraryViz->setChild(l, 0);
+}
+
+
+void ObjectPlacer::NextObject()
+{
+	if (mLibrary)
+		mCurrentLibaryObject = (mCurrentLibaryObject + 1) % (mLibrary->numChildren());
+	UpdateLibraryViz();
+}
+
+void ObjectPlacer::PreviousObject()
+{
+	if (mLibrary)
+		mCurrentLibaryObject = (mCurrentLibaryObject - 1) % (mLibrary->numChildren());
+	UpdateLibraryViz();
+}
+
+void ObjectPlacer::AddObject(const Point3f &p)
+{
+	//BranchGroup *o = new BranchGroup;
+	TransformGroup *tg = new TransformGroup;
+	Transform3D t;
+	t.setTranslation(p - Origin3f);
+	tg->setTransform(t);
+	//o->addChild(tg);
+
+	Link *l = new Link;
+	l->setSharedGroup(((Link *)(mLibrary->getChild(mCurrentLibaryObject)))->getSharedGroup());
+	tg->addChild(l);
+
+	mPlacedNodes->addChild(tg);
+}
+
+void ObjectPlacer::RemoveLastObject()
+{
+	if (mPlacedNodes->numChildren() > 0)
+		mPlacedNodes->removeChild(mPlacedNodes->numChildren()-1);
+}
+
+void ObjectPlacer::SaveObjects(const String &filename)
+{
+	WriteActionIV wa(filename, "");
+
+	wa.Apply(mPlacedNodes);
+}
+
+BranchGroup *ObjectPlacer::GetLibraryVisualization()
+{
+	return mLibraryViz;
+}
+
+BranchGroup *ObjectPlacer::GetPlacedNodeVisualization()
+{
+	return mPlacedNodes;
+}
+
+void ObjectPlacer::Clear()
+{
+	mPlacedNodes->removeAllChildren();	
+}
+
+
+void TestApp::Placer(const String &parm)
+{
+	if (parm.Empty())
+	{
+		OUT1("Object placement: place/load <libaryfile>/removelast/next/previous/save <objectfile>");
+		return;
+	}
+
+	ASM_RET(viewer->GetRoot(), "No scene");
+	
+	if (!placer)
+		placer = new ObjectPlacer;
+
+	//-- make sure the placer visualization (which shows the already placed objects) is in the viewer
+	SearchNodeByNameVisitor search("placervis");
+	search.Apply(viewer->GetRoot(), SearchNodeByNameVisitor::FIRST);
+	BranchGroup *placervis = search.GetNode();
+	if (!placervis)
+	{
+		placervis = placer->GetPlacedNodeVisualization();
+		viewer->GetRoot()->addChild(placervis);
+		placervis->setName("placervis");
+	}
+
+	if (parm == "place")
+	{
+		int x, y;
+		input_module->GetMousePos(x, y);
+
+		Point3f pos = viewer->UnProject(x, y);
+		if (viewer && viewer->GetRoot() && viewer->GetRoot()->getBoundingBox()->intersects(pos))
+		{
+			placer->AddObject(pos);
+			OUT1(x << " " << y << " " << pos);
+		}
+		else
+		{
+			OUT1("Point out of bounds");
+		}
+	} else if (parm == "removelast") {
+		placer->RemoveLastObject();
+	} else if (parm == "next") {
+		placer->NextObject();
+	} else if (parm == "previous") {
+		placer->PreviousObject();
+	} else if (parm.Left(5) == "save ") {
+		String filename = parm.Right(parm.size()-5);
+		if (!filename.Empty())
+			placer->SaveObjects(filename);
+	} else if (parm.Left(5) == "clear") {
+		placer->Clear();
+	} else if (parm.Left(5) == "load ") {
+		String fn = sysutils::FindFile(parm.Right(parm.size()-5), settings->get_ObjectPath());
+
+		ASM_ELSE(!fn.empty(), "Couldn't find file " << fn)
+		{
+			OUT1("Loading library " << fn << "...");
+			SceneBasePtr<BranchGroup> root = ReadSceneGraph(fn, 0, 0, 1);
+
+			BranchGroup *library = new BranchGroup;
+			ASM_ELSE((root != NULL), "No scene found in file...")
+			{
+				SearchNodeByNameVisitor search("start");
+				search.Apply(root, SearchNodeByNameVisitor::FIRST);
+				BranchGroup *local_root = search.GetNode();
+
+				if (local_root == NULL)
+				{
+					OUT1("Note: BranchGroup named \"start\" not found - using root node");
+					local_root = root;
+				}
+
+				placer->SetLibrary(local_root);
+				BranchGroup *viz = placer->GetLibraryVisualization();
+				mRenderArea->SetSceneRoot(viz);
+				mRenderArea->SetCamera(new Camera);
+				mRenderArea->GetCamera()->ViewAll(viz->getBoundingSphere());
+			}
+		}
+	} else
+		OUT1("Unknown placer command");
+
+}
+
+#endif
+
+}
