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) {
303 selection.
grow(radius);
305 std::vector<GUIGlID> result;
307 for (std::vector<GUIGlID>::const_iterator it = ids.begin(); it != ids.end(); it++) {
319 result.push_back(
id);
329 const int NB_HITS_MAX = 1024 * 1024;
331 static GUIGlID hits[NB_HITS_MAX];
332 static GLint nb_hits = 0;
333 glSelectBuffer(NB_HITS_MAX, hits);
343 nb_hits = glRenderMode(GL_RENDER);
347 std::vector<GUIGlID> result;
348 for (
int i = 0; i < nb_hits; ++i) {
349 assert(i * 4 + 3 < NB_HITS_MAX);
350 result.push_back(hits[i * 4 + 3]);
374 glEnable(GL_DEPTH_TEST);
384 glTranslated(0, 0, .55);
385 glColor3d(0.5, 0.5, 0.5);
388 for (; ypos < yend;) {
389 glVertex2d(xmin, ypos);
390 glVertex2d(xend, ypos);
394 for (; xpos < xend;) {
395 glVertex2d(xpos, ymin);
396 glVertex2d(xpos, yend);
400 glTranslated(0, 0, -.55);
408 const std::string text(
"10000000000");
410 size_t pixelSize = (size_t)
m2p((
SUMOReal) length);
411 while (pixelSize <= 20) {
414 if (noDigits > text.length()) {
422 glMatrixMode(GL_PROJECTION);
425 glMatrixMode(GL_MODELVIEW);
430 glDisable(GL_TEXTURE_2D);
431 glDisable(GL_ALPHA_TEST);
433 glEnable(GL_DEPTH_TEST);
437 double o = double(15) / double(getHeight());
439 double oo = double(5) / double(getHeight());
442 glVertex2d(-.98, -1. + o);
443 glVertex2d(-.98 + len, -1. + o);
445 glVertex2d(-.98, -1. + o);
446 glVertex2d(-.98, -1. + o2);
448 glVertex2d(-.98 + len, -1. + o);
449 glVertex2d(-.98 + len, -1. + o2);
456 glRotated(180, 1, 0, 0);
458 glRotated(-180, 1, 0, 0);
461 glRotated(180, 1, 0, 0);
463 glRotated(-180, 1, 0, 0);
466 glMatrixMode(GL_PROJECTION);
468 glMatrixMode(GL_MODELVIEW);
494 if (o != 0 && dynamic_cast<GUIGlObject*>(o) != 0) {
495 if (applyZoom && zoomDist < 0) {
536 glViewport(0, 0, getWidth() - 1, getHeight() - 1);
574 FXEvent* e = (FXEvent*) data;
576 if (e->state & CONTROLMASK) {
681 myApp->getCursorPosition(x, y, b);
696 FXEvent* e = (FXEvent*) data;
697 if ((e->state & ALTMASK) != 0) {
698 setDefaultCursor(getApp()->getDefaultCursor(DEF_CROSSHAIR_CURSOR));
725 FXEvent* e = (FXEvent*) data;
726 if ((e->state & ALTMASK) == 0) {
728 setDefaultCursor(getApp()->getDefaultCursor(DEF_ARROW_CURSOR));
743 std::string errorMessage;
744 FXString ext = FXPath::extension(destFile.c_str());
745 bool useGL2PS = ext ==
"ps" || ext ==
"eps" || ext ==
"pdf" || ext ==
"svg" || ext ==
"tex" || ext ==
"pgf";
756 glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
757 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
762 glDisable(GL_DITHER);
766 glEnable(GL_POLYGON_SMOOTH);
767 glEnable(GL_LINE_SMOOTH);
770 glDisable(GL_POLYGON_SMOOTH);
771 glDisable(GL_LINE_SMOOTH);
780 }
else if (ext ==
"eps") {
782 }
else if (ext ==
"pdf") {
784 }
else if (ext ==
"tex") {
786 }
else if (ext ==
"svg") {
788 }
else if (ext ==
"pgf") {
791 return "Could not save '" + destFile +
"'.\n Unrecognized format '" + std::string(ext.text()) +
"'.";
793 FILE* fp = fopen(destFile.c_str(),
"wb");
795 return "Could not save '" + destFile +
"'.\n Could not open file for writing";
799 glGetIntegerv(GL_VIEWPORT, viewport);
801 buffsize += 1024 * 1024;
804 GL_RGBA, 0, NULL, 0, 0, 0, buffsize, fp,
"out.eps");
805 glMatrixMode(GL_MODELVIEW);
807 glDisable(GL_TEXTURE_2D);
808 glDisable(GL_ALPHA_TEST);
810 glEnable(GL_DEPTH_TEST);
820 glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
824 minB[0] = viewPort.
xmin();
825 minB[1] = viewPort.
ymin();
826 maxB[0] = viewPort.
xmax();
827 maxB[1] = viewPort.
ymax();
829 glEnable(GL_POLYGON_OFFSET_FILL);
830 glEnable(GL_POLYGON_OFFSET_LINE);
848 FXMALLOC(&buf, FXColor, getWidth()*getHeight());
850 glReadBuffer(GL_BACK);
852 glReadPixels(0, 0, getWidth(), getHeight(), GL_RGBA, GL_UNSIGNED_BYTE, (GLvoid*)buf);
856 size_t mwidth = getWidth();
857 size_t mheight = getHeight();
859 FXColor* pbb = buf + mwidth * (mheight - 1);
873 errorMessage =
"Could not save '" + destFile +
"'.";
876 errorMessage =
"Could not save '" + destFile +
"'.\n" + e.what();
960 GDALDataset* poDataset = (GDALDataset*)GDALOpen(d.
filename.c_str(), GA_ReadOnly);
961 if (poDataset == 0) {
964 const int xSize = poDataset->GetRasterXSize();
965 const int ySize = poDataset->GetRasterYSize();
968 double adfGeoTransform[6];
969 if (poDataset->GetGeoTransform(adfGeoTransform) == CE_None) {
970 Position topLeft(adfGeoTransform[0], adfGeoTransform[3]);
971 const double horizontalSize = xSize * adfGeoTransform[1];
972 const double verticalSize = ySize * adfGeoTransform[5];
973 Position bottomRight(topLeft.
x() + horizontalSize, topLeft.
y() + verticalSize);
975 d.
width = bottomRight.x() - topLeft.
x();
976 d.
height = topLeft.
y() - bottomRight.y();
977 d.
centerX = (topLeft.
x() + bottomRight.x()) / 2;
978 d.
centerY = (topLeft.
y() + bottomRight.y()) / 2;
993 const int picSize = xSize * ySize;
995 if (!FXMALLOC(&result, FXColor, picSize)) {
999 for (
int j = 0; j < picSize; j++) {
1000 result[j] = FXRGB(0, 0, 0);
1003 for (
int i = 1; i <= poDataset->GetRasterCount(); i++) {
1004 GDALRasterBand* poBand = poDataset->GetRasterBand(i);
1006 if (poBand->GetColorInterpretation() == GCI_RedBand) {
1008 }
else if (poBand->GetColorInterpretation() == GCI_GreenBand) {
1010 }
else if (poBand->GetColorInterpretation() == GCI_BlueBand) {
1012 }
else if (poBand->GetColorInterpretation() == GCI_AlphaBand) {
1019 assert(xSize == poBand->GetXSize() && ySize == poBand->GetYSize());
1020 if (poBand->RasterIO(GF_Read, 0, 0, xSize, ySize, ((
unsigned char*)result) + shift, xSize, ySize, GDT_Byte, 4, 4 * xSize) == CE_Failure) {
1025 GDALClose(poDataset);
1027 return new FXImage(getApp(), result, IMAGE_OWNED | IMAGE_KEEP | IMAGE_SHMI | IMAGE_SHMP, xSize, ySize);
1039 for (std::vector<GUISUMOAbstractView::Decal>::iterator l =
myDecals.begin(); l !=
myDecals.end(); ++l) {
1063 glRotated(d.
rot, 0, 0, 1);
1110 glMatrixMode(GL_PROJECTION);
1115 glOrtho(0, getWidth(), 0, getHeight(), -
GLO_MAX - 1,
GLO_MAX + 1);
1116 glMatrixMode(GL_MODELVIEW);
1120 glScaled(scaleX, scaleY, 1);
1121 glTranslated(-bound.
xmin(), -bound.
ymin(), 0);