72 #include <gdal_priv.h>
75 #ifdef CHECK_MEMORY_LEAKS
77 #endif // CHECK_MEMORY_LEAKS
116 LAYOUT_SIDE_TOP | LAYOUT_FILL_X | LAYOUT_FILL_Y, 0, 0, 0, 0),
121 myMouseHotspotX(app.getDefaultCursor()->getHotX()),
122 myMouseHotspotY(app.getDefaultCursor()->getHotY()),
124 myUseToolTips(false),
125 myAmInitialised(false),
126 myViewportChooser(0),
127 myVisualizationChanger(0) {
130 flags |= FLAG_ENABLED;
131 myInEditMode =
false;
135 myVisualizationSettings->
gaming = myApp->isGaming();
148 for (std::vector<GUISUMOAbstractView::Decal>::iterator it =
myDecals.begin(); it !=
myDecals.end(); ++it) {
201 if (getWidth() == 0 || getHeight() == 0) {
220 glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
221 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
226 glDisable(GL_DITHER);
230 glEnable(GL_POLYGON_SMOOTH);
231 glEnable(GL_LINE_SMOOTH);
234 glDisable(GL_POLYGON_SMOOTH);
235 glDisable(GL_LINE_SMOOTH);
263 selection.
grow(SENSITIVITY);
266 unsigned int idMax = 0;
268 for (std::vector<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) {
285 layer =
dynamic_cast<Shape*
>(o)->getLayer();
288 if (layer > maxLayer) {
301 const int NB_HITS_MAX = 1024 * 1024;
303 static GUIGlID hits[NB_HITS_MAX];
304 static GLint nb_hits = 0;
305 glSelectBuffer(NB_HITS_MAX, hits);
315 nb_hits = glRenderMode(GL_RENDER);
319 std::vector<GUIGlID> result;
320 for (
int i = 0; i < nb_hits; ++i) {
321 assert(i * 4 + 3 < NB_HITS_MAX);
322 result.push_back(hits[i * 4 + 3]);
346 glEnable(GL_DEPTH_TEST);
356 glTranslated(0, 0, .55);
357 glColor3d(0.5, 0.5, 0.5);
360 for (; ypos < yend;) {
361 glVertex2d(xmin, ypos);
362 glVertex2d(xend, ypos);
366 for (; xpos < xend;) {
367 glVertex2d(xpos, ymin);
368 glVertex2d(xpos, yend);
372 glTranslated(0, 0, -.55);
380 const std::string text(
"10000000000");
382 size_t pixelSize = (size_t)
m2p((
SUMOReal) length);
383 while (pixelSize <= 20) {
386 if (noDigits > text.length()) {
394 glMatrixMode(GL_PROJECTION);
397 glMatrixMode(GL_MODELVIEW);
402 glDisable(GL_TEXTURE_2D);
403 glDisable(GL_ALPHA_TEST);
405 glEnable(GL_DEPTH_TEST);
409 double o = double(15) / double(getHeight());
411 double oo = double(5) / double(getHeight());
414 glVertex2d(-.98, -1. + o);
415 glVertex2d(-.98 + len, -1. + o);
417 glVertex2d(-.98, -1. + o);
418 glVertex2d(-.98, -1. + o2);
420 glVertex2d(-.98 + len, -1. + o);
421 glVertex2d(-.98 + len, -1. + o2);
428 glRotated(180, 1, 0, 0);
430 glRotated(-180, 1, 0, 0);
433 glRotated(180, 1, 0, 0);
435 glRotated(-180, 1, 0, 0);
438 glMatrixMode(GL_PROJECTION);
440 glMatrixMode(GL_MODELVIEW);
466 if (o != 0 && dynamic_cast<GUIGlObject*>(o) != 0) {
467 if (applyZoom && zoomDist < 0) {
500 FXbool ret = FXGLCanvas::makeCurrent();
508 glViewport(0, 0, getWidth() - 1, getHeight() - 1);
546 FXEvent* e = (FXEvent*) data;
548 if (e->state & CONTROLMASK) {
650 myApp->getCursorPosition(x, y, b);
665 FXEvent* e = (FXEvent*) data;
666 if ((e->state & ALTMASK) != 0) {
667 setDefaultCursor(getApp()->getDefaultCursor(DEF_CROSSHAIR_CURSOR));
688 return FXGLCanvas::onKeyPress(o, sel, data);
694 FXEvent* e = (FXEvent*) data;
695 if ((e->state & ALTMASK) == 0) {
697 setDefaultCursor(getApp()->getDefaultCursor(DEF_ARROW_CURSOR));
699 return FXGLCanvas::onKeyRelease(o, sel, data);
712 std::string errorMessage;
713 FXString ext = FXPath::extension(destFile.c_str());
714 bool useGL2PS = ext ==
"ps" || ext ==
"eps" || ext ==
"pdf" || ext ==
"svg" || ext ==
"tex" || ext ==
"pgf";
725 glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
726 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
731 glDisable(GL_DITHER);
735 glEnable(GL_POLYGON_SMOOTH);
736 glEnable(GL_LINE_SMOOTH);
739 glDisable(GL_POLYGON_SMOOTH);
740 glDisable(GL_LINE_SMOOTH);
749 }
else if (ext ==
"eps") {
751 }
else if (ext ==
"pdf") {
753 }
else if (ext ==
"tex") {
755 }
else if (ext ==
"svg") {
757 }
else if (ext ==
"pgf") {
760 return "Could not save '" + destFile +
"'.\n Unrecognized format '" + std::string(ext.text()) +
"'.";
762 FILE* fp = fopen(destFile.c_str(),
"wb");
764 return "Could not save '" + destFile +
"'.\n Could not open file for writing";
768 glGetIntegerv(GL_VIEWPORT, viewport);
770 buffsize += 1024 * 1024;
773 GL_RGBA, 0, NULL, 0, 0, 0, buffsize, fp,
"out.eps");
774 glMatrixMode(GL_MODELVIEW);
776 glDisable(GL_TEXTURE_2D);
777 glDisable(GL_ALPHA_TEST);
779 glEnable(GL_DEPTH_TEST);
789 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
793 minB[0] = viewPort.
xmin();
794 minB[1] = viewPort.
ymin();
795 maxB[0] = viewPort.
xmax();
796 maxB[1] = viewPort.
ymax();
798 glEnable(GL_POLYGON_OFFSET_FILL);
799 glEnable(GL_POLYGON_OFFSET_LINE);
817 FXMALLOC(&buf, FXColor, getWidth()*getHeight());
819 glReadBuffer(GL_BACK);
821 glReadPixels(0, 0, getWidth(), getHeight(), GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)buf);
825 size_t mwidth = getWidth();
826 size_t mheight = getHeight();
828 FXColor* pbb = buf + mwidth * (mheight - 1);
842 errorMessage =
"Could not save '" + destFile +
"'.";
845 errorMessage =
"Could not save '" + destFile +
"'.\n" + e.what();
929 GDALDataset* poDataset = (GDALDataset*)GDALOpen(d.
filename.c_str(), GA_ReadOnly);
930 if (poDataset == 0) {
933 const int xSize = poDataset->GetRasterXSize();
934 const int ySize = poDataset->GetRasterYSize();
937 double adfGeoTransform[6];
938 if (poDataset->GetGeoTransform(adfGeoTransform) == CE_None) {
939 Position topLeft(adfGeoTransform[0], adfGeoTransform[3]);
940 const double horizontalSize = xSize * adfGeoTransform[1];
941 const double verticalSize = ySize * adfGeoTransform[5];
942 Position bottomRight(topLeft.
x() + horizontalSize, topLeft.
y() + verticalSize);
944 d.
width = bottomRight.x() - topLeft.
x();
945 d.
height = topLeft.
y() - bottomRight.y();
946 d.
centerX = (topLeft.
x() + bottomRight.x()) / 2;
947 d.
centerY = (topLeft.
y() + bottomRight.y()) / 2;
962 const int picSize = xSize * ySize;
964 if (!FXMALLOC(&result, FXColor, picSize)) {
968 for (
int j = 0; j < picSize; j++) {
969 result[j] = FXRGB(0, 0, 0);
972 for (
int i = 1; i <= poDataset->GetRasterCount(); i++) {
973 GDALRasterBand* poBand = poDataset->GetRasterBand(i);
975 if (poBand->GetColorInterpretation() == GCI_RedBand) {
977 }
else if (poBand->GetColorInterpretation() == GCI_GreenBand) {
979 }
else if (poBand->GetColorInterpretation() == GCI_BlueBand) {
981 }
else if (poBand->GetColorInterpretation() == GCI_AlphaBand) {
988 assert(xSize == poBand->GetXSize() && ySize == poBand->GetYSize());
989 if (poBand->RasterIO(GF_Read, 0, 0, xSize, ySize, ((
unsigned char*)result) + shift, xSize, ySize, GDT_Byte, 4, 4 * xSize) == CE_Failure) {
994 GDALClose(poDataset);
996 return new FXImage(getApp(), result, IMAGE_OWNED | IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP, xSize, ySize);
1008 for (std::vector<GUISUMOAbstractView::Decal>::iterator l =
myDecals.begin(); l !=
myDecals.end(); ++l) {
1032 glRotated(d.
rot, 0, 0, 1);
1079 glMatrixMode(GL_PROJECTION);
1084 glOrtho(0, getWidth(), 0, getHeight(), -
GLO_MAX - 1,
GLO_MAX + 1);
1085 glMatrixMode(GL_MODELVIEW);
1089 glScaled(scaleX, scaleY, 1);
1090 glTranslated(-bound.
xmin(), -bound.
ymin(), 0);