Beispiel #1
0
main() {
	BiTNode * n1 = MakeNode(10, NULL, NULL);
	BiTNode * n2 = MakeNode(20, NULL, NULL);
	BiTNode * n3 = MakeNode(30, n1, n2);
	BiTNode * n4 = MakeNode(40, NULL, NULL);
	BiTNode * n5 = MakeNode(50, NULL, NULL);
	BiTNode * n6 = MakeNode(60, n4, n5);
	BiTNode * n7 = MakeNode(70, NULL, NULL);

	BiTree tree = InitBiTree(n7);
	SetLChild(tree, n3);
	SetRChild(tree, n6);

	printf("树的深度为:%d \n", GetDepth(tree));
	printTree(tree, GetDepth(tree));

	printf("\n先序遍历如下:");
	PreOrderTraverse(tree, print);

	printf("\n中序遍历如下:");
	InOrderTraverse(tree, print);

	printf("\n后序遍历如下:");
	PostOrderTraverse(tree, print);

	DeleteChild(tree, 1);
	printf("\n后序遍历如下:");
	PostOrderTraverse(tree, print);

	DestroyBiTree(tree);
	if (IsEmpty(tree))
		printf("\n二叉树为空,销毁完毕\n");
}
Beispiel #2
0
void Label::DrawSelf()
{
	int l_posX = 0;
	int l_posY = 0;

	m_pRenderer->SetRenderMode(RM_SOLID);

	m_pRenderer->RenderFreeTypeText(m_GUIFont, (float)l_posX, (float)l_posY, GetDepth(), m_colour, 1.0f, "%s", m_text.c_str());

	if(m_outline)
	{
		m_pRenderer->RenderFreeTypeText(m_OutlineGUIFont, (float)l_posX, (float)l_posY, GetDepth(), m_outlineColour, 1.0f, "%s", m_text.c_str());
	}

	/* DEBUG : Text bounds checking
	int l_stringWidth = m_pRenderer->GetFreeTypeTextWidth(m_GUIFont, "%s", m_text.c_str());
	int l_stringHeight = m_pRenderer->GetFreeTypeTextHeight(m_GUIFont, "%s", m_text.c_str());

	int l_outlineX1 = 0;
	int l_outlineX2 = l_stringWidth;
	int l_outlineY1 = 0;
	int l_outlineY2 = l_stringHeight;

	m_pRenderer->PushMatrix();
		m_pRenderer->SetRenderMode(RM_WIREFRAME);
		m_pRenderer->EnableImmediateMode(IM_QUADS);
		m_pRenderer->ImmediateColourAlpha(1.0f, 1.0f, 1.0f, 1.0f);
		m_pRenderer->ImmediateVertex(l_outlineX1, l_outlineY1, (int)m_depth);
		m_pRenderer->ImmediateVertex(l_outlineX2, l_outlineY1, (int)m_depth);
		m_pRenderer->ImmediateVertex(l_outlineX2, l_outlineY2, (int)m_depth);
		m_pRenderer->ImmediateVertex(l_outlineX1, l_outlineY2, (int)m_depth);
		m_pRenderer->DisableImmediateMode();
	m_pRenderer->PopMatrix();
	*/
}
/*--------------------------------------------------------------------------------*/
AudioObjectParameters& AudioObjectParameters::Modify(const Modifier& modifier, const ADMAudioObject *object)
{
  if (modifier.rotation.IsSet())
  {
    SetPosition(GetPosition() * modifier.rotation.Get());
    if (IsMinPositionSet()) SetMinPosition(GetMinPosition() * modifier.rotation.Get());
    if (IsMaxPositionSet()) SetMaxPosition(GetMaxPosition() * modifier.rotation.Get());

    Position size(GetWidth(), GetDepth(), GetHeight());
    size *= modifier.rotation.Get();
    SetWidth(static_cast<float>(size.pos.x));
    SetDepth(static_cast<float>(size.pos.y));
    SetHeight(static_cast<float>(size.pos.z));
  }
  if (modifier.position.IsSet()) SetPosition(GetPosition() + modifier.position.Get());
  if (modifier.scale.IsSet())
  {
    SetPosition(GetPosition() * modifier.scale.Get());
    if (IsMinPositionSet()) SetMinPosition(GetMinPosition() * modifier.scale.Get());
    if (IsMaxPositionSet()) SetMaxPosition(GetMaxPosition() * modifier.scale.Get());

    Position size(GetWidth(), GetDepth(), GetHeight());
    size *= modifier.scale.Get();
    SetWidth(static_cast<float>(size.pos.x));
    SetDepth(static_cast<float>(size.pos.y));
    SetHeight(static_cast<float>(size.pos.z));
  }
  if (modifier.gain.IsSet()) SetGain(GetGain() * modifier.gain.Get());

  // apply specific modifications (from derived classes)
  modifier.Modify(*this, object);

  return *this;
}
Beispiel #4
0
/// 求二叉树的深度
/// 递归解法:如果二叉树为空,二叉树的深度为0
///           如果二叉树不空,二叉树的深度 = max(左子树深度,右子树深度)+1
int GetDepth(TreeNode* root)
{
	if(root == NULL) /// 递归出口
		return 0;
	int depthLeft = GetDepth(root->left);
	int depthRight = GetDepth(root->right);
	return (depthLeft > depthRight)?(depthLeft + 1):(depthRight + 1);
}
Beispiel #5
0
//更新深度
void MyTree::UpdateDepth(TreeNode* pNode)
{
  TreeNode* pParent = pNode->m_pParent; 
  while(pParent)
  {
    //设置父节点的深度
    int nLeftDepth = GetDepth(pParent->m_pLeft);
    int nRightDepth = GetDepth(pParent->m_pRight);
    pParent->m_nDepth = max(nLeftDepth, nRightDepth) + 1;

    //判断是否平衡
    if(abs(nLeftDepth - nRightDepth) >= 2)
    {
      TreeNode* pNode1 = pParent;
      TreeNode* pNode2 = NULL;
      TreeNode* pNode3 = NULL;

      if(pNode1->m_pLeft)
      {
        pNode2 = pNode1->m_pLeft;
      }
      else
      {
        pNode2 = pNode1->m_pRight;
      }

      if(pNode2->m_pLeft)
      {
        pNode3 = pNode2->m_pLeft;
      }
      else
      {
        pNode3 = pNode2->m_pRight;
      }

      //进行相关的旋转操作
      if(pNode1->m_pLeft == pNode2 && pNode2->m_pLeft == pNode3)
      {
        //右单旋
      }
      else if(pNode1->m_pRight == pNode2 && pNode2->m_pRight == pNode3)
      {
        //左单旋
      }
      else if(pNode1->m_pRight == pNode2 && pNode2->m_pLeft == pNode3)
      {
        //先右单旋 再左单旋
      }
      else if(pNode1->m_pLeft == pNode2 && pNode2->m_pRight == pNode3)
      {
        //先左单旋 再右单旋
      }
    }

    pParent = pParent->m_pParent;
  }
}
Beispiel #6
0
bool
nsTreeRows::iterator::operator==(const iterator& aIterator) const
{
    if (GetDepth() != aIterator.GetDepth())
        return false;

    if (GetDepth() == 0)
        return true;

    return GetTop() == aIterator.GetTop();
}
Beispiel #7
0
bool
nsTreeRows::iterator::operator==(const iterator& aIterator) const
{
    if (GetDepth() != aIterator.GetDepth())
        return PR_FALSE;

    if (GetDepth() == 0)
        return PR_TRUE;

    return GetTop() == aIterator.GetTop();
}
Beispiel #8
0
void wxBitmap::SetPalette(const wxPalette& palette)
{
    wxCHECK_RET( IsOk(), wxT("invalid bitmap") );
    wxCHECK_RET( GetDepth() > 1 && GetDepth() <= 8, wxT("cannot set palette for bitmap of this depth") );

    AllocExclusive();
    wxDELETE(M_BITMAP->m_palette);

    if ( !palette.IsOk() ) return;

    M_BITMAP->m_palette = new wxPalette(palette);
}
Beispiel #9
0
///== /////////////////////////////////////////////
int GetDepth(RBTreeNode *node)
{
  
  RBTreeNode *l = node->left;
  RBTreeNode *r = node->right;
  int ld = 0;
  int rd = 0;
  if (l != 0) ld = 1 + GetDepth(l); 
  if (r != 0) rd = 1 + GetDepth(r); 
  if (ld >= rd) return ld; else return rd;
  return 0;
}
Beispiel #10
0
unsigned int BinarySearchTree<Key, Value>::GetDepth (typename BinarySearchTree<Key, Value>::BSTnode* subtree)
{
    unsigned int left=0, right=0, root=0;
    if (subtree==NULL)
    {
        return 0;
    }
    left=GetDepth(subtree->m_left);
    right=GetDepth(subtree->m_right);
    root=( left>right ? left : right )+1;
    return root;
}
Beispiel #11
0
		void Parse()
		{
			ReadNextNode();

			WriteElement();

			int nDepth = GetDepth();
			if ( 0 == xmlTextReaderIsEmptyElement(reader) )
			{
				XmlNodeType eNodeType = XmlNodeType_None;

				int nCurDepth = -1;
				// У закрывающего тэга глубина на 1 больше, чем у открывающего
                while( true )
				{
					if ( 1 != xmlTextReaderRead(reader) )
						break;

					int nTempType = xmlTextReaderNodeType(reader);
					if(-1 == nTempType)
						break;
					eNodeType = (XmlNodeType)nTempType;

					nCurDepth = GetDepth();
					if ( eNodeType == XmlNodeType_Text || eNodeType == XmlNodeType_Whitespace || eNodeType == XmlNodeType_SIGNIFICANT_WHITESPACE )
						m_pCurrentNode->m_sText += GetText();
					else if (eNodeType == XmlNodeType_Element)
						WriteElement();
					else if (eNodeType == XmlNodeType_EndElement)
					{
						m_list.pop_back();
						
						if (0 != m_list.size())
						{
							std::list<CXmlNodeBase*>::iterator iter = m_list.end();
							--iter;
							m_pCurrentNode = *iter;
						}
						else
						{
							m_pCurrentNode = m_pNode;
						}
					}

					nCurDepth = GetDepth();
					if ( nCurDepth < nDepth )
						break;

					if ( XmlNodeType_EndElement == eNodeType && nCurDepth == nDepth )
						break;
				}
			}
		}
