Ejemplo n.º 1
0
	virtual Chart *Create()
	{
		// serie xy data
		double data[][2] = {
				{ 10, 20, },
				{ 13, 16, },
				{ 14, 30, },
				{ 15, 34, },
				{ 25, 4, },
		};

		// first step: create plot
		XYPlot *plot = new XYPlot();

		// create dataset
		XYSimpleDataset *dataset = new XYSimpleDataset();

		// and add serie to it
		dataset->AddSerie((double *) data, WXSIZEOF(data));

		// set line renderer to dataset
		dataset->SetRenderer(new XYLineRenderer());

		// create first range marker
		RangeMarker *rangeMarker1 = new RangeMarker(new FillAreaDraw(wxColour(80, 80, 255), wxColour(200, 200, 250)));

		// set value to be marked, in our case vertical range [15; 20]
		rangeMarker1->SetVerticalRange(15, 20);

		// and add marker to dataset
		dataset->AddMarker(rangeMarker1);

		// create line marker
		LineMarker *lineMarker = new LineMarker(wxColour(80, 80, 255), 2);

		// set value to be marked, in our case horizontal value 15
		lineMarker->SetHorizontalLine(25);

		// and add marker to dataset
		dataset->AddMarker(lineMarker);

		// create left and bottom number axes
		NumberAxis *leftAxis = new NumberAxis(AXIS_LEFT);
		NumberAxis *bottomAxis = new NumberAxis(AXIS_BOTTOM);

		// add axes and dataset to plot
		plot->AddObjects(dataset, leftAxis, bottomAxis);

		// and finally create chart
		return new Chart(plot, GetName());
	}
Ejemplo n.º 2
0
	virtual Chart *Create()
	{
		// serie xy data
		double data[][2] = {
				{ 10, 20, },
				{ 13, 16, },
				{ 7, 30, },
				{ 15, 34, },
				{ 25, 4, },
		};

		// first step: create plot
		XYPlot *plot = new XYPlot();

		// create dataset
		XYSimpleDataset *dataset = new XYSimpleDataset();

		// and add serie to it
		dataset->AddSerie((double *) data, WXSIZEOF(data));

		// set line renderer to dataset
		dataset->SetRenderer(new XYLineRenderer());

		// create line marker
		LineMarker *lineMarker = new LineMarker(wxPen(*wxBLUE, 2, wxSOLID));

		// set value to be marked, in our case vertical line with x=20
		lineMarker->SetVerticalLine(20);

		// and add marker to dataset
		dataset->AddMarker(lineMarker);

		// create left and bottom number axes
		NumberAxis *leftAxis = new NumberAxis(AXIS_LEFT);
		NumberAxis *bottomAxis = new NumberAxis(AXIS_BOTTOM);

		// add axes and dataset to plot
		plot->AddObjects(dataset, leftAxis, bottomAxis);

		// and finally create chart
		return new Chart(plot, GetName());
	}
