示例#1
0
文件: s52gtk3egl.c 项目: vadp/S52
static gboolean configure_event(GtkWidget         *widget,
                                GdkEventConfigure *event,
                                gpointer           data)
{
    (void)event;
    (void)data;


    // FIXME: find the new screen size
    GtkAllocation allocation;
    gtk_widget_get_allocation(GTK_WIDGET(widget), &allocation);

    //gtk_widget_get_allocation(GTK_WIDGET(_engine.window), &allocation);
    //gtk_widget_size_allocate(GTK_WIDGET(_engine.window), &allocation);

    //GtkRequisition requisition;
    //gtk_widget_get_child_requisition(widget, &requisition);

    _engine.width  = allocation.width;
    _engine.height = allocation.height;

    _s52_computeView(&_engine.state);
    S52_setView(_engine.state.cLat, _engine.state.cLon, _engine.state.rNM, _engine.state.north);
    S52_setViewPort(0, 0, allocation.width, allocation.height);

    _engine.do_S52draw = TRUE;

    return TRUE;
}
示例#2
0
static gboolean _configure_event(GtkWidget         *widget,
                                GdkEventConfigure *event,
                                gpointer           data)
{
    (void)widget;
    (void)event;
    (void)data;


    //g_print("_configure_event\n");

    // FIXME: find the new screen size
    //GtkAllocation allocation;
    //gtk_widget_get_allocation(GTK_WIDGET(widget), &allocation);
    //_engine.width  = allocation.width;
    //_engine.height = allocation.height;


    //gtk_widget_get_allocation(GTK_WIDGET(_engine.window), &allocation);
    //gtk_widget_size_allocate(GTK_WIDGET(_engine.window), &allocation);

    //GtkRequisition requisition;
    //gtk_widget_get_child_requisition(widget, &requisition);

    //*
    if (TRUE == _engine.do_S52init) {
        g_print("s52egl:configure_event()\n");
        _egl_init(&_engine);
        _s52_init(&_engine);
        _engine.do_S52init = FALSE;
    }

    _s52_computeView(&_engine.state);
    S52_setView(_engine.state.cLat, _engine.state.cLon, _engine.state.rNM, _engine.state.north);
    S52_setViewPort(0, 0, _engine.width, _engine.height);

    _engine.do_S52draw = TRUE;
    //*/

    return TRUE;
}
示例#3
0
static int      _s52_draw_cb    (gpointer user_data)
// return TRUE for the signal to be called again
{
    s52engine *engine = (s52engine*)user_data;

    //g_print("s52egl:_s52_draw_cb(): begin .. \n");

    if (NULL == engine) {
        g_print("_s52_draw_cb(): no engine ..\n");
        goto exit;
    }

    // wait for libS52 to init - no use to go further - bailout
    if (TRUE == engine->do_S52init) {
        g_print("s52egl:_s52_draw_cb(): re-starting .. waiting for S52_init() to finish\n");
        goto exit;
    }

    if ((NULL==engine->eglDisplay) || (EGL_NO_DISPLAY==engine->eglDisplay)) {
        g_print("_s52_draw_cb(): no display ..\n");
        goto exit;
    }

    // no draw at all, the window is not visible
    if ((FALSE==engine->do_S52draw) && (FALSE==engine->do_S52drawLast)) {
        //g_print("s52egl:_s52_draw_cb(): nothing to draw (do_S52draw & do_S52drawLast FALSE)\n");
        goto exit;
    }

#ifndef S52_USE_EGL
    _egl_beg(engine);
#endif

    // draw background
    if (TRUE == engine->do_S52draw) {
        if (TRUE == engine->do_S52setViewPort) {
            eglQuerySurface(engine->eglDisplay, engine->eglSurface, EGL_WIDTH,  &engine->width);
            eglQuerySurface(engine->eglDisplay, engine->eglSurface, EGL_HEIGHT, &engine->height);

            S52_setViewPort(0, 0, engine->width, engine->height);

            engine->do_S52setViewPort = FALSE;
        }

        S52_draw();
        engine->do_S52draw = FALSE;
    }

    // draw AIS
    if (TRUE == engine->do_S52drawLast) {

#ifdef USE_FAKE_AIS
        _s52_updTimeTag(engine);
#endif
        S52_drawLast();
    }

#ifndef S52_USE_EGL
    _egl_end(engine);
#endif


exit:

    // debug
    //g_print("s52egl:_s52_draw_cb(): end .. \n");

    return EGL_TRUE;
}
示例#4
0
static int      _s52_init       (s52engine *engine)
{
    if ((NULL==engine->eglDisplay) || (EGL_NO_DISPLAY==engine->eglDisplay)) {
        g_print("_init_S52(): no EGL display ..\n");
        return FALSE;
    }

    eglQuerySurface(engine->eglDisplay, engine->eglSurface, EGL_WIDTH,  &engine->width);
    eglQuerySurface(engine->eglDisplay, engine->eglSurface, EGL_HEIGHT, &engine->height);

    // return constant value EGL_UNKNOWN (-1) with Mesa
    eglQuerySurface(engine->eglDisplay, engine->eglSurface, EGL_HORIZONTAL_RESOLUTION, &engine->wmm);
    eglQuerySurface(engine->eglDisplay, engine->eglSurface, EGL_VERTICAL_RESOLUTION,   &engine->hmm);

    {
        // FIXME: broken on some monitor
        GdkScreen    *screen   = NULL;
        gint         w,h;
        gint         wmm,hmm;

        screen = gdk_screen_get_default();
        w      = gdk_screen_get_width    (screen);
        h      = gdk_screen_get_height   (screen);
        wmm    = gdk_screen_get_width_mm (screen);
        hmm    = gdk_screen_get_height_mm(screen);

        //w   = 1280;
        //h   = 1024;
        //w   = engine->width;
        //h   = engine->height;
        //wmm = 376;
        //hmm = 301; // wrong
        //hmm = 307;

        //g_print("_init_S52(): start -1- ..\n");

        if (FALSE == S52_init(w, h, wmm, hmm, NULL)) {
            engine->do_S52init = FALSE;
            return FALSE;
        }

        //g_print("_init_S52(): start -2- ..\n");

        S52_setViewPort(0, 0, w, h);

    }

    // can be called any time
    S52_version();

#ifdef S52_USE_EGL
    S52_setEGLcb((EGL_cb)_egl_beg, (EGL_cb)_egl_end, engine);
#endif

    // read cell location fron s52.cfg
    //S52_loadCell(NULL, NULL);
    S52_loadCell("CA479017.000", NULL);
    S52_loadCell("SCX_CapSante.tif", NULL);
    S52_setMarinerParam(S52_MAR_DISP_RASTER, 1.0);

    // Rimouski
    //S52_loadCell("/home/sduclos/dev/gis/S57/riki-ais/ENC_ROOT/CA579041.000", NULL);

    //S52_loadCell("/home/vitaly/CHARTS/for_sasha/GB5X01SE.000", NULL);
	//S52_loadCell("/home/vitaly/CHARTS/for_sasha/GB5X01NE.000", NULL);

    // Ice - experimental
    //S52_loadCell("/home/sduclos/dev/gis/data/ice/East_Coast/--0WORLD.shp", NULL);

    // Bathy - experimental
    //S52_loadCell("/home/sduclos/dev/gis/data/bathy/2009_HD_BATHY_TRIALS/46307260_LOD2.merc.tif", NULL);
    //S52_loadCell("/home/sduclos/dev/gis/data/bathy/2009_HD_BATHY_TRIALS/46307250_LOD2.merc.tif", NULL);
    //S52_setMarinerParam(S52_MAR_DISP_RASTER, 1.0);

    // load AIS select symb.
    //S52_loadPLib("plib-test-priv.rle");


#ifdef S52_USE_WORLD
    // World data
    if (TRUE == S52_loadCell(PATH "/0WORLD/--0WORLD.shp", NULL)) {
        //S52_setMarinerParam(S52_MAR_DISP_WORLD, 0.0);   // default
        S52_setMarinerParam(S52_MAR_DISP_WORLD, 1.0);     // show world
    }
#endif

    // debug - remove clutter from this symb in SELECT mode
    //S52_setS57ObjClassSupp("M_QUAL", TRUE);  // supress display of the U pattern
    //S52_setS57ObjClassSupp("M_QUAL", FALSE);  // displaythe U pattern
    S52_toggleObjClassON ("M_QUAL");           //  suppression ON
    //S52_toggleObjClassOFF("M_QUAL");         //  suppression OFF


    S52_loadPLib(PLIB);
    S52_loadPLib(COLS);

    // -- DEPTH COLOR ------------------------------------
    S52_setMarinerParam(S52_MAR_TWO_SHADES,      0.0);   // 0.0 --> 5 shades
    //S52_setMarinerParam(S52_MAR_TWO_SHADES,      1.0);   // 1.0 --> 2 shades

    // sounding color
    //S52_setMarinerParam(S52_MAR_SAFETY_DEPTH,    10.0);
    S52_setMarinerParam(S52_MAR_SAFETY_DEPTH,    15.0);


    //S52_setMarinerParam(S52_MAR_SAFETY_CONTOUR,  10.0);
    S52_setMarinerParam(S52_MAR_SAFETY_CONTOUR,  3.0);

    //S52_setMarinerParam(S52_MAR_SHALLOW_CONTOUR, 10.0);
    S52_setMarinerParam(S52_MAR_SHALLOW_CONTOUR, 5.0);

    //S52_setMarinerParam(S52_MAR_DEEP_CONTOUR,   11.0);
    S52_setMarinerParam(S52_MAR_DEEP_CONTOUR,   10.0);

    //S52_setMarinerParam(S52_MAR_SHALLOW_PATTERN, 0.0);  // (default off)
    S52_setMarinerParam(S52_MAR_SHALLOW_PATTERN, 1.0);  // ON
    // -- DEPTH COLOR ------------------------------------



    S52_setMarinerParam(S52_MAR_SHIPS_OUTLINE,   1.0);
    S52_setMarinerParam(S52_MAR_HEADNG_LINE,     1.0);
    S52_setMarinerParam(S52_MAR_BEAM_BRG_NM,     1.0);
    //S52_setMarinerParam(S52_MAR_FULL_SECTORS,    0.0);    // (default ON)

    //S52_setMarinerParam(S52_MAR_DISP_CATEGORY,   S52_MAR_DISP_CATEGORY_BASE);    // always ON
    //S52_setMarinerParam(S52_MAR_DISP_CATEGORY,   S52_MAR_DISP_CATEGORY_STD);     // default
    //S52_setMarinerParam(S52_MAR_DISP_CATEGORY,   S52_MAR_DISP_CATEGORY_OTHER);
    //S52_setMarinerParam(S52_MAR_DISP_CATEGORY,   S52_MAR_DISP_CATEGORY_BASE | S52_MAR_DISP_CATEGORY_STD | S52_MAR_DISP_CATEGORY_OTHER);
    //S52_setMarinerParam(S52_MAR_DISP_CATEGORY,   S52_MAR_DISP_CATEGORY_STD | S52_MAR_DISP_CATEGORY_OTHER);
    S52_setMarinerParam(S52_MAR_DISP_CATEGORY,   S52_MAR_DISP_CATEGORY_SELECT);

    //S52_setMarinerParam(S52_MAR_DISP_LAYER_LAST, S52_MAR_DISP_LAYER_LAST_NONE );
    //S52_setMarinerParam(S52_MAR_DISP_LAYER_LAST, S52_MAR_DISP_LAYER_LAST_STD );   // default
    //S52_setMarinerParam(S52_MAR_DISP_LAYER_LAST, S52_MAR_DISP_LAYER_LAST_OTHER);
    S52_setMarinerParam(S52_MAR_DISP_LAYER_LAST, S52_MAR_DISP_LAYER_LAST_SELECT);   // All Mariner (Standard(default) + Other)

    //S52_setMarinerParam(S52_MAR_COLOR_PALETTE,   0.0);     // DAY (default)
    //S52_setMarinerParam(S52_MAR_COLOR_PALETTE,   1.0);     // DAY DARK
    S52_setMarinerParam(S52_MAR_COLOR_PALETTE,   5.0);     // DAY 60
    //S52_setMarinerParam(S52_MAR_COLOR_PALETTE,   6.0);     // DUSK 60

    //S52_setMarinerParam(S52_MAR_SCAMIN,          1.0);   // ON (default)
    //S52_setMarinerParam(S52_MAR_SCAMIN,          0.0);   // debug OFF - show all

    // remove QUAPNT01 symbole (black diagonal and a '?')
    S52_setMarinerParam(S52_MAR_QUAPNT01,        0.0);   // off

    S52_setMarinerParam(S52_MAR_DISP_CALIB,      1.0);

    // --- TEXT ----------------------------------------------
    S52_setMarinerParam(S52_MAR_SHOW_TEXT,       1.0);
    //S52_setMarinerParam(S52_MAR_SHOW_TEXT,       0.0);

    S52_setTextDisp(0, 100, TRUE);                      // show all text
    //S52_setTextDisp(0, 100, FALSE);                   // no text

    // cell's legend
    //S52_setMarinerParam(S52_MAR_DISP_LEGEND, 1.0);   // show
    S52_setMarinerParam(S52_MAR_DISP_LEGEND, 0.0);   // hide (default)
    // -------------------------------------------------------


    //S52_setMarinerParam(S52_MAR_DISP_DRGARE_PATTERN, 0.0);  // OFF
    //S52_setMarinerParam(S52_MAR_DISP_DRGARE_PATTERN, 1.0);  // ON (default)

    S52_setMarinerParam(S52_MAR_ANTIALIAS,       1.0);   // on
    //S52_setMarinerParam(S52_MAR_ANTIALIAS,       0.0);     // off


    // a delay of 0.0 to tell to not delete old AIS (default +600 sec old)
    //S52_setMarinerParam(S52_MAR_DEL_VESSEL_DELAY, 0.0);

    // debug - use for timing redering
    //S52_setMarinerParam(S52_CMD_WRD_FILTER, S52_CMD_WRD_FILTER_SY);
    //S52_setMarinerParam(S52_CMD_WRD_FILTER, S52_CMD_WRD_FILTER_LS);
    //S52_setMarinerParam(S52_CMD_WRD_FILTER, S52_CMD_WRD_FILTER_LC);
    //S52_setMarinerParam(S52_CMD_WRD_FILTER, S52_CMD_WRD_FILTER_AC);
    //S52_setMarinerParam(S52_CMD_WRD_FILTER, S52_CMD_WRD_FILTER_AP);
    //S52_setMarinerParam(S52_CMD_WRD_FILTER, S52_CMD_WRD_FILTER_TX);


    // if first start find where we are looking
    _s52_computeView(&engine->state);
    // then (re)position the 'camera'
    S52_setView(engine->state.cLat, engine->state.cLon, engine->state.rNM, engine->state.north);

    S52_newCSYMB();

    // must be first mariners' object so that the
    // rendering engine place it on top of OWNSHP/VESSEL
    //_s52_setupVRMEBL(&engine->state);

    //_s52_setupLEGLIN();

    //_s52_setupPRDARE(&engine->state);

#ifdef USE_FAKE_AIS
    _s52_setupVESSEL(&engine->state);

    _s52_setupOWNSHP(&engine->state);
#endif


    engine->do_S52init        = FALSE;

    engine->do_S52draw        = TRUE;
    engine->do_S52drawLast    = TRUE;

    engine->do_S52setViewPort = FALSE;


    return EGL_TRUE;
}
示例#5
0
文件: s52glx.c 项目: sduclos/S52
int main(int argc, char* argv[])
{
    (void)argc;
    (void)argv;

    Display     *dpy = _getXdis  ();
    XVisualInfo *vis = _getXvis  (dpy, _attr);
    Window       win = _setXwin  (dpy, vis);
    GLXContext   ctx = _getGLXctx(dpy, vis);

    // bind the rendering context to the window
    Bool ret = glXMakeCurrent(dpy, win, ctx);
    if (False == ret) {
        printf("ERROR: glXMakeCurrent() fail\n");
        exit(0);
    }

    {   // init S52 lib (Screen No 0)
#ifdef SET_SCREEN_SIZE
        int w      = 1280;
        int h      = 1024;
        int wmm    = 376;
        int hmm    = 307;
#else
        int h   = XDisplayHeight  (dpy, 0);
        int hmm = XDisplayHeightMM(dpy, 0);
        int w   = XDisplayWidth   (dpy, 0);
        int wmm = XDisplayWidthMM (dpy, 0);
#endif
        S52_init(w, h, wmm, hmm, NULL);
    }

    // differ from w/h
    S52_setViewPort(0, 0, WIDTH, HEIGHT);

    /* debug - use for timing rendering
    S52_setMarinerParam(S52_CMD_WRD_FILTER, S52_CMD_WRD_FILTER_SY);
    //S52_setMarinerParam(S52_CMD_WRD_FILTER, S52_CMD_WRD_FILTER_LS);
    S52_setMarinerParam(S52_CMD_WRD_FILTER, S52_CMD_WRD_FILTER_LC);
    S52_setMarinerParam(S52_CMD_WRD_FILTER, S52_CMD_WRD_FILTER_AC);
    S52_setMarinerParam(S52_CMD_WRD_FILTER, S52_CMD_WRD_FILTER_AP);
    S52_setMarinerParam(S52_CMD_WRD_FILTER, S52_CMD_WRD_FILTER_TX);
    //*/

    // load cell from s52.cfg
    S52_loadCell(NULL, NULL);

    { // main loop
        XEvent event;
        while (True) {
            do {
                XNextEvent(dpy, &event);
                switch (event.type) {
                case ConfigureNotify: break;
                //case GraphicsExpose:
                //    S52_setViewPort(0, 0, event.xconfigure.width, event.xconfigure.height); break;
                //case ...

                case KeyPress:
                case KeyRelease:
                    {
                        unsigned int keycode = ((XKeyEvent *)&event)->keycode;
                        unsigned int keysym  = XkbKeycodeToKeysym(dpy, keycode, 0, 1);

                        // ESC - quit
                        if (XK_Escape == keysym) {
                            goto exit;
                        }
                    }
                }
            } while (XPending(dpy));
            S52_draw();
            S52_drawLast();  // nothing to do

            glXSwapBuffers(dpy,  win);
        }
    }

exit:

    XKillClient(dpy, win);

    S52_done();

    return True;
}
示例#6
0
文件: s52gtk3egl.c 项目: vadp/S52
static int      _s52_draw_cb(GtkWidget *widget,
							 GdkEventExpose *event,
							 gpointer user_data)
