selection.cpp
changeset 453 23dba6527a7d
parent 424 d886c77ac0fe
child 460 12e763c3e486
     1.1 --- a/selection.cpp	Mon Jan 29 12:29:13 2007 +0000
     1.2 +++ b/selection.cpp	Wed Apr 11 09:21:15 2007 +0000
     1.3 @@ -1,17 +1,26 @@
     1.4  #include "selection.h"
     1.5  
     1.6 +#include "mainwindow.h"
     1.7 +#include "mapeditor.h"
     1.8 +
     1.9 +
    1.10 +
    1.11 +extern Main *mainWindow;
    1.12  
    1.13  Selection::Selection()
    1.14  {
    1.15 +	color= QColor(255,255,0);
    1.16  }
    1.17  
    1.18  Selection::~Selection()
    1.19  {
    1.20  }
    1.21  
    1.22 -void Selection::setMapCenter(MapCenterObj *mco)
    1.23 +void Selection::setMapEditor (MapEditor *me)
    1.24  {
    1.25 -	mapCenter=mco;
    1.26 +	mapEditor=me;
    1.27 +	mapCenter=me->getMapCenter();
    1.28 +	scene=mapCenter->getScene();
    1.29  }
    1.30  
    1.31  void Selection::copy(const Selection &other)
    1.32 @@ -27,11 +36,44 @@
    1.33  	lastSelectList.clear();
    1.34  }
    1.35  
    1.36 +void Selection::update()
    1.37 +{
    1.38 +	QRectF bbox;
    1.39 +	int w=0;
    1.40 +	for (int i=0; i< selectList.count(); ++i) 
    1.41 +	{
    1.42 +		bbox=selectList.at(i)->getBBox();
    1.43 +		selboxList.at(i)->setRect (
    1.44 +			bbox.x()-w,bbox.y()-w, 
    1.45 +			bbox.width()+2*w, bbox.height()+2*w);
    1.46 +		selboxList.at(i)->setPen (color);	
    1.47 +		selboxList.at(i)->setBrush (color);	
    1.48 +	}	
    1.49 +}
    1.50 +
    1.51 +void Selection::setColor (QColor col)
    1.52 +{
    1.53 +	color=col;
    1.54 +	update();
    1.55 +}
    1.56 +
    1.57 +QColor Selection::getColor ()
    1.58 +{
    1.59 +	return color;
    1.60 +}
    1.61 +
    1.62  bool Selection::select(LinkableMapObj *lmo)	// TODO no multiselections yet
    1.63  {
    1.64  	if (!selectList.isEmpty()) unselect();
    1.65  	selectList.append (lmo);
    1.66 +	QGraphicsRectItem *sb = scene->addRect(
    1.67 +		QRectF(0,0,0,0), 
    1.68 +		QPen(color),
    1.69 +		color);
    1.70 +	sb->setZValue(Z_SELBOX);
    1.71 +	selboxList.append (sb);
    1.72  	lmo->select();
    1.73 +	mainWindow->updateSatellites (mapEditor);	// update branchPropWindow...
    1.74  	return true;
    1.75  }
    1.76  
    1.77 @@ -69,6 +111,9 @@
    1.78  			selectList.at(i)->unselect();
    1.79  		lastSelectList=selectList;
    1.80  		selectList.clear();
    1.81 +		while (!selboxList.isEmpty() )
    1.82 +			delete selboxList.takeFirst();
    1.83 +
    1.84  	}	
    1.85  }
    1.86