#include <SciFigs.h>
#include "MainWindow.h"
#include "figueVersion.h"
#include "figueInstallPath.h"
void addDotPlot | ( | QVector< ValueDot > & | dots, |
XYValuePlot * | plot, | ||
int | iPlot, | ||
GraphicSheet * | sheet | ||
) |
References addPlot(), autoScalePalette, SciFigs::GraphContentLayer::graph(), SciFigs::XYValuePlot::setLinearPalette(), SciFigs::XYValuePlot::setValues(), SciFigs::XYPlot::setXData(), SciFigs::XYPlot::setYData(), ValueDot::value(), SciFigs::XYValuePlot::valueRange(), w, QGpCoreTools::Point2D::x(), and QGpCoreTools::Point2D::y().
Referenced by createDots().
{ qSort(dots); AxisWindow * w=plot->graph(); QVector<double> * x=new QVector<double>; QVector<double> * y=new QVector<double>; QVector<double> * val=new QVector<double>; for(QVector<ValueDot>::iterator it=dots.begin(); it!=dots.end(); it++) { ValueDot& d=*it; val->append(d.value()); x->append(d.x()); y->append(d.y()); } plot->setXData(x); plot->setYData(y); plot->setValues(val); if(autoScalePalette) { double min=1e99, max=-1e99; plot->valueRange(min, max); plot->setLinearPalette(min, max); } addPlot(sheet, w, iPlot); }
void addManyCurvePlot | ( | QVector< ValueCurve > & | curves, |
XYValueLines * | plot, | ||
int | iPlot, | ||
GraphicSheet * | sheet, | ||
ConsoleProgress * | progress | ||
) |
References addPlot(), autoScalePalette, QGpCoreTools::ConsoleProgress::begin(), QGpCoreTools::ConsoleProgress::end(), SciFigs::GraphContentLayer::graph(), QGpCoreTools::ConsoleProgress::setCaption(), SciFigs::XYValueLines::setLinearPalette(), QGpCoreTools::AbstractProgress::setMaximum(), SciFigs::XYColorLines::setPointCount(), SciFigs::XYColorLines::setPoints(), QGpCoreTools::AbstractProgress::setValue(), SciFigs::XYValueLines::setValues(), ValueCurve::value(), SciFigs::XYValueLines::valueRange(), and w.
Referenced by createManyCurves().
{ if(progress) { progress->setCaption( "Sorting curves ... " ); progress->begin(); } qSort(curves); if(progress) { progress->end(); progress->setCaption( "Definitive storage ... " ); progress->setMaximum(curves.count()); progress->begin(); } QVector<int> pointCounts; QVector<Point2D> points; QVector<double> val; int n=curves.count(); // Calculate capacity for points int totalCount=0; for(int i=0; i<n; i++ ) { const ValueCurve& c=curves.at(i); val.append(c.value()); pointCounts.append(c.count()); totalCount += c.count(); } // Low level transfer for maximum speed. Using QVector::operator+= was too slow points.resize(totalCount); Point2D * destPtr=points.data(); for(int i=0; i<n; i++) { const ValueCurve& c=curves.at(i); const Point2D * srcPtr=c.data(); memcpy(destPtr, srcPtr, c.count()*sizeof(Point2D)); destPtr+=c.count(); if(progress) progress->setValue(i); } plot->setPointCount(points.count(), pointCounts); plot->setPoints(points); plot->setValues(val); if(progress) progress->end(n); if(autoScalePalette) { double min=1e99, max=-1e99; plot->valueRange(min, max); plot->setLinearPalette(min, max); } AxisWindow * w=plot->graph(); addPlot(sheet, w, iPlot); }
void addPlot | ( | GraphicSheet * | sheet, |
AxisWindow * | w, | ||
int | iPlot | ||
) |
References SciFigs::GraphContent::addLayers(), SciFigs::GraphicSheet::addObject(), appendLayerFiles, autoScaleX, autoScaleY, SciFigs::GraphContent::boundingRect(), QGpCoreTools::Rect::enlarge(), SciFigs::AxisWindow::graphContent(), makeupObjectFile, SciFigs::GraphicSheet::moveObject(), SciFigs::GraphicObject::printHeight, SciFigs::GraphicObject::printWidth, SciFigs::GraphicObject::restoreMakeUp(), SciFigs::Scale::sampling(), SciFigs::GraphContent::scaleX(), SciFigs::GraphContent::scaleY(), SciFigs::GraphicObject::setPrintHeight(), SciFigs::GraphicObject::setPrintWidth(), SciFigs::GraphicObject::setPrintXAnchor(), SciFigs::GraphicObject::setPrintYAnchor(), SciFigs::Axis::setRange(), SciFigs::GraphicObject::setRemovable(), setXPlot, setYPlot, TRACE, QGpCoreTools::Rect::x1(), QGpCoreTools::Rect::x2(), SciFigs::AxisWindow::xAxis(), xPlot, QGpCoreTools::Rect::y1(), QGpCoreTools::Rect::y2(), SciFigs::AxisWindow::yAxis(), and yPlot.
Referenced by addDotPlot(), addManyCurvePlot(), createBands(), createCircles(), createCurve(), createCurveName(), and createGrid().
{ TRACE; Rect r; w->setPrintWidth(10.0); w->setPrintHeight(10.0); w->setRemovable(true); sheet->addObject(w); for(QStringList::iterator it=appendLayerFiles.begin();it!=appendLayerFiles.end(); it++) { w->graphContent()->addLayers(*it); } if(!makeupObjectFile.isEmpty()) w->restoreMakeUp(makeupObjectFile); if(autoScaleX || autoScaleY) { GraphContent * gc=w->graphContent(); r=gc->boundingRect(); r.enlarge(0.05, gc->scaleX().sampling(), gc->scaleY().sampling()); if(autoScaleX) { w->xAxis()->setRange(r.x1(), r.x2()); } if(autoScaleY) { w->yAxis()->setRange(r.y1(), r.y2()); } } if(setXPlot) { w->setPrintXAnchor(xPlot); } else { w->setPrintXAnchor((iPlot%2)* w->printWidth()+1.0); } if(setYPlot) { w->setPrintYAnchor(yPlot); } else { w->setPrintYAnchor((iPlot/2)*w->printHeight()+1.0); } sheet->moveObject(w); }
void createBands | ( | AxisType | a, |
GraphicSheet * | sheet | ||
) |
References SciFigs::ParallelBands::addBand(), addPlot(), SciFigs::GraphicSheet::autoResizeContent(), QGpGuiTools::ColorPalette::color(), SciFigs::ParallelBands::count(), createBandsPlot(), QGpGuiTools::ColorPalette::defaultColors(), QGpCoreTools::XMLErrorReport::exec(), SciFigs::GraphContentLayer::graph(), QGpCoreTools::StringSection::isValid(), SciFigs::GraphicSheet::moveObject(), QGpCoreTools::StringSection::nextField(), paletteFile, SciFigs::XMLSciFigs::restoreFile(), SciFigs::ParallelBands::setAxisType(), QGpCoreTools::XMLErrorReport::setFileName(), QGpCoreTools::XMLErrorReport::setTitle(), str, QGpCoreTools::StringSection::toDouble(), QGpCoreTools::tr(), TRACE, and w.
Referenced by main().
{ TRACE; ColorPalette * pal; if(paletteFile.isEmpty()) { pal=0; } else { pal=new ColorPalette; pal->defaultColors(20); XMLErrorReport xmler(XMLErrorReport::Read | XMLErrorReport::NoMessageBox); xmler.setTitle(tr("Load palette")); xmler.setFileName(paletteFile); XMLSciFigs s; if(!xmler.exec(s.restoreFile(paletteFile, pal, XMLSciFigs::Data))) { delete pal; pal=0; } } // Create plot ParallelBands * plot=createBandsPlot(); plot->setAxisType(a); int iPlot=0; // Read stdin for bands until encountering a blank line int n=256; char * buf=new char[n]; CoreApplication::instance()->debugUserInterrupts(false); while(!feof(stdin)) { File::readLine(buf, n, stdin); if(buf[0]=='\n' || buf[0]=='#') { if(plot->count()>0) { AxisWindow * w=plot->graph(); addPlot(sheet, w, iPlot); iPlot++; plot=createBandsPlot(); } } else { QString str(buf); StringSection content(str); const QChar * ptr=0; StringSection f; f=content.nextField(ptr); double min, max; Brush b(Qt::SolidPattern); if(f.isValid()) { min=f.toDouble(); } else { continue; } f=content.nextField(ptr); if(f.isValid()) { max=f.toDouble(); } else { continue; } if(pal) { f=content.nextField(ptr); if(f.isValid()) { b.setColor(pal->color(f.toDouble())); } } plot->addBand(min, max, b); } } CoreApplication::instance()->debugUserInterrupts(true); delete [] buf; if(plot->count()>0) { AxisWindow * w=plot->graph(); addPlot(sheet, w, iPlot); sheet->moveObject(w); } else { delete plot->graph(); } delete pal; sheet->autoResizeContent(); }
References createPlot(), TRACE, and w.
Referenced by createBands().
{ TRACE; AxisWindow * w=createPlot(); ParallelBands * plot=new ParallelBands(w); return plot; }
References createPlot(), TRACE, and w.
Referenced by createCircles().
{ TRACE; AxisWindow * w=createPlot(); CircleViewer * plot=new CircleViewer(w); return plot; }
void createCircles | ( | GraphicSheet * | sheet | ) |
References SciFigs::CircleViewer::add(), addPlot(), SciFigs::GraphicSheet::autoResizeContent(), SciFigs::CircleViewer::count(), createCirclePlot(), SciFigs::GraphContentLayer::graph(), SciFigs::GraphicSheet::moveObject(), TRACE, and w.
Referenced by main().
{ TRACE; // Create plot CircleViewer * plot=createCirclePlot(); int iPlot=0; // Read stdin for bands until encountering a blank line int n=256; char * buf=new char[n]; CoreApplication::instance()->debugUserInterrupts(false); while(!feof(stdin)) { File::readLine(buf, n, stdin); if(buf[0]=='\n' || buf[0]=='#') { if(plot->count()>0) { AxisWindow * w=plot->graph(); addPlot(sheet, w, iPlot); iPlot++; plot=createCirclePlot(); } } else { plot->add(buf); } } CoreApplication::instance()->debugUserInterrupts(true); delete [] buf; if(plot->count()>0) { AxisWindow * w=plot->graph(); addPlot(sheet, w, iPlot); sheet->moveObject(w); } else { delete plot->graph(); } sheet->autoResizeContent(); }
void createCurve | ( | GraphicSheet * | sheet | ) |
References SciFigs::LineLayer::addLine(), addPlot(), QGpCoreTools::Curve< pointType >::append(), createCurvePlot(), curvesPerPlot, QGpCoreTools::XMLErrorReport::exec(), QGpCoreTools::Point::fromString(), SciFigs::GraphContentLayer::graph(), QGpCoreTools::Curve< pointType >::isEmpty(), legendFile, SciFigs::LineLayer::line(), SciFigs::Legend::pen(), SciFigs::XMLSciFigs::restoreFile(), QGpCoreTools::XMLErrorReport::setFileName(), SciFigs::AbstractLine::setPen(), SciFigs::AbstractLine::setSymbol(), QGpCoreTools::XMLErrorReport::setTitle(), str, SciFigs::Legend::symbol(), QGpCoreTools::tr(), TRACE, and w.
Referenced by main().
{ TRACE; Legend * legend; if(legendFile.isEmpty()) { legend=0; } else { legend=new Legend; XMLErrorReport xmler(XMLErrorReport::Read | XMLErrorReport::NoMessageBox); xmler.setTitle(tr("Load legend")); xmler.setFileName(legendFile); XMLSciFigs s; if(!xmler.exec(s.restoreFile(legendFile, legend, XMLSciFigs::Data))) { delete legend; legend=0; } } // Create plot and a first curve LineLayer * plot=createCurvePlot(legend); AxisWindow * w=plot->graph(); Curve<Point> * curve=&static_cast<PlotLine *>(plot->line(0))->curve(); int iCurve=1; int iPlot=0; // Read stdin for curves until encountering a blank line int n=256; char * buf=new char[n]; Point p; CoreApplication::instance()->debugUserInterrupts(false); while(!feof(stdin)) { File::readLine(buf, n, stdin); if(buf[0]=='\n' || buf[0]=='#') { if(!curve->isEmpty()) { if(iCurve==curvesPerPlot) { addPlot(sheet, w, iPlot); iPlot++; iCurve=1; plot= createCurvePlot(legend); w=plot->graph(); curve=&static_cast<PlotLine *>(plot->line(0))->curve(); } else { AbstractLine * line=plot->addLine(); if(legend && iCurve<legend->count()) { line->setPen(legend->pen(iCurve) ); line->setSymbol(legend->symbol(iCurve) ); } curve=&static_cast<PlotLine *>(line)->curve(); iCurve++; } } } else { QString str(buf); if(!str.isEmpty()) { p.fromString(str); curve->append(p); } } } CoreApplication::instance()->debugUserInterrupts(true); delete [] buf; delete legend; addPlot(sheet, w, iPlot); }
void createCurveName | ( | GraphicSheet * | sheet | ) |
References SciFigs::NameLineLayer::addLine(), addPlot(), QGpCoreTools::Curve< pointType >::append(), createCurveNamePlot(), curvesPerPlot, QGpCoreTools::XMLErrorReport::exec(), QGpCoreTools::NamedPoint::fromString(), SciFigs::GraphContentLayer::graph(), QGpCoreTools::Curve< pointType >::isEmpty(), legendFile, SciFigs::NameLineLayer::line(), SciFigs::Legend::pen(), SciFigs::XMLSciFigs::restoreFile(), QGpCoreTools::XMLErrorReport::setFileName(), SciFigs::AbstractLine::setPen(), SciFigs::AbstractLine::setSymbol(), QGpCoreTools::XMLErrorReport::setTitle(), str, SciFigs::Legend::symbol(), QGpCoreTools::tr(), TRACE, and w.
Referenced by main().
{ TRACE; Legend * legend; if(legendFile.isEmpty()) { legend=0; } else { legend=new Legend; XMLErrorReport xmler(XMLErrorReport::Read | XMLErrorReport::NoMessageBox); xmler.setTitle(tr("Load legend")); xmler.setFileName(legendFile); XMLSciFigs s; if(!xmler.exec(s.restoreFile(legendFile, legend, XMLSciFigs::Data))) { delete legend; legend=0; } } // Create plot and a first curve NameLineLayer * plot=createCurveNamePlot(legend); AxisWindow * w=plot->graph(); Curve<NamedPoint> * curve=&static_cast<NameLine *>(plot->line(0))->curve(); int iCurve=1; int iPlot=0; // Read stdin for curves until encountering a blank line int n=256; char * buf=new char[n]; NamedPoint p; CoreApplication::instance()->debugUserInterrupts(false); while(!feof(stdin)) { File::readLine(buf, n, stdin); if(buf[0]=='\n' || buf[0]=='#') { if(!curve->isEmpty()) { if(iCurve==curvesPerPlot) { addPlot(sheet, w, iPlot); iPlot++; iCurve=1; plot= createCurveNamePlot(legend); w=plot->graph(); curve=&static_cast<NameLine *>(plot->line(0))->curve(); } else { AbstractLine * line=plot->addLine(); if(legend && iCurve<legend->count()) { line->setPen(legend->pen(iCurve) ); line->setSymbol(legend->symbol(iCurve) ); } curve=&static_cast<NameLine *>(line)->curve(); iCurve++; } } } else { QString str(buf); if(!str.isEmpty()) { p.fromString(str); curve->append(p); } } } CoreApplication::instance()->debugUserInterrupts(true); delete [] buf; delete legend; addPlot(sheet, w, iPlot); }
NameLineLayer* createCurveNamePlot | ( | Legend * | legend | ) |
References SciFigs::NameLineLayer::addLine(), createPlot(), SciFigs::Legend::pen(), SciFigs::AbstractLine::setPen(), SciFigs::LineLayer::setReferenceLine(), SciFigs::AbstractLine::setSymbol(), SciFigs::Legend::symbol(), TRACE, and w.
Referenced by createCurveName().
{ TRACE; AxisWindow * w=createPlot(); NameLineLayer * plot=new NameLineLayer(w); plot->setReferenceLine(new NameLine); AbstractLine * line=plot->addLine(); if(legend) { line->setPen(legend->pen(0) ); line->setSymbol(legend->symbol(0) ); } return plot; }
LineLayer* createCurvePlot | ( | Legend * | legend | ) |
References SciFigs::LineLayer::addLine(), createPlot(), SciFigs::Legend::pen(), SciFigs::AbstractLine::setPen(), SciFigs::LineLayer::setReferenceLine(), SciFigs::AbstractLine::setSymbol(), SciFigs::Legend::symbol(), TRACE, and w.
Referenced by createCurve().
{ TRACE; AxisWindow * w=createPlot(); LineLayer * plot=new LineLayer(w); plot->setReferenceLine(new PlotLine); AbstractLine * line=plot->addLine(); if(legend) { line->setPen(legend->pen(0) ); line->setSymbol(legend->symbol(0) ); } return plot; }
void createDots | ( | GraphicSheet * | sheet | ) |
References addDotPlot(), createDotsPlot(), QGpGuiTools::ColorPalette::defaultColors(), QGpCoreTools::XMLErrorReport::exec(), SciFigs::GraphContentLayer::graph(), QGpCoreTools::StringSection::isValid(), QGpCoreTools::StringSection::nextField(), paletteFile, SciFigs::XMLSciFigs::restoreFile(), QGpCoreTools::XMLErrorReport::setFileName(), QGpCoreTools::XMLErrorReport::setTitle(), ValueDot::setValue(), QGpCoreTools::Point2D::setX(), QGpCoreTools::Point2D::setY(), str, QGpCoreTools::StringSection::toDouble(), QGpCoreTools::tr(), and TRACE.
Referenced by main().
{ TRACE; ColorPalette * pal; if(paletteFile.isEmpty()) { pal=0; } else { pal=new ColorPalette; pal->defaultColors(20); XMLErrorReport xmler(XMLErrorReport::Read | XMLErrorReport::NoMessageBox); xmler.setTitle(tr("Load palette")); xmler.setFileName(paletteFile); XMLSciFigs s; if(!xmler.exec(s.restoreFile(paletteFile, pal, XMLSciFigs::Data))) { delete pal; pal=0; } } // Create plot XYValuePlot * plot=createDotsPlot(pal); QVector<ValueDot> dots; int iPlot=0; // Read stdin for dots until encountering a blank line int n=256; char * buf=new char[n]; CoreApplication::instance()->debugUserInterrupts(false); while(!feof(stdin)) { File::readLine(buf, n, stdin); if(buf[0]=='\n' || buf[0]=='#') { if(!dots.isEmpty()) { addDotPlot(dots, plot, iPlot, sheet); iPlot++; plot=createDotsPlot(pal); dots.clear(); } } else { QString str(buf); StringSection content(str); dots.append(ValueDot()); ValueDot& d=dots.last(); const QChar * ptr=0; StringSection f; f=content.nextField(ptr); if(f.isValid()) { d.setX(f.toDouble()); } else { dots.erase(dots.end()-1); break; } f=content.nextField(ptr); if(f.isValid()) { d.setY(f.toDouble()); } else { dots.erase(dots.end()-1); break; } f=content.nextField(ptr); if(f.isValid()) d.setValue(f.toDouble()); } } CoreApplication::instance()->debugUserInterrupts(true); delete [] buf; if(!dots.isEmpty()) { addDotPlot(dots, plot, iPlot, sheet); } else { delete plot->graph(); } delete pal; }
XYValuePlot* createDotsPlot | ( | ColorPalette * | pal | ) |
References SciFigs::XYValuePlot::setPalette(), SciFigs::GraphicObject::setPrintXAnchor(), SciFigs::GraphicObject::setPrintYAnchor(), TRACE, and w.
Referenced by createDots().
{ TRACE; AxisWindow * w=new AxisWindow(); w->setPrintXAnchor(1.0); w->setPrintYAnchor(1.0); XYValuePlot * plot=new XYValuePlot(w); if(pal) { plot->setPalette(*pal); } return plot; }
void createGrid | ( | GraphicSheet * | sheet | ) |
References addPlot(), autoScalePalette, createGridPlot(), QGpGuiTools::ColorPalette::defaultColors(), QGpCoreTools::XMLErrorReport::exec(), SciFigs::GraphContentLayer::graph(), paletteFile, SciFigs::XMLSciFigs::restoreFile(), QGpCoreTools::XMLErrorReport::setFileName(), SciFigs::IrregularGrid2DPlot::setGrid(), SciFigs::IrregularGrid2DPlot::setLinearPalette(), QGpCoreTools::XMLErrorReport::setTitle(), QGpCoreTools::tr(), TRACE, and w.
Referenced by main().
{ TRACE; ColorPalette * pal; if(paletteFile.isEmpty()) { pal=0; } else { pal=new ColorPalette; pal->defaultColors(20); XMLErrorReport xmler(XMLErrorReport::Read | XMLErrorReport::NoMessageBox); xmler.setTitle(tr("Load palette")); xmler.setFileName(paletteFile); XMLSciFigs s; if(!xmler.exec(s.restoreFile(paletteFile, pal, XMLSciFigs::Data))) { delete pal; pal=0; } } IrregularGrid2DPlot * plot; AxisWindow * w; IrregularGrid2D grid; int iPlot=0; // Read stdin for curves until encountering a blank line QTextStream s(stdin); CoreApplication::instance()->debugUserInterrupts(false); while(!s.atEnd()) { s >> grid; if(grid.nx()>0 && grid.ny()>0) { plot=createGridPlot(pal); w=plot->graph(); plot->setGrid(grid); if(autoScalePalette) plot->setLinearPalette(); addPlot(sheet, w, iPlot); iPlot++; } else break; } CoreApplication::instance()->debugUserInterrupts(true); delete pal; }
IrregularGrid2DPlot* createGridPlot | ( | ColorPalette * | pal | ) |
References createPlot(), SciFigs::GridPlot::setPalette(), TRACE, and w.
Referenced by createGrid().
{ TRACE; AxisWindow * w=createPlot(); IrregularGrid2DPlot * plot=new IrregularGrid2DPlot(w); if(pal) { plot->setPalette(*pal); } return plot; }
void createManyCurves | ( | GraphicSheet * | sheet | ) |
References addManyCurvePlot(), SciFigs::GraphicSheet::autoResizeContent(), QGpCoreTools::ConsoleProgress::begin(), createManyCurvesPlot(), curvesPerPlot, QGpGuiTools::ColorPalette::defaultColors(), QGpCoreTools::ConsoleProgress::end(), QGpCoreTools::XMLErrorReport::exec(), SciFigs::GraphContentLayer::graph(), QGpCoreTools::AbstractProgress::increaseValue(), QGpCoreTools::StringSection::isValid(), QGpCoreTools::StringSection::nextField(), paletteFile, SciFigs::XMLSciFigs::restoreFile(), QGpCoreTools::ConsoleProgress::setCaption(), QGpCoreTools::XMLErrorReport::setFileName(), QGpCoreTools::AbstractProgress::setMaximum(), QGpCoreTools::XMLErrorReport::setTitle(), str, QGpCoreTools::StringSection::toDouble(), QGpCoreTools::tr(), and TRACE.
Referenced by main().
{ TRACE; ColorPalette * pal; if(paletteFile.isEmpty()) { pal=0; } else { pal=new ColorPalette; pal->defaultColors(20); XMLErrorReport xmler(XMLErrorReport::Read | XMLErrorReport::NoMessageBox); xmler.setTitle(tr("Load palette")); xmler.setFileName(paletteFile); XMLSciFigs s; if(!xmler.exec(s.restoreFile(paletteFile, pal, XMLSciFigs::Data))) { delete pal; pal=0; } } // Create plot XYValueLines * plot=createManyCurvesPlot(pal); QVector<ValueCurve> curves(1); int iPlot=0; // Read stdin for points until encountering a blank line or comment ConsoleProgress progress; progress.setCaption("Loading curves... "); progress.setMaximum(0); progress.begin(); QTextStream sIn(stdin); CoreApplication::instance()->debugUserInterrupts(false); while(!sIn.atEnd()) { QString str=sIn.readLine(); if(str[0]=='\n' || str[0]=='#') { if(curves.last().count()>0) { if(curves.count()==curvesPerPlot) { addManyCurvePlot(curves, plot, iPlot, sheet, &progress); iPlot++; curves.clear(); plot=createManyCurvesPlot(pal); } curves.append(ValueCurve()); progress.increaseValue(1); } int index=str.indexOf("value="); if(index>=0) { bool ok; double v=str.mid(index+6).toDouble(&ok); if(ok) curves.last().setValue(v); } } else { StringSection content(str); const QChar * ptr=0; StringSection f; f=content.nextField(ptr); double x, y; if(f.isValid()) x=f.toDouble(); else break; f=content.nextField(ptr); if(f.isValid()) y=f.toDouble(); else break; curves.last().append(Point2D(x,y)); } } CoreApplication::instance()->debugUserInterrupts(true); progress.end(); if(curves.last().count()>0) { addManyCurvePlot(curves, plot, iPlot, sheet, &progress); } else { delete plot->graph(); } delete pal; sheet->autoResizeContent(); }
XYValueLines* createManyCurvesPlot | ( | ColorPalette * | pal | ) |
References createPlot(), SciFigs::XYValueLines::setPalette(), TRACE, and w.
Referenced by createManyCurves().
{ TRACE; AxisWindow * w=createPlot(); XYValueLines * plot=new XYValueLines(w, true); if(pal) { plot->setPalette(*pal); } return plot; }
AxisWindow* createPlot | ( | ) |
References SciFigs::GraphContent::addLayers(), SciFigs::AxisWindow::graphContent(), prependLayerFiles, SciFigs::GraphicObject::setPrintXAnchor(), SciFigs::GraphicObject::setPrintYAnchor(), TRACE, and w.
Referenced by createBandsPlot(), createCirclePlot(), createCurveNamePlot(), createCurvePlot(), createGridPlot(), and createManyCurvesPlot().
{ TRACE; AxisWindow * w=new AxisWindow(); w->setPrintXAnchor(1.0); w->setPrintYAnchor(1.0); for(QStringList::iterator it=prependLayerFiles.begin();it!=prependLayerFiles.end(); it++) { w->graphContent()->addLayers(*it); } return w; }
void createText | ( | GraphicSheet * | sheet | ) |
References SciFigs::GraphicSheet::addObject(), SciFigs::GraphicObject::setPrintXAnchor(), SciFigs::GraphicObject::setPrintYAnchor(), SciFigs::TextEdit::setText(), QGpCoreTools::LineParser::toDouble(), and TRACE.
Referenced by main().
{ TRACE; QString text; double x=0.0, y=0.0; bool properties=true; QTextStream sIn(stdin); CoreApplication::instance()->debugUserInterrupts(false); while(!sIn.atEnd()) { QString line=sIn.readLine(); if(line[0]=='\n' || line[0]=='#') { TextEdit * t=new TextEdit; t->setText(text); t->setPrintXAnchor(x); t->setPrintYAnchor(y); sheet->addObject(t); text=QString::null; properties=true; } else { if(properties) { LineParser lp(line); bool ok=true; x=lp.toDouble(0, ok); y=lp.toDouble(1, ok); properties=false; } else { if(!text.isEmpty()) { text+="\n"; } if(line.startsWith("\\#")) { text+=line.mid(1); } else { text+=line; } } } } CoreApplication::instance()->debugUserInterrupts(true); if(!text.isEmpty()) { TextEdit * t=new TextEdit; t->setText(text); t->setPrintXAnchor(x); t->setPrintYAnchor(y); sheet->addObject(t); } }
ApplicationHelp* help | ( | ) |
int main | ( | int | argc, |
char ** | argv | ||
) |
References appendLayerFiles, autoScalePalette, autoScaleX, autoScaleY, createBands(), createCircles(), createCurve(), createCurveName(), createDots(), createGrid(), createManyCurves(), createText(), curvesPerPlot, QGpCoreTools::endl(), SciFigs::GraphicSheet::exportFile(), SciFigs::GraphicSheet::fileOpen(), QGpCoreTools::CoreApplicationPrivate::getFileList(), help(), legendFile, makeupObjectFile, mode, paletteFile, prependLayerFiles, SciFigs::GraphicSheet::restoreMakeUp(), QGpGuiTools::Application::setConsoleMessage(), QGpGuiTools::Application::setGuiMessage(), QGpCoreTools::CoreApplicationPrivate::setStream(), setXPlot, setYPlot, MainWindow::sheet(), SciFigs::GraphicSheet::showAllObjects(), QGpCoreTools::tr(), QGpCoreTools::XAxis, xPlot, QGpCoreTools::YAxis, and yPlot.
{ Application a(argc, argv, help); a.setConsoleMessage(); // Options QString exportFile, makeupSheetFile; QString exportFormat="PAGE"; enum StdinMode {PageFile, Curve, CurveName, ManyCurves, Grid, Dots, Circles, Text, BandsX, BandsY}; StdinMode mode=PageFile; int dpi=0; // No dpi force double dx=0.0, dy=0.0, maxX=0.0, maxY=0.0; double dxPage=0.0, dyPage=0.0, maxXPage=0.0, maxYPage=0.0; // Check arguments int i, j=1; for(i=1; i<argc; i++) { QByteArray arg=argv[i]; if(arg[0]=='-') { if(arg=="-curve" || arg=="-c") { mode=Curve; } else if(arg=="-curve-name" || arg=="-cn") { mode=CurveName; } else if(arg=="-many-curves" || arg=="-mc") { mode=ManyCurves; } else if(arg=="-dots" || arg=="-d") { mode=Dots; } else if(arg=="-circles") { mode=Circles; } else if(arg=="-grid" || arg=="-g") { mode=Grid; } else if(arg=="-bands-x" || arg=="-bx") { mode=BandsX; } else if(arg=="-bands-y" || arg=="-by") { mode=BandsY; } else if(arg=="-text" || arg=="-t") { mode=Text; } else if(arg=="-legend" || arg=="-l") { Application::checkOptionArg(i, argc, argv); legendFile=argv[i]; } else if(arg=="-palette" || arg=="-p") { Application::checkOptionArg(i, argc, argv); paletteFile=argv[i]; } else if(arg=="-makeup" || arg=="-m") { Application::checkOptionArg(i, argc, argv); makeupObjectFile=argv[i]; } else if(arg=="-makeup-sheet" || arg=="-ms") { Application::checkOptionArg(i, argc, argv); makeupSheetFile=argv[i]; } else if(arg=="-x") { Application::checkOptionArg(i, argc, argv); xPlot=atof(argv[i]); setXPlot=true; } else if(arg=="-y") { Application::checkOptionArg(i, argc, argv); yPlot=atof(argv[i]); setYPlot=true; } else if(arg=="-append-layer" || arg=="-add-layer") { // Last test kept for compatibility Application::checkOptionArg(i, argc, argv); appendLayerFiles.append(argv[i]); } else if(arg=="-prepend-layer") { Application::checkOptionArg(i, argc, argv); prependLayerFiles.append(argv[i]); } else if(arg=="-export" || arg=="-e") { Application::checkOptionArg(i, argc, argv); exportFile=argv[i]; } else if(arg=="-format" || arg=="-f") { Application::checkOptionArg(i, argc, argv); exportFormat=argv[i]; } else if(arg=="-dpi") { Application::checkOptionArg(i, argc, argv); dpi=atoi(argv[i]); if(dpi>1200) dpi=1200; else if(dpi<0) dpi=0; } else if(arg=="-cpp") { Application::checkOptionArg(i, argc, argv); curvesPerPlot=atoi(argv[i] ); } else if(arg=="-preserve-x-scale") { autoScaleX=false; } else if(arg=="-preserve-y-scale") { autoScaleY=false; } else if(arg=="-preserve-pal-scale") { autoScalePalette=false; } else if(arg=="-dx") { Application::checkOptionArg(i, argc, argv); dx=atof(argv[i] ); } else if(arg=="-dy") { Application::checkOptionArg(i, argc, argv); dy=atof(argv[i] ); } else if(arg=="-max-x") { Application::checkOptionArg(i, argc, argv); maxX=atof(argv[i] ); } else if(arg=="-max-y") { Application::checkOptionArg(i, argc, argv); maxY=atof(argv[i] ); } else if(arg=="-dx-page") { Application::checkOptionArg(i, argc, argv); dxPage=atof(argv[i] ); } else if(arg=="-dy-page") { Application::checkOptionArg(i, argc, argv); dyPage=atof(argv[i] ); } else if(arg=="-max-x-page") { Application::checkOptionArg(i, argc, argv); maxXPage=atof(argv[i] ); } else if(arg=="-max-y-page") { Application::checkOptionArg(i, argc, argv); maxYPage=atof(argv[i] ); } else if(arg=="-debug-plugins") { printf("-- Testing available plugins --\n"); QSettings * reg=SciFigsGlobal::pluginSettings(); QStringList libs=reg->value( "pluginList" ).toStringList(); if(libs.isEmpty()) { printf("No plugins, search for new plugins...\n"); SciFigsGlobal::initPlugins(reg, true); } else { printf("%i plugins\n",libs.count()); SciFigsPlugin::loadPlugins(libs, true); } delete reg; return 0; } else if(arg=="-clear-plugins") { QSettings * reg=SciFigsGlobal::pluginSettings(); reg->remove( "Plugins" ); delete reg; } else if(arg=="-add-plugin-path") { CoreApplication::checkOptionArg(i, argc, argv); QSettings * reg=SciFigsGlobal::pluginSettings(); QStringList paths=reg->value( "Plugins/Paths" ).toStringList(); paths.append(argv[i]); reg->setValue( "Plugins/Paths", paths); delete reg; } else if(arg=="-plugin-paths") { QSettings * reg=SciFigsGlobal::pluginSettings(); QStringList paths=reg->value( "Plugins/Paths" ).toStringList(); for(QStringList::iterator it=paths.begin(); it!=paths.end(); it++ ) { printf("%s\n",it->toAscii().data()); } delete reg; return 0; } else { App::stream() << tr("figue: bad option %1, see -help").arg(argv[i]) << endl; return 2; } } else { argv[j++]=argv[i]; } } if(j<argc) { argv[j]=0; argc=j; } SciFigsGlobal s; MainWindow* mainWindow=new MainWindow(0); mainWindow->setObjectName( "figue" ); Settings::getRect(mainWindow, "figue" ); switch (mode) { case PageFile: { // Check stdin for page files double x=0.0, y=0.0, xPage=maxXPage, yPage=maxYPage; QStringList fileList=a.getFileList(argc, argv); for(QStringList::iterator it=fileList.begin();it!=fileList.end();it++) { App::stream() << tr("Opening file %1").arg(*it) << endl; mainWindow->sheet()->fileOpen( *it, x, y); if(maxX>0.0) { x+=dx; if(x>=maxX) { x=0.0; xPage=maxXPage; y+=dy; } } else if(maxY>0.0) { y+=dy; if(y>=maxY) { y=0.0; yPage=maxYPage; x+=dx; } } else { x+=dx; y+=dy; } if(maxXPage>0.0 && x>=xPage) { x=xPage+dxPage; xPage+=dxPage+maxXPage; } if(maxYPage>0.0 && y>=yPage) { y=yPage+dyPage; yPage+=dyPage+maxYPage; } } } break; case Curve: createCurve(mainWindow->sheet()); break; case ManyCurves: createManyCurves(mainWindow->sheet()); break; case CurveName: createCurveName(mainWindow->sheet()); break; case Dots: createDots(mainWindow->sheet()); break; case Circles: createCircles(mainWindow->sheet()); break; case Grid: createGrid(mainWindow->sheet()); break; case BandsX: // Convention is different than in command line interface createBands(YAxis, mainWindow->sheet()); break; case BandsY: createBands(XAxis, mainWindow->sheet()); break; case Text: createText(mainWindow->sheet()); break; } if(!makeupSheetFile.isEmpty()) { mainWindow->sheet()->restoreMakeUp(makeupSheetFile); } if(!exportFile.isEmpty()) { mainWindow->sheet()->exportFile(exportFile, exportFormat, dpi); delete mainWindow; return 0; } // Back to gui ... mainWindow->sheet()->showAllObjects(); a.setStream(new StandardStream(stdout)); a.setGuiMessage(); mainWindow->show(); int appReturn=a.exec(); Settings::setRect(mainWindow, "figue"); delete mainWindow; return appReturn; }
PACKAGE_INFO | ( | figue | , |
FIGUE | |||
) |
QStringList appendLayerFiles |
bool autoScalePalette = true |
Referenced by addDotPlot(), addManyCurvePlot(), createGrid(), and main().
bool autoScaleX = true |
bool autoScaleY = true |
int curvesPerPlot = 0 |
Referenced by createCurve(), createCurveName(), createManyCurves(), and main().
QString legendFile |
Referenced by createCurve(), createCurveName(), and main().
QString makeupObjectFile |
QString paletteFile |
Referenced by createBands(), createDots(), createGrid(), createManyCurves(), and main().
QStringList prependLayerFiles |
Referenced by createPlot(), and main().