Ejemplo n.º 3
0
CWindowDialogPlots::CWindowDialogPlots(
    CDisplayWindowPlots *winPlots,
    WxSubsystem::CWXMainFrame* parent,
    wxWindowID id,
    const std::string &caption,
    wxSize initialSize )
    :
    m_winPlots( winPlots ),
    m_mainFrame(parent),
	m_firstSubmenu(true)
{
    Create(
        parent,
        id,
        _U(caption.c_str()),
        wxDefaultPosition,
        initialSize,
        wxDEFAULT_FRAME_STYLE,
        _T("id"));

    SetClientSize(initialSize);

	wxIcon FrameIcon;
	FrameIcon.CopyFromBitmap(mrpt::gui::WxSubsystem::getMRPTDefaultIcon());
	SetIcon(FrameIcon);


    // Create the mpWindow object:
    m_plot = new mpWindow( this, ID_PLOT );
    m_plot->AddLayer( new mpScaleX() );
    m_plot->AddLayer( new mpScaleY() );
    m_plot->LockAspect( false );
    m_plot->EnableDoubleBuffer(true);

    m_plot->Fit( -10,10,-10,10 );

    // Menu:
    wxMenuBar *MenuBar1 = new wxMenuBar();

    wxMenu *Menu1 = new wxMenu();
    wxMenuItem *MenuItem1 = new wxMenuItem(Menu1, ID_MENUITEM1, _("Close"), _(""), wxITEM_NORMAL);
    Menu1->Append(MenuItem1);

    wxMenuItem *MenuItemPrint = new wxMenuItem(Menu1, ID_MENU_PRINT, _("Print..."), _(""), wxITEM_NORMAL);
    Menu1->Append(MenuItemPrint);

    MenuBar1->Append(Menu1, _("&File"));

    wxMenu *Menu2 = new wxMenu();
    wxMenuItem *MenuItem2 = new wxMenuItem(Menu2, ID_MENUITEM2, _("About..."), _(""), wxITEM_NORMAL);
    Menu2->Append(MenuItem2);
    MenuBar1->Append(Menu2, _("&Help"));

    SetMenuBar(MenuBar1);


    // Events:
    Connect(wxID_ANY,wxEVT_CLOSE_WINDOW,(wxObjectEventFunction)&CWindowDialogPlots::OnClose);
    Connect(ID_MENUITEM1,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&CWindowDialogPlots::OnMenuClose);
    Connect(ID_MENU_PRINT,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&CWindowDialogPlots::OnMenuPrint);
    Connect(ID_MENUITEM2,wxEVT_COMMAND_MENU_SELECTED,(wxObjectEventFunction)&CWindowDialogPlots::OnMenuAbout);

	Connect(wxID_ANY,wxEVT_SIZE,(wxObjectEventFunction)&CWindowDialogPlots::OnResize);

	Connect(wxID_ANY,wxEVT_CHAR,(wxObjectEventFunction)&CWindowDialogPlots::OnChar);
	m_plot->Connect(wxEVT_CHAR,(wxObjectEventFunction)&CWindowDialogPlots::OnChar,0,this);
	m_plot->Connect(wxEVT_MOTION,(wxObjectEventFunction)&CWindowDialogPlots::OnMouseMove,0,this);

	m_plot->Connect(wxEVT_LEFT_DOWN,(wxObjectEventFunction)&CWindowDialogPlots::OnMouseDown,NULL,this);
	m_plot->Connect(wxEVT_RIGHT_DOWN,(wxObjectEventFunction)&CWindowDialogPlots::OnMouseDown,NULL,this);

    // Increment number of windows:
    //int winCount =
    WxSubsystem::CWXMainFrame::notifyWindowCreation();
    //cout << "[CWindowDialogPlots] Notifying new window: " << winCount << endl;

	//this->Iconize(false);

#if 0
	// JL: TEST CODE: This is the seed of the future new implementation based on wxFreeChart...
	double data[][2] = {
			{ 10, 20, },
			{ 13, 16, },
			{ 7, 30, },
			{ 15, 34, },
			{ 25, 4, },
	};
	// first step: create plot
	XYPlot *plot = new XYPlot();
	// create dataset
	XYSimpleDataset *dataset = new XYSimpleDataset();
	// and add serie to it
	dataset->AddSerie((double *) data, WXSIZEOF(data));
	// set line renderer to dataset
	dataset->SetRenderer(new XYLineRenderer());
	// add our dataset to plot
	plot->AddDataset(dataset);
	// create left and bottom number axes
	NumberAxis *leftAxis = new NumberAxis(AXIS_LEFT);
	NumberAxis *bottomAxis = new NumberAxis(AXIS_BOTTOM);
	// optional: set axis titles
	leftAxis->SetTitle(wxT("X"));
	bottomAxis->SetTitle(wxT("Y"));
	// add axes to plot
	plot->AddAxis(leftAxis);
	plot->AddAxis(bottomAxis);
	// link axes and dataset
	plot->LinkDataVerticalAxis(0, 0);
	plot->LinkDataHorizontalAxis(0, 0);
	// and finally create chart
	Chart* chart = new Chart(plot, wxT("my title"));
	wxChartPanel *m_chartPanel = new wxChartPanel( this ); //, ID_PLOT );
	m_chartPanel->SetChart( chart );
#endif
}
Ejemplo n.º 4
0
	virtual Chart *Create()
	{
		// first dataset values
		double values1[][2] = {
				{ 1, 1 },
				{ 2, 3 },
				{ 5, 4 },
				{ 6, 3 },
				{ 7, 6 },
				{ 8, 6 },
				{ 9, 4 },
		};

		// second dataset values
		double values2[][2] = {
				{ 0, 0 },
				{ 2, -1 },
				{ 4, 6 },
				{ 5, 2 },
				{ 7, 8 },
				{ 8, 4 },
				{ 9, -2 },
		};

		// colors for first and second datasets
		wxColour color1 = wxColour(255, 0, 0);
		wxColour color2 = wxColour(0, 0, 255);

		// create xy plot
		XYPlot *plot = new XYPlot();

		// create first dataset
		XYSimpleDataset *dataset1 = new XYSimpleDataset();
		// add serie to it
		dataset1->AddSerie((double *) values1, WXSIZEOF(values1));

		// create second dataset
		XYSimpleDataset *dataset2 = new XYSimpleDataset();
		// add serie to it
		dataset2->AddSerie((double *) values2, WXSIZEOF(values2));

		// create renderer for first dataset
		XYLineRenderer *renderer1 = new XYLineRenderer();
		renderer1->SetSerieColour(0, &color1);

		// add first dataset to plot
		plot->AddDataset(dataset1);

		// set it to first dataset
		dataset1->SetRenderer(renderer1);

		// create renderer for second dataset
		XYLineRenderer *renderer2 = new XYLineRenderer();
		renderer2->SetSerieColour(0, &color2);

		// set it to second dataset
		dataset2->SetRenderer(renderer2);

		// add second dataset to plot
		plot->AddDataset(dataset2);

		// create left axis for first dataset
		NumberAxis *leftAxis1 = new NumberAxis(AXIS_LEFT);
		// set label text colour same as lines
		leftAxis1->SetLabelTextColour(color1);
		// set label lines colour same as lines
		leftAxis1->SetLabelPen(*wxThePenList->FindOrCreatePen(color1, 1, wxPENSTYLE_SOLID));
		plot->AddAxis(leftAxis1);

		// create left axis for second dataset
		NumberAxis *leftAxis2 = new NumberAxis(AXIS_LEFT);
		// set label text colour same as lines
		leftAxis2->SetLabelTextColour(color2);
		// set label lines colour same as lines
		leftAxis2->SetLabelPen(*wxThePenList->FindOrCreatePen(color2, 1, wxPENSTYLE_SOLID));
		plot->AddAxis(leftAxis2);

		// create bottom axis for first and second dataset
		NumberAxis *bottomAxis = new NumberAxis(AXIS_BOTTOM);
		plot->AddAxis(bottomAxis);

		// link first dataset with first left axis
		plot->LinkDataVerticalAxis(0, 0);
		// link second dataset with second left axis
		plot->LinkDataVerticalAxis(1, 1);

		// link first and second datasets with bottom axis
		plot->LinkDataHorizontalAxis(0, 0);
		plot->LinkDataHorizontalAxis(1, 0);

		return new Chart(plot, GetName());
	}
