-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathThellierToolView.cpp
executable file
·1680 lines (1472 loc) · 55.2 KB
/
ThellierToolView.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ThellierToolView.cpp : Implementierung der Klasse CThellierToolView
//
#include "stdafx.h"
#include "ThellierTool.h"
#include "ThellierToolDoc.h"
#include "ThellierToolView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CThellierToolView
IMPLEMENT_DYNCREATE(CThellierToolView, CScrollView)
BEGIN_MESSAGE_MAP(CThellierToolView, CScrollView)
//{{AFX_MSG_MAP(CThellierToolView)
ON_COMMAND(ID_CANCEL_EDIT_SRVR, OnCancelEditSrvr)
ON_COMMAND(ID_EDIT_COPY, OnEditCopy)
ON_COMMAND(ID_FILE_PRINT_PREVIEW, OnFilePrintPreview)
ON_COMMAND(ID_FILE_SAVEGRAPH, OnFileSavegraph)
//}}AFX_MSG_MAP
// Standard-Druckbefehle
ON_COMMAND(ID_FILE_PRINT, CScrollView::OnFilePrint)
ON_COMMAND(ID_FILE_PRINT_DIRECT, CScrollView::OnFilePrint)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CThellierToolView Konstruktion/Destruktion
CThellierToolView::CThellierToolView()
{
// ZU ERLEDIGEN: Hier Code zur Konstruktion einfügen,
}
CThellierToolView::~CThellierToolView()
{
}
BOOL CThellierToolView::PreCreateWindow(CREATESTRUCT& cs)
{
// ZU ERLEDIGEN: Ändern Sie hier die Fensterklasse oder das Erscheinungsbild, indem Sie
// CREATESTRUCT cs modifizieren.
return CScrollView::PreCreateWindow(cs);
}
/////////////////////////////////////////////////////////////////////////////
// CThellierToolView Zeichnen
void CThellierToolView::OnDraw(CDC* pDC)
{
CThellierToolDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
pDC->SetMapMode(MM_TEXT);
pDC->SetTextAlign(TA_BASELINE | TA_CENTER);
pDC->SetBkMode(TRANSPARENT);
// Initialisierung der Schriften
CFont textfont, *oldfont;
LOGFONT logfont ={100,0,0,0,0,0,0,0,0,0,0,0,0,"arial"};
CSize digitSize = pDC->GetTextExtent("0");
int scalefactor = digitSize.cx/7;
if(pDC->m_hAttribDC != NULL)
{
textfont.CreatePointFontIndirect (&logfont, pDC);
oldfont = pDC->SelectObject(&textfont);
CSize digitSize = pDC->GetTextExtent("0");
scalefactor = digitSize.cx/7;
}
else
{
logfont.lfHeight = 16;
textfont.CreateFontIndirect(&logfont);
oldfont = pDC->SelectObject(&textfont);
scalefactor = 1;
}
int mainview;
mainview = pDoc->vopt.mainview;
if (pDoc != 0 && pDoc->ThellierData.GetSize() != 0)
{
// (1) Koordinatentransformation und Messtyp-Bestimmung
pDoc->CoorTrans(&pDoc->ThellierData);
// (2) Vektorsubtraktion und Berechnung von Minimal bzw. Maximalwerten
pDoc->VectorSub(&pDoc->AllDataList);
// (3) Analyse der TR steps
pDoc->TRCheckAnalysis(&pDoc->THDataList, &pDoc->TRDataList, &pDoc->PTDataList);
// (4) Check Korrektur durchführen und Ergebnisse in eigene Liste speichern
pDoc->CheckCorrection( &pDoc->PTDataList, &pDoc->CKDataList);
// (5) Falls check Korrektur erwünscht: korrigierte Daten in Hauptliste übernehmen und AC Analyse durchführen
if (pDoc->vopt.ckcorr)
{
pDoc->CKCorrToPTData( &pDoc->PTCkCorrDataList, &pDoc->CKRemainingDataList);
pDoc->ACCheckAnalysis(&pDoc->ACDataList, &pDoc->PTDataList, &pDoc->CkErrorList);
}
else
{
pDoc->ACCheckAnalysis(&pDoc->ACDataList, &pDoc->PTDataList, &pDoc->CkErrorList);
}
// (6) Berechnung der Paleointensität
// Zuerst suche nach class A Ergebnissen
pDoc->ThellierCalc(&pDoc->THDataList, &pDoc->PTDataList, &pDoc->CkErrorList, &pDoc->TRResList, &pDoc->ACResList, 0);
// wenn nicht erfolgreich, suche nach class B Ergebnissen
if (pDoc->results.m_paleoint == 0)
pDoc->ThellierCalc(&pDoc->THDataList, &pDoc->PTDataList, &pDoc->CkErrorList, &pDoc->TRResList, &pDoc->ACResList, 1);
// (6b) optional: Berechnung der Korrigierten Paleonintensität
if (pDoc->results.m_type == "MT4" && pDoc->vopt.use_autock && pDoc->vopt.automatic == 0)
{
// UpdateData(TRUE);
// pDoc->vopt.ckcorr = TRUE;
if (pDoc->results.m_paleoint == 0) // Falls noch kein Ergebniss
{
pDoc->vopt.ckcorr = TRUE;
pDoc->CKCorrToPTData( &pDoc->PTCkCorrDataList, &pDoc->CKRemainingDataList);
pDoc->ACCheckAnalysis(&pDoc->ACDataList, &pDoc->PTDataList, &pDoc->CkErrorList);
pDoc->ThellierCalc(&pDoc->THDataList, &pDoc->PTDataList, &pDoc->CkErrorList, &pDoc->TRResList, &pDoc->ACResList, 0);
if (pDoc->results.m_paleoint == 0)
pDoc->ThellierCalc(&pDoc->THDataList, &pDoc->PTDataList, &pDoc->CkErrorList, &pDoc->TRResList, &pDoc->ACResList, 1);
}
else
{
pDoc->vopt.ckcorr = TRUE;
double wmax_without_corr;
if (pDoc->criteria.m_maximizingpar == 0)
wmax_without_corr = pDoc->results.m_w;
else
wmax_without_corr = pDoc->results.m_q;
pDoc->CKCorrToPTData( &pDoc->PTCkCorrDataList, &pDoc->CKRemainingDataList);
pDoc->ACCheckAnalysis(&pDoc->ACDataList, &pDoc->PTDataList, &pDoc->CkErrorList);
pDoc->ThellierCalc(&pDoc->THDataList, &pDoc->PTDataList, &pDoc->CkErrorList, &pDoc->TRResList, &pDoc->ACResList, 0);
if (pDoc->results.m_paleoint == 0)
pDoc->ThellierCalc(&pDoc->THDataList, &pDoc->PTDataList, &pDoc->CkErrorList, &pDoc->TRResList, &pDoc->ACResList, 1);
double wmax_with_corr;
if (pDoc->criteria.m_maximizingpar == 0)
wmax_with_corr = pDoc->results.m_w;
else
wmax_with_corr = pDoc->results.m_q;
if (wmax_with_corr < wmax_without_corr) // Falls Ergebnis nicht besser als ohne Korrektur
{
pDoc->vopt.ckcorr = FALSE;
pDoc->CoorTrans(&pDoc->ThellierData);
pDoc->VectorSub(&pDoc->AllDataList);
pDoc->TRCheckAnalysis(&pDoc->THDataList, &pDoc->TRDataList, &pDoc->PTDataList);
pDoc->CheckCorrection( &pDoc->PTDataList, &pDoc->CKDataList);
pDoc->ACCheckAnalysis(&pDoc->ACDataList, &pDoc->PTDataList, &pDoc->CkErrorList);
pDoc->ThellierCalc(&pDoc->THDataList, &pDoc->PTDataList, &pDoc->CkErrorList, &pDoc->TRResList, &pDoc->ACResList, 0);
if (pDoc->results.m_paleoint == 0)
pDoc->ThellierCalc(&pDoc->THDataList, &pDoc->PTDataList, &pDoc->CkErrorList, &pDoc->TRResList, &pDoc->ACResList, 1);
}
}
}
// (7) Normierung der TR daten auf true NRM
pDoc->NormTRRes(&pDoc->TRResList, pDoc->results.m_nrmt);
// (8) Bestimmung der Auswerteklasse
switch (pDoc->CriteriaCheck())
{
case 0: if (!pDoc->vopt.ckcorr)
pDoc->results.m_class = "A";
else
pDoc->results.m_class = "A*";
break;
case 1: if (!pDoc->vopt.ckcorr)
pDoc->results.m_class = "B";
else
pDoc->results.m_class = "B*";
break;
case 2: if (pDoc->results.m_paleoint == 0)
pDoc->results.m_class.Empty();
else
{
if (!pDoc->vopt.ckcorr)
pDoc->results.m_class = "C";
else
pDoc->results.m_class = "C*";
}
break;
};
switch (mainview)
{
case 0: if (pDoc->vopt.m_arai_norm == 0)
ThellierPlot (pDC, 400, 300, 0, scalefactor, &pDoc->THDataList, &pDoc->PTDataList, &pDoc->CKDataList, &pDoc->ACResList);
else
ThellierPlot (pDC, 300, 300, 0, scalefactor, &pDoc->THDataList, &pDoc->PTDataList, &pDoc->CKDataList, &pDoc->ACResList);
break;
case 1: ZijPlot (pDC, 400, 400, 0, scalefactor, &pDoc->THDataList, &pDoc->TRDataList);
break;
case 2: DecayPlot (pDC, 400, 300, 0, scalefactor, &pDoc->THDataList, &pDoc->TRDataList);
break;
case 3: if (pDoc->vopt.ckcorr)
MDPlot (pDC, 400, 300, 0, scalefactor, &pDoc->PTDataList, &pDoc->ACResList, &pDoc->TRResList);
else
MDPlot (pDC, 400, 300, 0, scalefactor, &pDoc->PTDataList, &pDoc->CkErrorList, &pDoc->TRResList);
break;
case 4: AllPlots (pDC, scalefactor);
break;
};
}
pDoc->UpdateAllViews(this); // Erneuert alle Ansichten ausser CThellierTool3View !! -> Führt zu Problemen mit PrintPreview
}
void CThellierToolView::OnInitialUpdate()
{
CScrollView::OnInitialUpdate();
CSize sizeTotal;
// ZU ERLEDIGEN: Gesamte Größe dieser Ansicht berechnen
sizeTotal.cx = sizeTotal.cy = 1000;
SetScrollSizes(MM_TEXT, sizeTotal);
}
/////////////////////////////////////////////////////////////////////////////
// CThellierToolView Drucken
BOOL CThellierToolView::OnPreparePrinting(CPrintInfo* pInfo)
{
// Standardvorbereitung
return DoPreparePrinting(pInfo);
}
void CThellierToolView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// ZU ERLEDIGEN: Zusätzliche Initialisierung vor dem Drucken hier einfügen
}
void CThellierToolView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
// ZU ERLEDIGEN: Hier Bereinigungsarbeiten nach dem Drucken einfügen
}
/////////////////////////////////////////////////////////////////////////////
// OLE-Server-Unterstützung
// Der folgende Befehls-Handler stellt die Standardtastatur als
// Benutzerschnittstelle zum Abbruch der direkten Bearbeitungssitzung zur Verfügung. Hier
// verursacht der Container (nicht der Server) die Deaktivierung.
void CThellierToolView::OnCancelEditSrvr()
{
GetDocument()->OnDeactivateUI(FALSE);
}
/////////////////////////////////////////////////////////////////////////////
// CThellierToolView Diagnose
#ifdef _DEBUG
void CThellierToolView::AssertValid() const
{
CScrollView::AssertValid();
}
void CThellierToolView::Dump(CDumpContext& dc) const
{
CScrollView::Dump(dc);
}
CThellierToolDoc* CThellierToolView::GetDocument() // Die endgültige (nicht zur Fehlersuche kompilierte) Version ist Inline
{
ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CThellierToolDoc)));
return (CThellierToolDoc*)m_pDocument;
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CThellierToolView Nachrichten-Handler
void CThellierToolView::ThellierPlot(CDC *pDC, int x_pos, int y_pos, int viewmode, int scfa, CThellierResList *datalist, CThellierResList *secondlist, CThellierResList *thirdlist, CThellierResList *fourthlist)
{
// *************************************************************
// Thellier plot
// *************************************************************
CRect rect;
GetClientRect(&rect);
int position1, position2;
if (viewmode == 0)
{
position1 = rect.Width()/2*scfa;
position2 = rect.Height()/2*scfa;
}
else
{
position1 = 200*scfa;
position2 = 200*scfa;
}
// Achsenlänge
int x_l = x_pos*scfa;
int y_l = y_pos*scfa;
CSize axesth (x_l, y_l);
// Null Punkt
CPoint zeropointth (position1-axesth.cx/2, position2+axesth.cy/2);
//rechter Rand
CPoint rigthpointth (position1+axesth.cx/2, position2+axesth.cy/2);
// oberer Rand
CPoint uppointth (position1-axesth.cx/2, position2-axesth.cy/2);
// Radius der Punkte
int p_r = axesth.cx/100;
// Dreieck
int tr = axesth.cx/80;
// Text Abstand
int ta = axesth.cy/50;
int ta_up = ta*3;
// Koordinatensystem
pDC->MoveTo(rigthpointth);
pDC->LineTo(zeropointth);
pDC->LineTo(uppointth);
pDC->MoveTo(rigthpointth);
pDC->LineTo(rigthpointth.x,zeropointth.y+p_r);
pDC->MoveTo(zeropointth.x+axesth.cx/2,zeropointth.y);
pDC->LineTo(zeropointth.x+axesth.cx/2,zeropointth.y+p_r/2);
pDC->MoveTo(zeropointth);
pDC->LineTo(zeropointth.x,zeropointth.y+p_r);
pDC->MoveTo(zeropointth);
pDC->LineTo(zeropointth.x-p_r,zeropointth.y);
pDC->MoveTo(zeropointth.x,zeropointth.y-axesth.cy/2);
pDC->LineTo(zeropointth.x-p_r/2,zeropointth.y-axesth.cy/2);
pDC->MoveTo(uppointth);
pDC->LineTo(zeropointth.x-p_r,uppointth.y);
int tempTH, tempPT, tempCK, tempCKstart;
double magTH, magPT, magCK;
CString actualtemp; // zum auslesen des Temperaturschritts
int deci, sign; //Decimale und Vorzeichen des Tempschritts
CThellierToolDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
double maxmagTH = pDoc->minmax.maxmagTH;
double maxmagPT = pDoc->minmax.maxmagPT;
// Abfrage der größeren Achse für Art des Arai plots
if (pDoc->vopt.m_arai_norm == 1)
{
double maxmagALL;
if (maxmagTH >= maxmagPT)
maxmagALL = maxmagTH;
else
maxmagALL = maxmagPT;
maxmagTH = maxmagALL;
maxmagPT = maxmagALL;
}
for (int i = 0; i < datalist->GetSize(); i++)
{
CThellierResStruct* daten1 = ( CThellierResStruct* )datalist->GetAt(i);
tempTH = daten1->m_temp;
magTH = daten1->m_mag;
for (int j = 0; j < secondlist->GetSize(); j++)
{
CThellierResStruct* daten2 = ( CThellierResStruct* )secondlist->GetAt(j);
tempPT = daten2->m_temp;
magPT = daten2->m_mag;
if (tempTH == tempPT)
{
CRect Datapointsize((zeropointth.x+p_r)+(magPT*axesth.cx/maxmagPT),(zeropointth.y-p_r)-(magTH*axesth.cy/maxmagTH),(zeropointth.x-p_r)+(magPT*axesth.cx/maxmagPT),(zeropointth.y+p_r)-(magTH*axesth.cy/maxmagTH));
pDC->Ellipse (&Datapointsize);
if (i == 1 || i == 4 || i == 7 || i == 10 || i == 13 || i == 16 || i == 19)
{
actualtemp = ecvt(tempPT,3,&deci,&sign);
actualtemp.Insert(deci,"°C");
if(tempPT < 100 && tempPT > 10)
actualtemp.Delete(4);
pDC->TextOut((zeropointth.x+ta)+(magPT*axesth.cx/maxmagPT),(zeropointth.y-ta_up)-(magTH*axesth.cy/maxmagTH),actualtemp);
}
}
} // Ende der pTRM Werte
for (j = 0; j < thirdlist->GetSize(); j++)
{
CThellierResStruct* daten3 = ( CThellierResStruct* )thirdlist->GetAt(j);
tempCKstart = daten3->m_temp;
tempCK = daten3->m_sptemp;
magCK = daten3->m_mag;
if (tempTH == tempCK && thirdlist->GetSize() != 0)
{
int linksunten_x = (zeropointth.x-tr)+(magCK*axesth.cx/maxmagPT);
int rechtsunten_x = (zeropointth.x+tr)+(magCK*axesth.cx/maxmagPT);
int unten_y = (zeropointth.y+p_r)-(magTH*axesth.cy/maxmagTH);
int oben_x = zeropointth.x+(magCK*axesth.cx/maxmagPT);
int oben_y = (zeropointth.y-p_r)-(magTH*axesth.cy/maxmagTH);
pDC->MoveTo (linksunten_x,unten_y);
pDC->LineTo (rechtsunten_x,unten_y);
pDC->LineTo (oben_x,oben_y);
pDC->LineTo (linksunten_x,unten_y);
for (int k = 0; k < secondlist->GetSize(); k++)
{
CThellierResStruct* daten2 = ( CThellierResStruct* )secondlist->GetAt(k);
tempPT = daten2->m_temp;
magPT = daten2->m_mag;
if (tempCKstart == tempPT)
{
int line_y;
int line_x = zeropointth.x+(magPT*axesth.cx/maxmagPT);
for (int l = 0; l < datalist->GetSize(); l++)
{
CThellierResStruct* daten4 = ( CThellierResStruct* )datalist->GetAt(l);
int tempTHnew = daten4->m_temp;
double magTHnew = daten4->m_mag;
if (tempTHnew == tempPT)
{
line_y = zeropointth.y-(magTHnew*axesth.cy/maxmagTH);
pDC->MoveTo (line_x,line_y);
pDC->LineTo (oben_x,line_y);
pDC->LineTo (oben_x,unten_y);
}
}
}
}
}
} // Ende der CK Werte
for (j = 0; j < fourthlist->GetSize(); j++)
{
CThellierResStruct* daten5 = ( CThellierResStruct* )fourthlist->GetAt(j);
int tempACstart = daten5->m_temp;
int tempAC = daten5->m_sptemp;
double magAC = daten5->m_z;
double magPT_AC2 = daten5->m_y;
double magPT_AC = daten5->m_x;
if (tempTH == tempAC && fourthlist->GetSize() != 0 && pDoc->vopt.accheck)
{
// neu (Modell, 23.09.03)
int linksunten_x = (zeropointth.x-p_r)+((magAC)*axesth.cx/maxmagPT);
int rechtsunten_x = (zeropointth.x+p_r)+((magAC)*axesth.cx/maxmagPT);
int unten_y = (zeropointth.y+p_r)-(magTH*axesth.cy/maxmagTH);
int oben_x = zeropointth.x+((magAC)*axesth.cx/maxmagPT);
int oben_y = (zeropointth.y-p_r)-(magTH*axesth.cy/maxmagTH);
/* alter code von David
int linksunten_x = (zeropointth.x-p_r)+((magPT_AC-magAC)*axesth.cx/maxmagPT);
int rechtsunten_x = (zeropointth.x+p_r)+((magPT_AC-magAC)*axesth.cx/maxmagPT);
int unten_y = (zeropointth.y+p_r)-(magTH*axesth.cy/maxmagTH);
int oben_x = zeropointth.x+((magPT_AC-magAC)*axesth.cx/maxmagPT);
int oben_y = (zeropointth.y-p_r)-(magTH*axesth.cy/maxmagTH);
*/
CBrush HorBrush;
HorBrush.CreateSolidBrush (RGB(255,0,0));
CBrush* pOriginalBrush;
pOriginalBrush = pDC->SelectObject(&HorBrush);
CRect TempACdatapointsize(linksunten_x,unten_y,rechtsunten_x,oben_y);
pDC->Rectangle(&TempACdatapointsize);
pDC->SelectObject(pOriginalBrush);
for (int k = 0; k < secondlist->GetSize(); k++)
{
CThellierResStruct* daten2 = ( CThellierResStruct* )secondlist->GetAt(k);
tempPT = daten2->m_temp;
magPT = daten2->m_mag;
if (tempACstart == tempPT)
{
int line_y;
int line_x = zeropointth.x+(magPT*axesth.cx/maxmagPT);
for (int l = 0; l < datalist->GetSize(); l++)
{
CThellierResStruct* daten4 = ( CThellierResStruct* )datalist->GetAt(l);
int tempTHnew = daten4->m_temp;
double magTHnew = daten4->m_mag;
if (tempTHnew == tempPT)
{
line_y = zeropointth.y-(magTHnew*axesth.cy/maxmagTH);
pDC->MoveTo (line_x,line_y);
pDC->LineTo (line_x,unten_y-p_r);
pDC->LineTo (oben_x,unten_y-p_r);
}
}
}
}
}
}// AC if zu
}
// *************** Fit - Gerade für Thellier plot *********************
double maxPT, minPT;
double y_ende, y_anfang;
minPT = pDoc->results.x_1;
maxPT = pDoc->results.x_2;
y_ende = pDoc->results.y_gerade - (maxPT - pDoc->results.x_gerade)*sqrt(pDoc->results.m_slope*pDoc->results.m_slope);
y_anfang = pDoc->results.y_gerade - (minPT - pDoc->results.x_gerade)*sqrt(pDoc->results.m_slope*pDoc->results.m_slope);
CPen PaleoPen;
CPen LinePen;
LinePen.CreatePen (PS_SOLID,1,RGB(0,0,0));
PaleoPen.CreatePen (PS_DASH,2,RGB(0,0,0));
CPen* qOriginalPen;
qOriginalPen = pDC->SelectObject(&PaleoPen);
if (y_anfang > 0)
{
pDC->MoveTo(zeropointth.x+(minPT*axesth.cx/maxmagPT),zeropointth.y-(y_anfang*axesth.cy/maxmagTH));
pDC->LineTo(zeropointth.x+(maxPT*axesth.cx/maxmagPT),zeropointth.y-(y_ende*axesth.cy/maxmagTH));
}
CPen* pOriginalPen;
pOriginalPen = pDC->SelectObject(&LinePen);
// ************* Beschriftung der Achsen *****************
CString smaxmagPT, smaxmagTH;
smaxmagPT = ecvt(maxmagPT,5,&deci,&sign);
if (deci <= 0)
{
smaxmagPT.Insert(deci,"0.");
for (int n = 0; n < -deci; n++)
smaxmagPT.Insert(2,'0');
}
else
smaxmagPT.Insert(deci,".");
smaxmagTH = ecvt(maxmagTH,5,&deci,&sign);
if (deci <= 0)
{
smaxmagTH.Insert(deci,"0.");
for (int n = 0; n < -deci; n++)
smaxmagTH.Insert(2,'0');
}
else
smaxmagTH.Insert(deci,".");
// y-Achse
pDC->TextOut(zeropointth.x-0.05*axesth.cx, zeropointth.y-0.98*axesth.cy, "1.0");
pDC->TextOut(zeropointth.x-0.05*axesth.cx, zeropointth.y-0.48*axesth.cy, "0.5");
pDC->TextOut(zeropointth.x-0.05*axesth.cx, zeropointth.y+0.02*axesth.cy, "0.0");
pDC->TextOut(zeropointth.x+0.1*axesth.cx,zeropointth.y-1.1*axesth.cy,"NRM (* "+smaxmagTH+" mA/m)");
// x-Achse
pDC->TextOut(zeropointth.x, zeropointth.y+0.07*axesth.cy, "0.0");
pDC->TextOut(zeropointth.x+0.5*axesth.cx, zeropointth.y+0.07*axesth.cy, "0.5");
pDC->TextOut(zeropointth.x+axesth.cx, zeropointth.y+0.07*axesth.cy, "1.0");
pDC->TextOut(zeropointth.x+axesth.cx*0.5,zeropointth.y+0.13*axesth.cy,"pTRM (* "+smaxmagPT+" mA/m)");
// ************* Ausgabe des Probennames + Palint *****************
CString palint, name;
name = pDoc->fielddata.name;
int length = name.GetLength();
CString chara = " ";
if (name.GetAt(length-1) == chara)
name.Delete(length-1);
palint.Format("%.2f \xb1 %.2f \xb5T ",pDoc->results.m_paleoint,pDoc->results.m_stddev);
pDC->TextOut(rigthpointth.x-0.15*axesth.cy, uppointth.y, name);
pDC->TextOut(rigthpointth.x-0.15*axesth.cy, uppointth.y+0.07*axesth.cy, palint);
}
void CThellierToolView::ZijPlot(CDC *pDC, int x_pos, int y_pos, int viewmode, int scfa, CThellierResList *datalist, CThellierResList *secondlist)
{
// *************************************************************
// Zij plot
// *************************************************************
CThellierToolDoc* pDoc = GetDocument();
ASSERT_VALID(pDoc);
CPen AxisPen;
CPen HPen;
CPen VPen;
CPen DirPen;
CBrush HorBrush;
CBrush OrgBrush;
AxisPen.CreatePen (PS_SOLID,1,RGB(0,0,0));
HPen.CreatePen (PS_SOLID,1,RGB(255,0,0));
VPen.CreatePen (PS_SOLID,1,RGB(0,0,255));
DirPen.CreatePen (PS_DASH,1,RGB(0,255,0));
HorBrush.CreateSolidBrush (RGB(255,0,0));
OrgBrush.CreateSolidBrush (RGB(255,255,255));
CBrush* pOriginalBrush;
CPen* pOriginalPen;
pOriginalPen = pDC->SelectObject(&AxisPen);
// ******************
// Position des Plots
// ******************
CRect rect;
GetClientRect(&rect);
int position1, position2;
if (viewmode == 0)
{
position1 = rect.Width()/2*scfa;
position2 = rect.Height()/2*scfa;
}
else
{
position1 = 550*scfa;
position2 = 200*scfa;
}
int x_l = x_pos*scfa;
int y_l = y_pos*scfa;
CSize axesth (x_l, y_l);
int p_r = axesth.cx/80;
int a_r = axesth.cx/80;
// Berechnung der absoluten Max.-werte für die Darstellung
// Deklination:
// x auf der x Achse
// y auf der y Achse (positive Wert nach unten)
// => North enstpricht rechts, West entspricht oben
// Inklination:
// z auf der y Achse (positive Werte nach unten)??
// Bestimmung der maximalen x - Achsen Werte
double max_left = pDoc->minmax.minx;
double max_right = pDoc->minmax.maxx;
if (pDoc->minmax.maxh > max_right)
max_right = pDoc->minmax.maxh;
if (pDoc->minmax.minh < max_left)
max_left = pDoc->minmax.minh;
// Bestimmung der maximalen y - Achsen Werte
double max_down = pDoc->minmax.maxy;
double max_up = pDoc->minmax.miny;
if (pDoc->minmax.minz < max_up)
max_up = pDoc->minmax.minz;
if (pDoc->minmax.maxz > max_down)
max_down = pDoc->minmax.maxz;
// Coordinatensystem - Ranbedingungen
if (max_left > 0)
max_left = 0.0f;
if (max_right < 0)
max_right = 0.0f;
if (max_down < 0)
max_down = 0.0f;
if (max_up > 0)
max_up = 0.0f;
// Bestimmung der längsten Achse
double max_tmp1, max_tmp2, max_all, max_all_sum;
if (max_down > -max_up)
max_tmp1 = max_down;
else
max_tmp1 = -max_up;
if (-max_left > max_right)
max_tmp2 = -max_left;
else
max_tmp2 = max_right;
if (max_tmp1 > max_tmp2)
max_all = max_tmp1;
else
max_all = max_tmp2;
if ((-max_left + max_right) > (max_down - max_up))
max_all_sum = -max_left + max_right;
else
max_all_sum = -max_up + max_down;
// Position des Nullpunktes
int zero_x = position1 - axesth.cx/2 + (-max_left * axesth.cx / (max_all_sum));
int zero_y = position2 + axesth.cy/2 - (max_down * axesth.cy / (max_all_sum));
CPoint zeropoint (zero_x, zero_y);
// unterer rechter Rand
CPoint rightdownpoint (position1+axesth.cx/2, position2+axesth.cy/2);
// oberer linker Rand
CPoint leftuppoint (position1-axesth.cx/2, position2-axesth.cy/2);
// oberer rechter Rand
CPoint rightuppoint (position1+axesth.cx/2, position2-axesth.cy/2);
// Koordinatensystem
pDC->MoveTo(zeropoint);
pDC->LineTo(zeropoint.x, zeropoint.y + max_up/max_all_sum*axesth.cy);
pDC->MoveTo(zeropoint);
pDC->LineTo(zeropoint.x, zeropoint.y + max_down/max_all_sum*axesth.cy);
pDC->MoveTo(zeropoint);
pDC->LineTo(zeropoint.x + max_left/max_all_sum*axesth.cx, zeropoint.y);
pDC->MoveTo(zeropoint);
pDC->LineTo(zeropoint.x + max_right/max_all_sum*axesth.cx, zeropoint.y);
// Erweiterung des Koordinatensystems und Beschriftung
int x_x_letter = zeropoint.x + 3*a_r + max_right/max_all_sum*axesth.cx;
int y_x_letter = zeropoint.y + 0.8*a_r;
int x_y_letter = zeropoint.x;
int y_y_letter = zeropoint.y - 1.5*a_r + max_up/max_all_sum*axesth.cy;
CString x_letter, y_letter;
if (pDoc->vopt.coordinates == 0)
{
x_letter = "X,H";
y_letter = "-Y,-Z";
}
else
{
x_letter = "N";
y_letter = "Up,W";
}
if (-max_left < 0.05*max_right)
{
pDC->MoveTo(zeropoint);
pDC->LineTo(zeropoint.x - 5*a_r, zeropoint.y);
}
if (max_right < -0.05*max_left)
{
pDC->MoveTo(zeropoint);
pDC->LineTo(zeropoint.x + 5*a_r, zeropoint.y);
x_x_letter += 5*a_r;
}
if (-max_up < 0.05*max_down)
{
pDC->MoveTo(zeropoint);
pDC->LineTo(zeropoint.x, zeropoint.y - 5*a_r);
y_y_letter -= 5*a_r;
}
if (max_down < -0.05*max_up)
{
pDC->MoveTo(zeropoint);
pDC->LineTo(zeropoint.x, zeropoint.y + 5*a_r);
}
pDC->TextOut(x_x_letter, y_x_letter, x_letter, x_letter.GetLength());
pDC->TextOut(x_y_letter, y_y_letter, y_letter, y_letter.GetLength());
// Zeichnen der H-Kurve
pOriginalPen = pDC->SelectObject(&HPen);
pOriginalBrush = pDC->SelectObject(&HorBrush);
for (int i=0; i < datalist->GetSize(); i++)
{
CThellierResStruct* daten = ( CThellierResStruct* )datalist->GetAt(i);
// Linien zeichnen
if (i > 0)
pDC->LineTo(zeropoint.x+(daten->m_x*axesth.cx/max_all_sum),zeropoint.y+(daten->m_y*axesth.cy/max_all_sum));
// Punkte zeichnen
int rigthdown_x = (zeropoint.x+p_r) + (daten->m_x*axesth.cx/max_all_sum);
int rigthdown_y = (zeropoint.y-p_r) + (daten->m_y*axesth.cy/max_all_sum);
int leftdown_x = (zeropoint.x-p_r) + (daten->m_x*axesth.cx/max_all_sum);
int leftdown_y = (zeropoint.y+p_r) + (daten->m_y*axesth.cy/max_all_sum);
CRect datapointsize(rigthdown_x,rigthdown_y,leftdown_x,leftdown_y);
pDC->Ellipse (&datapointsize);
// Zeiger zurücksetzten
pDC->MoveTo(zeropoint.x+(daten->m_x*axesth.cx/max_all_sum),zeropoint.y+(daten->m_y*axesth.cy/max_all_sum));
}
// Zeichnen der V-Kurve
pOriginalPen = pDC->SelectObject(&VPen);
pOriginalBrush = pDC->SelectObject(&OrgBrush);
// Mittleres x und vorzeichen von x_mean berechnen (für ZIJ-Plot, leon, 3.01.04)
double x_mean = 0.0;
double x_sign;
for (i=0; i < datalist->GetSize(); i++)
{
CThellierResStruct* daten = ( CThellierResStruct* )datalist->GetAt(i);
x_mean += daten->m_x/(datalist->GetSize()-1);
}
x_sign = x_mean/fabs(x_mean);
for (i=0; i < datalist->GetSize(); i++)
{
CThellierResStruct* daten = ( CThellierResStruct* )datalist->GetAt(i);
// Linien zeichnen
// - Vorzeichen von x-Wert berücksichtigen (siehe oben)
// - (x + -> rechte Plot-Hälfte, Inc + -> unten rechts, Inc - -> oben rechts)
// - (x - -> linke Plot-Hälfte, Inc + -> links unten, Inc - -> links oben)
// double m_h = daten->m_x/fabs(daten->m_x)*sqrt(pow(daten->m_x,2) + pow(daten->m_y,2));
double m_h = x_sign*sqrt(pow(daten->m_x,2) + pow(daten->m_y,2));
if (i > 0)
pDC->LineTo(zeropoint.x+(m_h*axesth.cx/max_all_sum),zeropoint.y+(daten->m_z*axesth.cy/max_all_sum));
// Punkte zeichnen
int rigthdown_x = (zeropoint.x+p_r) + (m_h*axesth.cx/max_all_sum);
int rigthdown_y = (zeropoint.y-p_r) + (daten->m_z*axesth.cy/max_all_sum);
int leftdown_x = (zeropoint.x-p_r) + (m_h*axesth.cx/max_all_sum);
int leftdown_y = (zeropoint.y+p_r) + (daten->m_z*axesth.cy/max_all_sum);
CRect datapointsize(rigthdown_x,rigthdown_y,leftdown_x,leftdown_y);
pDC->Ellipse (&datapointsize);
// Temperaturbeschriftung
if (i == 1 || i == 4 || i == 7 || i == 10 || i == 13 || i == 16 || i == 19)
{
int deci, sign;
CString actualtemp = ecvt(daten->m_temp,3,&deci,&sign);
actualtemp.Insert(deci,"°C");
if(daten->m_temp < 100 && daten->m_temp > 10)
actualtemp.Delete(4);
pDC->TextOut((zeropoint.x+2*p_r)+(m_h*axesth.cx/max_all_sum),(zeropoint.y-2*p_r)+(daten->m_z*axesth.cy/max_all_sum),actualtemp);
}
// Zeiger zurücksetzten
pDC->MoveTo(zeropoint.x+(m_h*axesth.cx/max_all_sum),zeropoint.y+(daten->m_z*axesth.cy/max_all_sum));
}
// *********************
// Scales auf den Achsen
// *********************
pOriginalPen = pDC->SelectObject(&AxisPen);
double scaleex;
double stepvalue, x_pos_stepvalue, y_pos_stepvalue, x_neg_stepvalue, y_neg_stepvalue;
double i_tmp;
if (max_all > 10) // richtigen Bereich für scales bestimmen
{
for (i = 10; i < 100000; i = i*10)
{
if (max_all/i <= 10 && max_all/i > 1)
{
scaleex = i;
stepvalue = max_all/i;
x_neg_stepvalue = -max_left/i;
y_neg_stepvalue = -max_up/i;
x_pos_stepvalue = max_right/i;
y_pos_stepvalue = max_down/i;
}
};
}
else
{
for (i = 10; i < 10000000; i = i*10)
{
i_tmp = 10.0/i;
if (max_all/i_tmp <= 10 && max_all/i_tmp > 1)
{
scaleex = i_tmp;
stepvalue = max_all/i_tmp;
x_neg_stepvalue = -max_left/i_tmp;
y_neg_stepvalue = -max_up/i_tmp;
x_pos_stepvalue = max_right/i_tmp;
y_pos_stepvalue = max_down/i_tmp;
}
};
}
int scale_stepwidth = 0;
if (-max_left >= max_right && -max_left >= max_down && -max_left >= -max_up)
scale_stepwidth = (zeropoint.x-leftuppoint.x)/stepvalue;
else
if (max_right > -max_up && max_right > max_down)
scale_stepwidth = (rightuppoint.x-zeropoint.x)/stepvalue;
else
if (-max_up >= max_down)
scale_stepwidth = (zeropoint.y-leftuppoint.y)/stepvalue;
else
scale_stepwidth = (rightdownpoint.y-zeropoint.y)/stepvalue;
// Variablen für die Beschriftung
CString magnetization;
char step [11];
int deci, sign;
for (i = 1; i < x_pos_stepvalue; i++)
{
pDC->MoveTo(zeropoint.x+i*scale_stepwidth, zeropoint.y - a_r);
pDC->LineTo(zeropoint.x+i*scale_stepwidth, zeropoint.y + a_r);
if (x_neg_stepvalue <= x_pos_stepvalue)
{
if (x_pos_stepvalue < 4)
{
magnetization = ecvt(i*scaleex, 10, &deci,&sign);
if (deci <= 0)
{
magnetization.Insert(deci,"0.");
for (int n = 0; n < -deci; n++)
magnetization.Insert(2,'0');
magnetization = magnetization.Left(-deci+3);
}
else
magnetization = magnetization.Left(deci);
//itoa (i*scaleex, step, 10);
//magnetization = step;
pDC->TextOut(zeropoint.x+i*scale_stepwidth, zeropoint.y + 5*p_r, magnetization, magnetization.GetLength());
}
else
if (x_pos_stepvalue < 7)
{
if (i/2.0 == 1 || i/2.0 == 2 || i/2.0 == 3)
{
magnetization = ecvt(i*scaleex, 10, &deci,&sign);
if (deci <= 0)
{
magnetization.Insert(deci,"0.");
for (int n = 0; n < -deci; n++)
magnetization.Insert(2,'0');
magnetization = magnetization.Left(-deci+3);
}
else
magnetization = magnetization.Left(deci);
//itoa (i*scaleex, step, 10);
//magnetization = step;
pDC->TextOut(zeropoint.x+i*scale_stepwidth, zeropoint.y + 5*p_r, magnetization, magnetization.GetLength());
}
}
else
{
if (i == 5 )
{
magnetization = ecvt(i*scaleex,10, &deci,&sign);
if (deci <= 0)
{
magnetization.Insert(deci,"0.");
for (int n = 0; n < -deci; n++)
magnetization.Insert(2,'0');
magnetization = magnetization.Left(-deci+3);
}
else
magnetization = magnetization.Left(deci);
//itoa (i*scaleex, step, 10);
//magnetization = step;
pDC->TextOut(zeropoint.x+i*scale_stepwidth, zeropoint.y + 5*p_r, magnetization, magnetization.GetLength());
}
}
}
};
for (i = 1; i < y_pos_stepvalue; i++)
{
pDC->MoveTo(zeropoint.x - a_r, zeropoint.y+i*scale_stepwidth);
pDC->LineTo(zeropoint.x + a_r, zeropoint.y+i*scale_stepwidth);
};
for (i = 1; i < x_neg_stepvalue; i++)
{
pDC->MoveTo(zeropoint.x-i*scale_stepwidth, zeropoint.y - a_r);
pDC->LineTo(zeropoint.x-i*scale_stepwidth, zeropoint.y + a_r);
if (x_neg_stepvalue > x_pos_stepvalue)
{
if (x_pos_stepvalue < 4)
{
magnetization = ecvt(i*scaleex,10, &deci,&sign);
if (deci <= 0)
{
magnetization.Insert(deci,"0.");
for (int n = 0; n < -deci; n++)
magnetization.Insert(2,'0');
magnetization = magnetization.Left(-deci+3);
}
else
magnetization = magnetization.Left(deci);
//itoa (i*scaleex, step, 10);
//magnetization = step;
magnetization.Insert(0,'-');
pDC->TextOut(zeropoint.x-i*scale_stepwidth, zeropoint.y + 5*p_r, magnetization, magnetization.GetLength());
}
else
if (x_pos_stepvalue < 7)
{
if (i/2.0 == 1 || i/2.0 == 2 || i/2.0 == 3)
{
magnetization = ecvt(i*scaleex,10, &deci,&sign);
if (deci <= 0)
{
magnetization.Insert(deci,"0.");
for (int n = 0; n < -deci; n++)
magnetization.Insert(2,'0');
magnetization = magnetization.Left(-deci+3);
}
else
magnetization = magnetization.Left(deci);
//itoa (i*scaleex, step, 10);
//magnetization = step;
magnetization.Insert(0,'-');
pDC->TextOut(zeropoint.x-i*scale_stepwidth, zeropoint.y + 5*p_r, magnetization, magnetization.GetLength());
}
}
else
{
if (i == 5 )
{
magnetization = ecvt(i*scaleex,10, &deci,&sign);
if (deci <= 0)
{
magnetization.Insert(deci,"0.");
for (int n = 0; n < -deci; n++)
magnetization.Insert(2,'0');
magnetization = magnetization.Left(-deci+3);
}
else
magnetization = magnetization.Left(deci);
//itoa (i*scaleex, step, 10);
//magnetization = step;
magnetization.Insert(0,'-');
pDC->TextOut(zeropoint.x-i*scale_stepwidth, zeropoint.y + 5*p_r, magnetization, magnetization.GetLength());