// return TRUE for the signal to be called again
{
    (void)widget;
    (void)event;

    struct s52engine *engine = (struct s52engine*)user_data;
    //g_print("s52egl:_s52_draw_cb(): begin .. \n");

    /*
    GTimeVal now;  // 2 glong (at least 32 bits each - but amd64 !?
    g_get_current_time(&now);
    if (0 == (now.tv_sec - engine->timeLastDraw.tv_sec))
        goto exit;
    //*/

    if (NULL == engine) {
        g_print("_s52_draw_cb(): no engine ..\n");
        goto exit;
    }

    if ((NULL==engine->eglDisplay) || (EGL_NO_DISPLAY==engine->eglDisplay)) {
        g_print("_s52_draw_cb(): no display ..\n");
        goto exit;
    }

    // wait for libS52 to init - no use to go further - bailout
    if (TRUE == engine->state.do_S52init) {
        g_print("s52egl:_s52_draw_cb(): re-starting .. waiting for S52_init() to finish\n");
        goto exit;
    }

    // no draw at all, the window is not visible
    if ((FALSE==engine->do_S52draw) && (FALSE==engine->do_S52drawLast)) {
        //g_print("s52egl:_s52_draw_cb(): nothing to draw (do_S52draw & do_S52drawLast FALSE)\n");
        goto exit;
    }

#if !defined(S52_USE_EGL)
    _egl_beg(engine, "test");
#endif

    // draw background
    if (TRUE == engine->do_S52draw) {
        if (TRUE == engine->do_S52setViewPort) {
            eglQuerySurface(engine->eglDisplay, engine->eglSurface, EGL_WIDTH,  &engine->width);
            eglQuerySurface(engine->eglDisplay, engine->eglSurface, EGL_HEIGHT, &engine->height);

            S52_setViewPort(0, 0, engine->width, engine->height);

            engine->do_S52setViewPort = FALSE;
        }

        S52_draw();
        engine->do_S52draw = FALSE;
    }

    // draw AIS
    if (TRUE == engine->do_S52drawLast) {

#ifdef USE_FAKE_AIS
        _s52_updTimeTag(engine);
#endif
        S52_drawLast();
    }

#if !defined(S52_USE_EGL)
    _egl_end(engine);
#endif


exit:

    // debug
    //g_print("s52egl:_s52_draw_cb(): end .. \n");

    return EGL_TRUE;
}