void KXYSelector::wheelEvent( QWheelEvent *e ) { if ( e->orientation() == Qt::Horizontal ) setValues( xValue() + e->delta()/120, yValue() ); else setValues( xValue(), yValue() + e->delta()/120 ); emit valueChanged( d->xPos, d->yPos ); }
int main() { constexpr auto p = Point(1, 1); // {1,1} constexpr auto y = project_x(p); // {0, 1} std::cout << "{" << p.xValue() << "," << y.yValue() << "},"; std::cout << "{" << y.xValue() << "," << y.yValue() << "},"; }
void ImageMarker::draw (QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRect &) const { const int x0 = xMap.transform(xValue()); const int y0 = yMap.transform(yValue()); const int x1 = xMap.transform(d_x_right); const int y1 = yMap.transform(d_y_bottom); p->drawPixmap(QRect(x0, y0, abs(x1 - x0), abs(y1 - y0)), d_pic); }
QRect ImageMarker::rect() const { const QwtScaleMap &xMap = plot()->canvasMap(xAxis()); const QwtScaleMap &yMap = plot()->canvasMap(yAxis()); const int x0 = xMap.transform(xValue()); const int y0 = yMap.transform(yValue()); const int x1 = xMap.transform(d_x_right); const int y1 = yMap.transform(d_y_bottom); return QRect(x0, y0, abs(x1 - x0), abs(y1 - y0)); }
void LegendWidget::setFixedCoordinatesMode(bool on) { if (d_fixed_coordinates == on) return; d_fixed_coordinates = on; if(on){ d_x = xValue(); d_y = yValue(); } }
QRect LegendMarker::rect() const { const QwtScaleMap &xMap = d_plot->canvasMap(xAxis()); const QwtScaleMap &yMap = d_plot->canvasMap(yAxis()); const int x = xMap.transform(xValue()); const int y = yMap.transform(yValue()); int width, height; itemsHeight(y, symbolsMaxLineLength(), width, height); return QRect(QPoint(x, y), QSize(width - 1, height - 1)); }
void LegendMarker::setOriginCoord(double x, double y) { if (xValue() == x && yValue() == y) return; setXValue(x); setYValue(y); const QwtScaleMap &xMap = d_plot->canvasMap(xAxis()); const QwtScaleMap &yMap = d_plot->canvasMap(yAxis()); d_pos = QPoint(xMap.transform(x), yMap.transform(y)); }
void LegendWidget::print(QPainter *painter, const QwtScaleMap map[QwtPlot::axisCnt]) { int x = map[QwtPlot::xBottom].transform(xValue()); int y = map[QwtPlot::yLeft].transform(yValue()); const int symbolLineLength = line_length + symbolsMaxWidth(); int width, height; QwtArray<int> heights = itemsHeight(y, symbolLineLength, width, height); QRect rect = QRect(x, y, width, height); drawFrame(painter, rect); drawText(painter, rect, heights, symbolLineLength); }
void LegendMarker::draw(QPainter *p, const QwtScaleMap &xMap, const QwtScaleMap &yMap, const QRect &) const { const int x = xMap.transform(xValue()); const int y = yMap.transform(yValue()); const int symbolLineLength = symbolsMaxLineLength(); int width, height; QwtArray<long> heights = itemsHeight(y, symbolLineLength, width, height); QRect rs = QRect(QPoint(x, y), QSize(width, height)); drawFrame(p, d_frame, rs); drawSymbols(p, rs, heights, symbolLineLength); drawLegends(p, rs, heights, symbolLineLength); }
void ImageMarker::setBoundingRect(double left, double top, double right, double bottom) { if (xValue() == left && yValue() == top && d_x_right == right && d_y_bottom == bottom) return; setXValue(left); setYValue(top); d_x_right = right; d_y_bottom = bottom; if (!plot()) return; plot()->updateLayout(); QRect r = this->rect(); d_pos = r.topLeft(); d_size = r.size(); }
QwtDoubleRect ImageMarker::boundingRect() const { return QwtDoubleRect(xValue(), yValue(), qAbs(d_x_right - xValue()), qAbs(d_y_bottom - yValue())); }
void ellipsoidWireFrame() { static GLuint vertBuffer; static GLuint normalsBuffer; static GLuint indexBuffer; static GLboolean first = GL_TRUE; GLfloat u,v; int m,n; int cnt=0; if (first || changeFlag) { for (n=0; n <= BIG_N; n++) { v = -M_PI/2.0 + (float) n/ (float) BIG_N * M_PI; for (m=0; m <= BIG_M; m++) { u = -M_PI + (float) m/ (float) BIG_M * 2.0 * M_PI; verticesArray[cnt] = xValue(u,v); normalsArray[cnt] = nxValue(u,v); cnt++; verticesArray[cnt] = yValue(u,v); normalsArray[cnt] = nyValue(u,v); cnt++; verticesArray[cnt] = zValue(u,v); normalsArray[cnt] = nzValue(u,v); cnt++; } } glGenBuffers(1, &vertBuffer); glBindBuffer(GL_ARRAY_BUFFER, vertBuffer); glBufferData(GL_ARRAY_BUFFER, sizeof(verticesArray), verticesArray, GL_STATIC_DRAW); glGenBuffers(1, &normalsBuffer); glBindBuffer(GL_ARRAY_BUFFER,normalsBuffer); glBufferData(GL_ARRAY_BUFFER, sizeof(normalsArray), normalsArray, GL_STATIC_DRAW); if (first) { createMeshStripIndices(); glGenBuffers(1, &indexBuffer); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, indexBuffer); glBufferData(GL_ELEMENT_ARRAY_BUFFER, sizeof(tubeStrips), tubeStrips, GL_STATIC_DRAW); } first = GL_FALSE; changeFlag = GL_FALSE; } loadUniforms(); glEnableVertexAttribArray(vertexPositionAttr); glBindBuffer(GL_ARRAY_BUFFER, vertBuffer); glVertexAttribPointer(vertexPositionAttr,3, GL_FLOAT,GL_FALSE, 0, (GLvoid*) 0); glBindBuffer(GL_ARRAY_BUFFER, normalsBuffer); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,indexBuffer); glDrawElements(GL_QUAD_STRIP, TOTAL_INDICES, GL_UNSIGNED_SHORT, (GLvoid*) 0); }