/** * Return the row count. the number of elements in the component. for * ObjComponent row count will be 0. */ int InstrumentTreeModel::rowCount(const QModelIndex &parent) const { // std::cout<<"rowCount +++++++++ row"<<parent.row()<<" column //"<<parent.column()<<" is valid "<<parent.isValid()<<'\n'; try { if (!parent.isValid()) // Root node row count is one. { return 1; // boost::dynamic_pointer_cast<ICompAssembly>(m_instrument)->nelements(); } else { auto instr = m_instrumentActor->getInstrument(); if (instr->getComponentID() == static_cast<Mantid::Geometry::ComponentID>( parent.internalPointer())) { return instr->nelements(); } boost::shared_ptr<const IComponent> comp = instr->getComponentByID(static_cast<Mantid::Geometry::ComponentID>( parent .internalPointer())); // static_cast<IComponent*>(parent.internalPointer()); boost::shared_ptr<const ICompAssembly> assembly = boost::dynamic_pointer_cast<const ICompAssembly>(comp); if (assembly) { return assembly->nelements(); } boost::shared_ptr<const IObjComponent> objcomp = boost::dynamic_pointer_cast<const IObjComponent>(comp); if (objcomp) return 0; } } catch (...) { // std::cout<<"Exception: in rowCount"<<'\n'; } return 0; }
shared_ptr<IExtensionsComponent> ObjectsSection::getComponent(shared_ptr<Portal> portal) const { ExtensionsComponentID component = getComponentID(portal); if(component != ExtensionsComponentID::EMPTY) return ExtensionsSystem::instance()->getComponent(component); else return nullptr; }
void ComponentManager::broadcastMessage(const InterfaceTypeID& iid, const MessageBase& msg) { //for (int o = 0; o < MAX_CONTAINERS; o++) for (std::set<unsigned int>::const_iterator i = m_activeContainers.begin(), e = m_activeContainers.end(); i != e; ++i) { ObjectID oid(*i); const ComponentID& cid = getComponentID(iid, oid); if (cid.isValid()) { ComponentBase* c = getComponent(cid); if (c) c->handleMessage(msg); } } }
ValueTree DrawableRectangle::createValueTree (ComponentBuilder::ImageProvider* imageProvider) const { ValueTree tree (valueTreeType); ValueTreeWrapper v (tree); v.setID (getComponentID()); writeTo (v, imageProvider, nullptr); v.setRectangle (bounds, nullptr); v.setCornerSize (cornerSize, nullptr); return tree; }
ValueTree DrawableText::createValueTree (ComponentBuilder::ImageProvider*) const { ValueTree tree (valueTreeType); ValueTreeWrapper v (tree); v.setID (getComponentID()); v.setText (text, nullptr); v.setFont (font, nullptr); v.setJustification (justification, nullptr); v.setColour (colour, nullptr); v.setBoundingBox (bounds, nullptr); v.setFontSizeControlPoint (fontSizeControlPoint, nullptr); return tree; }
MessageResult ComponentManager::sendMessage(const InterfaceTypeID& iid, const ObjectID& oid, MessageBase& msg) { const ComponentID& cid = getComponentID(iid, oid); if (cid.isValid()) { ComponentBase* component = getComponent(cid); if (component) { // write on envelope // this changes msg! msg.Addressee = oid; msg.Sender = ObjectID(); return component->handleMessage(msg); } std::cerr << "Component invalid in container " << oid.getIndex() << std::endl; return MR_ERROR; // failed to deliver } return MR_ERROR; // failed to deliver }
/** * Find a parameter by name, recursively going up the component tree * to higher parents. * @param comp :: The component to start the search with * @param name :: Parameter name * @param type :: An optional type string * @returns the first matching parameter. */ Parameter_sptr ParameterMap::getRecursive(const IComponent *comp, const char *name, const char *type) const { Parameter_sptr result = this->get(comp->getComponentID(), name, type); if (result) return result; auto parent = comp->getParent(); while (parent) { result = this->get(parent->getComponentID(), name, type); if (result) return result; parent = parent->getParent(); } return result; }
juced_ImageComponent::juced_ImageComponent() : ImageComponent () { setName("ImageComponent"); setProperty(Attributes::objectType, Modules::ImageComponent.toString()); setProperty(Attributes::height, getHeight()); setProperty(Attributes::width, getWidth()); setProperty(Attributes::name, getName()); ++_numObjects; setProperty(Attributes::varName, getName() + String(_numObjects)); setProperty(Attributes::image, ""); setProperty(Attributes::className, "ImageComponent"); setProperty(Attributes::toolName, "juced_ImageComponent"); setProperty(Attributes::declareExtended, false); setComponentID(Uuid().toString()); setProperty(Attributes::ID, getComponentID()); }
void ComponentManager::initAllComponents(Context& ctx) { for (int i = 0; i < MAX_INTERFACES; i++) { InterfaceTypeID iid = i; for (std::set<unsigned int>::const_iterator i = m_activeContainers.begin(), e = m_activeContainers.end(); i != e; ++i) { //for (int o = 0; o < MAX_CONTAINERS; o++) { ObjectID oid(*i); const ComponentID& cid = getComponentID(iid, oid); if (cid.isValid()) { ComponentBase* c = getComponent(cid); if (c) c->init(ctx); } //} } } }
ValueTree DrawableImage::createValueTree (ComponentBuilder::ImageProvider* imageProvider) const { ValueTree tree (valueTreeType); ValueTreeWrapper v (tree); v.setID (getComponentID()); v.setOpacity (opacity, nullptr); v.setOverlayColour (overlayColour, nullptr); v.setBoundingBox (bounds, nullptr); if (image.isValid()) { jassert (imageProvider != nullptr); // if you're using images, you need to provide something that can load and save them! if (imageProvider != nullptr) v.setImageIdentifier (imageProvider->getIdentifierForImage (image), nullptr); } return tree; }
juced_ComboBox::juced_ComboBox() : ComboBox () { setText("Combo Box", false); setName("Box"); setProperty(Attributes::objectType, Modules::ComboBox.toString()); setProperty(Attributes::text, getText()); //setProperty(Attributes::font, getFont().toString()); setProperty(Attributes::backgroundColour, findColour(backgroundColourId).toDisplayString(true)); setProperty(Attributes::textColour, findColour(textColourId).toDisplayString(true)); setProperty(Attributes::height, getHeight()); setProperty(Attributes::width, getWidth()); setProperty(Attributes::itemList, ""); setProperty(Attributes::name, getName()); ++_numObjects; setProperty(Attributes::varName, getName() + String(_numObjects)); setProperty(Attributes::className, "ComboBox"); setProperty(Attributes::toolName, "juced_ComboBox"); setProperty(Attributes::declareExtended, false); setComponentID(Uuid().toString()); setProperty(Attributes::ID, getComponentID()); }
juced_BubbleMessageComponent::juced_BubbleMessageComponent() : BubbleMessageComponent () { //setText("Text label", false); //setName("Label"); setProperty(Attributes::objectType, Modules::BubbleComponent.toString()); //setProperty(Attributes::text, getText()); //setProperty(Attributes::font, getFont().toString()); setProperty(Attributes::backgroundColour, findColour(backgroundColourId).toDisplayString(true)); //setProperty(Attributes::textColour, findColour(textColourId).toDisplayString(true)); //setProperty(Attributes::showEditor, false); //setProperty(Attributes::editable, false); setProperty(Attributes::height, getHeight()); setProperty(Attributes::width, getWidth()); setProperty(Attributes::name, getName()); ++_numObjects; setProperty(Attributes::varName, getName() + String(_numObjects)); setProperty(Attributes::className, "BubbleMessageComponent"); setProperty(Attributes::toolName, "juced_BubbleMessageComponent"); setProperty(Attributes::declareExtended, false); setComponentID(Uuid().toString()); setProperty(Attributes::ID, getComponentID()); }
ValueTree DrawableComposite::createValueTree (ComponentBuilder::ImageProvider* imageProvider) const { ValueTree tree (valueTreeType); ValueTreeWrapper v (tree); v.setID (getComponentID()); v.setBoundingBox (bounds, nullptr); ValueTree childList (v.getChildListCreating (nullptr)); for (int i = 0; i < getNumChildComponents(); ++i) { const Drawable* const d = dynamic_cast <const Drawable*> (getChildComponent(i)); jassert (d != nullptr); // You can't save a mix of Drawables and normal components! childList.addChild (d->createValueTree (imageProvider), -1, nullptr); } v.getMarkerListCreating (true, nullptr).readFrom (markersX, nullptr); v.getMarkerListCreating (false, nullptr).readFrom (markersY, nullptr); return tree; }
/** * Returns the ModelIndex at a give row and column and the parent. */ QModelIndex InstrumentTreeModel::index(int row, int column, const QModelIndex &parent) const { // std::cout<<"Index +++++++++ row"<<row<<" column "<<column<<" is valid //"<<parent.isValid()<<'\n'; try { boost::shared_ptr<const ICompAssembly> parentItem; auto instr = m_instrumentActor->getInstrument(); if (!parent.isValid()) // invalid parent, has to be the root node i.e // instrument return createIndex(row, column, instr->getComponentID()); boost::shared_ptr<const IComponent> comp = instr->getComponentByID( static_cast<Mantid::Geometry::ComponentID>(parent.internalPointer())); parentItem = boost::dynamic_pointer_cast<const ICompAssembly>(comp); if (!parentItem) { boost::shared_ptr<const IObjComponent> objcomp = boost::dynamic_pointer_cast<const IObjComponent>(comp); if (objcomp) return QModelIndex(); // Not an instrument so check for Component Assembly parentItem = boost::dynamic_pointer_cast<const ICompAssembly>(instr); } // If component assembly pick the Component at the row index. if row index // is higher than number // of components in assembly return empty model index if (parentItem->nelements() < row) { return QModelIndex(); } else { return createIndex(row, column, (void *)((*parentItem)[row]->getComponentID())); } } catch (...) { std::cout << "InstrumentTreeModel::index(" << row << "," << column << ") threw an exception.\n"; } return QModelIndex(); }
bool JausAddress::isLocalComponent(JausAddress address) { return (isLocalNode(address) && (getComponentID() == address.getComponentID())); }
bool JausAddress::isLocalComponent(jUnsignedShortInteger sID, jUnsignedByte nID, jUnsignedByte cID) { return (isLocalNode(sID, nID) && (getComponentID() == cID)); }
void InterpolationSpacePreset::mouseUp (const MouseEvent& e) { if (! e.mouseWasClicked()) { endBounds = getBounds(); if(dragging && startBounds != endBounds) { audioEngine.getDoc().beginTransaction(); audioEngine.getDoc().perform(new MovePresetAction(dynamic_cast<PMixInterpolationSpaceLayout*>(getParentComponent()), getComponentID(), startBounds, endBounds), TRANS("change preset bounds")); } } dragging = false; }