void StaticMap::SendPosition(Player *player)
{
    switch (PosType())
    {
    case POSITION_SIMPLE :
        player->SendSimplePositionalUpdate(
                            GameID(),
                            PosInfo());
        break;

    case POSITION_PLANET :
        player->SendPlanetPositionalUpdate(
                            GameID(),
                            PosInfo());
        break;

    case POSITION_CONSTANT :
        player->SendConstantPositionalUpdate(
                            GameID(),
                            PosX(),
                            PosY(),
                            PosZ(),
                            Orientation());
        break;
    }
}
Beispiel #2
0
void CBox::Render()
{
	m_pTM->DrawWithZSort(CurrImage(), PosX(), PosY(), PosZ(), m_fScaleX, m_fScaleY, NULL, 0.0f, 0.0f, 0.0f, D3DCOLOR_ARGB(m_nAlpha, 255, 255, 255));
	
	for (int i = 0; i < m_nNumItems; ++i)
	{
// 		if(m_Timer.GetElapsed() > 0.0475f && (i == m_nCurrSelectedIndex || i == m_nCurrInputIndex))
// 			continue;
		if (i == m_nCurrSelectedIndex || i == m_nCurrInputIndex)	// color the currently selected item
			m_dwColor = D3DCOLOR_ARGB(m_nAlpha, 255,50,50/*r, g, b*/);
		else
			m_dwColor = D3DCOLOR_ARGB(m_nAlpha, 255,255,255/*r, g, b*/);
		if (!m_bHasTitle || i > 0)
		{
			if (!m_bCenterText)
				m_pBM->DrawString(m_sItems[i].c_str(), m_nStartTextX, m_nStartTextY+(int)((float)i*((float)m_nSpacing*1.5f)), m_fTextZ, m_fTextScale, m_dwColor);
			else
				m_pBM->DrawStringAutoCenterBox(m_sItems[i].c_str(), m_nBoxWidth, m_nPosX, m_nStartTextY+(int)((float)i*((float)m_nSpacing*1.5f)), m_fTextZ, m_fTextScale, m_dwColor);
		}
		else // drawing the Title text, centered, and underlined
		{
			int centerBox = m_nBoxRight - (m_nBoxWidth >> 1);
			int centerStr = (m_nTitleWidth >> 1);
			m_pBM->DrawString(m_sItems[i].c_str(), centerBox-centerStr, m_nStartTextY+(int)((float)i*((float)m_nSpacing*1.5f)), m_fTextZ, m_fTextScale, m_dwColor);
			m_pD3D->DrawLine(centerBox-centerStr+5, m_nStartTextY + (int)((float)m_nSpacing*1.2f), centerBox-centerStr + m_nTitleWidth, m_nStartTextY + (int)((float)m_nSpacing*1.2f),
								0, 0, 0);
		}
	}
// 	else
// 	{
// 		m_dwColor = D3DCOLOR_ARGB(m_nAlpha, 255,50,50/*r, g, b*/);
// 		int centerBox = m_nBoxRight - (m_nBoxWidth >> 1);
// 		int centerStr = (m_nTitleWidth >> 1);
// 		m_pBM->DrawString(m_sInput.c_str(), centerBox-centerStr, m_nStartTextY, m_fTextZ, m_fTextScale, m_dwColor);
// 
// 	}
	if (m_nBackType == BOX_WITH_BACK)
	{
		if (m_nCurrSelectedIndex == BTN_BACK)
			m_dwColor = D3DCOLOR_ARGB(m_nAlpha, 255,50,50/*r, g, b*/);
		else
			m_dwColor = D3DCOLOR_ARGB(m_nAlpha, 255,255,255/*r, g, b*/);
		if (!m_bIsMsgBox)
			m_pBM->DrawString("BACK-ESC", (m_nBoxRight-(25+(int)(300.0f*m_fTextScale*0.8f))), m_nBoxBottom-(int)(40.0f*m_fTextScale), m_fTextZ, m_fTextScale * 0.7f, m_dwColor);
		else
			m_pBM->DrawString("OK", (m_nBoxRight-(25+(int)(300.0f*m_fTextScale*0.8f))), m_nBoxBottom-(int)(40.0f*m_fTextScale), m_fTextZ, m_fTextScale * 0.7f, m_dwColor);
	}
	if (m_bAcceptInput)
	{
	    if (m_nCurrSelectedIndex == BTN_ENTER || m_nCurrInputIndex == BTN_ENTER)
			m_dwColor = D3DCOLOR_ARGB(m_nAlpha, 255,50,50/*r, g, b*/);
		else
			m_dwColor = D3DCOLOR_ARGB(m_nAlpha, 255,255,255/*r, g, b*/);
		if (m_bAcceptInput)
			m_pBM->DrawString("ENTER", m_nPosX+25, m_nBoxBottom-(int)(40.0f*m_fTextScale), m_fTextZ, m_fTextScale * 0.7f, m_dwColor );
	}
}
Beispiel #3
0
void HistogramView::draw( QSize sz )
{
    QGraphicsScene *sc = scene();
    assert(sc);

    m_xRatio = 1.0 * ( sz.width() - 4*m_Border ) / ( m_maxX - m_minX );
    m_yRatio = 1.0 * ( sz.height() - 2*m_Border ) / ( m_maxY - m_minY );

    // eleimino la vecchia scena
    if (m_histogramItems != NULL)
    {
        sc->removeItem(m_histogramItems);
        delete m_histogramItems;
        m_histogramItems = NULL;
    }
    m_histogramItems = new QGraphicsItemGroup;

    // inizio i disegni
    addAxis( sz );

    //texts on axes
    //addText( m_minY, QPointF( 0, PosY(m_minY,sz) ) );
    //addText( m_maxY, QPointF( 0, PosY(m_maxY,sz) ) );

    addGridLine( 0, H, sz );

    int nlines = 5;
    for (int i=0; i<nlines; i++)
        addGridLine(  AutoRound( m_minY + (m_maxY-m_minY)*i/nlines  ), H, sz );

    //vertical line histogram from zero
    const float y2 = PosY (0, sz);
    for (auto ih: m_histo)
    {
        const float x1 = PosX (ih.first);
        const float y1 = PosY (ih.second, sz);
        if (y1 != 0)
        {
            QGraphicsLineItem *pt = new QGraphicsLineItem( QLineF(x1, y2, x1, y1) );
            pt->setPen(m_measurePen);
            m_histogramItems->addToGroup(pt);
        }
    }

    sc->addItem(m_histogramItems);

    //update scene rectangle.
    QRectF rectSc = m_histogramItems->boundingRect();
    scene()->setSceneRect(rectSc);

    setRenderHint(QPainter::HighQualityAntialiasing, true);

    //assert(scene()->sceneRect() == sceneRect());
}
Beispiel #4
0
void HistogramView::addGridLine(  const double value, tAxis ax,  const QSize &sz )
{
    QPainterPath p;
    if (ax == H)
    {
        p.moveTo( m_Border/2,  PosY(value,sz) );
        p.lineTo( sz.width() - m_Border, PosY(value,sz)  );
        addText( value, QPointF( sz.width() - 3 * m_Border, PosY(value,sz) - 20 ));
    }
    else
    {
        p.moveTo( PosX(value), m_Border );
        p.lineTo( PosX(value), sz.height() - m_Border  );
        addText( value, QPointF( PosX(value), sz.height() - m_Border - 20 ) );
    }

    QGraphicsPathItem *pathItem = new QGraphicsPathItem(p);
    pathItem->setPen(m_gridPen);
    m_histogramItems->addToGroup(pathItem);
}
Beispiel #5
0
void
ZHD_Node::EraseNode( )
{
   CRect    rect;
   CBrush   *pBrush;
   CPen     *pPen;
   zBOOL    bRelease;

   // Erase the rectangle containing the entity
   rect.left   = (PosX( ) - PosX( tzHDDISPLAYPOS )) * tzHDCELLSIZE;
   rect.top    = (PosY( ) - PosY( tzHDDISPLAYPOS )) * tzHDCELLSIZE;
   rect.right  = rect.left + (tzHDNODEX * tzHDCELLSIZE) - 1;
   rect.bottom = rect.top  + (tzHDNODEY * tzHDCELLSIZE) - 1;

   if ( m_pHD_Diagram->m_hDC == 0 )
   {
      m_pHD_Diagram->GetDeviceContext( );
      bRelease = TRUE;
   }
   else
      bRelease = FALSE;

   // Unpaint the nodes line
   DrawNodeLine( 1 );

   // Now un-paint the rectangle where the entity was
   pBrush = new CBrush( tzHDCOLORBACKGROUND );
   pPen   = new CPen( PS_SOLID, 1, tzHDCOLORBACKGROUND );
   CPen *pPenOld = m_pHD_Diagram->m_hDC->SelectObject( pPen );
   CBrush *pBrushOld = m_pHD_Diagram->m_hDC->SelectObject( pBrush );

   m_pHD_Diagram->m_hDC->Rectangle( rect );

   m_pHD_Diagram->m_hDC->SelectObject( pPenOld );
   m_pHD_Diagram->m_hDC->SelectObject( pBrushOld );
   mDeleteInit( pBrush );
   mDeleteInit( pPen );

   if ( bRelease )
      m_pHD_Diagram->ReleaseDeviceContext( );
}
void model_parameters::initialization(void)
{
	NAreaAge.initialize();
 	CatchAreaAge.initialize();
 	CatchNatAge.initialize();
	Nage(1,1) = So*Bo/(1+beta*Bo);
	for(int i=sage+1 ; i <= nage ; i++)
	{
		Nage(1,i) = Nage(1,i-1) * mfexp(-za(i-1));
	}
	VulB(1) = elem_prod(elem_prod(Nage(1),va),wa);
	SB(1) = elem_prod(Nage(1),fa)*wa/2;
	tBo = Nage(1)*wa;
	calcmaxpos(tBo);
	varPos = maxPos*cvPos;
	PosX(1) = minPos + (maxPos - minPos) * (0.5+0.5*sin(indmonth(1)*PI/6 - mo*PI/6)); 
	VBarea(1,sarea) = VulB(1)* (cnorm(areas(sarea)+0.5,PosX(1),varPos));
	for(int r=sarea+1 ; r <= narea-1 ; r++)
	{
		VBarea(1,r) = VulB(1)* (cnorm(areas(r)+0.5,PosX(1),varPos)-cnorm(areas(r)-0.5,PosX(1),varPos));
		NAreaAge(1)(r) = elem_prod(Nage(1)(sage,nage),(cnorm(areas(r)+0.5,PosX(1),varPos)-cnorm(areas(r)-0.5,PosX(1),varPos)));
	}
	//VBarea(1,narea) = VulB(1)* (1.0-cnorm(areas(narea)-0.5,PosX(1),varPos));
	NationVulB(1,1) = sum(VBarea(1)(sarea,sarea+nationareas(1)-1)); 
	NationVulB(1,2) = sum(VBarea(1)(sarea+nationareas(1),narea)); 
	dvar_vector tmp1(sarea,narea);
	dvar_vector tmp2(sarea,narea);
	dvar_vector tmp3(sarea,narea);
	for(int rr= sarea; rr<=narea; rr++)
	{
		tmp1(rr)= VBarea(1)(rr)/ (NationVulB(1)(indnatarea(rr)) + 0.0001);
		tmp2(rr) = tmp1(rr)*TotEffyear(indnatarea(rr))(indyr(1));
		Effarea(1)(rr) = tmp2(rr)*TotEffmonth(indnatarea(rr))(indmonth(1));
	}
	for(int a= sage; a<= nage;a++)
	{
		dvar_vector propVBarea(sarea,narea);
		for(int rr =sarea; rr<=narea; rr++)
		{
			propVBarea(rr) = (cnorm(areas(rr)+0.5,PosX(1),varPos)-cnorm(areas(rr)-0.5,PosX(1),varPos))(a-sage+1);
			CatchAreaAge(1)(rr)(a) = q*Effarea(1)(rr)*va(a)/(q*Effarea(1)(rr)*va(a)+m)*(1-mfexp(-(q*Effarea(1)(rr)*va(a)+m)))*NAreaAge(1)(rr)(a);
			CatchNatAge(1)(indnatarea(rr))(a) += CatchAreaAge(1)(rr)(a);
			EffNatAge(indnatarea(rr))(1)(sage-2) = 1;
			EffNatAge(indnatarea(rr))(1)(sage-1) = indnatarea(rr);
			EffNatAge(indnatarea(rr))(1)(a) += Effarea(1)(rr)*propVBarea(rr);
		}
		//cout<<"propVBarea "<<propVBarea<<endl;
		//cout<<"Effarea(1) "<<Effarea(1)<<endl;
		Effage(1)(a) = Effarea(1)* propVBarea;
	}
}
bool Player::FireEnergyCannon(ItemInstance *item)
{
    float pos[3];
    float *_heading = Heading();
    float range = (float)item->WeaponRange;
    
    if (GetEnergyValue() < item->EnergyUse)
    {
        SendVaMessage("Not enough energy! Need: %f", item->EnergyUse);
        return false;
    }
   
    /* Use the energy */
    RemoveEnergy(item->EnergyUse);
       
    pos[0] = PosX() + ( range * _heading[0] );
    pos[1] = PosY() + ( range * _heading[1] );
    pos[2] = PosZ() + ( range * _heading[2] );
   
    RangeListVec::iterator itrRList;
    Player *p = (0);
    
	while (g_PlayerMgr->GetNextPlayerOnList(p, m_RangeList))
	{        
        p->PointEffect(pos, 1017, 3.0f);
        //see if this player is in range of explosion.
        float range_to_blast = p->RangeFrom(pos, true);
        if (p != this)
        {
            SendVaMessage("Range to blast: %.2f", range_to_blast);
        }
        if (range_to_blast < 1000.0f)
        {
            float damage = p->CaughtInEnergyBlast(GameID(), range_to_blast);
            if (damage > 0)
            {
                SendVaMessage("Blast Damage: %.2f", damage);
                SendClientDamage(p->GameID(), GameID(), damage, 0, 0);
            }
        }
    }

    return true;
}
Beispiel #8
0
void
ZHD_Node::CenterNode( )
{
   CRect  rect;
   zLONG  lDisplaySizeX, lDisplaySizeY;
   zLONG  lNodeMiddleX, lNodeMiddleY;
   zLONG  lDisplayPosX, lDisplayPosY;

   m_pHD_Diagram->GetClientRect( rect );

   // Get the logical rect size with scaling
   m_pHD_Diagram->CalculateDisplaySize( lDisplaySizeX, lDisplaySizeY, rect, m_pHD_Diagram->m_lScale );

   lDisplaySizeX /= 2;
   lDisplaySizeY /= 2;

   lNodeMiddleX = PosX( ) + (tzHDNODEX / 2);
   lNodeMiddleY = PosY( ) + (tzHDNODEY / 2);

   lDisplayPosX = lNodeMiddleX - lDisplaySizeX;
   lDisplayPosY = lNodeMiddleY - lDisplaySizeY;

   if ( lDisplayPosX < 0 )
      lDisplayPosX = 0;

   if ( lDisplayPosY < 0 )
      lDisplayPosY = 0;

   m_pHD_Diagram->m_lDisplayPos = lDisplayPosY;
   m_pHD_Diagram->m_lDisplayPos *= tzHDDIAGRAMX;
   m_pHD_Diagram->m_lDisplayPos += lDisplayPosX;

   // Here we zoom the diagram to the current scale to ensure the display position is altered if necessary
   // so the right and bottom edge aren't beyond the diagram space
   m_pHD_Diagram->ZoomDiagram( (zSHORT) m_pHD_Diagram->m_lScale + 100, 1 );
}
void model_parameters::move_grow_die(void)
{
	dvariable tB;
	for(int i=2;i<=ntstp;i++)
	{
		//if(i>12)exit(1);
		switch (indmonth(i)) {
            case 1:           	
            	Nage(i)(sage) = (So*SB(i-nmon)/(1.+beta*SB(i-nmon)))*mfexp(wt(indyr(i))*err);
            	for(int a = sage+1;a<=nage;a++)
            	{
            		Nage(i)(a) = Nage(i-1)(a-1)*mfexp(-(m+q*Effage(i-1)(a-1)*va(a-1))/12);
            	}
            	break;
            default: 
            	Nage(i) = elem_prod(Nage(i-1),mfexp(-(m+q*elem_prod(Effage(i-1),va))/12));
            	break;
        }
		VulB(i) = elem_prod(elem_prod(Nage(i),va),wa);
		SB(i) = elem_prod(Nage(i),fa)*wa/2;
		maxPos.initialize();
		tB = Nage(i)*wa;
		calcmaxpos(tB);
		//cout<<"maxPos "<<maxPos<<endl;
		varPos = maxPos*cvPos;
		PosX(i) = minPos + (maxPos - minPos) * (0.5+0.5*sin(indmonth(i)*PI/6 - mo*PI/6)); 
		VBarea(i,sarea) = VulB(i)* (cnorm(areas(sarea)+0.5,PosX(i),varPos));
		for(int r = sarea+1;r <= narea;r++)
		{
			VBarea(i)(r) = VulB(i)* (cnorm(areas(r)+0.5,PosX(i),varPos)-cnorm(areas(r)-0.5,PosX(i),varPos));
			NAreaAge(i)(r) = elem_prod(Nage(i)(sage,nage),(cnorm(areas(r)+0.5,PosX(i),varPos)-cnorm(areas(r)-0.5,PosX(i),varPos)));
		}	
		//VBarea(i,narea) = VulB(i)* (1.0-cnorm(areas(narea)-0.5,PosX(i),varPos));
		NationVulB(i,1) = sum(VBarea(i)(sarea,sarea+nationareas(1)-1)); 
		NationVulB(i,2) = sum(VBarea(i)(sarea+nationareas(1),narea)); 
		dvar_vector tmp1(sarea,narea);
		dvar_vector tmp2(sarea,narea);
		for(int rr= sarea; rr<=narea; rr++)
		{
			tmp1(rr)= VBarea(i)(rr)/ (NationVulB(i)(indnatarea(rr)) + 1);
			tmp2(rr) = tmp1(rr)*TotEffyear(indnatarea(rr))(indyr(i));
			Effarea(i)(rr) = tmp2(rr)*TotEffmonth(indnatarea(rr))(indmonth(i));
		}
		for(int a = sage; a<=nage;a++)
		{
			dvar_vector propVBarea(sarea,narea);
			for(int rr =sarea; rr<=narea; rr++)
			{
				propVBarea(rr) = (cnorm(areas(rr)+0.5,PosX(i),varPos)-cnorm(areas(rr)-0.5,PosX(i),varPos))(a-sage+1);
				EffNatAge(indnatarea(rr))(i)(sage-2) = i;
				EffNatAge(indnatarea(rr))(i)(sage-1) = indnatarea(rr);
				EffNatAge(indnatarea(rr))(i)(a) += Effarea(i)(rr)* propVBarea(rr);
			}
			//cout<<"propVBarea "<<propVBarea<<endl;
			//cout<<"Effarea(1) "<<Effarea(1)<<endl;
			Effage(i)(a) = Effarea(i)*propVBarea;
		}
		for(int r = sarea+1;r <= narea-1;r++)
		{
			for(int a = sage; a<=nage;a++)
			{
				CatchAreaAge(i)(r)(a) = q*Effarea(i)(r)*va(a)/(q*Effarea(i)(r)*va(a)+m)*(1-mfexp(-(q*Effarea(i)(r)*va(a)+m)))*NAreaAge(i)(r)(a);
				CatchNatAge(i)(indnatarea(r))(a)+= CatchAreaAge(i)(r)(a);
			}
		}
	}
}
Beispiel #10
0
zSHORT
ZHD_Node::DrawNodeLine( zBOOL bErase )
{
   CPen   *pPen;
   CRect  rect;
   zBOOL  bRelease;
   CPoint point1;

   // Now that the node has been drawn, draw the line to the parent node if the node exists
   if ( m_pParentNode )
   {
      if ( m_pHD_Diagram->m_hDC == 0 )
      {
         m_pHD_Diagram->GetDeviceContext( );
         bRelease = TRUE;
      }
      else
         bRelease = FALSE;

      if ( m_pHD_Diagram->m_bPrintDC )
         pPen = new CPen( PS_SOLID, 1, tzHDCOLORBLACK );
      else
      if ( bErase )
         pPen = new CPen( PS_SOLID, 1, tzHDCOLORBACKGROUND );
      else
         pPen = new CPen( PS_SOLID, 1, tzHDCOLORLINES );

      rect.left   = (PosX( ) - PosX( tzHDDISPLAYPOS )) * tzHDCELLSIZE;
      rect.top    = (PosY( ) - PosY( tzHDDISPLAYPOS )) * tzHDCELLSIZE;
      rect.right  = rect.left + (tzHDNODEX * tzHDCELLSIZE) - 1;
      rect.bottom = rect.top  + (tzHDNODEY * tzHDCELLSIZE) - 1;
      if ( m_pHD_Diagram->m_bOrientation == 0 )
      {
         if ( m_bHidden )
            point1.x = rect.left + (tzHDCELLSIZE / 2);
         else
            point1.x = (rect.left + rect.right) / 2;

         point1.y = rect.top;
      }
      else
      {
         point1.x = rect.left;
         if ( m_bHidden )
            point1.y = rect.top + (tzHDCELLSIZE / 2);
         else
            point1.y = (rect.top + rect.bottom) / 2;
      }

      m_pHD_Diagram->m_hDC->MoveTo( point1.x, point1.y );
      rect.left = (m_pParentNode->PosX( ) - m_pParentNode->PosX( tzHDDISPLAYPOS )) * tzHDCELLSIZE;
      rect.top  = (m_pParentNode->PosY( ) - m_pParentNode->PosY( tzHDDISPLAYPOS )) * tzHDCELLSIZE;
      rect.right  = rect.left + (tzHDNODEX * tzHDCELLSIZE) - 1;
      rect.bottom = rect.top  + (tzHDNODEY * tzHDCELLSIZE) - 1;
      if ( m_pHD_Diagram->m_bOrientation == 0 )
      {
         point1.x = ( rect.left + rect.right ) / 2;
         point1.y = rect.bottom;
      }
      else
      {
         point1.x = rect.right;
         point1.y = ( rect.bottom + rect.top ) / 2;
      }

      m_pHD_Diagram->m_hDC->LineTo( point1.x, point1.y );
      mDeleteInit( pPen );
      if ( bRelease )
         m_pHD_Diagram->ReleaseDeviceContext( );
   }

   // return that entity was drawn
   return( 1 );
}
Beispiel #11
0
zSHORT
ZHD_Node::DrawNode( )
{
   CBrush   *pBrush = 0;    // but because we are a little neurotic
   CFont    *pFont = 0;     // we will do it regardless
   CPen     *pPen = 0;      // not sure we have to zero these out ...
   CRect    rect;
   CSize    Size;
   zBOOL    bRelease;
   zCHAR    szText[ 256 ];
   COLORREF colorOldText;
   zBOOL    bSpecialSelect = FALSE;

   // Now paint a rounded rectangle to represent the entity
   if ( !m_pHD_Diagram->PositionVisible( m_lPosIdx, m_lPosIdx + (tzHDNODEX - 1) + ((tzHDNODEY - 1) * tzHDDIAGRAMX) ) )
   {
      return( 0 );
   }

   if ( m_pHD_Diagram->m_hDC == 0 )
   {
      m_pHD_Diagram->GetDeviceContext( );
      bRelease = TRUE;
   }
   else
      bRelease = FALSE;

   if ( m_pHD_Diagram->m_bPrintDC )
   {
      if ( m_bSelected && m_pHD_Diagram->m_bShadeEnts )
         pBrush = new CBrush( COLORREF( tzHDCOLORSHADE ) );
      else
         pBrush = new CBrush( tzHDCOLORWHITE );

      pPen = new CPen( PS_SOLID, 1, tzHDCOLORBLACK );
      colorOldText = m_pHD_Diagram->m_hDC->SetTextColor( tzHDCOLORBLACK );
   }
   else
   {
      pPen = new CPen( PS_SOLID, 1, tzHDCOLORBOX );
      colorOldText = m_pHD_Diagram->m_hDC->SetTextColor( tzHDCOLORTEXT );
      if ( m_lColor >= 0 && m_lColor < 16 )
      {
         if ( m_bSelected )
            pBrush = new CBrush( tzHDCOLORSELECTED );
         else
            pBrush = new CBrush( tzHDCOLORNORMAL[ m_lColor ] );
      }
      else
      {
         pBrush = new CBrush( m_lColor );
         if ( m_bSelected )
            bSpecialSelect = TRUE;
      }
   }

   CPen   *pPenOld = m_pHD_Diagram->m_hDC->SelectObject( pPen );
   CBrush *pBrushOld = m_pHD_Diagram->m_hDC->SelectObject( pBrush );
   CFont  *pFontOld = 0;

   pFont = new CFont( );
   if ( pFont->CreateFont( (tzHDFONTHEIGHT * 5) / 4, 0, 0, 0, 0, 0, 0, 0, ANSI_CHARSET,
                           OUT_TT_ONLY_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, tzHDFONTFF, tzHDFONTNAME ) )
   {
      pFontOld = m_pHD_Diagram->m_hDC->SelectObject( pFont );
   }

   rect.left = (PosX( ) - PosX( tzHDDISPLAYPOS )) * tzHDCELLSIZE;
   rect.top  = (PosY( ) - PosY( tzHDDISPLAYPOS )) * tzHDCELLSIZE;
   if ( m_bHidden )
   {
      rect.right  = rect.left + tzHDCELLSIZE;
      rect.bottom = rect.top  + tzHDCELLSIZE;
      m_pHD_Diagram->m_hDC->Ellipse( rect.left, rect.top, rect.right, rect.bottom );
      if ( bSpecialSelect )
         m_pHD_Diagram->m_hDC->Ellipse( rect.left + 2, rect.top + 2, rect.right + 2, rect.bottom - 2 );

   }
   else
   {
      rect.right  = rect.left + ((tzHDNODEX * tzHDCELLSIZE) - 1);
      rect.bottom = rect.top  + ((tzHDNODEY * tzHDCELLSIZE) - 1);
      m_pHD_Diagram->m_hDC->RoundRect( rect.left, rect.top, rect.right, rect.bottom, tzHDARCSIZE, tzHDARCSIZE );
      if ( bSpecialSelect )
         m_pHD_Diagram->m_hDC->RoundRect( rect.left + 2, rect.top + 2, rect.right - 2, rect.bottom - 2, tzHDARCSIZE, tzHDARCSIZE );
      // Now that the rectangle is drawn, see if we need to draw the attributive or associative lines in the entity
      if ( m_chType == 'A' )
      {
         if ( m_pHD_Diagram->m_bPrintDC == FALSE )
         {
            CPen *pPen2 = pPen;
            pPen = new CPen( PS_SOLID, 1, tzHDCOLORGRAY );
            m_pHD_Diagram->m_hDC->SelectObject( pPen );
            mDeleteInit( pPen2 );
         }

         CPoint pt1;
         CPoint pt2;

         pt1.x = ((rect.left + rect.right) / 2);
         pt1.y = rect.top;
         m_pHD_Diagram->m_hDC->MoveTo( pt1.x, pt1.y );
         pt2.x = rect.left;
         pt2.y = rect.bottom - tzHDCELLSIZE;
         m_pHD_Diagram->m_hDC->LineTo( pt2.x, pt2.y );
         m_pHD_Diagram->m_hDC->MoveTo( pt1.x, pt1.y );
         pt2.x = rect.right;
         m_pHD_Diagram->m_hDC->LineTo( pt2.x, pt2.y );
      }
      else
      if ( m_chType == 'S' )
      {
         if ( m_pHD_Diagram->m_bPrintDC == FALSE )
         {
            CPen *pPen2 = pPen;
            pPen = new CPen( PS_SOLID, 1, tzHDCOLORGRAY );
            m_pHD_Diagram->m_hDC->SelectObject( pPen );
            mDeleteInit( pPen2 );
         }

         CPoint pt1;
         CPoint pt2;

         pt1.x = ((rect.left + rect.right) / 2);
         pt1.y = rect.top;
         m_pHD_Diagram->m_hDC->MoveTo( pt1.x, pt1.y );
         pt2.x = rect.left;
         pt2.y = (rect.top + rect.bottom) / 2;
         m_pHD_Diagram->m_hDC->LineTo( pt2.x, pt2.y );
         pt2.x = pt1.x;
         pt2.y = rect.bottom;
         m_pHD_Diagram->m_hDC->LineTo( pt2.x, pt2.y );
         pt2.x = rect.right;
         pt2.y = (rect.top + rect.bottom) / 2;
         m_pHD_Diagram->m_hDC->LineTo( pt2.x, pt2.y );
         m_pHD_Diagram->m_hDC->LineTo( pt1.x, pt1.y );
      }

      int nOldBkMode = m_pHD_Diagram->m_hDC->SetBkMode( TRANSPARENT );
      Size = m_pHD_Diagram->m_hDC->GetTextExtent( m_csText );
      rect.left   += 4;
      rect.right  -= 4;
      if ( Size.cx > (rect.right - rect.left) )
      {
         rect.top    += ((tzHDCELLSIZE * 3) / 4);
         rect.bottom -= ((tzHDCELLSIZE * 3) / 4);
//       rect.top    += tzHDCELLSIZE;
//       rect.bottom -= tzHDCELLSIZE;

         zSHORT nIdx = 0;
         zSHORT nLth = m_csText.GetLength( ) - 1;
         while ( nIdx < nLth && m_csText.GetAt( nIdx ) != ' ' )
            nIdx++;

         Size = m_pHD_Diagram->m_hDC->GetTextExtent( m_csText, nIdx );
         if ( Size.cx > (rect.right - rect.left) )
         {
            while ( nIdx && Size.cx > (rect.right - rect.left) )
            {
               nIdx--;
               Size = m_pHD_Diagram->m_hDC->GetTextExtent( m_csText, nIdx );
            }

            nIdx--;
            if ( nIdx > 0 )
            {
               HyphenateHD_Text( m_csText, szText, zsizeof( szText ), nIdx );
            }

            m_pHD_Diagram->m_hDC->DrawText( szText, -1, rect, DT_LEFT | DT_WORDBREAK );
   //                                                         DT_SINGLELINE | DT_LEFT | DT_VCENTER );
         }
         else
         {
   //       rect.top += ((tzHDCELLSIZE * 3) / 4);
            m_pHD_Diagram->m_hDC->DrawText( m_csText, -1, rect, DT_CENTER | DT_WORDBREAK );
         }
      }
      else
      {
         rect.left   -= 4;
         rect.right  += 4;
         m_pHD_Diagram->m_hDC->DrawText( m_csText, -1, rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER );
      }

      if ( m_pHD_Diagram->m_bCollapsable ||
           m_csTitle.IsEmpty( ) == FALSE  ||
           m_csDIL.IsEmpty( ) == FALSE    ||
           m_csOutsideText1.IsEmpty( ) == FALSE ||
           m_csOutsideText2.IsEmpty( ) == FALSE ||
           m_csOutsideText3.IsEmpty( ) == FALSE ||
           m_csOutsideText4.IsEmpty( ) == FALSE ||
           m_csOutsideText5.IsEmpty( ) == FALSE )
      {
         if ( pFontOld )
         {
            m_pHD_Diagram->m_hDC->SelectObject( pFontOld );
            pFontOld = 0;
         }

         mDeleteInit( pFont );
         pFont = new CFont( );
         if ( pFont->CreateFont( tzHDCELLSIZE - 1, 0, 0, 0, 0, 0, 0, 0, ANSI_CHARSET,
                                 OUT_TT_ONLY_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, tzHDFONTFF, tzHDFONTNAME ) )
         {
            pFontOld = m_pHD_Diagram->m_hDC->SelectObject( pFont );
         }

         if ( m_csTitle.IsEmpty( ) == FALSE )
         {
            rect.left   = (PosX( ) - PosX( tzHDDISPLAYPOS )) * tzHDCELLSIZE;
            rect.right  = rect.left + (tzHDNODEX * tzHDCELLSIZE) - 1;
            rect.top    = (PosY( ) - PosY( tzHDDISPLAYPOS )) * tzHDCELLSIZE;
            rect.bottom = rect.top  + tzHDCELLSIZE;
            m_pHD_Diagram->m_hDC->DrawText( m_csTitle, -1, rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER );
         }

         if ( m_csDIL.IsEmpty( ) == FALSE )
         {
            rect.left   = (PosX( ) - PosX( tzHDDISPLAYPOS )) * tzHDCELLSIZE;
            rect.right  = rect.left + (tzHDNODEX * tzHDCELLSIZE) - 1;
            rect.top    = (PosY( ) - PosY( tzHDDISPLAYPOS )) * tzHDCELLSIZE;
            rect.top    += ((tzHDNODEY - 1) * tzHDCELLSIZE);
            rect.bottom = rect.top + tzHDCELLSIZE;
            m_pHD_Diagram->m_hDC->DrawText( m_csDIL, -1, rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER );
         }

         if ( m_csOutsideText1.IsEmpty( ) == FALSE )
         {
            rect.left   = (PosX( ) - PosX( tzHDDISPLAYPOS )) * tzHDCELLSIZE;
            rect.left   = rect.left + (tzHDNODEX * tzHDCELLSIZE) + 1;
            rect.right  = rect.left + (tzHDNODEX * ((tzHDCELLSIZE + 1) / 2));
            rect.top    = (PosY( ) - PosY( tzHDDISPLAYPOS )) * tzHDCELLSIZE;
            rect.bottom = rect.top  + tzHDCELLSIZE;
            m_pHD_Diagram->m_hDC->DrawText( m_csOutsideText1, -1, rect,  DT_SINGLELINE | DT_VCENTER );
         }

         if ( m_csOutsideText2.IsEmpty( ) == FALSE )
         {
            rect.left   = (PosX( ) - PosX( tzHDDISPLAYPOS )) * tzHDCELLSIZE;
            rect.left   = rect.left + (tzHDNODEX * tzHDCELLSIZE) + 1;
            rect.right  = rect.left + (tzHDNODEX * ((tzHDCELLSIZE + 1) / 2));
            rect.top    = (PosY( ) - PosY( tzHDDISPLAYPOS )) * tzHDCELLSIZE;
            rect.top    += tzHDCELLSIZE;
            rect.bottom = rect.top  + tzHDCELLSIZE;
            m_pHD_Diagram->m_hDC->DrawText( m_csOutsideText2, -1, rect, DT_SINGLELINE | DT_VCENTER );
         }

         if ( m_csOutsideText3.IsEmpty( ) == FALSE )
         {
            rect.left   = (PosX( ) - PosX( tzHDDISPLAYPOS )) * tzHDCELLSIZE;
            rect.left   = rect.left + (tzHDNODEX * tzHDCELLSIZE) + 1;
            rect.right  = rect.left + (tzHDNODEX * ((tzHDCELLSIZE + 1) / 2));
            rect.top    = (PosY( ) - PosY( tzHDDISPLAYPOS )) * tzHDCELLSIZE;
            rect.top    += (2 * tzHDCELLSIZE);
            rect.bottom = rect.top  + tzHDCELLSIZE;
            m_pHD_Diagram->m_hDC->DrawText( m_csOutsideText3, -1, rect,  DT_SINGLELINE | DT_VCENTER );
         }

         if ( m_csOutsideText4.IsEmpty( ) == FALSE )
         {
            rect.left   = (PosX( ) - PosX( tzHDDISPLAYPOS )) * tzHDCELLSIZE;
            rect.left   = rect.left + (tzHDNODEX * tzHDCELLSIZE) + 1;
            rect.right  = rect.left + (tzHDNODEX * ((tzHDCELLSIZE + 1) / 2));
            rect.top    = (PosY( ) - PosY( tzHDDISPLAYPOS )) * tzHDCELLSIZE;
            rect.top    += (3 * tzHDCELLSIZE);
            rect.bottom = rect.top  + tzHDCELLSIZE;
            m_pHD_Diagram->m_hDC->DrawText( m_csOutsideText4, -1, rect, DT_SINGLELINE | DT_VCENTER );
         }

         if ( m_csOutsideText5.IsEmpty( ) == FALSE )
         {
            rect.left   = (PosX( ) - PosX( tzHDDISPLAYPOS )) * tzHDCELLSIZE;
            rect.left   = rect.left + (tzHDNODEX * tzHDCELLSIZE) + 1;
            rect.right  = rect.left + (tzHDNODEX * ((tzHDCELLSIZE + 1) / 2));
            rect.top    = (PosY( ) - PosY( tzHDDISPLAYPOS )) * tzHDCELLSIZE;
            rect.top    += (4 * tzHDCELLSIZE);
            rect.bottom = rect.top  + tzHDCELLSIZE;
            m_pHD_Diagram->m_hDC->DrawText( m_csOutsideText5, -1, rect, DT_SINGLELINE | DT_VCENTER );
         }
      }

      if ( m_pHD_Diagram->m_bCollapsable )
      {
         rect.left   = (PosX( ) - PosX( tzHDDISPLAYPOS )) * tzHDCELLSIZE;
         rect.top    = (PosY( ) - PosY( tzHDDISPLAYPOS )) * tzHDCELLSIZE;
         rect.right  = rect.left + tzHDCELLSIZE;
         rect.bottom = rect.top  + tzHDCELLSIZE;
         if ( m_bCollapsed )
         {
            if ( m_pHD_Diagram->m_bPrintDC == FALSE )
            {
               mDeleteInit( pBrush );
               if ( m_lColor >= 0 && m_lColor < 16 )
               {
                  if ( m_bSelected )
                     pBrush = new CBrush( tzHDCOLORNORMAL[ m_lColor ] );
                  else
                     pBrush = new CBrush( tzHDCOLORSELECTED );
               }
               else
               {
                  pBrush = new CBrush( m_lColor );
                  if ( m_bSelected )
                     bSpecialSelect = TRUE;
               }

               m_pHD_Diagram->m_hDC->SelectObject( pBrush );
               m_pHD_Diagram->m_hDC->SetBkMode( OPAQUE );
               m_pHD_Diagram->m_hDC->Ellipse( rect.left, rect.top, rect.right, rect.bottom );
               m_pHD_Diagram->m_hDC->SetBkMode( TRANSPARENT );
            }

            m_pHD_Diagram->m_hDC->DrawText( "+", -1, rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER );
         }
//       else
//       {
//          m_pHD_Diagram->m_hDC->DrawText( "-", -1, rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER );
//       }
      }

      m_pHD_Diagram->m_hDC->SetBkMode( nOldBkMode );
   }

   m_pHD_Diagram->m_hDC->SetTextColor( colorOldText );
   m_pHD_Diagram->m_hDC->SelectObject( pPenOld );
   if ( pFontOld )
      m_pHD_Diagram->m_hDC->SelectObject( pFontOld );

   m_pHD_Diagram->m_hDC->SelectObject( pBrushOld );
   mDeleteInit( pPen );
   mDeleteInit( pFont );
   mDeleteInit( pBrush );

   // Now that the node has been drawn, draw the line to the parent node if the node exists
   DrawNodeLine( );

   if ( bRelease )
      m_pHD_Diagram->ReleaseDeviceContext( );

   // return that entity was drawn
   return( 1 );
}