Add draw plot XY series

Для результатов запроса, можно построить график по трём колонкам:
L  | X | Y
----------
L1 | x1| y1
L1 | x2| y2
L2 | x3| y3
L2 | x4| y4
...

Колонки должны быть отсортированы по L,X
Типы колонок:
L - текст (это легенда серии данных)
X - дата или числа
Y - числа
График строится по четырём и более колонкам (серии данных вертикальные):
 X | L1| L2| ...| Lx
--------------------
 x1| y1| y5|....| y.
 x2| y2| y6|....| y.
 x3| y3| y7|....| y.
 x4| y4| y8|....| y.

Серии данных располагаются вертикально. Легенда это заголовок столбца
Колонка Х общая для всех серий.
This commit is contained in:
lsv 2022-05-25 17:37:39 +05:00
parent 8f8bd98d2c
commit 1431b1abdb
12 changed files with 5748 additions and 3 deletions

View file

@ -20,6 +20,8 @@
#include "ctl/ctlSQLResult.h"
#include "utils/sysSettings.h"
#include "frm/frmExport.h"
#include "frm/mathplot.h"
#include "frm/frmPlot.h"
@ -412,6 +414,202 @@ wxString ctlSQLResult::CheckSelColumnDate()
}
return ss;
}
wxDateTime parseDT(int &fmttype,const wxString dtStr) {
wxDateTime dt((time_t)-1);
if (fmttype == -1) {
if (dt.ParseISOCombined(dtStr, ' ')) {
fmttype = 0;
}
else if (dt.ParseDateTime(dtStr)) {
fmttype = 1;
} else fmttype = -1;
return dt;
}
else if (fmttype == 0) {
if (dt.ParseISOCombined(dtStr, ' ')) return dt;
else {
fmttype = -1;
return parseDT(fmttype,dtStr);
}
}
else if (fmttype == 1) {
if (dt.ParseDateTime(dtStr)) return dt;
else {
fmttype = -1;
return parseDT(fmttype, dtStr);
}
}
return dt;
}
wxString ctlSQLResult::AutoColsPlot(int flags,frmQuery* parent) {
wxArrayInt cols;
wxArrayString leg;
wxArrayInt colsY;
if (IsSelection()) {
unsigned int i;
int row, col;
wxGridCellCoordsArray cells = GetSelectedCells();
for (i = 0; i < cells.Count(); i++) {
//clearCellData(cells[i].GetRow(), cells[i].GetCol());
//cols.Add(cells[i].GetCol());
}
wxGridCellCoordsArray topLeft = GetSelectionBlockTopLeft();
wxGridCellCoordsArray bottomRight = GetSelectionBlockBottomRight();
for (i = 0; i < topLeft.Count(); i++) {
//for (row = topLeft[i].GetRow(); row <= bottomRight[i].GetRow(); row++)
{
for (col = topLeft[i].GetCol(); col <= bottomRight[i].GetCol(); col++) {
//clearCellData(row, col);
cols.Add(col);
}
}
}
wxArrayInt cls = GetSelectedCols();
for (i = 0; i < cls.Count(); i++) {
if (cols.Index(cls[i])== wxNOT_FOUND) cols.Add(cls[i]);
// for (row = 1; row < GetNumberRows(); row++) {
// clearCellData(row, cols[i]);
// }
}
}
else {
return "not select cells or columns";
}
if (cols.Count()>0) {
//cols = GetSelectedCols();
if (cols.Count() < 3) {
wxMessageBox("The number of selected columns must be more than 2\nExample: LXY or XYYYY...", "Plot");
return "";
}
}
int idx = 0;
int cl1 = cols[idx];
int legC = -1;
int xC = -1;
int typeAxisX = mpX_DATETIME;
// Leg col
if (colTypClasses.Item(cl1) == PGTYPCLASS_STRING) { legC = cl1; idx++; }
cl1 = cols[idx];
// X col
wxString xA, yA;
xA = ctlSQLGrid::GetColumnName(cl1);
if (colTypClasses.Item(cl1) == PGTYPCLASS_DATE) { xC = cl1; idx++; }
else if (colTypClasses.Item(cl1) == PGTYPCLASS_NUMERIC) { xC = cl1; typeAxisX = mpX_NORMAL; idx++; }
if (xC == -1) { wxMessageBox("The value type of column X must be a date or a number", "Plot"); return ""; }
// Y cols
for (size_t col = idx; col < cols.Count(); col++)
{
int cl = cols[col];
if (colTypClasses.Item(cl) == PGTYPCLASS_NUMERIC) {
if (legC == -1) {
}
colsY.Add(cl);
leg.Add(ctlSQLGrid::GetColumnName(cl));
}
else {
wxMessageBox("The values of column Y must be numeric", "Plot");
return "";
}
}
if (legC != -1) yA = leg[0]; else yA = "Value";
//frmQuery* q = &parent;
frmPlot* frame = new frmPlot(parent,"Plot");
frame->ClearAndSetAxis(xA, typeAxisX, yA);
// Rows read
size_t numRows = GetNumberRows();
wxString lg,currLg;
if (legC !=-1) {
// 3 cols
std::vector<double> x,y;
int fmttype = -1;
wxDateTime dt;
for (int i = 0; i < numRows; i++)
{
if (GetRowSize(i) == 0) continue;
currLg= GetCellValue(i, legC);
if (lg != currLg && !lg.IsEmpty()) {
frame->AddSeries(lg, x, y);
lg = wxEmptyString;
}
if (lg.IsEmpty()) {
x.clear();
y.clear();
lg = currLg;
}
//str.Append(GetExportLine(i, cols));
wxString xVal = GetCellValue(i, xC);
wxString yVal = GetCellValue(i, colsY[0]);
double xv, yv;
//yv=wxAtof(yVal);
if (!yVal.ToCDouble(&yv)) { yVal.ToDouble(&yv); /* error! */ }
if (typeAxisX == mpX_DATETIME) {
dt = parseDT(fmttype, xVal);
if (fmttype == -1) {
wxString temp = wxString::Format("The values of column X must be timestamp [row: %d,col: %d]",i+1, colsY[0]);
wxMessageBox(temp, "Plot");
return "";
}
xv = (double)dt.GetTicks();
}
else
{
if (!xVal.ToCDouble(&xv)) { xVal.ToDouble(&xv); /* error! */ }
}
x.push_back(xv);
y.push_back(yv);
}
frame->AddSeries(lg, x, y);
}
else {
std::vector<double> x, y;
int fmttype = -1;
wxDateTime dt;
bool first = true;
for (size_t col = 0; col < colsY.Count(); col++)
{
lg = leg[col];
int ccol = colsY[col];
for (int i = 0; i < numRows; i++)
{
if (GetRowSize(i) == 0) continue;
//str.Append(GetExportLine(i, cols));
wxString yVal = GetCellValue(i, ccol);
double xv, yv;
if (!yVal.ToCDouble(&yv)) { yVal.ToDouble(&yv); /* error! */ }
if (first) {
wxString xVal = GetCellValue(i, xC);
if (typeAxisX == mpX_DATETIME) {
dt = parseDT(fmttype, xVal);
if (fmttype == -1) {
wxString temp = wxString::Format("The values of column X must be timestamp [row: %d,col: %d]", i, colsY[0]);
wxMessageBox(temp, "Plot");
return "";
}
xv = (double)dt.GetTicks();
}
else
{
if (!xVal.ToCDouble(&xv)) { xVal.ToDouble(&xv); /* error! */ }
}
x.push_back(xv);
}
y.push_back(yv);
}
frame->AddSeries(lg, x, y);
y.clear();
first = false;
}
}
frame->Go();
return "plot draw";
}
wxString ctlSQLResult::SummaryColumn()
{
//ce=cells.Item(0);

408
frm/frmPlot.cpp Normal file
View file

@ -0,0 +1,408 @@
#include "pgAdmin3.h"
#include "frm/frmPlot.h"
enum {
ID_QUIT = 108,
ID_ABOUT,
ID_PRINT,
ID_PRINT_PREVIEW,
ID_ALIGN_X_AXIS,
ID_ALIGN_Y_AXIS,
ID_TOGGLE_GRID,
ID_TOGGLE_SCROLLBARS,
ID_TOGGLE_INFO,
ID_SAVE_SCREENSHOT,
ID_TOGGLE_LISSAJOUX,
ID_TOGGLE_SHOW_SIMBOL,
ID_TOGGLE_COSINE,
ID_BLACK_THEME
};
//IMPLEMENT_DYNAMIC_CLASS(frmPlot, pgFrame)
static const struct wxColourDesc
{
const wxChar* name;
// unsigned char r, g, b;
}
colors[] =
{
wxT("#ED7D31")
,wxT("#997300")
,wxT("#A580D5")
,wxT("#70AD47")
,wxT("#FFC000")
,wxT("#4472C4")
,wxT("#70AD47")
,wxT("#CA682A")
,wxT("#FFE533")
,wxT("#FF5933")
,wxT("#FF59B9")
,wxT("#5A5FFF")
,wxT("#5A9F8A")
,wxT("#5A9F50")
,wxT("#1CD749")
,wxT("#6ABB49")
,wxT("#BEBB49")
,wxT("#4797D8")
,wxT("#4713D8")
,wxT("#7413D8")
,wxT("#B389D8")
,wxT("#9CDA89")
,wxT("#E7D900")
,wxT("#FF9A00")
,wxT("#00FF00")
,wxT("#8A7DFF")
,wxT("#250DFF")
,wxT("#DA0D8F")
,wxT("#17C3FF")
};
wxBEGIN_EVENT_TABLE(frmPlot, pgFrame)
// test
EVT_MENU(ID_ABOUT, frmPlot::OnAbout)
EVT_MENU(ID_QUIT, frmPlot::OnQuit)
EVT_MENU(ID_PRINT_PREVIEW, frmPlot::OnPrintPreview)
EVT_MENU(ID_PRINT, frmPlot::OnPrint)
EVT_MENU(mpID_FIT, frmPlot::OnFit)
EVT_MENU(ID_ALIGN_X_AXIS, frmPlot::OnAlignXAxis)
EVT_MENU(ID_ALIGN_Y_AXIS, frmPlot::OnAlignYAxis)
EVT_MENU(ID_TOGGLE_GRID, frmPlot::OnToggleGrid)
EVT_MENU(ID_TOGGLE_SCROLLBARS, frmPlot::OnCopy)
EVT_MENU(ID_TOGGLE_INFO, frmPlot::OnToggleInfoLayer)
EVT_MENU(ID_SAVE_SCREENSHOT, frmPlot::OnSaveScreenshot)
EVT_MENU(ID_BLACK_THEME, frmPlot::OnBlackTheme)
EVT_MENU(ID_TOGGLE_LISSAJOUX, frmPlot::OnToggleLissajoux)
EVT_MENU(ID_TOGGLE_SHOW_SIMBOL, frmPlot::OnToggleShowSimbol)
EVT_MENU(ID_TOGGLE_COSINE, frmPlot::OnToggleCosine)
EVT_CLOSE(frmPlot::OnClose)
wxEND_EVENT_TABLE()
frmPlot::frmPlot(frmQuery* parent, const wxString& _title) : pgFrame(parent, _title)
{
dlgName = wxT("frmPlot");
RestorePosition(-1, -1, 700, 500, 700, 500);
indexColor = 0;
//SetIcon(wxIcon(log_xpm));
wxMenu* file_menu = new wxMenu();
wxMenu* view_menu = new wxMenu();
wxMenu* show_menu = new wxMenu();
file_menu->Append(ID_PRINT_PREVIEW, wxT("Print Pre&view..."));
file_menu->Append(ID_PRINT, wxT("&Print..."));
file_menu->Append(ID_SAVE_SCREENSHOT, wxT("Save screenshot"));
file_menu->Append(ID_TOGGLE_SCROLLBARS, wxT("Copy clipboard screenshot\tCtrl+C"));
file_menu->AppendSeparator();
file_menu->Append(ID_ABOUT, wxT("&About..."));
file_menu->Append(ID_QUIT, wxT("E&xit\tAlt-X"));
view_menu->Append(mpID_FIT, wxT("&Fit bounding box"), wxT("Set plot view to show all items"));
view_menu->Append(mpID_ZOOM_IN, wxT("Zoom in"), wxT("Zoom in plot view."));
view_menu->Append(mpID_ZOOM_OUT, wxT("Zoom out"), wxT("Zoom out plot view."));
view_menu->AppendSeparator();
view_menu->Append(ID_ALIGN_X_AXIS, wxT("Switch &X axis align"));
view_menu->Append(ID_ALIGN_Y_AXIS, wxT("Switch &Y axis align"));
view_menu->AppendCheckItem(ID_TOGGLE_GRID, wxT("Toggle grid/ticks"));
//view_menu->AppendCheckItem( ID_TOGGLE_SCROLLBARS, wxT("Show Scroll Bars"));
view_menu->AppendCheckItem(ID_TOGGLE_INFO, wxT("Show overlay info box"));
view_menu->Check(ID_TOGGLE_INFO, true);
view_menu->AppendCheckItem(ID_BLACK_THEME, wxT("Switch to black background theme"));
//show_menu->AppendCheckItem(ID_TOGGLE_LISSAJOUX, wxT("Lissajoux"));
show_menu->AppendCheckItem(ID_TOGGLE_SHOW_SIMBOL, wxT("Show Simbol"));
//show_menu->AppendCheckItem(ID_TOGGLE_COSINE, wxT("Cosine"));
// Start with all plots visible
//show_menu->Check(ID_TOGGLE_LISSAJOUX, true);
show_menu->Check(ID_TOGGLE_SHOW_SIMBOL, true);
//show_menu->Check(ID_TOGGLE_COSINE, true);
wxMenuBar* menu_bar = new wxMenuBar();
menu_bar->Append(file_menu, wxT("&File"));
menu_bar->Append(view_menu, wxT("&View"));
menu_bar->Append(show_menu, wxT("&Show"));
SetMenuBar(menu_bar);
// CreateStatusBar(1);
mpLayer* l;
m_plot = new mpWindow(this, -1, wxPoint(0, 0), wxSize(100, 100), wxSUNKEN_BORDER);
m_plot->SetMargins(30, 100, 50, 100);
wxBoxSizer* topsizer = new wxBoxSizer(wxVERTICAL);
topsizer->Add(m_plot, 1, wxEXPAND);
// topsizer->Add(m_log, 0, wxEXPAND);
SetAutoLayout(TRUE);
SetSizer(topsizer);
axesPos[0] = 0;
axesPos[1] = 0;
ticks = true;
m_plot->Fit();
}
frmPlot::~frmPlot()
{
// If the status window wasn't launched in standalone mode...
//if (mainForm) mainForm->RemoveFrame(this);
// If connection is still available, delete it
SavePosition();
}
void frmPlot::Go()
{
// Show the window
m_plot->Fit();
Show(true);
}
void frmPlot::OnClose(wxCloseEvent& event) {
event.Skip();
}
void frmPlot::OnQuit(wxCommandEvent& WXUNUSED(event))
{
Close(TRUE);
}
void frmPlot::ClearAndSetAxis(wxString XtextAxis, unsigned int X_labelType, wxString YtextAxis)
{
m_plot->DelAllLayers(true, false);
mpScaleX* xaxis = new mpScaleX(XtextAxis, mpALIGN_BOTTOM, true, X_labelType);
mpScaleY* yaxis = new mpScaleY(YtextAxis, mpALIGN_LEFT, true);
wxFont graphFont(11, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
xaxis->SetFont(graphFont);
yaxis->SetFont(graphFont);
xaxis->SetDrawOutsideMargins(false);
yaxis->SetDrawOutsideMargins(false);
m_plot->AddLayer(xaxis);
m_plot->AddLayer(yaxis);
m_plot->AddLayer(nfo = new mpInfoCoords(wxRect(80, 20, 10, 10), wxTRANSPARENT_BRUSH)); //&hatch));
nfo->SetVisible(true);
//wxBrush hatch2(wxColour(163,208,212), wxSOLID);
mpInfoLegend* leg;
m_plot->AddLayer(leg = new mpInfoLegend(wxRect(20, 20, 40, 40), wxTRANSPARENT_BRUSH)); //&hatch2));
leg->SetVisible(true);
leg->SetDrawOutsideMargins(false);
indexColor = 0;
//m_plot->Fit();
}
void frmPlot::AddSeries(const wxString legend, const std::vector<double>& x, const std::vector<double>& y)
{
mpFXYVector* vectorLayer = new mpFXYVector(legend);
vectorLayer->SetData(x, y);
vectorLayer->SetContinuity(true);
size_t n;
wxColourDesc cc;
for (n = indexColor; n < WXSIZEOF(colors); n++)
{
cc = colors[n];
indexColor++;
break;
//= new wxColour(cc.name);
}
if (indexColor >= WXSIZEOF(colors)) cc.name = L"#000000";
wxPen vectorpen(wxColour(cc.name), 2, wxPENSTYLE_SOLID);
vectorLayer->SetPen(vectorpen);
vectorLayer->SetDrawOutsideMargins(false);
vectorLayer->ShowName(false);
vectorLayer->ShowSimbol(true);
m_plot->AddLayer(vectorLayer);
//m_plot->Fit();
}
void frmPlot::OnFit(wxCommandEvent& WXUNUSED(event))
{
m_plot->Fit();
}
void frmPlot::OnAbout(wxCommandEvent& WXUNUSED(event))
{
wxMessageBox(wxT("wxWidgets mathplot sample\n(c) 2003 David Schalig\n(c) 2007-2009 Davide Rondini and wxMathPlot team"));
}
void frmPlot::OnAlignXAxis(wxCommandEvent& WXUNUSED(event))
{
axesPos[0] = (int)(axesPos[0] + 1) % 5;
mpScaleX* xaxis = ((mpScaleX*)(m_plot->GetLayer(0)));
mpScaleY* yaxis = ((mpScaleY*)(m_plot->GetLayer(1)));
if (axesPos[0] == 0) {
xaxis->SetAlign(mpALIGN_BORDER_BOTTOM);
m_plot->SetMarginTop(0);
m_plot->SetMarginBottom(0);
}
if (axesPos[0] == 1) {
//((mpScaleX*)(m_plot->GetLayer(0)))->SetAlign(mpALIGN_BOTTOM);
xaxis->SetAlign(mpALIGN_BOTTOM);
m_plot->SetMarginTop(0);
m_plot->SetMarginBottom(50);
}
if (axesPos[0] == 2) {
//((mpScaleX*)(m_plot->GetLayer(0)))->SetAlign(mpALIGN_CENTER);
xaxis->SetAlign(mpALIGN_CENTER);
m_plot->SetMarginTop(0);
m_plot->SetMarginBottom(0);
}
if (axesPos[0] == 3) {
//((mpScaleX*)(m_plot->GetLayer(0)))->SetAlign(mpALIGN_TOP);
xaxis->SetAlign(mpALIGN_TOP);
m_plot->SetMarginTop(50);
m_plot->SetMarginBottom(0);
}
if (axesPos[0] == 4) {
((mpScaleX*)(m_plot->GetLayer(0)))->SetAlign(mpALIGN_BORDER_TOP);
xaxis->SetAlign(mpALIGN_BORDER_TOP);
m_plot->SetMarginTop(0);
m_plot->SetMarginBottom(0);
}
m_plot->UpdateAll();
}
void frmPlot::OnAlignYAxis(wxCommandEvent& WXUNUSED(event))
{
axesPos[1] = (int)(axesPos[1] + 1) % 5;
mpScaleX* xaxis = ((mpScaleX*)(m_plot->GetLayer(0)));
mpScaleY* yaxis = ((mpScaleY*)(m_plot->GetLayer(1)));
if (axesPos[1] == 0) {
//((mpScaleY*)(m_plot->GetLayer(1)))->SetAlign(mpALIGN_BORDER_LEFT);
yaxis->SetAlign(mpALIGN_BORDER_LEFT);
m_plot->SetMarginLeft(0);
m_plot->SetMarginRight(0);
}
if (axesPos[1] == 1) {
//((mpScaleY*)(m_plot->GetLayer(1)))->SetAlign(mpALIGN_LEFT);
yaxis->SetAlign(mpALIGN_LEFT);
m_plot->SetMarginLeft(70);
m_plot->SetMarginRight(0);
}
if (axesPos[1] == 2) {
//((mpScaleY*)(m_plot->GetLayer(1)))->SetAlign(mpALIGN_CENTER);
yaxis->SetAlign(mpALIGN_CENTER);
m_plot->SetMarginLeft(0);
m_plot->SetMarginRight(0);
}
if (axesPos[1] == 3) {
//((mpScaleY*)(m_plot->GetLayer(1)))->SetAlign(mpALIGN_RIGHT);
yaxis->SetAlign(mpALIGN_RIGHT);
m_plot->SetMarginLeft(0);
m_plot->SetMarginRight(70);
}
if (axesPos[1] == 4) {
//((mpScaleY*)(m_plot->GetLayer(1)))->SetAlign(mpALIGN_BORDER_RIGHT);
yaxis->SetAlign(mpALIGN_BORDER_RIGHT);
m_plot->SetMarginLeft(0);
m_plot->SetMarginRight(0);
}
m_plot->UpdateAll();
}
void frmPlot::OnToggleGrid(wxCommandEvent& event)
{
//ticks = !ticks;
ticks = !event.IsChecked();
((mpScaleX*)(m_plot->GetLayer(0)))->SetTicks(ticks);
((mpScaleY*)(m_plot->GetLayer(1)))->SetTicks(ticks);
m_plot->UpdateAll();
}
void frmPlot::OnCopy(wxCommandEvent& event)
{
// Write a bitmap to the clipboard wxImage image(wxT("splash.png"), wxBITMAP_TYPE_PNG);
wxBitmapType fileType = wxBITMAP_TYPE_PNG;
// wxSize imgSize(500, 500);
m_plot->SaveScreenshot("", fileType, wxDefaultSize, false,true);
}
void frmPlot::OnToggleInfoLayer(wxCommandEvent& event)
{
if (event.IsChecked())
nfo->SetVisible(true);
else
nfo->SetVisible(false);
m_plot->UpdateAll();
event.Skip();
}
void frmPlot::OnBlackTheme(wxCommandEvent& event)
{
//wxColor black(0,0,0);
//wxColor white(255,255,255);
wxColour grey(96, 96, 96);
/*wxBrush* brush = new wxBrush(*wxTRANSPARENT_BRUSH)*/;
m_plot->SetColourTheme(*wxBLACK, *wxWHITE, grey);
m_plot->UpdateAll();
}
void frmPlot::OnPrintPreview(wxCommandEvent& WXUNUSED(event))
{
// Pass two printout objects: for preview, and possible printing.
mpPrintout* plotPrint = new mpPrintout(m_plot);
mpPrintout* plotPrintPreview = new mpPrintout(m_plot);
wxPrintPreview* preview = new wxPrintPreview(plotPrintPreview, plotPrint);
wxPreviewFrame* frame = new wxPreviewFrame(preview, this, wxT("Print Plot"), wxPoint(100, 100), wxSize(600, 650));
frame->Centre(wxBOTH);
frame->Initialize();
frame->Show(true);
}
void frmPlot::OnPrint(wxCommandEvent& WXUNUSED(event))
{
wxPrinter printer;
mpPrintout printout(m_plot, wxT("Plot print"));
printer.Print(this, &printout, true);
}
void frmPlot::OnSaveScreenshot(wxCommandEvent& event)
{
wxFileDialog fileDialog(this, _("Save a screenshot"), wxT(""), wxT(""), wxT("BMP image (*.bmp) | *.bmp|JPEG image (*.jpg) | *.jpeg;*.jpg|PNG image (*.png) | *.png"), wxFD_SAVE);
if (fileDialog.ShowModal() == wxID_OK) {
wxFileName namePath(fileDialog.GetPath());
wxBitmapType fileType = wxBITMAP_TYPE_BMP;
if (namePath.GetExt().CmpNoCase(wxT("jpeg")) == 0) fileType = wxBITMAP_TYPE_JPEG;
if (namePath.GetExt().CmpNoCase(wxT("jpg")) == 0) fileType = wxBITMAP_TYPE_JPEG;
if (namePath.GetExt().CmpNoCase(wxT("png")) == 0) fileType = wxBITMAP_TYPE_PNG;
wxSize imgSize(500, 500);
m_plot->SaveScreenshot(fileDialog.GetPath(), fileType, imgSize, false);
}
event.Skip();
}
void frmPlot::OnToggleLissajoux(wxCommandEvent& event)
{
m_plot->SetLayerVisible(wxT("Lissajoux"), event.IsChecked());
}
void frmPlot::OnToggleShowSimbol(wxCommandEvent& event)
{
//m_plot->SetLayerVisible(wxT("f(x) = SIN(x)"), event.IsChecked());
mpLayer* ly = NULL;
wxPen lpen;
wxString label;
bool show = event.IsChecked();
for (unsigned int p = 0; p < m_plot->CountAllLayers(); p++) {
ly = m_plot->GetLayer(p);
if ((ly->GetLayerType() == mpLAYER_PLOT)) {
mpFXYVector* ly = reinterpret_cast<mpFXYVector*>(m_plot->GetLayer(p));
ly->ShowSimbol(show);
}
}
m_plot->UpdateAll();
}
void frmPlot::OnToggleCosine(wxCommandEvent& event)
{
m_plot->SetLayerVisible(wxT("g(y) = COS(y)"), event.IsChecked());
}

View file

@ -124,6 +124,7 @@ BEGIN_EVENT_TABLE(frmQuery, pgFrame)
EVT_MENU(MNU_COPY_WHERELIST, frmQuery::OnCopy_WhereList)
EVT_MENU(MNU_CLEAR_FILTER, frmQuery::OnClear_Filter)
EVT_MENU(MNU_CHECK_COLUMN_DATE, frmQuery::OnCheck_Column_Date)
EVT_MENU(MNU_AUTOCOLSPLOT, frmQuery::OnAutoColsPlot)
EVT_MENU(MNU_FIND, frmQuery::OnSearchReplace)
EVT_MENU(MNU_UNDO, frmQuery::OnUndo)
EVT_MENU(MNU_REDO, frmQuery::OnRedo)
@ -2171,14 +2172,16 @@ void frmQuery::OnLabelRightClick(wxGridEvent &event)
xmenu->Append(MNU_COPY, _("&Copy"), _("Copy selected cells to clipboard."));
xmenu->Append(MNU_PASTE, _("&Paste"), _("Paste data from the clipboard."));
xmenu->Append(MNU_DELETE, _("&Delete"), _("Delete selected rows."));
xmenu->Append(MNU_AUTOCOLSPLOT, _("Draw plot LXY or XYYY..."), _("Draw plot LXY or XYYY..."));
xmenu->Append(MNU_SUMMARY_COL, _("Summary"), _("Summary selected cells."));
xmenu->Append(MNU_CHECK_COLUMN_DATE, _("Check the sequence of dates"), _("Check the sequence of dates"));
xmenu->Append(MNU_COPY_INSERT, _("Copy Insert format"), _("Copy Insert format."));
xmenu->Append(MNU_COPY_INLIST, _("IN LIST format copy"), _("Copy In list format."));
xmenu->Append(MNU_COPY_WHERELIST, _("WHERE LIST format copy"), _("Copy where list format."));
xmenu->Append(MNU_CLEAR_FILTER, _("Clear filter"), _("Clear filter"));
xmenu->Enable(MNU_CHECK_COLUMN_DATE, sqlResult->GetSelectedCols().GetCount() > 0);
bool selcol = sqlResult->GetSelectedCols().GetCount() > 0;
xmenu->Enable(MNU_CHECK_COLUMN_DATE, selcol);
xmenu->Enable(MNU_AUTOCOLSPLOT, sqlResult->IsSelection());
xmenu->Enable(MNU_SUMMARY_COL, sqlResult->IsSelection());
xmenu->Enable(MNU_COPY_INLIST, sqlResult->IsSelection());
xmenu->Enable(MNU_COPY_WHERELIST, sqlResult->IsSelection());
@ -2257,6 +2260,16 @@ void frmQuery::OnCheck_Column_Date(wxCommandEvent& ev)
}
}
void frmQuery::OnAutoColsPlot(wxCommandEvent& ev)
{
// if (currentControl() == sqlResult)
{
frmQuery* q = this;
wxString s = sqlResult->AutoColsPlot(0, q);
SetStatusText(s, STATUSPOS_MSGS);
}
}
void frmQuery::OnSummary_Column(wxCommandEvent &ev)
{
// if (currentControl() == sqlResult)

3183
frm/mathplot.cpp Normal file

File diff suppressed because it is too large Load diff

View file

@ -45,6 +45,7 @@ public:
isSort=flag;
};
wxString GetColumnName(int colNum);
wxSize GetBestSize(int row, int col);
void OnLabelDoubleClick(wxGridEvent &event);
void OnLabelClick(wxGridEvent &event);
@ -67,7 +68,6 @@ private:
void OnMouseWheel(wxMouseEvent &event);
void OnGridColSize(wxGridSizeEvent &event);
void DrawColLabel( wxDC& dc, int col );
wxString GetColumnName(int colNum);
wxString GetColKeyValue(int col);
void AppendColumnHeader(wxString &str, int start, int end);
void AppendColumnHeader(wxString &str, wxArrayInt columns);

