Revision: 78249
          http://sourceforge.net/p/brlcad/code/78249
Author:   starseeker
Date:     2021-02-16 21:24:51 +0000 (Tue, 16 Feb 2021)
Log Message:
-----------
Start a simple Qt viewer for the isst visual.

Main goal is to figure out how Qt's OpenGL widget will work
with the texture based approach to data display.  ISST's
visual is a working example of displaying raytracing results
with a texture, and is also fairly self contained as far as
the rest of the dm/fb software pipeline is concerned.

Noticed also that the Tcl/Tk version of isst doesn't want to
start, at least using a system install of Tcl/Tk on Linux.

Modified Paths:
--------------
    brlcad/trunk/src/CMakeLists.txt

Added Paths:
-----------
    brlcad/trunk/src/isst/
    brlcad/trunk/src/isst/CMakeLists.txt
    brlcad/trunk/src/isst/isstapp.cpp
    brlcad/trunk/src/isst/isstapp.h
    brlcad/trunk/src/isst/main.cpp
    brlcad/trunk/src/isst/main_window.cpp
    brlcad/trunk/src/isst/main_window.h

Modified: brlcad/trunk/src/CMakeLists.txt
===================================================================
--- brlcad/trunk/src/CMakeLists.txt     2021-02-16 16:02:15 UTC (rev 78248)
+++ brlcad/trunk/src/CMakeLists.txt     2021-02-16 21:24:51 UTC (rev 78249)
@@ -75,6 +75,7 @@
   # as dependencies for the targets in these directories
   tclscripts
   adrt
+  isst
   rtwizard
   archer
   mged

Added: brlcad/trunk/src/isst/CMakeLists.txt
===================================================================
--- brlcad/trunk/src/isst/CMakeLists.txt                                (rev 0)
+++ brlcad/trunk/src/isst/CMakeLists.txt        2021-02-16 21:24:51 UTC (rev 
78249)
@@ -0,0 +1,49 @@
+if(BRLCAD_ENABLE_QT)
+  include_directories(
+    ${CMAKE_CURRENT_BINARY_DIR}
+    ${CMAKE_CURRENT_SOURCE_DIR}
+    ${CMAKE_CURRENT_SOURCE_DIR}/../adrt
+    ${CMAKE_CURRENT_SOURCE_DIR}/../adrt/librender
+    ${BRLCAD_BINARY_DIR}/${INCLUDE_DIR}
+    ${BRLCAD_SOURCE_DIR}/include
+    ${GED_INCLUDE_DIRS}
+    ${RT_INCLUDE_DIRS}
+    ${BU_INCLUDE_DIRS}
+    )
+endif(BRLCAD_ENABLE_QT)
+
+# NOTE: We can't use the CMake global values for automoc et. al.
+# because most of BRL-CAD's targets are not Qt targets.  We don't
+# want to run the automatic moc logic for all of them.
+
+set(isst_srcs
+  main.cpp
+  main_window.cpp
+  isstapp.cpp
+  )
+
+set(moc_headers
+  main_window.h
+  isstapp.h
+  )
+
+if(BRLCAD_ENABLE_QT)
+  QT5_WRAP_CPP(moc_srcs ${moc_headers})
+  BRLCAD_ADDEXEC(isst "${isst_srcs};${moc_srcs}" 
"libbu;librt;libgcv;librender;${OPENGL_LIBRARIES};Qt5::Core;Qt5::Widgets;Qt5::OpenGL")
+endif(BRLCAD_ENABLE_QT)
+
+set(isst_ignore_srcs
+  CMakeLists.txt
+  ${isst_srcs}
+  ${moc_headers}
+  )
+
+CMAKEFILES(${isst_ignore_srcs})
+
+# Local Variables:
+# tab-width: 8
+# mode: cmake
+# indent-tabs-mode: t
+# End:
+# ex: shiftwidth=2 tabstop=8
+


