QVariant SCgNode::itemChange(GraphicsItemChange change, const QVariant &value) { if (mBus && !mBus->isDead() && change == QGraphicsItem::ItemParentHasChanged) mBus->setParentItem(parentItem()); updateConnected(); return SCgObject::itemChange(change, value); }
void SCgBus::updateShape() { prepareGeometryChange(); // creating shape mShape = QPainterPath(); mShape.moveTo(mPoints.at(0)); for (int i = 1; i < mPoints.size(); i++) mShape.lineTo(mPoints.at(i)); QPainterPathStroker path_stroker; path_stroker.setJoinStyle(Qt::MiterJoin); path_stroker.setWidth(SCgAlphabet::lineWidthForShape()); mShape = path_stroker.createStroke(mShape); mLineShape = mShape; // update item update(); // update connected objects updateConnected(); // update text position if (mTextItem) mTextItem->setTextPos((mPoints.at(0) + mPoints.at(1)) / 2.f); }
BioXASSideXIAFilters::BioXASSideXIAFilters(QObject *parent) : BioXASXIAFilters("BioXASSideXIAFilters", parent) { // Initialize inherited variables. filter1_ = new BioXASXIAFiltersActuator(name()+"1", "PFIL1607-6-I22-01", this); connect( filter1_, SIGNAL(connected(bool)), this, SLOT(updateConnected()) ); filter2_ = new BioXASXIAFiltersActuator(name()+"2", "PFIL1607-6-I22-02", this); connect( filter2_, SIGNAL(connected(bool)), this, SLOT(updateConnected()) ); filter3_ = new BioXASXIAFiltersActuator(name()+"3", "PFIL1607-6-I22-03", this); connect( filter3_, SIGNAL(connected(bool)), this, SLOT(updateConnected()) ); filter4_ = new BioXASXIAFiltersActuator(name()+"4", "PFIL1607-6-I22-04", this); connect( filter4_, SIGNAL(connected(bool)), this, SLOT(updateConnected()) ); // filtersControl_ = new BioXASXIAFiltersControl(name() + " Control", this); // filtersControl_->addFilterActuatorControl(filter1_, 0.25); // filtersControl_->addFilterActuatorControl(filter2_, 0.5); // filtersControl_->addFilterActuatorControl(filter3_, 1.0); // filtersControl_->addFilterActuatorControl(filter4_, 10.0); // Current settings. updateConnected(); }
void SCgContour::updateShape() { prepareGeometryChange(); mShape = QPainterPath(); // Generate control points to be used for path drawing PointFVector points; quint32 pointsSize = mPoints.size(); for (quint32 i = 0; i < pointsSize; i++) { QPointF p2 = mPoints[(i + 1) % pointsSize]; QPointF p1 = mPoints[i]; QVector2D dir(p2 - p1); // In case two points are placed close to each other // we need to adjust corner radius. qreal cornerRadiusAdjusted = cornerRadius; qreal dirLength = dir.length(); if(dirLength < cornerRadius * 2) cornerRadiusAdjusted = dirLength / 2; dir.normalize(); QPointF dv = dir.toPointF() * cornerRadiusAdjusted; points.push_back(p1); points.push_back(p1 + dv); points.push_back(p2 - dv); } // Draw path using generated points quint32 psz3 = pointsSize * 3; for (quint32 i = 0; i < psz3; i += 3) { if (i == 0) mShape.moveTo(points[i + 1]); mShape.lineTo(points[i + 2]); mShape.quadTo(points[(i + 3) % psz3], points[(i + 4) % psz3]); } mShape.closeSubpath(); mShapeNormal = mShape; QPainterPathStroker path_stroker; path_stroker.setWidth(SCgAlphabet::lineWidthForShape() + 2); mShape = path_stroker.createStroke(mShape); mLineShape = mShape; mShape = mShapeNormal.united(mShape); updateConnected(); update(); }
QVariant SCgObject::itemChange(GraphicsItemChange change, const QVariant &value) { // item selection changed if (change == QGraphicsItem::ItemSelectedHasChanged) { if (isSelected()) { mColor = scg_cfg_get_value_color(scg_key_element_color_selected);//QColor(255, 128, 64); //setCursor(QCursor(Qt::SizeAllCursor)); } else { mColor = scg_cfg_get_value_color(scg_key_element_color_normal);//QColor(0, 0, 0); //setCursor(QCursor(Qt::ArrowCursor)); } } // move to correct position automaticly if (change == QGraphicsItem::ItemParentChange && scene()) { // we need to set this flag to prevent processing ItemPositionHasChanged, // because item position at this moment not actual mParentChanging = true; QGraphicsItem* newParent = value.value<QGraphicsItem*>(); if(newParent) setPos(newParent->mapFromScene(scenePos())); else setPos(scenePos()); } if (change == QGraphicsItem::ItemParentHasChanged) { // now item position has valid value mParentChanging = false; updateConnected(); } // Change stacking order if (scene() && change == QGraphicsItem::ItemSelectedHasChanged && isSelected() && scene()->selectedItems().size() == 1) { QGraphicsItem* top = this; QList<QGraphicsItem*> lst = scene()->items(); foreach(QGraphicsItem* it, lst) { if(it != this && it->type() == type() && it->parentItem() == parentItem()) { it->stackBefore(top); top = it; } } }
void SCgNode::hideContent() { Q_ASSERT(mContentVisible && mContentViewer); prepareGeometryChange(); mContentVisible = false; updateConnected(); mContentViewer->hide(); update(); }
void SCgNode::showContent() { Q_ASSERT(!mContentVisible && mContentViewer); prepareGeometryChange(); mContentVisible = true; updateConnected(); mContentViewer->show(); update(); }
void SCgContour::updateShape() { prepareGeometryChange(); mShape = QPainterPath(); PointFVector points; quint32 pointsSize = mPoints.size(); for (quint32 i = 0; i < pointsSize; i++) { QPointF p2 = mPoints[(i + 1) % pointsSize]; QPointF p1 = mPoints[i]; QVector2D dir(p2 - p1); dir.normalize(); QPointF dv = dir.toPointF() * CONTOUR_CORNER_RADIUS; points.push_back(p1); points.push_back(p1 + dv); points.push_back(p2 - dv); } // draw path quint32 psz3 = pointsSize * 3; for (quint32 i = 0; i < pointsSize; i++) { quint32 idx = i * 3; if (i == 0) mShape.moveTo(points[idx + 1]); mShape.lineTo(points[idx + 2]); mShape.quadTo(points[(idx + 3) % psz3], points[(idx + 4) % psz3]); } mShape.closeSubpath(); mShapeNormal = mShape; QPainterPathStroker path_stroker; //path_stroker.setJoinStyle(Qt::MiterJoin); path_stroker.setWidth(SCgAlphabet::lineWidthForShape() + 2); mShape = path_stroker.createStroke(mShape); mLineShape = mShape; mShape = mShapeNormal.united(mShape); updateConnected(); update(); }
BioXASMainMonochromator::BioXASMainMonochromator(QObject *parent) : BioXASSSRLMonochromator("MainMono", parent) { // Create components. upperSlit_ = new AMPVwStatusControl("UpperSlitBlade", "SMTR1607-5-I21-09:mm:fbk", "SMTR1607-5-I21-09:mm", "SMTR1607-5-I21-09:status", "SMTR1607-5-I21-09:stop", this); lowerSlit_ = new AMPVwStatusControl("LowerSlitBlade", "SMTR1607-5-I21-10:mm:fbk", "SMTR1607-5-I21-10:mm", "SMTR1607-5-I21-10:status", "SMTR1607-5-I21-10:stop", this); slitsStatus_ = new AMReadOnlyPVControl(QString("SlitsStatus"), QString("BL1607-5-I21:Mono:SlitsClosed"), this); paddle_ = new AMPVwStatusControl("Paddle", "SMTR1607-5-I21-11:mm:fbk", "SMTR1607-5-I21-11:mm", "SMTR1607-5-I21-11:status", "SMTR1607-5-I21-11:stop", this); paddleStatus_ = new AMReadOnlyPVControl(QString("PaddleStatus"), QString("BL1607-5-I21:Mono:PaddleExtracted"), this); keyStatus_ = new AMReadOnlyPVControl(QString("KeyStatus"), QString("BL1607-5-I21:Mono:KeyStatus"), this); brakeStatus_ = new AMReadOnlyPVControl(QString("BrakeStatus"), QString("BL1607-5-I21:Mono:BrakeOff"), this); braggAtCrystalChangePositionStatus_ = new AMReadOnlyPVControl("AtCrystalChangePosition", "BL1607-5-I21:Mono:XtalChangePos", this); crystalChange_ = new AMPVwStatusControl("CrystalChange", "SMTR1607-5-I21-22:mm:fbk", "SMTR1607-5-I21-22:mm", "SMTR1607-5-I21-22:status", "SMTR1607-5-I21-22:stop", this); crystalChangeCWLimitStatus_ = new AMReadOnlyPVControl("CrystalChangeCWStatus", "SMTR1607-5-I21-22:cw", this); crystalChangeCCWLimitStatus_ = new AMReadOnlyPVControl("CrystalChangeCCWStatus", "SMTR1607-5-I21-22:ccw", this); regionAStatus_ = new AMReadOnlyPVControl("RegionAStatus", "BL1607-5-I21:Mono:Region:A", this); regionBStatus_ = new AMReadOnlyPVControl("RegionBStatus", "BL1607-5-I21:Mono:Region:B", this); upperSlitMotor_ = new CLSMAXvMotor(QString("SMTR1607-5-I21-09 VERT UPPER BLADE"), QString("SMTR1607-5-I21-09"), QString("SMTR1607-5-I21-09 VERT UPPER BLADE"), true, 0.1, 2.0, this); lowerSlitMotor_ = new CLSMAXvMotor(QString("SMTR1607-5-I21-10 VERT LOWER BLADE"), QString("SMTR1607-5-I21-10"), QString("SMTR1607-5-I21-10 VERT LOWER BLADE"), true, 0.1, 2.0, this); paddleMotor_ = new CLSMAXvMotor(QString("SMTR1607-5-I21-11 PHOSPHOR PADDLE"), QString("SMTR1607-5-I21-11"), QString("SMTR1607-5-I21-11 PHOSPHOR PADDLE"), false, 0.1, 2.0, this); encoderBraggMotor_ = new CLSMAXvMotor(QString("SMTR1607-5-I21-12 BRAGG"), QString("SMTR1607-5-I21-12"), QString("SMTR1607-5-I21-12 BRAGG"), true, 0.05, 2.0, this, QString(":deg")); stepsBraggMotor_ = new CLSMAXvMotor(QString("SMTR1607-5-I21-12 BRAGG"), QString("SMTR1607-5-I21-12"), QString("SMTR1607-5-I21-12 BRAGG"), false, 0.05, 2.0, this, QString(":deg")); verticalMotor_ = new CLSMAXvMotor(QString("SMTR1607-5-I21-13 VERTICAL"), QString("SMTR1607-5-I21-13"), QString("SMTR1607-5-I21-13 VERTICAL"), true, 0.05, 2.0, this); lateralMotor_ = new CLSMAXvMotor(QString("SMTR1607-5-I21-14 LATERAL"), QString("SMTR1607-5-I21-14"), QString("SMTR1607-5-I21-14 LATERAL"), true, 0.05, 2.0, this); crystalChangeMotor_ = new CLSMAXvMotor(QString("SMTR1607-5-I21-22 XTAL XCHAGE"), QString("SMTR1607-5-I21-22"), QString("SMTR1607-5-I21-22 XTAL XCHAGE"), true, 0.05, 2.0, this); crystal1PitchMotor_ = new CLSMAXvMotor(QString("SMTR1607-5-I21-23 XTAL 1 PITCH"), QString("SMTR1607-5-I21-23"), QString("SMTR1607-5-I21-23 XTAL 1 PITCH"), true, 0.05, 2.0, this, QString(":V")); crystal1RollMotor_ = new CLSMAXvMotor(QString("SMTR1607-5-I21-24 XTAL 1 ROLL"), QString("SMTR1607-5-I21-24"), QString("SMTR1607-5-I21-24 XTAL 1 ROLL"), true, 0.05, 2.0, this, QString(":V")); crystal2PitchMotor_ = new CLSMAXvMotor(QString("SMTR1607-5-I21-25 XTAL 2 PITCH"), QString("SMTR1607-5-I21-25"), QString("SMTR1607-5-I21-25 XTAL 2 PITCH"), true, 0.05, 2.0, this, QString(":V")); crystal2RollMotor_ = new CLSMAXvMotor(QString("SMTR1607-5-I21-26 XTAL 2 ROLL"), QString("SMTR1607-5-I21-26"), QString("SMTR1607-5-I21-26 XTAL 2 ROLL"), true, 0.05, 2.0, this, QString(":V")); encoderStepsDiff_ = new AMReadOnlyPVControl(name()+"EncoderStepsDiffControlDeg", "BL1607-7-I21:Mono:fbk:diff", this); // Create region control. region_ = new BioXASSSRLMonochromatorRegionControl(name()+"RegionControl", this); region_->setUpperSlitControl(upperSlit_); region_->setLowerSlitControl(lowerSlit_); region_->setSlitsStatusControl(slitsStatus_); region_->setPaddleControl(paddle_); region_->setPaddleStatusControl(paddleStatus_); region_->setKeyStatusControl(keyStatus_); region_->setBrakeStatusControl(brakeStatus_); region_->setBraggControl(braggMotor()); region_->setBraggAtCrystalChangePositionStatusControl(braggAtCrystalChangePositionStatus_); region_->setCrystalChangeControl(crystalChange_); region_->setCrystalChangeCWLimitStatusControl(crystalChangeCWLimitStatus_); region_->setCrystalChangeCCWLimitStatusControl(crystalChangeCCWLimitStatus_); region_->setRegionAStatusControl(regionAStatus_); region_->setRegionBStatusControl(regionBStatus_); // Create energy control. encoderEnergy_ = new BioXASSSRLMonochromatorEnergyControl(name()+"EncoderEnergyControl", this); encoderEnergy_->setBraggControl(encoderBraggMotor_); encoderEnergy_->setRegionControl(region_); encoderEnergy_->setM1MirrorPitchControl(m1Pitch_); stepEnergy_ = new BioXASSSRLMonochromatorEnergyControl(name()+"StepEnergyControl", this); stepEnergy_->setBraggControl(stepsBraggMotor_); stepEnergy_->setRegionControl(region_); stepEnergy_->setM1MirrorPitchControl(m1Pitch_); // Listen to connection states. connect( upperSlit_, SIGNAL(connected(bool)), this, SLOT(updateConnected()) ); connect( lowerSlit_, SIGNAL(connected(bool)), this, SLOT(updateConnected()) ); connect( slitsStatus_, SIGNAL(connected(bool)), this, SLOT(updateConnected()) ); connect( paddle_, SIGNAL(connected(bool)), this, SLOT(updateConnected()) ); connect( paddleStatus_, SIGNAL(connected(bool)), this, SLOT(updateConnected()) ); connect( keyStatus_, SIGNAL(connected(bool)), this, SLOT(updateConnected()) ); connect( brakeStatus_, SIGNAL(connected(bool)), this, SLOT(updateConnected()) ); connect( braggAtCrystalChangePositionStatus_, SIGNAL(connected(bool)), this, SLOT(updateConnected()) ); connect( crystalChange_, SIGNAL(connected(bool)), this, SLOT(updateConnected()) ); connect( crystalChangeCWLimitStatus_, SIGNAL(connected(bool)), this, SLOT(updateConnected()) ); connect( crystalChangeCCWLimitStatus_, SIGNAL(connected(bool)), this, SLOT(updateConnected()) ); connect( regionAStatus_, SIGNAL(connected(bool)), this, SLOT(updateConnected()) ); connect( regionBStatus_, SIGNAL(connected(bool)), this, SLOT(updateConnected()) ); connect( upperSlitMotor_, SIGNAL(connected(bool)), this, SLOT(updateConnected()) ); connect( lowerSlitMotor_, SIGNAL(connected(bool)), this, SLOT(updateConnected()) ); connect( paddleMotor_, SIGNAL(connected(bool)), this, SLOT(updateConnected()) ); connect( encoderBraggMotor_, SIGNAL(connected(bool)), this, SLOT(updateConnected()) ); connect( stepsBraggMotor_, SIGNAL(connected(bool)), this, SLOT(updateConnected()) ); connect( verticalMotor_, SIGNAL(connected(bool)), this, SLOT(updateConnected()) ); connect( lateralMotor_, SIGNAL(connected(bool)), this, SLOT(updateConnected()) ); connect( crystalChangeMotor_, SIGNAL(connected(bool)), this, SLOT(updateConnected()) ); connect( crystal1PitchMotor_, SIGNAL(connected(bool)), this, SLOT(updateConnected()) ); connect( crystal1RollMotor_, SIGNAL(connected(bool)), this, SLOT(updateConnected()) ); connect( crystal2PitchMotor_, SIGNAL(connected(bool)), this, SLOT(updateConnected()) ); connect( crystal2RollMotor_, SIGNAL(connected(bool)), this, SLOT(updateConnected()) ); connect( region_, SIGNAL(connected(bool)), this, SLOT(updateConnected()) ); connect( encoderEnergy_, SIGNAL(connected(bool)), this, SLOT(updateConnected()) ); connect( stepEnergy_, SIGNAL(connected(bool)), this, SLOT(updateConnected()) ); // Current settings. updateConnected(); updateMotorSettlingTime(); }
void SGMGratingAngleControl::onControlSetConnectionChanged(bool) { updateConnected(); }
void SGMUndulatorControl::onControlSetConnectionChanged(bool) { updateConnected(); }