/* * * Copyright (C) 2000 Silicon Graphics, Inc. All Rights Reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * 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. * * Further, this software is distributed without any warranty that it is * free of the rightful claim of any third person regarding infringement * or the like. Any license provided herein, whether implied or * otherwise, applies only to this software file. Patent licenses, if * any, provided herein do not apply to combinations of this program with * other software, or any other product whatsoever. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, * Mountain View, CA 94043, or: * * http://www.sgi.com * * For further information regarding this notice, see: * * http://oss.sgi.com/projects/GenInfo/NoticeExplan/ * */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include // #include "../../samples/widgets/MyColorEditor.h" #include "ivviewMenus.h" #define SCREEN(w) XScreenNumberOfScreen(XtScreen(w)) typedef struct { int count; // Number of files read char **names; // File names SoNode *original; // Un-munged scene SoSeparator *optimized; // Optimized scene SoSeparator *ivfixed; // Ivfixed scene } FileInfo; // Function prototypes static void print_usage(const char *); static void parse_args(int , char **); static SbBool readScene(FileInfo &); // Returns TRUE if error static void initPerfMeter(SoXtViewer *); static void viewStartCB(void *, SoXtViewer *); static void setBusyCursor(SbBool); static void createBusyCursor(Display *); static void overlayViewportCB(void *, SoAction *); static void countUpdatesCB(void *, SoAction *); static void perfSensorCB(void *, SoSensor *); static void showAboutDialog(); static void getNewScene(); static void optimizationChanged(FileInfo &, SbBool); static void newSceneCB(Widget, void *, XmFileSelectionBoxCallbackStruct *); static void editBackgroundColor(); static void backgroundColorCB(void *, const SbColor *); static void processTopbarEvent(Widget, ivMenuItem *, XmAnyCallbackStruct *); static Widget buildAndLayoutMenus(Widget ); static SoXtViewer *buildAndLayoutViewer(Widget , Widget, SbBool); static SoSeparator *addUpdateCounter(SoNode *); static int countTriangles(SoNode *); static void countTriangleCB(void *, SoCallbackAction *, const SoPrimitiveVertex *, const SoPrimitiveVertex *, const SoPrimitiveVertex *); // Global variables static SoXtViewer *viewer = NULL; static Widget shell = NULL; static SbBool useWalkViewer = FALSE; static FileInfo files = { 0, NULL, NULL, NULL, NULL }; static SbBool showPerfMeter = FALSE; static int numTris = 0; static int numFramesRendered = 0; static SbBool ivfix = FALSE; static SbBool shapeHintBackface = FALSE; // Definitions for busy cursor: static Cursor busyCursor = 0; #define hourglass_width 17 #define hourglass_height 21 #define hourglass_x_hot 8 #define hourglass_y_hot 11 static char hourglass_bits[] = { 0x00, 0x00, 0x00, 0xfe, 0xff, 0x00, 0x04, 0x40, 0x00, 0x04, 0x40, 0x00, 0x04, 0x40, 0x00, 0xe8, 0x2e, 0x00, 0xd0, 0x17, 0x00, 0xa0, 0x0b, 0x00, 0x40, 0x05, 0x00, 0x40, 0x05, 0x00, 0x40, 0x04, 0x00, 0x40, 0x04, 0x00, 0x40, 0x04, 0x00, 0x20, 0x09, 0x00, 0x10, 0x11, 0x00, 0x88, 0x23, 0x00, 0xc4, 0x47, 0x00, 0xe4, 0x4f, 0x00, 0xf4, 0x5f, 0x00, 0xfe, 0xff, 0x00, 0x00, 0x00, 0x00}; static char hourglass_mask_bits[] = { 0xff, 0xff, 0x01, 0xff, 0xff, 0x01, 0xfe, 0xff, 0x00, 0xfe, 0xff, 0x00, 0xfe, 0xff, 0x00, 0xfc, 0x7f, 0x00, 0xf8, 0x3f, 0x00, 0xf0, 0x1f, 0x00, 0xe0, 0x0f, 0x00, 0xe0, 0x0f, 0x00, 0xe0, 0x0f, 0x00, 0xe0, 0x0f, 0x00, 0xe0, 0x0f, 0x00, 0xf0, 0x1f, 0x00, 0xf8, 0x3f, 0x00, 0xfc, 0x7f, 0x00, 0xfe, 0xff, 0x00, 0xfe, 0xff, 0x00, 0xfe, 0xff, 0x00, 0xff, 0xff, 0x01, 0xff, 0xff, 0x01}; ////////////////////////////////////////////////////////////////////// // // Print the help message // static void print_usage(const char *progname) { fprintf(stderr, "Usage: %s [-hpw] [infiles]\n", progname); fprintf(stderr, "\t-h : Print this message (help) and exit\n" "\t-p : Enable performance meter\n" "\t-w : Use walk viewer (examiner viewer is default)\n" ); exit(99); } ///////////////////////////////////////////////////////////////////// // // Parse the command line arguments // static void parse_args(int argc, char **argv) { int err = FALSE; // Flag: error in options? int c; showPerfMeter = FALSE; while ((c = getopt(argc, argv, "hpqw")) != -1) { switch(c) { case 'h': // Help err = TRUE; break; case 'p': showPerfMeter = TRUE; break; case 'q': // no-op for backward compatibility only break; case 'w': useWalkViewer = TRUE; break; default: err = TRUE; break; } } // Can't handle -pw, at least right now: if (showPerfMeter && useWalkViewer) { fprintf(stderr, "Sorry, can't show performance when using " "walk viewer. Ignoring -p option\n"); showPerfMeter = FALSE; } /* Handle multiple filenames */ if (optind == argc) { // Act like one argument "-" was given argc++; argv[optind] = "-"; } files.count = argc - optind; files.names = (char **) malloc (files.count * sizeof(char *)); for (int i=0; i