Ejemplo n.º 5
0
	virtual Chart *Create()
	{
		// first dataset values
		double values1[][2] = {
				{ 1, 1 },
				{ 2, 3 },
				{ 5, 4 },
				{ 6, 3 },
				{ 7, 6 },
				{ 8, 6 },
				{ 9, 4 },
		};

		// second dataset values
		double values2[][2] = {
				{ 0, 0 },
				{ 2, -1 },
				{ 4, 6 },
				{ 5, 2 },
				{ 7, 8 },
				{ 8, 4 },
				{ 9, -2 },
		};

		// colors for first and second datasets
		wxColour color1 = wxColour(255, 0, 0);
		wxColour color2 = wxColour(0, 0, 255);

		// create xy plot
		XYPlot *plot = new XYPlot();

		// create first dataset
		XYSimpleDataset *dataset1 = new XYSimpleDataset();
		// add serie to it
		dataset1->AddSerie((double *) values1, WXSIZEOF(values1));

		// create second dataset
		XYSimpleDataset *dataset2 = new XYSimpleDataset();
		// add serie to it
		dataset2->AddSerie((double *) values2, WXSIZEOF(values2));

		// create renderer for first dataset
		XYLineRenderer *renderer1 = new XYLineRenderer();
		renderer1->SetSerieColour(0, &color1);

		// add first dataset to plot
		plot->AddDataset(dataset1);

		// set it to first dataset
		dataset1->SetRenderer(renderer1);

		// create renderer for second dataset
		XYLineRenderer *renderer2 = new XYLineRenderer();
		renderer2->SetSerieColour(0, &color2);

		// set it to second dataset
		dataset2->SetRenderer(renderer2);

		// add second dataset to plot
		plot->AddDataset(dataset2);

		// create left axis for first dataset
		NumberAxis *leftAxis = new NumberAxis(AXIS_LEFT);
		leftAxis->SetLabelTextColour(color1);
        leftAxis->SetTitle("Left Axis");
		plot->AddAxis(leftAxis);

		// create left axis for second dataset
		NumberAxis *rightAxis = new NumberAxis(AXIS_RIGHT);
		rightAxis->SetLabelTextColour(color2);
        rightAxis->SetTitle("Right Axis");
		plot->AddAxis(rightAxis);

		// create top axis for first dataset
		NumberAxis *topAxis = new NumberAxis(AXIS_TOP);
		topAxis->SetLabelTextColour(color1);
        topAxis->SetTitle("Top Axis");
		plot->AddAxis(topAxis);

		// create bottom axis for second dataset
		NumberAxis *bottomAxis = new NumberAxis(AXIS_BOTTOM);
		bottomAxis->SetLabelTextColour(color2);
		bottomAxis->SetTitle("Bottom Axis");
        plot->AddAxis(bottomAxis);

		// link first dataset with left axis
		plot->LinkDataVerticalAxis(0, 0);
		// link second dataset with right axis
		plot->LinkDataVerticalAxis(1, 1);

		// link first dataset with top axis
		plot->LinkDataHorizontalAxis(0, 0);

		// link second dataset with bottom axis
		plot->LinkDataHorizontalAxis(1, 1);

		return new Chart(plot, GetName());
	}
