Select Git revision
ComponentItem.cpp
-
Oliver Bock authored
* Items are now in defined z-order: link (-1) -> component (0) -> node (1) * Ensures that nodes are on top of things * Makes sure itemAt() works properly on mouse release * Code cleanup: removed superfluous events and redundant code git-svn-id: https://svn.origo.ethz.ch/fidelity@27 53d1999f-d1a8-4366-aa61-588fded17473
Oliver Bock authored* Items are now in defined z-order: link (-1) -> component (0) -> node (1) * Ensures that nodes are on top of things * Makes sure itemAt() works properly on mouse release * Code cleanup: removed superfluous events and redundant code git-svn-id: https://svn.origo.ethz.ch/fidelity@27 53d1999f-d1a8-4366-aa61-588fded17473
ComponentItem.cpp 10.33 KiB
/*************************************************************************
* Copyright (C) 2007 by Oliver Bock *
* bock@tfh-berlin.de *
* *
* This file is part of Fidelity. *
* *
* Fidelity is free software: you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published *
* by the Free Software Foundation, version 3 of the License. *
* *
* Fidelity is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License *
* along with Fidelity. If not, see <http://www.gnu.org/licenses/>. *
* *
*************************************************************************/
#include "ComponentItem.h"
// Constructors/Destructors
Fidelity::GUI::ComponentItem::ComponentItem(QPointer<IComponent> component)
{
// Initialisations
m_NodeItemList = new QList<QPointer<ANodeItem> >();
m_LinkItemList = new QList<QPointer<ComponentLinkItem> >();
m_ParameterModel = new QStandardItemModel();
m_ParameterModel->setHorizontalHeaderLabels(QStringList()
<< "Identifier" << "Parameter" << "Value" << "Unit" << "Type" << "Description");
// Configure basics
m_RotationAngle = 0;
unsetCursor();
setFlag(QGraphicsItem::ItemIsMovable);
setFlag(QGraphicsItem::ItemIsSelectable);
setAcceptsHoverEvents(true);
// Components are drawn on the default z-plane
setZValue(0);
if(component!=NULL) {
m_Component = component;
// Set SVG image (max. 48px per side!)
setSharedRenderer(component->Icon());
// Configure nodes
NodeTable* beamNodes = component->BeamNodeTable();
NodeTable* controlNodes = component->ControlNodeTable();
NodeTable::const_iterator itNodes = beamNodes->constBegin();
while (itNodes != beamNodes->constEnd()) {
// DON'T delete this item. Its parent will care for it...
BeamNodeItem* nodeItem = new BeamNodeItem(itNodes.value(), this);
nodeItem->setToolTip("<b>Beam Node</b><hr>" \
"Name: "+itNodes.value()->Label()+"<br>"
"Description: "+itNodes.value()->Description());
m_NodeItemList->append(nodeItem);
++itNodes;
}
itNodes = controlNodes->constBegin();
while (itNodes != controlNodes->constEnd()) {
// DON'T delete this item. Its parent will care for it...
ControlNodeItem* nodeItem = new ControlNodeItem(itNodes.value(), this);