Text archives Help
- From: bigler@sci.utah.edu
- To: manta@sci.utah.edu
- Subject: [MANTA] r1312 - in trunk: Engine/PixelSamplers UserInterface
- Date: Tue, 20 Mar 2007 10:08:13 -0700 (MST)
Author: bigler
Date: Tue Mar 20 10:08:12 2007
New Revision: 1312
Modified:
trunk/Engine/PixelSamplers/TimeViewSampler.cc
trunk/Engine/PixelSamplers/TimeViewSampler.h
trunk/UserInterface/XWindowUI.cc
Log:
Engine/PixelSamplers/TimeViewSampler.cc
Engine/PixelSamplers/TimeViewSampler.h
Added toggleTimeView and changeScale functions.
UserInterface/XWindowUI.cc
Added callbacks to increase/decrease the scale of the
TimeViewSampler.
Moved the guts of toggleTimeView to TimeViewSampler.
Modified: trunk/Engine/PixelSamplers/TimeViewSampler.cc
==============================================================================
--- trunk/Engine/PixelSamplers/TimeViewSampler.cc (original)
+++ trunk/Engine/PixelSamplers/TimeViewSampler.cc Tue Mar 20 10:08:12
2007
@@ -4,6 +4,7 @@
#include <Interface/Fragment.h>
#include <Interface/RayPacket.h>
#include <Interface/Renderer.h>
+#include <Interface/MantaInterface.h>
#include <MantaSSE.h>
#include <Core/Util/Args.h>
#include <Core/Exceptions/IllegalArgument.h>
@@ -114,5 +115,37 @@
void TimeViewSampler::setActive(bool activeOn)
{
active = activeOn;
+}
+
+// This will turn on and off the timeView display on the
+// manta_interface. Both parameters must be non-NULL. If
+// non-NULL the function returns the TimeViewSampler associated
+// with the manta_interface, otherwise it returns timeView.
+TimeViewSampler*
+TimeViewSampler::toggleTimeView(MantaInterface* manta_interface,
+ TimeViewSampler* timeView)
+{
+ ASSERT(manta_interface != NULL);
+ ASSERT(timeView != NULL);
+ PixelSampler* ps = manta_interface->getPixelSampler();
+ // Check to see if there is a TimeViewSampler already running
+ TimeViewSampler* tvps = dynamic_cast<TimeViewSampler*>(ps);
+ if (tvps != NULL) {
+ // We have a winner. Let's swap it out.
+ timeView = tvps;
+ ps = tvps->getPixelSampler();
+ // If the child is NULL, don't stuff it back in.
+ if (ps != NULL) {
+ manta_interface->setPixelSampler(ps);
+ } else {
+ cerr << "TimeViewSampler has no child, so it can't be turned off\n";
+ }
+ } else {
+ // The pixel sampler in the engine isn't a TimeViewSampler, so
+ // let's make it a child of one.
+ timeView->setPixelSampler(ps);
+ manta_interface->setPixelSampler(timeView);
+ }
+ return timeView;
}
Modified: trunk/Engine/PixelSamplers/TimeViewSampler.h
==============================================================================
--- trunk/Engine/PixelSamplers/TimeViewSampler.h (original)
+++ trunk/Engine/PixelSamplers/TimeViewSampler.h Tue Mar 20 10:08:12
2007
@@ -9,10 +9,12 @@
#include <sgi_stl_warnings_on.h>
namespace Manta {
- using namespace std;
+
+ class MantaInterface;
+
class TimeViewSampler : public PixelSampler {
public:
- TimeViewSampler(const vector<string>& args);
+ TimeViewSampler(const std::vector<std::string>& args);
virtual ~TimeViewSampler();
// From PixelSampler
@@ -25,7 +27,7 @@
// For the factory interface, but it shouldn't really be called
// from the factory anyway, since there isn't a mechanism in the
// factory for child classes.
- static PixelSampler* create(const vector<string>& args);
+ static PixelSampler* create(const std::vector<std::string>& args);
// New methods
void setPixelSampler(PixelSampler* new_child);
@@ -36,6 +38,19 @@
void setActive(bool activeOn);
bool getActive() { return active; }
+
+ //////////////////////////////////////
+ // User interface helpers
+
+ // This will turn on and off the timeView display on the
+ // manta_interface. Both parameters must be non-NULL. If
+ // non-NULL the function returns the TimeViewSampler associated
+ // with the manta_interface, otherwise it returns timeView.
+ static TimeViewSampler* toggleTimeView(MantaInterface* manta_interface,
+ TimeViewSampler* timeView);
+
+ // Multiplies the scale by the factor.
+ void changeScale(ColorComponent factor) { scale *= factor; }
private:
TimeViewSampler(const TimeViewSampler&);
TimeViewSampler& operator=(const TimeViewSampler&);
Modified: trunk/UserInterface/XWindowUI.cc
==============================================================================
--- trunk/UserInterface/XWindowUI.cc (original)
+++ trunk/UserInterface/XWindowUI.cc Tue Mar 20 10:08:12 2007
@@ -506,6 +506,12 @@
register_key(0, XStringToKeysym("t"),
"time profile display",
Callback::create(this, &XWindowUI::timeView_keyboard));
+ register_key(ControlMask, XStringToKeysym("t"),
+ "time profile scale increase",
+ Callback::create(this, &XWindowUI::timeView_keyboard));
+ register_key(ControlMask, XStringToKeysym("T"),
+ "time profile scale decrease",
+ Callback::create(this, &XWindowUI::timeView_keyboard));
register_key(0, XStringToKeysym("Escape"),
"quit after this frame, press again to immediately quit",
Callback::create(this, &XWindowUI::quitkey));
@@ -644,39 +650,38 @@
void XWindowUI::toggleTimeView()
{
- PixelSampler* ps = rtrt_interface->getPixelSampler();
- // Check to see if there is a TimeViewSampler already running
- TimeViewSampler* tvps = dynamic_cast<TimeViewSampler*>(ps);
- if (tvps != NULL) {
- // We have a winner. Let's swap it out.
+ TimeViewSampler* currentTimeView =
TimeViewSampler::toggleTimeView(rtrt_interface, timeView);
+ if (timeView != currentTimeView) {
// TODO: (bigler) should we delete the old one?
- timeView = tvps;
- ps = tvps->getPixelSampler();
- // If the child is NULL, don't stuff it back in.
- if (ps != NULL) {
- rtrt_interface->setPixelSampler(ps);
- } else {
- cerr << "TimeViewSampler has no child, so it can't be turned off\n";
- }
- } else {
- // The pixel sampler in the engine isn't a TimeViewSampler, so
- // let's make it a child of one.
- if (timeView == NULL) {
- // Allocate one
- timeView = new TimeViewSampler(vector<string>());
- }
- timeView->setPixelSampler(ps);
- rtrt_interface->setPixelSampler(timeView);
+ timeView = currentTimeView;
}
}
-void XWindowUI::timeView_keyboard(unsigned int /*state*/,
- unsigned long /*key*/,
+void XWindowUI::timeView_keyboard(unsigned int state,
+ unsigned long key,
int /*channel*/)
{
- rtrt_interface->addTransaction("TimeView toggle",
- Callback::create(this,
-
&XWindowUI::toggleTimeView));
+ if (timeView == NULL) {
+ // We are in an uninitialized state. Check to see if we can grab
+ // a TimeViewSampler from the MantaInterface or if we need to
+ // allocate one.
+ timeView =
dynamic_cast<TimeViewSampler*>(rtrt_interface->getPixelSampler());
+ if (timeView == NULL)
+ timeView = new TimeViewSampler(vector<string>());
+ }
+ if (state & ControlMask) {
+ ColorComponent factor = static_cast<ColorComponent>(1.1);
+ if(key == XStringToKeysym("T"))
+ factor = 1/factor;
+ rtrt_interface->addTransaction("TimeView scale up",
+ Callback::create(timeView,
+
&TimeViewSampler::changeScale,
+ factor));
+ } else {
+ rtrt_interface->addTransaction("TimeView toggle",
+ Callback::create(this,
+
&XWindowUI::toggleTimeView));
+ }
}
void XWindowUI::output_camera(unsigned int, unsigned long, int channel)
- [MANTA] r1312 - in trunk: Engine/PixelSamplers UserInterface, bigler, 03/20/2007
Archive powered by MHonArc 2.6.16.