BPoint MediaJack::connectionPoint() const { D_METHOD(("MediaJack::connectionPoint()\n")); switch (dynamic_cast<MediaRoutingView *>(view())->getLayout()) { case MediaRoutingView::M_ICON_VIEW: { if (isInput()) { return BPoint(Frame().left - 1.0, Frame().top + Frame().Height() / 2.0); } else if (isOutput()) { return BPoint(Frame().right + 1.0, Frame().top + Frame().Height() / 2.0); } break; } case MediaRoutingView::M_MINI_ICON_VIEW: { if (isInput()) { return BPoint(Frame().left + Frame().Width() / 2.0, Frame().top - 1.0); } else if (isOutput()) { return BPoint(Frame().left + Frame().Width() / 2.0, Frame().bottom + 1.0); } break; } } return BPoint(-1.0, -1.0); }
NodeConnection::NodeConnection(NCID id1, NCID id2) : id(reg.registerId(this)) { NodeConnector *nc1 = NodeConnector::getNC(id1), *nc2 = NodeConnector::getNC(id2); if(nc1 && nc2 && NodeConnector::validConnection(id1, id2)) { fromId = isOutput(nc1->ioType) ? id1 : (isOutput(nc2->ioType) ? id2 : -1); toId = isInput(nc1->ioType) ? id1 : (isInput(nc2->ioType) ? id2 : -1); fromNc = NodeConnector::getNC(fromId); toNc = NodeConnector::getNC(toId); //Connect given nodes if(fromNc) { fromNc->onConnect(toId, this); fromNode = fromNc->getNode(); } if(toNc) { toNc->onConnect(fromId, this); toNode = toNc->getNode(); } } //else invalid connection }
void MediaJack::setPosition( float offset, float leftTopBoundary, float rightBottomBoundary, BRegion *updateRegion) { D_METHOD(("MediaJack::setPosition\n")); switch (dynamic_cast<MediaRoutingView *>(view())->getLayout()) { case MediaRoutingView::M_ICON_VIEW: { if (isInput()) { moveTo(BPoint(leftTopBoundary, offset), updateRegion); } else if (isOutput()) { moveTo(BPoint(rightBottomBoundary - Frame().Width(), offset), updateRegion); } break; } case MediaRoutingView::M_MINI_ICON_VIEW: { if (isInput()) { moveTo(BPoint(offset, leftTopBoundary), updateRegion); } else if (isOutput()) { moveTo(BPoint(offset, rightBottomBoundary - Frame().Height()), updateRegion); } break; } } }
string AstVar::dpiArgType(bool named, bool forReturn) const { if (forReturn) named=false; string arg; if (!basicp()) arg = "UNKNOWN"; if (basicp()->isBitLogic()) { if (widthMin() == 1) { arg = "unsigned char"; if (!forReturn && isOutput()) arg += "*"; } else { if (forReturn) { arg = "svBitVecVal"; } else if (isInOnly()) { arg = "const svBitVecVal*"; } else { arg = "svBitVecVal*"; } } } else { arg = basicp()->keyword().dpiType(); if (basicp()->keyword().isDpiUnsignable() && !basicp()->isSigned()) { arg = "unsigned "+arg; } if (!forReturn && isOutput()) arg += "*"; } if (named) arg += " "+name(); return arg; }
vlak::vlak(int _pvagonu, bool _output) { vagon *pvagon; pvagonu = _pvagonu; output = _output; pkoleje = NULL; mkoleji = 0; if (pvagonu <= 0) { pvagonu = (rand()%N)+1; } // projizdejici vlak (jeho vygenerovani/naplneni a vypsani) for (int i=0; i<pvagonu; i++) { pvagon = vagony.push(new vagon((i+1))); // pvagon = vagony.push(new vagon((i+1), ((rand()%P)+1), ((rand()%(C2-C1))+C1))); if (isOutput()) { printf("G%d[%d][%d] ", pvagon->cislo(), pvagon->pocetPolozek(), pvagon->cenaPolozky()); } } if (isOutput()) { printf("\n\n"); } }
void NodeConnectorView::mouseMoveEvent(QGraphicsSceneMouseEvent* event) { if(mTemporaryLink != nullptr) { mTemporaryLink->updateEndPosition(event->scenePos()); QList<QGraphicsItem*> items = scene()->items (event->scenePos(), Qt::IntersectsItemShape, Qt::DescendingOrder); for(QGraphicsItem* item : items) { // Did we hover on another connector during making connection if(item != this && item->type() == NodeConnectorView::Type) { auto nc = static_cast<NodeConnectorView*>(item); if(nc->isOutput() != isOutput()) { if(mHoveredConnector != nullptr) mHoveredConnector->setHighlight(false); mHoveredConnector = nc; mHoveredConnector->setHighlight(true); return; } } } if(mHoveredConnector != nullptr) { mHoveredConnector->setHighlight(false); mHoveredConnector = nullptr; } } }
int vlak::vylozVsechnyVagony() { if (!vagony.isEmpty()) { fprintf(stderr, "chyba: vlak neni prazdny - je nutne rozdelit vagony na koleje!\n"); return 0; } if (mkoleji == 0) { fprintf(stderr, "chyba: na kolejich nejsou zadne vagony k vylozeni!\n"); return 0; } vagon *pvagon; int ok = 0; if (isOutput()) { printf("----------\n"); } for (int i=0; i<mkoleji; i++) { if (isOutput()) { printf("vykladam vagony z %d.koleje:\n\t", (i+1)); } while (!pkoleje[i].isEmpty()) { pvagon = pkoleje[i].pop(); int v = 0; while (pvagon->vylozitPolozku(output)) { v++; } if (v > 0) { ok++; } if (isOutput()) { printf("X%d[%d]\n\t", pvagon->cislo(), (i+1)); } vagony.push(pvagon); } if (isOutput()) { printf("\n"); } } return ok; }
void generateSingleParent(float gene[], int size) { int inputMax = 1 + 1; // Hash int inputMin = 0; int outputMax = 1; int outputMin = 0; int i = 0; int individualGene; float a, b; for (i = 0; i < size; i+=2) { if(isOutput(i) == 0) { a = randomFloatGenerator(0, 1); b = randomFloatGenerator(0, 1); if(a >= b) { gene[i] = a; gene[i + 1] = b; } else { gene[i] = b; gene[i + 1] = a; } } else { gene[i] = randomIntGenerator(0, 1, NULL); i--; // as i is being incremeted by 2 and this is to offset it } } }
std::string getClipIdentifier() const { if( isOutput() || ! isConnected() ) return getFullName(); else return getConnectedClipFullName(); }
bool NodeConnector::pushData(PushPacket &input) { bool pushed = false; if(isOutput(ioType)) //Only output nodes can push { node->nodeLock.lockWait(); //Push data to each connection for(auto c : connections) { NCID other_nc = c.second->getOppositeNc(id); NodeConnector *nc = getNC(other_nc); if(nc) { c.second->setPushing(true); if(nc->node->pushData(input, other_nc, id)) { pushed = true; c.second->setActive(NCDir::FORWARD); } } } node->nodeLock.unlock(); } return pushed; }
void MediaJack::showContextMenu( BPoint point) { D_METHOD(("MediaJack::showContextMenu()\n")); BPopUpMenu *menu = new BPopUpMenu("MediaJack PopUp", false, false, B_ITEMS_IN_COLUMN); menu->SetFont(be_plain_font); BMenuItem *item; // add the "Get Info" item if (isInput()) { media_input input; getInput(&input); BMessage *message = new BMessage(InfoWindowManager::M_INFO_WINDOW_REQUESTED); message->AddData("input", B_RAW_TYPE, reinterpret_cast<const void *>(&input), sizeof(input)); menu->AddItem(item = new BMenuItem("Get info", message)); } else if (isOutput()) { media_output output; getOutput(&output); BMessage *message = new BMessage(InfoWindowManager::M_INFO_WINDOW_REQUESTED); message->AddData("output", B_RAW_TYPE, reinterpret_cast<const void *>(&output), sizeof(output)); menu->AddItem(item = new BMenuItem("Get info", message)); } menu->SetTargetForItems(view()); view()->ConvertToScreen(&point); point -= BPoint(1.0, 1.0); menu->Go(point, true, true, true); }
std::string getConnectedClipFullName() const { if( isOutput() || !isConnected() || _connectedClip->getFullName().size() == 0 ) { BOOST_THROW_EXCEPTION( exception::Logic() << exception::user( "Input clip " + getFullName() + " is not connected !" ) ); } return _connectedClip->getFullName(); }
void TextureGraphicsItem::_doPaint(QPainter *painter, const QStyleOptionGraphicsItem *option) { Q_UNUSED(option); // Perform the actual mapping (done by subclasses). if (isOutput()) _doDrawOutput(painter); else _doDrawInput(painter); }
int vlak::superTypekNaNadraziRozdelujeVagonyNaKolejePodleCeny(double *pcena, int max) { if (pcena == NULL || max == 0) { return 0; } if (mkoleji != 0) { fprintf(stderr, "varovani: koleje nejsou prazdne! - natvrdo je rusim!\n"); delete []pkoleje; } mkoleji = max; pkoleje = new zasobnik[mkoleji]; vagon *pvagon; int ok = 0; // rozdelovani vagonu vlaku for (int i=0; i<pvagonu; i++) { pvagon = vagony.pop(); // pcena[1..k] for (int k=0; k<mkoleji; k++) { if (pvagon->cenaNakladu() <= pcena[k]) { pkoleje[k].push(pvagon); ok++; if (isOutput()) { printf("Z%d[%d] ", pvagon->cislo(), (k+1)); } break; } } } if (isOutput()) { printf("\n\n"); } return ok; }
string AstVar::verilogKwd() const { if (isInout()) { return "inout"; } else if (isInput()) { return "input"; } else if (isOutput()) { return "output"; } else if (isTristate()) { return "tri"; } else if (varType()==AstVarType::WIRE) { return "wire"; } else { return dtypep()->name(); } }
void TriangleTextureGraphicsItem::_doDrawOutput(QPainter* painter) { Q_UNUSED(painter); if (isOutput()) { glBegin(GL_TRIANGLES); { for (int i=0; i<_inputShape->nVertices(); i++) { Util::setGlTexPoint(*_texture, _inputShape->getVertex(i), mapFromScene(_shape->getVertex(i))); } } glEnd(); } }
status_t MediaJack::getOutput( media_output *output) const { D_METHOD(("MediaJack::getOutput()\n")); if (isOutput()) { output->node = m_node; output->source = m_source; output->destination = m_destination; output->format = m_format; strlcpy(output->name, m_label.String(), B_MEDIA_NAME_LENGTH); return B_OK; } return B_ERROR; }
bool ScriptNode::makeDatum(std::string n, PyTypeObject* type, std::string value, bool output) { for (auto a : script.active) if (a->name == n) return false; // If there's an existing datum and it's of the wrong type, delete it. auto d = getDatum(n); if (d != NULL && (d->type != type)) { datums.remove_if([&](const std::unique_ptr<Datum>& d_) { return d_.get() == d; }); d = NULL; } if (d == NULL) { d = new Datum(n, value, type, this); assert(d->isValid()); } else { // Move the existing datum to the end of the list // (so that ordering matches ordering in the script) for (auto itr = datums.begin(); itr != datums.end(); ++itr) if (itr->get() == d) { datums.splice(datums.end(), datums, itr); break; } // If the datum is an output, update its expression if (output) d->setText(value); // Otherwise, erase the output sigil by setting the text else if (d->isOutput()) d->setText(value); } script.active.insert(d); // Inject this variable into the script's namespace script.inject(n.c_str(), d->currentValue()); saveLookup(n, &script); return true; }
void DocumentDatasLinksList::updateLinks(const graphics::DrawColors& colors) { LinksList::updateLinks(colors); auto pen = colors.penColor; int inputIndex = 0, outputIndex = 0; for (const auto& gdr : m_documentDatasView.dataRects()) { const auto data = gdr.first; const auto& dataRect = gdr.second; if (data->isInput()) { auto d1 = dataRect.center(); for (const auto& output : data->getOutputs()) { if (BaseData* data = dynamic_cast<BaseData*>(output)) { Rect dataRect; if (!getDataRect(data, dataRect)) continue; auto d2 = dataRect.center(); Point w = { (d2.x - d1.x) / 2, 0 }; m_linksDrawList->addBezierCurve(d1, d1 + w, d2 - w, d2, pen, 1); } } } if (data->isOutput()) { auto d2 = dataRect.center(); for (const auto& input : data->getInputs()) { if (BaseData* data = dynamic_cast<BaseData*>(input)) { Rect dataRect; if (!getDataRect(data, dataRect)) continue; auto d1 = dataRect.center(); Point w = { (d2.x - d1.x) / 2, 0 }; m_linksDrawList->addBezierCurve(d1, d1 + w, d2 - w, d2, pen, 1); } } } } }
NodeConnection::NodeConnection(NCID id) : id(reg.registerId(this)) { NodeConnector *nc = NodeConnector::getNC(id); if(nc) { fromId = isOutput(nc->ioType) ? id : -1; toId = isInput(nc->ioType) ? id : -1; fromNc = NodeConnector::getNC(fromId); toNc = NodeConnector::getNC(toId); fromNode = fromNc ? fromNc->getNode() : nullptr; toNode = toNc ? toNc->getNode() : nullptr; } //Else invalid id }
void ShapeGraphicsItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) { Q_UNUSED(widget); // Sync depth of figure with that of mapping (for layered output). if (isOutput()) setZValue(_mapping->getDepth()); // Paint if visible. if (isMappingVisible()) { // Paint whatever needs to be painted. _prePaint(painter, option); _doPaint(painter, option); _postPaint(painter, option); } }
void FilterPortWidget::mouseMoveEvent(QMouseEvent *ev) { if(!mStartPos.isNull() && (ev->pos() - mStartPos).manhattanLength() > QApplication::startDragDistance()) { if(mPressedButton == Qt::LeftButton) startDrag(); else if(mPressedButton == Qt::RightButton) { if(isOutput()) emit startConnect(this); else emit startDisconnect(this); } mStartPos = QPoint(); } else ev->ignore(); }
NodeConnectorView* NodeConnectorView::canDrop(const QPointF& scenePos) { QList<QGraphicsItem*> items = scene()->items(scenePos, Qt::IntersectsItemShape, Qt::DescendingOrder); foreach(QGraphicsItem* item, items) { // Did we dropped on another connector if(item->type() == NodeConnectorView::Type && item != this) { // Ensure we connect from input to output or the opposite NodeConnectorView* citem = static_cast<NodeConnectorView*>(item); if(citem->isOutput() != isOutput()) { return citem; } } } return nullptr; }
void AstVar::dump(ostream& str) { this->AstNode::dump(str); if (isSc()) str<<" [SC]"; if (isPrimaryIO()) str<<(isInout()?" [PIO]":(isInput()?" [PI]":" [PO]")); else { if (isInout()) str<<" [IO]"; else if (isInput()) str<<" [I]"; else if (isOutput()) str<<" [O]"; } if (isConst()) str<<" [CONST]"; if (isUsedClock()) str<<" [CLK]"; if (isSigPublic()) str<<" [P]"; if (isUsedLoopIdx()) str<<" [LOOP]"; if (attrClockEn()) str<<" [aCLKEN]"; if (attrIsolateAssign()) str<<" [aISO]"; if (attrFileDescr()) str<<" [aFD]"; if (isFuncReturn()) str<<" [FUNCRTN]"; else if (isFuncLocal()) str<<" [FUNC]"; str<<" "<<varType(); }
void MeshTextureGraphicsItem::_doDrawOutput(QPainter* painter) { Q_UNUSED(painter); if (isOutput()) { std::tr1::shared_ptr<Mesh> outputMesh = std::tr1::static_pointer_cast<Mesh>(_shape); std::tr1::shared_ptr<Mesh> inputMesh = std::tr1::static_pointer_cast<Mesh>(_inputShape); QVector<QVector<Quad> > outputQuads = outputMesh->getQuads2d(); QVector<QVector<Quad> > inputQuads = inputMesh->getQuads2d(); for (int x = 0; x < outputMesh->nHorizontalQuads(); x++) { for (int y = 0; y < outputMesh->nVerticalQuads(); y++) { QSizeF size = mapFromScene(outputQuads[x][y].toPolygon()).boundingRect().size(); float area = size.width() * size.height(); _drawQuad(*_texture, inputQuads[x][y], outputQuads[x][y], area); } } } }
void FilterPortWidget::startDrag() { if(!draggable()) return; QDrag *drag = new QDrag(this); QMimeData *mimeData = new QMimeData; QStringList data; if(isOutput()) data << "output"; else data << "input"; data << QByteArray::number(filterId()); data << portName().toLocal8Bit(); data << QByteArray::number(portType()); mimeData->setData("application/x-olvis-port", data.join("#").toLocal8Bit()); drag->setPixmap(grab()); drag->setHotSpot(QPoint(width()/2, height()/2)); drag->setMimeData(mimeData); drag->exec(Qt::CopyAction); }
void NodeConnectorView::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) { if(mTemporaryLink != nullptr) { NodeConnectorView* itemColliding = canDrop(event->scenePos()); if(itemColliding != nullptr) { if(isOutput()) emit draggingLinkDropped(socketView(), itemColliding->socketView()); else emit draggingLinkDropped(itemColliding->socketView(), socketView()); } mHoveredConnector = nullptr; // From Qt: It is more efficient to remove the item from the QGraphicsScene before destroying the item. scene()->removeItem(mTemporaryLink); delete mTemporaryLink; mTemporaryLink = nullptr; } }
void TextureGraphicsItem::_prePaint(QPainter* painter, const QStyleOptionGraphicsItem *option) { Q_UNUSED(option); painter->beginNativePainting(); // Only works for similar shapes. // TODO:remettre //Q_ASSERT( _inputShape->nVertices() == outputShape->nVertices()); // Project source texture and sent it to destination. _texture->update(); // Allow alpha blending. glEnable (GL_BLEND); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Get texture. glEnable (GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, _texture->getTextureId()); // Copy bits to texture iff necessary. _texture->lockMutex(); if (_texture->bitsHaveChanged()) { glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _texture->getWidth(), _texture->getHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, _texture->getBits()); } _texture->unlockMutex(); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); // Set texture color (apply opacity). glColor4f(1.0f, 1.0f, 1.0f, isOutput() ? _mapping->getOpacity() : _mapping->getPaint()->getOpacity()); }
/// @warning HACK ! to keep the connection /// @todo remove this !!!! void setConnectedClip( const ClipImage& other ) { if( isOutput() ) { BOOST_THROW_EXCEPTION( exception::Logic() << exception::user( "You can't connect an output Clip !" ) ); } if( !other.isOutput() ) { BOOST_THROW_EXCEPTION( exception::Logic() << exception::user( "You can't connect to an input Clip !" ) ); } //TUTTLE_TLOG( TUTTLE_TRACE, "== setConnectedClip: " ); //TUTTLE_TLOG_VAR( TUTTLE_TRACE, getFullName() ); //TUTTLE_TLOG_VAR( TUTTLE_TRACE, other.getFullName() ); _connectedClip = &other; setConnected(); getEditableProperties().setStringProperty( "TuttleFullName", getFullName() ); getEditableProperties().setStringProperty( "TuttleIdentifier", getClipIdentifier() ); }
string AstVar::vlArgType(bool named, bool forReturn, bool forFunc) const { if (forReturn) named=false; if (forReturn) v3fatalSrc("verilator internal data is never passed as return, but as first argument"); string arg; if (isWide() && isInOnly()) arg += "const "; AstBasicDType* bdtypep = basicp(); bool strtype = bdtypep && bdtypep->keyword()==AstBasicDTypeKwd::STRING; if (bdtypep && bdtypep->keyword()==AstBasicDTypeKwd::CHARPTR) { arg += "const char*"; } else if (bdtypep && bdtypep->keyword()==AstBasicDTypeKwd::SCOPEPTR) { arg += "const VerilatedScope*"; } else if (bdtypep && bdtypep->keyword()==AstBasicDTypeKwd::DOUBLE) { arg += "double"; } else if (bdtypep && bdtypep->keyword()==AstBasicDTypeKwd::FLOAT) { arg += "float"; } else if (strtype) { if (isInOnly()) arg += "const "; arg += "string"; } else if (widthMin() <= 8) { arg += "CData"; } else if (widthMin() <= 16) { arg += "SData"; } else if (widthMin() <= VL_WORDSIZE) { arg += "IData"; } else if (isQuad()) { arg += "QData"; } else if (isWide()) { arg += "WData"; // []'s added later } if (isWide() && !strtype) { arg += " (& "+name(); arg += ")["+cvtToStr(widthWords())+"]"; } else { if (forFunc && (isOutput() || (strtype && isInput()))) arg += "&"; if (named) arg += " "+name(); } return arg; }