View file

@ -19,6 +19,7 @@
#include "db/pgConn.h"
#include "ctlSQLGrid.h"
#include "frm/frmExport.h"
#include "frm/frmQuery.h"
#define CTLSQL_RUNNING 100 // must be greater than ExecStatusType PGRES_xxx values
@ -47,6 +48,7 @@ public:
wxString OnGetItemText(long item, long col) const;
wxString SummaryColumn();
wxString AutoColsPlot(int flags,frmQuery *parent);
wxString CheckSelColumnDate();
void ClearFilter();
bool IsColText(int col);

48
include/frm/frmPlot.h Normal file
View file

@ -0,0 +1,48 @@
#pragma once
#ifndef __FRMPLOT_H
#define __FRMPLOT_H
// wxWindows headers
#include "pgAdmin3.h"
#include "frmQuery.h"
#include "mathplot.h"
class frmPlot : public pgFrame
{
public:
frmPlot(frmQuery* parent, const wxString& _title);
~frmPlot();
void Go();
void AddSeries(const wxString legend, const std::vector<double>& x, const std::vector<double>& y);
void ClearAndSetAxis(wxString XtextAxis, unsigned int X_labelType, wxString YtextAxis);
void OnAbout(wxCommandEvent& event);
void OnQuit(wxCommandEvent& event);
void OnPrintPreview(wxCommandEvent& event);
void OnPrint(wxCommandEvent& event);
void OnFit(wxCommandEvent& event);
void OnAlignXAxis(wxCommandEvent& event);
void OnAlignYAxis(wxCommandEvent& event);
void OnToggleGrid(wxCommandEvent& event);
void OnCopy(wxCommandEvent& event);
void OnToggleInfoLayer(wxCommandEvent& event);
void OnSaveScreenshot(wxCommandEvent& event);
void OnToggleLissajoux(wxCommandEvent& event);
void OnToggleShowSimbol(wxCommandEvent& event);
void OnToggleCosine(wxCommandEvent& event);
void OnBlackTheme(wxCommandEvent& event);
mpWindow* m_plot;
private:
void OnClose(wxCloseEvent& event);
int axesPos[2];
bool ticks;
mpInfoCoords* nfo; // mpInfoLayer* nfo;
//DECLARE_DYNAMIC_CLASS(frmPlot)
int indexColor;
DECLARE_EVENT_TABLE()
};
#endif

