Commits

Anonymous committed a9b7129

removed libgd; added AGG

Comments (0)

Files changed (17)

 FIND_PACKAGE (ossim REQUIRED)
 FIND_PACKAGE (GEOS REQUIRED)
 FIND_PACKAGE (GDAL REQUIRED)
-FIND_PACKAGE (GD REQUIRED)
 #find_library(PROJ4_LIBRARY NAMES proj proj4)
 
-
+#find_Agg
 
 INCLUDE_DIRECTORIES (${CMAKE_CURRENT_SOURCE_DIR})
 INCLUDE_DIRECTORIES (${GDAL_INCLUDE_DIR})
 INCLUDE_DIRECTORIES (${GEOS_INCLUDE_DIR})
 INCLUDE_DIRECTORIES (${OSSIM_INCLUDE_DIR})
-INCLUDE_DIRECTORIES (${GD_INCLUDE_DIR})
+INCLUDE_DIRECTORIES ("/usr/include/agg2")
 
 
 
 ADD_LIBRARY (ossimVector SHARED
 ossimVector.cpp
-ossimGdVectorSource.cpp
+ossimAggVectorSource.cpp
 ossimOgrVectorHandler.cpp
 ossimVectorFeature.cpp
 ossimVectorHandler.cpp
+agg_embedded_raster_fonts.cpp
 ossimVectorSource.cpp)
 
 # Link the executable to the OssimVector library.
-TARGET_LINK_LIBRARIES (ossimVector ${GDAL_LIBRARY} ${GEOS_LIBRARY} ${OSSIM_LIBRARIES} ${GD_LIBRARIES}) 
+TARGET_LINK_LIBRARIES (ossimVector ${GDAL_LIBRARY} ${GEOS_LIBRARY} ${OSSIM_LIBRARIES} -lagg) 
 
 ADD_EXECUTABLE(ossimVector_cl main.cpp)
-TARGET_LINK_LIBRARIES(ossimVector_cl ossimVector)
+TARGET_LINK_LIBRARIES(ossimVector_cl ossimVector )
 

Makefile.simple

- 
-GD_LIB=  -lgd -L/usr/lib -lgd -lproj -L/usr/local/lib -lgdal1.8.0 -lossim -L. -lossimVector 
-GD=       -I/usr/include/gdal -DUSE_OGR -DUSE_PROJ
-  
-
-CXX=	g++
-AR= ar rc
-RANLIB= ranlib
-
-
-CFLAGS= -O2  -w -g $(GD) 
-
-
-LDFLAGS=  $(GD_LIB)
-
-
-
-RM= /bin/rm -f
-
-OBJS= ossimVectorLabel.o ossimVectorHandler.o ossimOgrVectorHandler.o ossimVectorSource.o ossimGdVectorSource.o ossimVectorStyle.o ossimVectorFeature.o
-
-
-.cpp.o:
-	$(CXX) -c $(CFLAGS) $< -o $@
-
-all: libossimVector.a ossimVector 
-
-
-lib: libossimVector.a
-libossimVector: libossimVector.a
-libossimVector.a: $(OBJS)
-	$(AR) libossimVector.a $(OBJS)
-	$(RANLIB) libossimVector.a
-
-ossimVector: libossimVector.a  main.o
-	$(CXX) $(CFLAGS) main.o $(LDFLAGS) $(STATIC_LIBS) -o ossimVector
-
-clean:	$(MAKE_CLEAN) 
-	rm -f libossimVector.a *.o ossimVector shp
-

UI/Makefile

