imageobj.cpp
author insilmaril
Tue, 10 Apr 2007 13:22:55 +0000
changeset 449 5378ed53ec92
parent 426 e0a3449f4458
permissions -rw-r--r--
1.8.71 Basic support for macros
     1 #include "imageobj.h"
     2 #include "mapobj.h"
     3 
     4 /////////////////////////////////////////////////////////////////
     5 // ImageObj
     6 /////////////////////////////////////////////////////////////////
     7 ImageObj::ImageObj( QGraphicsScene *scene) : QGraphicsPixmapItem (NULL,scene )
     8 {
     9 //	cout << "Const ImageObj (scene)\n";
    10 
    11 	setShapeMode (QGraphicsPixmapItem::BoundingRectShape);
    12     setZValue(Z_ICON);	
    13 	mapScene=scene;
    14 	hide();
    15 }
    16 
    17 ImageObj::~ImageObj()
    18 {
    19  //  cout << "Destr ImageObj\n";
    20 }
    21 
    22 void ImageObj::copy(ImageObj* other)
    23 {
    24 	prepareGeometryChange();
    25 	setVisibility (other->isVisible() );
    26 	setPixmap (other->QGraphicsPixmapItem::pixmap());	
    27 	setPos (other->pos());
    28 }
    29 
    30 void ImageObj::setVisibility (bool v)
    31 {
    32 	if (v)	
    33 		show();
    34 	else
    35 		hide();
    36 }
    37 
    38 void ImageObj::save(const QString &fn, const char *format)
    39 {
    40 	pixmap().save (fn,format,100);
    41 }
    42 
    43 bool ImageObj::load (const QString &fn)
    44 {
    45 	QPixmap pixmap;
    46     if (pixmap.load (fn)) 
    47 	{
    48 		prepareGeometryChange();
    49 		setPixmap (pixmap);
    50 		return true;
    51 	}	
    52 	return false;
    53 }
    54 
    55 bool ImageObj::load (const QPixmap &pm)
    56 {
    57 	prepareGeometryChange();
    58 	setPixmap (pm);
    59 	return true;
    60 }
    61 
    62