[very urgent] How to draw many squares?

TeeChart for ActiveX, COM and ASP
Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: [very urgent] How to draw many squares?

Post by Narcís » Thu Feb 11, 2010 4:07 pm

Hi David,

In that case the only solution I can think of is implementing MakeIsoAxis as shown here. There are some hints on how to write this code in VC++ here.

Hope this helps!
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

David
Advanced
Posts: 203
Joined: Tue Nov 08, 2005 5:00 am

Re: [very urgent] How to draw many squares?

Post by David » Fri Feb 12, 2010 12:06 pm

I didn't notice your reply is on page 2 and I have been waisting so much time waiting... :?

I think the solution you provided should work and I will give it a try. Thank you so much for your kind help and quick response.

David
Advanced
Posts: 203
Joined: Tue Nov 08, 2005 5:00 am

Re: [very urgent] How to draw many squares?

Post by David » Sat Feb 13, 2010 6:46 am

I have translated what was done in the post suggested into the code shown below, but unfortunately, the effect is still not there. I don't know if it is because I didn't translate correctly or it is because the algorithm itself. :(

Code: Select all

	double w = m_chart1.GetWidth();
	double h = m_chart1.GetHeight();

	if(h>0 && w>0)
	{
		double xmin = m_chart1.GetAxis().GetBottom().GetMinimum();
		double xmax = m_chart1.GetAxis().GetBottom().GetMaximum();
		double ymin = m_chart1.GetAxis().GetLeft().GetMinimum();
		double ymax = m_chart1.GetAxis().GetLeft().GetMaximum();

		double cx = GetSystemMetrics(SM_CXSCREEN); 
		double cy = GetSystemMetrics(SM_CYSCREEN); 

		CDC dc;
		long hDC=m_chart1.GetCanvas().GetHandleDC().lVal;
		dc.Attach(HDC(hDC));

		double xyscreen = (GetDeviceCaps(dc,HORZSIZE)/cx)/(GetDeviceCaps(dc,VERTSIZE)/cy);

		double tmpx = (xmax-xmin)/w;
		double tmpy = xyscreen*(ymax-ymin)/h;
		if(tmpx>tmpy)
		{
			if(tmpy != 0.0)
			{
				double offset = ((ymax-ymin)*tmpx/tmpy - (ymax-ymin))/2.0;
				m_chart1.GetAxis().GetLeft().SetMinMax(ymin+offset,ymax -offset);
			}
		}
		else
		{
			if (tmpx != 0.0)
			{
				double offset = ((xmax-xmin)*tmpy/tmpx - (xmax-xmin))/2.0;
				m_chart1.GetAxis().GetBottom().SetMinMax(xmin+offset,xmax -offset);
			}
		}

		dc.Detach();
	}

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: [very urgent] How to draw many squares?

Post by Narcís » Mon Feb 15, 2010 11:09 am

Hi David,

I see an error in your implementation. It's in the offset addition/substraction in SetMinMax. This part:

Code: Select all

          if(tmpx>tmpy)
          {
             if(tmpy != 0.0)
             {
                double offset = ((ymax-ymin)*tmpx/tmpy - (ymax-ymin))/2.0;
                m_chart1.GetAxis().GetLeft().SetMinMax(ymin+offset,ymax -offset);
             }
          }
          else
          {
             if (tmpx != 0.0)
             {
                double offset = ((xmax-xmin)*tmpy/tmpx - (xmax-xmin))/2.0;
                m_chart1.GetAxis().GetBottom().SetMinMax(xmin+offset,xmax -offset);
             }
          }
Should be:

Code: Select all

          if(tmpx>tmpy)
          {
             if(tmpy != 0.0)
             {
                double offset = ((ymax-ymin)*tmpx/tmpy - (ymax-ymin))/2.0;
                m_chart1.GetAxis().GetLeft().SetMinMax(ymin-offset,ymax+offset);
             }
          }
          else
          {
             if (tmpx != 0.0)
             {
                double offset = ((xmax-xmin)*tmpy/tmpx - (xmax-xmin))/2.0;
                m_chart1.GetAxis().GetBottom().SetMinMax(xmin-offset,xmax+offset);
             }
          }
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

David
Advanced
Posts: 203
Joined: Tue Nov 08, 2005 5:00 am

Re: [very urgent] How to draw many squares?

Post by David » Tue Feb 16, 2010 1:27 pm

I can't believe I made such an error... :oops: Now it works well! Thank you so much for your patience and effort!

David
Advanced
Posts: 203
Joined: Tue Nov 08, 2005 5:00 am

Re: [very urgent] How to draw many squares?

Post by David » Fri Feb 19, 2010 5:54 am

One more question. The application is MFC dialog based and I initialized the chart in OnInitDialog, but where should I call the SetIsometricAxis so that the display is correct at the beginning, not after you zoom it?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: [very urgent] How to draw many squares?

Post by Narcís » Fri Feb 19, 2010 8:35 am

Hi David,

In the same event you can call InternalRepaint before calling SetIsometricAxis so that chart is internally painted and therefore all objects initialized, for example:

Code: Select all

	m_Chart1.GetEnvironment().InternalRepaint();
	SetIsometricAxis();
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

David
Advanced
Posts: 203
Joined: Tue Nov 08, 2005 5:00 am

Re: [very urgent] How to draw many squares?

Post by David » Fri Feb 19, 2010 8:57 am

Yes, it works! Thanks a lot. BTW, are all these methods documented? I just hope I could find it somewhere in the help files instead of always asking questions in the forum.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: [very urgent] How to draw many squares?

Post by Narcís » Fri Feb 19, 2010 9:00 am

Hi David,

You are welcome! Yes, I think they are documented in the help files, tutorials, demos and mentioned in other forums threads.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply