void PosInterpolator::generateBezierMainCurve() {
    if(steps_.size() <= 2) {
        generateLinearMainCurve();
        return;
    }
    qglviewer::Vec a,b,pa;
    qglviewer::Vec delta;
    for(size_t i = 0 ; i < steps_.size() ; i++) {
        if( i == 0 ) {
            delta = steps_.at(1).position_ - steps_.at(2).position_;
            pa = steps_.at(1).position_ + delta;
        } else if( i ==  steps_.size() - 1 ) {
            delta = steps_.at(i-1).position_ - steps_.at(i-2).position_;
            b = steps_.at(i-1).position_ + delta;
            //curves.push_back(new BezierCubic(points.at(i-1),pa,b,points.at(i)));
            addCurve(new BezierQuadratic(steps_.at(i-1).position_,pa,steps_.at(i).position_));
        }else {
            delta = steps_.at(i).position_ - steps_.at(i-1).position_;
            a = steps_.at(i).position_ + delta;
            a = (a + steps_.at(i+1).position_)/2.0;
            delta = steps_.at(i).position_ - a;
            b = steps_.at(i).position_ + delta;
            if( i == 1) {
                addCurve(new BezierQuadratic(steps_.at(i-1).position_,b,steps_.at(i).position_));
            }else{
                addCurve(new BezierCubic(steps_.at(i-1).position_,pa,b,steps_.at(i).position_));
            }
            pa = a;

        }
    }
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RicNewWellLogCurveExtractionFeature::onActionTriggered(bool isChecked)
{
    RimWellLogTrack* wellLogPlotTrack = selectedWellLogPlotTrack();
    if (wellLogPlotTrack)
    {
        addCurve(wellLogPlotTrack, NULL, NULL);
    }
    else
    {
        RimWellPath* wellPath = selectedWellPath();
        if (wellPath)
        {
            RimWellLogTrack* wellLogPlotTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack();
            RimWellLogExtractionCurve* plotCurve = addCurve(wellLogPlotTrack, RiaApplication::instance()->activeReservoirView(), wellPath);

            plotCurve->updatePlotData();

            RimWellLogPlot* plot = NULL;
            wellLogPlotTrack->firstAnchestorOrThisOfType(plot);
            if (plot && plotCurve->curveData())
            {
                plot->setDepthUnit(plotCurve->curveData()->depthUnit());
            }

            plotCurve->updateConnectedEditors();
        }
    }
}
void PosInterpolator::generateCatmullRoomMainCurve() {
    if(steps_.size() <= 2) {
        generateLinearMainCurve();
        return;
    }

    qglviewer::Vec ta,tb,aux;
    qglviewer::Vec delta;
    for(size_t i = 0 ; i < steps_.size() ; i++) {
        if( i == 0 ) {
            ta = (steps_.at(2).position_*2.0 - steps_.at(1).position_  - steps_.at(0).position_)*(0.5);

        } else if( i ==  steps_.size() - 1 ) {
            /*delta = steps_.at(i-2).position_ - steps_.at(i-1).position_;
            aux = steps_.at(i-1).position_ + delta;
            tb = (aux - steps_.at(i-1).position_)*(0.5);*/
            tb = (steps_.at(i-1).position_*2.0 - steps_.at(i-2).position_ - steps_.at(i).position_)*(0.5);
            addCurve(new Hermite(steps_.at(i-1).position_,ta,steps_.at(i).position_,tb));
        }else {
            tb = (steps_.at(i+1).position_ - steps_.at(i-1).position_)*(0.5);
            addCurve(new Hermite(steps_.at(i-1).position_,ta,steps_.at(i).position_,tb));
            ta = tb;

        }
    }
}
/* called by the C++ code for initialization */
extern "C" void device_init (char* cfg)
{
  /* create new Embree device */
  g_device = rtcNewDevice(cfg);
  error_handler(rtcDeviceGetError(g_device));

  /* set error handler */
  rtcDeviceSetErrorFunction(g_device,error_handler);

  /* create scene */
  g_scene = rtcDeviceNewScene(g_device, RTC_SCENE_STATIC,RTC_INTERSECT1 | RTC_INTERPOLATE);

  /* add ground plane */
  addGroundPlane(g_scene);

  /* add curve */
  addCurve(g_scene,Vec3fa(0.0f,0.0f,0.0f));

  /* commit changes to scene */
  rtcCommit (g_scene);

  /* set start render mode */
  renderTile = renderTileStandard;
  key_pressed_handler = device_key_pressed_default;
}
CvFuzzyCurve *CvFuzzyFunction::newCurve()
{
    CvFuzzyCurve *c;
    c = new CvFuzzyCurve();
    addCurve(c);
    return c;
};
void
OffsetCurveSetBuilder::addCurves(const vector<CoordinateSequence*> *lineList, int leftLoc, int rightLoc)
{
	for (unsigned int i=0;i<lineList->size();i++) {
		const CoordinateSequence *coords=(*lineList)[i];
		addCurve(coords, leftLoc, rightLoc);
	}
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RicNewWellLogFileCurveFeature::onActionTriggered(bool isChecked)
{
    RimWellLogTrack* wellLogPlotTrack = selectedWellLogPlotTrack();
    if (wellLogPlotTrack)
    {
        addCurve(wellLogPlotTrack);
    }
    else
    {
        RimWellPath* wellPath = selectedWellPathWithLogFile();
        if (wellPath)
        {
            RimWellLogTrack* wellLogPlotTrack = RicNewWellLogPlotFeatureImpl::createWellLogPlotTrack();
            RimWellLogFileCurve* plotCurve = addCurve(wellLogPlotTrack);
            plotCurve->setWellPath(wellPath);
            plotCurve->updateConnectedEditors();
        }
    }
}
/*public*/
void
OffsetCurveSetBuilder::addCurves(const std::vector<CoordinateSequence*>& lineList,
	int leftLoc, int rightLoc)
{
	for (size_t i=0, n=lineList.size(); i<n; ++i)
	{
		CoordinateSequence *coords=lineList[i];
		addCurve(coords, leftLoc, rightLoc);
	}
}
Exemple #9
0
ICurveHandle CurveEditor::addCurve(ICurvePtr curve)
{
    auto handle = curve->getHandleT<ICurve>();
    TF_ASSERT(handle != nullptr);
    if (addCurve(handle))
    {
		impl_->ownedCurves_.push_back(std::move(curve));
        return handle;
    }
    return nullptr;
}
bool PSV_ChartRealItem::addCurve(const QMap<int, double> &data, const PSV_CurveParam &curveParam)
{
    QMap<double,double> tempData;
    QMapIterator<int,double> iter(data);
    while(iter.hasNext())
    {
        iter.next();
        tempData.insert(iter.key(),iter.value());
    }
    return addCurve(tempData,curveParam);
}
Exemple #11
0
KstViewLegend::KstViewLegend(const QDomElement& e)
: KstBorderedViewObject(e) {

  // some defaults and invariants
  _fallThroughTransparency = false;
  _container = false;
  _type = "Legend";
  _rotation = 0.0;
  _fontName = KstApp::inst()->defaultFont();
  _vertical = true;
  _isResizable = false;
  _fontSize = -1;
  setFontSize(0);
  _layoutActions &= ~(MoveTo | Copy | CopyTo);
  _standardActions |= Delete | Edit;
  _legendMargin = 5;
  _parsedTitle = 0L;
  _trackContents = true;

  QStringList ctaglist;

  // read the properties
  QDomNode n = e.firstChild();
  while (!n.isNull()) {
    QDomElement el = n.toElement();
    if (!el.isNull()) {
      if (metaObject()->indexOfProperty(el.tagName().toLatin1()) > -1) {
        setProperty(el.tagName().toLatin1(), QVariant(el.text()));
      } else if (el.tagName() == "curvetag") {
        ctaglist.append(el.text()); 
      }
    }
    n = n.nextSibling();
  }
  if (!_title.isEmpty()) {
    reparseTitle();
  }

  KstBaseCurveList l = kstObjectSubList<KstDataObject,KstBaseCurve>(KST::dataObjectList);
  KstBaseCurveList::ConstIterator end = l.end();
  for (QStringList::ConstIterator str = ctaglist.begin(); str != ctaglist.end(); ++str) {
    KstBaseCurveList::ConstIterator it = l.findTag(*str);
    if (it != end) {
      addCurve(*it);
    }
  }
  
  // Padding was incorrectly saved as 5 in Kst <= 1.2.0 so we need to strip it
  // out here since this object is buggy.  Remove this once padding is properly
  // supported?  Maybe, but geometries are then wrong.
  if (e.ownerDocument().documentElement().attribute("version") == "1.2") {
    setPadding(0);
  }
}
void curvesDialog::addSelectedCurve()
{
QStringList emptyColumns;
QString text=available->text(selectedCurve);
if (!contents->findItem(text, Qt::ExactMatch))
	{
	if (!addCurve(text))
		emptyColumns << text;
	else
		g->updatePlot();
	}
Graph::showPlotErrorMessage(this, emptyColumns);
}
bool PSV_ChartDateTimeItem::addCurve(const QMap<QDate, double> &data, const PSV_CurveParam &curveParam)
{
    QMapIterator<QDate, double> iter(data);
    QMap<QDateTime,double> tempData;
    while(iter.hasNext())
    {
        iter.next();
        if(iter.key().isValid())
        {
            tempData.insert(QDateTime(iter.key(),QTime(0,0,0)),iter.value());
        }
    }
    return addCurve(tempData,curveParam,true);
}
Exemple #14
0
void xsCanvasContext::quadraticCurveTo(float qcpx, float qcpy, float qx, float qy)
{
	xsBezierCurve *curve = static_cast<xsBezierCurve *>(xsBezierCurve::createInstance());
	curve ->x1 = lastX;
	curve ->y1 = lastY;
	curve ->x2 = qcpx;
	curve ->y2 = qcpy;
	curve ->x3 = qx;
	curve ->y3 = qy;
	curve ->fillColor = fillColor;
	curve ->strokeColor = strokeColor;
	curve ->lineWidth = lineWidth;
	curve ->isCubic = XS_FALSE;
	addCurve(curve);
}
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RicNewWellLogFileCurveFeature::addWellLogChannelsToPlotTrack(RimWellLogTrack* plotTrack, const std::vector<RimWellLogFileChannel*>& wellLogFileChannels)
{
    for (size_t cIdx = 0; cIdx < wellLogFileChannels.size(); cIdx++)
    {
        RimWellLogFileCurve* plotCurve = addCurve(plotTrack);
    
        RimWellPath* wellPath;
        wellLogFileChannels[cIdx]->firstAncestorOrThisOfType(wellPath);
        if (wellPath)
        {
            plotCurve->setWellPath(wellPath);
            plotCurve->setWellLogChannelName(wellLogFileChannels[cIdx]->name());
            plotCurve->loadDataAndUpdate();
            plotCurve->updateConnectedEditors();
        }
    }
}
Exemple #16
0
void xsCanvasContext::bezierCurveTo(float cp1x, float cp1y, float cp2x, float cp2y, float x, float y)
{
	xsBezierCurve *curve = static_cast<xsBezierCurve *>(xsBezierCurve::createInstance());
	curve ->x1 = lastX;
	curve ->y1 = lastY;
	curve ->x2 = cp1x;
	curve ->y2 = cp1y;
	curve ->x3 = cp2x;
	curve ->y3 = cp2y;
	curve ->x4 = x;
	curve ->y4 = y;
	curve ->fillColor = fillColor;
	curve ->strokeColor = strokeColor;
	curve ->lineWidth = lineWidth;
	curve ->isCubic = XS_TRUE;
	addCurve(curve);
}
//SLOTS----------
void MainWindow::newCurve() {
    GenericTimeData* s=CustomCurveFactory::newDialogCurve(this,&m_widgetStyleUI);
    if (s==NULL) return;
    TimePlotParams* _tParams=dynamic_cast<TimePlotParams*>(m_plotTime->getDataParameters());
    Q_ASSERT(_tParams);
    s->setTimePlotParams(_tParams);
    QString name= "Curve_";
    name.append(QString::number(m_indexGenerator++));
    GenericTimeDataParams* _gtdParams=dynamic_cast<GenericTimeDataParams*>(s->getDataParameters());
    Q_ASSERT(_gtdParams);
    m_actualColor=ComboBoxWidgetColor::getNextColor(m_actualColor);
    _gtdParams->setColor(m_actualColor);
    _gtdParams->setName(name);
    _gtdParams->setShowCurve(true);

    addCurve(s);
}
void curvesDialog::addCurve()
{
QStringList emptyColumns;
for (int i=0;i<int(available->count());i++)
	{
	if (available->isSelected(i))
		{
		QString text=available->text(i);
		if (!contents->findItem(text, Qt::ExactMatch))
			{
			if (!addCurve(text))
				emptyColumns << text;
			}
		}
	}
g->updatePlot();
Graph::showPlotErrorMessage(this, emptyColumns);
}
/* called by the C++ code for initialization */
extern "C" void device_init (char* cfg)
{
  /* create scene */
  g_scene = rtcNewScene(g_device);

  /* add ground plane */
  addGroundPlane(g_scene);

  /* add cubes */
  addCurve(g_scene,Vec3fa(4.0f,-1.0f,-3.5f));
  quadCubeID = addQuadSubdivCube(g_scene,Vec3fa(4.0f,0.0f,0.0f));
  triCubeID  = addTriangleSubdivCube(g_scene,Vec3fa(4.0f,0.0f,3.5f));
  addTriangleCube(g_scene,Vec3fa(0.0f,0.0f,-3.0f));
  addQuadCube(g_scene,Vec3fa(0.0f,0.0f,3.0f));

  /* commit changes to scene */
  rtcCommitScene (g_scene);

  /* set start render mode */
  renderTile = renderTileStandard;
  key_pressed_handler = device_key_pressed_default;
}
TextFormatButtons::TextFormatButtons(QTextEdit * textEdit, Buttons buttons, QWidget * parent)
: QWidget(parent),
connectedTextEdit(textEdit),
d_buttons(buttons)
{
	QHBoxLayout * layout = new QHBoxLayout(this);
	layout->setMargin(0);
	layout->setSpacing(0);

	QFont font = this->font();
	font.setPointSize(14);

	if (buttons == Legend){
		buttonCurve = new QPushButton( QPixmap(lineSymbol_xpm), QString());
		buttonCurve->setMaximumWidth(40);
		buttonCurve->setMinimumHeight(35);
		buttonCurve->setFont(font);
		layout->addWidget(buttonCurve);
		connect( buttonCurve, SIGNAL(clicked()), this, SLOT(addCurve()) );
	}

	buttonSubscript = new QPushButton(QPixmap(index_xpm), QString());
	buttonSubscript->setMaximumWidth(40);
	buttonSubscript->setMinimumHeight(35);
	buttonSubscript->setFont(font);
	layout->addWidget(buttonSubscript);
	connect( buttonSubscript, SIGNAL(clicked()), this, SLOT(addSubscript()) );

	buttonSuperscript = new QPushButton(QPixmap(exp_xpm), QString());
	buttonSuperscript->setMaximumWidth(40);
	buttonSuperscript->setMinimumHeight(35);
	buttonSuperscript->setFont(font);
	layout->addWidget(buttonSuperscript);
	connect( buttonSuperscript, SIGNAL(clicked()), this, SLOT(addSuperscript()));

	if (buttons != Equation){
		buttonLowerGreek = new QPushButton(QString(QChar(0x3B1)));
		buttonLowerGreek->setFont(font);
		buttonLowerGreek->setMaximumWidth(40);
		layout->addWidget(buttonLowerGreek);
		connect( buttonLowerGreek, SIGNAL(clicked()), this, SLOT(showLowerGreek()));

		buttonUpperGreek = new QPushButton(QString(QChar(0x393)));
		buttonUpperGreek->setFont(font);
		buttonUpperGreek->setMaximumWidth(40);
		layout->addWidget(buttonUpperGreek);
		connect( buttonUpperGreek, SIGNAL(clicked()), this, SLOT(showUpperGreek()));

		buttonMathSymbols = new QPushButton(QString(QChar(0x222B)));
		buttonMathSymbols->setFont(font);
		buttonMathSymbols->setMaximumWidth(40);
		layout->addWidget(buttonMathSymbols);
		connect( buttonMathSymbols, SIGNAL(clicked()), this, SLOT(showMathSymbols()));

		buttonArrowSymbols = new QPushButton(QString(QChar(0x2192)));
		buttonArrowSymbols->setFont(font);
		buttonArrowSymbols->setMaximumWidth(40);
		layout->addWidget(buttonArrowSymbols);
		connect( buttonArrowSymbols, SIGNAL(clicked()), this, SLOT(showArrowSymbols()));
	}

	if (buttons != Plot3D && buttons != Equation){
		font = this->font();
		font.setBold(true);
		font.setPointSize(14);

		buttonBold = new QPushButton(tr("B","Button bold"));
		buttonBold->setFont(font);
		buttonBold->setMaximumWidth(40);
		layout->addWidget(buttonBold);
		connect( buttonBold, SIGNAL(clicked()), this, SLOT(addBold()));

		font = this->font();
		font.setItalic(true);
		font.setPointSize(14);

		buttonItalics = new QPushButton(tr("It","Button italics"));
		buttonItalics->setFont(font);
		buttonItalics->setMaximumWidth(40);
		layout->addWidget(buttonItalics);
		connect( buttonItalics, SIGNAL(clicked()), this, SLOT(addItalics()));

		font = this->font();
		font.setUnderline(true);
		font.setPointSize(14);

		buttonUnderline = new QPushButton(tr("U","Button underline"));
		buttonUnderline->setFont(font);
		buttonUnderline->setMaximumWidth(40);
		layout->addWidget(buttonUnderline);
   		layout->addStretch();
		connect( buttonUnderline, SIGNAL(clicked()), this, SLOT(addUnderline()));
	}

	if (buttons == Equation){
		buttonFraction = new QPushButton(QPixmap(fraction_xpm), QString());
		buttonFraction->setMaximumWidth(40);
		buttonFraction->setMinimumHeight(35);
		buttonFraction->setFont(font);
		layout->addWidget(buttonFraction);
		connect(buttonFraction, SIGNAL(clicked()), this, SLOT(addFraction()));

		buttonSquareRoot = new QPushButton(QPixmap(square_root_xpm), QString());
		buttonSquareRoot->setMaximumWidth(40);
		buttonSquareRoot->setMinimumHeight(35);
		buttonSquareRoot->setFont(font);
		layout->addWidget(buttonSquareRoot);
		connect(buttonSquareRoot, SIGNAL(clicked()), this, SLOT(addSquareRoot()));
		layout->addStretch();
	}
}
Exemple #21
0
void TextFormatButtons::init(Buttons buttons)
{
  QHBoxLayout *layout = (QHBoxLayout*)this->layout();
  QLayoutItem *child;
  while ((child = layout->takeAt(0)) != 0){
    if (child->widget())
      delete child->widget();
  }

  QFont font = QFont();
  int btnSize = 32;
#ifdef Q_OS_MAC
  btnSize = 38;
#endif
  if (buttons == Legend || buttons == TexLegend){
    QPushButton *buttonCurve = new QPushButton( QPixmap(":/lineSymbol.png"), QString());
    buttonCurve->setFixedWidth(btnSize);
    buttonCurve->setFixedHeight(btnSize);
    buttonCurve->setFont(font);
    layout->addWidget(buttonCurve);
    connect( buttonCurve, SIGNAL(clicked()), this, SLOT(addCurve()) );
  }

  QPushButton *buttonSubscript = new QPushButton(QPixmap(":/index.png"), QString());
  buttonSubscript->setFixedWidth(btnSize);
  buttonSubscript->setFixedHeight(btnSize);
  buttonSubscript->setFont(font);
  layout->addWidget(buttonSubscript);
  connect( buttonSubscript, SIGNAL(clicked()), this, SLOT(addSubscript()) );

  QPushButton *buttonSuperscript = new QPushButton(QPixmap(":/exp.png"), QString());
  buttonSuperscript->setFixedWidth(btnSize);
  buttonSuperscript->setFixedHeight(btnSize);
  buttonSuperscript->setFont(font);
  layout->addWidget(buttonSuperscript);
  connect( buttonSuperscript, SIGNAL(clicked()), this, SLOT(addSuperscript()));

  if (buttons == Equation || buttons == TexLegend){
    QPushButton *buttonFraction = new QPushButton(QPixmap(":/fraction.png"), QString());
    buttonFraction->setFixedWidth(btnSize);
    buttonFraction->setFixedHeight(btnSize);
    buttonFraction->setFont(font);
    layout->addWidget(buttonFraction);
    connect(buttonFraction, SIGNAL(clicked()), this, SLOT(addFraction()));

    QPushButton *buttonSquareRoot = new QPushButton(QPixmap(":/square_root.png"), QString());
    buttonSquareRoot->setFixedWidth(btnSize);
    buttonSquareRoot->setFixedHeight(btnSize);
    buttonSquareRoot->setFont(font);
    layout->addWidget(buttonSquareRoot);
    connect(buttonSquareRoot, SIGNAL(clicked()), this, SLOT(addSquareRoot()));
  }

  QPushButton *buttonLowerGreek = new QPushButton(QString(QChar(0x3B1)));
  buttonLowerGreek->setFont(font);
  buttonLowerGreek->setFixedWidth(btnSize);
  buttonLowerGreek->setFixedHeight(btnSize);
  layout->addWidget(buttonLowerGreek);
  connect( buttonLowerGreek, SIGNAL(clicked()), this, SLOT(showLowerGreek()));

  QPushButton *buttonUpperGreek = new QPushButton(QString(QChar(0x393)));
  buttonUpperGreek->setFont(font);
  buttonUpperGreek->setFixedWidth(btnSize);
  buttonUpperGreek->setFixedHeight(btnSize);
  layout->addWidget(buttonUpperGreek);
  connect( buttonUpperGreek, SIGNAL(clicked()), this, SLOT(showUpperGreek()));

  QPushButton *buttonArrowSymbols = new QPushButton(QString(QChar(0x2192)));
  buttonArrowSymbols->setFont(font);
  buttonArrowSymbols->setFixedWidth(btnSize);
  buttonArrowSymbols->setFixedHeight(btnSize);
  layout->addWidget(buttonArrowSymbols);
  connect( buttonArrowSymbols, SIGNAL(clicked()), this, SLOT(showArrowSymbols()));

  QPushButton *buttonMathSymbols = new QPushButton(QString(QChar(0x222B)));
  buttonMathSymbols->setFont(font);
  buttonMathSymbols->setFixedWidth(btnSize);
  buttonMathSymbols->setFixedHeight(btnSize);
  layout->addWidget(buttonMathSymbols);
  connect( buttonMathSymbols, SIGNAL(clicked()), this, SLOT(showMathSymbols()));

  if (buttons != Plot3D && buttons != Equation && buttons != TexLegend){
    font = this->font();
    font.setBold(true);

    QPushButton *buttonBold = new QPushButton(tr("B","Button bold"));
    buttonBold->setFont(font);
    buttonBold->setFixedWidth(btnSize);
    buttonBold->setFixedHeight(btnSize);
    layout->addWidget(buttonBold);
    connect( buttonBold, SIGNAL(clicked()), this, SLOT(addBold()));

    font = this->font();
    font.setItalic(true);

    QPushButton *buttonItalics = new QPushButton(tr("It","Button italics"));
    buttonItalics->setFont(font);
    buttonItalics->setFixedWidth(btnSize);
    buttonItalics->setFixedHeight(btnSize);
    layout->addWidget(buttonItalics);
    connect( buttonItalics, SIGNAL(clicked()), this, SLOT(addItalics()));

    font = this->font();
    font.setUnderline(true);

    QPushButton *buttonUnderline = new QPushButton(tr("U","Button underline"));
    buttonUnderline->setFont(font);
    buttonUnderline->setFixedWidth(btnSize);
    buttonUnderline->setFixedHeight(btnSize);
    layout->addWidget(buttonUnderline);
    layout->addStretch();
    connect( buttonUnderline, SIGNAL(clicked()), this, SLOT(addUnderline()));
  } else
    layout->addStretch();
}
TextDialog::TextDialog(TextType type, QWidget* parent,  const char* name, bool modal, WFlags fl )
    : QDialog( parent, name, modal, fl )
{
    if ( !name )
		setName( "TextDialog" );

    setCaption( tr( "QtiPlot - Text options" ) );
    setSizeGripEnabled( true );
	
	text_type = type;
	GroupBox1 = new QButtonGroup(3,QGroupBox::Horizontal, QString::null, this);

	new QLabel(tr( "Color" ), GroupBox1);
	
    colorBox = new ColorButton(GroupBox1);

	buttonOk = new QPushButton( GroupBox1);
    buttonOk->setText( tr( "&OK" ) );
    buttonOk->setAutoDefault( TRUE );
    buttonOk->setDefault( TRUE );

	new QLabel(tr( "Font" ),GroupBox1);
	buttonFont = new QPushButton( GroupBox1, "buttonFont" );
    buttonFont->setText( tr( "&Font" ) );

	buttonApply = new QPushButton( GroupBox1, "buttonApply" );
    buttonApply->setText( tr( "&Apply" ) );
    buttonApply->setDefault( TRUE );
	
	if (text_type)
		{
		new QLabel(tr( "Alignement" ),GroupBox1, "TextLabel1_22",0);
		alignementBox = new QComboBox( FALSE, GroupBox1, "alignementBox" );
		alignementBox->insertItem( tr( "Center" ) );
		alignementBox->insertItem( tr( "Left" ) );
		alignementBox->insertItem( tr( "Right" ) );
		}
	else
		{
		new QLabel(tr( "Frame" ), GroupBox1, "TextLabel1",0 );
		backgroundBox = new QComboBox( FALSE, GroupBox1, "backgroundBox" );
		backgroundBox->insertItem( tr( "None" ) );
		backgroundBox->insertItem( tr( "Rectangle" ) );
		backgroundBox->insertItem( tr( "Shadow" ) );
		}

	buttonCancel = new QPushButton( GroupBox1, "buttonCancel" );
    buttonCancel->setText( tr( "&Cancel" ) );

	if (text_type == TextMarker)
		{
		new QLabel(tr("Background"), GroupBox1, "TextLabel2",0 );
		backgroundBtn = new ColorButton(GroupBox1);

		connect(backgroundBtn, SIGNAL(clicked()), this, SLOT(pickBackgroundColor()));

		buttonDefault = new QPushButton( GroupBox1);
		buttonDefault->setText( tr( "Set &Default" ) );
		connect(buttonDefault, SIGNAL(clicked()), this, SLOT(setDefaultValues()));
		}

	QLabel* rotate=new QLabel(tr( "Rotate (deg.)" ),GroupBox1, "TextLabel1_2",0);
	rotate->hide();
	
    rotateBox = new QComboBox( FALSE, GroupBox1, "rotateBox" );
    rotateBox->insertItem( tr( "0" ) );
    rotateBox->insertItem( tr( "45" ) );
    rotateBox->insertItem( tr( "90" ) );
    rotateBox->insertItem( tr( "135" ) );
    rotateBox->insertItem( tr( "180" ) );
    rotateBox->insertItem( tr( "225" ) );
    rotateBox->insertItem( tr( "270" ) );
    rotateBox->insertItem( tr( "315" ) );
	rotateBox->setEditable (TRUE);
	rotateBox->setCurrentItem(0);
	rotateBox->hide();
	
	GroupBox2= new QButtonGroup(8, QGroupBox::Horizontal, QString::null,this, "GroupBox2" );

	if (text_type == TextMarker)
		{
		buttonCurve = new QPushButton( GroupBox2, "buttonCurve" ); 
		buttonCurve->setPixmap (QPixmap(lineSymbol_xpm));
		connect( buttonCurve, SIGNAL( clicked() ), this, SLOT(addCurve() ) );
		}

    buttonIndice = new QPushButton( GroupBox2, "buttonIndice" ); 
    buttonIndice->setPixmap (QPixmap(index_xpm));

    buttonExp = new QPushButton( GroupBox2, "buttonExp" );
    buttonExp->setPixmap (QPixmap(exp_xpm));

    buttonMinGreek = new QPushButton(QChar(0x3B1), GroupBox2, "buttonMinGreek" ); 
	buttonMinGreek->setMaximumWidth(40);

	buttonMajGreek = new QPushButton(QChar(0x393), GroupBox2, "buttonMajGreek" ); 
	buttonMajGreek->setMaximumWidth(40);

	QFont font = this->font();
	font.setBold(true);

    buttonB = new QPushButton(tr("B"), GroupBox2, "buttonB" ); 
    buttonB->setFont(font);
	buttonB->setMaximumWidth(40);

	font = this->font();
	font.setItalic(true);
    buttonI = new QPushButton(tr("It"), GroupBox2, "buttonI" );
	buttonI->setFont(font);
	buttonI->setMaximumWidth(40);

	font = this->font();
	font.setUnderline(true);

    buttonU = new QPushButton(tr("U"), GroupBox2, "buttonU" );
	buttonU->setFont(font);
	buttonU->setMaximumWidth(40);

    textEditBox = new QTextEdit( this);
	textEditBox->setTextFormat(QTextEdit::PlainText);

	setFocusPolicy(QWidget::StrongFocus);
	setFocusProxy(textEditBox);
	
	QVBoxLayout* vlayout = new QVBoxLayout(this,5,5, "vlayout");
    vlayout->addWidget(GroupBox1);
	vlayout->addWidget(GroupBox2);
	vlayout->addWidget(textEditBox);

    // signals and slots connections
	connect( colorBox, SIGNAL( clicked() ), this, SLOT( pickTextColor() ) );
    connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
	connect( buttonApply, SIGNAL( clicked() ), this, SLOT( apply() ) );
    connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
	connect( buttonFont, SIGNAL( clicked() ), this, SLOT(customFont() ) );
	connect( buttonExp, SIGNAL( clicked() ), this, SLOT(addExp() ) );
	connect( buttonIndice, SIGNAL( clicked() ), this, SLOT(addIndex() ) );
	connect( buttonU, SIGNAL( clicked() ), this, SLOT(addUnderline() ) );
	connect( buttonI, SIGNAL( clicked() ), this, SLOT(addItalic() ) );
	connect( buttonB, SIGNAL( clicked() ), this, SLOT(addBold() ) );
	connect( buttonMinGreek, SIGNAL(clicked()), this, SLOT(showMinGreek()));
	connect( buttonMajGreek, SIGNAL(clicked()), this, SLOT(showMajGreek()));
}
Exemple #23
0
PlotWizard::PlotWizard( QWidget* parent, Qt::WFlags fl )
: QDialog( parent, fl )
{
	setWindowTitle( tr("MantidPlot - Select Columns to Plot") );

	setSizeGripEnabled( true );

	// top part starts here
	groupBox1 = new QGroupBox();

    QGridLayout *gl1 = new QGridLayout();
	buttonX = new QPushButton("<->" + tr("&X"));
	buttonX->setAutoDefault( false );
	gl1->addWidget( buttonX, 0, 0);

	buttonXErr = new QPushButton("<->" + tr("x&Err"));
	buttonXErr->setAutoDefault( false );
	gl1->addWidget( buttonXErr, 0, 1);

	buttonY = new QPushButton("<->" + tr("&Y"));
	buttonY->setAutoDefault( false );
	gl1->addWidget( buttonY, 1, 0);

	buttonYErr = new QPushButton("<->" + tr("yE&rr"));
	buttonYErr->setAutoDefault( false );
	gl1->addWidget( buttonYErr, 1, 1);

	buttonZ = new QPushButton("<->" + tr("&Z"));
	buttonZ->setAutoDefault( false );
	gl1->addWidget( buttonZ, 2, 0);
    gl1->setRowStretch(3,1);

    QHBoxLayout *hl2 = new QHBoxLayout();
    buttonNew = new QPushButton(tr("&New curve"));
    buttonNew->setDefault( true );
    buttonNew->setAutoDefault( true );
	hl2->addWidget(buttonNew);

	buttonDelete = new QPushButton(tr("&Delete curve"));
    buttonDelete->setAutoDefault( false );
	hl2->addWidget(buttonDelete);

    QVBoxLayout *vl = new QVBoxLayout();
    vl->addLayout(gl1);
    vl->addStretch();
    vl->addLayout(hl2);

    QGridLayout *gl2 = new QGridLayout(groupBox1);
    gl2->addWidget(new QLabel(tr( "Worksheet" )), 0, 0);
    boxTables = new QComboBox();
    gl2->addWidget(boxTables, 0, 1);
    columnsList = new QListWidget();
    gl2->addWidget(columnsList, 1, 0);
    gl2->addLayout(vl, 1, 1);

	// middle part is only one widget
	plotAssociations = new QListWidget();

	// bottom part starts here
	QHBoxLayout * bottomLayout = new QHBoxLayout();
    bottomLayout->addStretch();

	buttonOk = new QPushButton(tr("&Plot"));
    buttonOk->setAutoDefault( false );
	bottomLayout->addWidget( buttonOk );

	buttonCancel = new QPushButton(tr("&Close"));
    buttonCancel->setAutoDefault( false );
	bottomLayout->addWidget( buttonCancel );

	QVBoxLayout* vlayout = new QVBoxLayout( this );
	vlayout->addWidget( groupBox1 );
	vlayout->addWidget( plotAssociations );
	vlayout->addLayout( bottomLayout );

	// signals and slots connections
	connect( boxTables, SIGNAL(activated(const QString &)),this, SLOT(changeColumnsList(const QString &)));
	connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
	connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
	connect( buttonNew, SIGNAL( clicked() ), this, SLOT( addCurve() ) );
	connect( buttonDelete, SIGNAL( clicked() ), this, SLOT( removeCurve() ) );
	connect( buttonX, SIGNAL( clicked() ), this, SLOT(addXCol()));
	connect( buttonY, SIGNAL( clicked() ), this, SLOT(addYCol()));
	connect( buttonXErr, SIGNAL( clicked() ), this, SLOT(addXErrCol()));
	connect( buttonYErr, SIGNAL( clicked() ), this, SLOT(addYErrCol()));
	connect( buttonZ, SIGNAL( clicked() ), this, SLOT(addZCol()));
}
Exemple #24
0
ICurveHandle CurveEditor::addCurve(CurveTypes::CurveType curveType)
{
    return addCurve(createCurve(curveType));
}
void MainWindow::realtimeDataSlot()
{

    QVector<Qstring> deviceNums[10000];
        QVector<double> timeStamps[10000];
        QVector<double> tempVals[10000];
    QSqlDatabase accounts_db = QSqlDatabase::addDatabase("QSQLITE");
        accounts_db.setDatabaseName(dbaddr);
        if (!accounts_db.open())
        {
            qDebug() << "Could not open database file:";
            qDebug() << accounts_db.lastError();
            return;
         }
        else
        {
            qDebug("Connected to the database");
        }


    Qstring temp = Qstring("select Data, Timestamp, DeviceID from sensorData ORDER BY Timestamp;");
    qDebug() << "Query:"<< temp;
    QSqlQuery query(temp);

    if( !query.exec() )
             qDebug() << query.lastError();
    else
             qDebug( "Qeuried successfully" );


    //count the current number of rows in database ordered by timestamp
            int  cur_last_row;
            if(query.last())   cur_last_row = query.at();

            qDebug()<<"current last row: "<<cur_last_row;

            if(cur_last_row > prev_last_row) {

                         /*Before adding data, check to see if new devices are added
                          * and add a curve for the device
                          **/

                         // if db is not specified, then default database of this program is choosen
                         QSqlQuery dev_query("SELECT  DISTINCT DeviceID FROM Client_IP ORDER BY Timestamp;");
                         if( !dev_query.exec() )
                           qDebug() << dev_query.lastError();
                         else
                           qDebug( "Qeury executed successfully" );

                         // find the number of distinct devices
                          int cur_num_dev;
                          if(dev_query.last())   cur_num_dev = dev_query.at() ;// dev_num counts from "zero"

                         qDebug( "number of distinct devices: " );
                         qDebug() << cur_num_dev;

                         if(cur_num_dev>num_dev){

                             for(int i=num_dev; i<cur_num_dev+1; i++){
                                  dev_query.seek(i);
                                  dev_id[i]=dev_query.value(0).toString();
                                  qDebug() << dev_id[i];
                                 // add the add_graph function
                                  addCurve(ui->qtplot,i);
                             }
                             num_dev=cur_num_dev;
                          }




                         /*  for(int i=prev_last_row; i<cur_last_row+1;i++){

                               query.seek(i);
                               x[i]=query.value(0).toDouble();
                               y[i]=query.value(1).toDouble();
                               qDebug()<<x[i]<<y[i];
                               a[i]=query.value(2).toString();
                                qDebug()<<a[i];
                               // add the current data to the corresponding curve
                               addData(ui->qtplot,a[i],x[i],y[i]);
                               sleep(1);
                           }
                           */

                         QString tempdev= query.value(2).toString();
                          tempVals[prev_last_row]=query.value(0).toDouble();
                          timeStamps[prev_last_row]=query.value(1).toDouble();
                          qDebug()<<x[prev_last_row]<<y[prev_last_row];
                          deviceNums[prev_last_row]=tempdev;
                          //dviceNums.push_back(query.value(1).toString());
                           queryData(ui->qtplot,deviceNums[prev_last_row],timeStamps[prev_last_row],tempVals[prev_last_row]);

                           prev_last_row +=1;
                           qDebug()<<"previous last row: "<<prev_last_row;
               }

    //count_graph = deviceNums.length();


/*
     data = 0;
     static double lastPointKey = 0;
     double value0;
     double key=QDateTime::currentDateTime().toMSecsSinceEpoch()/1000.0;;

     if (key-lastPointKey >= 1.4) // at most add point every 14 ms
     {
         if(checkqry)
             if(qry->next())
             {
                 data = qry->value(2).toDouble();
                 qDebug() << "value:"<< qry->value(2).toDouble();
 //                timestamp = qry->value(1).toInt();
 //                qDebug() << "timestamp:"<< qry->value(1).toInt();
//                 if(init_time==0)
//                 {
//                     init_time = timestamp;
//                 }
             }
             else
             {
                 qry->~QSqlQuery();
                 close_qry();
                 accounts_db.close();
                 QSqlDatabase::removeDatabase("sData" );
             }
//     key= timestamp-init_time;  */





    // add data to lines:
    //ui->customPlot->graph(count_graph)->addData(timeStamps[count_graph], tempVals[count_graph]);

    // set data of dots:
   // ui->customPlot->graph(1)->clearData();
    //ui->customPlot->graph(count_graph)->addData(timeStamps[count_graph], tempVals[count_graph]);

    //ui->customPlot->graph(1)->addData(key, value0);

    // remove data of lines that's outside visible range:
   // ui->customPlot->graph(0)->removeDataBefore(key-15);
    }
curvesDialog::curvesDialog( QWidget* parent,  const char* name, bool modal, WFlags fl )
    : QDialog( parent, name, modal, fl )
{
    if ( !name )
	setName( "curvesDialog" );
	setMinimumSize(QSize(400,200));
    setCaption( tr( "QtiPlot - Add/Remove curves" ) );
	setFocus();
	
	QHBox *box5 = new QHBox (this, "box5"); 
	box5->setSpacing (5);
	box5->setMargin(5);

	new QLabel("New curves style", box5, "label0");
	boxStyle = new QComboBox (box5, "boxStyle");
	boxStyle->insertItem( QPixmap(lPlot_xpm), tr( " Line" ) );
    boxStyle->insertItem( QPixmap(pPlot_xpm), tr( " Scatter" ) );
    boxStyle->insertItem( QPixmap(lpPlot_xpm), tr( " Line + Symbol" ) );
    boxStyle->insertItem( QPixmap(dropLines_xpm), tr( " Vertical drop lines" ) );
	boxStyle->insertItem( QPixmap(spline_xpm), tr( " Spline" ) );
	boxStyle->insertItem( QPixmap(steps_xpm), tr( " Vertical steps" ) );
	boxStyle->insertItem( QPixmap(area_xpm), tr( " Area" ) );
	boxStyle->insertItem( QPixmap(vertBars_xpm), tr( " Vertical Bars" ) );
	boxStyle->insertItem( QPixmap(hBars_xpm), tr( " Horizontal Bars" ) );

	QHBox  *box0 = new QHBox (this, "box0"); 
	box0->setSpacing (5);

	QVBox  *box1=new QVBox (box0, "box1"); 
	box1->setMargin(5);
	box1->setSpacing (5);
	
	TextLabel1 = new QLabel(box1, "TextLabel1" );
    TextLabel1->setText( tr( "Available data" ) );

    available = new QListBox( box1, "available" );
	available->setSelectionMode (QListBox::Multi);
	
	QVBox  *box2=new QVBox (box0, "box2"); 
	box2->setMargin(5);
	box2->setSpacing (5);

    btnAdd = new QPushButton(box2, "btnAdd" );
    btnAdd->setPixmap( QPixmap(add_xpm) );
	btnAdd->setFixedWidth (35);
	btnAdd->setFixedHeight (30);
	
    btnRemove = new QPushButton(box2, "btnRemove" );
    btnRemove->setPixmap( QPixmap(remove_xpm) );
	btnRemove->setFixedWidth (35);
	btnRemove->setFixedHeight(30);
		
	QVBox  *box3=new QVBox (box0, "box3"); 
	box3->setMargin(5);
	box3->setSpacing (5);
	
	TextLabel2 = new QLabel(box3, "TextLabel2" );
    TextLabel2->setText( tr( "Graph contents" ) );

    contents = new QListBox( box3, "contents" );
	contents->setSelectionMode (QListBox::Multi);

	QVBox  *box4=new QVBox (box0, "box4"); 
	box4->setMargin(5);
	box4->setSpacing (5);

	btnAssociations = new QPushButton(box4, "btnAssociations" );
    btnAssociations->setText( tr( "&Plot Associations..." ) );
	btnAssociations->setEnabled(false);
	
	btnEditFunction = new QPushButton(box4, "btnEditFunction" );
    btnEditFunction->setText( tr( "&Edit Function..." ) );
	btnEditFunction->setEnabled(false);
	
    btnOK = new QPushButton(box4, "btnOK" );
    btnOK->setText( tr( "OK" ) );
	btnOK->setDefault( TRUE );
	
    btnCancel = new QPushButton(box4, "btnCancel" );
    btnCancel->setText( tr( "Close" ) );

	QVBoxLayout* layout = new QVBoxLayout(this,5,5, "hlayout3");
    layout->addWidget(box5);
	layout->addWidget(box0);

connect(btnAssociations, SIGNAL(clicked()),this, SLOT(showPlotAssociations()));
connect(btnEditFunction, SIGNAL(clicked()),this, SLOT(showFunctionDialog()));

connect(btnAdd, SIGNAL(clicked()),this, SLOT(addCurve()));
connect(btnRemove, SIGNAL(clicked()),this, SLOT(removeCurve()));
connect(btnOK, SIGNAL(clicked()),this, SLOT(close()));
connect(btnCancel, SIGNAL(clicked()),this, SLOT(close()));
connect(btnAdd, SIGNAL(clicked()),this, SLOT(enableRemoveBtn()));
connect(btnRemove, SIGNAL(clicked()),this, SLOT(enableRemoveBtn()));

connect(contents, SIGNAL(highlighted (int)), this, SLOT(showCurveBtn(int)));
connect(contents, SIGNAL(rightButtonClicked(QListBoxItem *, const QPoint &)), this, SLOT(deletePopupMenu(QListBoxItem *, const QPoint &)));
connect(available, SIGNAL(rightButtonClicked(QListBoxItem *, const QPoint &)), this, SLOT(addPopupMenu(QListBoxItem *, const QPoint &)));

QAccel *accel = new QAccel(this);
accel->connectItem( accel->insertItem( Key_Delete ), this, SLOT(removeCurve()) );
}
Exemple #27
0
void CurveWidget::initialize(bool zoom)
{
    setContentsMargins(2, 2, 2, 2);
    setMinimumHeight(338);

    int _width = QApplication::desktop()->availableGeometry().width();
    switch (_width) {
    case 1280: q_width = 493; break;
    case 1366: q_width = 532; break;
    default: q_width = 493; break;
    }

    setFixedWidth(q_width);
    plotLayout()->setAlignCanvasToScales( true);
    setAutoReplot();
    //setAxisAutoScale(QwtPlot::yLeft, false);

    QwtPlotGrid *grid = new QwtPlotGrid();
    grid->setPen(QColor(80, 80, 80, 100), 0.5, Qt::SolidLine);
    grid->enableX(true);
    grid->enableY(true);
    grid->attach(this);

    q_origin = new QwtPlotMarker();
    q_origin->setLineStyle( QwtPlotMarker::Cross);
    q_origin->setLinePen(QColor(100, 100, 100, 100), 1.0, Qt::DashLine );
    q_origin->attach(this);

    setAxisScaleDraw(QwtPlot::xBottom, new TimeScaleDraw());

    TimePlotPicker* picker = new TimePlotPicker(QwtPlot::xBottom, QwtPlot::yLeft,
        QwtPlotPicker::CrossRubberBand, QwtPicker::AlwaysOn, canvas());
    picker->setStateMachine(new QwtPickerDragPointMachine());
    picker->setRubberBandPen(QColor(100, 100, 100, 200));
    picker->setTrackerPen(QColor(128, 128, 200, 200));

    // zoomer
    if (zoom) {
        q_zoomer = new Zoomer(QwtPlot::xBottom, QwtPlot::yLeft, canvas());
        q_zoomer->setRubberBand(QwtPicker::RectRubberBand);
        q_zoomer->setRubberBandPen(QColor(Qt::green));
        q_zoomer->setTrackerMode(QwtPicker::ActiveOnly);
        q_zoomer->setTrackerPen(QColor(Qt::white));
    }

    // scale
    //setAxisScale( QwtPlot::xBottom, 0, 200 );
    //setAxisScale( QwtPlot::yLeft, 400, 800 );

    //! curve

    //srand(QDateTime::currentDateTime().fromMSecsSinceEpoch());

    //
    QVector<QPointF> samples(0);
    addCurve("Curve 1", QPen(QColor("#0c78a6"), 1), samples);
    addCurve("Curve 2", QPen(QColor("#5fd43b"), 1), samples);

    // Legend
    QwtPlotLegendItem* legendItem = new JLegendItem;
    legendItem->setMaxColumns(q_curves.count());
    legendItem->attach(this);
}
void MainWindow::on_StartButton_clicked()
{
    double A=ui->ASpin->value(), B=ui->BSpin->value(), N=ui->NSpin->value(), TMax=ui->TMaxSpin->value(), Eps=ui->EpsSpin->value();
    RungeKutta rk = RungeKutta(A, B, N, TMax, Eps);
    ui->Qwt_Widget->detachItems(QwtPlotItem::Rtti_PlotCurve, true);
    rk.run();
    //QCustomPlot* customPlot = ui->MainPlot;
    //customPlot->addGraph();
    //customPlot->graph(0)->setData(rk.y1, rk.y2);
//    for(int i=0; i<N; i++)
//    {
//        qDebug()<<"y1["<<i<<"]= "<<rk.y1[i]<<endl;
//    }
//    for(int i=0; i<N; i++)
//    {
//        qDebug()<<"y2["<<i<<"]= "<<rk.y2[i]<<endl;
//    }
//    customPlot->xAxis->setLabel("y1");
//    customPlot->yAxis->setLabel("y2");
//    if(rk.y1[0]<rk.y1[N])
//        customPlot->xAxis->setRange(rk.y1[0], rk.y1[N-1]);
//    else
//        customPlot->xAxis->setRange(rk.y1[N-1], rk.y1[0]);
//    if(rk.y2[0]<rk.y2[N])
//        customPlot->yAxis->setRange(rk.y2[0], rk.y2[N-1]);
//    else
//        customPlot->yAxis->setRange(rk.y2[N-1], rk.y2[0]);
//    customPlot->replot();
     min1=min(rk.y1,rk.p1);
     min2=min(rk.y2,rk.p2);
     max1=max(rk.y1,rk.p1);
     max2=max(rk.y2,rk.p2);
     ui->Qwt_Widget->setAxisScale(QwtPlot::xBottom, min1 , max1);
     ui->Qwt_Widget->setAxisScale(QwtPlot::yLeft, min2 , max2);
     ui->Qwt_Widget->replot();//чтобы сразу приблизить наблюдателя к графику
            // рисуем кривую
     addCurve(rk);

     QString abcs;
     abcs.setNum(c);
     c++;
     const QString filename = "C:/Users/Kirill/Desktop/Prac/report/"+abcs+".pdf";
     QPrinter printer;
       printer.setOutputFormat(QPrinter::PdfFormat);
       printer.setOrientation(QPrinter::Landscape);
       printer.setResolution(80);
       printer.setPaperSize(QPrinter::A4);
       printer.setFullPage(true);
       printer.setOutputFileName(filename);
       QImage image= QPixmap::grabWidget(ui->Qwt_Widget).toImage();
      // image.setDotsPerMeterX(500);
       image.scaled(1000,1000, Qt::KeepAspectRatio);
      // image.setDotsPerMeterY(500);
       QPainter painter;
         painter.begin(&printer);
         painter.drawImage(0,0,image);
         painter.end();

         //сделаем красивые графики в гнуплоте(выведем массивы в файл)

         QFile file("C:/Users/Kirill/Desktop/Prac/report/"+abcs+".txt");
         file.open(QIODevice::WriteOnly | QIODevice::Text);
         QTextStream out(&file);
         out.setRealNumberPrecision(10);
         for (int i=0; i<N ; i++)
             out << rk.t[i] <<' ' << rk.y1[i]<<' '<<rk.y2[i]<<"\n";

}
plotWizard::plotWizard( QWidget* parent, const char* name, bool modal, WFlags fl )
    : QDialog( parent, name, modal, fl )
{
    if ( !name )
	setName( "plotWizard" );
	setCaption( tr("QtiPlot - Select Columns to Plot") );
    setSizeGripEnabled( TRUE );
	
	GroupBox1 = new QButtonGroup( 2,QGroupBox::Horizontal,tr(""),this,"GroupBox1" );

    new QLabel( tr( "Worksheet" ), GroupBox1, "TextLabel3",0 );
	
    boxTables = new QComboBox( FALSE,GroupBox1, "boxTables" );
	
	columnsList = new QListBox(GroupBox1, "listBox" );
	columnsList->setSizePolicy(QSizePolicy (QSizePolicy::Expanding, QSizePolicy::Fixed, 2, 0, FALSE ));

	GroupBox3 = new QButtonGroup(2,QGroupBox::Horizontal,tr(""),GroupBox1,"GroupBox3" );
	GroupBox3->setFlat (TRUE);
	GroupBox3->setLineWidth (0);
	
	buttonX = new QPushButton(GroupBox3, "buttonX" );
    buttonX->setText("<->&X");
	
	buttonXErr = new QPushButton(GroupBox3, "buttonXErr" );
    buttonXErr->setText("<->x&Err");
	
	buttonY = new QPushButton(GroupBox3, "buttonY" );
    buttonY->setText("<->&Y");
   
    buttonYErr = new QPushButton(GroupBox3, "buttonYErr" );
    buttonYErr->setText("<->yE&rr");
	
	buttonZ = new QPushButton(GroupBox3, "buttonZ" );
    buttonZ->setText("<->&Z");
	
	columnsList->setMaximumHeight(3*buttonX->height() + 20);

	buttonNew = new QPushButton(GroupBox1, "buttonCurve" );
    buttonNew->setText(tr("&New curve"));
	
	buttonDelete = new QPushButton(GroupBox1, "buttonDelete" );
    buttonDelete->setText(tr("&Delete curve"));
	
	plotAssociations = new QListBox(this, "listBox" );
	
	GroupBox2 = new QButtonGroup(2,QGroupBox::Horizontal,tr(""),this,"GroupBox2" );
	GroupBox2->setFlat (TRUE);
	GroupBox2->setLineWidth (0);
	
	buttonOk = new QPushButton(GroupBox2, "buttonOk" );
    buttonOk->setText(tr("&Plot"));
    buttonOk->setDefault( TRUE );
   
    buttonCancel = new QPushButton(GroupBox2, "buttonCancel" );
    buttonCancel->setText(tr("&Cancel"));
	
	QVBoxLayout* vlayout = new QVBoxLayout(this,5,5, "hlayout");
    vlayout->addWidget(GroupBox1);
	vlayout->addWidget(plotAssociations);
	vlayout->addWidget(GroupBox2);
   
    // signals and slots connections
	connect( boxTables, SIGNAL(activated(const QString &)),this, SLOT(changeColumnsList(const QString &)));
    connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
    connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
	connect( buttonNew, SIGNAL( clicked() ), this, SLOT( addCurve() ) );
    connect( buttonDelete, SIGNAL( clicked() ), this, SLOT( toggleCurve() ) );
	connect( buttonX, SIGNAL( clicked() ), this, SLOT(addXCol()));
    connect( buttonY, SIGNAL( clicked() ), this, SLOT(addYCol()));
	connect( buttonXErr, SIGNAL( clicked() ), this, SLOT(addXErrCol()));
	connect( buttonYErr, SIGNAL( clicked() ), this, SLOT(addYErrCol()));
	connect( buttonZ, SIGNAL( clicked() ), this, SLOT(addZCol()));
}
Exemple #30
0
/* Read Type 13 charstring. Initial seek to offset performed if offset != -1 */
static void t13Read(cffCtx h, Offset offset, int init, int csLen)
	{
	unsigned length;

	switch (init)
		{
	case cstr_GLYPH:
		/* Initialize glyph charstring */
		h->stack.cnt = 0;
		h->path.nStems = 0;
		h->path.flags = GET_WIDTH|FIRST_MOVE|FIRST_MASK;
		break;
	case cstr_DICT:
		/* Initialize DICT charstring */
		h->path.flags = DICT_CSTR;
		break;
	case cstr_METRIC:
		/* Initialize metric charstring */
		h->stack.cnt = 0;
		h->path.flags = 0;
		break;
		}

	if (offset != -1)
		/* Seek to position of charstring if not already positioned */
		seekbyte(h, offset);

	for (;;)
		{
		int j;
		Fixed a;
		Fixed b;
		int byte0 = GETBYTE(h);
		switch (byte0)
			{
		case t13_endchar:
			if (!(h->path.flags & DICT_CSTR))
				{
				if (h->path.flags & FIRST_MOVE)
					{
					/* Non-marking glyph; set bounds */
					h->path.left = h->path.right = 0;
					h->path.bottom = h->path.top = 0;
					}
				if ((h->path.flags & GET_WIDTH) && setAdvance(h))
					return;	/* Stop after getting width */
				if (h->stack.cnt > 1)
					{
					/* Process seac components */
					int base;
					int accent;
					j = (h->stack.cnt == 4)? 0: 1;
					a = indexFix(h, j++);
					b = indexFix(h, j++);
					base = indexInt(h, j++);
					accent = indexInt(h, j);
					setComponentBounds(h, 0, base, 0, 0);
					setComponentBounds(h, 1, accent, a, b);
					}
				}
			PATH_FUNC_CALL(endchar,(h->cb.ctx));
			h->path.flags |= SEEN_END;
			return;
		case t13_reserved0:
		case t13_reserved236:
		case t13_reserved237:
		case t13_reserved244:
		case t13_reserved255:
			fatal(h, "reserved charstring op");
		case t13_rlineto:
			for (j = 0; j < h->stack.cnt; j += 2)
				addLine(h, indexFix(h, j + 0), indexFix(h, j + 1));
			h->stack.cnt = 0;
			break;
		case t13_hlineto:
		case t13_vlineto:
			{
			int horz = byte0 == t13_hlineto;
			for (j = 0; j < h->stack.cnt; j++)
				if (horz++ & 1)
					addLine(h, indexFix(h, j), 0);
				else
					addLine(h, 0, indexFix(h, j));
			}
			h->stack.cnt = 0;
			break;
		case t13_rrcurveto:
			for (j = 0; j < h->stack.cnt; j += 6)
				addCurve(h, 0,
						 indexFix(h, j + 0), indexFix(h, j + 1), 
						 indexFix(h, j + 2), indexFix(h, j + 3), 
						 indexFix(h, j + 4), indexFix(h, j + 5));
			h->stack.cnt = 0;
			break;
		case t13_callsubr:
			{
			Offset save = TELL(h);
			Offset localOffset = INDEXGet(h, &h->index.Subrs, popInt(h) + 
										  h->index.Subrs.bias, &length);
			t13Read(h, localOffset, cstr_NONE, length);
			if (h->path.flags & SEEN_END)
				return;		/* endchar operator terminated subr */
			seekbyte(h, save);
			}
			break;
		case t13_return:
			return;
		case t13_rcurveline:
			for (j = 0; j < h->stack.cnt - 2; j += 6)
				addCurve(h, 0,
						 indexFix(h, j + 0), indexFix(h, j + 1), 
						 indexFix(h, j + 2), indexFix(h, j + 3), 
						 indexFix(h, j + 4), indexFix(h, j + 5));
			addLine(h, indexFix(h, j + 0), indexFix(h, j + 1));
			h->stack.cnt = 0;
			break;
		case t13_rlinecurve:
			for (j = 0; j < h->stack.cnt - 6; j += 2)
				addLine(h, indexFix(h, j + 0), indexFix(h, j + 1));
			addCurve(h, 0,
					 indexFix(h, j + 0), indexFix(h, j + 1), 
					 indexFix(h, j + 2), indexFix(h, j + 3), 
					 indexFix(h, j + 4), indexFix(h, j + 5));
			h->stack.cnt = 0;
			break;
		case t13_vvcurveto:
			if (h->stack.cnt & 1)
				{
				/* Add initial curve */
				addCurve(h, 0,
						 indexFix(h, 0), indexFix(h, 1), 
						 indexFix(h, 2), indexFix(h, 3), 
						 0,				 indexFix(h, 4));
				j = 5;
				}
			else
				j = 0;

			/* Add remaining curve(s) */
			for (; j < h->stack.cnt; j += 4)
				addCurve(h, 0,
						 0, 				 indexFix(h, j + 0), 
						 indexFix(h, j + 1), indexFix(h, j + 2), 
						 0, 				 indexFix(h, j + 3));
			h->stack.cnt = 0;
			break;
		case t13_hhcurveto:
			if (h->stack.cnt & 1)
				{
				/* Add initial curve */
				addCurve(h, 0,
						 indexFix(h, 1), indexFix(h, 0), 
						 indexFix(h, 2), indexFix(h, 3), 
						 indexFix(h, 4), 0);
				j = 5;
				}
			else
				j = 0;

			/* Add remaining curve(s) */
			for (; j < h->stack.cnt; j += 4)
				addCurve(h, 0,
						 indexFix(h, j + 0), 0,
						 indexFix(h, j + 1), indexFix(h, j + 2), 
						 indexFix(h, j + 3), 0);
			h->stack.cnt = 0;
			break;
		case t13_callgsubr:
			{
			Offset save = TELL(h);
			Offset localOffset = INDEXGet(h, &h->index.global, popInt(h) + 
											  h->index.global.bias, &length);
			t13Read(h, localOffset, cstr_NONE, length);
			if (h->path.flags & SEEN_END)
				return;		/* endchar operator terminated subr */
			seekbyte(h, save);
			}
			break;
		case t13_vhcurveto:
		case t13_hvcurveto:
			{
			int adjust = (h->stack.cnt & 1)? 5: 0;
			int horz = byte0 == t13_hvcurveto;

			/* Add initial curve(s) */
			for (j = 0; j < h->stack.cnt - adjust; j += 4)
				if (horz++ & 1)
					addCurve(h, 0,
							 indexFix(h, j + 0), 0,
							 indexFix(h, j + 1), indexFix(h, j + 2), 
							 0,				     indexFix(h, j + 3));
				else
					addCurve(h, 0,
							 0,				     indexFix(h, j + 0),
							 indexFix(h, j + 1), indexFix(h, j + 2), 
							 indexFix(h, j + 3), 0);

			if (j < h->stack.cnt)
				{
				/* Add last curve */
				if (horz & 1)
					addCurve(h, 0,
							 indexFix(h, j + 0), 0,
							 indexFix(h, j + 1), indexFix(h, j + 2), 
							 indexFix(h, j + 4), indexFix(h, j + 3));
				else
					addCurve(h, 0,
							 0,				     indexFix(h, j + 0),
							 indexFix(h, j + 1), indexFix(h, j + 2), 
							 indexFix(h, j + 3), indexFix(h, j + 4));
				}
			h->stack.cnt = 0;
			}
			break;
		case t13_rmoveto:
			b = popFix(h);
			a = popFix(h);
			if (addMove(h, a, b))
				return;	/* Stop after getting width */
			h->stack.cnt = 0;
			break;
		case t13_hmoveto:
			if (addMove(h, popFix(h), 0))
				return;	/* Stop after getting width */
			h->stack.cnt = 0;
			break;
		case t13_vmoveto:
			if (addMove(h, 0, popFix(h)))
				return;	/* Stop after getting width */
			h->stack.cnt = 0;
			break;
		case t13_hstem:
		case t13_vstem:
		case t13_hstemhm:
		case t13_vstemhm:
			if ((h->path.flags & GET_WIDTH) && setAdvance(h))
				return;	/* Stop after getting width */
			h->path.nStems += h->stack.cnt / 2;
			if (PATH_FUNC_DEFINED(hintstem))
				{
				int vert = byte0 == tx_vstem || byte0 == t2_vstemhm;
				b = vert? h->path.vstem: h->path.hstem;
				for (j = h->stack.cnt & 1; j < h->stack.cnt; j += 2)
					{
					a = b + indexFix(h, j);
					b = a + indexFix(h, j + 1);
					h->path.cb->hintstem(h->cb.ctx, vert, a, b);
					}
				if (vert)
					h->path.vstem = b;
				else
					h->path.hstem = b;
				}
			h->stack.cnt = 0;
			break;
		case t13_hintmask:
		case t13_cntrmask:
			{
			int cnt;
			if (h->path.flags & FIRST_MASK)
				{
				/* The vstem(hm) op may be omitted if stem list is followed by
				   a mask op. In this case count the additional stems */
				if (PATH_FUNC_DEFINED(hintstem))
					{
					b = h->path.vstem;
					for (j = h->stack.cnt & 1; j < h->stack.cnt; j += 2)
						{
						a = b + indexFix(h, j);
						b = a + indexFix(h, j + 1);
						h->path.cb->hintstem(h->cb.ctx, 1, a, b);
						}
					}
				h->path.nStems += h->stack.cnt / 2;
				h->stack.cnt = 0;
				h->path.flags &= ~FIRST_MASK;
				}
			cnt = (h->path.nStems + 7) / 8;
			if (PATH_FUNC_DEFINED(hintmask))
				{
				char mask[CFF_MAX_MASK_BYTES];
				for (j = 0; j < cnt; j++)
					mask[j] = GETBYTE(h);
				h->path.cb->hintmask(h->cb.ctx, 
									 byte0 == t2_cntrmask, cnt, mask);
				}
			else
				while (cnt--)
					(void)GETBYTE(h);	/* Discard mask bytes */
			}
			break;
		case t13_escape:
			{
			double x;
			double y;
			switch (t13_ESC(GETBYTE(h)))
				{
			case t13_dotsection:
				break;
			default:
			case t13_reservedESC255:
			case t13_cntron:
				fatal(h, "reserved charstring op");
			case t13_and:
				b = popFix(h);
				a = popFix(h);
				pushInt(h, a && b);
				break;
			case t13_or:
				b = popFix(h);
				a = popFix(h);
				pushInt(h, a || b);
				break;
			case t13_not:
				a = popFix(h);
				pushInt(h, !a);
				break;
			case t13_store:
				{
				int count = popInt(h);
				int i = popInt(h);
				int j = popInt(h);
				int iReg = popInt(h);
				int regSize;
				Fixed *reg = selRegItem(h, iReg, &regSize);
				if (i < 0 || i + count - 1 >= h->BCA.size ||
					j < 0 || j + count - 1 >= regSize)
					fatal(h, "bounds check (store)\n");
				memcpy(&reg[j], &h->BCA.array[i], sizeof(Fixed) * count);
				}
				break;
			case t13_abs:
				a = popFix(h);
				pushFix(h, (a < 0)? -a: a);
				break;
			case t13_add:
				b = popFix(h);
				a = popFix(h);
				pushFix(h, a + b);
				break;
			case t13_sub:
				b = popFix(h);
				a = popFix(h);
				pushFix(h, a - b);
				break;
			case t13_div:
				y = popDbl(h);
				x = popDbl(h);
				if (y == 0.0)
					fatal(h, "divide by zero (div)");
				pushFix(h, DBL2FIX(x / y));
				break;
			case t13_load:
				{
				int regSize;
				int count = popInt(h);
				int i = popInt(h);
				int iReg = popInt(h);
				Fixed *reg = selRegItem(h, iReg, &regSize);
				if (i < 0 || i + count - 1 >= h->BCA.size || count > regSize)
					fatal(h, "bounds check (load)\n");
				memcpy(&h->BCA.array[i], reg, sizeof(Fixed) * count);
				}
				break;
			case t13_neg:
				a = popFix(h);
				pushFix(h, -a);
				break;
			case t13_eq:
				b = popFix(h);
				a = popFix(h);
				pushInt(h, a == b);
				break;
			case t13_drop:
				(void)popFix(h);
				break;
			case t13_put:
				{
				int i = popInt(h);
				if (i < 0 || i >= h->BCA.size)
					fatal(h, "bounds check (put)\n");
				h->BCA.array[i] = popFix(h);
				}
				break;
			case t13_get:
				{
				int i = popInt(h);
				if (i < 0 || i >= h->BCA.size)
					fatal(h, "bounds check (get)\n");
				pushFix(h, h->BCA.array[i]);
				}
				break;
			case t13_ifelse:
				{
				Fixed v2 = popFix(h);
				Fixed v1 = popFix(h);
				Fixed s2 = popFix(h);
				Fixed s1 = popFix(h);
				pushFix(h, (v1 > v2)? s2: s1);
				}
				break;
			case t13_random:	
				pushFix(h, PMRand());
				break;
			case t13_mul:
				y = popDbl(h);
				x = popDbl(h);
				pushFix(h, DBL2FIX(x * y));
				break;
			case t13_sqrt:
				pushFix(h, FixedSqrt(popFix(h)));
				break;
			case t13_dup:
				pushFix(h, h->stack.array[h->stack.cnt - 1].f);
				break;
			case t13_exch:
				b = popFix(h);
				a = popFix(h);
				pushFix(h, b);
				pushFix(h, a);
				break;
			case t13_index:
				{
				int i = popInt(h);
				if (i < 0)
					i = 0;	/* Duplicate top element */
				if (i >= h->stack.cnt)
					fatal(h, "limit check (index)");
				pushFix(h, h->stack.array[h->stack.cnt - 1 - i].f);
				}
				break;
			case t13_roll:
				{
				int j = popInt(h);
				int n = popInt(h);
				int iTop = h->stack.cnt - 1;
				int iBottom = h->stack.cnt - n;

				if (n < 0 || iBottom < 0)
					fatal(h, "limit check (roll)");

				/* Constrain j to [0,n) */
				if (j < 0)
					j = n - (-j % n);
				j %= n;

				reverse(h, iTop - j + 1, iTop);
				reverse(h, iBottom, iTop - j);
				reverse(h, iBottom, iTop);
				}
				break;
			case t13_hflex:
				addCurve(h, 1,
						 indexFix(h, 0),  0,
						 indexFix(h, 1),  indexFix(h, 2),
						 indexFix(h, 3),  0);
				addCurve(h, 1,
						 indexFix(h, 4),  0,
						 indexFix(h, 5),  0,
						 indexFix(h, 6), -indexFix(h, 2));
				h->stack.cnt = 0;
				break;
			case t13_flex:
				addCurve(h, 1,
						 indexFix(h, 0),  indexFix(h, 1),
						 indexFix(h, 2),  indexFix(h, 3),
						 indexFix(h, 4),  indexFix(h, 5));
				addCurve(h, 1,
						 indexFix(h, 6),  indexFix(h, 7),
						 indexFix(h, 8),  indexFix(h, 9),
						 indexFix(h, 10), indexFix(h, 11));
				h->stack.cnt = 0;
				break;
			case t13_hflex1:
				{
				Fixed dy1 = indexFix(h, 1);
				Fixed dy2 = indexFix(h, 3);
				Fixed dy5 = indexFix(h, 7);
				addCurve(h, 1,
						 indexFix(h, 0),  dy1,
						 indexFix(h, 2),  dy2,
						 indexFix(h, 4),  0);		  
				addCurve(h, 1,
						 indexFix(h, 5),  0,		  
						 indexFix(h, 6),  dy5,
						 indexFix(h, 8),  -(dy1 + dy2 + dy5));
				}
				h->stack.cnt = 0;
				break;
			case t13_flex1:
				{
				Fixed dx1 = indexFix(h, 0);
				Fixed dy1 = indexFix(h, 1);
				Fixed dx2 = indexFix(h, 2);
				Fixed dy2 = indexFix(h, 3);
				Fixed dx3 = indexFix(h, 4);
				Fixed dy3 = indexFix(h, 5);
				Fixed dx4 = indexFix(h, 6);
				Fixed dy4 = indexFix(h, 7);
				Fixed dx5 = indexFix(h, 8);
				Fixed dy5 = indexFix(h, 9);
				Fixed dx = dx1 + dx2 + dx3 + dx4 + dx5;
				Fixed dy = dy1 + dy2 + dy3 + dy4 + dy5;
				if (ABS(dx) > ABS(dy))
					{
					dx = indexFix(h, 10);
					dy = -dy;
					}
				else
					{
					dx = -dx;
					dy = indexFix(h, 10);
					}
				addCurve(h, 1, dx1, dy1, dx2, dy2, dx3, dy3);
				addCurve(h, 1, dx4, dy4, dx5, dy5,  dx,  dy);
				}
				h->stack.cnt = 0;
				break;
				}
			}
			break;
		case t13_blend:
			blendValues(h);
			break;
		default:
			/* Matches 1..215, result -107..107 */
			pushInt(h, 108 - byte0);
			break;
		case 241:
			/* 108..363 */
			pushInt(h, 363 - GETBYTE(h));
			break;
		case 239:
			/* 364..619 */
			pushInt(h, 619 - GETBYTE(h));
			break;
		case 246:
			/* 620..875 */
			pushInt(h, GETBYTE(h) + 620);
			break;
		case 235:
			/* 876..1131 */
			pushInt(h, 1131 - GETBYTE(h));
			break;
		case 232:
			/* -108..-363 */
			pushInt(h, GETBYTE(h) - 363);
			break;
		case 228:
			/* -364..-619 */
			pushInt(h, GETBYTE(h) - 619);
			break;
		case 224:
			/* -620..-875 */
			pushInt(h, GETBYTE(h) - 875);
			break;
		case 220:
			/* -876..-1131 */
			pushInt(h, GETBYTE(h) - 1131);
			break;
		case t13_shortint:
			{
			/* 2 byte number */
			long byte1 = GETBYTE(h);
			pushInt(h, byte1<<8 | GETBYTE(h));
			}
			break;
		case t13_shftshort:
			{
			long byte1 = GETBYTE(h);
			pushFix(h, byte1<<23 | GETBYTE(h)<<15);
			}
			break;
		case 254:
			{
			/* 5 byte number */
			long byte1 = GETBYTE(h);
			long byte2 = GETBYTE(h);
			long byte3 = GETBYTE(h);
			pushFix(h, byte1<<24 | byte2<<16 | byte3<<8 | GETBYTE(h));
			}
			break;
			}
		}
	}