2010-01-21 04:13:33 +08:00
|
|
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2010 Robert Osfield
|
|
|
|
*
|
|
|
|
* This library is open source and may be redistributed and/or modified under
|
|
|
|
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
|
|
|
* (at your option) any later version. The full license is in LICENSE file
|
|
|
|
* included with this distribution, and on the openscenegraph.org website.
|
|
|
|
*
|
|
|
|
* 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
|
|
|
|
* OpenSceneGraph Public License for more details.
|
|
|
|
*/
|
|
|
|
// Written by Wang Rui, (C) 2010
|
|
|
|
|
2010-01-25 19:03:21 +08:00
|
|
|
#ifndef OSGDB_DATATYPES
|
|
|
|
#define OSGDB_DATATYPES
|
2010-01-21 04:13:33 +08:00
|
|
|
|
|
|
|
#include <string>
|
2011-10-22 17:02:18 +08:00
|
|
|
#include <osg/GL>
|
2010-01-21 04:13:33 +08:00
|
|
|
|
|
|
|
namespace osgDB
|
|
|
|
{
|
|
|
|
|
|
|
|
// OSG Header (MD5, 16Bit)
|
|
|
|
#define OSG_HEADER_LOW 0x6C910EA1
|
|
|
|
#define OSG_HEADER_HIGH 0x1AFB4545
|
|
|
|
|
|
|
|
// Reader/writer plugin version
|
From Jean-Sebastien Guay, "osgWidget::WindowManager did nothing in its keyUp event, and in particular didn't call any callbacks. Since I wanted to have callbacks on keyUp, I copied what it does on keyDown, which works for me. I could have just used keyDown and saved myself the trouble, but you know me... :-)
osgWidget::Input:
[Functional changes]
- Previously, the field would be filled with spaces up to its max length, and typing would just replace the spaces. Also, there was a _textLength variable that kept track of the real length of text in the field, since the osgText::Text's length just reflected the length of spaces+text entered. This was not great, as you could still select the spaces with the mouse and it just feels hacky. So I changed it to only contain the text entered, no spaces, and _textLength was removed since it's now redundant (the osgText::Text's length is used instead).
- Fixed the selection size which (visually only) showed one more character selected than what was really selected.
- Fixed selection by dragging the mouse, it would sometimes not select the last character of the string.
- Cursor will now accurately reflect whether insert mode is activated (block cursor) or we're in normal mode (line cursor) like in most editors.
- Implemented Ctrl-X (cut)
- Added a new clear() method that allows the field to be emptied correctly. Useful for a command line interface, for example (hint, hint).
- Mouse and keyboard event handler methods would always return false, which meant selecting with the mouse would also rotate the trackball, and typing an 's' would turn on stats.
[Code cleanup]
- Renamed the (local) _selectionMin and _selectionMax variables which are used in a lot of places, as the underscores would lead to think they were members. Either I called them selection{Min|Max} or delete{Min|Max} where it made more sense.
- Fixed some indenting which was at 3 spaces (inconsistently), I'm sure I didn't catch all the lines where this was the case though.
- Put spaces between variable, operator and value where missing, especially in for()s. Again I only did this where I made changes, there are probably others left.
The result is that delete, backspace, Ctrl-X, Ctrl-C, Ctrl-V, and typing behaviour should now be consistent with text editor conventions, whether insert mode is enabled or not. I hope. :-)
Note, there's a nasty const_cast in there. Why isn't osgText::Font::getGlyph() declared const?
Also, as a note, the current implementation of cut, copy and paste (in addition to being Windows only, yuck) gets and puts the data into an std::string, thus if the osgText::String in the field contains unicode characters I think it won't work correctly. Perhaps someone could implement a proper clipboard class that would be cross-platform and support osgText::String (more precisely other languages like Chinese) correctly? Cut, copy and paste are not critical to what I'm doing so I won't invest the time to do that, but I just thought I'd mention it.
"
2010-09-10 00:49:10 +08:00
|
|
|
const unsigned int PLUGIN_VERSION = 2;
|
2010-01-21 04:13:33 +08:00
|
|
|
|
From Jean-Sebastien Guay, "osgWidget::WindowManager did nothing in its keyUp event, and in particular didn't call any callbacks. Since I wanted to have callbacks on keyUp, I copied what it does on keyDown, which works for me. I could have just used keyDown and saved myself the trouble, but you know me... :-)
osgWidget::Input:
[Functional changes]
- Previously, the field would be filled with spaces up to its max length, and typing would just replace the spaces. Also, there was a _textLength variable that kept track of the real length of text in the field, since the osgText::Text's length just reflected the length of spaces+text entered. This was not great, as you could still select the spaces with the mouse and it just feels hacky. So I changed it to only contain the text entered, no spaces, and _textLength was removed since it's now redundant (the osgText::Text's length is used instead).
- Fixed the selection size which (visually only) showed one more character selected than what was really selected.
- Fixed selection by dragging the mouse, it would sometimes not select the last character of the string.
- Cursor will now accurately reflect whether insert mode is activated (block cursor) or we're in normal mode (line cursor) like in most editors.
- Implemented Ctrl-X (cut)
- Added a new clear() method that allows the field to be emptied correctly. Useful for a command line interface, for example (hint, hint).
- Mouse and keyboard event handler methods would always return false, which meant selecting with the mouse would also rotate the trackball, and typing an 's' would turn on stats.
[Code cleanup]
- Renamed the (local) _selectionMin and _selectionMax variables which are used in a lot of places, as the underscores would lead to think they were members. Either I called them selection{Min|Max} or delete{Min|Max} where it made more sense.
- Fixed some indenting which was at 3 spaces (inconsistently), I'm sure I didn't catch all the lines where this was the case though.
- Put spaces between variable, operator and value where missing, especially in for()s. Again I only did this where I made changes, there are probably others left.
The result is that delete, backspace, Ctrl-X, Ctrl-C, Ctrl-V, and typing behaviour should now be consistent with text editor conventions, whether insert mode is enabled or not. I hope. :-)
Note, there's a nasty const_cast in there. Why isn't osgText::Font::getGlyph() declared const?
Also, as a note, the current implementation of cut, copy and paste (in addition to being Windows only, yuck) gets and puts the data into an std::string, thus if the osgText::String in the field contains unicode characters I think it won't work correctly. Perhaps someone could implement a proper clipboard class that would be cross-platform and support osgText::String (more precisely other languages like Chinese) correctly? Cut, copy and paste are not critical to what I'm doing so I won't invest the time to do that, but I just thought I'd mention it.
"
2010-09-10 00:49:10 +08:00
|
|
|
const int BOOL_SIZE = 1;
|
|
|
|
const int CHAR_SIZE = 1;
|
|
|
|
const int SHORT_SIZE = 2;
|
|
|
|
const int INT_SIZE = 4;
|
|
|
|
const int LONG_SIZE = 4;
|
|
|
|
const int FLOAT_SIZE = 4;
|
|
|
|
const int DOUBLE_SIZE = 8;
|
|
|
|
const int GLENUM_SIZE = 4;
|
2010-01-21 04:13:33 +08:00
|
|
|
|
From Jean-Sebastien Guay, "osgWidget::WindowManager did nothing in its keyUp event, and in particular didn't call any callbacks. Since I wanted to have callbacks on keyUp, I copied what it does on keyDown, which works for me. I could have just used keyDown and saved myself the trouble, but you know me... :-)
osgWidget::Input:
[Functional changes]
- Previously, the field would be filled with spaces up to its max length, and typing would just replace the spaces. Also, there was a _textLength variable that kept track of the real length of text in the field, since the osgText::Text's length just reflected the length of spaces+text entered. This was not great, as you could still select the spaces with the mouse and it just feels hacky. So I changed it to only contain the text entered, no spaces, and _textLength was removed since it's now redundant (the osgText::Text's length is used instead).
- Fixed the selection size which (visually only) showed one more character selected than what was really selected.
- Fixed selection by dragging the mouse, it would sometimes not select the last character of the string.
- Cursor will now accurately reflect whether insert mode is activated (block cursor) or we're in normal mode (line cursor) like in most editors.
- Implemented Ctrl-X (cut)
- Added a new clear() method that allows the field to be emptied correctly. Useful for a command line interface, for example (hint, hint).
- Mouse and keyboard event handler methods would always return false, which meant selecting with the mouse would also rotate the trackball, and typing an 's' would turn on stats.
[Code cleanup]
- Renamed the (local) _selectionMin and _selectionMax variables which are used in a lot of places, as the underscores would lead to think they were members. Either I called them selection{Min|Max} or delete{Min|Max} where it made more sense.
- Fixed some indenting which was at 3 spaces (inconsistently), I'm sure I didn't catch all the lines where this was the case though.
- Put spaces between variable, operator and value where missing, especially in for()s. Again I only did this where I made changes, there are probably others left.
The result is that delete, backspace, Ctrl-X, Ctrl-C, Ctrl-V, and typing behaviour should now be consistent with text editor conventions, whether insert mode is enabled or not. I hope. :-)
Note, there's a nasty const_cast in there. Why isn't osgText::Font::getGlyph() declared const?
Also, as a note, the current implementation of cut, copy and paste (in addition to being Windows only, yuck) gets and puts the data into an std::string, thus if the osgText::String in the field contains unicode characters I think it won't work correctly. Perhaps someone could implement a proper clipboard class that would be cross-platform and support osgText::String (more precisely other languages like Chinese) correctly? Cut, copy and paste are not critical to what I'm doing so I won't invest the time to do that, but I just thought I'd mention it.
"
2010-09-10 00:49:10 +08:00
|
|
|
const int ID_BYTE_ARRAY = 0;
|
|
|
|
const int ID_UBYTE_ARRAY = 1;
|
|
|
|
const int ID_SHORT_ARRAY = 2;
|
|
|
|
const int ID_USHORT_ARRAY = 3;
|
|
|
|
const int ID_INT_ARRAY = 4;
|
|
|
|
const int ID_UINT_ARRAY = 5;
|
|
|
|
const int ID_FLOAT_ARRAY = 6;
|
|
|
|
const int ID_DOUBLE_ARRAY = 7;
|
|
|
|
const int ID_VEC2B_ARRAY = 8;
|
|
|
|
const int ID_VEC3B_ARRAY = 9;
|
|
|
|
const int ID_VEC4B_ARRAY = 10;
|
|
|
|
const int ID_VEC4UB_ARRAY = 11;
|
|
|
|
const int ID_VEC2S_ARRAY = 12;
|
|
|
|
const int ID_VEC3S_ARRAY = 13;
|
|
|
|
const int ID_VEC4S_ARRAY = 14;
|
|
|
|
const int ID_VEC2_ARRAY = 15;
|
|
|
|
const int ID_VEC3_ARRAY = 16;
|
|
|
|
const int ID_VEC4_ARRAY = 17;
|
|
|
|
const int ID_VEC2D_ARRAY = 18;
|
|
|
|
const int ID_VEC3D_ARRAY = 19;
|
|
|
|
const int ID_VEC4D_ARRAY = 20;
|
2013-06-28 16:57:42 +08:00
|
|
|
const int ID_VEC2UB_ARRAY = 21;
|
|
|
|
const int ID_VEC3UB_ARRAY = 22;
|
|
|
|
const int ID_VEC2US_ARRAY = 23;
|
|
|
|
const int ID_VEC3US_ARRAY = 24;
|
|
|
|
const int ID_VEC4US_ARRAY = 25;
|
2010-01-21 04:13:33 +08:00
|
|
|
|
2013-09-11 23:44:08 +08:00
|
|
|
const int ID_VEC2I_ARRAY = 26;
|
|
|
|
const int ID_VEC3I_ARRAY = 27;
|
|
|
|
const int ID_VEC4I_ARRAY = 28;
|
|
|
|
const int ID_VEC2UI_ARRAY = 29;
|
|
|
|
const int ID_VEC3UI_ARRAY = 30;
|
|
|
|
const int ID_VEC4UI_ARRAY = 31;
|
|
|
|
|
From Jean-Sebastien Guay, "osgWidget::WindowManager did nothing in its keyUp event, and in particular didn't call any callbacks. Since I wanted to have callbacks on keyUp, I copied what it does on keyDown, which works for me. I could have just used keyDown and saved myself the trouble, but you know me... :-)
osgWidget::Input:
[Functional changes]
- Previously, the field would be filled with spaces up to its max length, and typing would just replace the spaces. Also, there was a _textLength variable that kept track of the real length of text in the field, since the osgText::Text's length just reflected the length of spaces+text entered. This was not great, as you could still select the spaces with the mouse and it just feels hacky. So I changed it to only contain the text entered, no spaces, and _textLength was removed since it's now redundant (the osgText::Text's length is used instead).
- Fixed the selection size which (visually only) showed one more character selected than what was really selected.
- Fixed selection by dragging the mouse, it would sometimes not select the last character of the string.
- Cursor will now accurately reflect whether insert mode is activated (block cursor) or we're in normal mode (line cursor) like in most editors.
- Implemented Ctrl-X (cut)
- Added a new clear() method that allows the field to be emptied correctly. Useful for a command line interface, for example (hint, hint).
- Mouse and keyboard event handler methods would always return false, which meant selecting with the mouse would also rotate the trackball, and typing an 's' would turn on stats.
[Code cleanup]
- Renamed the (local) _selectionMin and _selectionMax variables which are used in a lot of places, as the underscores would lead to think they were members. Either I called them selection{Min|Max} or delete{Min|Max} where it made more sense.
- Fixed some indenting which was at 3 spaces (inconsistently), I'm sure I didn't catch all the lines where this was the case though.
- Put spaces between variable, operator and value where missing, especially in for()s. Again I only did this where I made changes, there are probably others left.
The result is that delete, backspace, Ctrl-X, Ctrl-C, Ctrl-V, and typing behaviour should now be consistent with text editor conventions, whether insert mode is enabled or not. I hope. :-)
Note, there's a nasty const_cast in there. Why isn't osgText::Font::getGlyph() declared const?
Also, as a note, the current implementation of cut, copy and paste (in addition to being Windows only, yuck) gets and puts the data into an std::string, thus if the osgText::String in the field contains unicode characters I think it won't work correctly. Perhaps someone could implement a proper clipboard class that would be cross-platform and support osgText::String (more precisely other languages like Chinese) correctly? Cut, copy and paste are not critical to what I'm doing so I won't invest the time to do that, but I just thought I'd mention it.
"
2010-09-10 00:49:10 +08:00
|
|
|
const int ID_DRAWARRAYS = 50;
|
|
|
|
const int ID_DRAWARRAY_LENGTH = 51;
|
|
|
|
const int ID_DRAWELEMENTS_UBYTE = 52;
|
|
|
|
const int ID_DRAWELEMENTS_USHORT = 53;
|
|
|
|
const int ID_DRAWELEMENTS_UINT = 54;
|
2010-01-21 04:13:33 +08:00
|
|
|
|
|
|
|
// Used by BEGIN_BRACKET and END_BRACKET
|
From Jean-Sebastien Guay, "osgWidget::WindowManager did nothing in its keyUp event, and in particular didn't call any callbacks. Since I wanted to have callbacks on keyUp, I copied what it does on keyDown, which works for me. I could have just used keyDown and saved myself the trouble, but you know me... :-)
osgWidget::Input:
[Functional changes]
- Previously, the field would be filled with spaces up to its max length, and typing would just replace the spaces. Also, there was a _textLength variable that kept track of the real length of text in the field, since the osgText::Text's length just reflected the length of spaces+text entered. This was not great, as you could still select the spaces with the mouse and it just feels hacky. So I changed it to only contain the text entered, no spaces, and _textLength was removed since it's now redundant (the osgText::Text's length is used instead).
- Fixed the selection size which (visually only) showed one more character selected than what was really selected.
- Fixed selection by dragging the mouse, it would sometimes not select the last character of the string.
- Cursor will now accurately reflect whether insert mode is activated (block cursor) or we're in normal mode (line cursor) like in most editors.
- Implemented Ctrl-X (cut)
- Added a new clear() method that allows the field to be emptied correctly. Useful for a command line interface, for example (hint, hint).
- Mouse and keyboard event handler methods would always return false, which meant selecting with the mouse would also rotate the trackball, and typing an 's' would turn on stats.
[Code cleanup]
- Renamed the (local) _selectionMin and _selectionMax variables which are used in a lot of places, as the underscores would lead to think they were members. Either I called them selection{Min|Max} or delete{Min|Max} where it made more sense.
- Fixed some indenting which was at 3 spaces (inconsistently), I'm sure I didn't catch all the lines where this was the case though.
- Put spaces between variable, operator and value where missing, especially in for()s. Again I only did this where I made changes, there are probably others left.
The result is that delete, backspace, Ctrl-X, Ctrl-C, Ctrl-V, and typing behaviour should now be consistent with text editor conventions, whether insert mode is enabled or not. I hope. :-)
Note, there's a nasty const_cast in there. Why isn't osgText::Font::getGlyph() declared const?
Also, as a note, the current implementation of cut, copy and paste (in addition to being Windows only, yuck) gets and puts the data into an std::string, thus if the osgText::String in the field contains unicode characters I think it won't work correctly. Perhaps someone could implement a proper clipboard class that would be cross-platform and support osgText::String (more precisely other languages like Chinese) correctly? Cut, copy and paste are not critical to what I'm doing so I won't invest the time to do that, but I just thought I'd mention it.
"
2010-09-10 00:49:10 +08:00
|
|
|
const int INDENT_VALUE = 2;
|
2010-01-21 04:13:33 +08:00
|
|
|
|
|
|
|
// Used by the writeImage/readImage parameter
|
From Jean-Sebastien Guay, "osgWidget::WindowManager did nothing in its keyUp event, and in particular didn't call any callbacks. Since I wanted to have callbacks on keyUp, I copied what it does on keyDown, which works for me. I could have just used keyDown and saved myself the trouble, but you know me... :-)
osgWidget::Input:
[Functional changes]
- Previously, the field would be filled with spaces up to its max length, and typing would just replace the spaces. Also, there was a _textLength variable that kept track of the real length of text in the field, since the osgText::Text's length just reflected the length of spaces+text entered. This was not great, as you could still select the spaces with the mouse and it just feels hacky. So I changed it to only contain the text entered, no spaces, and _textLength was removed since it's now redundant (the osgText::Text's length is used instead).
- Fixed the selection size which (visually only) showed one more character selected than what was really selected.
- Fixed selection by dragging the mouse, it would sometimes not select the last character of the string.
- Cursor will now accurately reflect whether insert mode is activated (block cursor) or we're in normal mode (line cursor) like in most editors.
- Implemented Ctrl-X (cut)
- Added a new clear() method that allows the field to be emptied correctly. Useful for a command line interface, for example (hint, hint).
- Mouse and keyboard event handler methods would always return false, which meant selecting with the mouse would also rotate the trackball, and typing an 's' would turn on stats.
[Code cleanup]
- Renamed the (local) _selectionMin and _selectionMax variables which are used in a lot of places, as the underscores would lead to think they were members. Either I called them selection{Min|Max} or delete{Min|Max} where it made more sense.
- Fixed some indenting which was at 3 spaces (inconsistently), I'm sure I didn't catch all the lines where this was the case though.
- Put spaces between variable, operator and value where missing, especially in for()s. Again I only did this where I made changes, there are probably others left.
The result is that delete, backspace, Ctrl-X, Ctrl-C, Ctrl-V, and typing behaviour should now be consistent with text editor conventions, whether insert mode is enabled or not. I hope. :-)
Note, there's a nasty const_cast in there. Why isn't osgText::Font::getGlyph() declared const?
Also, as a note, the current implementation of cut, copy and paste (in addition to being Windows only, yuck) gets and puts the data into an std::string, thus if the osgText::String in the field contains unicode characters I think it won't work correctly. Perhaps someone could implement a proper clipboard class that would be cross-platform and support osgText::String (more precisely other languages like Chinese) correctly? Cut, copy and paste are not critical to what I'm doing so I won't invest the time to do that, but I just thought I'd mention it.
"
2010-09-10 00:49:10 +08:00
|
|
|
const int IMAGE_INLINE_DATA = 0;
|
|
|
|
const int IMAGE_INLINE_FILE = 1;
|
|
|
|
const int IMAGE_EXTERNAL = 2;
|
|
|
|
const int IMAGE_WRITE_OUT = 3;
|
2010-01-21 04:13:33 +08:00
|
|
|
|
|
|
|
struct ObjectGLenum
|
|
|
|
{
|
|
|
|
ObjectGLenum( GLenum value=0 ) : _value(value) {}
|
|
|
|
ObjectGLenum( const ObjectGLenum& copy ) : _value(copy._value) {}
|
|
|
|
void set( GLenum e ) { _value = e; }
|
|
|
|
GLenum get() const { return _value; }
|
|
|
|
GLenum _value;
|
|
|
|
};
|
|
|
|
#define GLENUM(value) osgDB::ObjectGLenum(value)
|
|
|
|
#define DEF_GLENUM(var) osgDB::ObjectGLenum var;
|
|
|
|
|
2010-10-04 23:23:19 +08:00
|
|
|
class ObjectProperty
|
2010-01-21 04:13:33 +08:00
|
|
|
{
|
2010-10-04 23:23:19 +08:00
|
|
|
public:
|
2012-04-05 21:53:47 +08:00
|
|
|
ObjectProperty() : _value(0), _mapProperty(false) {}
|
|
|
|
|
2010-01-21 04:13:33 +08:00
|
|
|
ObjectProperty( const char* name, int value=0, bool useMap=false )
|
|
|
|
: _name(name), _value(value), _mapProperty(useMap) {}
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2010-01-21 04:13:33 +08:00
|
|
|
ObjectProperty( const ObjectProperty& copy )
|
|
|
|
: _name(copy._name), _value(copy._value), _mapProperty(copy._mapProperty) {}
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2012-04-05 21:53:47 +08:00
|
|
|
ObjectProperty& operator()( const char* name )
|
2010-01-25 19:03:21 +08:00
|
|
|
{ _name = name; return *this; }
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2010-01-25 19:03:21 +08:00
|
|
|
void set( int v ) { _value = v; }
|
|
|
|
int get() const { return _value; }
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2010-01-21 04:13:33 +08:00
|
|
|
std::string _name;
|
|
|
|
int _value;
|
|
|
|
bool _mapProperty;
|
|
|
|
};
|
|
|
|
#define MAPPEE(pairName, value) osgDB::ObjectProperty(#pairName, value, true)
|
|
|
|
#define DEF_MAPPEE(pairName, var) osgDB::ObjectProperty var(#pairName, 0, true);
|
|
|
|
|
2010-10-04 23:23:19 +08:00
|
|
|
class ObjectMark
|
2010-01-21 04:13:33 +08:00
|
|
|
{
|
2010-10-04 23:23:19 +08:00
|
|
|
public:
|
2012-04-05 21:53:47 +08:00
|
|
|
ObjectMark() : _indentDelta(0) {}
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2010-01-21 04:13:33 +08:00
|
|
|
ObjectMark( const ObjectMark& copy )
|
|
|
|
: _name(copy._name), _indentDelta(copy._indentDelta) {}
|
2012-03-22 01:36:20 +08:00
|
|
|
|
2012-04-05 21:53:47 +08:00
|
|
|
void set( const char* name, int delta=0 )
|
|
|
|
{ _name = name, _indentDelta = delta; }
|
|
|
|
|
2010-01-21 04:13:33 +08:00
|
|
|
std::string _name;
|
|
|
|
int _indentDelta;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|