Skip to content

Commit

Permalink
ScatterCtrl: Updated namespace
Browse files Browse the repository at this point in the history
git-svn-id: svn://ultimatepp.org/upp/trunk@13712 f0d560ea-af0d-0410-9eb7-867de7ffcac7
  • Loading branch information
koldo committed Nov 24, 2019
1 parent ed8f981 commit 9babdad
Show file tree
Hide file tree
Showing 13 changed files with 131 additions and 51 deletions.
12 changes: 11 additions & 1 deletion uppsrc/ScatterCtrl/Data.cpp
@@ -1,5 +1,7 @@
#include "ScatterCtrl.h"

namespace Upp {

void ScatterCtrl::DoShowData()
{
DataDlg dlg;
Expand Down Expand Up @@ -29,9 +31,11 @@ void DataDlg::Init(ScatterCtrl& scatter)
OnTab();

bool addedAll = false;
if (scatter.IsDeletedDataSource(0))
return;
DataSource &serie0 = scatter.GetDataSource(0);
for(int c = 1; c < scatter.GetCount(); c++) {
if (!IsNull(scatter.GetCount(c))) {
if (!IsNull(scatter.GetCount(c) && !scatter.IsDeletedDataSource(c))) {
DataSource &serie = scatter.GetDataSource(c);
if (serie0.SameX(serie)) {
if (!addedAll) {
Expand All @@ -51,6 +55,8 @@ void DataDlg::Init(ScatterCtrl& scatter)

Value DataDlg::DataSourceX::Format(const Value& q) const
{
if (pscatter->IsDeletedDataSource(index))
return Null;
if (int(q) >= pscatter->GetDataSource(index).GetCount())
return Null;
Value ret = pscatter->GetStringX(index, q);
Expand All @@ -64,6 +70,8 @@ Value DataDlg::DataSourceX::Format(const Value& q) const

Value DataDlg::DataSourceY::Format(const Value& q) const
{
if (pscatter->IsDeletedDataSource(index))
return Null;
if (int(q) >= pscatter->GetDataSource(index).GetCount())
return Null;
Value ret = pscatter->GetStringY(index, q);
Expand Down Expand Up @@ -184,3 +192,5 @@ void DataDlg::OnArrayBar(Bar &menu)
.Help(t_("Save to .csv file"));
}
}

}
5 changes: 4 additions & 1 deletion uppsrc/ScatterCtrl/PieCtrl.cpp
Expand Up @@ -4,7 +4,8 @@
#define IMAGEFILE <ScatterCtrl/ScatterCtrl.iml>
#include <Draw/iml.h>


namespace Upp {

PieCtrl::PieCtrl() : copyRatio(1) {
Transparent();
BackPaint();
Expand Down Expand Up @@ -99,4 +100,6 @@ void PieCtrl::SaveToFile(String fileName)
encoder.SaveFile(fileName, GetImage(copyRatio));
} else
Exclamation(Format(t_("File format \"%s\" not found"), GetFileExt(fileName)));
}

}
3 changes: 2 additions & 1 deletion uppsrc/ScatterCtrl/PieCtrl.h
Expand Up @@ -5,7 +5,7 @@
#include <ScatterDraw/PieDraw.h>
#include <plugin/jpg/jpg.h>

using namespace Upp;
namespace Upp {


class PieCtrl: public StaticRect, public PieDraw {
Expand Down Expand Up @@ -48,6 +48,7 @@ class PieCtrl: public StaticRect, public PieDraw {
PieCtrl& SetLegendTop(const int& v) {PieDraw::SetLegendTop(v); return *this;}
};

}

#endif

Expand Down
8 changes: 5 additions & 3 deletions uppsrc/ScatterCtrl/PopUpText.cpp
@@ -1,9 +1,9 @@
#include <CtrlLib/CtrlLib.h>

using namespace Upp;

#include "PopUpText.h"


namespace Upp {

static Size GetEditSize(const String &_str, const Font &font) {
WString str(_str);
Size ret(0, 0);
Expand Down Expand Up @@ -42,4 +42,6 @@ PopUpInfo::PopUpInfo(): color(SColorInfo()) {
SetAlign(ALIGN_CENTER);
SetFrame(BlackFrame());
opened = false;
}

}
4 changes: 4 additions & 0 deletions uppsrc/ScatterCtrl/PopUpText.h
@@ -1,6 +1,8 @@
#ifndef _PopUpText_PopUpText_h
#define _PopUpText_PopUpText_h

namespace Upp {

class PopUpText {
public:
Point pos;
Expand Down Expand Up @@ -74,5 +76,7 @@ class PopUpInfo : public StaticText {
}
};

}

#endif

39 changes: 33 additions & 6 deletions uppsrc/ScatterCtrl/Processing.cpp
@@ -1,5 +1,7 @@
#include "ScatterCtrl.h"

namespace Upp {

void ScatterCtrl::DoProcessing()
{
ProcessingDlg dlg;
Expand Down Expand Up @@ -125,7 +127,7 @@ ProcessingTab::ProcessingTab()

for (int i = 0; i < DataSource::GetFFTWindowCount(); ++i)
tabFreqRight.window.Add(InitCaps(DataSource::GetFFTWindowStr(i)));
tabFreqRight.window.SetIndex(0);
tabFreqRight.window.SetIndex(1);
tabFreqRight.window.WhenAction = THISBACK(OnFFT);
tabFreqRight.num <<= 1;
tabFreqRight.overlapping <<= 0.1;
Expand Down Expand Up @@ -198,6 +200,8 @@ void ProcessingTab::OnArrayBar(Bar &menu) {
void ProcessingTab::OnFit() {
WaitCursor waitcursor;

if (pscatter->IsDeletedDataSource(id))
return;
DataSource &ds = pscatter->GetDataSource(id);

userEquation->Init("User", ~tabBestFitRight.userFormula, "x");
Expand Down Expand Up @@ -230,6 +234,8 @@ void ProcessingTab::OnFit() {

void ProcessingTab::OnOp()
{
if (tabFitLeft.scatter.IsDeletedDataSource(0))
return;
DataSource &data = tabFitLeft.scatter.GetDataSource(0);

if (data.IsParam() || data.IsExplicit())
Expand Down Expand Up @@ -326,6 +332,8 @@ void ProcessingTab::OnOp()

void ProcessingTab::OnAutoSensSector()
{
if (tabFitLeft.scatter.IsDeletedDataSource(0))
return;
DataSource &data = tabFitLeft.scatter.GetDataSource(0);
Vector<Pointf> secAvg;
double baseWidth;
Expand Down Expand Up @@ -363,6 +371,8 @@ void ProcessingTab::OnOperation()
}
}
exclamationOpened = false;
if (pscatter->IsDeletedDataSource(id))
return;
dataXRange.Init(pscatter->GetDataSource(id), tabOpRight.xLow, tabOpRight.xHigh);
tabOpLeft.scatter.Refresh();
}
Expand All @@ -373,6 +383,8 @@ void ProcessingTab::UpdateField(const String _name, int _id)
name.SetText(_name);

tabFitLeft.scatter.RemoveAllSeries();
if (pscatter->IsDeletedDataSource(id))
return;
tabFitLeft.scatter.AddSeries(pscatter->GetDataSource(id)).SetSequentialX(pscatter->GetSequentialX())
.Legend(pscatter->GetLegend(id));
tabFitLeft.scatter.SetFastViewX(pscatter->GetFastViewX());
Expand Down Expand Up @@ -400,6 +412,8 @@ void ProcessingTab::UpdateField(const String _name, int _id)

tabFitLeft.scatter.ShowInfo().ShowContextMenu().ShowProcessDlg().ShowPropertiesDlg().SetMouseHandlingLinked(true, true);

if (tabFitLeft.scatter.IsDeletedDataSource(0))
return;
DataSource &data = tabFitLeft.scatter.GetDataSource(0);

if (!data.IsParam()/* && !data.IsExplicit()*/) {
Expand All @@ -411,7 +425,7 @@ void ProcessingTab::UpdateField(const String _name, int _id)
double val;
val = data.MaxY(idmx);
if (!IsNull(val)) {
tabFitRight.eMax = Format("(%f,%f)", data.x(idmx), val);
tabFitRight.eMax <<= Format("(%f,%f)", data.x(idmx), val);
Pointf p = data.MaxSubDataImpY(idmx, 3);
if (!IsNull(p))
tabFitRight.eMaxImp = Format("(%f,%f)", p.x, p.y);
Expand Down Expand Up @@ -461,6 +475,8 @@ void ProcessingTab::UpdateField(const String _name, int _id)

void ProcessingTab::OnUpdateSensitivity()
{
if (tabFitLeft.scatter.IsDeletedDataSource(0))
return;
DataSource &data = tabFitLeft.scatter.GetDataSource(0);

bool refresh = false;
Expand Down Expand Up @@ -505,6 +521,8 @@ void ProcessingTab::OnUpdateSensitivity()

void ProcessingTab::OnSet()
{
if (tabFitLeft.scatter.IsDeletedDataSource(0))
return;
DataSource &data = tabFitLeft.scatter.GetDataSource(0);

if (tabFreqFirst && tab.Get() == 1) {
Expand Down Expand Up @@ -534,6 +552,9 @@ void ProcessingTab::OnSet()
tabFreqRight.samplingTime = (maxdT + mindT)/2.;
}
} else if (tabOpFirst && tab.Get() == 2) {
if (pscatter->IsDeletedDataSource(id))
return;

tabOpFirst = false;

tabOpLeft.scatter.RemoveAllSeries();
Expand Down Expand Up @@ -566,6 +587,9 @@ void ProcessingTab::OnSet()

tabOpLeft.scatter.ShowInfo().ShowContextMenu().ShowProcessDlg().ShowPropertiesDlg().SetMouseHandlingLinked(true, true);
} else if (tabBestFitFirst && tab.Get() == 3) {
if (pscatter->IsDeletedDataSource(id))
return;

tabBestFitFirst = false;

tabBestFitLeft.scatter.RemoveAllSeries();
Expand Down Expand Up @@ -636,6 +660,8 @@ void ProcessingTab::OnFFT()
{
WaitCursor waitcursor;

if (tabFitLeft.scatter.IsDeletedDataSource(0))
return;
DataSource &data = tabFitLeft.scatter.GetDataSource(0);

Vector<Pointf> orderedSeries;
Expand Down Expand Up @@ -670,10 +696,9 @@ void ProcessingTab::OnFFT()
fft = series.FFTY(samplingTime, tabFreqRight.opXAxis == 1, tabFreqRight.type,
tabFreqRight.window.GetIndex(), tabFreqRight.num, tabFreqRight.overlapping);
VectorPointf fftData(fft);
fftData.MaxY(idMaxFFT);
Pointf p = fftData.MaxSubDataImpY(idMaxFFT, 3);
if (!IsNull(p))
tabFreqRight.eMax = Format("(%f,%f)", p.x, p.y);
double mxy = fftData.MaxY(idMaxFFT);
if (!IsNull(mxy))
tabFreqRight.eMax <<= Format("(%f,%f)", fftData.x(idMaxFFT), mxy);

if (tabFreqRight.type == DataSource::T_PSD) {
double m_1, m0, m1, m2;
Expand Down Expand Up @@ -712,3 +737,5 @@ void ProcessingTab::OnFFT()

tabFreqLeft.comments.SetText(errText);
}

}
20 changes: 16 additions & 4 deletions uppsrc/ScatterCtrl/Properties.cpp
@@ -1,9 +1,12 @@
#include "ScatterCtrl.h"

namespace Upp {

#define IMAGECLASS ScatterImgP
#define IMAGEFILE <ScatterCtrl/ScatterCtrl.iml>
#include <Draw/iml_source.h>


void ScatterCtrl::DoShowEditDlg(int itab)
{
PropertiesDlg dlg;
Expand Down Expand Up @@ -42,13 +45,17 @@ void MeasuresTab::Init(ScatterCtrl& scatter)
opReticleX <<= scatter.GetDrawXReticle();
opReticleY <<= scatter.GetDrawYReticle();
opReticleY2 <<= scatter.GetDrawY2Reticle();
opReticleXNumbers <<= scatter.GetDrawXReticleNumbers();
opReticleYNumbers <<= scatter.GetDrawYReticleNumbers();
opReticleY2Numbers <<= scatter.GetDrawY2ReticleNumbers();
reticlethickness <<= scatter.GetAxisWidth();

linethickness <<= scatter.GetGridWidth();
linecolor <<= scatter.GetGridColor();
dashStyle.Clear();
for(int i = 0; i < DashStyle::GetCount(); i++)
dashStyle.Add(DashStyle::TypeName(i));

int id = DashStyle::StyleIndex(scatter.GetGridDash());
if (id < 0) {
id = DashStyle::Register(Format(t_("Dash \"%s\""), scatter.GetGridDash()), scatter.GetGridDash());
Expand All @@ -72,6 +79,10 @@ void MeasuresTab::Init(ScatterCtrl& scatter)
opReticleX.WhenAction = THISBACK(Change);
opReticleY.WhenAction = THISBACK(Change);
opReticleY2.WhenAction = THISBACK(Change);
opReticleXNumbers.WhenAction = THISBACK(Change);
opReticleYNumbers.WhenAction = THISBACK(Change);
opReticleY2Numbers.WhenAction = THISBACK(Change);
reticlethickness <<= THISBACK(Change);

linecolor <<= THISBACK(Change);
linethickness <<= THISBACK(Change);
Expand Down Expand Up @@ -104,17 +115,18 @@ void MeasuresTab::Change()

scatter.SetMouseHandlingLinked(!opAttachX, !opAttachY);
scatter.SetDrawXReticle(opReticleX).SetDrawYReticle(opReticleY).SetDrawY2Reticle(opReticleY2);
scatter.SetDrawXReticleNumbers(opReticleXNumbers).SetDrawYReticleNumbers(opReticleYNumbers).SetDrawY2ReticleNumbers(opReticleY2Numbers);
scatter.SetAxisWidth(~reticlethickness);

scatter.SetXYMinLinked(xMin, yMin, yMin2);
//scatter.SetMinUnits(xMin, yMin);
scatter.SetRangeLinked(xMax - xMin, yMax - yMin, yMax2 - yMin2);

scatter.SetMinUnits(xMinUnit, yMinUnit);
scatter.SetMajorUnits(xMajorUnit, yMajorUnit);

scatter.SetGridDash(DashStyle::Style(DashStyle::TypeIndex(~dashStyle)));
scatter.SetGridColor(~linecolor);
scatter.SetGridWidth(linethickness);
scatter.SetGridWidth(~linethickness);

scatter.SetModify();
scatter.Refresh();
Expand Down Expand Up @@ -574,4 +586,4 @@ void SeriesTab::OnDelete()
scatter.Refresh();
}


}
5 changes: 5 additions & 0 deletions uppsrc/ScatterCtrl/Properties.h
@@ -1,13 +1,16 @@
#ifndef _ScatterCtrl_Properties_h_
#define _ScatterCtrl_Properties_h_

namespace Upp {

#define LAYOUTFILE <ScatterCtrl/ScatterCtrl.lay>
#include <CtrlCore/lay.h>

#define IMAGECLASS ScatterImgP
#define IMAGEFILE <ScatterCtrl/ScatterCtrl.iml>
#include <Draw/iml_header.h>


class FontSelect : public WithFontSelector<TopWindow> {
typedef FontSelect CLASSNAME;
public:
Expand Down Expand Up @@ -304,4 +307,6 @@ class ProcessingDlg : public TopWindow {
void UpdateFields();
};

}

#endif
7 changes: 6 additions & 1 deletion uppsrc/ScatterCtrl/ScatterCtrl.cpp
@@ -1,12 +1,16 @@
#include "ScatterCtrl.h"


#define IMAGECLASS ScatterImg
#define IMAGEFILE <ScatterCtrl/ScatterCtrl.iml>
#include <Draw/iml.h>

#define TFILE <ScatterCtrl/ScatterCtrl.t>
#include <Core/t.h>

namespace Upp {


Vector<ScatterCtrl *> ScatterCtrl::instances;

#ifdef PLATFORM_WIN32
Expand Down Expand Up @@ -648,7 +652,7 @@ void ScatterCtrl::ZoomWindow(bool down, Point &pt) {
isLabelPopUp = isZoomWindow = false;

if (popLT.x > popRB.x)
::Swap(popLT, popRB);
Upp::Swap(popLT, popRB);
double LTx, LTy, LTy2, RBx, RBy, RBy2;
LTx = (popLT.x - hPlotLeft)*xRange/(GetSize().cx - (hPlotLeft + hPlotRight)-1) + xMin;
LTy = -(popLT.y - vPlotTop - titleHeight)*yRange/(GetSize().cy - (vPlotTop + vPlotBottom + titleHeight)+1) + yMin + yRange;
Expand Down Expand Up @@ -1153,3 +1157,4 @@ ScatterCtrl::ScatterCtrl() {
AddInstance(this);
}

}

0 comments on commit 9babdad

Please sign in to comment.