zeichnen in scrollalbe panel
-
Hallo ich würde gerne wissen wie ich in ein scrollalbe Panel zeichne.
Mein Problem ist das mein panel Horizontal Doppel oder dreifach .., so groß ist. Wenn ich in das Panel zeiche wird aber immer nur der untere teil angezeigt.
Das heißt wenn ich nach oben scrolle zeichnet er trotzdem nur den unteren teil des Bildes neu ( nur weiter oben )????mein Beispiel ist ein Histogramm das ich zeichnen will wie folgt:
private: System::Void panelHistLin_Paint(System::Object^ sender, System::Windows::Forms::PaintEventArgs^ e) { //if( tabControl1->SelectedIndex==0 && myRefHisto!=nullptr){ if( tabControl1->SelectedIndex==0 && refImageData!=nullptr){ int** pHistoData; Histogram* myRefHisto=new Histogram(this->x,this->y,3); if(checkBoxSmooth->Checked){ myRefHisto->calHisto(refImageData); myRefHisto->scaleHistoLin(panelHistLin->Height); pHistoData=myRefHisto->smooth(5); } else { myRefHisto=new Histogram(this->x,this->y,3); myRefHisto->calHisto(refImageData); pHistoData=myRefHisto->scaleHistoLin(maxHisto); } int count=0; for(int i=0;i<512;i+=2){ if(checkBoxRed->Checked){ pointsR[count].X=i; pointsR[count].Y=panelHistLin->Height-pHistoData[0][count]; } if(checkBoxGreen->Checked){ pointsG[count].X=i; pointsG[count].Y=panelHistLin->Height-pHistoData[1][count]; } if(checkBoxBlue->Checked){ pointsB[count].X=i; pointsB[count].Y=panelHistLin->Height-pHistoData[2][count]; } count++; } if(checkBoxRed->Checked) e->Graphics->DrawCurve(penR,pointsR); if(checkBoxGreen->Checked) e->Graphics->DrawCurve(penG,pointsG); if(checkBoxBlue->Checked) e->Graphics->DrawCurve(penB,pointsB); delete myRefHisto; } }
-
Hi,
du musst natürlich immer den Offset berücksichtigen. Wenn du nach unten scrollst, sind die Koordinaten größer, als z.B. der gleiche Punkt dahinter bei dem Forms Fenster (das ist ja der Sinn von Scrollbalken).
Du musst also immer, wenn du in deinem ScrollPanel Koordinaten angibst, einen "KorrekturOffSet" angeben:
//angenommen, das betreffende panel heißt panelHistLin for(int i=0;i<512;i+=2){ if(checkBoxRed->Checked){ pointsR[count].X=i - panelHistLin->HorizontalScroll->Value; pointsR[count].Y=panelHistLin->Height-pHistoData[0][count] - panelHistLin->VerticalScroll->Value; } if(checkBoxGreen->Checked){ pointsG[count].X=i - panelHistLin->HorizontalScroll->Value; pointsG[count].Y=panelHistLin->Height-pHistoData[1][count] - panelHistLin->VerticalScroll->Value; } if(checkBoxBlue->Checked){ pointsB[count].X=i - panelHistLin->HorizontalScroll->Value; pointsB[count].Y=panelHistLin->Height-pHistoData[2][count] - panelHistLin->VerticalScroll->Value; } count++; }
cadaei