Ejemplo n.º 6
0
	virtual Chart *Create()
	{
		// data
		double data[] = {
			 64.09,
			 63.34,
			 61.41,
			 62.00,
			 61.71,
			 63.39,
			 63.64,
			 63.61,
			 65.11,
			 65.72,
			 66.89,
			 66.68,
			 66.51,
			 66.40,
			 67.27,
			 67.66,
		};
		// dates
		const wxChar *strDates[] = {
			wxT("20060317"),
			wxT("20060320"),
			wxT("20060321"),
			wxT("20060322"),
			wxT("20060323"),
			wxT("20060324"),
			wxT("20060327"),
			wxT("20060328"),
			wxT("20060329"),
			wxT("20060330"),
			wxT("20060331"),
			wxT("20060403"),
			wxT("20060404"),
			wxT("20060405"),
			wxT("20060406"),
			wxT("20060407"),
		};

		time_t times[WXSIZEOF(strDates)];

		wxDateTime dt;
		for (size_t n = 0; n < WXSIZEOF(strDates); n++) {
			dt.ParseFormat(strDates[n], wxT("%Y%m%d"));
			times[n] = dt.GetTicks();
		}

		// first step: create plot
		XYPlot *plot = new XYPlot();

		TimeSeriesDataset *dataset = new TimeSeriesDataset(data, times, WXSIZEOF(data));

		dataset->SetRenderer(new XYLineRenderer());

		plot->AddDataset(dataset);

		// add left number and bottom date axes
		NumberAxis *leftAxis = new NumberAxis(AXIS_LEFT);
		DateAxis *bottomAxis = new DateAxis(AXIS_BOTTOM);

		// setup window
		//bottomAxis->SetWindow(0, 10);
		//bottomAxis->SetUseWindow(true);

		bottomAxis->SetVerticalLabelText(true);
		bottomAxis->SetDateFormat(wxT("%d-%m"));

		// add axes to first plot
		plot->AddAxis(leftAxis);
		plot->AddAxis(bottomAxis);

		// link axes and dataset
		plot->LinkDataVerticalAxis(0, 0);
		plot->LinkDataHorizontalAxis(0, 0);

		// and finally create chart
		Chart *chart = new Chart(plot, GetName());

		//chart->SetScrolledAxis(bottomAxis);
		return chart;
	}
