ScatterCtrl: Improvement in linked ScatterCtrls

git-svn-id: svn://ultimatepp.org/upp/trunk@11607 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
koldo 2017-12-23 00:27:41 +00:00
parent a020e12a89
commit 6481819dfb
5 changed files with 42 additions and 33 deletions

View file

@ -39,6 +39,9 @@ void MeasuresTab::Init(ScatterCtrl& scatter)
yMin2 <<= scatter.GetYMin2();
yMax2 <<= scatter.GetY2Range() + scatter.GetYMin2();
opAttachX <<= !scatter.GetMouseHandlingX();
opAttachY <<= !scatter.GetMouseHandlingY();
xMin.WhenEnter = THISBACK(Change);
xMax.WhenEnter = THISBACK(Change);
yMin.WhenEnter = THISBACK(Change);
@ -46,11 +49,14 @@ void MeasuresTab::Init(ScatterCtrl& scatter)
yMin2.WhenEnter = THISBACK(Change);
yMax2.WhenEnter = THISBACK(Change);
opAttachX.WhenAction = THISBACK(Change);
opAttachY.WhenAction = THISBACK(Change);
Change();
}
void MeasuresTab::Change()
{
{
if (xMax <= xMin) {
Exclamation(t_("X min has to be lower than X max"));
return;
@ -63,11 +69,19 @@ void MeasuresTab::Change()
Exclamation(t_("Y min2 has to be lower than Y max2"));
return;
}
ScatterCtrl &scatter = *pscatter;
scatter.SetXYMin(xMin, yMin, yMin2);
xMin.Enable(!opAttachX);
xMax.Enable(!opAttachX);
yMin.Enable(!opAttachY);
yMax.Enable(!opAttachY);
ScatterCtrl &scatter = *pscatter;
scatter.SetMouseHandlingLinked(!opAttachX, !opAttachY);
scatter.SetXYMinLinked(xMin, yMin, yMin2);
//scatter.SetMinUnits(xMin, yMin);
scatter.SetRange(xMax - xMin, yMax - yMin, yMax2 - yMin2);
scatter.SetRangeLinked(xMax - xMin, yMax - yMin, yMax2 - yMin2);
scatter.SetModify();
scatter.Refresh();
@ -907,7 +921,7 @@ void ProcessingTab::UpdateField(const String _name, int _id)
tabFit.scatter.SetMajorUnits(pscatter->GetMajorUnitsX(), primary ? pscatter->GetMajorUnitsY() : pscatter->GetMajorUnitsY2());
tabFit.scatter.SetXYMin(pscatter->GetXMin(), primary ? pscatter->GetYMin() : pscatter->GetY2Min());
tabFit.scatter.SetMouseHandling(true, true).ShowInfo().ShowContextMenu().ShowProcessDlg().ShowPropertiesDlg();
tabFit.scatter.ShowInfo().ShowContextMenu().ShowProcessDlg().ShowPropertiesDlg().SetMouseHandlingLinked(true, true);
DataSource &data = tabFit.scatter.GetSeries(0);
@ -1065,7 +1079,7 @@ void ProcessingTab::OnSet()
tabOp.scatter.SetMajorUnits(pscatter->GetMajorUnitsX(), primary ? pscatter->GetMajorUnitsY() : pscatter->GetMajorUnitsY2());
tabOp.scatter.SetXYMin(pscatter->GetXMin(), primary ? pscatter->GetYMin() : pscatter->GetY2Min());
tabOp.scatter.SetMouseHandling(true, true).ShowInfo().ShowContextMenu().ShowProcessDlg().ShowPropertiesDlg();
tabOp.scatter.ShowInfo().ShowContextMenu().ShowProcessDlg().ShowPropertiesDlg().SetMouseHandlingLinked(true, true);
} else if (tabBestFitFirst && tab.Get() == 3) {
tabBestFitFirst = false;
@ -1085,7 +1099,7 @@ void ProcessingTab::OnSet()
tabBestFit.scatter.SetMajorUnits(pscatter->GetMajorUnitsX(), primary ? pscatter->GetMajorUnitsY() : pscatter->GetMajorUnitsY2());
tabBestFit.scatter.SetXYMin(pscatter->GetXMin(), primary ? pscatter->GetYMin() : pscatter->GetY2Min());
tabBestFit.scatter.SetMouseHandling(true, true).ShowInfo().ShowContextMenu().ShowProcessDlg().ShowPropertiesDlg();
tabBestFit.scatter.ShowInfo().ShowContextMenu().ShowProcessDlg().ShowPropertiesDlg().SetMouseHandlingLinked(true, true);
}
}
@ -1203,7 +1217,7 @@ void ProcessingTab::OnFFT()
}
String legend = tabFit.scatter.GetLegend(0) + String("-") + strtype;
tabFreq.scatter.AddSeries(fft).Legend(legend);
tabFreq.scatter.SetMouseHandling(true, true).ShowInfo().ShowContextMenu().ShowProcessDlg().ShowPropertiesDlg();
tabFreq.scatter.ShowInfo().ShowContextMenu().ShowProcessDlg().ShowPropertiesDlg().SetMouseHandlingLinked(true, true);
tabFreq.scatter.SetLabelX(tabFreq.opXAxis == 1 ? t_("Frequency [Hz]") : t_("Period [sec]"));
tabFreq.scatter.SetLabelY(legend);
tabFreq.scatter.ZoomToFit(true, true);

