File: DIFRKMTY\D_INTERN.CPP

    1 //##############################################################################
    2 //                                                                            //
    3 // D_INTERN.H                                                                 //
    4 //                                                                            //
    5 // Subsystem: Diffraktometrie/ Reflektometrie                                 //
    6 //            allgemeine, intern genutzte Fenster                             //
    7 // Benutzung durch andere Subsysteme erforderlich: NEIN                       //
    8 //                                                                            //
    9 //##############################################################################
   10 //! Kommentierung und Aenderungen B. Buss, 2000/2001, HUB IfI
   11 
   12 #include "internls\evrythng.h" // GermanVersion, SetInfo
   13 #include "winresrc\rc_def.h"   // Ressourcen-IDs
   14 #include <new.h>
   15 #pragma hdrstop
   16 
   17 #include "difrkmty\d_intern.h" // SCHNITTSTELLE für diese Datei
   18 #include "difrkmty\d_extern.h" // für TPlotWindow
   19 
   20 #include "datavisa\datavisa.h"
   21 #include "internls\l_layer.h" //17.11.2002 für extern lpDBase
   22 
   23 //! neu: klier Allgemeine Einstellungen
   24 #include "mespara\mespara.h"
   25 
   26 //--||--\\--||--//--||--\\--||--//--||--\\--||--//--||--\\--||--//--||--\\--||--
   27 
   28 //! Kurvendatenbasis
   29 __declspec(dllimport) LPDataBase lpDBase;
   30 
   31 //! neu: klier Allgemeine Einstellungen
   32 extern TMeasurementParameter MeasurementParameter; // in M_MAIN.CPP
   33 extern TMain Main; // in M_MAIN.CPP deklariertes Hauptprogramm
   34 
   35 //#############################################################################
   36 // globale Typen und Konstanten
   37 //#############################################################################
   38 
   39 const UINT _BEREICHDIGITS= 2;
   40 const UINT _MINIDDIGITS= 2;
   41 const UINT _MAXIDDIGITS= 2;
   42 const UINT _MININTENSITYDIGITS= 2;
   43 const UINT _MAXINTENSITYDIGITS= 2;
   44 
   45 // Bezeichner korrespondieren mit den entsprechenden Enum-Typen
   46 const char aOutputType[6][15] =
   47 {
   48         "RL-Bitmap", "Raw Matrix", "Curve", "Number", "BarGraph", "Histogram"
   49 };
   50 
   51 const char aScaleType[3][15]= 
   52 {
   53         "Logarithmic", "Linear", "User"
   54 };
   55 
   56 //#############################################################################
   57 // sprachspezifische Konstanten
   58 //#############################################################################
   59 
   60 #ifdef GermanVersion
   61         static const char szMessageDlg[]= "Meldung";
   62 
   63         static const char szMsgLine300[]= "Farbbereich falsch!";
   64         static const char szMsgLine301[]= "Intensitätsbereich falsch!";
   65         static const char szMsgLine302[]= "gewählte Intensität zu klein";
   66         static const char szMsgLine303[]= "MinIntensität größer als MaxIntensität";
   67         static const char szMsgLine304[]= "gewählte Intensität zu groß";
   68         static const char szMsgLine305[]= "Werte fuer Ordinateneinteilung 2 - 15";
   69         static const char szMsgLine306[]= "Werte fuer Abzisseneinteilung 2 - 15";
   70         static const char szMsgLine307[]= "Intensitätsbereich [%.3f-->%.3f] ";
   71         static const char szMsgLine308[]= "Zeile %d mit %d Spalten";
   72         static const char szMsgLine309[]= "Daten in ein Bitmap wandeln...";
   73         static const char szMsgLine310[]= "Bereichsüberschreitung !";
   74         static const char szMsgLine311[]= "User Skalierung - Farbwahl";
   75         static const char szMsgLine312[]= "Farbe %d";
   76         static const char szMsgLine313[]= "Int.bereiche";
   77         static const char szMsgLine314[]= "Intensitäten";
   78         static const char szMsgLine315[]= "Bereich %d -> Farbe";
