imageobj.cpp
author insilmaril
Mon Feb 12 09:28:46 2007 +0000 (2007-02-12)
changeset 425 7014be3ac7d0
parent 408 c2a05fa925a1
child 426 e0a3449f4458
permissions -rw-r--r--
1.8.66 Various fixes
     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 	setVisibility (other->isVisible() );
    25 	setPixmap (other->QGraphicsPixmapItem::pixmap());	
    26 	setPos (other->pos());
    27 }
    28 
    29 void ImageObj::setVisibility (bool v)
    30 {
    31 	if (v)	
    32 		show();
    33 	else
    34 		hide();
    35 }
    36 
    37 void ImageObj::save(const QString &fn, const char *format)
    38 {
    39 	pixmap().save (fn,format,100);
    40 }
    41 
    42 bool ImageObj::load (const QString &fn)
    43 {
    44 	QPixmap pixmap;
    45     if (pixmap.load (fn)) 
    46 	{
    47 		setPixmap (pixmap);
    48 		return true;
    49 	}	
    50 	return false;
    51 }
    52 
    53 bool ImageObj::load (const QPixmap &pm)
    54 {
    55 	setPixmap (pm);
    56 	return true;
    57 }
    58 
    59