-#############################################################################
-# Makefile for building: ossimVectorQt
-# Generated by qmake (2.01a) (Qt 4.7.4) on: Fri Mar 9 22:01:51 2012
-# Project:  ossimVect.pro
-# Template: app
-# Command: /usr/bin/qmake -o Makefile ossimVect.pro
-#############################################################################
-
-####### Compiler, tools and options
-
-CC            = gcc
-CXX           = g++
-DEFINES       = -DQT_WEBKIT -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -DQT_SHARED
-CFLAGS        = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
-CXXFLAGS      = -pipe -O2 -Wall -W -D_REENTRANT $(DEFINES)
-INCPATH       = -I/usr/share/qt4/mkspecs/linux-g++ -I. -I/usr/include/qt4/QtCore -I/usr/include/qt4/QtGui -I/usr/include/qt4 -I.. -I.
-LINK          = g++
-LFLAGS        = -Wl,-O1
-LIBS          = $(SUBLIBS)  -L/usr/lib/i386-linux-gnu -lgd -L.. -l ossimVector -lQtGui -lQtCore -lpthread 
-AR            = ar cqs
-RANLIB        = 
-QMAKE         = /usr/bin/qmake
-TAR           = tar -cf
-COMPRESS      = gzip -9f
-COPY          = cp -f
-SED           = sed
-COPY_FILE     = $(COPY)
-COPY_DIR      = $(COPY) -r
-STRIP         = strip
-INSTALL_FILE  = install -m 644 -p
-INSTALL_DIR   = $(COPY_DIR)
-INSTALL_PROGRAM = install -m 755 -p
-DEL_FILE      = rm -f
-SYMLINK       = ln -f -s
-DEL_DIR       = rmdir
-MOVE          = mv -f
-CHK_DIR_EXISTS= test -d
-MKDIR         = mkdir -p
-
-####### Output directory
-
-OBJECTS_DIR   = ./
-
-####### Files
-
-SOURCES       = main.cpp \
-		mainwindow.cpp \
-		widget.cpp moc_mainwindow.cpp \
-		moc_widget.cpp
-OBJECTS       = main.o \
-		mainwindow.o \
-		widget.o \
-		moc_mainwindow.o \
-		moc_widget.o
-DIST          = /usr/share/qt4/mkspecs/common/g++.conf \
-		/usr/share/qt4/mkspecs/common/unix.conf \
-		/usr/share/qt4/mkspecs/common/linux.conf \
-		/usr/share/qt4/mkspecs/qconfig.pri \
-		/usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \
-		/usr/share/qt4/mkspecs/features/qt_functions.prf \
-		/usr/share/qt4/mkspecs/features/qt_config.prf \
-		/usr/share/qt4/mkspecs/features/exclusive_builds.prf \
-		/usr/share/qt4/mkspecs/features/default_pre.prf \
-		/usr/share/qt4/mkspecs/features/release.prf \
-		/usr/share/qt4/mkspecs/features/default_post.prf \
-		/usr/share/qt4/mkspecs/features/warn_on.prf \
-		/usr/share/qt4/mkspecs/features/qt.prf \
-		/usr/share/qt4/mkspecs/features/unix/thread.prf \
-		/usr/share/qt4/mkspecs/features/moc.prf \
-		/usr/share/qt4/mkspecs/features/resources.prf \
-		/usr/share/qt4/mkspecs/features/uic.prf \
-		/usr/share/qt4/mkspecs/features/yacc.prf \
-		/usr/share/qt4/mkspecs/features/lex.prf \
-		/usr/share/qt4/mkspecs/features/include_source_dir.prf \
-		ossimVect.pro
-QMAKE_TARGET  = ossimVectorQt
-DESTDIR       = 
-TARGET        = ossimVectorQt
-
-first: all
-####### Implicit rules
-
-.SUFFIXES: .o .c .cpp .cc .cxx .C
-
-.cpp.o:
-	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
-
-.cc.o:
-	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
-
-.cxx.o:
-	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
-
-.C.o:
-	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o "$@" "$<"
-
-.c.o:
-	$(CC) -c $(CFLAGS) $(INCPATH) -o "$@" "$<"
-
-####### Build rules
-
-all: Makefile $(TARGET)
-
-$(TARGET):  $(OBJECTS)  
-	$(LINK) $(LFLAGS) -o $(TARGET) $(OBJECTS) $(OBJCOMP) $(LIBS)
-
-Makefile: ossimVect.pro  /usr/share/qt4/mkspecs/linux-g++/qmake.conf /usr/share/qt4/mkspecs/common/g++.conf \
-		/usr/share/qt4/mkspecs/common/unix.conf \
-		/usr/share/qt4/mkspecs/common/linux.conf \
-		/usr/share/qt4/mkspecs/qconfig.pri \
-		/usr/share/qt4/mkspecs/modules/qt_webkit_version.pri \
-		/usr/share/qt4/mkspecs/features/qt_functions.prf \
-		/usr/share/qt4/mkspecs/features/qt_config.prf \
-		/usr/share/qt4/mkspecs/features/exclusive_builds.prf \
-		/usr/share/qt4/mkspecs/features/default_pre.prf \
-		/usr/share/qt4/mkspecs/features/release.prf \
-		/usr/share/qt4/mkspecs/features/default_post.prf \
-		/usr/share/qt4/mkspecs/features/warn_on.prf \
-		/usr/share/qt4/mkspecs/features/qt.prf \
-		/usr/share/qt4/mkspecs/features/unix/thread.prf \
-		/usr/share/qt4/mkspecs/features/moc.prf \
-		/usr/share/qt4/mkspecs/features/resources.prf \
-		/usr/share/qt4/mkspecs/features/uic.prf \
-		/usr/share/qt4/mkspecs/features/yacc.prf \
-		/usr/share/qt4/mkspecs/features/lex.prf \
-		/usr/share/qt4/mkspecs/features/include_source_dir.prf \
-		/usr/lib/i386-linux-gnu/libQtGui.prl \
-		/usr/lib/i386-linux-gnu/libQtCore.prl
-	$(QMAKE) -o Makefile ossimVect.pro
-/usr/share/qt4/mkspecs/common/g++.conf:
-/usr/share/qt4/mkspecs/common/unix.conf:
-/usr/share/qt4/mkspecs/common/linux.conf:
-/usr/share/qt4/mkspecs/qconfig.pri:
-/usr/share/qt4/mkspecs/modules/qt_webkit_version.pri:
-/usr/share/qt4/mkspecs/features/qt_functions.prf:
-/usr/share/qt4/mkspecs/features/qt_config.prf:
-/usr/share/qt4/mkspecs/features/exclusive_builds.prf:
-/usr/share/qt4/mkspecs/features/default_pre.prf:
-/usr/share/qt4/mkspecs/features/release.prf:
-/usr/share/qt4/mkspecs/features/default_post.prf:
-/usr/share/qt4/mkspecs/features/warn_on.prf:
-/usr/share/qt4/mkspecs/features/qt.prf:
-/usr/share/qt4/mkspecs/features/unix/thread.prf:
-/usr/share/qt4/mkspecs/features/moc.prf:
-/usr/share/qt4/mkspecs/features/resources.prf:
-/usr/share/qt4/mkspecs/features/uic.prf:
-/usr/share/qt4/mkspecs/features/yacc.prf:
-/usr/share/qt4/mkspecs/features/lex.prf:
-/usr/share/qt4/mkspecs/features/include_source_dir.prf:
-/usr/lib/i386-linux-gnu/libQtGui.prl:
-/usr/lib/i386-linux-gnu/libQtCore.prl:
-qmake:  FORCE
-	@$(QMAKE) -o Makefile ossimVect.pro
-
-dist: 
-	@$(CHK_DIR_EXISTS) .tmp/ossimVectorQt1.0.0 || $(MKDIR) .tmp/ossimVectorQt1.0.0 
-	$(COPY_FILE) --parents $(SOURCES) $(DIST) .tmp/ossimVectorQt1.0.0/ && $(COPY_FILE) --parents mainwindow.h widget.h .tmp/ossimVectorQt1.0.0/ && $(COPY_FILE) --parents main.cpp mainwindow.cpp widget.cpp .tmp/ossimVectorQt1.0.0/ && (cd `dirname .tmp/ossimVectorQt1.0.0` && $(TAR) ossimVectorQt1.0.0.tar ossimVectorQt1.0.0 && $(COMPRESS) ossimVectorQt1.0.0.tar) && $(MOVE) `dirname .tmp/ossimVectorQt1.0.0`/ossimVectorQt1.0.0.tar.gz . && $(DEL_FILE) -r .tmp/ossimVectorQt1.0.0
-
-
-clean:compiler_clean 
-	-$(DEL_FILE) $(OBJECTS)
-	-$(DEL_FILE) *~ core *.core
-
-
-####### Sub-libraries
-
-distclean: clean
-	-$(DEL_FILE) $(TARGET) 
-	-$(DEL_FILE) Makefile
-
-
-check: first
-
-mocclean: compiler_moc_header_clean compiler_moc_source_clean
-
-mocables: compiler_moc_header_make_all compiler_moc_source_make_all
-
-compiler_moc_header_make_all: moc_mainwindow.cpp moc_widget.cpp
-compiler_moc_header_clean:
-	-$(DEL_FILE) moc_mainwindow.cpp moc_widget.cpp
-moc_mainwindow.cpp: widget.h \
-		../ossimVectorPrimitive.h \
-		mainwindow.h
-	/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) mainwindow.h -o moc_mainwindow.cpp
-
-moc_widget.cpp: ../ossimVectorPrimitive.h \
-		widget.h
-	/usr/bin/moc-qt4 $(DEFINES) $(INCPATH) widget.h -o moc_widget.cpp
-
-compiler_rcc_make_all:
-compiler_rcc_clean:
-compiler_image_collection_make_all: qmake_image_collection.cpp
-compiler_image_collection_clean:
-	-$(DEL_FILE) qmake_image_collection.cpp
-compiler_moc_source_make_all:
-compiler_moc_source_clean:
-compiler_uic_make_all:
-compiler_uic_clean:
-compiler_yacc_decl_make_all:
-compiler_yacc_decl_clean:
-compiler_yacc_impl_make_all:
-compiler_yacc_impl_clean:
-compiler_lex_make_all:
-compiler_lex_clean:
-compiler_clean: compiler_moc_header_clean 
-
-####### Compile
-
-main.o: main.cpp mainwindow.h \
-		widget.h \
-		../ossimVectorPrimitive.h
-	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o main.o main.cpp
-
-mainwindow.o: mainwindow.cpp mainwindow.h \
-		widget.h \
-		../ossimVectorPrimitive.h \
-		ui_mainwindow.h
-	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o mainwindow.o mainwindow.cpp
-
-widget.o: widget.cpp widget.h \
-		../ossimVectorPrimitive.h
-	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o widget.o widget.cpp
-
-moc_mainwindow.o: moc_mainwindow.cpp 
-	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_mainwindow.o moc_mainwindow.cpp
-
-moc_widget.o: moc_widget.cpp 
-	$(CXX) -c $(CXXFLAGS) $(INCPATH) -o moc_widget.o moc_widget.cpp
-
-####### Install
-
-install:   FORCE
-
-uninstall:   FORCE
-
-FORCE:
-