View file

@ -60,7 +60,7 @@ void ScatterCtrl::Paint(Draw& w)
if (IsEnabled()) {
if (mode == MD_DRAW) {
ScatterCtrl::SetDrawing(w, GetSize(), 1);
PlotTexts(w, GetSize(), 1);
PlotTexts(w, GetSize(), 1, !mouseHandlingX, !mouseHandlingY);
} else {
ImageBuffer ib(GetSize());
BufferPainter bp(ib, mode);
@ -68,7 +68,7 @@ void ScatterCtrl::Paint(Draw& w)
bp.LineJoin(LINEJOIN_MITER);
ScatterCtrl::SetDrawing(bp, GetSize(), 1);
w.DrawImage(0, 0, ib);
PlotTexts(w, GetSize(), 1);
PlotTexts(w, GetSize(), 1, !mouseHandlingX, !mouseHandlingY);
}
if (HasFocus()) {
w.DrawLine(0, 0, GetSize().cx, 0, 2, LtGray());
@ -539,13 +539,6 @@ Image ScatterCtrl::CursorImage(Point p, dword keyflags)
return Image::Arrow();
}
ScatterCtrl &ScatterCtrl::SetMouseHandling(bool valx, bool valy)
{
mouseHandlingX = valx;
mouseHandlingY = valy;
return *this;
}
void ScatterCtrl::ContextMenu(Bar& bar)
{
if (mouseHandlingX || mouseHandlingY) {
@ -669,7 +662,7 @@ void ScatterCtrl::CheckButtonVisible() {
ScatterCtrl::ScatterCtrl() : offset(10,12), copyRatio(1), isLeftDown(false)
{
showInfo = mouseHandlingX = mouseHandlingY = isScrolling = isLabelPopUp = isZoomWindow = false;
showInfo = isScrolling = isLabelPopUp = isZoomWindow = false;
WantFocus();
popTextX = t_("x");
popTextY = t_("y1");

View file

@ -202,12 +202,6 @@ public:
ScatterCtrl& SetPopText(const String x, const String y1, const String y2)
{popTextX = x; popTextY = y1; popTextY2 = y2; return *this;}
ScatterCtrl& SetMouseHandling(bool valx = true, bool valy = false);
bool GetMouseHandlingX() {return mouseHandlingX;}
bool GetMouseHandlingY() {return mouseHandlingY;}
private:
void ChangeMouseHandlingX() {mouseHandlingX = !mouseHandlingX;}
void ChangeMouseHandlingY() {mouseHandlingY = !mouseHandlingY;}
public:
ScatterCtrl& ShowInfo(bool show = true) {showInfo = show; return *this;}
@ -279,12 +273,11 @@ public:
ScatterCtrl& SetDefaultCSVSeparator(String sep) {defaultCSVseparator = sep; return *this;}
String GetDefaultCSVSeparator() {return defaultCSVseparator;}
ScatterCtrl &SetMouseHandling(bool valx = true, bool valy = false) {ScatterDraw::SetMouseHandling(valx, valy); return *this;}
ScatterCtrl &SetMouseHandlingLinked(bool valx = true, bool valy = false) {ScatterDraw::SetMouseHandlingLinked(valx, valy); return *this;}
void Jsonize(JsonIO& json) {
ScatterDraw::Jsonize(json);
json
("mouseHandlingX", mouseHandlingX)
("mouseHandlingY", mouseHandlingY)
;
}
private:
@ -301,7 +294,6 @@ private:
int butDownX, butDownY;
bool isScrolling, isLabelPopUp;
bool mouseHandlingX, mouseHandlingY;
bool showContextMenu;
bool showPropDlg;
bool showProcessDlg;

View file

@ -18,6 +18,8 @@ LAYOUT(Measures, 396, 256)
ITEM(Label, dv___11, SetLabel(t_("Y max")).LeftPosZ(12, 64).TopPosZ(12, 21))
ITEM(Label, dv___12, SetLabel(t_("Y min")).LeftPosZ(12, 64).BottomPosZ(79, 21))
ITEM(Label, dv___13, SetLabel(t_("X min")).LeftPosZ(80, 64).BottomPosZ(35, 21))
ITEM(Option, opAttachX, SetLabel(t_("Attach")).HSizePosZ(168, 160).BottomPosZ(16, 16))
ITEM(Option, opAttachY, SetLabel(t_("Attach")).LeftPosZ(12, 64).VSizePosZ(60, 104))
END_LAYOUT
LAYOUT(Texts, 472, 284)

View file

@ -603,6 +603,12 @@ esES("")
euES("")
frFR("")
T_("Attach")
caES("")
esES("")
euES("")
frFR("")
T_("Label Y2:")
caES("Etiqueta Y2:")
esES("Etiqueta Y2:")
@ -1049,7 +1055,7 @@ frFR("")
T_("Normal\nFull\nText")
caES("")
esES("")
esES("Normal\nCompleto\nTexto")
euES("")
frFR("")
@ -1102,10 +1108,12 @@ euES("")
frFR("")
// Obsolete
// PieCtrl.cpp
T_("Update")
T_("Pie plot")
caES("")
esES("Actualizar")
esES("Gr\303\241fico de tarta")
euES("")
frFR("")