79 #else 80 static const char szMessageDlg[]= "Message"; 81 82 static const char szMsgLine300[]= "Color-gamut falsely!"; 83 static const char szMsgLine301[]= "Intensity-area falsely!"; 84 static const char szMsgLine302[]= "selected intensity too small"; 85 static const char szMsgLine303[]= "Min intensity more largely than max intensity"; 86 static const char szMsgLine304[]= "selected intensity excessively"; 87 static const char szMsgLine305[]= "Values for y-axle organization 2 - 15"; 88 static const char szMsgLine306[]= "Values for x-axle organization 2 - 15"; 89 static const char szMsgLine307[]= "Intensity Range [%.3f-->%.3f] "; 90 static const char szMsgLine308[]= "Row %d with %d Columns"; 91 static const char szMsgLine309[]= "Transform data to Bitmap..."; 92 static const char szMsgLine310[]= "Overflow !"; 93 static const char szMsgLine311[]= "User scaling - color choice"; 94 static const char szMsgLine312[]= "Color %d"; 95 static const char szMsgLine313[]= "Int.areas"; 96 static const char szMsgLine314[]= "Intensities"; 97 static const char szMsgLine315[]= "Area %d -> Color";
98 #endif 99 100 //############################################################################## 101 // TCurveFreeScalDlg 102 //############################################################################## 103 104 TCurveFreeScalDlg::TCurveFreeScalDlg(TPlotWindow *aPlotWindow) : TModalDlg( "USERSCAL", GetMainInstance() ), PlotWindow(0) 105 { 106 PlotWindow= aPlotWindow; 107 }; 108 //***************************************************************************** 109 110 int TCurveFreeScalDlg::GetFarbeId(UINT aBereich) { 111 switch (aBereich) { 112 case 0: 113 return IDFarbe1; 114 115 case 1: 116 return IDFarbe2; 117 118 case 2: 119 return IDFarbe3; 120 121 case 3: 122 return IDFarbe4; 123 124 case 4: 125 return IDFarbe5; 126 127 case 5: 128 return IDFarbe6; 129 130 case 6: 131 return IDFarbe7; 132 133 case 7: 134 return IDFarbe8; 135 136 default: // unbekannter Bereich 137 return -1; 138 } 139 } 140 //***************************************************************************** 141 142 int TCurveFreeScalDlg::GetBereichId(UINT aBereich) { 143 switch (aBereich) { 144 case 0: 145 return IDBereich1; 146 147 case 1: 148 return IDBereich2; 149 150 case 2: 151 return IDBereich3; 152 153 case 3: 154 return IDBereich4; 155 156 case 4: 157 return IDBereich5; 158 159 case 5: 160 return IDBereich6; 161 162 case 6: 163 return IDBereich7; 164 165 case 7: 166 return IDBereich8; 167 168 default: // unbekannter Bereich 169 return -1; 170 } 171 } 172 //***************************************************************************** 173 174 //! zum Initialisieren des Modaldialogs 175 BOOL TCurveFreeScalDlg::Dlg_OnInit(HWND, HWND hwndCtl, LPARAM lParam) 176 { 177 char buf[MaxString]; 178 int i; 179 180 //! die Funktion des neu erzeugten Fensters soll anders eingebaut werden... 181 if (!PlotWindow->BSource->UserFarb) 182 (new TCurveFreeScalColorWindow(GetMainInstance(), PlotWindow))->Show(); // registriert sich selbst als PlotWindow->BSource->UserFarb 183 184 //Datum: 27.07.2002 TModalDlg::Dlg_OnInit(hwnd,hwndCtl,lParam); 185 186 //! setze Intensitaeten und Farben im Dialog 187 for (i= 0;i < 8;i++) 188 { 189 CtrlSetDouble(GetBereichId(i), PlotWindow->BSource->ber[i], _BEREICHDIGITS, _DECIMAL); 190 CtrlSetLong(GetFarbeId(i), PlotWindow->BSource->farbe[i]); 191 } 192 //! setze Min und MaxIntensitaet im Dialog 193 if (!GetDlgItemText(GetHandle(), IDBereichMax, (LPSTR)buf, 10)) 194 { 195 CtrlSetDouble(IDBereichMin, PlotWindow->LowerBound, _MINIDDIGITS, _DECIMAL); 196 CtrlSetDouble(IDBereichMax, PlotWindow->UpperBound, _MAXIDDIGITS, _DECIMAL); 197 } 198 CtrlSetLong(IDFarbeMin, 0 ); 199 CtrlSetLong(IDFarbeMax, ( PlotWindow->BSource ) ? PlotWindow->BSource->ColorTable.ColorMap.GetCount()-1 : 0); 200 201 return TRUE; 202 }; 203 //***************************************************************************** 204 205 //! Ablaufsteuerung des Dialogs 206 void TCurveFreeScalDlg::Dlg_OnCommand(HWND, int id, HWND hwndCtl, UINT codeNotify) 207 { 208 int i; 209 210 switch (id) 211 { 212 case cm_SetupParameters: //! im Falle von Button "Int. skalieren" 213 PlotWindow->BSource->BereichDef(); 214 for (i= 0;i < 8;i++) 215 { 216 CtrlSetDouble(GetBereichId(i), PlotWindow->BSource->ber[i], _BEREICHDIGITS, _DECIMAL); 217 } 218 CanClose(); 219 PlotWindow->UpdateWnd(); 220 break; 221 222 case IDOK: //! Return Taste bewirkt eine Ueberpruefung der Dialogeingaben 223 CanClose(); 224 PlotWindow->UpdateWnd(); 225 break; 226 227 case id_Standard: //! id_Standard wird abgefangen, aufgerufen durch den OK-Button 228 if ( CanClose() ) 229 { 230 LeaveDialog(); 231 EndDialog(GetHandle(), id); 232 }; 233 PlotWindow->UpdateWnd(); 234 break; 235 236 case IDCANCEL: //! im Falle Abbrechen Button 237 LeaveDialog(); 238 EndDialog(GetHandle(), id); 239 break; 240 241 default: 242 TModalDlg::Dlg_OnCommand(GetHandle(), id, hwndCtl, codeNotify); 243 } 244 }; 245 //***************************************************************************** 246 247 //! Ueberpruefung der internen Abhaengigkeiten im Dialog 248 BOOL TCurveFreeScalDlg::CanClose(void) 249 { 250 float valueF; 251 int valueI; 252 BOOL bValid= TRUE; 253 254 //! eingegebene Intensitaeten und Farben auf Zulaessigkeit ueberpruefen 255 for (int i= 0;i < 8;i++) 256 { 257 valueF= CtrlGetDouble(GetBereichId(i), _BEREICHDIGITS, _DECIMAL, bValid); 258 if (!bValid) return FALSE; 259 else if (i == 0) 260 { 261 if (!(PlotWindow->LowerBound <= valueF)) 262 { 263 CtrlSetDouble(GetBereichId(i), PlotWindow->BSource->ber[i], _BEREICHDIGITS, _DECIMAL); 264 CtrlSetFocus(GetBereichId(i)); 265 MessageBox(szMsgLine301, szMessageDlg, MBINFO); 266 return FALSE; 267 } 268 else 269 PlotWindow->BSource->ber[i]= valueF; 270 } 271 else if (i == 7) 272 { 273 if (!(PlotWindow->UpperBound >= valueF) || 274 !(PlotWindow->BSource->ber[i - 1] <= valueF)) 275 { 276 CtrlSetDouble(GetBereichId(i), PlotWindow->BSource->ber[i], _BEREICHDIGITS, _DECIMAL); 277 CtrlSetFocus(GetBereichId(i)); 278 MessageBox(szMsgLine301, szMessageDlg, MBINFO); 279 return FALSE; 280 } 281 else 282 PlotWindow->BSource->ber[i]= valueF; 283 } 284 else if (!(PlotWindow->BSource->ber[i - 1] <= valueF)) 285 { 286 CtrlSetDouble(GetBereichId(i), PlotWindow->BSource->ber[i], _BEREICHDIGITS, _DECIMAL); 287 CtrlSetFocus(GetBereichId(i)); 288 MessageBox(szMsgLine301, szMessageDlg, MBINFO); 289 return FALSE; 290 } 291 else 292 PlotWindow->BSource->ber[i]= valueF; 293 294 valueI= CtrlGetLong( GetFarbeId(i), bValid ); 295 if (!bValid) return FALSE; 296 else if (i == 0) 297 { 298 if (!(0 <= valueI)) 299 { 300 CtrlSetLong(GetFarbeId(i), PlotWindow->BSource->farbe[i]); 301 CtrlSetFocus(GetFarbeId(i)); 302 MessageBox(szMsgLine300, szMessageDlg, MBINFO); 303 return FALSE; 304 } 305 else 306 PlotWindow->BSource->farbe[i]= valueI; 307 } 308 else if (i == 7) 309 { 310 if (!(255 >= valueI) || 311 !(PlotWindow->BSource->farbe[i - 1] <= valueI)) 312 { 313 CtrlSetLong(GetFarbeId(i), PlotWindow->BSource->farbe[i]); 314 CtrlSetFocus(GetFarbeId(i)); 315 MessageBox(szMsgLine300, szMessageDlg, MBINFO); 316 return FALSE; 317 } 318 else 319 PlotWindow->BSource->farbe[i]= valueI; 320 } 321 else if (!(PlotWindow->BSource->farbe[i - 1] <= valueI)) 322 { 323 CtrlSetLong(GetFarbeId(i), PlotWindow->BSource->farbe[i]); 324 CtrlSetFocus(GetFarbeId(i)); 325 MessageBox(szMsgLine300, szMessageDlg, MBINFO); 326 return FALSE; 327 } 328 else 329 PlotWindow->BSource->farbe[i]= valueI; 330 } 331 332 PlotWindow->EnablePaint(); 333 //! Farbverteilung neu berechnen 334 PlotWindow->BSource->ColorDef(); 335 PlotWindow->BSource->UserFarb->UpdateWnd(); 336 return TRUE; 337 }; 338 //***************************************************************************** 339 340 void TCurveFreeScalDlg::LeaveDialog(void) 341 { 342 PlotWindow->EnablePaint(); 343 }; 344 345 //############################################################################## 346 // TCurveShowParamDlg 347 //############################################################################## 348 349 TCurveShowParamDlg::TCurveShowParamDlg(TPlotWindow *aPlotWindow) : TModalDlg( "DATASHOWPARAM", GetMainInstance() ), PlotWindow(0), hWndOutputT(0), hWndScaleT(0), hWndScrolldx(0), hWndScrolldy(0) 350 { 351 PlotWindow= aPlotWindow; 352 scrolldxpos= scrolldypos= 0; 353 bSavedSecondaryCoor= FALSE; 354 }; 355 //***************************************************************************** 356 357 BOOL TCurveShowParamDlg::Dlg_OnInit(HWND, HWND hwndCtl, LPARAM lParam) 358 //! initialisiert den Modaldialog fuer Visualising Options - Fehler 7,8,13 359 { 360 BOOL id= 0; 361 char buf[50]; 362 BOOL bValid= TRUE; 363 364 hWndOutputT= Ctrl(id_ShowDataType); 365 hWndScaleT= Ctrl(id_ScaleTypeY); 366 hWndScrolldy= Ctrl(id_Bar); 367 hWndScrolldx= Ctrl(id_Bar2); 368 369 scrolldypos= PlotWindow->RLdy; 370 scrolldxpos= PlotWindow->RLdx; 371 372 SCROLLINFO scrInfo; 373 scrInfo.cbSize= sizeof(SCROLLINFO); 374 scrInfo.fMask= SIF_RANGE | SIF_POS; 375 376 scrInfo.nMin= PlotWindow->scrolldyposmin; 377 scrInfo.nMax= PlotWindow->scrolldyposmax; 378 scrInfo.nPos= scrolldypos; 379 SetScrollInfo(hWndScrolldy, SB_CTL, &scrInfo, TRUE); 380 381 scrInfo.nMin= PlotWindow->scrolldxposmin; 382 scrInfo.nMax= PlotWindow->scrolldxposmax; 383 scrInfo.nPos= scrolldxpos; 384 SetScrollInfo(hWndScrolldx, SB_CTL, &scrInfo, TRUE); 385 386 //! Combobox fuer Darstellungsart 387 if ( PlotWindow->WindowType != wtScan ) 388 { 389 ComboBox_AddString(hWndOutputT, aOutputType[0]); // RL-Bitmap (nur AreaScan) 390 ComboBox_AddString(hWndOutputT, aOutputType[1]); // Raw-Bitmap (nur AreaScan) 391 } 392 ComboBox_AddString(hWndOutputT, aOutputType[2]); // Kurve (immer) 393 394 ComboBox_SelectString(hWndOutputT, 0, aOutputType[(PlotWindow->eOutputType - 1)]); 395 ComboBox_AddString(hWndScaleT, aScaleType[0]); 396 ComboBox_AddString(hWndScaleT, aScaleType[1]); 397 ComboBox_AddString(hWndScaleT, aScaleType[2]); 398 399 //! Intensitaetsskalierung User nur fuer Bitmaps gueltig 400 switch ( PlotWindow->eOutputType ) { 401 case otReciprokeLatticeBitmap: 402 case otMatrixBitmap: 403 ComboBox_SelectString(hWndScaleT, 0, aScaleType[(PlotWindow->CoorSys.zScal - 1)]); 404 CtrlSetEnabled(cm_UserScal, TRUE); 405 break; 406 407 default: 408 ComboBox_SelectString(hWndScaleT, 0, aScaleType[(PlotWindow->CoorSys.yScal - 1)]); 409 ComboBox_DeleteString(hWndScaleT, 2); 410 CtrlSetEnabled(cm_UserScal, FALSE); 411 } 412 413 // bei RL-Bitmap nur Winkeldarstellung 414 bSavedSecondaryCoor= PlotWindow->bSecondaryCoor; 415 if ( PlotWindow->eOutputType==otReciprokeLatticeBitmap ) PlotWindow->bSecondaryCoor= FALSE; 416 417 //! betrifft Kanaele und Winkel 418 CtrlSetChecked(id_X_Scala, !PlotWindow->bSecondaryCoor); //! Winkel 419 CtrlSetChecked(id_Z_Scala, PlotWindow->bSecondaryCoor); //! Kanaele 420 //! wenn kein PSD-Device als Detektor, dann Fkt. oder Energyspektrum aktiv: nicht waehlbar 421 CtrlSetEnabled(id_X_Scala, PlotWindow->CanSwitchChannelAngle()); 422 CtrlSetEnabled(id_Z_Scala, PlotWindow->CanSwitchChannelAngle()); 423 424 //! falls Intensitaeten im Dialog nicht gesetzt, mache dies 425 if ( !CtrlGetText(id_MaxIntensity, (LPSTR)buf, 10) ) 426 { 427 CtrlSetDouble(id_MaxIntensity, PlotWindow->UpperBound, _MAXINTENSITYDIGITS, _DECIMAL); 428 CtrlSetDouble(id_MinIntensity, PlotWindow->LowerBound, _MININTENSITYDIGITS, _DECIMAL); 429 } 430 431 //! falls dy nicht gueltig, setze dy 432 if ( !CtrlGetText(id_dy1, buf, 1) ) { 433 CtrlSetLong( id_dy1, PlotWindow->RLdy); 434 CtrlSetFocus(id_dy1); 435 } 436 437 //! falls dx nicht gueltig, setze dx 438 if ( !CtrlGetText(id_dx1, buf, 1) ) { 439 CtrlSetLong(id_dx1, PlotWindow->RLdx); 440 CtrlSetFocus(id_dx1); 441 } 442 443 //! falls tilesx leer, setze 444 if ( !CtrlGetText(id_tilesx, buf, 1) ) { 445 CtrlSetLong(id_tilesx, PlotWindow->tilesx); 446 CtrlSetFocus(id_tilesx); 447 } 448 449 //! falls tilesy leer, setze 450 if ( !CtrlGetText(id_tilesy, buf, 1) ) { 451 CtrlSetLong(id_tilesy, PlotWindow->tilesy); 452 CtrlSetFocus(id_tilesy); 453 } 454 455 //! groessere Punkte, xy Skalierung, y Punkte 456 CtrlSetChecked(id_Dilatation, PlotWindow->bIncreasePP); 457 CtrlSetChecked(id_XY_Scaling, PlotWindow->bXY_Scaling); 458 459 //! Graustufen Checkbox setzen 460 if (PlotWindow->BSource != NULL) 461 CtrlSetChecked(id_Graustufen, PlotWindow->BSource->bGrayScalePalette); 462 463 //! hier geaendert, da die Fkt nur fuer RL-Bitmap gueltig sind 464 CtrlSetEnabled(id_XY_Scaling, PlotWindow->eOutputType==otReciprokeLatticeBitmap); //! <= MatrixBitmap 465 466 BOOL bEnable= ( PlotWindow->eOutputType==otReciprokeLatticeBitmap || PlotWindow->eOutputType==otMatrixBitmap ); 467 CtrlSetEnabled(id_dy1, bEnable); 468 CtrlSetEnabled(id_dx1, bEnable); 469 CtrlSetEnabled(id_Bar, bEnable); 470 CtrlSetEnabled(id_Bar2, bEnable); 471 CtrlSetEnabled(id_Dilatation, bEnable); 472 CtrlSetEnabled(id_Graustufen, bEnable); 473 474 // gepunktete Kurven? 475 CtrlSetChecked(id_Dotted, PlotWindow->m_Dotted); 476 CtrlSetEnabled(id_Dotted, PlotWindow->eOutputType==otCurve); 477 478 // Filter verwenden? 479 CtrlSetChecked( id_Filter, PlotWindow->m_HasFilter ); 480 CtrlSetEnabled( id_Filter, PlotWindow->eOutputType==otCurve ); 481 CtrlSetEnabled( id_FilterStrength, ( PlotWindow->eOutputType==otCurve && PlotWindow->m_HasFilter ) ); 482 CtrlSetDouble( id_FilterStrength, PlotWindow->m_FilterStrength, 1, _DECIMAL ); 483 return TRUE; 484 }; 485 //***************************************************************************** 486 487 void TCurveShowParamDlg::Dlg_OnHScrollBar(HWND, HWND hwndctl, UINT code, int pos) 488 { 489 //! Fehler 7,8 490 //! dies nur, um laestige Warnungen auszuschalten... 491 TModalDlg::Dlg_OnHScrollBar(GetHandle(), hwndctl, code, pos); 492 493 SCROLLINFO scrInfo; 494 scrInfo.cbSize= sizeof(SCROLLINFO); 495 scrInfo.fMask= SIF_POS; 496 497 if (hwndctl == hWndScrolldy) 498 { 499 switch (code) 500 { 501 case SB_LINEUP: 502 case SB_PAGEUP: 503 if (scrolldypos > PlotWindow->scrolldyposmin) 504 { 505 scrolldypos -= 50; 506 PlotWindow->RLdy= scrolldypos; 507 scrInfo.nPos= scrolldypos; 508 SetScrollInfo(hWndScrolldy, SB_CTL, &scrInfo, TRUE); 509 CtrlSetLong(id_dy1, PlotWindow->RLdy); 510 } 511 break; 512 513 case SB_LINEDOWN: 514 case SB_PAGEDOWN: 515 if (scrolldypos < PlotWindow->scrolldyposmax) 516 { 517 scrolldypos += 50; 518 PlotWindow->RLdy= scrolldypos; 519 scrInfo.nPos= scrolldypos; 520 SetScrollInfo(hWndScrolldy, SB_CTL, &scrInfo, TRUE); 521 CtrlSetLong(id_dy1, PlotWindow->RLdy); 522 } 523 break; 524 } 525 } 526 527 if (hwndctl == hWndScrolldx) 528 { 529 switch (code) 530 { 531 case SB_LINEUP: 532 case SB_PAGEUP: 533 if (scrolldxpos > PlotWindow->scrolldxposmin) 534 { 535 scrolldxpos -= 50; 536 PlotWindow->RLdx= scrolldxpos; 537 scrInfo.nPos= scrolldxpos; 538 SetScrollInfo(hWndScrolldx,SB_CTL,&scrInfo,TRUE); 539 CtrlSetLong(id_dx1, PlotWindow->RLdx); 540 } 541 break; 542 543 case SB_LINEDOWN: 544 case SB_PAGEDOWN: 545 if (scrolldxpos < PlotWindow->scrolldxposmax) 546 { 547 scrolldxpos += 50; 548 PlotWindow->RLdx= scrolldxpos; 549 scrInfo.nPos= scrolldxpos; 550 SetScrollInfo(hWndScrolldx,SB_CTL,&scrInfo,TRUE); 551 CtrlSetLong(id_dx1, PlotWindow->RLdx); 552 } 553 break; 554 } 555 } 556 }; 557 //***************************************************************************** 558 559 void TCurveShowParamDlg::Dlg_OnCommand(HWND, int id, HWND hwndCtl, UINT codeNotify) 560 { 561 //! behandelt das Untermenü Visualising Options und reagiert auf 562 //! Änderungen in Menüeinträgen mit entsprechenden Reaktionen - Fehler 7,8,13 563 switch (id) 564 { 565 case cm_UserScal: { //! betrifft Button User Skalierung 566 PlotWindow->UpdateWnd(); 567 TModalDlg *dlg= (TCurveFreeScalDlg *)new TCurveFreeScalDlg(PlotWindow); 568 if ( dlg ) dlg->ExecuteDialog(GetHandle()); 569 _FREEOBJ(dlg); 570 PlotWindow->UpdateWnd(); 571 break; 572 } 573 574 case cm_SetupParameters: //! betrifft Button "Neuzeichnen" 575 CanClose(); 576 PlotWindow->UpdateWnd(); 577 break; 578 579 case IDOK: //! IDOK wird abgefangen, da ein "Enter" auch ein IDOK liefert...aber hier Beenden des Dialogs unerwuenscht, aber Aktualisierung der Darstellung erfolgt 580 CanClose(); 581 PlotWindow->UpdateWnd(); 582 break; 583 584 case id_Standard: //! id_Standard wird abgefangen, aufgerufen durch den OK-Button 585 CanClose(); 586 PlotWindow->UpdateWnd(); 587 LeaveDialog(); 588 EndDialog(GetHandle(), id); 589 break; 590 591 case IDCANCEL: 592 LeaveDialog(); 593 EndDialog(GetHandle(), id); 594 break; 595 596 case id_Filter: 597 CtrlSetEnabled(id_FilterStrength, CtrlIsChecked(id_Filter)); 598 break; 599 /*case id_ScaleTypeY: 600 if (codeNotify==CBN_SELCHANGE) { 601 retval= ComboBox_GetCurSel(hWndScaleT); 602 if (retval != CB_ERR) switch (retval+1) { 603 case Logarithmic: 604 case Linear: 605 CtrlSetEnabled(id_MaxIntensity,TRUE); 606 CtrlSetEnabled(id_MinIntensity,TRUE); 607 break; 608 609 case User: 610 CtrlSetEnabled(id_MaxIntensity,FALSE); 611 CtrlSetEnabled(id_MinIntensity,FALSE); 612 break; 613 } 614 } 615 break*/ 616 617 case id_X_Scala: 618 bSavedSecondaryCoor= FALSE; 619 break; 620 621 case id_Z_Scala: 622 bSavedSecondaryCoor= TRUE; 623 break; 624 625 //! betrifft Combobox zur Auswahl der Darstellungsart 626 //! hier geaendert, da die Fkt nur fuer RL-Bitmap gueltig sind 627 //! nur fuer RL-Bitmap werden Menupunkte xy Skalierung, y-Punkte, 628 //! groessere Punkte sichtbar 629 case id_ShowDataType: 630 if (codeNotify == CBN_SELCHANGE) 631 { 632 if (PlotWindow->WindowType == wtScan) 633 break; 634 int retvalT= ComboBox_GetCurSel(hWndOutputT); 635 if (retvalT == CB_ERR) 636 break; 637 switch (retvalT + 1) 638 { 639 case otReciprokeLatticeBitmap: 640 CtrlSetEnabled(id_Dotted, FALSE); 641 CtrlSetEnabled(id_Filter, FALSE); 642 CtrlSetEnabled(id_FilterStrength, FALSE); 643 CtrlSetEnabled(id_Dilatation, TRUE); 644 CtrlSetEnabled(id_XY_Scaling, TRUE); 645 CtrlSetEnabled(id_Graustufen, TRUE); 646 CtrlSetEnabled(id_dy1, TRUE); 647 CtrlSetEnabled(id_Bar, TRUE); 648 CtrlSetEnabled(id_dx1, TRUE); 649 CtrlSetEnabled(id_Bar2, TRUE); 650 if (ComboBox_FindString(hWndScaleT, 0, aScaleType[sUser - 1]) == CB_ERR) 651 ComboBox_AddString(hWndScaleT, aScaleType[sUser - 1]); 652 break; 653 654 case otMatrixBitmap: 655 CtrlSetEnabled(id_Dotted, FALSE); 656 CtrlSetEnabled(id_Filter, FALSE); 657 CtrlSetEnabled(id_FilterStrength, FALSE); 658 CtrlSetEnabled(id_Dilatation, TRUE); 659 CtrlSetEnabled(id_XY_Scaling, FALSE); 660 CtrlSetEnabled(id_Graustufen, TRUE); 661 CtrlSetEnabled(id_dy1, TRUE); 662 CtrlSetEnabled(id_Bar, TRUE); 663 CtrlSetEnabled(id_dx1, TRUE); 664 CtrlSetEnabled(id_Bar2, TRUE); 665 if (ComboBox_FindString(hWndScaleT, 0, aScaleType[sUser - 1]) == CB_ERR) 666 ComboBox_AddString(hWndScaleT, aScaleType[sUser - 1]); 667 break; 668 669 case otCurve: 670 CtrlSetEnabled(id_Dotted, TRUE); 671 CtrlSetEnabled(id_Filter, TRUE); 672 CtrlSetEnabled(id_FilterStrength, CtrlIsChecked(id_Filter)); 673 CtrlSetEnabled(id_Dilatation, FALSE); 674 CtrlSetEnabled(id_XY_Scaling, FALSE); 675 CtrlSetEnabled(id_Graustufen, FALSE); 676 CtrlSetEnabled(id_dy1, FALSE); 677 CtrlSetEnabled(id_Bar, FALSE); 678 CtrlSetEnabled(id_dx1, FALSE); 679 CtrlSetEnabled(id_Bar2, FALSE); 680 int retval= ComboBox_GetCurSel(hWndScaleT); 681 if ( (retval != CB_ERR) && (retval + 1 == sUser) ) 682 { 683 PlotWindow->CoorSys.yScal= sLogarithmic; 684 ComboBox_SelectString(hWndScaleT, 0, aScaleType[sLogarithmic - 1]); 685 break; 686 } 687 if (ComboBox_FindString(hWndScaleT, 0, aScaleType[sUser - 1]) != CB_ERR) 688 ComboBox_DeleteString(hWndScaleT, sUser - 1); 689 break; 690 } // switch (retval+1) 691 if ( retvalT+1 == otReciprokeLatticeBitmap ) { // bei RL-Bitmap nur Winkeldarstellung 692 bSavedSecondaryCoor= CtrlIsChecked(id_Z_Scala); 693 CtrlSetChecked(id_X_Scala, TRUE); //! Winkel 694 CtrlSetChecked(id_Z_Scala, FALSE); //! Kanaele 695 CtrlSetEnabled(id_X_Scala, FALSE); 696 CtrlSetEnabled(id_Z_Scala, FALSE); 697 } else { 698 //! betrifft Kanaele und Winkel 699 CtrlSetChecked(id_X_Scala, !bSavedSecondaryCoor); //! Winkel 700 CtrlSetChecked(id_Z_Scala, bSavedSecondaryCoor); //! Kanaele 701 //! wenn kein PSD-Device als Detektor, dann Fkt. oder Energyspektrum aktiv: nicht waehlbar 702 EOutputType temp= PlotWindow->eOutputType; 703 PlotWindow->eOutputType= otCurve; // für CanSwitchChannelAngle 704 CtrlSetEnabled(id_X_Scala, PlotWindow->CanSwitchChannelAngle()); 705 CtrlSetEnabled(id_Z_Scala, PlotWindow->CanSwitchChannelAngle()); 706 PlotWindow->eOutputType= temp; 707 } 708 } // codeNotify==CBN_SELCHANGE 709 break; 710 711 default: 712 TModalDlg::Dlg_OnCommand(GetHandle(), id, hwndCtl, codeNotify); 713 } // switch (id) 714 }; 715 //***************************************************************************** 716 717 BOOL TCurveShowParamDlg::CanClose(void) 718 //! bereitet Daten zum Schliessen oder Neuzeichnen des Plotwindows auf 719 //! Fehler 7,8,9,10,13 720 { 721 BOOL result= TRUE; 722 float valueF; 723 BOOL id= 0; 724 BOOL bValid; 725 726 //! waehle Ausgabetyp und setze Parameter entsprechend 727 int retval= ComboBox_GetCurSel(hWndOutputT); 728 if ( retval!=CB_ERR && PlotWindow->WindowType!=wtScan ) switch (1 + retval) 729 { 730 case otReciprokeLatticeBitmap: 731 if (Main.AreaScanWindow != PlotWindow) 732 break; 733 734 CtrlSetEnabled(cm_UserScal, TRUE); 735 PlotWindow->eOutputType= otReciprokeLatticeBitmap; 736 PlotWindow->CoorSys.yScal= sLinear; 737 retval= 1 + ComboBox_GetCurSel(hWndScaleT); 738 if (retval == 1) 739 PlotWindow->CoorSys.zScal= sLogarithmic; 740 else if (retval == 2) 741 PlotWindow->CoorSys.zScal= sLinear; 742 else 743 PlotWindow->CoorSys.yScal= sUser; 744 break; 745 746 case otMatrixBitmap: 747 if (Main.AreaScanWindow != PlotWindow) 748 break; 749 750 CtrlSetEnabled(cm_UserScal, TRUE); 751 PlotWindow->eOutputType= otMatrixBitmap; 752 PlotWindow->CoorSys.yScal= sLinear; 753 retval= 1 + ComboBox_GetCurSel(hWndScaleT); 754 if (retval == 1) 755 PlotWindow->CoorSys.zScal= sLogarithmic; 756 else if (retval == 2) 757 PlotWindow->CoorSys.zScal= sLinear; 758 else 759 PlotWindow->CoorSys.yScal= sUser; 760 break; 761 762 case otCurve: 763 CtrlSetEnabled(cm_UserScal, FALSE); 764 PlotWindow->eOutputType= otCurve; 765 retval= 1 + ComboBox_GetCurSel(hWndScaleT); 766 if (retval == 1) 767 PlotWindow->CoorSys.yScal= sLogarithmic; 768 else if (retval == 2) 769 PlotWindow->CoorSys.yScal= sLinear; 770 break; 771 } // switch 772 773 //! erzeuge neues TBitmapSourceObjekt wenn noetig 774 if (PlotWindow->eOutputType==otReciprokeLatticeBitmap || PlotWindow->eOutputType==otMatrixBitmap) 775 { 776 if ( !PlotWindow->BSource ) new TBitmapSource(PlotWindow); // registriert sich selbst für dieses Fenster 777 } 778 779 PlotWindow->DisablePaint(); 780 781 //! bewirkt ob an der Abzisse Kanaele oder Winkel abgetragen... 782 PlotWindow->bSecondaryCoor= CtrlIsChecked(id_Z_Scala); 783 784 // bei RL-Bitmap nur Winkeldarstellung 785 if ( PlotWindow->eOutputType==otReciprokeLatticeBitmap ) PlotWindow->bSecondaryCoor= FALSE; 786 787 //! betrifft Kanaele und Winkel 788 CtrlSetChecked(id_X_Scala, !PlotWindow->bSecondaryCoor); //! Winkel 789 CtrlSetChecked(id_Z_Scala, PlotWindow->bSecondaryCoor); //! Kanaele 790 //! wenn kein PSD-Device als Detektor, dann Fkt. oder Energyspektrum aktiv: nicht waehlbar 791 CtrlSetEnabled(id_X_Scala, PlotWindow->CanSwitchChannelAngle()); 792 CtrlSetEnabled(id_Z_Scala, PlotWindow->CanSwitchChannelAngle()); 793 794 //! hier werden Felder id_tilesx, id_tilesy abgefragt 795 valueF= CtrlGetLong(id_tilesx, bValid); 796 if ( bValid && 2<=valueF && valueF<=15 ) PlotWindow->tilesx= valueF; 797 else { 798 CtrlSetLong(id_tilesx, PlotWindow->tilesx); 799 CtrlSetFocus(id_tilesx); 800 result= FALSE; 801 if ( bValid ) { 802 MessageBox(szMsgLine306, szMessageDlg, MBINFO); 803 return FALSE; 804 } else MessageBeep(0); 805 } 806 807 valueF= CtrlGetLong(id_tilesy, bValid); 808 if ( bValid && 2<=valueF && valueF<=15 ) PlotWindow->tilesy= valueF; 809 else { 810 CtrlSetLong(id_tilesy, PlotWindow->tilesy); 811 CtrlSetFocus(id_tilesy); 812 result= FALSE; 813 if ( bValid ) { 814 MessageBox(szMsgLine305, szMessageDlg, MBINFO); 815 return FALSE; 816 } else MessageBeep(0); 817 } 818 819 //! hier jetzt Abfrage der Min und Max Werte fuer Intensitaeten 820 //! es werden nur zulaessige Intensitaeten zugelassen 821 //! die hier setzt bei keinen Werten im Fenster Werte entsprechend 822 valueF= CtrlGetDouble(id_MaxIntensity, _MAXINTENSITYDIGITS, _DECIMAL, bValid); 823 if ( bValid && valueF<=PlotWindow->MaxIntensitaet ) PlotWindow->UpperBound= valueF; 824 else { 825 CtrlSetDouble(id_MaxIntensity, PlotWindow->UpperBound, _MAXINTENSITYDIGITS, _DECIMAL); 826 CtrlSetFocus(id_MaxIntensity); 827 result= FALSE; 828 if ( bValid ) { 829 MessageBox(szMsgLine304, szMessageDlg, MBINFO); 830 return FALSE; 831 } else MessageBeep(0); 832 } 833 834 valueF= CtrlGetDouble(id_MinIntensity, _MININTENSITYDIGITS, _DECIMAL, bValid); 835 if ( bValid && valueF>=PlotWindow->MinIntensitaet ) PlotWindow->LowerBound= valueF; 836 else { 837 CtrlSetDouble(id_MinIntensity, PlotWindow->LowerBound, _MININTENSITYDIGITS, _DECIMAL); 838 CtrlSetFocus(id_MinIntensity); 839 MessageBox(szMsgLine302, szMessageDlg, MBINFO); 840 return FALSE; 841 } 842 if (PlotWindow->LowerBound >= PlotWindow->UpperBound) 843 { 844 PlotWindow->UpperBound= PlotWindow->MaxIntensitaet; 845 PlotWindow->LowerBound= PlotWindow->MinIntensitaet; 846 CtrlSetDouble(id_MaxIntensity, PlotWindow->UpperBound, _MAXINTENSITYDIGITS, _DECIMAL); 847 CtrlSetDouble(id_MinIntensity, PlotWindow->LowerBound, _MININTENSITYDIGITS, _DECIMAL); 848 MessageBox(szMsgLine303, szMessageDlg, MBINFO); 849 return FALSE; 850 } 851 852 //! pruefe CheckButtons "groessere Punkte", "x-y Skalierung" 853 PlotWindow->bIncreasePP= CtrlIsChecked(id_Dilatation); 854 PlotWindow->bXY_Scaling= CtrlIsChecked(id_XY_Scaling); 855 856 if (PlotWindow->BSource != NULL) 857 PlotWindow->BSource->bGrayScalePalette= CtrlIsChecked(id_Graustufen); 858 859 //! waehle Intensitätsskalierung und setze Parameter entsprechend 860 retval= ComboBox_GetCurSel(hWndScaleT); 861 if (retval != CB_ERR) 862 { 863 switch (retval + 1) 864 { 865 case sLogarithmic: 866 if ( PlotWindow->eOutputType==otReciprokeLatticeBitmap || PlotWindow->eOutputType==otMatrixBitmap ) 867 { 868 PlotWindow->CoorSys.zScal= sLogarithmic; 869 PlotWindow->CoorSys.yScal= sLinear; 870 } 871 else 872 PlotWindow->CoorSys.yScal= sLogarithmic; 873 break; 874 875 case sLinear: 876 PlotWindow->CoorSys.yScal= sLinear; 877 PlotWindow->CoorSys.zScal= sLinear; 878 break; 879 880 case sUser: 881 if ( PlotWindow->eOutputType==otReciprokeLatticeBitmap || PlotWindow->eOutputType==otMatrixBitmap ) 882 { 883 PlotWindow->CoorSys.zScal= sUser; 884 PlotWindow->CoorSys.yScal= sLinear; 885 } 886 else 887 PlotWindow->CoorSys.yScal= sUser; 888 break; 889 } 890 } 891 892 //! wenn irgendein Bitmap, muss aktualisiert werden... 893 HCURSOR hOldCursor= SetDefaultCursor( IDC_WAIT ); 894 if ( PlotWindow->eOutputType==otReciprokeLatticeBitmap || PlotWindow->eOutputType==otMatrixBitmap ) 895 { 896 //! zu Fehler 12 897 PlotWindow->Screen.dy= stdy; 898 PlotWindow->Screen.dx= stdx; 899 900 PlotWindow->BSource->FormatDBaseToBitmapSource(); 901 } 902 SetCursor(hOldCursor); // restore cursor before waiting cursor 903 904 // gepunktete Kurven? 905 PlotWindow->m_Dotted= CtrlIsChecked(id_Dotted); 906 // Kurven-Filter an? 907 PlotWindow->m_HasFilter= CtrlIsChecked(id_Filter); 908 // Wert trotzdem immer uebernehmen 909 BOOL aValid; 910 PlotWindow->m_FilterStrength= CtrlGetDouble(id_FilterStrength, 1, _DECIMAL, aValid); 911 PlotWindow->EnablePaint(); 912 913 return result; 914 }; 915 //***************************************************************************** 916 917 void TCurveShowParamDlg::LeaveDialog(void) 918 { 919 //! der Name sagt alles... 920 //! wird im Falle von Dlg_OnCommand --> (IDOK), IDABORT und IDCANCEL aufgerufen 921 //! in dlg_tpl.cpp, was zu tun fuer Nachricht IDOK selbst neu definiert 922 /* if(PlotWindow->eOutputType <= MatrixBitmap) 923 { 924 CoorSys= &PlotWindow->CoorSys; 925 CoorSys->yScal= CoorSys->xScal= Linear; 926 }*/ 927 PlotWindow->EnablePaint(); 928 }; 929 930 //############################################################################## 931 // TBitmapSource 932 //############################################################################## 933 934 //! Konstruktor TBitmapSource 935 TBitmapSource::TBitmapSource(TPlotWindow *aPlotWindow) : ber(8, 0.0), farbe(8, 0), m_Daten(0), PlotWindow(0), hDIBInfo(0), hDIBData(0), hMemPal(0), hPalette(0), hOldPalette(0), hBitmap(0) 936 { 937 char Ident[]= "AreaScan"; 938 //! int cnt=0,cnt1=0; 939 //! Stellt die Funktionalitaet der Darstellung von Kurven und der Bewertung 940 //! dieser Kurven bereit - Klasse TPlotWindow 941 PlotWindow= aPlotWindow; 942 PlotWindow->BSource= this; 943 944 m_DatenRows= m_DatenCols= 0; 945 m_DatenInited= false; 946 947 UserFarb= NULL; 948 //15.05.2004 PlotWindow->xBorder= 80; //! der Rand zur y-Achse im Bitmap (alter Wert 40) 949 //15.05.2004 PlotWindow->yBorder= 40; //! der Rand zur x-Achse im Bitmap (alter Wert 26) 950 951 /*30.06.2004 dies hier rausgenommen, da eOutputType zu Anfang immer RL-Bitmap und nicht wie vorgesehen dem Menueintrag im Modaldialog entspricht! - Fehler 11 952 switch (PlotWindow->eOutputType) 953 { 954 case ReciprokeLatticeBitmap: 955 case MatrixBitmap: 956 break; 957 958 default: 959 PlotWindow->eOutputType= ReciprokeLatticeBitmap; 960 }*/ 961 BMCoorSys= &PlotWindow->AltCoorSys; 962 *BMCoorSys= PlotWindow->CoorSys; // überschreibt PlotWindow->AltCoorSys mit PlotWindow->CoorSys 963 // Kullmann, Reinecker: ATOS-Testfall MS.2 Fehlerbehebung PlotWindow->bAltCoorSystem= TRUE; 964 BMCoorSys->xScal= BMCoorSys->yScal= sLinear; 965 BMCoorSys->zScal= sLogarithmic; 966 hDIBInfo= NULL; 967 hDIBData= NULL; 968 hMemPal= NULL; 969 970 for (int i=0; i<RLAreaPkts; i++) { 971 RLArea[i].x= RLArea[i].y= 0; 972 } 973 974 BereichDef(); // <ber> und <farbe> initialisieren 975 ColorDef(); // <ColorTable> initialisieren 976 977 //! wenn gewuenscht kann sw-Palette im ini-File angegeben werden 978 bGrayScalePalette= GetPrivateProfileInt(Ident, "swPalette", 0, GetCFile()); 979 980 strcpy(Fileold, ""); 981 }; 982 //***************************************************************************** 983 984 //! setzt Variablenfelder farbe[] und ber[] 985 //! so dass ein linearer Verlauf abhaengig von Min-,MaxIntensitaet 986 void TBitmapSource::BereichDef(void) 987 { 988 float bereich1, bereich2; 989 bereich1= PlotWindow->UpperBound - PlotWindow->LowerBound; 990 bereich1= bereich1 / 9; 991 bereich2= ColorTable.ColorMap.GetCount() / 9; 992 for (int i= 0; i<8; i++) 993 { 994 ber[i]= PlotWindow->LowerBound + (i + 1) * bereich1; 995 farbe[i]= (i + 1) * bereich2; 996 } 997 } 998 //***************************************************************************** 999 1000 //! dies hier entspricht einer Angabe von Leveln im ini-File 1001 //! um Intensitaetsabstufungen im User Falle zu generieren 1002 //! ansonsten werden Defaultwerte gesetzt 1003 //! dies aber nur im Zusammenhang mit Bitmaps sinnvoll 1004 void TBitmapSource::ColorDef(void) 1005 { 1006 //! schon mal vorinitialisiert, damit nix schief geht 1007 int i= 0, cnt; 1008 1009 for (cnt= 0; cnt<ColorTable.ColorMap.GetCount(); cnt++) 1010 ColorTable.ColorMap.SetAt(cnt, 255); 1011 1012 //! in ColorTable.ColorMap[0...GetCount()-1] wird jeder Farbe ein bestimmter 1013 //! Intensitaetswert zugewiesen 1014 1015 float zaehl= 0, bereich1, bereich2; 1016 1017 bereich1= ber[i] - PlotWindow->LowerBound; 1018 bereich2= farbe[i] - 0; 1019 bereich1= bereich1 / bereich2; 1020 for (cnt= 0; cnt<farbe[i]; cnt++) 1021 { 1022 ColorTable.ColorMap.SetAt(cnt, PlotWindow->LowerBound + zaehl * bereich1); 1023 zaehl++; 1024 } 1025 1026 zaehl= 0; 1027 for (i= 0; i<7; i++) 1028 { 1029 bereich1= ber[i + 1] - ber[i]; 1030 bereich2= farbe[i + 1] - farbe[i]; 1031 bereich1= bereich1 / bereich2; 1032 for (cnt= farbe[i]; cnt<=farbe[i + 1]; cnt++) 1033 { 1034 ColorTable.ColorMap.SetAt(cnt, ber[i] + zaehl * bereich1); 1035 zaehl++; 1036 } 1037 zaehl= 0; 1038 } 1039 1040 i= 7; 1041 bereich1= PlotWindow->UpperBound - ber[i]; 1042 bereich2= 255 - farbe[i]; 1043 bereich1= bereich1 / bereich2; 1044 for (cnt= farbe[i]; cnt<ColorTable.ColorMap.GetCount(); cnt++) 1045 { 1046 ColorTable.ColorMap.SetAt(cnt, ber[i] + zaehl * bereich1); 1047 zaehl++; 1048 } 1049 } 1050 //***************************************************************************** 1051 1052 //! Destruktor TBitmapSource 1053 TBitmapSource::~TBitmapSource() 1054 { 1055 if (hDIBData) 1056 HeapFree(GetProcessHeap(),0,hDIBData); 1057 hDIBData= 0; 1058 1059 if (hDIBInfo) 1060 HeapFree(GetProcessHeap(),0,hDIBInfo); 1061 hDIBInfo= 0; 1062 1063 if (hMemPal) 1064 HeapFree(GetProcessHeap(),0,hMemPal); 1065 hMemPal= 0; 1066 1067 if (hBitmap) 1068 DeleteObject(hBitmap); 1069 hBitmap= NULL; 1070 1071 _FREEOBJ(UserFarb); // Dialog verstecken, falls sichtbar 1072 FreeDaten(); 1073 // Kullmann, Reinecker: ATOS-Testfall MS.2 Fehlerbehebung bAltCoorSystem= FALSE; 1074 // 15.05.2004 PlotWindow->xBorder= XBNorm; 1075 // 15.05.2004 PlotWindow->yBorder= YBNorm; 1076 }; 1077 //***************************************************************************** 1078 1079 void TBitmapSource::CreateDaten(UINT aRows, UINT aCols) { 1080 // zuerst alte Daten freigeben 1081 FreeDaten(); 1082 1083 //! SCHRITT 1: ZEILEN. 1084 m_Daten= new TBMContens * [aRows]; 1085 if ( !m_Daten ) 1086 { 1087 MessageBox(GetFocus(), "Speicherreservierung der Zeilen fehlgeschlagen!", "CreateDaten", MBINFO ); 1088 exit(-1); 1089 } 1090 //! SCHRITT 2: SPALTEN. 1091 for (int r= 0; r<aRows ;r++) 1092 { 1093 m_Daten[r]= new TBMContens[aCols]; 1094 if ( !m_Daten[r] ) { 1095 MessageBox(GetFocus(), "Speicherreservierung einer Spalte fehlgeschlagen!", "CreateDaten", MBINFO ); 1096 exit(-1); 1097 } 1098 } 1099 1100 // m_DatenCols und m_DatenRows fuer SetOmega, SetTheta, SetIntens setzen 1101 m_DatenCols= aCols; 1102 m_DatenRows= aRows; 1103 1104 //! IRGENDEINE INITIALISIERUNG 1105 for (r= 0; r<aRows; r++) 1106 { 1107 for (int c= 0; c<aCols; c++) 1108 { 1109 SetOmega (r, c, r*r - c*c); 1110 SetTheta (r, c, r*r - c*c); 1111 SetIntens(r, c, r*r - c*c); 1112 } 1113 char buf[_MAXLENDOUBLE]; 1114 sprintf(buf, "%d % vorinitialisiert", 100 * r / aRows); 1115 SetInfo(buf); 1116 } 1117 1118 //! auf FALSE setzen, weil "Daten"feld neu initialisiert werden muss 1119 m_DatenInited= false; 1120 } 1121 //***************************************************************************** 1122 1123 bool TBitmapSource::CheckKoord(UINT &aRow, UINT &aCol) { 1124 bool result= true; // alles O.K. 1125 if ( aRow>=m_DatenRows ) { 1126 if ( m_DatenRows ) aRow= m_DatenRows-1; 1127 result= false; 1128 TraceErr("ZEILE!!! Die angegebene Zeile ueberschreitet das Maximum!."); 1129 } 1130 if ( aCol>=m_DatenCols ) { 1131 if ( m_DatenCols ) aCol= m_DatenCols-1; 1132 result= false; 1133 TraceErr("SPALTE!!! Die angegebene Spalte ueberschreitet das Maximum!."); 1134 } 1135 return result; 1136 } 1137 //***************************************************************************** 1138 1139 void TBitmapSource::FreeDaten() { 1140 if ( !m_Daten ) return; // fertig 1141 1142 for (int r= 0; r<m_DatenRows; r++) 1143 _FREELIST(m_Daten[r]); //! SCHRITT 1: SPALTEN LOESCHEN 1144 _FREELIST(m_Daten); //! Schritt 2: ZEILEN LOESCHEN 1145 1146 m_DatenRows= 0; 1147 m_DatenCols= 0; 1148 m_DatenInited= false; 1149 } 1150 1151 //***************************************************************************** 1152 1153 float TBitmapSource::GetOmega(UINT aRow, UINT aCol) { 1154 if ( !IsDatenInited() ) { 1155 TraceErr("DATEN!!! Diese Bitmap ist uninitilisiert!."); 1156 if ( !m_DatenRows || !m_DatenCols ) return 0; // es kann kein "vorinitialisierter"-Wert zurückgegeben werden 1157 } 1158 CheckKoord(aRow, aCol); // ggf. auf das Ende gesetzt 1159 return m_Daten[aRow][aCol].omega; 1160 } 1161 float TBitmapSource::GetTheta(UINT aRow, UINT aCol) { 1162 if ( !IsDatenInited() ) { 1163 TraceErr("DATEN!!! Diese Bitmap ist uninitilisiert!."); 1164 if ( !m_DatenRows || !m_DatenCols ) return 0; // es kann kein "vorinitialisierter"-Wert zurückgegeben werden 1165 } 1166 CheckKoord(aRow, aCol); // ggf. auf das Ende gesetzt 1167 return m_Daten[aRow][aCol].theta; 1168 } 1169 float TBitmapSource::GetIntens(UINT aRow, UINT aCol) { 1170 if ( !IsDatenInited() ) { 1171 TraceErr("DATEN!!! Diese Bitmap ist uninitilisiert!."); 1172 if ( !m_DatenRows || !m_DatenCols ) return 0; // es kann kein "vorinitialisierter"-Wert zurückgegeben werden 1173 } 1174 CheckKoord(aRow, aCol); // ggf. auf das Ende gesetzt 1175 return m_Daten[aRow][aCol].intens; 1176 } 1177 //***************************************************************************** 1178 1179 bool TBitmapSource::SetOmega(UINT aRow, UINT aCol, float aValue) { 1180 //if ( !CheckKoord(aRow, aCol) ) return false; 1181 m_Daten[aRow][aCol].omega= aValue; 1182 return true; 1183 } 1184 bool TBitmapSource::SetTheta(UINT aRow, UINT aCol, float aValue) { 1185 //if ( !CheckKoord(aRow, aCol) ) return false; 1186 m_Daten[aRow][aCol].theta= aValue; 1187 return true; 1188 } 1189 bool TBitmapSource::SetIntens(UINT aRow, UINT aCol, float aValue) { 1190 //if ( !CheckKoord(aRow, aCol) ) return false; 1191 m_Daten[aRow][aCol].intens= aValue; 1192 return true; 1193 } 1194 //***************************************************************************** 1195 1196 void TBitmapSource::New(void) 1197 { 1198 if (hDIBData != NULL) 1199 HeapFree(GetProcessHeap(),0,hDIBData); 1200 hDIBData= NULL; 1201 1202 if (hDIBInfo != NULL) 1203 HeapFree(GetProcessHeap(),0,hDIBInfo); 1204 hDIBInfo= NULL; 1205 }; 1206 //***************************************************************************** 1207 1208 /* derzeit nicht verwendet 17.05.2004 1209 // DIB-Datei lesen 1210 //! soll ein Bitmapfile einlesen, stuerzt aber ab, weil Screen nicht initialisiert 1211 BOOL TBitmapSource::ProcessBitmapFile(HFILE hStream) 1212 { 1213 BITMAPINFOHEADER bmInfoHeader; 1214 LPBITMAPINFO lpBMPInfo; 1215 int nColors; 1216 DWORD memsize; 1217 HPBYTE hpData; 1218 TScreen &Screen= PlotWindow->Screen; 1219 1220 // File-Header lesen 1221 BITMAPFILEHEADER BMPFileHdr; 1222 _lread(hStream, &BMPFileHdr, sizeof(BMPFileHdr)); 1223 if (BMPFileHdr.bfType != *(UINT*)"BM") 1224 return FALSE; // Ausstieg bei falschem Marker 1225 // BITMAPINFOHEADER Struktur einlesen 1226 _lread(hStream, &bmInfoHeader, sizeof(bmInfoHeader)); 1227 if (bmInfoHeader.biSize != sizeof(BITMAPINFOHEADER)) 1228 return FALSE; // Ausstieg bei falscher Groeße 1229 // Wenn Anzahl benutzter Farben im Header stehen ... 1230 if (bmInfoHeader.biClrUsed == 0) { // aus Bittiefe erechnen 1231 if (bmInfoHeader.biBitCount != 24) 1232 nColors= 1 << bmInfoHeader.biBitCount; 1233 else 1234 nColors= 0; 1235 bmInfoHeader.biClrUsed= nColors; 1236 } else nColors= (int)bmInfoHeader.biClrUsed; // direkte Angabe verwenden 1237 // ggf. biSizeImage nachtragen 1238 GetImageSize(); 1239 // Speicher fuer Bitmapinfo + Farbpalette anfordern 1240 memsize= sizeof(BITMAPINFO) + (nColors - 1) * sizeof(RGBQUAD); 1241 if (hDIBInfo) 1242 hDIBInfo= HeapReAlloc(GetProcessHeap(), 0, hDIBInfo, memsize); 1243 else 1244 hDIBInfo= (HGLOBAL)HeapAlloc(GetProcessHeap(), 0, memsize); 1245 if (!hDIBInfo) 1246 return FALSE; 1247 lpBMPInfo= (LPBITMAPINFO)hDIBInfo; 1248 // Header kopieren 1249 lpBMPInfo->bmiHeader= bmInfoHeader; 1250 // Farbtabelle lesen 1251 _lread(hStream, lpBMPInfo->bmiColors, sizeof(RGBQUAD)*nColors); 1252 // Speicher fuer die eigentliche Bitmap anfordern, einlesen 1253 if (hDIBData) 1254 hDIBData= HeapReAlloc(GetProcessHeap(),0, hDIBData, bmInfoHeader.biSizeImage); 1255 else 1256 hDIBData= (HGLOBAL)HeapAlloc(GetProcessHeap(),0,bmInfoHeader.biSizeImage); 1257 1258 Screen.dx= (int)bmInfoHeader.biWidth; 1259 Screen.dy= (int)bmInfoHeader.biHeight; 1260 1261 if (!hDIBData) 1262 return FALSE; 1263 hpData= (HPBYTE)hDIBData; 1264 _hread(hStream, hpData, bmInfoHeader.biSizeImage); 1265 PlotWindow->eOutputType= otMatrixBitmap; 1266 if (hBitmap) 1267 DeleteObject(hBitmap); 1268 hBitmap= NULL; 1269 return TRUE; 1270 }; 1271 //***************************************************************************** */ 1272 1273 //! berechnet Bytes pro Zeile*Hoehe des Bitmaps= Gesamtgroesse im Speicher 1274 DWORD TBitmapSource::GetImageSize(void) 1275 { 1276 DWORD nBits; 1277 LPBITMAPINFOHEADER lpBMPInfoHdr; 1278 LPBITMAPINFO lpBMPInfo; 1279 1280 if (!hDIBInfo) 1281 return 1; 1282 lpBMPInfo= (LPBITMAPINFO)hDIBInfo; 1283 lpBMPInfoHdr= &lpBMPInfo->bmiHeader; 1284 nBits= ((lpBMPInfoHdr->biWidth * lpBMPInfoHdr->biBitCount + 31) 1285 / 32) * 4; // Bytes pro Zeile, Aufrunden auf DWords 1286 nBits *= (DWORD)lpBMPInfoHdr->biHeight + 1; //! zur Sicherheit eine Zeile mehr... 1287 lpBMPInfoHdr->biSizeImage= nBits; 1288 return nBits; 1289 }; 1290 //***************************************************************************** 1291 1292 //! // einigermaßen gleichmaeßigverteilte Standardpalette erzeugen 1293 LOGPALETTE *TBitmapSource::CreateDefaultPalette(void) 1294 { 1295 int i; 1296 int size= sizeof(LOGPALETTE) + ColorTable.ColorMap.GetCount() * sizeof(PALETTEENTRY); 1297 LOGPALETTE *pPal= (LOGPALETTE *)new char[size]; 1298 memset(pPal, 0, size); 1299 pPal->palVersion= 0x300; 1300 pPal->palNumEntries= ColorTable.ColorMap.GetCount(); 1301 PALETTEENTRY *pEntry= pPal->palPalEntry; 1302 if (bGrayScalePalette) 1303 { 1304 //! grayscale palette 1305 for (i= 0; i<ColorTable.ColorMap.GetCount(); i++) 1306 { 1307 pEntry->peRed= 255 - i; 1308 pEntry->peGreen= 255 - i; 1309 pEntry->peBlue= 255 - i; 1310 pEntry->peFlags= 0; 1311 pEntry++; 1312 } 1313 } 1314 //! ansonsten Farbverlauf mit 256 Farben 1315 else 1316 { 1317 // Farbe 0 1318 pEntry->peRed= 255; 1319 pEntry->peGreen= 255; 1320 pEntry->peBlue= 255; 1321 pEntry->peFlags= 0; 1322 pEntry++; 1323 1324 for (i= 0;i <= 49;i++) 1325 { // Farbe 1 .. 50 1326 pEntry->peRed= 255; 1327 pEntry->peGreen= (255 - 5 * i); 1328 pEntry->peBlue= 0; 1329 pEntry->peFlags= 0; 1330 pEntry++; 1331 } 1332 1333 for (i= 0;i <= 49;i++) 1334 { // Farbe 51..100 1335 pEntry->peRed= 255; 1336 pEntry->peGreen= 0; 1337 pEntry->peBlue= (5 * i); 1338 pEntry->peFlags= 0; 1339 pEntry++; 1340 } 1341 for (i= 0;i <= 49;i++) 1342 { // Farbe 101..150 1343 pEntry->peRed= (255 - 5 * i); 1344 pEntry->peGreen= 0; 1345 pEntry->peBlue= 255; 1346 pEntry->peFlags= 0; 1347 pEntry++; 1348 } 1349 for (i= 0;i <= 49;i++) 1350 { // Farbe 151..200 1351 pEntry->peRed= 0; 1352 pEntry->peGreen= (5 * i); 1353 pEntry->peBlue= 255; 1354 pEntry->peFlags= 0; 1355 pEntry++; 1356 } 1357 for (i= 0;i <= 49;i++) 1358 { // Farbe 201..250 1359 pEntry->peRed= 0; 1360 pEntry->peGreen= 255; 1361 pEntry->peBlue= (255 - 5 * i); 1362 pEntry->peFlags= 0; 1363 pEntry++; 1364 } 1365 for (i= 0;i <= 4;i++) 1366 { // Farbe 251..254 1367 pEntry->peRed= (160 - 10 * i * i); 1368 pEntry->peGreen= (160 - 10 * i * i); 1369 pEntry->peBlue= (160 - 10 * i * i); 1370 pEntry->peFlags= 0; 1371 pEntry++; 1372 } 1373 } 1374 return pPal; 1375 }; 1376 //***************************************************************************** 1377 1378 //! generiert Palette aus DIB (Device independend Bitmap) 1379 LOGPALETTE *TBitmapSource::CreatePaletteFromDIB(void) 1380 { 1381 // Palette aus DIB erzeugen 1382 LOGPALETTE *pPalette; 1383 PALETTEENTRY *pEntry; 1384 RGBQUAD *pRGB; 1385 int cnt; 1386 short nColors; 1387 LPBITMAPINFO lpBMPInfo; 1388 1389 lpBMPInfo= (LPBITMAPINFO)hDIBInfo; 1390 if (!lpBMPInfo) 1391 return NULL; 1392 nColors= (short)lpBMPInfo->bmiHeader.biClrUsed; 1393 if (nColors == 0) 1394 { 1395 return CreateDefaultPalette(); 1396 } 1397 pPalette= (LOGPALETTE*)new char[sizeof(LOGPALETTE) + (nColors - 1) * sizeof(PALETTEENTRY)]; 1398 if (pPalette) 1399 { 1400 pPalette->palVersion= 0x300; 1401 pPalette->palNumEntries= nColors; 1402 pRGB= lpBMPInfo->bmiColors; 1403 pEntry= pPalette->palPalEntry; 1404 for (cnt= 0;cnt < nColors;cnt++) 1405 { 1406 pEntry->peRed= pRGB->rgbRed; 1407 pEntry->peGreen= pRGB->rgbGreen; 1408 pEntry->peBlue= pRGB->rgbBlue; 1409 pEntry->peFlags= 0; 1410 pRGB++; 1411 pEntry++; 1412 } 1413 } 1414 return pPalette; 1415 }; 1416 //***************************************************************************** 1417 1418 //! fuellt den Header eines Bitmaps mit Farbwerten der Palette 1419 void TBitmapSource::FillBMInfoFromPalette(LOGPALETTE *pPal) 1420 { 1421 PALETTEENTRY *pEntry; 1422 RGBQUAD *pRGB; 1423 int nColors, cnt; 1424 LPBITMAPINFO lpBMPInfo; 1425 1426 lpBMPInfo= (LPBITMAPINFO)hDIBInfo; 1427 pRGB= lpBMPInfo->bmiColors; 1428 pEntry= pPal->palPalEntry; 1429 nColors= min((WORD)lpBMPInfo->bmiHeader.biClrUsed, (WORD)pPal->palNumEntries); 1430 for (cnt= 0; cnt < nColors; cnt++) 1431 { 1432 pRGB->rgbRed= pEntry->peRed; 1433 pRGB->rgbGreen= pEntry->peGreen; 1434 pRGB->rgbBlue= pEntry->peBlue; 1435 pRGB++; 1436 pEntry++; 1437 } 1438 }; 1439 //***************************************************************************** 1440 1441 //! ruft CreatePaletteFromDIB(), ansonsten CreateDefaultPalette() 1442 LOGPALETTE * TBitmapSource::GetPalette(void) 1443 { 1444 LOGPALETTE *logPal; 1445 1446 logPal= CreatePaletteFromDIB(); 1447 if (!logPal) 1448 logPal= CreateDefaultPalette(); 1449 return logPal; 1450 }; 1451 //***************************************************************************** 1452 1453 //! function creates a device-dependent bitmap (DDB) from a device-independent 1454 //! bitmap (DIB) and, optionally, sets the bitmap bits 1455 HBITMAP TBitmapSource::CreateGDIObject(HDC hdc) 1456 { 1457 HPALETTE hPal, hDefPal; 1458 HPBYTE hpData; 1459 LPBITMAPINFO lpBMPInfo; 1460 1461 hPal= CreatePalette(GetPalette()); 1462 hDefPal= SelectPalette(hdc, hPal, FALSE); 1463 hpData= (HPBYTE)hDIBData; 1464 lpBMPInfo= (LPBITMAPINFO)hDIBInfo; 1465 RealizePalette(hdc); 1466 hBitmap= CreateDIBitmap(hdc, &lpBMPInfo->bmiHeader, CBM_INIT, hpData, lpBMPInfo, DIB_RGB_COLORS); 1467 SelectPalette(hdc, hDefPal, FALSE); 1468 DeleteObject(hPal); 1469 return hBitmap; 1470 }; 1471 //***************************************************************************** 1472 1473 //! gibt zu uebergebener Intensitaet entsprechende Intensitaetsfarbe zurueck 1474 int TBitmapSource::GetColor(float intens) 1475 { 1476 int ci; 1477 float fval; 1478 switch (BMCoorSys->zScal) 1479 { 1480 //! clogval= ColorTable.nColorRange / log10(BMCoorSys->zMax / BMCoorSys->zMin); 1481 //! clinval= (BMCoorSys->zMax - BMCoorSys->zMin); 1482 case sLogarithmic: 1483 if (intens < BMCoorSys->zMin) 1484 return 0; 1485 fval= log10(intens / BMCoorSys->zMin) * clogval; 1486 if (fval >= ColorTable.ColorMap.GetCount()) 1487 return ColorTable.ColorMap.GetCount()-1; // last Color should be black always 1488 1489 //! hab hier die zeile reingeschoben, zum runden - Fehler 2 1490 fval= floor(fval); 1491 return (int)fval; 1492 1493 case sLinear: 1494 //! fval= (intens - BMCoorSys->zMin) / clinval; Fehler 4 1495 //! hier wurden falsche Intesitaetswerte berechnet, da ColorRange nicht beachtet 1496 fval= ((intens - BMCoorSys->zMin) / clinval) * (ColorTable.ColorMap.GetCount()-1); 1497 if (fval < 0.0) 1498 return 0; 1499 if (fval >= ColorTable.ColorMap.GetCount()) 1500 return ColorTable.ColorMap.GetCount()-1; // last Color should be black always 1501 1502 //! hab hier die zeile reingeschoben, zum runden - Fehler 2 1503 fval= floor(fval); 1504 return (int)fval; 1505 1506 case sUser: 1507 for (ci= 0; ci<ColorTable.ColorMap.GetCount(); ci++) 1508 { 1509 if (ColorTable.ColorMap[ci] < intens) 1510 continue; 1511 return ci; 1512 } 1513 break; 1514 } 1515 return ColorTable.ColorMap.GetCount()-1; // last Color should be black always 1516 }; 1517 //***************************************************************************** 1518 1519 //! Bitblock-Transfer von hMemDC (dem gegebenen Quell-DC) 1520 //! zu diesem HDC (dem Ziel-DC) - entspricht der Darstellung eines Bitmaps 1521 void TBitmapSource::DrawBitmap(HDC hdc, int ofsx, int ofsy, TScreen &Screen) 1522 { 1523 SetScreen(hdc, Screen); 1524 SetMapMode(hdc, MM_TEXT); 1525 // Bitmap-Handle holen 1526 if ( !hBitmap) 1527 hBitmap= CreateGDIObject(hdc); 1528 1529 // Bitmap ausgeben 1530 HDC hMemDC= CreateCompatibleDC(hdc); 1531 HGDIOBJ OldBitmap= SelectObject(hMemDC, hBitmap); 1532 SetMapMode(hMemDC, MM_TEXT); 1533 BitBlt(hdc, Screen.x0 + ofsx, Screen.y0 + ofsy, Screen.dx, Screen.dy, hMemDC, 0, 0, SRCCOPY); 1534 1535 // GDI aufraeumen 1536 SelectObject(hMemDC, OldBitmap); 1537 DeleteDC(hMemDC); 1538 }; 1539 //***************************************************************************** 1540 1541 //! ruft bei RL_Bitmap DrawMeasurementArea() 1542 //! berechnet Position der Anordnung der Farblegende 1543 //! setzt Min,MaxIntensitaeten 1544 //! ruft DrawColorTable() 1545 void TBitmapSource::DrawBitmapFrame(HDC hdc, TScreen &Screen) 1546 { 1547 SetScreen(hdc, Screen); 1548 1549 // Frame zeichnen 1550 switch (PlotWindow->eOutputType) 1551 { 1552 case otReciprokeLatticeBitmap: 1553 case otMatrixBitmap: 1554 DrawMeasurementArea(hdc); 1555 break; 1556 } 1557 1558 // Struktur CTable fuellen 1559 ColorTable.place.left= Screen.x0 + Screen.dx + 20; 1560 ColorTable.place.right= ColorTable.place.left + 30; 1561 ColorTable.place.bottom= Screen.y0 - 30; 1562 ColorTable.place.top= ColorTable.place.bottom + (ColorTable.ColorMap.GetCount()-1) * 2; 1563 ColorTable.zMin= BMCoorSys->zMin; 1564 ColorTable.zMax= BMCoorSys->zMax; 1565 strcpy(ColorTable.zUnit, "Intensity"); 1566 DrawColorTable(hdc, ColorTable); 1567 }; 1568 //***************************************************************************** 1569 1570 //! setzt Screen-Variablen, entsprechend der Bildschirmgroesse 1571 //! setzt Units, Orientation, Scaling 1572 void TBitmapSource::SetScreen(HDC hdc, TScreen& screen) 1573 //! hier wird der Screen innerhalb des Koordinatensystems gemeint 1574 { 1575 SIZE tagS; 1576 POINT tagP; 1577 RECT rect; 1578 int dx, dy; 1579 1580 TScreen &Screen= PlotWindow->Screen; 1581 // Bestimmen der Ausdehnung in Pixeln des Zeichen-Fensters 1582 GetClientRect(PlotWindow->GetHandle(), (LPRECT)&rect); 1583 // Daten-Bereich festlegen 1584 //! wenn nicht initialisiert, setzt Standardwerte 1585 if ( !Screen.dx || !Screen.dy ) 1586 { 1587 Screen.dx= stdx; 1588 Screen.dy= stdy; 1589 MessageBox(GetFocus(), "Screen (1)", "Message", MBINFO); 1590 } 1591 1592 dx= (rect.right - rect.left); 1593 dy= (rect.bottom - rect.top); 1594 screen.x0= 0; 1595 screen.x1= dx; 1596 screen.y0= 0; 1597 screen.y1= dy; 1598 1599 //! Functions to specify the units, orientation, and scaling that you want 1600 SetMapMode(hdc, MM_ANISOTROPIC); 1601 SetWindowExtEx(hdc, dx + PlotWindow->xBorder, dy + PlotWindow->yBorder, &tagS); 1602 SetViewportExtEx(hdc, dx + PlotWindow->xBorder, -(dy + PlotWindow->yBorder), &tagS); 1603 SetWindowOrgEx(hdc, 0, 0, &tagP); 1604 SetViewportOrgEx(hdc, PlotWindow->xBorder, dy - PlotWindow->yBorder, &tagP); 1605 }; 1606 //***************************************************************************** 1607 1608 //! berechnet zu den Intensitäten entsprechende Farbwerte und zeichnet die Farb-Legende 1609 void TBitmapSource::DrawColorTable(HDC hdc, TColorTable &ct) 1610 { 1611 int cnt, fs= 14; 1612 int xl, yt, xr, yb, red, green, blue; 1613 float intens, sf; 1614 char buf[30]; 1615 LOGPALETTE *pPal; 1616 LOGFONT lf; 1617 PALETTEENTRY *pPE; 1618 HBRUSH hBrush, hOldBrush; 1619 HPEN hPen, hOldPen; 1620 HFONT hFont, hOldFont; 1621 POINT aPoints[5]; 1622 SIZE tagS; 1623 1624 //! ruft CreatePaletteFromDIB oder im Fehlerfall CreateDefaultPalette 1625 pPal= GetPalette(); 1626 1627 pPE= pPal->palPalEntry; 1628 1629 switch (BMCoorSys->zScal) 1630 { 1631 case sLinear: 1632 sf= (BMCoorSys->zMax - BMCoorSys->zMin) / (float)(ct.ColorMap.GetCount()-1); 1633 break; 1634 1635 case sLogarithmic: 1636 sf= (float)(ct.ColorMap.GetCount()-1) / log10(BMCoorSys->zMax / BMCoorSys->zMin); 1637 break; 1638 } 1639 1640 // Font selektieren 1641 memset(&lf, 0, sizeof(LOGFONT)); 1642 lf.lfHeight= fs; 1643 lf.lfWidth= 0; 1644 lf.lfWeight= 200; 1645 lf.lfUnderline= FALSE; 1646 strcpy(lf.lfFaceName, "Times New Roman"); 1647 hFont= CreateFontIndirect(&lf); 1648 hOldFont= (HFONT)SelectObject(hdc, hFont); 1649 xl= ct.place.left; 1650 xr= ct.place.right; 1651 1652 //! durchlaeuft die for-Schleife fuer alle Farben und 1653 //! traegt die Intensitaeten in das Rechteck ein 1654 1655 for (cnt= 0; cnt<ct.ColorMap.GetCount();cnt++) 1656 { 1657 red= pPE[cnt].peRed; 1658 green= pPE[cnt].peGreen; 1659 blue= pPE[cnt].peBlue; 1660 hBrush= CreateSolidBrush(RGB(red, green, blue)); 1661 hPen= CreatePen(PS_SOLID, 1, RGB(red, green, blue)); 1662 1663 if (!cnt) 1664 { 1665 hOldBrush= (HBRUSH)SelectObject(hdc, hBrush); 1666 hOldPen= (HPEN)SelectObject(hdc, hPen); 1667 } 1668 1669 SelectObject(hdc, hBrush); 1670 SelectObject(hdc, hPen); 1671 1672 switch (BMCoorSys->zScal) 1673 { 1674 //! berechene Intensitaetsverteilung je nachdem ob linear oder logarithmisch skalierter Verlauf 1675 case sLinear: 1676 intens= BMCoorSys->zMin + (float)cnt * sf; 1677 break; 1678 1679 case sLogarithmic: 1680 intens= pow((float)10, (float)cnt / sf) * BMCoorSys->zMin; 1681 break; 1682 1683 case sUser: //! hier User Intensitaetsverteilung hinzugefuegt 1684 intens= ct.ColorMap[cnt]; 1685 break; 1686 } 1687 1688 if (intens < 10.0) 1689 sprintf(buf, "I= %.3f", intens); 1690 else 1691 if (intens < 100.0) 1692 sprintf(buf, "I= %.2f", intens); 1693 else 1694 if (intens < 1000.0) 1695 sprintf(buf, "I= %.1f", intens); 1696 else 1697 sprintf(buf, "I > %.0f", intens); 1698 1699 //! hier angepasst, um Farbkreis als Intensitaetsskala auszugeben 1700 if ( PlotWindow->RLdy < 400 ) 1701 { 1702 yb= ct.place.bottom + cnt; 1703 yt= yb + 1; 1704 } 1705 else 1706 { 1707 yb= ct.place.bottom + cnt * 2; 1708 //! yt= (++yb) + bs; 1709 yt= yb + 2; 1710 } 1711 1712 //! the rectangle is outlined by using the current pen and filled 1713 //! by using the current brush 1714 //! zeichne einzelne Intensitaetsstufen 1715 Rectangle(hdc, xl, yt, xr, yb); 1716 1717 //! schreibe Intensitaeten mit vorher bestimmten Nachkommastellen aus 1718 if ( (PlotWindow->RLdy < 400 && !(cnt % 18)) || (PlotWindow->RLdy >= 400 && !(cnt % 9)) ) 1719 { 1720 SetTextAlign(hdc, TA_BOTTOM); 1721 GetTextExtentPoint(hdc, buf, strlen(buf), &tagS); 1722 TextOut(hdc, xr + 8, (yb + yt) / 2 - tagS.cy / 2, (LPSTR)buf, strlen(buf)); 1723 SelectObject(hdc, hOldPen); 1724 DeleteObject(hPen); 1725 //! zeichne kleine Orientierungslinie an Intensitaetsskala 1726 hPen= CreatePen(PS_SOLID, 1, RGB(0, 0, 0)); 1727 aPoints[0].y= aPoints[1].y= (yb + yt) / 2; 1728 aPoints[0].x= xr + 5; 1729 aPoints[1].x= xr; 1730 Polyline(hdc, aPoints, 2); 1731 SetTextAlign(hdc, TA_TOP); 1732 } 1733 1734 //! zum Schluss noch den Rand um die Intensitaetsskala zeichnen 1735 if (cnt == ct.ColorMap.GetCount()-1) // letzte Farbe= schwarz 1736 { 1737 SelectObject(hdc, hOldPen); 1738 DeleteObject(hPen); 1739 hPen= CreatePen(PS_SOLID, 1, RGB(0, 0, 0)); 1740 aPoints[0].x= aPoints[1].x= aPoints[4].x= xl; 1741 aPoints[0].y= aPoints[3].y= aPoints[4].y= ct.place.bottom; 1742 aPoints[1].y= aPoints[2].y= yt; 1743 aPoints[2].x= aPoints[3].x= xr; 1744 Polyline(hdc, aPoints, sizeof(aPoints) / sizeof(POINT)); 1745 } 1746 SelectObject(hdc, hOldBrush); 1747 DeleteObject(hBrush); 1748 SelectObject(hdc, hOldPen); 1749 DeleteObject(hPen); 1750 } //! while 1751 1752 SelectObject(hdc, hOldFont); 1753 DeleteObject(hFont); 1754 }; 1755 //***************************************************************************** 1756 1757 //! generiere MatrixBitmap 1758 void TBitmapSource::GenerateAngleSpaceBitmap(void) 1759 { 1760 char Msg[MaxString]; 1761 TCurve *Scan= lpDBase->GetCurve(0); 1762 // TCurve* ScanRep= lpDBase->GetScanReport(); 1763 UINT nScanNumber= lpDBase->GetCNumber(); 1764 // UINT nPointNumber= Scan->GetPNumber(); 1765 //! definiert in comhead.h typedef struct {float x, y;int Ord;} TKSystem[4]; 1766 TKSystem KS_AR; 1767 HPBYTE hpData; 1768 DWORD addr; 1769 int cnt, cx, cy, ival; 1770 float fIntens, dd; 1771 float imin= PlotWindow->MaxIntensitaet; 1772 float imax= PlotWindow->MinIntensitaet; 1773 TScreen &Screen= PlotWindow->Screen; 1774 1775 if (PlotWindow->eOutputType != otMatrixBitmap) 1776 return; 1777 //**************************************************************************** 1778 //**** Bitmap formatieren **************************************************** 1779 // get pointer to data area 1780 hpData= (HPBYTE)hDIBData; 1781 if (!hpData) 1782 { 1783 MessageBox(GetFocus(), "Cannot create memory object (2)", "Message", MBINFO); 1784 return; 1785 } 1786 // inquire intensity range 1787 //! ermittle Werte fuer Statuszeile - Intensity Range 1788 //! durchlaufe alle Scans und ermittle min und max... 1789 if (1 < nScanNumber) 1790 { 1791 int cy= nScanNumber; 1792 while (cy--) 1793 { 1794 Scan= lpDBase->GetCurve(cy); 1795 imin= min(Scan->GetMin(P_Y), imin); 1796 imax= max(Scan->GetMax(P_Y), imax); 1797 } 1798 } 1799 else 1800 //! hier fehlte vorher die Klammerung..., so dass imax sonst immer 1000 1801 //! Fehler3 1802 { 1803 imin= 0.1f; 1804 imax= 1000.0; 1805 } 1806 sprintf(Msg, szMsgLine307, imin, imax); 1807 1808 // compute cacheval for colormap 1809 switch (BMCoorSys->zScal) 1810 { 1811 case sLogarithmic: 1812 clogval= (float)(ColorTable.ColorMap.GetCount()-1) / log10(BMCoorSys->zMax / BMCoorSys->zMin); 1813 break; 1814 1815 case sLinear: 1816 case sUser: 1817 clinval= (BMCoorSys->zMax - BMCoorSys->zMin); 1818 break; 1819 } 1820 // Inquire measurement area 1821 PlotWindow->SetMeasurementArea(KS_AR); 1822 // sort ranges 1823 1824 //! Suche nach kleinstem KS_AR[*].y 1825 for (cnt= 1, ival= 0;cnt < 4;cnt++) 1826 if (KS_AR[cnt].y < KS_AR[ival].y) 1827 ival= cnt; 1828 BMCoorSys->yMin= KS_AR[ival].y; 1829 1830 //! Suche nach groesstem KS_AR[*].y 1831 for (cnt= 1, ival= 0;cnt < 4;cnt++) 1832 if (KS_AR[cnt].y > KS_AR[ival].y) 1833 ival= cnt; 1834 BMCoorSys->yMax= KS_AR[ival].y; 1835 1836 //! Suche nach kleinstem KS_AR[*].x 1837 for (cnt= 1, ival= 0;cnt < 4;cnt++) 1838 if (KS_AR[cnt].x < KS_AR[ival].x) 1839 ival= cnt; 1840 BMCoorSys->xMin= KS_AR[ival].x; 1841 1842 //! Suche nach groesstem KS_AR[*].x 1843 for (cnt= 1, ival= 0;cnt < 4;cnt++) 1844 if (KS_AR[cnt].x > KS_AR[ival].x) 1845 ival= cnt; 1846 BMCoorSys->xMax= KS_AR[ival].x; 1847 1848 // compute scaling factors 1849 BMCoorSys->xSF= (BMCoorSys->xMax - BMCoorSys->xMin) / Screen.dx; 1850 BMCoorSys->ySF= (BMCoorSys->yMax - BMCoorSys->yMin) / Screen.dy; 1851 1852 //! ab hier Berechnung des MatrixBitmap umgestellt, berechnet sich jetzt aehnlich 1853 //! wie ein RL-Bitmap 1854 1855 addr= cy= 0; 1856 TCurve* ScanRep= lpDBase->GetScanReport(); 1857 1858 //** draw points in bitmap source 1859 // 07.05.2004 ScanRep->FastOpen(); 1860 1861 float fOmega, fThetaPsd, fTheta; 1862 int rmx, rmy; 1863 BYTE nColor; 1864 BOOL bOutsideData= FALSE; 1865 1866 UINT nPointNumber= Scan->GetPNumber(); 1867 DWORD MaxAddr= GetImageSize()-1; 1868 1869 //! MaxAddr -= Screen.dx + 1; 1870 //! durchlaufe alle Zeilen 1871 1872 1873 for (cy= 0;cy < nScanNumber;cy++) 1874 { 1875 Scan= lpDBase->GetCurve(cy); 1876 Scan->SetPP(); 1877 // 07.05.2004 Scan->FastOpen(); 1878 ScanRep->SetPP(cy); 1879 1880 //! FastPGet(x,y,z) holt Werte der Kurve und setzt ActualIdx++ (m_curve.cpp) 1881 ScanRep->PGet(fOmega, dd, dd); // 07.05.2004 FastP... 1882 fTheta= PlotWindow->GetThetaOffset(cy); 1883 nPointNumber= Scan->GetPNumber(); 1884 if (!(cy % 30)) 1885 { 1886 sprintf(Msg, szMsgLine308, cy, nPointNumber); 1887 SetInfo(Msg); 1888 } 1889 //! durchlaufe alle Spalten 1890 for (cx= 0;cx < nPointNumber;cx++) 1891 { 1892 //! FastPGet(x,y,z) holt Werte der Kurve und setzt ActualIdx++ (m_curve.cpp) 1893 Scan->PGet(fThetaPsd, fIntens, dd); // 07.05.2004 FastP... 1894 //! hier mit PlotWindow->CoorSys.xMin gerechnet, da Theta und der ThetaOffset 1895 //! nicht in BMCoorSyseinheiten umgerechnet wurden und sich somit 1896 //! auf ein altes Koordinatensystem beziehen 1897 //! berechne Koordinaten des Pixels 1898 if (!PlotWindow->VisualDB.bPsd) 1899 fTheta= 0; 1900 rmx= (fThetaPsd + fTheta - BMCoorSys->xMin) / BMCoorSys->xSF; 1901 rmy= (fOmega - BMCoorSys->yMin) / BMCoorSys->ySF; 1902 1903 //! manchmal wird rmx>Screen.dx - Rundungsfehler! 1904 //! manchmal wird rmy>Screen.dy - Rundungsfehler! 1905 if (rmx > Screen.dx) 1906 rmx= Screen.dx; 1907 if (rmy > Screen.dy) 1908 rmy= Screen.dy; 1909 1910 //! berechne Adresse des Pixels im Bitmap 1911 addr= rmx + (DWORD)rmy * Screen.dx; 1912 //! hole Farbe des Pixels fuer aktuelle Intensitaet 1913 nColor= (short)GetColor(fIntens); 1914 1915 if (nColor == 0) 1916 continue; 1917 1918 if (addr > MaxAddr) 1919 { 1920 sprintf(Msg, "rmx %d rmy %d dx %d dy %d Omega %f Theta %f", rmx, rmy, Screen.dx, Screen.dy, fOmega, fTheta + fThetaPsd); 1921 MessageBox(GetFocus(), Msg, "Fehler/Error", MBSTOP); 1922 bOutsideData= TRUE; 1923 continue; 1924 } 1925 hpData[addr]= nColor; 1926 //! falls "Groessere Punkte" gewaehlt, wird Punkt kuenstlich vergroessert 1927 if ( !PlotWindow->bIncreasePP ) 1928 continue; 1929 if ( ((addr + 1) > MaxAddr) || ((addr + Screen.dx) > MaxAddr) || 1930 ((addr - 1) > MaxAddr) || ((addr - Screen.dx) > MaxAddr) ) 1931 continue; 1932 hpData[addr - 1]= nColor; 1933 hpData[addr + 1]= nColor; 1934 hpData[addr - Screen.dx]= nColor; 1935 hpData[addr + Screen.dx]= nColor; 1936 } 1937 // 07.05.2004 Scan->FastClose(); 1938 } 1939 sprintf(Msg, szMsgLine307, imin, imax); 1940 if (bOutsideData) strcat(Msg, szMsgLine310); 1941 1942 // 07.05.2004 ScanRep->FastClose(); 1943 SetInfo(Msg); 1944 }; 1945 //***************************************************************************** 1946 1947 //! falls RL-Bitmapdarstellung, berechnet und zeichnet 1948 //! das untersuchte Messgebiet im den reziproken Raum 1949 void TBitmapSource::DrawMeasurementArea(HDC hdc) 1950 { 1951 int dx, dy, cnt, ival; 1952 float dARx, dARy, mf; 1953 float fOmega, fTheta, offset; 1954 //! definiert in comhead.h typedef struct {float x, y;int Ord;} TKSystem[4]; 1955 TKSystem KS_AR, KS_RL; 1956 TCoorSystem coorsys; 1957 HPEN hOldPen, hPenDot; 1958 POINT egde[5]; 1959 float factor= M_PI / (0.5 * MeasurementParameter.GetWaveLength()); 1960 TScreen &Screen= PlotWindow->Screen; 1961 1962 //! zeichnen 2 Hilfslinien, um Measurementarea abzugrenzen 1963 if ( PlotWindow->eOutputType==otMatrixBitmap ) 1964 { 1965 hPenDot= CreatePen(PS_DOT, 1, RGB(255, 0, 0)); 1966 hOldPen= (HPEN)SelectObject(hdc, hPenDot); 1967 offset= PlotWindow->VisualDB.dThetaMinLast - PlotWindow->AltCoorSys.xMin; 1968 offset= offset / BMCoorSys->xSF; 1969 egde[0].x= Screen.x0; 1970 egde[0].y= Screen.y0; 1971 egde[1].x= Screen.x0 + offset; 1972 egde[1].y= Screen.y0 + Screen.dy; 1973 Polyline(hdc, egde, 2); 1974 egde[0].x= Screen.x0 + Screen.dx - offset; 1975 egde[0].y= Screen.y0; 1976 egde[1].x= Screen.x0 + Screen.dx; 1977 egde[1].y= Screen.y0 + Screen.dy; 1978 Polyline(hdc, egde, 2); 1979 SelectObject(hdc, hOldPen); 1980 DeleteObject(hPenDot); 1981 } 1982 else 1983 { 1984 PlotWindow->SetMeasurementArea(KS_AR); 1985 if ( !hBitmap ) 1986 { 1987 //! ::RLdy ist die y-Punkte Ausdehnung im Visualising Options Menu 1988 Screen.dy= PlotWindow->RLdy= max((WORD)0, min((WORD)700, PlotWindow->RLdy)); 1989 //! ::RLdx ist die x-Punkte Ausdehnung 1990 Screen.dx= ( (PlotWindow->RLdx+3) / 4) * 4; 1991 1992 PlotWindow->SetRanges(); 1993 BMCoorSys->zMax= PlotWindow->UpperBound; 1994 BMCoorSys->zMin= PlotWindow->LowerBound; 1995 switch (BMCoorSys->zScal) 1996 { 1997 case sLogarithmic: 1998 clogval= (float)(ColorTable.ColorMap.GetCount()-1) / log10(BMCoorSys->zMax / BMCoorSys->zMin); 1999 break; 2000 2001 case sLinear: 2002 case sUser: 2003 clinval= (BMCoorSys->zMax - BMCoorSys->zMin); 2004 break; 2005 } 2006 // compute new Coordinate system ranges 2007 for (cnt= 0;cnt < 4;cnt++) 2008 { 2009 KS_RL[cnt].x= ArToRLx (KS_AR[cnt].y, KS_AR[cnt].x); 2010 KS_RL[cnt].y= ArToRLy (KS_AR[cnt].y, KS_AR[cnt].x); 2011 KS_RL[cnt].Ord= -1; 2012 } 2013 // sort ranges 2014 for (cnt= 1, ival= 0;cnt < 4;cnt++) 2015 if (KS_RL[cnt].y < KS_RL[ival].y) 2016 ival= cnt; 2017 2018 BMCoorSys->yMin= KS_RL[ival].y; 2019 2020 for (cnt= 1, ival= 0;cnt < 4;cnt++) 2021 if (KS_RL[cnt].y > KS_RL[ival].y) 2022 ival= cnt; 2023 2024 BMCoorSys->yMax= KS_RL[ival].y; 2025 2026 for (cnt= 1, ival= 0;cnt < 4;cnt++) 2027 if (KS_RL[cnt].x < KS_RL[ival].x) 2028 ival= cnt; 2029 2030 BMCoorSys->xMin= KS_RL[ival].x; 2031 2032 for (cnt= 1, ival= 0;cnt < 4;cnt++) 2033 if (KS_RL[cnt].x > KS_RL[ival].x) 2034 ival= cnt; 2035 2036 BMCoorSys->xMax= KS_RL[ival].x; 2037 // compute scaling factors 2038 BMCoorSys->xSF= (BMCoorSys->xMax - BMCoorSys->xMin) / Screen.dx; 2039 BMCoorSys->ySF= (BMCoorSys->yMax - BMCoorSys->yMin) / Screen.dy; 2040 //** fix scale relation 2041 if (!PlotWindow->bXY_Scaling) 2042 { 2043 if (BMCoorSys->xSF < BMCoorSys->ySF) 2044 BMCoorSys->xSF= BMCoorSys->ySF; 2045 else 2046 BMCoorSys->ySF= BMCoorSys->xSF; 2047 } 2048 //! falls Aenderung von Werten, muss neu berechnet werden 2049 BMCoorSys->xMax= BMCoorSys->xMin + Screen.dx * BMCoorSys->xSF; 2050 BMCoorSys->yMax= BMCoorSys->yMin + Screen.dy * BMCoorSys->ySF; 2051 2052 //** center bitmap 2053 mf= (BMCoorSys->xMax - BMCoorSys->xMin) / BMCoorSys->xSF; 2054 mf= (Screen.dx - mf) / 2 * BMCoorSys->xSF; 2055 BMCoorSys->xMin -= mf; 2056 BMCoorSys->xMax -= mf; 2057 mf= (BMCoorSys->yMax - BMCoorSys->yMin) / BMCoorSys->ySF; 2058 mf= (Screen.dy - mf) / 2 * BMCoorSys->ySF; 2059 BMCoorSys->yMin -= mf; 2060 BMCoorSys->yMax -= mf; 2061 factor= M_PI / (0.5 * MeasurementParameter.GetWaveLength()); 2062 BMCoorSys->xSF *= factor; 2063 BMCoorSys->ySF *= factor; 2064 BMCoorSys->xMin *= factor; 2065 BMCoorSys->xMax *= factor; 2066 BMCoorSys->yMin *= factor; 2067 BMCoorSys->yMax *= factor; 2068 } 2069 // access the first coordinate structure to get angle koordinate system 2070 coorsys= *BMCoorSys; 2071 factor= (0.5 * MeasurementParameter.GetWaveLength()) / M_PI; 2072 coorsys.xSF *= factor; 2073 coorsys.ySF *= factor; 2074 coorsys.xMin *= factor; 2075 coorsys.xMax *= factor; 2076 coorsys.yMin *= factor; 2077 coorsys.yMax *= factor; 2078 // compute frame 2079 for (int pp= 0;pp < 4;pp++) 2080 { 2081 dARx= KS_AR[(pp + 1) % 4].x - KS_AR[pp].x; 2082 dARy= KS_AR[(pp + 1) % 4].y - KS_AR[pp].y; 2083 switch (pp) 2084 { 2085 case 0: 2086 dx= dy= 1; 2087 break; 2088 2089 case 1: 2090 dx= 1; 2091 dy= -1; 2092 break; 2093 2094 case 2: 2095 dx= dy= -1; 2096 break; 2097 2098 case 3: 2099 dx= -1; 2100 dy= 1; 2101 break; 2102 } 2103 for (cnt= pp * 10;cnt < (pp + 1) * 10; cnt++) 2104 { 2105 fOmega= KS_AR[pp].y + (cnt % 10) * (dARy / 10.0); 2106 fTheta= KS_AR[pp].x + (cnt % 10) * (dARx / 10.0); 2107 RLArea[cnt].x= (ArToRLx (fOmega, fTheta) - coorsys.xMin) / coorsys.xSF; 2108 RLArea[cnt].y= (ArToRLy (fOmega, fTheta) - coorsys.yMin) / coorsys.ySF; 2109 RLArea[cnt].x += dx; 2110 RLArea[cnt].y += dy; 2111 } 2112 } 2113 RLArea[RLAreaPkts-1]= RLArea[0]; 2114 hPenDot= CreatePen(PS_DOT, 1, RGB(255, 0, 0)); 2115 hOldPen= (HPEN)SelectObject(hdc, hPenDot); 2116 Polyline(hdc, RLArea, 41); 2117 SelectObject(hdc, hOldPen); 2118 DeleteObject(hPenDot); 2119 } 2120 }; 2121 //***************************************************************************** 2122 2123 //! generiere RL-Bitmap 2124 void TBitmapSource::GenerateRLBitmap(void) 2125 { 2126 int cnt, cx, cy, rlx, rly, ival; 2127 //! erste Kurve holen 2128 TCurve* Scan= lpDBase->GetCurve(0); 2129 //! ScanReport holen 2130 TCurve* ScanRep= lpDBase->GetScanReport(); 2131 //! Anzahl der Scans holen 2132 UINT nScanNumber= lpDBase->GetCNumber(); 2133 //! Anzahl der Punkte einer Kurve holen 2134 UINT nPointNumber= Scan->GetPNumber(); 2135 HPBYTE hpData; 2136 DWORD addr, MaxAddr= GetImageSize()-1; 2137 char Msg[MaxString]; 2138 float fOmega, fThetaPsd, fTheta, fIntens, dd, mf; 2139 TKSystem KS_RL, KS_AR; 2140 double fome, fthe, factor; 2141 BYTE nColor; 2142 BOOL bOutsideData= FALSE; 2143 TScreen &Screen= PlotWindow->Screen; 2144 2145 //! nur bei richtigem Darstellungstyp weitermachen 2146 if (PlotWindow->eOutputType != otReciprokeLatticeBitmap) 2147 return; 2148 2149 //**************************************************************************** 2150 //**** Bitmap formatieren **************************************************** 2151 //! Speicher fuer Bitmap reservieren 2152 // get pointer to data area 2153 hpData= (HPBYTE)hDIBData; 2154 if (!hpData) 2155 { 2156 2157 MessageBox(GetFocus(), "Cannot create memory object (2)", "Message", MBINFO); 2158 return; 2159 } 2160 // inquire intensity range 2161 float imin= PlotWindow->MaxIntensitaet; 2162 float imax= PlotWindow->MinIntensitaet; 2163 2164 if ( 1 < nScanNumber ) 2165 { 2166 int cy= nScanNumber; 2167 while (cy--) 2168 { 2169 2170 Scan= lpDBase->GetCurve(cy); 2171 imin= min(Scan->GetMin(P_Y), imin); 2172 imax= max(Scan->GetMax(P_Y), imax); 2173 } 2174 } 2175 else 2176 imin= imax= 0.0; 2177 2178 sprintf(Msg, szMsgLine307, imin, imax); 2179 2180 // compute cacheval for colormap 2181 switch (BMCoorSys->zScal) 2182 { 2183 case sLogarithmic: 2184 clogval= (float)(ColorTable.ColorMap.GetCount()-1) / log10(BMCoorSys->zMax / BMCoorSys->zMin); 2185 break; 2186 2187 case sLinear: 2188 case sUser: 2189 clinval= (BMCoorSys->zMax - BMCoorSys->zMin); 2190 break; 2191 } 2192 // transformate data 2193 // KS_AR,ArToRLx (x,y) : "x" means "theta" and "y" means "omega" 2194 // compute new Coordinate system ranges 2195 PlotWindow->SetMeasurementArea(KS_AR); 2196 2197 for (cnt= 0;cnt < 4;cnt++) 2198 { 2199 KS_RL[cnt].x= ArToRLx (KS_AR[cnt].y, KS_AR[cnt].x); 2200 KS_RL[cnt].y= ArToRLy (KS_AR[cnt].y, KS_AR[cnt].x); 2201 KS_RL[cnt].Ord= -1; 2202 } 2203 2204 // sort ranges 2205 //! Suche nach kleinstem KS_RL[*].y 2206 for (cnt= 1, ival= 0;cnt < 4;cnt++) 2207 if (KS_RL[cnt].y < KS_RL[ival].y) 2208 ival= cnt; 2209 BMCoorSys->yMin= KS_RL[ival].y; 2210 2211 2212 //! Suche nach groesstem KS_RL[*].y 2213 for (cnt= 1, ival= 0;cnt < 4;cnt++) 2214 if (KS_RL[cnt].y > KS_RL[ival].y) 2215 ival= cnt; 2216 BMCoorSys->yMax= KS_RL[ival].y; 2217 2218 2219 //! Suche nach kleinstem KS_RL[*].x 2220 for (cnt= 1, ival= 0;cnt < 4;cnt++) 2221 if (KS_RL[cnt].x < KS_RL[ival].x) 2222 ival= cnt; 2223 BMCoorSys->xMin= KS_RL[ival].x; 2224 2225 2226 //! Suche nach groesstem KS_RL[*].x 2227 for (cnt= 1, ival= 0;cnt < 4;cnt++) 2228 if (KS_RL[cnt].x > KS_RL[ival].x) 2229 ival= cnt; 2230 BMCoorSys->xMax= KS_RL[ival].x; 2231 2232 2233 //** compute scaling factors 2234 BMCoorSys->xSF= (BMCoorSys->xMax - BMCoorSys->xMin) / Screen.dx; 2235 BMCoorSys->ySF= (BMCoorSys->yMax - BMCoorSys->yMin) / Screen.dy; 2236 if (!PlotWindow->bXY_Scaling) 2237 { 2238 //** fix scale relation 2239 if (BMCoorSys->xSF < BMCoorSys->ySF) 2240 BMCoorSys->xSF= BMCoorSys->ySF; 2241 else 2242 BMCoorSys->ySF= BMCoorSys->xSF; 2243 } 2244 //! falls Aenderung von Werten, muss neu berechnet werden 2245 BMCoorSys->xMax= BMCoorSys->xMin + Screen.dx * BMCoorSys->xSF; 2246 BMCoorSys->yMax= BMCoorSys->yMin + Screen.dy * BMCoorSys->ySF; 2247 2248 //** center bitmap 2249 mf= (BMCoorSys->xMax - BMCoorSys->xMin) / BMCoorSys->xSF; 2250 mf= (Screen.dx - mf) / 2 * BMCoorSys->xSF; 2251 BMCoorSys->xMin -= mf; 2252 BMCoorSys->xMax -= mf; 2253 mf= (BMCoorSys->yMax - BMCoorSys->yMin) / BMCoorSys->ySF; 2254 mf= (Screen.dy - mf) / 2 * BMCoorSys->ySF; 2255 BMCoorSys->yMin -= mf; 2256 BMCoorSys->yMax -= mf; 2257 2258 //** draw points in bitmap source 2259 // 07.05.2004 ScanRep->FastOpen(); 2260 //! MaxAddr -= Screen.dx + 1; 2261 2262 //! hole den Filename der aktuellen Daten 2263 strcpy(Msg, PlotWindow->GetFileName()); 2264 //! Vergleich alter Filename - neuer Filename 2265 int filevgl= strcmp(Fileold, Msg); 2266 //! generiere neues "Daten"feld, wenn ... 2267 if ( !IsDatenInited() || m_DatenRows!=Screen.dy+1 || m_DatenCols!=Screen.dx+1 || filevgl ) 2268 { 2269 CreateDaten(Screen.dy+1, Screen.dx+1); 2270 //! alten Filenamen speichern 2271 strcpy(Fileold, PlotWindow->GetFileName()); 2272 } 2273 //! durchlaufe alle Zeilen 2274 for (cy= 0;cy < nScanNumber;cy++) 2275 { 2276 Scan= lpDBase->GetCurve(cy); 2277 Scan->SetPP(); 2278 // 07.05.2004 Scan->FastOpen(); 2279 ScanRep->SetPP(cy); 2280 2281 //! FastPGet(x,y,z) holt Werte der Kurve und setzt ActualIdx++ (m_curve.cpp) 2282 ScanRep->PGet(fOmega, dd, dd); // 07.05.2004 FastP... 2283 //! diese Unterscheidung, da 0-dim. andere Datenbasisspeicherung als 2284 //! 1-dim Areascans (ThetaOffset mitgespeichert/nichtgespeichert) 2285 if (PlotWindow->VisualDB.bPsd) 2286 fTheta= PlotWindow->GetThetaOffset(cy); 2287 else 2288 fTheta= 0; 2289 2290 nPointNumber= Scan->GetPNumber(); 2291 if (!(cy % 30)) 2292 { 2293 sprintf(Msg, szMsgLine308, cy, nPointNumber); 2294 SetInfo(Msg); 2295 } 2296 //! durchlaufe alle Spalten 2297 for (cx= 0; cx < nPointNumber; cx++) 2298 { 2299 2300 //! FastPGet(x,y,z) holt Werte der Kurve und setzt ActualIdx++ (m_curve.cpp) 2301 Scan->PGet(fThetaPsd, fIntens, dd); // 07.05.2004 FastP... 2302 //! Farbe des Pixels fuer die aktuelle Intensitaet holen 2303 nColor= (short)GetColor(fIntens); 2304 //! nach RAD transformieren, weil COS/SIN nur dort definiert 2305 2306 fthe= DegToRad(fTheta + fThetaPsd); 2307 fome= DegToRad(fOmega); 2308 2309 if ( nColor == 0 && IsDatenInited() ) 2310 continue; 2311 2312 //! in den reziproken Raum transformieren 2313 rlx= (ArToRLx (fome, fthe) - BMCoorSys->xMin) / BMCoorSys->xSF; 2314 rly= (ArToRLy (fome, fthe) - BMCoorSys->yMin) / BMCoorSys->ySF; 2315 2316 //! manchmal wird rlx>Screen.dx - Rundungsfehler! 2317 //! manchmal wird rly>Screen.dy - Rundungsfehler! 2318 if (rlx > Screen.dx) 2319 rlx= Screen.dx; 2320 if (rly > Screen.dy) 2321 rly= Screen.dy; 2322 2323 //! Adresse des Pixels im Bitmap berechnen 2324 addr= rlx + (DWORD)rly * Screen.dx; 2325 //! falls Adresse ausserhalb des Bitmaps liegt 2326 2327 if (addr > MaxAddr) 2328 { 2329 bOutsideData= TRUE; 2330 continue; 2331 } 2332 //! beim ersten Durchlauf "datenarray" aktualisieren 2333 if ( !IsDatenInited() ) 2334 { 2335 if (rlx > Screen.dx || rly > Screen.dy || rlx < 0 || rly < 0) 2336 { 2337 bOutsideData= TRUE; 2338 continue; 2339 } 2340 //! "Daten"feld neu initialisieren 2341 SetOmega(rly, rlx, fOmega); 2342 SetTheta(rly, rlx, fThetaPsd); 2343 } 2344 2345 hpData[addr]= nColor; 2346 if ( !PlotWindow->bIncreasePP ) 2347 continue; 2348 if ( ((addr + 1) > MaxAddr) || ((addr + Screen.dx) > MaxAddr) || 2349 ((addr - 1) > MaxAddr) || ((addr - Screen.dx) > MaxAddr) ) 2350 continue; 2351 hpData[addr - 1]= nColor; 2352 hpData[addr + 1]= nColor; 2353 hpData[addr - Screen.dx]= nColor; 2354 hpData[addr + Screen.dx]= nColor; 2355 } 2356 // 07.05.2004 Scan->FastClose(); 2357 } 2358 // nach erstmaligen Durchlauf der Schleifen ist "datenarray" initialisiert 2359 m_DatenInited= TRUE; 2360 2361 sprintf(Msg, szMsgLine307, imin, imax); 2362 if (bOutsideData) strcat(Msg, szMsgLine310); 2363 2364 // 07.05.2004 ScanRep->FastClose(); 2365 factor= M_PI / (0.5 * MeasurementParameter.GetWaveLength()); 2366 BMCoorSys->xSF *= factor; 2367 BMCoorSys->ySF *= factor; 2368 BMCoorSys->xMin *= factor; 2369 BMCoorSys->xMax *= factor; 2370 BMCoorSys->yMin *= factor; 2371 BMCoorSys->yMax *= factor; 2372 SetInfo(Msg); 2373 }; 2374 //***************************************************************************** 2375 2376 //! generiert den Header fuer ein Bitmap, setzt Koordinatensystem und Screen 2377 void TBitmapSource::FormatDBaseToBitmapSource(void) 2378 { 2379 //! char Ident[]= "AreaScan"; 2380 LPBITMAPINFOHEADER lpBMPInfoHdr; 2381 LPBITMAPINFO lpBMPInfo; 2382 LOGPALETTE *palette; 2383 DWORD dwSize; 2384 TCurve* Scan= lpDBase->GetCurve(0); 2385 //! TCurve* ScanRep= lpDBase->GetScanReport(); 2386 UINT nScanNumber= lpDBase->GetCNumber(); 2387 UINT nPointNumber= Scan->GetPNumber(); 2388 TScreen &Screen= PlotWindow->Screen; 2389 //! wenn Bitmap existiert -> loeschen 2390 if ( hBitmap ) 2391 DeleteObject(hBitmap); 2392 hBitmap= NULL; 2393 //! wenn mehr als 2 Scankurven oder mehr als 2 Punkte in der Kurve 2394 if ((2 > nScanNumber) || (2 > nPointNumber)) 2395 { 2396 //! Screen-Anpassung in Fkt. CanClose() eingebaut - Fehler 12 2397 //! Screen.dx= (Screen.x1 - Screen.x0) * 0.8; 2398 //! Screen.dy= (Screen.y1 - Screen.y0) * 0.9; 2399 PlotWindow->SetRanges(); 2400 PlotWindow->AltCoorSys= PlotWindow->CoorSys; 2401 // compute scaling factors 2402 BMCoorSys->xSF= (BMCoorSys->xMax - BMCoorSys->xMin) / Screen.dx; 2403 BMCoorSys->ySF= (BMCoorSys->yMax - BMCoorSys->yMin) / Screen.dy; 2404 return; 2405 } 2406 2407 // inquire measurement Ranges 2408 PlotWindow->SetRanges(); 2409 PlotWindow->AltCoorSys= PlotWindow->CoorSys; 2410 BMCoorSys->xScal= BMCoorSys->yScal= sLinear; 2411 if (BMCoorSys->xMin <= 0.0) 2412 BMCoorSys->xMin= 0.0001; 2413 if (BMCoorSys->yMin <= 0.0) 2414 BMCoorSys->yMin= 0.0001; 2415 2416 //******** create header for device independend bitmap *********************** 2417 dwSize= sizeof(BITMAPINFO) + ColorTable.ColorMap.GetCount() * sizeof(RGBQUAD); 2418 if (hDIBInfo) 2419 //! the GlobalReAlloc function changes the size or attributes 2420 //! of a specified global memory object 2421 hDIBInfo= HeapReAlloc(GetProcessHeap(),0, hDIBInfo, dwSize); 2422 else 2423 hDIBInfo= (HGLOBAL)HeapAlloc(GetProcessHeap(),0,dwSize); 2424 if (!hDIBInfo) 2425 { 2426 MessageBox(GetFocus(), "Cannot create memory object (1)", "Message", MBINFO); 2427 return; 2428 } 2429 lpBMPInfo= (LPBITMAPINFO)hDIBInfo; 2430 lpBMPInfoHdr= &lpBMPInfo->bmiHeader; 2431 lpBMPInfoHdr->biSize= sizeof(BITMAPINFOHEADER); 2432 lpBMPInfoHdr->biPlanes= 1; 2433 lpBMPInfoHdr->biBitCount= 8; 2434 lpBMPInfoHdr->biSizeImage= 0; // Because BI_RGB 2435 lpBMPInfoHdr->biCompression= BI_RGB; 2436 lpBMPInfoHdr->biXPelsPerMeter= lpBMPInfoHdr->biYPelsPerMeter= 0; 2437 lpBMPInfoHdr->biClrUsed= ColorTable.ColorMap.GetCount(); 2438 lpBMPInfoHdr->biClrImportant= 0; 2439 // Palette bereitstellen 2440 palette= CreateDefaultPalette(); 2441 FillBMInfoFromPalette(palette); 2442 //************ compute bitmap size **************** 2443 switch (PlotWindow->eOutputType) 2444 { 2445 case otReciprokeLatticeBitmap: 2446 //! ::RLdy ist die y-Punkte Ausdehnung im Visualising Options Menu 2447 Screen.dy= PlotWindow->RLdy= max((WORD)0, min((WORD)800, PlotWindow->RLdy)); 2448 //! ::RLdx ist die x-Punkte Ausdehnung 2449 Screen.dx= ( (PlotWindow->RLdx+3) / 4) * 4; 2450 lpBMPInfoHdr->biWidth= Screen.dx; 2451 lpBMPInfoHdr->biHeight= Screen.dy; 2452 break; 2453 2454 case otMatrixBitmap: 2455 //! Groesse x-Achse gleich der Anzahl der Kurvenpunkte 2456 //! ::RLdy ist die y-Punkte Ausdehnung im Visualising Options Menu 2457 Screen.dy= PlotWindow->RLdy= max((WORD)0, min((WORD)800, PlotWindow->RLdy)); 2458 //! ::RLdx ist die x-Punkte Ausdehnung 2459 Screen.dx= ( (PlotWindow->RLdx+3) / 4) * 4; 2460 lpBMPInfoHdr->biWidth= Screen.dx; 2461 lpBMPInfoHdr->biHeight= Screen.dy; 2462 break; 2463 2464 default: 2465 MessageBox(GetFocus(), "Unknown OutputType", "Message", MBINFO); 2466 } 2467 // allocate memory for bitmap bits 2468 if (hDIBData) 2469 HeapFree(GetProcessHeap(),0,hDIBData); 2470 2471 hDIBData= (HGLOBAL)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,GetImageSize()); 2472 SetInfo(szMsgLine309); 2473 switch (PlotWindow->eOutputType) 2474 { 2475 case otReciprokeLatticeBitmap: 2476 GenerateRLBitmap(); 2477 break; 2478 2479 case otMatrixBitmap: 2480 GenerateAngleSpaceBitmap(); 2481 break; 2482 } 2483 }; 2484 //***************************************************************************** 2485 2486 //! Zwischenablageoperation, wenn Typ CF_DIB 2487 HGLOBAL TBitmapSource::RenderDIB(void) 2488 { 2489 HGLOBAL hMem; 2490 long szInfo; 2491 HPBYTE hpNewData; 2492 HPBYTE hpData; 2493 LPBITMAPINFO lpBMPInfo; 2494 2495 lpBMPInfo= (LPBITMAPINFO)hDIBInfo; 2496 if (hDIBData && lpBMPInfo) 2497 { 2498 szInfo= sizeof(BITMAPINFO) 2499 + (lpBMPInfo->bmiHeader.biClrUsed - 1) * sizeof(RGBQUAD); 2500 2501 hMem= (HGLOBAL)HeapAlloc(GetProcessHeap(),0,szInfo + HeapSize(GetProcessHeap(),0,hDIBData)); 2502 if (hMem) 2503 { 2504 hpNewData= (HPBYTE)hMem; 2505 memcpy(hpNewData, lpBMPInfo, (int)szInfo); 2506 hpData= (HPBYTE)hDIBData; 2507 // move bitmap bits 2508 memcpy(hpNewData + szInfo, hpData, HeapSize(GetProcessHeap(),0,hDIBData)); 2509 } 2510 return hMem; 2511 } 2512 else 2513 return NULL; 2514 }; 2515 2516 //############################################################################## 2517 // TCurveFreeScalColorWindow 2518 //############################################################################## 2519 2520 //! Konstruktor 2521 TCurveFreeScalColorWindow::TCurveFreeScalColorWindow(HINSTANCE aInstance, TPlotWindow *aPlotWindow) : TMDIWindow(aInstance) 2522 { 2523 PlotWindow= aPlotWindow; 2524 PlotWindow->BSource->UserFarb= this; 2525 } 2526 //***************************************************************************** 2527 2528 //! Destruktor 2529 TCurveFreeScalColorWindow::~TCurveFreeScalColorWindow() 2530 { 2531 char buf[MaxString]; 2532 RECT rc, rcm; 2533 2534 GetWindowRect(GetFrameHandle(), &rcm ); 2535 GetWindowRect(GetHandle(), &rc); 2536 sprintf(buf, "%d", rc.left - rcm.left - 4); 2537 WritePrivateProfileString("UserScal", "xo", buf, GetCFile()); 2538 sprintf(buf, "%d", rc.top - rcm.top - 42 ); 2539 WritePrivateProfileString("UserScal", "yo", buf, GetCFile()); 2540 PlotWindow->BSource->UserFarb= NULL; 2541 } 2542 //***************************************************************************** 2543 2544 //! Titel setzen 2545 BOOL TCurveFreeScalColorWindow::SetTitle() 2546 { 2547 strcpy( m_Title, szMsgLine311 ); 2548 return TMDIWindow::SetTitle(); 2549 }; 2550 //***************************************************************************** 2551 2552 //! neues Fenster bauen 2553 void TCurveFreeScalColorWindow::OnCreate() 2554 { 2555 RECT rc; 2556 2557 //! lese ini-File fuer Fensterposition 2558 rc.left= GetPrivateProfileInt("UserScal", "xo", 0, GetCFile()); 2559 rc.top= GetPrivateProfileInt("UserScal", "yo", 0, GetCFile()); 2560 SetWindowPos(GetHandle(), HWND_TOP, rc.left, rc.top, 375, 325, SWP_NOZORDER); 2561 SetTitle(); 2562 } 2563 //***************************************************************************** 2564 2565 //! wenn Fensterinhalt neu gezeichnet werden muss 2566 void TCurveFreeScalColorWindow::DoPaint(HDC hdc, PAINTSTRUCT *) 2567 { 2568 DrawColorTable(hdc); 2569 } 2570 //***************************************************************************** 2571 2572 //! zeichnet den Inhalt des Fensters 2573 void TCurveFreeScalColorWindow::DrawColorTable(HDC hdc) 2574 { 2575 int cnt, i, red, green, blue; 2576 int yrand= 20, xlrand= 50, xrrand= 80, fs= 14; 2577 LOGPALETTE *pPal; 2578 PALETTEENTRY *pPE; 2579 char buf[30]; 2580 HBRUSH hBrush, hBrushOld; 2581 HPEN hPen, hPenOld; 2582 POINT aPoints[5]; 2583 HPALETTE hPal, hDefPal; 2584 HFONT hFont, hOldFont; 2585 LOGFONT lf; 2586 SIZE tagS; 2587 TBitmapSource* BitmapSource= PlotWindow->BSource; 2588 2589 //! Font selektieren 2590 memset(&lf, 0, sizeof(LOGFONT)); 2591 lf.lfHeight= fs; 2592 lf.lfWidth= 0; 2593 lf.lfWeight= 200; 2594 lf.lfUnderline= FALSE; 2595 strcpy(lf.lfFaceName, "Times New Roman"); 2596 hFont= CreateFontIndirect(&lf); 2597 hOldFont= (HFONT)SelectObject(hdc, hFont); 2598 2599 //! Palette aufbauen 2600 pPal= BitmapSource->GetPalette(); 2601 hPal= CreatePalette(pPal); 2602 hDefPal= SelectPalette(hdc, hPal, FALSE); 2603 RealizePalette(hdc); 2604 2605 pPE= pPal->palPalEntry; 2606 2607 //! male Farbverlauf 2608 for (cnt= BitmapSource->ColorTable.ColorMap.GetCount()-1; cnt >=0; cnt--) 2609 { 2610 red= pPE[cnt].peRed; 2611 green= pPE[cnt].peGreen; 2612 blue= pPE[cnt].peBlue; 2613 hBrush= CreateSolidBrush(RGB(red, green, blue)); 2614 if (cnt == BitmapSource->ColorTable.ColorMap.GetCount()-1) 2615 hBrushOld= (HBRUSH)SelectObject(hdc, hBrush); 2616 hPen= CreatePen(PS_SOLID, 1, RGB(red, green, blue)); 2617 if (cnt == BitmapSource->ColorTable.ColorMap.GetCount()-1) 2618 hPenOld= (HPEN)SelectObject(hdc, hPen); 2619 2620 SelectObject(hdc, hBrush); 2621 SelectObject(hdc, hPen); 2622 2623 //! male Markierungen rechts am Farbverlauf 2624 aPoints[0].y= aPoints[1].y= BitmapSource->ColorTable.ColorMap.GetCount()-1 - cnt + yrand; 2625 aPoints[0].x= xlrand; 2626 aPoints[1].x= xrrand; 2627 2628 Polyline(hdc, aPoints, 2); 2629 SetTextAlign(hdc, TA_TOP); 2630 SelectObject(hdc, hBrushOld); 2631 DeleteObject(hBrush); 2632 SelectObject(hdc, hPenOld); 2633 DeleteObject(hPen); 2634 2635 //! male Markierungen fuer "reine Farben" 2636 int t= BitmapSource->ColorTable.ColorMap.GetCount()-1 - cnt; 2637 if ( t == 0 || t == 51 || t == 101 || t == 151 || t == 201 || t == 255 ) 2638 { 2639 SetTextAlign(hdc, TA_LEFT); 2640 2641 sprintf(buf, szMsgLine312, t); 2642 GetTextExtentPoint(hdc, buf, strlen(buf), &tagS); 2643 TextOut(hdc, xrrand + 10, cnt + yrand - (lf.lfHeight / 2), (LPSTR)buf, strlen(buf)); 2644 2645 hPen= CreatePen(PS_SOLID, 1, RGB(0, 0, 0)); 2646 hPenOld= (HPEN)SelectObject(hdc, hPen); 2647 aPoints[0].x= xrrand; 2648 aPoints[0].y= aPoints[1].y= cnt + yrand; 2649 aPoints[1].x= xrrand + 5; 2650 Polyline(hdc, aPoints, 2); 2651 SelectObject(hdc, hPenOld); 2652 DeleteObject(hPen); 2653 } 2654 } 2655 //! schreibe links und rechts oben Text aus... 2656 SetTextAlign(hdc, TA_LEFT); 2657 2658 sprintf(buf, szMsgLine313); 2659 GetTextExtentPoint(hdc, buf, strlen(buf), &tagS); 2660 TextOut(hdc, xlrand - 40, yrand - 17, (LPSTR)buf, strlen(buf)); 2661 2662 sprintf(buf, szMsgLine314); 2663 GetTextExtentPoint(hdc, buf, strlen(buf), &tagS); 2664 TextOut(hdc, xrrand + 200, yrand - 17, (LPSTR)buf, strlen(buf)); 2665 2666 hPen= CreatePen(PS_SOLID, 1, RGB(0, 0, 0)); 2667 hPenOld= (HPEN)SelectObject(hdc, hPen); 2668 2669 //! male und schreibe Farben und Intensitaeten 2670 for (i= 0;i < 8;i++) 2671 { 2672 int y= BitmapSource->ColorTable.ColorMap.GetCount()-1 - BitmapSource->farbe[i] + yrand; 2673 aPoints[0].x= xlrand; 2674 aPoints[0].y= aPoints[1].y= y; 2675 aPoints[1].x= xlrand - 5; 2676 Polyline(hdc, aPoints, 2); 2677 SetTextAlign(hdc, TA_LEFT); 2678 sprintf(buf, "%d", i + 1); 2679 GetTextExtentPoint(hdc, buf, strlen(buf), &tagS); 2680 y-= (lf.lfHeight / 2); 2681 if (i % 2) 2682 TextOut(hdc, xlrand - 15, y, (LPSTR)buf, strlen(buf)); 2683 else 2684 TextOut(hdc, xlrand - 25, y, (LPSTR)buf, strlen(buf)); 2685 2686 red= pPE[BitmapSource->farbe[i]].peRed; 2687 green= pPE[BitmapSource->farbe[i]].peGreen; 2688 blue= pPE[BitmapSource->farbe[i]].peBlue; 2689 hBrush= CreateSolidBrush(RGB(red, green, blue)); 2690 hBrushOld= (HBRUSH)SelectObject(hdc, hBrush); 2691 2692 SelectObject(hdc, hBrush); 2693 SelectObject(hdc, hPen); 2694 2695 int x= xrrand + 180; 2696 y= BitmapSource->ColorTable.ColorMap.GetCount()-1 + yrand - i*32 - 20; 2697 Rectangle(hdc, x, y, 2698 x+20, y+20); 2699 2700 SelectObject(hdc, hBrushOld); 2701 DeleteObject(hBrush); 2702 2703 SetTextAlign(hdc, TA_LEFT); 2704 2705 y=- (lf.lfHeight / 2) - 10; 2706 sprintf(buf, szMsgLine315, i + 1); 2707 GetTextExtentPoint(hdc, buf, strlen(buf), &tagS); 2708 TextOut(hdc, xrrand + 90, y, (LPSTR)buf, strlen(buf)); 2709 sprintf(buf, "%.2f", BitmapSource->ber[i]); 2710 GetTextExtentPoint(hdc, buf, strlen(buf), &tagS); 2711 TextOut(hdc, xrrand + 210, y, (LPSTR)buf, strlen(buf)); 2712 } 2713 //! zeichne Rand um Farbskala 2714 aPoints[0].x= aPoints[1].x= aPoints[4].x= xlrand; 2715 aPoints[0].y= aPoints[3].y= aPoints[4].y= yrand; 2716 aPoints[1].y= aPoints[2].y= BitmapSource->ColorTable.ColorMap.GetCount()-1 + yrand + 1; 2717 aPoints[2].x= aPoints[3].x= xrrand; 2718 2719 Polyline(hdc, aPoints, sizeof(aPoints) / sizeof(POINT)); 2720 2721 SelectObject(hdc, hPenOld); 2722 DeleteObject(hPen); 2723 SelectObject(hdc, hOldFont); 2724 DeleteObject(hFont); 2725 2726 SelectPalette(hdc, hDefPal, FALSE); 2727 DeleteObject(hPal); 2728 }; 2729