1 /*
2  * NPlot - A charting library for .NET
3  *
4  * PlotSurface2DDemo.cs
5  * Copyright (C) 2003-2006 Jamie McQuay.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without modification,
9  * are permitted provided that the following conditions are met:
10  *
11  * 1. Redistributions of source code must retain the above copyright notice, this
12  *    list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright notice,
14  *    this list of conditions and the following disclaimer in the documentation
15  *    and/or other materials provided with the distribution.
16  * 3. Neither the name of NPlot nor the names of its contributors may
17  *    be used to endorse or promote products derived from this software without
18  *    specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
21  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
22  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
23  * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
24  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
28  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
29  * OF THE POSSIBILITY OF SUCH DAMAGE.
30  */
31 #pragma once
32 
33 using namespace System;
34 using namespace System::ComponentModel;
35 using namespace System::Collections;
36 using namespace System::Windows::Forms;
37 using namespace System::Data;
38 using namespace System::Drawing;
39 using namespace NPlot;
40 
41 
42 namespace NPlotDemo {
43 
44 	/// <summary>
45 	/// Summary for PlotSurface2DDemo
46 	///
47 	/// WARNING: If you change the name of this class, you will need to change the
48 	///          'Resource File Name' property for the managed resource compiler tool
49 	///          associated with all .resx files this class depends on.  Otherwise,
50 	///          the designers will not be able to interact properly with localized
51 	///          resources associated with this form.
52 	/// </summary>
53 	public ref class CPlotSurface2DDemo : public System::Windows::Forms::Form
54 	{
55 	public:
56 		CPlotSurface2DDemo(void);
57 
58 		System::Void PlotCircular();
59 		System::Void PlotWavelet();
60 		System::Void PlotLogAxis();
61 		System::Void PlotLogLog();
62 		System::Void PlotSincFunction();
63 		System::Void PlotGaussian();
64 		System::Void PlotABC();
65 		System::Void PlotLabelAxis();
66 		System::Void PlotParticles();
67 		System::Void PlotQE();
68 		System::Void PlotDataSet();
69 		System::Void PlotImage();
70 		System::Void PlotMarkers();
71 		System::Void PlotCandle();
72 		System::Void PlotTest();
73 		System::Void PlotWave();
74 		System::Void PlotMultiHistogram();
75 		System::Void PlotCandleSimple();
76 		System::Void PlotMockup();
77 		System::Void PlotProfitLoss();
78 
79 	protected:
80 		/// <summary>
81 		/// Clean up any resources being used.
82 		/// </summary>
~CPlotSurface2DDemo()83 		~CPlotSurface2DDemo()
84 		{
85 			if (components)
86 			{
87 				delete components;
88 			}
89 		}
90 	private:
91 		NPlot::Windows::PlotSurface2D^  plotSurface;
92 
93 		array<float>^ CPlotSurface2DDemo::makeDaub( int len );
94 		System::Void TwissEllipse(float a, float b, float g, float e, array<float>^ x, array<float>^ y);
95 		System::Void Twiss(array<float>^ x, array<float>^ y, float& a, float& b, float& g, float& e);
96 
97 	protected:
98 
99 	// Note that a NPlot.Windows.PlotSurface2D class
100 	// is used here. This has exactly the same
101 	// functionality as the NPlot.PlotSurface2D
102 	// class, except that it is derived from Forms.UserControl
103 	// and automatically paints itself in a windows.forms
104 	// application. Windows.PlotSurface2D can also paint itself
105 	// to other arbitrary Drawing.Graphics drawing surfaces
106 	// using the Draw method. (see printing later).
107 
108 
109 	private: System::Windows::Forms::Button^  prevPlotButton;
110 	private: System::Drawing::Printing::PrintDocument^ printDocument;
111 
112 	private: System::Windows::Forms::Button^  nextPlotButton;
113 	private: System::Windows::Forms::Button^  printButton;
114 	private: System::Windows::Forms::Button^  quitButton;
115 	private: System::Windows::Forms::Label^  exampleNumberLabel;
116 	private: System::Windows::Forms::Timer^  qeExampleTimer;
117 
118 	private: System::Windows::Forms::TextBox^  infoBox;
119 
120 
121 	private: System::Void quitButton_Click(System::Object^  sender, System::EventArgs^  e);
122 	private: System::Void printButton_Click(System::Object^  sender, System::EventArgs^  e);
123 	private: System::Void nextPlotButton_Click(System::Object^  sender, System::EventArgs^  e);
124 	private: System::Void prevPlotButton_Click(System::Object^  sender, System::EventArgs^  e);
125 	private: System::ComponentModel::IContainer^  components;
126 
127 	protected:
128 
129 	private:
130 		/// <summary>
131 		/// Required designer variable.
132 		/// </summary>
133 
134 
135 		/// <summary>
136 		/// used to keep track of the current demo plot being displayed.
137 		/// </summary>
138 		int currentPlot;
139 
140 		/// <summary>
141 		/// delegate for plot demo functions.
142 		/// </summary>
143 		delegate void PlotDemoDelegate();
144 
145 		/// <summary>
146 		///  list of the plot demos, initialized in the form constructor.
147 		/// </summary>
148 		array<PlotDemoDelegate^>^ PlotRoutines;
149 
150 		array<double>^ PlotQEExampleValues;
151 		array<System::String^>^ PlotQEExampleTextValues;
152 
153 		System::Void pd_PrintPage(System::Object^ sender, Printing::PrintPageEventArgs^ ev);
154 
155 #pragma region Windows Form Designer generated code
156 		/// <summary>
157 		/// Required method for Designer support - do not modify
158 		/// the contents of this method with the code editor.
159 		/// </summary>
InitializeComponent(void)160 		void InitializeComponent(void)
161 		{
162 			this->components = (gcnew System::ComponentModel::Container());
163 			this->plotSurface = (gcnew NPlot::Windows::PlotSurface2D());
164 			this->prevPlotButton = (gcnew System::Windows::Forms::Button());
165 			this->nextPlotButton = (gcnew System::Windows::Forms::Button());
166 			this->printButton = (gcnew System::Windows::Forms::Button());
167 			this->quitButton = (gcnew System::Windows::Forms::Button());
168 			this->infoBox = (gcnew System::Windows::Forms::TextBox());
169 			this->exampleNumberLabel = (gcnew System::Windows::Forms::Label());
170 			this->qeExampleTimer = (gcnew System::Windows::Forms::Timer(this->components));
171 			this->SuspendLayout();
172 			//
173 			// plotSurface
174 			//
175 			this->plotSurface->AutoScaleAutoGeneratedAxes = false;
176 			this->plotSurface->AutoScaleTitle = false;
177 			this->plotSurface->BackColor = System::Drawing::SystemColors::ControlLightLight;
178 			this->plotSurface->DateTimeToolTip = false;
179 			this->plotSurface->Legend = nullptr;
180 			this->plotSurface->LegendZOrder = 1;
181 			this->plotSurface->Location = System::Drawing::Point(8, 8);
182 			this->plotSurface->Name = L"plotSurface";
183 			this->plotSurface->RightMenu = nullptr;
184 			this->plotSurface->ShowCoordinates = true;
185 			this->plotSurface->Size = System::Drawing::Size(616, 360);
186 			this->plotSurface->SmoothingMode = System::Drawing::Drawing2D::SmoothingMode::None;
187 			this->plotSurface->TabIndex = 0;
188 			this->plotSurface->Text = L"plotSurface2D1";
189 			this->plotSurface->Title = L"";
190 			this->plotSurface->TitleFont = (gcnew System::Drawing::Font(L"Arial", 14, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Pixel));
191 			this->plotSurface->XAxis1 = nullptr;
192 			this->plotSurface->XAxis2 = nullptr;
193 			this->plotSurface->YAxis1 = nullptr;
194 			this->plotSurface->YAxis2 = nullptr;
195 			//
196 			// prevPlotButton
197 			//
198 			this->prevPlotButton->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Left));
199 			this->prevPlotButton->Location = System::Drawing::Point(8, 374);
200 			this->prevPlotButton->Name = L"prevPlotButton";
201 			this->prevPlotButton->Size = System::Drawing::Size(75, 23);
202 			this->prevPlotButton->TabIndex = 1;
203 			this->prevPlotButton->Text = L"Prev";
204 			this->prevPlotButton->UseVisualStyleBackColor = true;
205 			this->prevPlotButton->Click += gcnew System::EventHandler(this, &CPlotSurface2DDemo::prevPlotButton_Click);
206 			//
207 			// nextPlotButton
208 			//
209 			this->nextPlotButton->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Left));
210 			this->nextPlotButton->Location = System::Drawing::Point(90, 374);
211 			this->nextPlotButton->Name = L"nextPlotButton";
212 			this->nextPlotButton->Size = System::Drawing::Size(75, 23);
213 			this->nextPlotButton->TabIndex = 2;
214 			this->nextPlotButton->Text = L"Next";
215 			this->nextPlotButton->UseVisualStyleBackColor = true;
216 			this->nextPlotButton->Click += gcnew System::EventHandler(this, &CPlotSurface2DDemo::nextPlotButton_Click);
217 			//
218 			// printButton
219 			//
220 			this->printButton->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Left));
221 			this->printButton->Location = System::Drawing::Point(172, 374);
222 			this->printButton->Name = L"printButton";
223 			this->printButton->Size = System::Drawing::Size(75, 23);
224 			this->printButton->TabIndex = 3;
225 			this->printButton->Text = L"Print";
226 			this->printButton->UseVisualStyleBackColor = true;
227 			this->printButton->Click += gcnew System::EventHandler(this, &CPlotSurface2DDemo::printButton_Click);
228 			//
229 			// quitButton
230 			//
231 			this->quitButton->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Left));
232 			this->quitButton->Location = System::Drawing::Point(254, 374);
233 			this->quitButton->Name = L"quitButton";
234 			this->quitButton->Size = System::Drawing::Size(75, 23);
235 			this->quitButton->TabIndex = 4;
236 			this->quitButton->Text = L"Close";
237 			this->quitButton->UseVisualStyleBackColor = true;
238 			this->quitButton->Click += gcnew System::EventHandler(this, &CPlotSurface2DDemo::quitButton_Click);
239 			//
240 			// infoBox
241 			//
242 			this->infoBox->Anchor = static_cast<System::Windows::Forms::AnchorStyles>(((System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Left)
243 				| System::Windows::Forms::AnchorStyles::Right));
244 			this->infoBox->Location = System::Drawing::Point(8, 416);
245 			this->infoBox->Multiline = true;
246 			this->infoBox->Name = L"infoBox";
247 			this->infoBox->ScrollBars = System::Windows::Forms::ScrollBars::Vertical;
248 			this->infoBox->Size = System::Drawing::Size(611, 92);
249 			this->infoBox->TabIndex = 5;
250 			//
251 			// exampleNumberLabel
252 			//
253 			this->exampleNumberLabel->Anchor = static_cast<System::Windows::Forms::AnchorStyles>((System::Windows::Forms::AnchorStyles::Bottom | System::Windows::Forms::AnchorStyles::Left));
254 			this->exampleNumberLabel->Location = System::Drawing::Point(335, 374);
255 			this->exampleNumberLabel->Name = L"exampleNumberLabel";
256 			this->exampleNumberLabel->Size = System::Drawing::Size(72, 23);
257 			this->exampleNumberLabel->TabIndex = 6;
258 			//
259 			// qeExampleTimer
260 			//
261 			this->qeExampleTimer->Interval = 500;
262 			this->qeExampleTimer->Tick += gcnew System::EventHandler(this, &CPlotSurface2DDemo::qeExampleTimer_Tick);
263 			//
264 			// CPlotSurface2DDemo
265 			//
266 			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
267 			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
268 			this->ClientSize = System::Drawing::Size(631, 520);
269 			this->Controls->Add(this->exampleNumberLabel);
270 			this->Controls->Add(this->infoBox);
271 			this->Controls->Add(this->quitButton);
272 			this->Controls->Add(this->printButton);
273 			this->Controls->Add(this->nextPlotButton);
274 			this->Controls->Add(this->prevPlotButton);
275 			this->Controls->Add(this->plotSurface);
276 			this->Name = L"CPlotSurface2DDemo";
277 			this->Text = L"NPlot C++.Net Demo";
278 			this->ResumeLayout(false);
279 			this->PerformLayout();
280 
281 		}
282 #pragma endregion
283 
284 
285 private: System::Void qeExampleTimer_Tick(System::Object^  sender, System::EventArgs^  e);
286 };
287 }
288 
289 
290 
291 
292 
293 //#pragma once
294 //
295 //using namespace System;
296 //using namespace System::ComponentModel;
297 //using namespace System::Collections;
298 //using namespace System::Windows::Forms;
299 //using namespace System::Data;
300 //using namespace System::Drawing;
301 //
302 //
303 //namespace cpp {
304 //
305 //	/// <summary>
306 //	/// Summary for PlotSurface2DDemo
307 //	///
308 //	/// WARNING: If you change the name of this class, you will need to change the
309 //	///          'Resource File Name' property for the managed resource compiler tool
310 //	///          associated with all .resx files this class depends on.  Otherwise,
311 //	///          the designers will not be able to interact properly with localized
312 //	///          resources associated with this form.
313 //	/// </summary>
314 //	public ref class PlotSurface2DDemo : public System::Windows::Forms::Form
315 //	{
316 //	public:
317 //		PlotSurface2DDemo(void)
318 //		{
319 //			InitializeComponent();
320 //			//
321 //			//TODO: Add the constructor code here
322 //			//
323 //		}
324 //
325 //	protected:
326 //		/// <summary>
327 //		/// Clean up any resources being used.
328 //		/// </summary>
329 //		~PlotSurface2DDemo()
330 //		{
331 //			if (components)
332 //			{
333 //				delete components;
334 //			}
335 //		}
336 //	private: NPlot::Windows::PlotSurface2D^  plotSurface;
337 //	private: System::Windows::Forms::Button^  prevPlotButton;
338 //	private: System::Windows::Forms::Button^  nextPlotButton;
339 //	private: System::Windows::Forms::Button^  printButton;
340 //	private: System::Windows::Forms::Button^  quitButton;
341 //	private: System::Windows::Forms::TextBox^  infoBox;
342 //	private: System::Windows::Forms::Label^  exampleNumberLabel;
343 //	private: System::Windows::Forms::Timer^  qeExampleTimer;
344 //	private: System::ComponentModel::IContainer^  components;
345 //	protected:
346 //
347 //	protected:
348 //
349 //	private:
350 //		/// <summary>
351 //		/// Required designer variable.
352 //		/// </summary>
353 //
354 //
355 //#pragma region Windows Form Designer generated code
356 //		/// <summary>
357 //		/// Required method for Designer support - do not modify
358 //		/// the contents of this method with the code editor.
359 //		/// </summary>
360 //		void InitializeComponent(void)
361 //		{
362 //			this->components = (gcnew System::ComponentModel::Container());
363 //			this->plotSurface = (gcnew NPlot::Windows::PlotSurface2D());
364 //			this->prevPlotButton = (gcnew System::Windows::Forms::Button());
365 //			this->nextPlotButton = (gcnew System::Windows::Forms::Button());
366 //			this->printButton = (gcnew System::Windows::Forms::Button());
367 //			this->quitButton = (gcnew System::Windows::Forms::Button());
368 //			this->infoBox = (gcnew System::Windows::Forms::TextBox());
369 //			this->exampleNumberLabel = (gcnew System::Windows::Forms::Label());
370 //			this->qeExampleTimer = (gcnew System::Windows::Forms::Timer(this->components));
371 //			this->SuspendLayout();
372 //			//
373 //			// plotSurface
374 //			//
375 //			this->plotSurface->AutoScaleAutoGeneratedAxes = false;
376 //			this->plotSurface->AutoScaleTitle = false;
377 //			this->plotSurface->BackColor = System::Drawing::SystemColors::ControlLightLight;
378 //			this->plotSurface->DateTimeToolTip = false;
379 //			this->plotSurface->Legend = nullptr;
380 //			this->plotSurface->LegendZOrder = -1;
381 //			this->plotSurface->Location = System::Drawing::Point(71, 23);
382 //			this->plotSurface->Name = L"plotSurface";
383 //			this->plotSurface->RightMenu = nullptr;
384 //			this->plotSurface->ShowCoordinates = true;
385 //			this->plotSurface->Size = System::Drawing::Size(328, 272);
386 //			this->plotSurface->SmoothingMode = System::Drawing::Drawing2D::SmoothingMode::None;
387 //			this->plotSurface->TabIndex = 0;
388 //			this->plotSurface->Text = L"plotSurface2D1";
389 //			this->plotSurface->Title = L"";
390 //			this->plotSurface->TitleFont = (gcnew System::Drawing::Font(L"Arial", 14, System::Drawing::FontStyle::Regular, System::Drawing::GraphicsUnit::Pixel));
391 //			this->plotSurface->XAxis1 = nullptr;
392 //			this->plotSurface->XAxis2 = nullptr;
393 //			this->plotSurface->YAxis1 = nullptr;
394 //			this->plotSurface->YAxis2 = nullptr;
395 //			//
396 //			// prevPlotButton
397 //			//
398 //			this->prevPlotButton->Location = System::Drawing::Point(23, 329);
399 //			this->prevPlotButton->Name = L"prevPlotButton";
400 //			this->prevPlotButton->Size = System::Drawing::Size(75, 23);
401 //			this->prevPlotButton->TabIndex = 1;
402 //			this->prevPlotButton->Text = L"Prev";
403 //			this->prevPlotButton->UseVisualStyleBackColor = true;
404 //			//
405 //			// nextPlotButton
406 //			//
407 //			this->nextPlotButton->Location = System::Drawing::Point(105, 329);
408 //			this->nextPlotButton->Name = L"nextPlotButton";
409 //			this->nextPlotButton->Size = System::Drawing::Size(75, 23);
410 //			this->nextPlotButton->TabIndex = 2;
411 //			this->nextPlotButton->Text = L"Next";
412 //			this->nextPlotButton->UseVisualStyleBackColor = true;
413 //			//
414 //			// printButton
415 //			//
416 //			this->printButton->Location = System::Drawing::Point(187, 329);
417 //			this->printButton->Name = L"printButton";
418 //			this->printButton->Size = System::Drawing::Size(75, 23);
419 //			this->printButton->TabIndex = 3;
420 //			this->printButton->Text = L"Print";
421 //			this->printButton->UseVisualStyleBackColor = true;
422 //			this->printButton->Click += gcnew System::EventHandler(this, &PlotSurface2DDemo::printButton_Click);
423 //			//
424 //			// quitButton
425 //			//
426 //			this->quitButton->Location = System::Drawing::Point(268, 329);
427 //			this->quitButton->Name = L"quitButton";
428 //			this->quitButton->Size = System::Drawing::Size(75, 23);
429 //			this->quitButton->TabIndex = 4;
430 //			this->quitButton->Text = L"Close";
431 //			this->quitButton->UseVisualStyleBackColor = true;
432 //			//
433 //			// infoBox
434 //			//
435 //			this->infoBox->Location = System::Drawing::Point(32, 383);
436 //			this->infoBox->Multiline = true;
437 //			this->infoBox->Name = L"infoBox";
438 //			this->infoBox->Size = System::Drawing::Size(100, 20);
439 //			this->infoBox->TabIndex = 5;
440 //			//
441 //			// exampleNumberLabel
442 //			//
443 //			this->exampleNumberLabel->AutoSize = true;
444 //			this->exampleNumberLabel->Location = System::Drawing::Point(373, 329);
445 //			this->exampleNumberLabel->Name = L"exampleNumberLabel";
446 //			this->exampleNumberLabel->Size = System::Drawing::Size(35, 13);
447 //			this->exampleNumberLabel->TabIndex = 6;
448 //			this->exampleNumberLabel->Text = L"label1";
449 //			//
450 //			// qeExampleTimer
451 //			//
452 //			this->qeExampleTimer->Interval = 500;
453 //			//
454 //			// PlotSurface2DDemo
455 //			//
456 //			this->AutoScaleDimensions = System::Drawing::SizeF(6, 13);
457 //			this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
458 //			this->ClientSize = System::Drawing::Size(561, 489);
459 //			this->Controls->Add(this->exampleNumberLabel);
460 //			this->Controls->Add(this->infoBox);
461 //			this->Controls->Add(this->quitButton);
462 //			this->Controls->Add(this->printButton);
463 //			this->Controls->Add(this->nextPlotButton);
464 //			this->Controls->Add(this->prevPlotButton);
465 //			this->Controls->Add(this->plotSurface);
466 //			this->Name = L"PlotSurface2DDemo";
467 //			this->Text = L"PlotSurface2DDemo";
468 //			this->ResumeLayout(false);
469 //			this->PerformLayout();
470 //
471 //		}
472 //#pragma endregion
473 //	private: System::Void printButton_Click(System::Object^  sender, System::EventArgs^  e) {
474 //			 }
475 //};
476 //}
477