View file

@ -219,6 +219,7 @@ private:
void OnCopy_WhereList(wxCommandEvent& event);
void OnClear_Filter(wxCommandEvent &event);
void OnCheck_Column_Date(wxCommandEvent& ev);
void OnAutoColsPlot(wxCommandEvent& ev);
void OnSearchReplace(wxCommandEvent &event);
void OnUndo(wxCommandEvent &event);
void OnRedo(wxCommandEvent &event);

1875
include/frm/mathplot.h Normal file

File diff suppressed because it is too large Load diff

View file

@ -81,6 +81,7 @@ enum
MNU_COPY_WHERELIST,
MNU_CLEAR_FILTER,
MNU_CHECK_COLUMN_DATE,
MNU_AUTOCOLSPLOT,
MNU_AUTOROLLBACK,
MNU_AUTOCOMMIT,
MNU_CLEARHISTORY,

View file

@ -912,11 +912,13 @@
<ClCompile Include="frm\frmOptions.cpp" />
<ClCompile Include="frm\frmPassword.cpp" />
<ClCompile Include="frm\frmPgpassConfig.cpp" />
<ClCompile Include="frm\frmPlot.cpp" />
<ClCompile Include="frm\frmQuery.cpp" />
<ClCompile Include="frm\frmReport.cpp" />
<ClCompile Include="frm\frmRestore.cpp" />
<ClCompile Include="frm\frmSplash.cpp" />
<ClCompile Include="frm\frmStatus.cpp" />
<ClCompile Include="frm\mathplot.cpp" />
<ClCompile Include="frm\plugins.cpp" />
<ClCompile Include="pro_scheduler\pgproJob.cpp" />
<ClCompile Include="schema\edbPackage.cpp" />
@ -1549,6 +1551,8 @@
<ClInclude Include="include\dlg\dlgProJob.h" />
<ClInclude Include="include\dlg\dlgResourceGroup.h" />
<ClInclude Include="include\frm\frmLog.h" />
<ClInclude Include="include\frm\frmPlot.h" />
<ClInclude Include="include\frm\mathplot.h" />
<ClInclude Include="include\log\MyDataViewCtrl.h" />
<ClInclude Include="include\log\Storage.h" />
<ClInclude Include="include\log\StorageModel.h" />

View file

@ -1650,6 +1650,12 @@
<ClCompile Include="utils\log\MyDataViewCtrl.cpp">
<Filter>utils</Filter>
</ClCompile>
<ClCompile Include="frm\frmPlot.cpp">
<Filter>frm</Filter>
</ClCompile>
<ClCompile Include="frm\mathplot.cpp">
<Filter>frm</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<None Include="agent\module.mk">
@ -3548,6 +3554,12 @@
<ClInclude Include="include\log\MyDataViewCtrl.h">
<Filter>include\log</Filter>
</ClInclude>
<ClInclude Include="include\frm\frmPlot.h">
<Filter>include\frm</Filter>
</ClInclude>
<ClInclude Include="include\frm\mathplot.h">
<Filter>include\frm</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<png2c Include="include\images\aggregate-sm.png">