void Window_Profiles::Plot_Profiles()
{
	// Find the right x variable, together with the x axis lable
	QVector<double> axis_x;
	QString axis_x_title;
	FindXVariable(axis_x, axis_x_title);

	// XY Plot
	XYPlot* xyplot;
	xyplot = new XYPlot(this);
	xyplot->SetAbscissas(axis_x);
	xyplot->SetXTitle(axis_x_title);
	
	// Select additional y variables
	unsigned int n_selected_additional;
	{
		QList<QListWidgetItem*> selected_additional = ui.listWidget_Additional->selectedItems();
		n_selected_additional = selected_additional.size();
		for(unsigned int j=0;j<n_selected_additional;j++)
		{
			for(unsigned int k=0;k<data_->string_list_additional.size();k++)
			if (selected_additional[j]->text() == data_->string_list_additional[k])
			{
				xyplot->AddGraph(selected_additional[j]->text().toStdString(), data_->additional[k]);
				break;
			}
		}	
	}

	// Select y variables among the species
	{
		QList<QListWidgetItem*> selected_species = ui.listWidget_Species->selectedItems();
		unsigned int n_selected_species = selected_species.size();
		if (n_selected_species == 0 && n_selected_additional == 0)
		{
			QMessageBox msgBox;
			msgBox.setText(QString::fromStdString("At least one species must be selected in the Species Panel"));
			msgBox.exec();
			return;
		}

		for(unsigned int j=0;j<n_selected_species;j++)
		{
			for(unsigned int k=0;k<data_->string_list_massfractions_sorted.size();k++)
			if (selected_species[j]->text() == data_->string_list_massfractions_sorted[k])
			{
				QVector<double> tmp = data_->omega[data_->sorted_index[k]];
				const double mwj = data_->mw_species_[data_->sorted_index[k]];
			
				if (ui.radioButton_x->isChecked())
				{
					for(unsigned int i=0;i<data_->number_of_abscissas_;i++)
						tmp[i] = tmp[i] * data_->additional[data_->index_MW][i] / mwj;
				}
				else if (ui.radioButton_c->isChecked())
				{
					for(unsigned int i=0;i<data_->number_of_abscissas_;i++)
					{
						double cTot = data_->additional[data_->index_P][i]/PhysicalConstants::R_J_kmol/data_->additional[data_->index_T][i];
						tmp[i] = cTot * tmp[i] * data_->additional[data_->index_MW][i] / mwj;
					}
				}
				else if (ui.radioButton_p->isChecked())
				{
					for(unsigned int i=0;i<data_->number_of_abscissas_;i++)
						tmp[i] = tmp[i] * data_->additional[data_->index_MW][i] / mwj * (data_->additional[data_->index_P][i]/101325.);
				}

				xyplot->AddGraph(selected_species[j]->text().toStdString(), tmp);
				break;
			}
		}
	}

	// Plot
	xyplot->Plot();
}
void Window_Profiles::Plot_Selectivities()
{
	// Find the right x variable, together with the x axis lable
	QVector<double> axis_x;
	QString axis_x_title;
	FindXVariable(axis_x, axis_x_title);

	// XY Plot
	XYPlot* xyplot;
	xyplot = new XYPlot(this);
	xyplot->SetXTitle(axis_x_title);
	xyplot->SetYTitle("selectivity [-]");

	// Find the species for the conversion
	unsigned int index_species_conversion = data_->list_of_conversion_species_[ui.comboBox_Conversion->currentIndex()];

	// If the conversion is too small, the sensitivity coefficient is badly defined
	// Therefore the calculation is skipped in those points
	const double eta_threshold = 1.e-6;
	QVector<double> omega_conversion = data_->omega[index_species_conversion];
	QVector<double> eta_x;
	for(unsigned int i=0;i<data_->number_of_abscissas_;i++)
	{
		const double conversion = (omega_conversion[0] - omega_conversion[i])/omega_conversion[0];
		if (conversion > eta_threshold)	
				eta_x.push_back(axis_x[i]);
	}
	xyplot->SetAbscissas(eta_x);

	// Reconstruct the profiles
	{
		QList<QListWidgetItem*> selected_species_selectivity = ui.listWidget_Species_Selectivity->selectedItems();
		unsigned int n_selected_species = selected_species_selectivity.size();
		if (n_selected_species == 0)
		{
			QMessageBox msgBox;
			msgBox.setText(QString::fromStdString("At least one species must be selected in the Species (Selectivity) Panel"));
			msgBox.exec();
			return;
		}

		for(unsigned int j=0;j<n_selected_species;j++)
		{
			for(unsigned int k=0;k<data_->string_list_massfractions_sorted.size();k++)
			if (selected_species_selectivity[j]->text() == data_->string_list_massfractions_sorted[k])
			{
				unsigned int index_selectivity = data_->sorted_index[k];
				
				QVector<double> sigma;
				for(unsigned int i=0;i<data_->number_of_abscissas_;i++)
				{
					const double conversion = (omega_conversion[0] - omega_conversion[i])/omega_conversion[0];
					if (conversion > eta_threshold)
						sigma.push_back(data_->omega[index_selectivity][i]/omega_conversion[0]/conversion);
				}

				if (ui.radioButton_Selectivity_Mole->isChecked() == true)
				{
					const double mw_conversion = data_->mw_species_[index_species_conversion];
					const double mw_selectivity = data_->mw_species_[index_selectivity];
					for(unsigned int i=0;i<sigma.size();i++)
						sigma[i] *= mw_conversion/mw_selectivity;
				}

				if (ui.radioButton_Selectivity_Element->isChecked() == true)
				{
					const double n_conversion  = data_->thermodynamicsMapXML->atomic_composition()(index_species_conversion, ui.comboBox_Elements->currentIndex());
					const double n_selectivity = data_->thermodynamicsMapXML->atomic_composition()(index_selectivity, ui.comboBox_Elements->currentIndex());

					if (n_conversion > 0)
					{
						const double mw_conversion = data_->mw_species_[index_species_conversion];
						const double mw_selectivity = data_->mw_species_[index_selectivity];
						for(unsigned int i=0;i<sigma.size();i++)
							sigma[i] *= mw_conversion/mw_selectivity *n_selectivity/n_conversion;
					}
					else
					{
						QMessageBox msgBox;
						msgBox.setText(QString::fromStdString("The selected element is not present in the selected species (conversion side)"));
						msgBox.exec();
						return;
					}
				}

				xyplot->AddGraph(selected_species_selectivity[j]->text().toStdString(), sigma);
				break;
			}
		}

		// Plot
		xyplot->Plot();
	}
}