initial import
[vym] / imageobj.cpp
diff --git a/imageobj.cpp b/imageobj.cpp
new file mode 100644 (file)
index 0000000..769e8db
--- /dev/null
@@ -0,0 +1,62 @@
+#include "imageobj.h"
+#include "mapobj.h"
+
+/////////////////////////////////////////////////////////////////
+// ImageObj
+/////////////////////////////////////////////////////////////////
+ImageObj::ImageObj( QGraphicsScene *scene) : QGraphicsPixmapItem (NULL,scene )
+{
+//     cout << "Const ImageObj (scene)\n";
+
+       setShapeMode (QGraphicsPixmapItem::BoundingRectShape);
+    setZValue(Z_ICON); 
+       mapScene=scene;
+       hide();
+}
+
+ImageObj::~ImageObj()
+{
+ //  cout << "Destr ImageObj\n";
+}
+
+void ImageObj::copy(ImageObj* other)
+{
+       prepareGeometryChange();
+       setVisibility (other->isVisible() );
+       setPixmap (other->QGraphicsPixmapItem::pixmap());       
+       setPos (other->pos());
+}
+
+void ImageObj::setVisibility (bool v)
+{
+       if (v)  
+               show();
+       else
+               hide();
+}
+
+void ImageObj::save(const QString &fn, const char *format)
+{
+       pixmap().save (fn,format,100);
+}
+
+bool ImageObj::load (const QString &fn)
+{
+       QPixmap pixmap;
+    if (pixmap.load (fn)) 
+       {
+               prepareGeometryChange();
+               setPixmap (pixmap);
+               return true;
+       }       
+       return false;
+}
+
+bool ImageObj::load (const QPixmap &pm)
+{
+       prepareGeometryChange();
+       setPixmap (pm);
+       return true;
+}
+
+