Property changes on: brlcad/trunk/src/isst/CMakeLists.txt
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: brlcad/trunk/src/isst/isstapp.cpp
===================================================================
--- brlcad/trunk/src/isst/isstapp.cpp                           (rev 0)
+++ brlcad/trunk/src/isst/isstapp.cpp   2021-02-16 21:24:51 UTC (rev 78249)
@@ -0,0 +1,351 @@
+/*                      I S S T A P P . C X X
+ * BRL-ISST
+ *
+ * Copyright (c) 2014-2021 United States Government as represented by
+ * the U.S. Army Research Laboratory.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this file; see the file named COPYING for more
+ * information.
+ */
+/** @file cadapp.cxx
+ *
+ * Application level data and functionality implementations.
+ *
+ */
+
+#include <QFileInfo>
+#include <QFile>
+#include <QPlainTextEdit>
+#include <QTextStream>
+#include "isstapp.h"
+#include "bu/malloc.h"
+#include "bu/file.h"
+
+#include "gcv.h"
+#include "nmg.h"
+#include "rt/geom.h"
+
+/* Replace the load_g globals from adrt with a struct that is
+ * passed through the callers. */
+struct isst_nmg_data {
+    TIE_3 **tribuf;
+    struct tie_s *cur_tie;
+    struct db_i *dbip;
+    struct bn_tol *tol;
+};
+
+struct gcv_data {
+    struct gcv_region_end_data region_end_data;
+    struct adrt_mesh_s **meshes;
+};
+
+static void nmg_to_adrt_gcvwrite(struct nmgregion *r, const struct 
db_full_path *pathp, int UNUSED(region_id), int material_id, float color[3], 
void *client_data);
+
+static struct gcv_data gcvwriter = {{nmg_to_adrt_gcvwrite, NULL}, NULL};
+
+/* load the region into the tie image */
+static void
+nmg_to_adrt_internal(TIE_3 **tribuf, struct tie_s *cur_tie, struct adrt_mesh_s 
*mesh, struct nmgregion *r)
+{
+    struct model *m;
+    struct shell *s;
+    int region_polys=0;
+
+    NMG_CK_REGION(r);
+
+    m = r->m_p;
+    NMG_CK_MODEL(m);
+
+    /* Check triangles */
+    for (BU_LIST_FOR (s, shell, &r->s_hd))
+    {
+       struct faceuse *fu;
+
+       NMG_CK_SHELL(s);
+
+       for (BU_LIST_FOR (fu, faceuse, &s->fu_hd))
+       {
+           struct loopuse *lu;
+
+           NMG_CK_FACEUSE(fu);
+
+           if (fu->orientation != OT_SAME)
+               continue;
+
+           for (BU_LIST_FOR (lu, loopuse, &fu->lu_hd))
+           {
+               struct edgeuse *eu;
+               int vert_count=0;
+
+               NMG_CK_LOOPUSE(lu);
+
+               if (BU_LIST_FIRST_MAGIC(&lu->down_hd) != NMG_EDGEUSE_MAGIC)
+                   continue;
+
+               /* check vertex numbers for each triangle */
+               for (BU_LIST_FOR (eu, edgeuse, &lu->down_hd))
+               {
+                   struct vertex *v;
+
+                   NMG_CK_EDGEUSE(eu);
+
+                   v = eu->vu_p->v_p;
+                   NMG_CK_VERTEX(v);
+
+                   /* convert mm to m */
+                   VSCALE((*tribuf[vert_count]).v, v->vg_p->coord, 1.0/1000.0);
+                   vert_count++;
+               }
+               if (vert_count > 3)
+               {
+                   bu_log("lu %p has %d vertices!\n", (void *)lu, vert_count);
+                   bu_exit(1, "ERROR: LU is not a triangle");
+               }
+               else if (vert_count < 3)
+                   continue;
+
+               TIE_VAL(tie_push)(cur_tie, tribuf, 1, mesh, 0);
+               region_polys++;
+           }
+       }
+    }
+
+    /* region_name must not be freed until we're done with the tie engine. */
+}
+
+
+static int
+nmg_to_adrt_regstart(struct db_tree_state *ts, const struct db_full_path 
*path, const struct rt_comb_internal *rci, void *client_data)
+{
+    /*
+     * if it's a simple single bot region, just eat the bots and return -1.
+     * Omnomnom. Return 0 to do nmg eval.
+     */
+    struct gcv_region_end_data *rd = (struct gcv_region_end_data *)client_data;
+    struct isst_nmg_data *d = (struct isst_nmg_data *)rd->client_data;
+    struct directory *dir;
+    struct rt_db_internal intern;
+    struct adrt_mesh_s *mesh;
+    unsigned char rgb[3] = { 0xc0, 0xc0, 0xc0 };
+
+    RT_CHECK_COMB(rci);
+
+    /* abort cases, no fast loading. */
+    if (rci->tree == NULL)
+       return 0;
+    RT_CK_TREE(rci->tree);
+    if ( rci->tree->tr_op != OP_DB_LEAF )
+       return 0;
+    if ((dir = db_lookup(d->dbip, rci->tree->tr_l.tl_name, 1)) == NULL) {
+       printf("Lookup failed: %s\n", rci->tree->tr_l.tl_name);
+       return 0;
+    }
+    if (dir->d_minor_type != ID_BOT && dir->d_minor_type != ID_NMG)
+       return 0;
+    if (rt_db_get_internal(&intern, dir, d->dbip, (fastf_t *)NULL, 
&rt_uniresource) < 0) {
+       printf("Failed to load\n");
+       return 0;
+    }
+
+    if (dir->d_minor_type == ID_NMG)
+       return 0;
+
+    /* FIXME: where is this released? */
+    BU_ALLOC(mesh, struct adrt_mesh_s);
+
+    BU_LIST_PUSH(&((*gcvwriter.meshes)->l), &(mesh->l));
+
+    mesh->texture = NULL;
+    mesh->flags = 0;
+
+    BU_ALLOC(mesh->attributes, struct adrt_mesh_attributes_s);
+    mesh->matid = ts->ts_gmater;
+
+    rt_comb_get_color(rgb, rci);
+    VSCALE(mesh->attributes->color.v, rgb, 1.0/256.0);
+
+    bu_strlcpy(mesh->name, db_path_to_string(path), sizeof(mesh->name));
+
+    if (intern.idb_minor_type == ID_NMG) {
+       nmg_to_adrt_internal(d->tribuf, d->cur_tie, mesh, (struct nmgregion 
*)intern.idb_ptr);
+       return -1;
+    } else if (intern.idb_minor_type == ID_BOT) {
+       size_t i;
+       struct rt_bot_internal *bot = (struct rt_bot_internal *)intern.idb_ptr;
+
+       RT_BOT_CK_MAGIC(bot);
+
+       for (i=0;i<bot->num_faces;i++)
+       {
+           VSCALE((*d->tribuf[0]).v, (bot->vertices+3*bot->faces[3*i+0]), 
1.0/1000.0);
+           VSCALE((*d->tribuf[1]).v, (bot->vertices+3*bot->faces[3*i+1]), 
1.0/1000.0);
+           VSCALE((*d->tribuf[2]).v, (bot->vertices+3*bot->faces[3*i+2]), 
1.0/1000.0);
+
+           TIE_VAL(tie_push)(d->cur_tie, d->tribuf, 1, mesh, 0);
+       }
+       return -1;
+    }
+
+    bu_log("Strange, %d is not %d or %d\n", intern.idb_minor_type, ID_BOT, 
ID_NMG);
+    return 0;
+}
+
+
+static void
+nmg_to_adrt_gcvwrite(struct nmgregion *r, const struct db_full_path *pathp, 
int UNUSED(region_id), int material_id, float color[3], void *client_data)
+{
+
+    struct isst_nmg_data *d = (struct isst_nmg_data *)client_data;
+    struct model *m;
+    struct adrt_mesh_s *mesh;
+
+    NMG_CK_REGION(r);
+    RT_CK_FULL_PATH(pathp);
+
+    m = r->m_p;
+    NMG_CK_MODEL(m);
+
+    /* triangulate model */
+    nmg_triangulate_model(m, &RTG.rtg_vlfree, d->tol);
+
+    /* FIXME: where is this released? */
+    BU_ALLOC(mesh, struct adrt_mesh_s);
+
+    BU_LIST_PUSH(&((*gcvwriter.meshes)->l), &(mesh->l));
+
+    mesh->texture = NULL;
+    mesh->flags = 0;
+
+    BU_ALLOC(mesh->attributes, struct adrt_mesh_attributes_s);
+    mesh->matid = material_id;
+
+    VMOVE(mesh->attributes->color.v, color);
+    bu_strlcpy(mesh->name, db_path_to_string(pathp), sizeof(mesh->name));
+
+    nmg_to_adrt_internal(d->tribuf, d->cur_tie, mesh, r);
+}
+
+int
+ISSTApp::load_g(const char *filename, int argc, const char *argv[])
+{
+    struct model *the_model;
+    struct bn_tol tol;
+    struct bg_tess_tol ttol;           /* tessellation tolerance in mm */
+    struct db_tree_state tree_state;   /* includes tol & model */
+    struct isst_nmg_data d;
+
+    tree_state = rt_initial_tree_state;        /* struct copy */
+    tree_state.ts_tol = &tol;
+    tree_state.ts_ttol = &ttol;
+    tree_state.ts_m = &the_model;
+
+    /* Set up tessellation tolerance defaults */
+    ttol.magic = BG_TESS_TOL_MAGIC;
+    /* Defaults, updated by command line options. */
+    ttol.abs = 0.0;
+    ttol.rel = 0.01;
+    ttol.norm = 0.0;
+
+    /* Set up calculation tolerance defaults */
+    /* FIXME: These need to be improved */
+    tol.magic = BN_TOL_MAGIC;
+    tol.dist = 0.0005;
+    tol.dist_sq = tol.dist * tol.dist;
+    tol.perp = 1e-6;
+    tol.para = 1 - tol.perp;
+    d.tol = &tol;
+
+    tie_check_degenerate = 0;
+
+    /* make empty NMG model */
+    the_model = nmg_mm();
+    BU_LIST_INIT(&RTG.rtg_vlfree);     /* for vlist macros */
+
+    /*
+     * these should probably encode so the result can be passed back to client
+     */
+    if ((dbip = db_open(filename, DB_OPEN_READONLY)) == DBI_NULL) {
+       bu_log("Unable to open geometry database file (%s)\n", filename);
+       return -1;
+    }
+    if (db_dirbuild(dbip)) {
+       bu_log("ERROR: db_dirbuild failed\n");
+       return -1;
+    }
+    d.dbip = dbip;
+
+    BU_ALLOC(tie, struct tie_s);
+    TIENET_BUFFER_INIT(buffer_image);
+    render_camera_init(&camera, bu_avail_cpus());
+    d.cur_tie = this->tie;
+
+
+    BN_CK_TOL(tree_state.ts_tol);
+    BG_CK_TESS_TOL(tree_state.ts_ttol);
+
+    TIE_VAL(tie_init)(d.cur_tie, BU_PAGE_SIZE, TIE_KDTREE_FAST);
+
+    /* FIXME: where is this released? */
+    BU_ALLOC(this->meshes, struct adrt_mesh_s);
+    BU_LIST_INIT(&((this->meshes)->l));
+
+    gcvwriter.meshes = &this->meshes;
+    gcvwriter.region_end_data.client_data = &d;
+
+    tribuf = (TIE_3 **)bu_malloc(sizeof(TIE_3 *) * 3, "triangle tribuffer 
tribuffer");
+    tribuf[0] = (TIE_3 *)bu_malloc(sizeof(TIE_3) * 3, "triangle tribuffer");
+    tribuf[1] = (TIE_3 *)bu_malloc(sizeof(TIE_3) * 3, "triangle tribuffer");
+    tribuf[2] = (TIE_3 *)bu_malloc(sizeof(TIE_3) * 3, "triangle tribuffer");
+    d.tribuf = this->tribuf;
+
+    (void) db_walk_tree(dbip,
+                       argc,                   /* number of toplevel regions */
+                       argv,                   /* region names */
+                       1,                      /* ncpu */
+                       &tree_state,            /* initial tree state */
+                       nmg_to_adrt_regstart,   /* region start function */
+                       gcv_region_end,         /* region end function */
+                       nmg_booltree_leaf_tess, /* leaf func */
+                       (void *)&gcvwriter);    /* client data */
+
+    /* Release dynamic storage */
+    nmg_km(the_model);
+    rt_vlist_cleanup();
+    db_close(dbip);
+    bu_free(tribuf[0], "vert");
+    bu_free(tribuf[1], "vert");
+    bu_free(tribuf[2], "vert");
+    bu_free(tribuf, "tri");
+
+    TIE_VAL(tie_prep)(d.cur_tie);
+
+    return 0;
+}
+
+void
+ISSTApp::closedb()
+{
+    current_file.clear();
+}
+
+/*
+ * Local Variables:
+ * mode: C++
+ * tab-width: 8
+ * c-basic-offset: 4
+ * indent-tabs-mode: t
+ * c-file-style: "stroustrup"
+ * End:
+ * ex: shiftwidth=4 tabstop=8
+ */
+


Property changes on: brlcad/trunk/src/isst/isstapp.cpp
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: brlcad/trunk/src/isst/isstapp.h
===================================================================
--- brlcad/trunk/src/isst/isstapp.h                             (rev 0)
+++ brlcad/trunk/src/isst/isstapp.h     2021-02-16 21:24:51 UTC (rev 78249)
@@ -0,0 +1,81 @@
+/*                       I S S T A P P . H
+ * BRL-ISST
+ *
+ * Copyright (c) 2014-2021 United States Government as represented by
+ * the U.S. Army Research Laboratory.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this file; see the file named COPYING for more
+ * information.
+ */
+/** @file cadapp.h
+ *
+ *  Specialization of QApplication that adds information specific
+ *  to ISST's data and functionality
+ *
+ */
+
+#ifndef ISSTAPP_H
+#define ISSTAPP_H
+
+#include <QApplication>
+#include <QObject>
+#include <QString>
+
+extern "C" {
+#include "bn/tol.h"
+#include "raytrace.h"
+
+#include "rt/tie.h"
+#include "adrt.h"
+#include "adrt_struct.h"
+#include "librender/camera.h"
+}
+
+class ISSTApp : public QApplication
+{
+    Q_OBJECT
+
+    public:
+       ISSTApp(int &argc, char *argv[]) :QApplication(argc, argv) {};
+       ~ISSTApp() {};
+
+       int load_g(const char *filename, int argc, const char **argv);
+       void closedb();
+
+       struct tie_s *tie;
+       struct adrt_mesh_s *meshes;
+       struct render_camera_s camera;
+       tienet_buffer_t buffer_image;
+       void *texdata;
+       int texid;
+
+       struct tie_s *cur_tie;
+       struct db_i *dbip;
+       TIE_3 **tribuf;
+
+       QString current_file;
+};
+
+#endif // ISSTAPP_H
+
+/*
+ * Local Variables:
+ * mode: C++
+ * tab-width: 8
+ * c-basic-offset: 4
+ * indent-tabs-mode: t
+ * c-file-style: "stroustrup"
+ * End:
+ * ex: shiftwidth=4 tabstop=8
+ */
+


Property changes on: brlcad/trunk/src/isst/isstapp.h
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: brlcad/trunk/src/isst/main.cpp
===================================================================
--- brlcad/trunk/src/isst/main.cpp                              (rev 0)
+++ brlcad/trunk/src/isst/main.cpp      2021-02-16 21:24:51 UTC (rev 78249)
@@ -0,0 +1,129 @@
+/*                        M A I N . C P P
+ * BRL-CAD
+ *
+ * Copyright (c) 2014-2021 United States Government as represented by
+ * the U.S. Army Research Laboratory.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this file; see the file named COPYING for more
+ * information.
+ */
+/** @file main.cpp
+ *
+ * ISST
+ *
+ */
+
+#include <iostream>
+
+#include "main_window.h"
+#include "isstapp.h"
+
+#include "bu/app.h"
+#include "bu/log.h"
+#include "brlcad_version.h"
+
+int main(int argc, char *argv[])
+{
+    bu_setprogname(argv[0]);
+
+    ISSTApp app(argc, argv);
+    ISST_MainWindow mainWin;
+
+    argc--; argv++;
+
+    if (argc <= 1) {
+       bu_exit(1, "isst file.g obj1 [obj2 ...]");
+    }
+
+    if (argc > 1) {
+       const char *filename = argv[0];
+       argc--; argv++;
+       if (app.load_g(filename, argc, (const char **)argv)) {
+           bu_exit(1, "%s%s%s\n", "Error: opening ", filename, " failed.");
+       }
+    }
+
+    // TODO - this needs to be a setting that is saved and restored
+    mainWin.resize(1100, 800);
+    app.camera.w = 1100;
+    app.camera.h = 800;
+
+    mainWin.show();
+
+    app.camera.type = RENDER_CAMERA_PERSPECTIVE;
+    app.camera.fov = 25;
+
+    struct camera_tile_s tile;
+    tile.format = RENDER_CAMERA_BIT_DEPTH_24;
+    tile.size_x = 1100;
+    tile.size_y = 800;
+
+    TIENET_BUFFER_SIZE(app.buffer_image, (uint32_t)(3 * app.camera.w * 
app.camera.h));
+
+    mainWin.canvas->makeCurrent();
+    glClearColor (0.0, 0, 0.0, 1);
+    glBindTexture (GL_TEXTURE_2D, app.texid);
+    glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
+    glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+    glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+    glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
+    app.texdata = malloc(app.camera.w * app.camera.h * 3);
+    glTexImage2D (GL_TEXTURE_2D, 0, GL_RGB, app.camera.w, app.camera.h, 0, 
GL_RGB, GL_UNSIGNED_BYTE, app.texdata);
+    glDisable(GL_LIGHTING);
+
+    glViewport(0,0, app.camera.w, app.camera.h);
+    glMatrixMode (GL_PROJECTION);
+    glLoadIdentity ();
+    glOrtho(0, app.camera.w, app.camera.h, 0, -1, 1);
+    glMatrixMode (GL_MODELVIEW);
+
+    glClear(GL_COLOR_BUFFER_BIT);
+
+    app.buffer_image.ind = 0;
+
+    VSETALL(app.camera.pos, app.tie->radius);
+    VMOVE(app.camera.focus, app.tie->mid);
+
+    render_camera_prep(&app.camera);
+    render_camera_render(&app.camera, app.tie, &tile, &app.buffer_image);
+
+    glClear(GL_DEPTH_BUFFER_BIT);
+    glLoadIdentity();
+    glColor3f(1,1,1);
+    glEnable(GL_TEXTURE_2D);
+    glBindTexture(GL_TEXTURE_2D, app.texid);
+    glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, app.camera.w, app.camera.h, 
GL_RGB, GL_UNSIGNED_BYTE, app.buffer_image.data + sizeof(camera_tile_t));
+    glBegin(GL_TRIANGLE_STRIP);
+
+    glTexCoord2d(0, 0); glVertex3f(0, 0, 0);
+    glTexCoord2d(0, 1); glVertex3f(0, app.camera.h, 0);
+    glTexCoord2d(1, 0); glVertex3f(app.camera.w, 0, 0);
+    glTexCoord2d(1, 1); glVertex3f(app.camera.w, app.camera.h, 0);
+
+    glEnd();
+    glFlush();
+
+    mainWin.canvas->update();
+    return app.exec();
+}
+
+/*
+ * Local Variables:
+ * mode: C++
+ * tab-width: 8
+ * c-basic-offset: 4
+ * indent-tabs-mode: t
+ * c-file-style: "stroustrup"
+ * End:
+ * ex: shiftwidth=4 tabstop=8
+ */


