// Complete/incremental contents rebuilder; check dirty status if incremental. void qjackctlConnect::updateContents ( bool bClear ) { int iDirtyCount = 0; if (startMutex()) { // Do we do a complete rebuild? if (bClear) { m_pOClientList->clear(); m_pIClientList->clear(); updateIconPixmaps(); } // Add (newer) client:ports and respective connections... if (m_pOClientList->updateClientPorts() > 0) { m_pOClientList->refresh(); iDirtyCount++; } if (m_pIClientList->updateClientPorts() > 0) { m_pIClientList->refresh(); iDirtyCount++; } updateConnections(); endMutex(); } (m_pConnectView->connectorView())->update(); if (!bClear && iDirtyCount > 0) emit connectChanged(); }
void GNEVariableSpeedSignal::updateGeometry() { // Clear shape myShape.clear(); // Set block icon position myBlockIconPosition = myPosition; // Set block icon offset myBlockIconOffset = Position(-0.5, -0.5); // Set block icon rotation, and using their rotation for draw logo setBlockIconRotation(); // Set position myShape.push_back(myPosition); // Add shape of childs (To avoid graphics errors) for (childLanes::iterator i = myChildLanes.begin(); i != myChildLanes.end(); i++) { myShape.append(i->lane->getShape()); } // Update connections updateConnections(); // Refresh element (neccesary to avoid grabbing problems) myViewNet->getNet()->refreshAdditional(this); }
void GraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *event){ QGraphicsItem *activeItem = itemAt(event->scenePos().x(),event->scenePos().y(),transform); if (activeItem != 0 and ((CustomItem*)activeItem)->isClickable()){ QGraphicsItem *selection = itemAt(event->scenePos().x(),event->scenePos().y(),transform); if(((CustomItem*)selection)->getName() == std::string("Dot")){ selectionActive = true; selectedDot = ((Dot*)selection); } } else{ if (event->button() == Qt::LeftButton){ QGraphicsItem *newDot = new Dot(event->scenePos(),dotRadius,Qt::white); addItem(newDot); connectToNearest(((Dot*)newDot)); totalCost = calculateCost(); emit costChanged(totalCost); } else{ QGraphicsItem *newDot = new Dot(event->scenePos(),dotRadius,Qt::red); addItem(newDot); ((Dot*)newDot)->makeCenter(); centersPointers.append(((Dot*)newDot)); updateConnections(); totalCost = calculateCost(); emit costChanged(totalCost); } } update(QRectF(-50,-50,1000,1000)); }
void BaseConnection::updateEncoderAndIMU(const BotPosition& enc, const BotPosition& imu) { updateConnections(); for (auto& proxy : baseProxies) { // We don't care about exceptions, so we disregard the callback. proxy->begin_updateBotPosition(enc, imu); } }
void ComponentGraph::updateGraph(const ComponentDrawOptions &options) { ComponentTypesFile compFile; OovStatus status = compFile.read(); if(status.ok()) { mNodes.clear(); for(auto const &name : compFile.getComponentNames()) { ComponentTypesFile::eCompTypes ct = compFile.getComponentType(name); if(ct != ComponentTypesFile::CT_Unknown) { mNodes.push_back(ComponentNode(name, ComponentNode::CNT_Component, ct)); } } BuildPackages buildPkgs(true); std::vector<Package> packages = buildPkgs.getPackages(); for(auto const &pkg : packages) { mNodes.push_back(ComponentNode(pkg.getPkgName(), ComponentNode::CNT_ExternalPackage)); } updateConnections(compFile, options); } if(status.needReport()) { status.report(ET_Error, "Unable to update component graph"); } }
void ZoneGraph::updateGraph() { if(mDiagramChanged & ZDC_Nodes) { clearGraph(); for(auto const &type : mModel->mTypes) { ModelClassifier const *cls = ModelClassifier::getClass(type.get()); if(cls && cls->getModule() != nullptr) { if(!isFiltered(cls->getModule(), mFilteredModules)) { mNodes.push_back(ZoneNode(type.get())); } } } mDrawOptions.initDrawOptions(mNodes.size() < 500); sortNodes(); } if(mDiagramChanged & ZDC_Connections) { updateConnections(); } mDiagramChanged = ZDC_None; }
PowerLawWidget *PowerLawWidgetManager::addPowerLaw() { auto widget = new PowerLawWidget; m_Parent->layout()->addWidget(widget); m_Widgets.push_back(widget); updateConnections(); return widget; }
void BaseConnection::updatePowerStats(float batteryPercent, float voltage, float regulatedCurrent, float unregulatedCurrent) { updateConnections(); for (auto& proxy : baseProxies) { proxy->begin_updatePowerStats( batteryPercent, voltage, regulatedCurrent, unregulatedCurrent); } }
bool KAccelBase::setAutoUpdate(bool bAuto) { kdDebug(125) << "KAccelBase::setAutoUpdate( " << bAuto << " ): m_bAutoUpdate on entrance = " << m_bAutoUpdate << endl; bool b = m_bAutoUpdate; if(!m_bAutoUpdate && bAuto) updateConnections(); m_bAutoUpdate = bAuto; return b; }
void KoConnectionShape::finishLoadingConnection() { Q_D(KoConnectionShape); if (d->hasCustomPath) { const bool loadingFinished1 = d->connectionPointId1 >= 0 ? d->shape1 != 0 : true; const bool loadingFinished2 = d->connectionPointId2 >= 0 ? d->shape2 != 0 : true; if (loadingFinished1 && loadingFinished2) { QPointF p1, p2; if (d->handleConnected(StartHandle)) { if (d->shape1->hasConnectionPoint(d->connectionPointId1)) { p1 = d->shape1->absoluteTransformation(0).map(d->shape1->connectionPoint(d->connectionPointId1).position); } } else { p1 = d->handles[StartHandle]; } if (d->handleConnected(EndHandle)) { if (d->shape2->hasConnectionPoint(d->connectionPointId2)) { p2 = d->shape2->absoluteTransformation(0).map(d->shape2->connectionPoint(d->connectionPointId2).position); } } else { p2 = d->handles[EndHandle]; } QPointF relativeBegin = m_subpaths.first()->first()->point(); QPointF relativeEnd = m_subpaths.last()->last()->point(); QPointF diffRelative(relativeBegin - relativeEnd); QPointF diffAbsolute(p1 - p2); qreal factorX = diffRelative.x() ? diffAbsolute.x() / diffRelative.x(): 1.0; qreal factorY = diffRelative.y() ? diffAbsolute.y() / diffRelative.y(): 1.0; p1.setX(p1.x() - relativeBegin.x() * factorX); p1.setY(p1.y() - relativeBegin.y() * factorY); p2.setX(p2.x() + (1 - relativeEnd.x()) * factorX); p2.setY(p2.y() + (1 - relativeEnd.y()) * factorY); QRectF targetRect = QRectF(p1, p2).normalized(); // transform the normalized coordinates back to our target rectangle QTransform viewMatrix; viewMatrix.translate(targetRect.x(), targetRect.y()); viewMatrix.scale(targetRect.width(), targetRect.height()); d->map(viewMatrix); // pretend we are during a forced update, so normalize() // will not trigger an updateConnections() call d->forceUpdate = true; normalize(); d->forceUpdate = false; } } else { updateConnections(); } }
bool ProcessorGraph::enableProcessors() { updateConnections(getEditorViewport()->requestSignalChain()); std::cout << "Enabling processors..." << std::endl; bool allClear; if (getNumNodes() < 5) { getUIComponent()->disableCallbacks(); return false; } for (int i = 0; i < getNumNodes(); i++) { Node* node = getNode(i); if (node->nodeId != OUTPUT_NODE_ID) { GenericProcessor* p = (GenericProcessor*) node->getProcessor(); allClear = p->isReady(); if (!allClear) { std::cout << p->getName() << " said it's not OK." << std::endl; // sendActionMessage("Could not initialize acquisition."); getUIComponent()->disableCallbacks(); return false; } } } for (int i = 0; i < getNumNodes(); i++) { Node* node = getNode(i); if (node->nodeId != OUTPUT_NODE_ID) { GenericProcessor* p = (GenericProcessor*) node->getProcessor(); p->enableEditor(); p->enable(); } } getEditorViewport()->signalChainCanBeEdited(false); // sendActionMessage("Acquisition started."); return true; }
void Resistor::setResistance(QString resistance, QString pinSpacing, bool force) { QString tolerance = prop("tolerance"); if (resistance.endsWith(OhmSymbol)) { resistance.chop(1); } switch (this->m_viewIdentifier) { case ViewIdentifierClass::BreadboardView: if (force || resistance.compare(m_ohms) != 0) { QString svg = makeSvg(resistance, m_viewLayerID); //DebugDialog::debug(svg); loadExtraRenderer(svg.toUtf8()); } break; case ViewIdentifierClass::PCBView: if (force || pinSpacing.compare(m_pinSpacing) != 0) { InfoGraphicsView * infoGraphicsView = InfoGraphicsView::getInfoGraphicsView(this); if (infoGraphicsView == NULL) break; if (moduleID().compare(ModuleIDNames::ResistorModuleIDName) != 0) break; QDomElement element = LayerAttributes::getSvgElementLayers(modelPart()->domDocument(), m_viewIdentifier); if (element.isNull()) break; // hack the dom element and call setUpImage FSvgRenderer::removeFromHash(moduleID(), ""); QString filename = PinSpacings.value(pinSpacing, ""); if (filename.isEmpty()) break; element.setAttribute("image", filename); m_changingPinSpacing = true; resetImage(infoGraphicsView); m_changingPinSpacing = false; updateConnections(); } break; default: break; } m_ohms = resistance; m_pinSpacing = pinSpacing; modelPart()->setProp("resistance", resistance); modelPart()->setProp("pin spacing", pinSpacing); modelPart()->setProp("tolerance", tolerance); updateResistances(m_ohms); if (m_partLabel) m_partLabel->displayTextsIf(); }
bool PowerLawWidgetManager::removePowerLaw() { if (m_Widgets.size() > 1) { auto widget = m_Widgets.back(); m_Parent->layout()->removeWidget(widget); m_Widgets.pop_back(); delete widget; updateConnections(); return true; } return false; }
bool GNEAdditionalSet::removeEdgeChild(GNEEdge* edge) { for (childEdges::iterator i = myChildEdges.begin(); i != myChildEdges.end(); i++) { if (i->edge == edge) { myChildEdges.erase(i); updateConnections(); return true; } } // If wasn't found, return false return false; }
bool GNEAdditionalSet::removeLaneChild(GNELane* lane) { for (childLanes::iterator i = myChildLanes.begin(); i != myChildLanes.end(); i++) { if (i->lane == lane) { myChildLanes.erase(i); updateConnections(); return true; } } // If wasn't found, return false return false; }
bool GNEAdditionalSet::removeAdditionalGeometryChild(GNEAdditional* additional) { for (childAdditionals::iterator i = myChildAdditionals.begin(); i != myChildAdditionals.end(); i++) { if ((*i) == additional) { myChildAdditionals.erase(i); updateConnections(); return true; } } // If wasn't found, return false return false; }
bool gProjectCore::open(const QString &path_,const QString &name_) { path=path_; name=name_; QDir dir(path); dir.cd(name); git->init(dir.path()); updateConnections(); return true; }
void MainWindow::rotate(int index, bool toleft) { const Cell::Dirs d = board[index]->dirs(); if((d == Cell::Free) || (d == Cell::None) || isGameOver() || board[index]->isLocked() ) { KNotifyClient::event(winId(), "clicksound"); blink(index); } else { KNotifyClient::event(winId(), "turnsound"); board[index]->rotate(toleft ? -6 : 6); updateConnections(); for(int i = 0; i < 14; i++) { kapp->eventLoop()->processEvents(QEventLoop::ExcludeUserInput); QTimer::singleShot(20, board[index], SLOT(update())); kapp->eventLoop()->processEvents(QEventLoop::ExcludeUserInput | QEventLoop::WaitForMore); board[index]->rotate(toleft ? -6 : 6); } if (updateConnections()) KNotifyClient::event(winId(), "connectsound"); m_clickcount++; QString clicks = i18n("Click: %1"); statusBar()->changeItem(clicks.arg(QString::number(m_clickcount)),1); if (isGameOver()) { KNotifyClient::event(winId(), "winsound"); blink(index); KExtHighscore::Score score(KExtHighscore::Won); score.setScore(m_clickcount); KExtHighscore::submitScore(score, this); } } }
bool GNEAdditionalSet::addEdgeChild(GNEEdge* edge) { for (childEdges::iterator i = myChildEdges.begin(); i != myChildEdges.end(); i++) { if (i->edge == edge) { return false; } } // If wasn't found, insert it edgeChild myEdgeChild; myEdgeChild.edge = edge; myChildEdges.push_back(myEdgeChild); updateConnections(); return true; }
bool GNEAdditionalSet::addLaneChild(GNELane* lane) { for (childLanes::iterator i = myChildLanes.begin(); i != myChildLanes.end(); i++) { if (i->lane == lane) { return false; } } // If wasn't found, insert it laneChild myLaneChild; myLaneChild.lane = lane; myChildLanes.push_back(myLaneChild); updateConnections(); return true; }
void ClassGraph::updateGenes(const ModelData &modelData, DiagramDrawer &nullDrawer) { updateNodeSizes(); updateConnections(modelData); if(mNodes.size() > 1) { mGenes.initialize(*this, getAvgNodeSize()); mGenes.updatePositionsInGraph(*this, mBackgroundTaskStatusListener, *this); } else { // single node just ends up at 0,0 } }
void GraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent * event){ if (selectionActive){ selectedDot->setPos(event->scenePos()); if (selectedDot->isCenter()){ updateConnections(); } else{ removeItem(((QGraphicsItem*)selectedDot->getConnection())); connectToNearest(selectedDot); } totalCost = calculateCost(); emit costChanged(totalCost); update(QRectF(-50,-50,1000,1000)); } }
GraphSize ClassGraph::updateGraph(const ModelData &modelData, bool geneRepositioning) { if(geneRepositioning) { stopAndWaitForCompletion(); addTask(ClassGraphBackgroundItem(&modelData, &mGraphOptions)); } else { updateNodeSizes(); updateConnections(modelData); mGraphListener->doneRepositioning(); } return(getGraphSize()); }
void GraphicsScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event){ QGraphicsItem *selection = itemAt(event->scenePos().x(),event->scenePos().y(),transform); if(((CustomItem*)selection)->getName() == std::string("Dot")){ if(((Dot*)selection)->isCenter()){ removeCenter(((Dot*)selection)); updateConnections(); } else{ removeItem((QGraphicsItem*)((Dot*)selection)->getConnection()); removeItem(selection); } totalCost = calculateCost(); emit costChanged(totalCost); update(QRectF(-50,-50,1000,1000)); } }
void Node::paint(QPainter* painter, const QStyleOptionGraphicsItem* option, QWidget* widget) { Q_UNUSED(option) Q_UNUSED(widget) // Set node colors in subclasses painter->save(); painter->setBrush(mBackground); painter->setPen(Qt::black); painter->drawRoundedRect(boundingRect(), 15, 15); QTextOption textOption; textOption.setAlignment(Qt::AlignCenter); painter->drawText(boundingRect(), mName, textOption); painter->restore(); emit updateConnections(); }
void PowerLawWidgetManager::setPowerLawWidgets(std::vector < PowerLawWidget * > _widgets) { // TODO: ugly code, refactor while (removePowerLaw()); // clear // there's still one left auto widget = m_Widgets.back(); m_Parent->layout()->removeWidget(widget); m_Widgets.pop_back(); delete widget; // add new ones for (auto &widget : _widgets) { m_Parent->layout()->addWidget(widget); m_Widgets.push_back(widget); updateConnections(); } }
void SourcePortItem::editingFinished() { QString text = ((QLineEdit*)lineEditWidget->widget())->text(); for (int i=0;i<scene()->items().count();i++){ QGraphicsItem *it = scene()->items().at(i); if((it->type() == QGraphicsItem::UserType + DestinationPortItemType || it->type() == QGraphicsItem::UserType + SourcePortItemType) && (it != this)){ if(((SourcePortItem*)it)->getItemName() == text){ ((QLineEdit*)lineEditWidget->widget())->setStyleSheet("QLineEdit { background-color: red;}"); ((QLineEdit*)lineEditWidget->widget())->setToolTip(tr("Duplicate Entry")); allowOutputs = false; errorState = true; return; } } } errorState = false; allowOutputs = true; ((QLineEdit*)lineEditWidget->widget())->setStyleSheet("QLineEdit {background-color: white;}"); ((QLineEdit*)lineEditWidget->widget())->setToolTip(""); this->itemName = text; lineEditWidget->setVisible(false); QFontMetrics fontMetric(font); int textWidth = fontMetric.width(itemName); prepareGeometryChange(); mainRect = QRectF(-((2*PORT_TEXT_WIDTH) + textWidth)/2,-15,(2*PORT_TEXT_WIDTH) + textWidth,30); boundingR = QRectF(mainRect); setToolTip(itemName); QRectF geo = lineEditWidget->geometry(); geo.setWidth(textWidth); lineEditWidget->setGeometry(geo); lineEditWidget->setPos(-textWidth/2,-lineEditWidget->geometry().height()/2); emit signalHandler()->modified(); update(); updateConnections(); updateConnectionsFrom(this->itemName); }
void update() { static float t=0; t += 0.02f; frame++; if ( ! loaded ) return; PROFILE; w32::Lock lock( &(critSec) ); for ( size_t i=0; i<numItems(); i++ ) { Item * it = getItem(i); it->updateFrame( t, frame ); } // doAudioDSound(); parseMessages(); if ( ! numItems() ) { return; } updateConnections( matchRadius ); if ( frame % 100 == 0 ) { printf( "items(%d) alive(%d) ", numItems(), tuio.nAlive ); for ( int i=0; i<tuio.nAlive; i++ ) { printf( " %d ", tuio.alive[i] ); } printf( "\n" ); } }
void ComponentGraph::removeNode(const ComponentNode &node, const ComponentDrawOptions &options) { for(size_t i=0; i<mNodes.size(); i++) { if(&node == &mNodes[i]) { mNodes.erase(mNodes.begin() + i); break; } } ComponentTypesFile compFile; OovStatus status = compFile.read(); if(status.needReport()) { status.report(ET_Error, "Unable to read components file to update connections"); } if(status.ok()) { updateConnections(compFile, options); } mModified = true; }
GNEAdditionalSet::GNEAdditionalSet(const std::string& id, GNEViewNet* viewNet, Position pos, SumoXMLTag tag, GUIIcon icon, std::vector<GNEAdditional*> additionalChilds, std::vector<GNEEdge*> edgeChilds, std::vector<GNELane*> laneChilds) : GNEAdditional(id, viewNet, pos, tag, icon) { // Insert additionals for (int i = 0; i < (int)additionalChilds.size(); i++) { addAdditionalChild(additionalChilds.at(i)); } // Insert edges for (int i = 0; i < (int)edgeChilds.size(); i++) { edgeChilds.at(i)->addAdditionalSet(this); edgeChild myEdgeChild; myEdgeChild.edge = edgeChilds.at(i); myChildEdges.push_back(myEdgeChild); } // Insert lanes for (int i = 0; i < (int)laneChilds.size(); i++) { laneChilds.at(i)->addAdditionalSet(this); laneChild myLaneChild; myLaneChild.lane = laneChilds.at(i); myChildLanes.push_back(myLaneChild); } // Update connections updateConnections(); }