Main Page   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

MyMaterialPalette.h

00001 /*
00002  *
00003  *  Copyright (C) 2000 Silicon Graphics, Inc.  All Rights Reserved. 
00004  *
00005  *  This library is free software; you can redistribute it and/or
00006  *  modify it under the terms of the GNU Lesser General Public
00007  *  License as published by the Free Software Foundation; either
00008  *  version 2.1 of the License, or (at your option) any later version.
00009  *
00010  *  This library is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  *  Lesser General Public License for more details.
00014  *
00015  *  Further, this software is distributed without any warranty that it is
00016  *  free of the rightful claim of any third person regarding infringement
00017  *  or the like.  Any license provided herein, whether implied or
00018  *  otherwise, applies only to this software file.  Patent licenses, if
00019  *  any, provided herein do not apply to combinations of this program with
00020  *  other software, or any other product whatsoever.
00021  * 
00022  *  You should have received a copy of the GNU Lesser General Public
00023  *  License along with this library; if not, write to the Free Software
00024  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00025  *
00026  *  Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
00027  *  Mountain View, CA  94043, or:
00028  * 
00029  *  http://www.sgi.com 
00030  * 
00031  *  For further information regarding this notice, see: 
00032  * 
00033  *  http://oss.sgi.com/projects/GenInfo/NoticeExplan/
00034  *
00035  */
00036 
00037 //  -*- C++ -*-
00038 
00039 /*
00040  * Copyright (C) 1991-93   Silicon Graphics, Inc.
00041  *
00042  _______________________________________________________________________
00043  ______________  S I L I C O N   G R A P H I C S   I N C .  ____________
00044  |
00045  |   $Revision: 1.1 $
00046  |
00047  |   Description:
00048  |      Component which displays a palette of materials. 
00049  |
00050  |   Classes:   MyMaterialPalette
00051  |
00052  |   Author(s): Alain Dumesny
00053  |
00054  ______________  S I L I C O N   G R A P H I C S   I N C .  ____________
00055  _______________________________________________________________________
00056  */
00057 
00058 #ifndef _SO_XT_MATERIAL_PALETTE_GIZMO_H_
00059 #define _SO_XT_MATERIAL_PALETTE_GIZMO_H_
00060 
00061 #include <X11/Intrinsic.h>
00062 #include <Xm/Xm.h>
00063 #include <Inventor/Xt/SoXtComponent.h>
00064 #include <Inventor/misc/SoCallbackList.h>
00065 #include <Inventor/SbPList.h>
00066 
00067 class SoMaterial;
00068 class SoSwitch;
00069 class SoXtRenderArea;
00070 class SoNode;
00071 class MySimpleMaterialEditor;
00072 class SoAction;
00073 class SoXtInputFocus;
00074 class SoXtClipboard;
00075 class SoTranslation;
00076 class SoPathList;
00077 
00078 struct MaterialNameStruct;
00079 
00080 // callback function prototypes
00081 typedef void MyMaterialPaletteCB(void *userData, const SoMaterial *mtl);
00082 
00084 //
00085 //  Class: MyMaterialPalette
00086 //
00087 //
00089 
00090 // C-api: prefix=SoXtMtlPalGiz
00091 class MyMaterialPalette : public SoXtComponent {
00092   public:
00093     // pass the home directory of the material palettes as dir
00094     MyMaterialPalette(
00095         Widget parent = NULL,
00096         const char *name = NULL, 
00097         SbBool buildInsideParent = TRUE, 
00098         const char *dir = NULL);
00099    ~MyMaterialPalette();
00100 
00101     // deselect the currently selected item in the palette, if something
00102     // is selected. This should be called when the thing the palette
00103     // is affecting doesn't match any of the palette's choices (because
00104     // the palette is read only and not an editor).
00105     void    deselectCurrentItem();
00106     
00107     // Callbacks - register functions that will be called whenever the user
00108     // chooses a new material from the palette.
00109     // (This component cannot be attached to a database - it is read only)
00110     // C-api: name=addCB
00111     void    addCallback(
00112                 MyMaterialPaletteCB *f,
00113                 void *userData = NULL)
00114         { callbackList.addCallback((SoCallbackListCB *) f, userData);}
00115 
00116     // C-api: name=removeCB
00117     void    removeCallback(
00118                 MyMaterialPaletteCB *f,
00119                 void *userData = NULL)
00120         { callbackList.removeCallback((SoCallbackListCB *) f, userData); }
00121     
00122     // redefine these to also show/hide material editor
00123     virtual void    show();
00124     virtual void    hide();
00125     
00126   protected:
00127 
00128     // This constructor takes a boolean whether to build the widget now.
00129     // Subclasses can pass FALSE, then call MyMaterialPalette::buildWidget()
00130     // when they are ready for it to be built.
00131     SoEXTENDER
00132     MyMaterialPalette(
00133         Widget parent,
00134         const char *name, 
00135         SbBool buildInsideParent, 
00136         const char *dir, 
00137         SbBool buildNow);
00138     
00139     // redefine these
00140     virtual const char *    getDefaultWidgetName() const;
00141     virtual const char *    getDefaultTitle() const;
00142     virtual const char *    getDefaultIconTitle() const;
00143     
00144   private:
00145     char            *paletteDir;
00146     SoCallbackList  callbackList;
00147     SoXtRenderArea  *ra;
00148     Widget          *widgetList;
00149     SbPList         paletteList;
00150     MaterialNameStruct *mtlNames;
00151     int             curPalette;
00152     SoSwitch        *itemSwitch;
00153     int             selectedItem, currentItem;
00154     MySimpleMaterialEditor *matEditor;
00155     SoXtInputFocus  *focus;
00156     Time            prevTime;
00157     SoTranslation   *overlayTrans1, *overlayTrans2;
00158     
00159     void            createSceneGraph();
00160     void            getPaletteNamesAndLoad();
00161     void            loadPaletteItems();
00162     SoNode          *getMaterialFromFile(char *file);
00163     SbBool          handleEvent(XAnyEvent *);
00164     void            updateMaterialName();
00165     void            updateFileMenu();
00166     void            updateEditMenu();
00167     void            findCurrentItem(int x, int y);
00168     void            updateOverlayFeedback();
00169     void            updateWindowTitle();
00170     void            createNewPalette(char *name);
00171     void            savePalette();
00172     void            savePaletteAs(char *name);
00173     void            switchPalette();
00174     
00175     // dialog routines and vars
00176     SbBool          paletteChanged;
00177     int             whatToDoNext, nextPalette;
00178     void            createSaveDialog();
00179     void            createDeleteDialog(char *title, char *str1, char *str2);
00180     void            createPromptDialog(char *title, char *str);
00181     static void     saveDialogCB(Widget, MyMaterialPalette *, XmAnyCallbackStruct *);
00182     static void     promptDialogCB(Widget, MyMaterialPalette *, XmAnyCallbackStruct *);
00183     static void     deleteDialogCB(Widget, MyMaterialPalette *, XmAnyCallbackStruct *);
00184     
00185     // component callbacks
00186     static SbBool   raEventCB(void *, XAnyEvent *);
00187     static void     matEditorCB(void *pt, MySimpleMaterialEditor *ed);
00188     
00189     // motif static callbacks
00190     static void     menuCB(Widget, int, XmAnyCallbackStruct *);
00191     static void     paletteMenuCB(Widget, int, void *);
00192 
00193   protected:   
00194     // Build routines
00195     Widget          buildWidget(Widget parent);
00196     Widget          buildMenu(Widget parent);
00197     void            buildPaletteSubMenu();
00198     Widget          buildPaletteMenuEntry(int id);
00199  
00200   private:   
00201     // cut/copy/paste/delete vars and functions
00202     SoXtClipboard   *clipboard;
00203     void            deleteCurrentMaterial();
00204     static void     pasteDone(void *, SoPathList *);
00205   
00206     // this is called by both constructors
00207     void constructorCommon(const char *dir, SbBool buildNow);
00208 };
00209 
00210 #endif // _SO_XT_MATERIAL_PALETTE_GIZMO_H_

Generated on Fri Oct 26 23:38:09 2001 for bicobj-intersection by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001