Property changes on: brlcad/trunk/src/isst/main.cpp
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: brlcad/trunk/src/isst/main_window.cpp
===================================================================
--- brlcad/trunk/src/isst/main_window.cpp                               (rev 0)
+++ brlcad/trunk/src/isst/main_window.cpp       2021-02-16 21:24:51 UTC (rev 
78249)
@@ -0,0 +1,82 @@
+/*                 M A I N _ W I N D O W . C P P
+ * BRL-CAD
+ *
+ * Copyright (c) 2014-2021 United States Government as represented by
+ * the U.S. Army Research Laboratory.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this file; see the file named COPYING for more
+ * information.
+ */
+/** @file main_window.cpp
+ *
+ */
+
+#include "main_window.h"
+#include "isstapp.h"
+
+ISST_MainWindow::ISST_MainWindow()
+{
+    // This solves the disappearing menubar problem on Ubuntu + fluxbox -
+    // suspect Unity's "global toolbar" settings are being used even when
+    // the Qt app isn't being run under unity - this is probably a quirk
+    // of this particular setup, but it sure is an annoying one...
+    menuBar()->setNativeMenuBar(false);
+
+    // Create Menus
+    file_menu = menuBar()->addMenu("File");
+    isst_open = new QAction("Open", this);
+    connect(isst_open, SIGNAL(triggered()), this, SLOT(open_file()));
+    file_menu->addAction(isst_open);
+
+    isst_exit = new QAction("Exit", this);
+    connect(isst_exit, SIGNAL(triggered()), this, SLOT(close()));
+    file_menu->addAction(isst_exit);
+
+    // Set up Display canvas
+    canvas = new QOpenGLWidget();
+    canvas->setMinimumSize(512,512);
+    setCentralWidget(canvas);
+
+}
+
+void
+ISST_MainWindow::open_file()
+{
+    const char *file_filters = "BRL-CAD (*.g *.asc);;All Files (*)";
+    QString fileName = QFileDialog::getOpenFileName((QWidget *)this,
+           "Open Geometry File",
+           qApp->applicationDirPath(),
+           file_filters,
+           NULL,
+           QFileDialog::DontUseNativeDialog);
+    if (!fileName.isEmpty()) {
+       int ret = ((ISSTApp *)qApp)->load_g(fileName.toLocal8Bit(), 0, NULL);
+       if (ret) {
+           statusBar()->showMessage("open failed");
+       } else {
+           statusBar()->showMessage(fileName);
+       }
+    }
+}
+
+/*
+ * Local Variables:
+ * mode: C++
+ * tab-width: 8
+ * c-basic-offset: 4
+ * indent-tabs-mode: t
+ * c-file-style: "stroustrup"
+ * End:
+ * ex: shiftwidth=4 tabstop=8
+ */
+


