void QSFMLCanvas::mouseMoveEvent(QMouseEvent* event) { QWidget::mouseMoveEvent(event); setAxis(A_L,event->pos().x()-mousePosition.x()); setAxis(A_R,event->pos().y()-mousePosition.y()); mousePosition=event->pos(); }
// Convert from spherical to cartesian coordinates void sphericalBlendShape::sphericalToCartesian(const MPoint& aPoint, short aPoleAxis, short aSeamAxis, MPoint& warpPoint, MPoint& outPoint) { const double radius = aPoint[0]; const double zenith = aPoint[1]; const double azimuth = aPoint[2]; MVector result; setAxis(result, aSeamAxis, radius * sin(zenith) * cos(azimuth)); setAxis(result, axisCross(aPoleAxis, aSeamAxis), radius * sin(zenith) * sin(azimuth)); setAxis(result, aPoleAxis, radius * cos(zenith)); outPoint.x = result[0]; outPoint.y = result[1]; outPoint.z = result[2]; }
/*! \fn void QGraphicsRotation::setAxis(Qt::Axis axis) Convenience function to set the axis to \a axis. Note: the Qt::YAxis rotation for QTransform is inverted from the correct mathematical rotation in 3D space. The QGraphicsRotation class implements a correct mathematical rotation. The following two sequences of code will perform the same transformation: \code QTransform t; t.rotate(45, Qt::YAxis); QGraphicsRotation r; r.setAxis(Qt::YAxis); r.setAngle(-45); \endcode */ void QGraphicsRotation::setAxis(Qt::Axis axis) { switch (axis) { case Qt::XAxis: setAxis(QVector3D(1, 0, 0)); break; case Qt::YAxis: setAxis(QVector3D(0, 1, 0)); break; case Qt::ZAxis: setAxis(QVector3D(0, 0, 1)); break; } }
TJoint::TJoint(vpColVector axis, float min_value, float max_value) : Joint() { setAxis(axis); setRange(min_value, max_value); setValue(0); }
void EngineMeter::paintEvent(QPaintEvent *) { if(!m_visible) hide(); else if(isHidden()) show(); //info.info_log("r:%d\n",m_radius); QPainter painter(this); painter.setRenderHint(QPainter::Antialiasing); setAxis(&painter); if(m_compoment & BackGround) drawBackground(&painter); if(m_compoment & Crown) drawCrown(&painter,m_radius); drawScale(&painter,m_radius); drawScaleNum(&painter,m_radius); drawNumericValue(&painter); if(m_compoment & DoubleMeter) { drawInnerScale(&painter,m_center,m_radius-m_strech); drawInnerScaleNum(&painter,m_center,m_radius-m_strech); } if(m_compoment & NumericValue) drawNumericValue(&painter); //draw units if((m_compoment & Units) || (m_compoment & NumericRate)) { if(!(m_compoment & NumericRate)) //rate is invisible { int haltw = int(1.7*m_radius); QRect r(-haltw,-m_radius/2-8,haltw<<1,16); drawContexts(&painter,QRect(r),m_units,16*m_scale,Qt::AlignCenter,QPen(Qt::darkMagenta)); } else { int haltw1 = int(1.7*m_radius); QRect r(-haltw1,-m_radius/2,haltw1<<1,16); //QRect r(-40,15,80,20); QString rate = QStringLiteral("¡Á") + QString("%1").arg(m_rate); if(m_compoment & Units) //units is visible rate += " "+m_units; drawContexts(&painter,QRect(r),rate,16*m_scale,Qt::AlignCenter,QPen(Qt::darkMagenta)); } } //draw title if(m_compoment & Title) { QRect rect(-width()/2,m_radius+2,width(),18); drawContexts(&painter,rect,m_title,18*m_scale,Qt::AlignCenter,QPen(Qt::yellow)); } drawRuntime(&painter); drawIndicator(&painter); }
QwtPlotPicker::QwtPlotPicker( QwtPlotCanvas *canvas ): QwtPicker( canvas ), d_xAxis( -1 ), d_yAxis( -1 ) { if ( !canvas ) return; // attach axes int xAxis = QwtPlot::xBottom; const QwtPlot *plot = QwtPlotPicker::plot(); if ( !plot->axisEnabled( QwtPlot::xBottom ) && plot->axisEnabled( QwtPlot::xTop ) ) { xAxis = QwtPlot::xTop; } int yAxis = QwtPlot::yLeft; if ( !plot->axisEnabled( QwtPlot::yLeft ) && plot->axisEnabled( QwtPlot::yRight ) ) { yAxis = QwtPlot::yRight; } setAxis( xAxis, yAxis ); }
void Grid::load(const QStringList& grid) { Plot *d_plot = (Plot *)plot(); if (!d_plot) return; bool majorOnX = grid[1].toInt(); bool minorOnX = grid[2].toInt(); bool majorOnY = grid[3].toInt(); bool minorOnY = grid[4].toInt(); bool xZeroOn = false; bool yZeroOn = false; int xAxis = QwtPlot::xBottom; int yAxis = QwtPlot::yLeft; QPen majPenX, minPenX, majPenY, minPenY; if (grid.count() >= 21) { // since 0.9 final majPenX = QPen(QColor(grid[5]), grid[7].toDouble(), Graph::getPenStyle(grid[6].toInt())); minPenX = QPen(QColor(grid[8]), grid[10].toDouble(), Graph::getPenStyle(grid[9].toInt())); majPenY = QPen(QColor(grid[11]), grid[13].toDouble(), Graph::getPenStyle(grid[12].toInt())); minPenY = QPen(QColor(grid[14]), grid[16].toDouble(), Graph::getPenStyle(grid[15].toInt())); xZeroOn = grid[17].toInt(); yZeroOn = grid[18].toInt(); xAxis = grid[19].toInt(); yAxis = grid[20].toInt(); if (grid.count() >= 22) setRenderHint(QwtPlotItem::RenderAntialiased, grid[21].toInt()); } else { // older versions of QtiPlot (<= 0.9rc3) majPenX = QPen(ColorBox::color(grid[5].toInt()), grid[7].toDouble(), Graph::getPenStyle(grid[6].toInt())); minPenX = QPen(ColorBox::color(grid[8].toInt()), grid[10].toDouble(), Graph::getPenStyle(grid[9].toInt())); majPenY = majPenX; minPenY = minPenX; xZeroOn = grid[11].toInt(); yZeroOn = grid[12].toInt(); if (grid.count() == 15) { xAxis = grid[13].toInt(); yAxis = grid[14].toInt(); } } setMajPenX(majPenX); setMinPenX(minPenX); setMajPenY(majPenY); setMinPenY(minPenY); enableX(majorOnX); enableXMin(minorOnX); enableY(majorOnY); enableYMin(minorOnY); setAxis(xAxis, yAxis); enableZeroLineX(xZeroOn); enableZeroLineY(yZeroOn); }
PlotZozPicker::PlotZozPicker( QWidget *canvas ): QwtPlotPicker( canvas ) { setAxis(QwtPlot::xBottom, QwtPlot::yLeft); setTrackerMode(QwtPlotPicker::AlwaysOn); setRubberBandPen(QColor(Qt::green)); setRubberBand(QwtPicker::CrossRubberBand); setTrackerPen(QColor(Qt::black)); }
bool SingleCellViewGraphPanelPlotWidget::setAxes(double pMinX, double pMaxX, double pMinY,double pMaxY, const bool &pCanReplot) { // Keep track of our axes' old values double oldMinX = minX(); double oldMaxX = maxX(); double oldMinY = minY(); double oldMaxY = maxY(); // Make sure that the given axes' values are fine checkAxesValues(pMinX, pMaxX, pMinY, pMaxY); // Update our axes' values, if needed bool axesValuesChanged = false; if ((pMinX != oldMinX) || (pMaxX != oldMaxX)) { setAxis(QwtPlot::xBottom, pMinX, pMaxX); axesValuesChanged = true; } if ((pMinY != oldMinY) || (pMaxY != oldMaxY)) { setAxis(QwtPlot::yLeft, pMinY, pMaxY); axesValuesChanged = true; } // Update our actions in case the axes' values have changed if (axesValuesChanged) updateActions(); // Replot ourselves, if needed and allowed if (axesValuesChanged && pCanReplot) { replotNow(); return true; } else { return false; } }
tRotatedPoint::tRotatedPoint(void *theOwner,tElement *REFDOT, tElement *AXIS, tReal angle):tDot(theOwner) { refDot = NULL; Axis = NULL; setAngle(angle); setReference(REFDOT); setAxis(AXIS); }
int QDeclarativeDrag::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QObject::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 8) qt_static_metacall(this, _c, _id, _a); _id -= 8; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< QGraphicsObject**>(_v) = target(); break; case 1: *reinterpret_cast< Axis*>(_v) = axis(); break; case 2: *reinterpret_cast< qreal*>(_v) = xmin(); break; case 3: *reinterpret_cast< qreal*>(_v) = xmax(); break; case 4: *reinterpret_cast< qreal*>(_v) = ymin(); break; case 5: *reinterpret_cast< qreal*>(_v) = ymax(); break; case 6: *reinterpret_cast< bool*>(_v) = active(); break; case 7: *reinterpret_cast< bool*>(_v) = filterChildren(); break; } _id -= 8; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setTarget(*reinterpret_cast< QGraphicsObject**>(_v)); break; case 1: setAxis(*reinterpret_cast< Axis*>(_v)); break; case 2: setXmin(*reinterpret_cast< qreal*>(_v)); break; case 3: setXmax(*reinterpret_cast< qreal*>(_v)); break; case 4: setYmin(*reinterpret_cast< qreal*>(_v)); break; case 5: setYmax(*reinterpret_cast< qreal*>(_v)); break; case 7: setFilterChildren(*reinterpret_cast< bool*>(_v)); break; } _id -= 8; } else if (_c == QMetaObject::ResetProperty) { switch (_id) { case 0: resetTarget(); break; } _id -= 8; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 8; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 8; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 8; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 8; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 8; } #endif // QT_NO_PROPERTIES return _id; }
RevoluteJoint::RevoluteJoint(const boost::shared_ptr<Link>& link_parent, const boost::shared_ptr<Link>& link_child, const Transform3f& transform_to_parent, const std::string& name, const Vec3f& axis) : Joint(link_parent, link_child, transform_to_parent, name) { BOOST_ASSERT(isNormalized(axis) && "Axis is not normalized."); setAxis(axis); init(); }
void H3LIS331DL::init(H3LIS331DL_ODR_t odr,H3LIS331DL_Mode_t mode,H3LIS331DL_Fullscale_t fullScale){ Wire.begin(); //set output data rate setODR(odr); //set PowerMode setMode( mode); //set Fullscale setFullScale( fullScale); //set axis Enable setAxis( H3LIS331DL_X_ENABLE | H3LIS331DL_Y_ENABLE | H3LIS331DL_Z_ENABLE); }
void QwtErrorPlotCurve::setMasterCurve(DataCurve *c) { if (!c || d_master_curve == c) return; d_master_curve = c; setAxis(c->xAxis(), c->yAxis()); d_start_row = c->startRow(); d_end_row = c->endRow(); c->addErrorBars(this); loadData(); }
void QSFMLCanvas::setKeyState(int key, int pressed) { switch(key){ case 16777235: setAxis(A_X,-1 * pressed); break; case 16777237: setAxis(A_X,1 * pressed); break; case 16777234: setAxis(A_Y,-1 * pressed); break; case 16777236: setAxis(A_Y,1 * pressed); break; case 87: setKey(K_UP,pressed); break; case 83: setKey(K_DOWN,pressed); break; case 65: setKey(K_LEFT,pressed); break; case 68: setKey(K_RIGHT,pressed); break; case 32: //space setKey(K_A,pressed); break; case 16777223: //supr setKey(K_B,pressed); break; default: if(pressed) cout << __func__ << " key " << key << "not handled" << endl; } }
PlotPicker( QWidget *canvas , const struct stream_info* streamInfo, const size_t group, const QVector<QwtPlotCurve*>* curves): m_streamInfo( streamInfo ), m_group( group ), m_curves( curves ), QwtPlotPicker( canvas ) { setAxis( QwtPlot::xBottom, QwtPlot::yLeft ); setRubberBand( QwtPlotPicker::CrossRubberBand ); setRubberBandPen( QColor( Qt::green ) ); setTrackerMode( QwtPicker::AlwaysOn ); setTrackerPen( QColor( Qt::black ) ); setStateMachine( new QwtPickerDragPointMachine () ); }
//矩形设门 //提供选择类 RectPicker::RectPicker(QWidget *canvas) :QwtPlotPicker(canvas) { setAxis(QwtPlot::xBottom, QwtPlot::yLeft); setResizeMode(QwtPicker::KeepSize);//变形模式 //设置一个状态机,并删除上一个 setStateMachine(new QwtPickerDragRectMachine()); setRubberBandPen(QColor(Qt::red)); //设置橡胶圈样式:椭圆 setRubberBand(QwtPicker::RectRubberBand); setTrackerPen(QColor(Qt::blue)); //设置跟踪模式 setTrackerMode(QwtPicker::ActiveOnly); setEnabled(false); }
void KoReportDesignerItemChart::slotPropertyChanged(KoProperty::Set &s, KoProperty::Property &p) { if (p.name() == "Name") { //For some reason p.oldValue returns an empty string if (!m_reportDesigner->isEntityNameUnique(p.value().toString(), this)) { p.setValue(m_oldName); } else { m_oldName = p.value().toString(); } } else if (p.name() == "three-dimensions") { set3D(p.value().toBool()); } else if (p.name() == "antialiased") { setAA(p.value().toBool()); } else if (p.name() == "color-scheme") { setColorScheme(p.value().toString()); } else if (p.name() == "data-source") { populateData(); } else if (p.name() == "title-x-axis" || p.name() == "title-y-axis") { setAxis(m_xTitle->value().toString(), m_yTitle->value().toString()); } else if (p.name() == "background-color") { setBackgroundColor(p.value().value<QColor>()); } else if (p.name() == "display-legend") { if (m_chartWidget && p.value().toBool()) { populateData(); } } else if (p.name() == "legend-position") { if (m_chartWidget) { populateData(); } } else if (p.name() == "legend-orientation") { if (m_chartWidget) { populateData(); } } else if (p.name() == "chart-type") { if (m_chartWidget) { populateData(); //m_chartWidget->setType((KDChart::Widget::ChartType) m_chartType->value().toInt()); } } else if (p.name() == "chart-sub-type") { if (m_chartWidget) { m_chartWidget->setSubType((KDChart::Widget::SubType) m_chartSubType->value().toInt()); } } KoReportDesignerItemRectBase::propertyChanged(s, p); if (m_reportDesigner) m_reportDesigner->setModified(true); }
void Spectrogram::showColorScale(int axis, bool on) { if (hasColorScale() == on && color_axis == axis) return; QwtPlot *plot = this->plot(); if (!plot) return; QwtScaleWidget *colorAxis = plot->axisWidget(color_axis); colorAxis->setColorBarEnabled(false); color_axis = axis; // We must switch main and the color scale axes and their respective scales int xAxis = this->xAxis(); int yAxis = this->yAxis(); int oldMainAxis = QwtPlot::xBottom; if (axis == QwtPlot::xBottom || axis == QwtPlot::xTop){ oldMainAxis = xAxis; xAxis = 5 - color_axis; } else if (axis == QwtPlot::yLeft || axis == QwtPlot::yRight){ oldMainAxis = yAxis; yAxis = 1 - color_axis; } // First we switch axes setAxis(xAxis, yAxis); // Next we switch axes scales QwtScaleDiv *scDiv = plot->axisScaleDiv(oldMainAxis); if (axis == QwtPlot::xBottom || axis == QwtPlot::xTop) plot->setAxisScale(xAxis, scDiv->lBound(), scDiv->hBound()); else if (axis == QwtPlot::yLeft || color_axis == QwtPlot::yRight) plot->setAxisScale(yAxis, scDiv->lBound(), scDiv->hBound()); colorAxis = plot->axisWidget(color_axis); plot->setAxisScale(color_axis, data().range().minValue(), data().range().maxValue()); colorAxis->setColorBarEnabled(on); colorAxis->setColorMap(data().range(), colorMap()); if (!plot->axisEnabled(color_axis)) plot->enableAxis(color_axis); colorAxis->show(); plot->updateLayout(); }
END_OPENFDM_OBJECT_DEF PrismaticJoint::PrismaticJoint(const std::string& name) : CartesianJoint<1>(name), mPositionPort(this, "position", Size(1, 1)), mVelocityPort(this, "velocity", Size(1, 1)), mPositionStateInfo(new Vector1StateInfo), mVelocityStateInfo(new Vector1StateInfo), mAxis(Vector3(1, 0, 0)), mInitialPosition(0), mInitialVelocity(0) { addContinousStateInfo(mPositionStateInfo); addContinousStateInfo(mVelocityStateInfo); // FIXME setAxis(mAxis); }
void caStripPlot::defineAxis(units unit, double period) { double interval; if(unit == Millisecond) { interval = period / 1000.0; } else if(unit == Second) { interval = period; } else if(unit == Minute) { interval = period * 60; } else { interval = 60; printf("\nunknown unit\n"); } // set axis and in case of a time scale define the time axis setAxis(interval, period); replot(); }
int QGraphicsRotation::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QGraphicsTransform::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { if (_id < 3) qt_static_metacall(this, _c, _id, _a); _id -= 3; } #ifndef QT_NO_PROPERTIES else if (_c == QMetaObject::ReadProperty) { void *_v = _a[0]; switch (_id) { case 0: *reinterpret_cast< QVector3D*>(_v) = origin(); break; case 1: *reinterpret_cast< qreal*>(_v) = angle(); break; case 2: *reinterpret_cast< QVector3D*>(_v) = axis(); break; } _id -= 3; } else if (_c == QMetaObject::WriteProperty) { void *_v = _a[0]; switch (_id) { case 0: setOrigin(*reinterpret_cast< QVector3D*>(_v)); break; case 1: setAngle(*reinterpret_cast< qreal*>(_v)); break; case 2: setAxis(*reinterpret_cast< QVector3D*>(_v)); break; } _id -= 3; } else if (_c == QMetaObject::ResetProperty) { _id -= 3; } else if (_c == QMetaObject::QueryPropertyDesignable) { _id -= 3; } else if (_c == QMetaObject::QueryPropertyScriptable) { _id -= 3; } else if (_c == QMetaObject::QueryPropertyStored) { _id -= 3; } else if (_c == QMetaObject::QueryPropertyEditable) { _id -= 3; } else if (_c == QMetaObject::QueryPropertyUser) { _id -= 3; } #endif // QT_NO_PROPERTIES return _id; }
void Grid::copy(Grid *grid) { if (!grid) return; setMajPenX(grid->majPenX()); setMinPenX(grid->minPenX()); setMajPenY(grid->majPenY()); setMinPenY(grid->minPenY()); enableX(grid->xEnabled()); enableXMin(grid->xMinEnabled()); enableY(grid->yEnabled()); enableYMin(grid->yMinEnabled()); setAxis(grid->xAxis(), grid->yAxis()); enableZeroLineX(grid->xZeroLineEnabled()); enableZeroLineY(grid->yZeroLineEnabled()); setRenderHint(QwtPlotItem::RenderAntialiased, grid->testRenderHint(QwtPlotItem::RenderAntialiased)); }
//============================================================================== void PrismaticJoint::setAspectProperties(const AspectProperties& properties) { setAxis(properties.mAxis); }
void sphericalBlendShapeVisualizerDrawOverride::addUIDrawables( const MDagPath& objPath, MHWRender::MUIDrawManager& drawManager, const MHWRender::MFrameContext& frameContext, const MUserData* data) { sphericalBlendShapeVisualizerData* pLocatorData = (sphericalBlendShapeVisualizerData*)data; if (!pLocatorData) { return; } MMatrix spaceMatrix = pLocatorData->fSpaceMatrix; MMatrix spaceInvMatrix = spaceMatrix.inverse(); short poleAxis = pLocatorData->fPoleAxis; short seamAxis = pLocatorData->fSeamAxis; drawManager.beginDrawable(); MColor lineColor, vertexColor, poleAxisColor, seamAxisColor; lineColor = MColor(0.7294f, .239216f, 0.2980f, 1.0f); vertexColor = MColor(0.5843f, 0.78824f, .17255f, 1.0f); poleAxisColor = MColor(1.0f, 0.0f, 0.f, 1.0f); seamAxisColor = MColor(0.0f, 1.0f, 0.0f, 1.0f); MMatrix identity; identity.setToIdentity(); double radius = 1.0; int numRings = 20; int numSections = 20; MPoint sphericalPoint, xyzPoint; MPoint startPoint, endPoint, firstPoint; MPointArray points; drawManager.setDepthPriority(5); drawManager.setColor(lineColor); bboxPoints.clear(); bboxPoints.setLength(numRings*numSections); for(int ring=0; ring<=numRings; ring++) { double azimuth = (double)ring / numRings * M_PI * 2; for(int section=0; section<=numSections; section++) { double zenith = (double)section / (numSections) * M_PI; sphericalPoint.x = radius; sphericalPoint.y = zenith; sphericalPoint.z = azimuth; if (section==0) { sphericalToCartesian(sphericalPoint, poleAxis, seamAxis, startPoint); startPoint = startPoint * spaceMatrix; firstPoint = startPoint; bboxPoints.append(firstPoint); continue; } else { sphericalToCartesian(sphericalPoint, poleAxis, seamAxis, endPoint); endPoint = endPoint * spaceMatrix; drawManager.line(startPoint, endPoint); bboxPoints.append(endPoint); startPoint = endPoint; } } } for(int ring=0; ring<=numRings; ring++) { double azimuth = (double)ring / numRings * M_PI * 2; for(int section=0; section<=numSections; section++) { double zenith = (double)section / (numSections) * M_PI; sphericalPoint.x = radius; sphericalPoint.y = azimuth; sphericalPoint.z = zenith; if (section==0) { sphericalToCartesian(sphericalPoint, poleAxis, seamAxis, startPoint); startPoint = startPoint * spaceMatrix; firstPoint = startPoint; continue; } else { sphericalToCartesian(sphericalPoint, poleAxis, seamAxis, endPoint); endPoint = endPoint * spaceMatrix; drawManager.line(startPoint, endPoint); startPoint = endPoint; } } } drawManager.setLineWidth(3.0); drawManager.setLineStyle(MHWRender::MUIDrawManager::kDashed); startPoint = MPoint(0, 0, 0) * spaceMatrix; MVector endVector(0, 0, 0); setAxis(endVector, poleAxis, radius); endPoint = MPoint(endVector) * spaceMatrix; drawManager.setColor(poleAxisColor); drawManager.line(startPoint, endPoint); endVector = MVector(0, 0, 0); setAxis(endVector, seamAxis, radius); endPoint = MPoint(endVector) * spaceMatrix; drawManager.setColor(seamAxisColor); drawManager.line(startPoint, endPoint); drawManager.endDrawable(); }
Rotate::Rotate(GLint* axis, GLfloat angle) { setAxis(axis); setAngle(angle); }
//============================================================================== void RevoluteJoint::setAspectProperties(const AspectProperties& properties) { setAxis(properties.mAxis); }
//----------------------------------------------------------------------------- tTransformedDotListCurve::~tTransformedDotListCurve() { setAxis(NULL); setReferenceCurve(NULL); }