Fixed line endings

This commit is contained in:
Robert Osfield
2016-01-19 11:35:13 +00:00
parent 30dc6a9428
commit e8fd414661
4 changed files with 68 additions and 68 deletions

View File

@@ -1,14 +1,14 @@
/* -*-c++-*-
/* -*-c++-*-
* Copyright (C) 2008 Cedric Pinson <mornifle@plopbyte.net>
*
* 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
* 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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*
* Authors:
@@ -24,18 +24,18 @@
#include <osgDB/ReadFile>
#include <osgAnimation/BasicAnimationManager>
class AnimtkViewerModelController
class AnimtkViewerModelController
{
public:
typedef std::vector<std::string> AnimationMapVector;
static AnimtkViewerModelController& instance()
static AnimtkViewerModelController& instance()
{
static AnimtkViewerModelController avmc;
return avmc;
}
static bool setModel(osgAnimation::BasicAnimationManager* model)
static bool setModel(osgAnimation::BasicAnimationManager* model)
{
AnimtkViewerModelController& self = instance();
self._model = model;
@@ -48,7 +48,7 @@ public:
return true;
}
bool list()
bool list()
{
std::cout << "Animation List:" << std::endl;
for(osgAnimation::AnimationMap::iterator it = _map.begin(); it != _map.end(); it++)
@@ -56,9 +56,9 @@ public:
return true;
}
bool play()
bool play()
{
if(_focus < _amv.size())
if(_focus < _amv.size())
{
std::cout << "Play " << _amv[_focus] << std::endl;
_model->playAnimation(_map[_amv[_focus]].get());
@@ -68,44 +68,44 @@ public:
return false;
}
bool stop()
bool stop()
{
if(_focus < _amv.size())
if(_focus < _amv.size())
{
std::cout << "Stop " << _amv[_focus] << std::endl;
_model->stopAnimation(_map[_amv[_focus]].get());
return true;
}
return false;
}
}
bool next()
bool next()
{
_focus = (_focus + 1) % _map.size();
std::cout << "Current now is " << _amv[_focus] << std::endl;
return true;
}
bool previous()
bool previous()
{
_focus = (_map.size() + _focus - 1) % _map.size();
std::cout << "Current now is " << _amv[_focus] << std::endl;
return true;
}
bool playByName(const std::string& name)
bool playByName(const std::string& name)
{
for(unsigned int i = 0; i < _amv.size(); i++) if(_amv[i] == name) _focus = i;
_model->playAnimation(_map[name].get());
return true;
}
const std::string& getCurrentAnimationName() const
const std::string& getCurrentAnimationName() const
{
return _amv[_focus];
}
const AnimationMapVector& getAnimationMap() const
const AnimationMapVector& getAnimationMap() const
{
return _amv;
}

View File

@@ -1,4 +1,4 @@
/* -*-c++-*-
/* -*-c++-*-
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
@@ -31,7 +31,7 @@ class AnimtkViewerGUI: public osgWidget::WindowManager {
protected:
osgWidget::Widget* _createButton(const std::string&);
bool _buttonPush(osgWidget::Event&);
bool _listMouseHover(osgWidget::Event&);

View File

@@ -1,14 +1,14 @@
/* -*-c++-*-
/* -*-c++-*-
* Copyright (C) 2008 Cedric Pinson <mornifle@plopbyte.net>
*
* 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
* 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
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*
* Authors:
@@ -26,7 +26,7 @@
const std::string IMAGE_PATH = "osgWidget/";
template <class T>
struct Sampler: public osg::Drawable::UpdateCallback
struct Sampler: public osg::Drawable::UpdateCallback
{
T _motion;
Sampler() {
@@ -35,28 +35,28 @@ struct Sampler: public osg::Drawable::UpdateCallback
typedef Sampler<osgAnimation::OutQuadMotion> WidgetSampler;
struct ButtonFunctor: public WidgetSampler
struct ButtonFunctor: public WidgetSampler
{
float _direction;
float _previous;
const float _speed;
ButtonFunctor(): _speed(5) { _direction = -_speed; _previous = 0;}
bool enter(osgWidget::Event&)
{
_direction = _speed;
_direction = _speed;
return true;
}
bool leave(osgWidget::Event&)
{
_direction = -_speed;
_direction = -_speed;
return true;
}
void update(osg::NodeVisitor* nv , osg::Drawable* geom)
void update(osg::NodeVisitor* nv , osg::Drawable* geom)
{
const osg::FrameStamp* f = nv->getFrameStamp();
float dt = f->getSimulationTime() - _previous;
@@ -67,7 +67,7 @@ struct ButtonFunctor: public WidgetSampler
void update(float t, osgWidget::Widget* w)
{
if (!w) return;
_motion.update(t*_direction);
_motion.update(t*_direction);
float val = _motion.getValue()*0.5;
val += 0.5;
if (val >= 1.0)
@@ -76,7 +76,7 @@ struct ButtonFunctor: public WidgetSampler
}
};
struct LabelFunctor: public WidgetSampler
struct LabelFunctor: public WidgetSampler
{
float _previous;
bool _active;
@@ -86,7 +86,7 @@ struct LabelFunctor: public WidgetSampler
osgAnimation::OutCubicMotion _scaleSampler;
LabelFunctor():
_fadeOutTime(1.5f)
_fadeOutTime(1.5f)
{
_previous = 0.0f;
_active = false;
@@ -94,7 +94,7 @@ struct LabelFunctor: public WidgetSampler
_scaleSampler = osgAnimation::OutCubicMotion(0.5, 1.0, 1.0);
}
void setActive(bool active)
void setActive(bool active)
{
_active = active;
@@ -103,7 +103,7 @@ struct LabelFunctor: public WidgetSampler
_scaleSampler.reset();
}
void update(osg::NodeVisitor* nv , osg::Drawable* geom)
void update(osg::NodeVisitor* nv , osg::Drawable* geom)
{
const osg::FrameStamp* f = nv->getFrameStamp();
@@ -118,7 +118,7 @@ struct LabelFunctor: public WidgetSampler
updateScale(dt, dynamic_cast<osgWidget::Label*>(geom));
}
void update(float t, osgWidget::Label* w)
void update(float t, osgWidget::Label* w)
{
if(!w) return;
@@ -134,7 +134,7 @@ struct LabelFunctor: public WidgetSampler
w->setFontColor(osg::Vec4(0.0f, 0.0f, 0.0f, (1.0f - val) * 0.7f));
}
void updateScale(float t, osgWidget::Label* w)
void updateScale(float t, osgWidget::Label* w)
{
_scaleSampler.update(t);
float val = _scaleSampler.getValue();
@@ -146,14 +146,14 @@ struct LabelFunctor: public WidgetSampler
};
struct ListFunctor: public osg::NodeCallback
struct ListFunctor: public osg::NodeCallback
{
float _previous;
int _direction;
osgAnimation::InQuadMotion _transformSampler;
ListFunctor()
ListFunctor()
{
_direction = 1;
_previous = 0;
@@ -161,14 +161,14 @@ struct ListFunctor: public osg::NodeCallback
_transformSampler.update(1.0f);
}
void toggleShown()
void toggleShown()
{
if(_direction == 1) _direction = -1;
else _direction = 1;
}
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
{
const osg::FrameStamp* f = nv->getFrameStamp();
@@ -195,13 +195,13 @@ struct ListFunctor: public osg::NodeCallback
};
// This is a temporary hack to "prevent" dragging on Widgets and Windows.
bool eatDrag(osgWidget::Event&)
bool eatDrag(osgWidget::Event&)
{
return true;
}
AnimtkViewerGUI::AnimtkViewerGUI(osgViewer::View* view, float w, float h, unsigned int mask):
osgWidget::WindowManager(view, w, h, mask, 0)
osgWidget::WindowManager(view, w, h, mask, 0)
{
_createButtonBox();
_createLabelBox();
@@ -226,10 +226,10 @@ AnimtkViewerGUI::AnimtkViewerGUI(osgViewer::View* view, float w, float h, unsign
_buttonBox->resizeAdd(0.0f, 10.0f);
}
osgWidget::Widget* AnimtkViewerGUI::_createButton(const std::string& name)
osgWidget::Widget* AnimtkViewerGUI::_createButton(const std::string& name)
{
osgWidget::Widget* b = new osgWidget::Widget(name, 64.0f, 64.0f);
if(!b) return 0;
b->setImage(IMAGE_PATH + name + ".png", true);
@@ -237,7 +237,7 @@ osgWidget::Widget* AnimtkViewerGUI::_createButton(const std::string& name)
ButtonFunctor* bt = new ButtonFunctor();
b->setUpdateCallback(bt);
b->addCallback(new osgWidget::Callback(&ButtonFunctor::enter, bt, osgWidget::EVENT_MOUSE_ENTER));
b->addCallback(new osgWidget::Callback(&ButtonFunctor::leave, bt, osgWidget::EVENT_MOUSE_LEAVE));
b->addCallback(new osgWidget::Callback(&AnimtkViewerGUI::_buttonPush, this, osgWidget::EVENT_MOUSE_PUSH));
@@ -246,7 +246,7 @@ osgWidget::Widget* AnimtkViewerGUI::_createButton(const std::string& name)
return b;
}
bool AnimtkViewerGUI::_listMouseHover(osgWidget::Event& ev)
bool AnimtkViewerGUI::_listMouseHover(osgWidget::Event& ev)
{
osgWidget::Label* l = dynamic_cast<osgWidget::Label*>(ev.getWidget());
@@ -259,13 +259,13 @@ bool AnimtkViewerGUI::_listMouseHover(osgWidget::Event& ev)
else if(ev.type == osgWidget::EVENT_MOUSE_PUSH) {
AnimtkViewerModelController::instance().playByName(ev.getWidget()->getName());
}
else return false;
return true;
}
bool AnimtkViewerGUI::_buttonPush(osgWidget::Event& ev)
bool AnimtkViewerGUI::_buttonPush(osgWidget::Event& ev)
{
if(!ev.getWidget()) return false;
@@ -285,7 +285,7 @@ bool AnimtkViewerGUI::_buttonPush(osgWidget::Event& ev)
else if(name == "stop") mc.stop();
else if(name == "next")
else if(name == "next")
{
mc.next();
@@ -293,21 +293,21 @@ bool AnimtkViewerGUI::_buttonPush(osgWidget::Event& ev)
l->setLabel(mc.getCurrentAnimationName());
lf->setActive(true);
}
else if(name == "back")
else if(name == "back")
{
mc.previous();
l->setFontColor(osg::Vec4(0.0f, 0.0f, 0.0f, 0.7f));
l->setLabel(mc.getCurrentAnimationName());
lf->setActive(true);
}
else if(name == "pause")
else if(name == "pause")
{
}
else if(name == "open")
else if(name == "open")
{
ListFunctor* lsf = dynamic_cast<ListFunctor*>(_listBox->getUpdateCallback());
@@ -321,7 +321,7 @@ bool AnimtkViewerGUI::_buttonPush(osgWidget::Event& ev)
return true;
}
void AnimtkViewerGUI::_createButtonBox()
void AnimtkViewerGUI::_createButtonBox()
{
_buttonBox = new osgWidget::Box("buttonBox", osgWidget::Box::HORIZONTAL);
@@ -345,12 +345,12 @@ void AnimtkViewerGUI::_createButtonBox()
_buttonBox->addWidget(open);
_buttonBox->addWidget(osg::clone(space, "space1", osg::CopyOp::DEEP_COPY_ALL));
_buttonBox->getBackground()->setColor(0.0f, 0.0f, 0.0f, 0.7f);
_buttonBox->setEventMask(osgWidget::EVENT_MASK_MOUSE_DRAG);
_buttonBox->addCallback(new osgWidget::Callback(&eatDrag, osgWidget::EVENT_MOUSE_DRAG));
}
void AnimtkViewerGUI::_createListBox()
void AnimtkViewerGUI::_createListBox()
{
_listBox = new osgWidget::Box("listBox", osgWidget::Box::VERTICAL);
@@ -362,7 +362,7 @@ void AnimtkViewerGUI::_createListBox()
AnimtkViewerModelController::AnimationMapVector::const_iterator i = amv.begin();
i != amv.end();
i++
)
)
{
osgWidget::Label* label = new osgWidget::Label(*i);
@@ -387,12 +387,12 @@ void AnimtkViewerGUI::_createListBox()
_listBox->getBackground()->setColor(0.0f, 0.0f, 0.0f, 0.7f);
}
void AnimtkViewerGUI::_createLabelBox()
void AnimtkViewerGUI::_createLabelBox()
{
_labelBox = new osgWidget::Box("labelBox", osgWidget::Box::VERTICAL);
osgWidget::Label* label = new osgWidget::Label("label");
label->setFont("fonts/Vera.ttf");
label->setFontSize(50);
label->setFontColor(0.0f, 0.0f, 0.0f, 0.7f);

View File

@@ -1,4 +1,4 @@
/* -*-c++-*-
/* -*-c++-*-
* Copyright (C) 2008 Cedric Pinson <mornifle@plopbyte.net>
*
* This program is free software; you can redistribute it and/or modify
@@ -16,7 +16,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* Authors:
*
*
* Cedric Pinson <mornifle@plopbyte.net>
*
*/
@@ -32,7 +32,7 @@ AnimtkKeyEventHandler::AnimtkKeyEventHandler()
_actionKeys[Prev] = '[';
}
void AnimtkKeyEventHandler::printUsage() const
void AnimtkKeyEventHandler::printUsage() const
{
std::cout << (char) _actionKeys.find(Help)->second << " for Help" << std::endl;
std::cout << (char) _actionKeys.find(List)->second << " for List" << std::endl;
@@ -46,13 +46,13 @@ bool AnimtkKeyEventHandler::handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIA
osg::Object*, osg::NodeVisitor*)
{
AnimtkViewerModelController& mc = AnimtkViewerModelController::instance();
if(ea.getEventType() == osgGA::GUIEventAdapter::KEYDOWN)
if(ea.getEventType() == osgGA::GUIEventAdapter::KEYDOWN)
{
if (ea.getKey() == _actionKeys[List]) return mc.list();
else if (ea.getKey() == _actionKeys[Play]) return mc.play();
else if (ea.getKey() == _actionKeys[Next]) return mc.next();
else if (ea.getKey() == _actionKeys[Prev]) return mc.previous();
else if (ea.getKey() == _actionKeys[Help])
else if (ea.getKey() == _actionKeys[Help])
{
printUsage();
return true;