Skip to content
Snippets Groups Projects
Select Git revision
  • df0e5efe2374895d91cb194ab56229b04417bdec
  • master default protected
2 results

ComponentItem.cpp

Blame
  • 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);