UI/mainwindow.cpp

 
 void MainWindow::openVector()
 {
-  QString filename = QFileDialog::getOpenFileName( this,"","/home/rashad/maps/kerala/" );
+  QString filename = QFileDialog::getOpenFileName( this,"","/home/rashad/maps");//,"Vector Files (*.shp *.gml *.gpx *xml)" );
   if( filename.isEmpty() )
     return;
 
 #include <iostream>
 #include <QPoint>
 #include <QDebug>
-#include <gd.h>
 
 #include <iostream>
 
 using namespace std;
 
 
-#define CELLSIZE(min,max,d)    ((max - min)/d)
-#define MAP2IMAGE_X(x,minx,cx) (NINT((x - minx)/cx))
-#define MAP2IMAGE_Y(y,maxy,cy) (NINT((maxy - y)/cy))
-#define IMAGE2MAP_X(x,minx,cx) (minx + cx*x)
-#define IMAGE2MAP_Y(y,maxy,cy) (maxy - cy*y)
-#define NINT(x)      ((x) >= 0.0 ? ((long) ((x)+.5)) : ((long) ((x)-.5)))
-#define ABS(a)	(((a)<0) ? -(a) : (a))
-
 #include <QPushButton>
 #include "ossimVector.h"
+#include "ossimVectorDef.h"
+
 Widget::Widget(QWidget *parent) :
     QWidget(parent)
 {
 loaded = false;
+width = 800; height= 600;
+buffer = new unsigned char[width * height * 3];
 
-     img = QImage(640,480,QImage::Format_RGB32);
+
+  
+
+
+
+
+
 zoomFactor = 1.0;
 
 }
 
     QPainter painter(this);
 
-    QRgb value;
 
 if(!loaded)
 return;
 
 
-   for(int i=0;i<gdImageSX(im);i++)
-    {
-       for(int j=0;j<gdImageSY(im);j++)
-       {
 
-           int index  = gdImageGetPixel(im,i,j);
-         int r = gdImageRed(im,index);
-         int g = gdImageGreen(im,index);
-         int b = gdImageBlue(im,index);
-         value = qRgb(r,g,b);
-        img.setPixel(i,j,value);
 
 
-       }
-   }
 
 
-painter.drawImage(0,0,img);
-//loaded = false;
+   QImage  img = QImage(buffer,width,height,QImage::Format_RGB666);
+   painter.drawImage(0,0,img);
+
 
 }
 
