Esempio n. 1
0
int Gv2Anchor::Do(GDisplayTreeTraversal &state) 
{
   //return Gv2Group::Do(state);		

   int traverse=1;
   int ret=0;
   switch (state.mode) {
   case GDisplayTreeTraversal::MODE_EXTERN_REF:
   		if (url.getNum() == 0)  return(TraverseChildren(state));

   case GDisplayTreeTraversal::MODE_TREE:
   default: 
		{
#ifndef  _NO_DISPLAY_TREE

   		HTREEITEM thisItem = state.InsertNodeItem(this,traverse, DGvTreeItem::GV_GROUP_NODE);

		if (traverse) {
   			TREE_PUSH(state,thisItem);
   				state.topInsertAfter = TVI_LAST;
   				ret=TraverseChildren(state);
   			TREE_POP(state);
   		}
   
   		state.returnItem = thisItem;
#endif
		}

   		break;
   }
   return(ret);
}
/** \brief Accept a light. As we only support one light for now we just set it as the active light
 * \param l which we traverse
 */
void RenderVisitorOpenGL1::VisitLight( Light* l )
{
	//DLOG(INFO) << "Light accepted visitor" << endl;

	// Set the State if not set or not OpenGL
	if (l->GetState() == 0) {
		State* LightState = new OpenGLState();
		LightState->Enable(GL_LIGHTING);
		LightState->Enable(GL_LIGHT0+LightCounter);

		l->SetState(LightState);
		l->SetLightNumber(LightCounter);

		LightCounter++;
		DLOG(INFO) << "Light Number: " << LightCounter << endl;
	}

	// If the light was changed we need to define the new properties for the light
	if (l->IsChanged()) {
		int Number = l->GetLightNumber();

		glLightfv(GL_LIGHT0+Number, GL_POSITION, l->GetPosition().GetConstPointer());
		glLightfv(GL_LIGHT0+Number, GL_AMBIENT, l->GetAmbient().GetConstPointer());
		glLightfv(GL_LIGHT0+Number, GL_DIFFUSE, l->GetDiffuse().GetConstPointer());
		glLightfv(GL_LIGHT0+Number, GL_SPECULAR, l->GetSpecular().GetConstPointer());

		l->SetChanged(false);
	}

	if (l->GetState())
		l->GetState()->Apply();

	TraverseChildren(l);
}
Esempio n. 3
0
int Gv2Inline::Do(GDisplayTreeTraversal &state) 
{

   int traverse=0;
   int ret=0;
   switch (state.mode) {
   case GDisplayTreeTraversal::MODE_EXTERN_REF:
   case GDisplayTreeTraversal::MODE_TREE:
   default: {

 #ifndef  _NO_DISPLAY_TREE
   HTREEITEM thisItem = state.InsertNodeItem(this,traverse, DGvTreeItem::GV_GROUP_NODE);

   if (traverse) {
   	TREE_PUSH(state,thisItem);
		// inline has separate name space
		GvDict		*saveRefDict = state.refDict;	// NAME HtreeItem 
    	state.refDict = new GvDict();
   		state.topInsertAfter = TVI_LAST;
   		ret = TraverseChildren(state);
		
		delete state.refDict;
		state.refDict = saveRefDict;

   	TREE_POP(state);
   }
   
   state.returnItem = thisItem;
#endif
   break;
   }
   }
   return(ret);
}
Esempio n. 4
0
void TraverseTreebarItems(void)
{
	SetWindowRedraw(Dcx::mIRC.getTreeview(), FALSE);
	TString buf((UINT)MIRC_BUFFER_SIZE_CCH);
	TString res;
	TVITEMEX item;
	ZeroMemory(&item, sizeof(item));
	for (HTREEITEM ptvitem = TreeView_GetRoot(Dcx::mIRC.getTreeview()); ptvitem != NULL; ptvitem = TreeView_GetNextSibling(Dcx::mIRC.getTreeview(), ptvitem)) {
		item.hItem = ptvitem;
		item.pszText = buf.to_chr();
		item.cchTextMax = MIRC_BUFFER_SIZE_CCH;
		item.mask = TVIF_TEXT|TVIF_PARAM;
		if (TreeView_GetItem(Dcx::mIRC.getTreeview(), &item))
		{
			{
				TString tsType;
				DcxDock::getTreebarItemType(tsType, item.lParam);
				Dcx::mIRC.execex("/!set -nu1 %%dcx_%d %s", item.lParam, item.pszText );
				Dcx::mIRC.tsEvalex(res, "$xtreebar_callback(geticons,%s,%%dcx_%d)", tsType.to_chr(), item.lParam);
			}
			item.mask = TVIF_IMAGE|TVIF_SELECTEDIMAGE;
			int i = res.gettok( 1 ).to_int() -1;
			if (i < 0)
				i = 0;
			item.iImage = i;
			i = res.gettok( 2 ).to_int() -1;
			if (i < 0)
				i = 0;
			item.iSelectedImage = i;
			TreeView_SetItem(Dcx::mIRC.getTreeview(), &item);
		}
		TraverseChildren(ptvitem, buf, res, &item);
	}
	SetWindowRedraw(Dcx::mIRC.getTreeview(), TRUE);
}
Esempio n. 5
0
void TraverseChildren(const HTREEITEM hParent, TString &buf, TString &res, LPTVITEMEX pitem)
{
	ZeroMemory(pitem, sizeof(TVITEMEX));
	for (HTREEITEM ptvitem = TreeView_GetChild(Dcx::mIRC.getTreeview(), hParent); ptvitem != NULL; ptvitem = TreeView_GetNextSibling(Dcx::mIRC.getTreeview(), ptvitem)) {
		pitem->hItem = ptvitem;
		pitem->pszText = buf.to_chr();
		pitem->cchTextMax = MIRC_BUFFER_SIZE_CCH;
		pitem->mask = TVIF_TEXT|TVIF_PARAM;
		if (TreeView_GetItem(Dcx::mIRC.getTreeview(), pitem))
		{
			{
				TString tsType;
				DcxDock::getTreebarItemType(tsType, pitem->lParam);
				Dcx::mIRC.execex("/!set -nu1 %%dcx_%d %s", pitem->lParam, pitem->pszText );
				Dcx::mIRC.tsEvalex(res, "$xtreebar_callback(geticons,%s,%%dcx_%d)", tsType.to_chr(), pitem->lParam);
			}
			pitem->mask = TVIF_IMAGE|TVIF_SELECTEDIMAGE;
			int i = res.gettok( 1 ).to_int() -1;
			if (i < 0)
				i = 0;
			pitem->iImage = i;
			i = res.gettok( 2 ).to_int() -1;
			if (i < 0)
				i = 0;
			pitem->iSelectedImage = i;
			TreeView_SetItem(Dcx::mIRC.getTreeview(), pitem);
		}
		TraverseChildren(ptvitem, buf, res, pitem);
	}
}
/**
* \brief Get transformations for viewing space and projection.
* Retrieve the view matrix and projection load them to
* the matrix stacks. View and projection transforms aren't
* accumulated.
*
* @see Camera
* @param c Node to visit
*/
void RenderVisitorOpenGL1::VisitCamera( Camera* c)
{
	// save current matrices
	_modelViewMatrix.PushMatrix();
	_projectionMatrix.PushMatrix();

	// retrieve view and projection matrices
	// maybe shouldn't accumulate them but replace current
	// matrices? Does it make sense to add transformations
	// for cameras?
	M3DMatrix44f matrix;
	c->GetViewMatrix(matrix);
	_modelViewMatrix.LoadMatrix( matrix );
	c->GetProjectionMatrix(matrix);
	_projectionMatrix.LoadMatrix( matrix );

	// OpenGL Load Matrices/
	glMatrixMode(GL_PROJECTION);
	glLoadMatrixf(_projectionMatrix.GetMatrix());

	glMatrixMode(GL_MODELVIEW);
	glLoadMatrixf( _modelViewMatrix.GetMatrix() );

	TraverseChildren(c);

	_projectionMatrix.PopMatrix();
	_modelViewMatrix.PopMatrix();

	// Open GL Restore Matrices
	glMatrixMode(GL_PROJECTION);
	glLoadMatrixf(_projectionMatrix.GetMatrix());

	glMatrixMode(GL_MODELVIEW);
	glLoadMatrixf( _modelViewMatrix.GetMatrix() );
}
// TODO: transform light with the Viewspace/Projection Matrix!!!
void RenderVisitorOpenGL1::VisitLight( Light* l )
{
	// Set the State if not set or not OpenGL
	if (l->GetState() == 0) {
		State* LightState = new OpenGLState();
		LightState->Enable(GL_LIGHTING);
		LightState->Enable(GL_LIGHT0+l->GetLightNumber());
		// TODO: warning when to many lights!
		l->SetState(LightState);
	}

	// If the light was changed we need to define the new properties for the light
	if (l->IsChanged()) {
		int Number = l->GetLightNumber();

		glLightfv(GL_LIGHT0+Number, GL_POSITION, l->GetPosition().GetConstPointer());
		glLightfv(GL_LIGHT0+Number, GL_AMBIENT, l->GetAmbient().GetConstPointer());
		glLightfv(GL_LIGHT0+Number, GL_DIFFUSE, l->GetDiffuse().GetConstPointer());
		glLightfv(GL_LIGHT0+Number, GL_SPECULAR, l->GetSpecular().GetConstPointer());

		l->SetChanged(false);
	}

	if (l->GetState())
		l->GetState()->Apply();

	TraverseChildren(l);

	if (l->GetState())
		l->GetState()->Undo();
}
Esempio n. 8
0
		//Sets
		/*virtual*/ void CGroup::SetVisible(const bool bVis)
		{
			m_bVisible.Bool(VisibilityMask::SELF, bVis);
			TraverseChildren(this, [&bVis](CObject* pChild)
			{
				pChild->OnParentVisibilityChanged(bVis);
			});
			OnVisibilityChanged(bVis);
		}
