home *** CD-ROM | disk | FTP | other *** search
/ Chip 1999 March / Chip_1999-03_cd.bin / zkuste / delphi / D / MATEM.ARJ / RCHART.ZIP / exmpl-2 / cpp1 / rchmov1.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-22  |  2.9 KB  |  114 lines

  1. //---------------------------------------------------------------------------
  2. #include <vcl\vcl.h>
  3. #pragma hdrstop
  4.  
  5. #include "rchmov1.h"
  6. #include "logwarn.h"
  7. #include "math.h"
  8. //---------------------------------------------------------------------------
  9. #pragma link "RChart"
  10. #pragma resource "*.dfm"
  11. TForm1 *Form1;
  12. bool RunMove;
  13. //---------------------------------------------------------------------------
  14. __fastcall TForm1::TForm1(TComponent* Owner)
  15.     : TForm(Owner)
  16. {
  17. }
  18. //---------------------------------------------------------------------------
  19. void __fastcall TForm1::ButDoneClick(TObject *Sender)
  20. {
  21. Close();    
  22. }
  23. //---------------------------------------------------------------------------
  24. void __fastcall TForm1::ButStartClick(TObject *Sender)
  25. {
  26. const int NPnts = 140;
  27.  
  28. int  i,j;
  29.  
  30. ButStop->Enabled = true;
  31. ButStart->Enabled = false;
  32. ButDone->Enabled = false;
  33. RChart1->RangeLoX = 0;
  34. RChart1->RangeHiX = NPnts;
  35. RChart1->RangeLoY = 10;
  36. RChart1->RangeHiY = 600;
  37. RChart1->DataColor = clBlack;
  38. RChart1->ClearGraf();
  39. for (i=1; i<=NPnts; i++)
  40.   RChart1->MarkAt (i, NPnts+i*sin(i*0.1), 0);
  41. RChart1->ShowGraf();
  42. RunMove = true;
  43. RChart1->DataColor = clBlue;
  44. RChart1->MarkAt (0,0,12);
  45. RChart1->DataColor = clRed;
  46. RChart1->MarkAt (0,0,12);
  47. RChart1->ShowGraf();
  48. i = 0;
  49. j = 0;
  50. while (RunMove == true) 
  51.   {
  52.   j = j+2;
  53.   if (j > NPnts)
  54.     {
  55.     j = 1;
  56.     }
  57.   i++;
  58.   if (i > NPnts)
  59.     {
  60.     i = 1;
  61.     }
  62.   RChart1->RemoveLastItem();
  63.   RChart1->RemoveLastItem();
  64.   RChart1->DataColor = clRed;
  65.   RChart1->MarkAt (i,NPnts+i*sin(i*0.1), 18);
  66.   RChart1->DataColor = clBlue;
  67.   RChart1->MarkAt (j,NPnts+j*sin(j*0.1), 18);
  68.   RChart1->ShowGraf();
  69.   Application->ProcessMessages();
  70.   }
  71. }
  72. //---------------------------------------------------------------------------
  73. void __fastcall TForm1::ButStopClick(TObject *Sender)
  74. {
  75. ButStop->Enabled = false;
  76. ButStart->Enabled = true;
  77. ButDone->Enabled = true;
  78. RunMove = False;
  79. }
  80. //---------------------------------------------------------------------------
  81. void __fastcall TForm1::CBLogXClick(TObject *Sender)
  82. {
  83. if ((! CBLogX->Checked) && (RChart1->RangeLoX <= 0))
  84.   {
  85.   LogWarnForm->ShowModal();
  86.   CBLogX->Checked = false;
  87.   }
  88. else
  89.   {
  90.   RChart1->LogScaleX = CBLogX->Checked;
  91.   CBLogX->Checked = RChart1->LogScaleX;
  92.   }
  93. }
  94. //---------------------------------------------------------------------------
  95. void __fastcall TForm1::CBLogYClick(TObject *Sender)
  96. {
  97. if ((! CBLogY->Checked) && (RChart1->RangeLoY <= 0))
  98.   {
  99.   LogWarnForm->ShowModal();
  100.   CBLogY->Checked = false;
  101.   }
  102. else
  103.   {
  104.   RChart1->LogScaleY = CBLogY->Checked;
  105.   CBLogY->Checked = RChart1->LogScaleY;
  106.   }
  107. }
  108. //---------------------------------------------------------------------------
  109. void __fastcall TForm1::FormMouseMove(TObject *Sender, TShiftState Shift, int X,
  110.     int Y)
  111. {
  112. Screen->Cursor = crDefault;
  113. }
  114. //---------------------------------------------------------------------------