-void Widget::loadVector(QString fname1)
+void Widget::loadVector(QString name)
 {
 
-minx=miny=0;
-this->fname = fname1;
+
+this->fname = name;
 
 rect.minx = 0;
 rect.miny = 0;
 
 
 
-im = renderVector(fname.toStdString().c_str(),labelindex,&rect);
 
+renderVector(fname.toStdString().c_str(),labelindex,buffer,&rect);
 loaded = true;
 update();
 
 
 
 void Widget::wheelEvent(QWheelEvent *wevent){
-ImgPnt.x = wevent->pos().x();
-ImgPnt.y = wevent->pos().y();
+mx = wevent->pos().x();
+my = wevent->pos().y();
   setCursor(Qt::OpenHandCursor);
     if(wevent->delta()>0)
         zoomIn();
 
 void Widget::doZoom() {
 
+
     if(zoomSize != 0) {
         if(zoomDirection == 0) {
          zoomFactor = 1;
        } else {
          zoomFactor = zoomSize*zoomDirection;
          if(zoomFactor < 0)
-           zoomFactor = 1.0/ABS(zoomFactor);
+           zoomFactor = 1.0/OV_ABS(zoomFactor);
        }
      }
 
 
 
-    double ImgRows = 480;
-    double ImgCols = 640;
 
-    double cellx = CELLSIZE(rect.minx, rect.maxx, ImgCols);
-    double celly = CELLSIZE(rect.miny, rect.maxy, ImgRows);
-    px = IMAGE2MAP_X(ImgPnt.x, rect.minx, cellx);
-    py = IMAGE2MAP_Y(ImgPnt.y, rect.maxy, celly);
+ double csize = OV_MAX(OV_CELLSIZE(rect.minx, rect.maxx, width), OV_CELLSIZE(rect.miny, rect.maxy, height));
+
+    px = IMAGE2MAP_X(mx, rect.minx, csize);
+    py = IMAGE2MAP_Y(my, rect.maxy, csize);
+
+    //px =100;
+    //py=100;
+    //zoomFactor = 2;
+
 
     rect.minx = px - .5*((rect.maxx - rect.minx)/zoomFactor);
     rect.miny = py - .5*((rect.maxy - rect.miny)/zoomFactor);
 
 
 
-    im = renderVector(fname.toStdString().c_str(),labelindex,&rect);
-    loaded = true;
-    update();
+  renderVector(fname.toStdString().c_str(),labelindex,buffer,&rect);
+  loaded = true;
+  update();
+
 
 
 
 
 }
 
+void Widget::mousePressEvent(QMouseEvent *event)
+{
+    cout <<
+            event->pos().x() << ":" <<
+    event->pos().y();
+}
+
 
 void Widget::mouseMoveEvent(QMouseEvent *mevent){
 
+
+
+
         setCursor(Qt::OpenHandCursor);
     zoomFactor = 1.0;
 double panFactor = 70;
     rect.maxy =rect.maxy + deltay;
 }
 
- im = renderVector(fname.toStdString().c_str(),labelindex,&rect);
+  renderVector(fname.toStdString().c_str(),labelindex,buffer,&rect);
  loaded = true;
  update();
 
 
      lastpos =  mevent->pos();
 
+
 }
 
     Q_OBJECT
 public:
     explicit Widget(QWidget *parent = 0);
-  gdImagePtr im;
-  int w,h;
-  QPixmap p;
-  QImage img;
-bool loaded;
 
-void loadVector(QString fname);
+   void loadVector(QString fname);
 
+   void zoomIn();
 
+   void zoomOut();
 
+   void doZoom();
 
-void zoomIn();
-void zoomOut();
+
+private:
+
+
+  bool loaded;
+
+  int width, height;
+
+  unsigned char* buffer;
+
+  double mx,my;
+
+  QPoint lastpos;
+
+  int zoomSize, zoomDirection;
+
+  double zoomFactor;
+
+  double px ,py;
+
+  int labelindex;
+
+  ossimVectorRect rect;
+
+  QString fname;
+
+
+
+
+
 
 protected:
-virtual void paintEvent(QPaintEvent *event);
-virtual void wheelEvent(QWheelEvent *wevent);
-virtual void mouseMoveEvent(QMouseEvent *mevent);
-public:
 
-double minx,miny,maxx,maxy;
+  virtual void paintEvent(QPaintEvent *);
 
+  virtual void wheelEvent(QWheelEvent *);
 
-struct {
-    double x;
-    double y;
-}ImgPnt;
-QPoint lastpos;
+  virtual void mouseMoveEvent(QMouseEvent *);
 
-int zoomSize, zoomDirection;
-double zoomFactor;
+  virtual void mousePressEvent(QMouseEvent *);
 
-double px ,py;
-void doZoom();
-int labelindex;
 
-ossimVectorRect rect;
-QString fname;
 };
 
 #endif // WIDGET_H