Esempio n. 9
0
void
DeleteTree(const Path& pth)
{
	TraverseChildren(pth, [&](NodeCategory c, const string& name){
		const auto child(pth / name);

		if(c == NodeCategory::Directory)
			DeleteTree(child);
		uremove(string(child).c_str());
	});
}
Esempio n. 10
0
void
ClearTree(const Path& pth)
{
    TraverseChildren(pth, [&](NodeCategory c, NativePathView npv) {
        const auto child(pth / String(npv));

        if(c == NodeCategory::Directory)
            DeleteTree(child);
        TryRemove(string(child).c_str());
    });
}
/**
* Get transformation data.
*/
void RenderVisitorOpenGL1::VisitTransform( Transform* t )
{
	//DLOG(INFO) << "Transform accepted visitor" << endl;

	_modelViewMatrix.PushMatrix(); // save current matrix
	_modelViewMatrix.MultMatrix( t->GetMatrix() );

	glMatrixMode(GL_MODELVIEW);
	glLoadMatrixf( _modelViewMatrix.GetMatrix() );

	TraverseChildren(t);

	_modelViewMatrix.PopMatrix(); // restore matrix
}
Esempio n. 12
0
int GvGroup::Do(GDisplayTreeTraversal &state) 
{  int traverse=1;
   int ret = 1;
 

   switch (state.mode) {
   case GDisplayTreeTraversal::MODE_EXTERN_REF:
   		ret=TraverseChildren(state);
		break;
/*
   case GDisplayTreeTraversal::MODE_DEF:
        // if (
     	ret=TraverseChildren(state);
		break;
*/

   case GDisplayTreeTraversal::MODE_TREE:
   default:
		{
#ifndef  _NO_DISPLAY_TREE

   		HTREEITEM thisItem = state.InsertNodeItem(this,traverse, DGvTreeItem::GV_GROUP_NODE);

   		if (traverse) {
   			TREE_PUSH(state,thisItem);
   				state.topInsertAfter = TVI_LAST;
   				ret=TraverseChildren(state);
   			TREE_POP(state);
   		}
   
   		state.returnItem = thisItem;
#endif
		}
   break;
   }
   return(ret);
}
/**
* Get transformation data.
*/
void RenderVisitorOpenGL1::VisitTransform( Transform* t )
{
	// Save our viewspace matrix
	_modelViewMatrix.PushMatrix();

	// create the one containing the transformation
	_modelViewMatrix.MultMatrix( t->GetMatrix() );

	// load new matrix
	glMatrixMode(GL_MODELVIEW);
	glLoadMatrixf( _modelViewMatrix.GetMatrix() );

	TraverseChildren(t);

	// restore the old one
	_modelViewMatrix.PopMatrix();
}
Esempio n. 14
0
		const Part::PartList GetPartList(const Object::CObject* const pObj, const bool& reverse_priority)
		{
			assert(pObj);
			Part::PartList list;

			std::vector<Part::IPart*> vec = pObj->GetParts();
			for (ulong i = 0; i < vec.size(); ++i)
			{
				list.push_back(vec[i]);
			}

			if (pObj->IsGroup())
			{
				const CGroup* const pGroup = static_cast<const CGroup* const>(pObj);
				TraverseChildren(pGroup, [&list](Object::CObject* pObj)
				{
					std::vector<Part::IPart*> vec = pObj->GetParts();
					for (ulong i = 0; i < vec.size(); ++i)
					{
						list.push_back(vec[i]);
					}
				});
			}

			//Type of sorting function
			std::function<bool(Part::IPart* lhs, Part::IPart* rhs)> func;
			if (reverse_priority)
			{
				func = [](Part::IPart* lhs, Part::IPart* rhs)
				{
					return lhs->GetPriority() > rhs->GetPriority();
				};
			}
			else
			{
				func = [](Part::IPart* lhs, Part::IPart* rhs)
				{
					return lhs->GetPriority() < rhs->GetPriority();
				};
			}

			list.sort(func);

			return list;
		}