Property changes on: brlcad/trunk/src/isst/main_window.cpp
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: brlcad/trunk/src/isst/main_window.h
===================================================================
--- brlcad/trunk/src/isst/main_window.h                         (rev 0)
+++ brlcad/trunk/src/isst/main_window.h 2021-02-16 21:24:51 UTC (rev 78249)
@@ -0,0 +1,70 @@
+/*                   M A I N _ W I N D O W . H
+ * BRL-CAD
+ *
+ * Copyright (c) 2014-2021 United States Government as represented by
+ * the U.S. Army Research Laboratory.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * version 2.1 as published by the Free Software Foundation.
+ *
+ * This library is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this file; see the file named COPYING for more
+ * information.
+ */
+/** @file main_window.h
+ *
+ * Defines the toplevel window for the BRL-CAD GUI, into which other
+ * windows are docked.
+ *
+ */
+
+#ifndef ISST_MAINWINDOW_H
+#define ISST_MAINWINDOW_H
+
+#include <QMainWindow>
+#include <QtWidgets/QOpenGLWidget>
+#include <QDockWidget>
+#include <QMenu>
+#include <QMenuBar>
+#include <QAction>
+#include <QStatusBar>
+#include <QFileDialog>
+
+class ISST_MainWindow : public QMainWindow
+{
+    Q_OBJECT
+    public:
+       ISST_MainWindow();
+
+       QOpenGLWidget *canvas;
+
+    private slots:
+       void open_file();
+
+    private:
+       QMenu *file_menu;
+       QAction *isst_open;
+       QAction *isst_exit;
+
+       QString db_file;
+};
+
+#endif /* ISST_MAINWINDOW_H */
+
+/*
+ * Local Variables:
+ * mode: C++
+ * tab-width: 8
+ * c-basic-offset: 4
+ * indent-tabs-mode: t
+ * c-file-style: "stroustrup"
+ * End:
+ * ex: shiftwidth=4 tabstop=8
+ */
+


Property changes on: brlcad/trunk/src/isst/main_window.h
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to