Beispiel #12
0
void
nsTreeRows::iterator::Prev()
{
    NS_PRECONDITION(GetDepth() > 0, "cannot increment an uninitialized iterator");

    // Decrement the absolute row index
    --mRowIndex;

    // Move to the previous child in this subtree
    --(GetTop().mChildIndex);

    // Have we exhausted the current subtree?
    if (GetTop().mChildIndex < 0) {
        // Yep. See if we've just iterated back to the first element
        // in the tree, period. Walk back up the stack, looking for
        // any unfinished subtrees.
        PRInt32 unfinished;
        for (unfinished = GetDepth() - 2; unfinished >= 0; --unfinished) {
            const Link& link = mLink[unfinished];
            if (link.mChildIndex >= 0)
                break;
        }

        // If there are no unfinished subtrees in the stack, then this
        // iterator is exhausted. Leave it in the same state that
        // First() does.
        if (unfinished < 0)
            return;

        // Otherwise, we ran off the end of one of the inner
        // subtrees. Pop up to the next unfinished level in the stack.
        mLink.SetLength(unfinished + 1);
        return;
    }

    // Is there a child subtree immediately prior to our current
    // position? If so, descend into it, grovelling down to the
    // deepest, rightmost left edge.
    Subtree* parent = GetTop().GetParent();
    PRInt32 index = GetTop().GetChildIndex();

    Subtree* subtree = (*parent)[index].mSubtree;

    if (subtree && subtree->Count()) {
        do {
            index = subtree->Count() - 1;
            Append(subtree, index);

            parent = subtree;
            subtree = (*parent)[index].mSubtree;
        } while (subtree && subtree->Count());
    }
}
void ExperimentalPoint::CheckList(TString grid, int quad, int level){
  
  //Check if it's already in the list
  for (unsigned i = 0 ; i < flistGrid.size() ; i++)
	if(grid == flistGrid.at(i) && quad == flistQuad.at(i) && GetDepth(level) == flistDepth.at(i) ) return ;

//otherwise 
	flistGrid.push_back(grid) ;
	flistQuad.push_back(quad) ;
	flistDepth.push_back(GetDepth(level)); 

return; 
}
Beispiel #14
0
//函数返回根结点的最大和最小深度
Depth GetDepth(SearchTree tree) {
	if (NULL == tree) {
		Depth empty = {0, 0};
		return empty;
	}

	Depth lhs = GetDepth(tree->left);
	Depth rhs = GetDepth(tree->right);
	Depth depth;
	depth.max_depth = 1 + max(lhs.max_depth, rhs.max_depth);
	depth.min_depth = 1 + min(lhs.min_depth, rhs.min_depth);
	return depth;
}
Beispiel #15
0
//求二叉树深度
int GetDepth( BiNode *T )
{
	if( T == NULL )
	{
	      	return 0;
	}

	// int Left_Length = GetDepth( T->lch );
	// int Right_Length = GetDepth( T->rch );
	// return Left_length > Right_Length ?( Left_Length + 1 ) : ( Right_length + 1 );
	return GetDepth( T->lch ) > GetDepth( T->rch ) ?
		( GetDepth( T->lch ) + 1 ) : ( GetDepth( T->rch ) + 1 );
}
Beispiel #16
0
void Terrain::BuildQuadPatchVB(ID3D11Device* device)
{
	patchVertices.resize(mNumPatchVertRows*mNumPatchVertCols);

	float halfWidth = 0.5f*GetWidth();
	float halfDepth = 0.5f*GetDepth();

	float patchWidth = GetWidth() / (mNumPatchVertCols-1);
	float patchDepth = GetDepth() / (mNumPatchVertRows-1);
	float du = 1.0f / (mNumPatchVertCols-1);
	float dv = 1.0f / (mNumPatchVertRows-1);

	for(UINT i = 0; i < mNumPatchVertRows; ++i)
	{
		float z = halfDepth - i*patchDepth;
		for(UINT j = 0; j < mNumPatchVertCols; ++j)
		{
			float x = -halfWidth + j*patchWidth;

			patchVertices[i*mNumPatchVertCols+j].Pos = XMFLOAT3(x, 0.0f, z);

			// Stretch texture over grid.
			patchVertices[i*mNumPatchVertCols+j].Tex.x = j*du;
			patchVertices[i*mNumPatchVertCols+j].Tex.y = i*dv;
		}
	}

	// Store axis-aligned bounding box y-bounds in upper-left patch corner.
	for(UINT i = 0; i < mNumPatchVertRows-1; ++i)
	{
		for(UINT j = 0; j < mNumPatchVertCols-1; ++j)
		{
			UINT patchID = i*(mNumPatchVertCols-1)+j;
			patchVertices[i*mNumPatchVertCols+j].BoundsY = mPatchBoundsY[patchID];
		}
	}

    D3D11_BUFFER_DESC vbd;
    vbd.Usage = D3D11_USAGE_IMMUTABLE;
	vbd.ByteWidth = sizeof(Vertex::Terrain) * patchVertices.size();
    vbd.BindFlags = D3D11_BIND_VERTEX_BUFFER;
    vbd.CPUAccessFlags = 0;
    vbd.MiscFlags = 0;
	vbd.StructureByteStride = 0;

	D3D11_SUBRESOURCE_DATA vinitData;
    vinitData.pSysMem = &patchVertices[0];
    HR(device->CreateBuffer(&vbd, &vinitData, &mQuadPatchVB));
}
Beispiel #17
0
//右单旋
void MyTree::RightRotate(TreeNode* pNode1, TreeNode* pNode2)
{
  /*
             [X]              X
          [N1]   C         N2    C
       [N2]    B         N3   N1
    N3   [A]                A    B
  */
  TreeNode* pNodeX = pNode1->m_pParent;
  TreeNode* pNodeA = pNode2->m_pRight;

  //pNodeX
  if(pNodeX)
  {
    if(pNodeX->m_pLeft == pNode1)
    {
      pNodeX->m_pLeft = pNode2;
    }
    else
    {
      pNodeX->m_pRight = pNode2;
    }
  }
  else
  {
    m_pRoot = pNode2;
  } 

  //pNode1
  pNode1->m_pLeft = pNodeA;
  pNode1->m_pParent = pNode2;

  //pNode2
  pNode2->m_pParent = pNodeX;
  pNode2->m_pRight = pNode1;

  //pNodeA
  if(pNodeA)
  {
    pNodeA->m_pParent = pNode1;
  }

  //更新pNode1和pNode2的深度
  pNode1->m_nDepth = max(GetDepth(pNode1->m_pLeft),
    GetDepth(pNode1->m_pRight)) + 1;
  pNode2->m_nDepth = max(GetDepth(pNode2->m_pLeft),
    GetDepth(pNode2->m_pRight)) + 1;
}
Beispiel #18
0
//左单旋
void MyTree::LeftRotate(TreeNode* pNode1, TreeNode* pNode2)
{
  /*
         X                      X
      C     N1               C     N2
          B    N2               N1    N3
             A    N3          B    A
  */
  TreeNode* pNodeX = pNode1->m_pParent;
  TreeNode* pNodeA = pNode2->m_pLeft;

  //pNodeX
  if(pNodeX)
  {
    if(pNodeX->m_pLeft == pNode1)
    {
      pNodeX->m_pLeft = pNode2;
    }
    else
    {
      pNodeX->m_pRight = pNode2;
    }
  }
  else
  {
    m_pRoot = pNode2;
  }

  //pNode1
  pNode1->m_pRight = pNodeA;
  pNode1->m_pParent = pNode2;

  //pNode2
  pNode2->m_pLeft = pNode1;
  pNode2->m_pParent = pNodeX;

  //pNodeA
  if(pNodeA)
  {
    pNodeA->m_pParent = pNode1;
  }

  //更新pNode1和pNode2的深度
  pNode1->m_nDepth = max(GetDepth(pNode1->m_pLeft),
    GetDepth(pNode1->m_pRight)) + 1;
  pNode2->m_nDepth = max(GetDepth(pNode2->m_pLeft),
    GetDepth(pNode2->m_pRight)) + 1;
}
bool SUIComponentComposite::PostDraw()
{
	SPComposite::ChildIterator iter = children.begin();

	while(iter != children.end())
	{
		if (*iter)
		{
			(*iter)->SetRenderTarget(NULL);
			iter++;
		}
		else
		{
			iter = children.erase(iter);
		}
	}

	if (childTarget)
	{
		SPSpriteManager::GetSingleton().RenderWithRotation(
			childTarget, 
			GetCurrentEffect(), 
			D3DXVECTOR3(GetPosition().x, GetPosition().y, GetDepth()),
			properties.rotationCenter,
			properties.rotation,
			properties.transparency * SPColor::White,
			renderTarget);
	}	

	//childTarget = NULL;

	return true;
}
void AudioObjectParameters::MultiplyByScene(float width, float height, float depth)
{
  Position pos = GetPosition().Cart();
  pos.pos.x *= width;
  pos.pos.y *= depth;
  pos.pos.z *= height;
  SetPosition(GetPosition().polar ? pos.Polar() : pos);

  if (IsMinPositionSet())
  {
    Position pos = GetMinPosition().Cart();
    pos.pos.x *= width;
    pos.pos.y *= depth;
    pos.pos.z *= height;
    SetMinPosition(GetMinPosition().polar ? pos.Polar() : pos);
  }

  if (IsMaxPositionSet())
  {
    Position pos = GetMaxPosition().Cart();
    pos.pos.x *= width;
    pos.pos.y *= depth;
    pos.pos.z *= height;
    SetMaxPosition(GetMaxPosition().polar ? pos.Polar() : pos);
  }

  SetWidth(GetWidth() * width);
  SetHeight(GetHeight() * height);
  SetDepth(GetDepth() * depth);

  if (excludedZones) excludedZones->MultiplyByScene(width, height, depth);
}
/*--------------------------------------------------------------------------------*/
void AudioObjectParameters::DivideByScene(float width, float height, float depth)
{
  Position pos = GetPosition().Cart();
  pos.pos.x /= width;
  pos.pos.y /= depth;
  pos.pos.z /= height;
  SetPosition(GetPosition().polar ? pos.Polar() : pos);

  if (IsMinPositionSet())
  {
    Position pos = GetMinPosition().Cart();
    pos.pos.x /= width;
    pos.pos.y /= depth;
    pos.pos.z /= height;
    SetMinPosition(GetMinPosition().polar ? pos.Polar() : pos);
  }

  if (IsMaxPositionSet())
  {
    Position pos = GetMaxPosition().Cart();
    pos.pos.x /= width;
    pos.pos.y /= depth;
    pos.pos.z /= height;
    SetMaxPosition(GetMaxPosition().polar ? pos.Polar() : pos);
  }

  SetWidth(GetWidth() / width);
  SetHeight(GetHeight() / height);
  SetDepth(GetDepth() / depth);
  
  if (excludedZones) excludedZones->DivideByScene(width, height, depth);
}
Beispiel #22
0
// On utilise cette fonction lorsque un coup refute le coup de la couche
// precedente.
int TTableTrans::StoreRefutation( TChessBoard& cb, int ply, int depth,
                                  int wtm, short valeur, int alpha, int beta,
                                  int danger )
{
  Bitboard* pTable;

  // Blanc ou noir?
  pTable = (wtm)?m_pTableBlanc:m_pTableNoir;

  // Retrouver la position dans la table.
  int  iPosition = (m_iMaskCle & (int)cb.CleHachage);
  pTable += iPosition*2;


  // Verifier si la position est meilleur que celle qu'on a dans la table.
  // Si l'age est setter alors toujours remplacer.
  if ( !GetAge( (*pTable) ) && GetDepth( (*pTable) ) > depth  ) {
	g_iTranspositionCollision++;
    return false;
  }

  // Mettre les informations dans la table.
  *pTable = 0;
  *(pTable+1) = cb.CleHachage;
  StoreValeur( (*pTable), valeur );
  int iType = BORNE_INFERIEUR;
  StoreType( (*pTable), iType );
  StoreDanger( (*pTable), danger );
  StoreCoup( (*pTable), 0 );
  StoreDepth( (*pTable), depth );

  return true;
}
Beispiel #23
0
float Box::GetVolume() const
{
    float w = GetWidth();
    float h = GetHeight();
    float d = GetDepth();
    return w * h * d;
}
Beispiel #24
0
void
nsTreeRows::iterator::Next()
{
    NS_PRECONDITION(GetDepth() > 0, "cannot increment an uninitialized iterator");

    // Increment the absolute row index
    ++mRowIndex;

    Link& top = GetTop();

    // Is there a child subtree? If so, descend into the child
    // subtree.
    Subtree* subtree = top.GetRow().mSubtree;

    if (subtree && subtree->Count()) {
        Append(subtree, 0);
        return;
    }

    // Have we exhausted the current subtree?
    if (top.mChildIndex >= top.mParent->Count() - 1) {
        // Yep. See if we've just iterated path the last element in
        // the tree, period. Walk back up the stack, looking for any
        // unfinished subtrees.
        PRInt32 unfinished;
        for (unfinished = GetDepth() - 2; unfinished >= 0; --unfinished) {
            const Link& link = mLink[unfinished];
            if (link.mChildIndex < link.mParent->Count() - 1)
                break;
        }

        // If there are no unfinished subtrees in the stack, then this
        // iterator is exhausted. Leave it in the same state that
        // Last() does.
        if (unfinished < 0) {
            top.mChildIndex++;
            return;
        }

        // Otherwise, we ran off the end of one of the inner
        // subtrees. Pop up to the next unfinished level in the stack.
        mLink.SetLength(unfinished + 1);
    }

    // Advance to the next child in this subtree
    ++(GetTop().mChildIndex);
}
Beispiel #25
0
bool IsBalancedTree2(SearchTree tree) {
	Depth depth = GetDepth(tree);
	//如果根结点的最大深度和最小深度之差不超过1为平衡二叉树
	if (depth.max_depth - depth.min_depth > 1)
		return false;
	else
		return true;
}
Beispiel #26
0
XxWindow::XxWindow
    ( EzString Name
    , XxWindow *Parent
    , int XPos, int YPos, int Width, int Height
    , EzString Title
    )
    : XxDrawable (Name), Member (this), WindowsMember (this)
{
    Window               XxParentWindow;
    Atom                 atom;

    XxWindow::Parent   = Parent;

    Hints.x            = XPos;
    Hints.y            = YPos;
    Hints.width        = Width;
    Hints.height       = Height;

    XxAttrs.event_mask =   ExposureMask
                         | EnterWindowMask | LeaveWindowMask
                         | ButtonPressMask | ButtonReleaseMask;

    XxAttrMask         = CWEventMask;

    WindowsMember.Attach  (WindowsOwner);
    if (Parent != NULL) Member.Attach (Parent->Owner);

    XxParentWindow =
        (Parent == NULL ? GetRootWindow () : Parent->Xid);

    Xid = XCreateWindow
        ( GetDisplay (), XxParentWindow
        , Hints.x, Hints.y, Hints.width, Hints.height
        , 0, GetDepth ()
        , InputOutput, CopyFromParent
        , XxAttrMask, &XxAttrs);

    XxAttrMask = 0;

    Hints.max_width    = Width;
    Hints.max_height   = Height;
    Hints.min_width    = Width;
    Hints.min_height   = Height;
    Hints.flags        = PMinSize | PMaxSize | PPosition | PSize;

    XSetNormalHints (GetDisplay (), Xid, &Hints);
    // XStoreName      (GetDisplay (), Xid, "Test");

    XMapRaised      (GetDisplay (), Xid);
    XSelectInput    (GetDisplay (), Xid, XxAttrs.event_mask);

    if (Parent == NULL) {
        atom = GetWmDeleteWindow ();

        XStoreName      (GetDisplay (), Xid, Title);
        XSetWMProtocols (GetDisplay (), Xid, &atom, 1);
    };
};
Beispiel #27
0
void OptionController::DrawSelf()
{
	if(mbDisplayBorder)
	{
		int l_containerWidth = m_dimensions.m_width;
		int l_containerHeight = m_dimensions.m_height;
		float l_depth = GetDepth();

		float l_outlineX1 = 0.5f;
		float l_outlineX2 = l_containerWidth + 0.5f;
		float l_outlineY1 = 0.5f;
		float l_outlineY2 = l_containerHeight + 0.5f;

		int l_LabelheightAdjust = m_pRenderer->GetFreeTypeTextHeight(m_label.GetFontID(), "%s", m_label.GetText().c_str()) / 2;
		int l_labelWidth = m_pRenderer->GetFreeTypeTextWidth(m_label.GetFontID(), "%s", m_label.GetText().c_str());

		if(mbDisplayLabel)
		{
			m_pRenderer->PushMatrix();
				m_pRenderer->SetLineWidth(1.0f);
				m_pRenderer->ImmediateColourAlpha(1.0f, 1.0f, 1.0f, 1.0f);
				m_pRenderer->EnableImmediateMode(IM_LINES);
				m_pRenderer->ImmediateVertex(l_outlineX1 + m_labelIndent, l_outlineY2 + l_LabelheightAdjust, l_depth);
				m_pRenderer->ImmediateVertex(l_outlineX1, l_outlineY2 + l_LabelheightAdjust, l_depth);

				m_pRenderer->ImmediateVertex(l_outlineX1, l_outlineY2 + l_LabelheightAdjust, l_depth);
				m_pRenderer->ImmediateVertex(l_outlineX1, l_outlineY1, l_depth);

				m_pRenderer->ImmediateVertex(l_outlineX1, l_outlineY1, l_depth);
				m_pRenderer->ImmediateVertex(l_outlineX2, l_outlineY1, l_depth);

				m_pRenderer->ImmediateVertex(l_outlineX2, l_outlineY1, l_depth);
				m_pRenderer->ImmediateVertex(l_outlineX2, l_outlineY2 + l_LabelheightAdjust, l_depth);

				m_pRenderer->ImmediateVertex(l_outlineX2, l_outlineY2 + l_LabelheightAdjust, l_depth);
				m_pRenderer->ImmediateVertex(l_outlineX1 + m_labelIndent + l_labelWidth + 2, l_outlineY2 + l_LabelheightAdjust, l_depth);
				m_pRenderer->DisableImmediateMode();
			m_pRenderer->PopMatrix();
		}
		else
		{
			m_pRenderer->PushMatrix();
				m_pRenderer->SetLineWidth(1.0f);
				m_pRenderer->ImmediateColourAlpha(1.0f, 1.0f, 1.0f, 1.0f);
				m_pRenderer->EnableImmediateMode(IM_LINE_LOOP);
				m_pRenderer->ImmediateVertex(l_outlineX1, l_outlineY1, l_depth);
				m_pRenderer->ImmediateVertex(l_outlineX2, l_outlineY1, l_depth);
				m_pRenderer->ImmediateVertex(l_outlineX2 + 1, l_outlineY2, l_depth);
				m_pRenderer->ImmediateVertex(l_outlineX1, l_outlineY2, l_depth);
				m_pRenderer->DisableImmediateMode();
			m_pRenderer->PopMatrix();
		}
	
	}

	// Set the label visibility
	m_label.SetVisible(mbDisplayLabel);
}
Beispiel #28
0
// Copy from DIB's color table to DIB section's color table
UINT KDIBSection::SetColorTable(void)
{
	int width, height;

	if ( (GetDepth()>8) || ! Prepare(width, height) ) // create memory DC
		return 0;

	return SetDIBColorTable(m_hMemDC, 0, m_nClrUsed, m_pRGBQUAD);
}
void ExperimentalPoint::CalculateCentralPosition(void){ // taking into account the level and the quadrant 
	 //Calculate position with respect to the Mapper
	double x,y,z;
	TString label = fGrid+fGrid+Form("%d",fLocation); // AA1
	x = fmapPosition[label].X() ; 
	y = fmapPosition[label].Y() ;
	z = GetDepth(fLevel); 
	fPosition.SetXYZ(x,y,z); 
}
Beispiel #30
0
float Box::GetArea() const
{
    float w = GetWidth();
    float h = GetHeight();
    float d = GetDepth();
    return w * h * 2 +
           w * d * 2 +
           h * d * 2;
}