Esempio n. 15
0
		/*virtual*/ void CGroup::Destroy(void)
		{
			std::list<Part::IPart*> list = GetPartList(this, true);
			for (auto iter = list.begin(); iter != list.end(); ++iter)
			{
				(*iter)->Destroy();
			}

			std::list<CObject*> children;
			TraverseChildren(this, [&children](CObject* pChild)
			{
				children.push_back(pChild);
			});
			for (auto iter = children.begin(); iter != children.end(); ++iter)
			{
				delete (*iter);
			}

			delete this;
		}
Esempio n. 16
0
		void TraverseChildren(const CGroup* const that
			, std::function<void(CObject*const)> func
			, int depth)
		{
			assert(that);
			std::vector<CObject*> children = that->GetChildren();
			int size = children.size();
			for (int i = 0; i < size; ++i)
			{
				func(children[i]);
			}
			
			if (depth == 0)
				return;
			
			for (int i = 0; i < size; ++i)
			{
				if (children[i]->IsGroup())
				{
					CGroup* pGroup = static_cast<CGroup*>(children[i]);
					TraverseChildren(pGroup, func, depth - 1);
				}
			}
		}
 void RenderVisitorOpenGL1::VisitGroup( Group* g ) {
	//DLOG(INFO) << "Group accepted visitor" << endl;

	TraverseChildren(g);
}
/* \brief Just traverse the children */
void RenderVisitorOpenGL1::VisitGroup( Group* g ) {
	TraverseChildren(g);
}