本文整理汇总了C++中SbTime类的典型用法代码示例。如果您正苦于以下问题:C++ SbTime类的具体用法?C++ SbTime怎么用?C++ SbTime使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SbTime类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: wheelEvent
void QXipIvWidget::wheelEvent(QWheelEvent* event)
{
// TODO: Find a solution for Linux and Mac
#if WIN32
SbTime time;
time.setToTimeOfDay();
SoMouseWheelEvent e;
e.setTime(time);
if (event->modifiers() & Qt::ShiftModifier)
e.setShiftDown(TRUE);
if (event->modifiers() & Qt::ControlModifier)
e.setCtrlDown(TRUE);
//#if WIN32
e.setDelta(event->delta());
e.setDelta(event->delta() / 120);
e.setPosition( SbVec2s(event->pos().x(), this->height() - event->pos().y() ) );
//#endif
if (m_sceneManager->processEvent(&e))
{
processDelayQueue();
updateCursor(true);
}
else
{
updateCursor(false);
}
#endif
}
示例2: float
// Documented in superclass.
void
SoOneShot::evaluate(void)
{
SbTime elapsed = this->timeIn.getValue() - this->starttime;
SbTime durationval = this->duration.getValue();
SbTime timeoutval;
float rampval = -999.0f; // Explicit init to kill bogus egcs-2.91.66 warning.
if (this->running) {
if (elapsed < durationval) {
timeoutval = elapsed;
rampval = float(elapsed.getValue()) / float(durationval.getValue());
}
else {
this->running = FALSE;
if (this->flags.getValue() & SoOneShot::HOLD_FINAL) {
this->holdduration = durationval;
this->holdramp = 1.0f;
}
}
}
// Don't use "else" here, as the value of this->running might change
// in the if-block above.
if (!this->running) {
if (this->flags.getValue() & SoOneShot::HOLD_FINAL) {
timeoutval = this->holdduration;
rampval = this->holdramp;
}
else {
timeoutval = 0.0;
rampval = 0.0f;
}
}
// Values should be distributed on evaluate() even though outputs
// are not initially enabled.
//
// enable-settings will be restored again on the next
// inputChanged().
this->timeOut.enable(TRUE);
this->ramp.enable(TRUE);
this->isActive.enable(TRUE);
SO_ENGINE_OUTPUT(isActive, SoSFBool, setValue(this->running));
SO_ENGINE_OUTPUT(timeOut, SoSFTime, setValue(timeoutval));
SO_ENGINE_OUTPUT(ramp, SoSFFloat, setValue(rampval));
}
示例3: SbTime
SbTime
operator *(const SbTime &tm, double s)
//
////////////////////////////////////////////////////////////////////////
{
return SbTime(tm.getValue() * s);
}
示例4: SbVec2s
void QCtkXipSGWidget::mousePressEvent(QMouseEvent *event)
{
if(mInteractingField)
mInteractingField->setValue(1);
// store old pos for delta mode
mOldPos = SbVec2s(event->pos().x(), event->pos().y());
event->accept();
// Pass the QT mouse button event to open inventor
SbTime time;
time.setToTimeOfDay();
SoMouseButtonEvent e;
e.setTime(time);
switch (event->button())
{
default:
case Qt::LeftButton: e.setButton(SoMouseButtonEvent::BUTTON1); break;
case Qt::MidButton: e.setButton(SoMouseButtonEvent::BUTTON2); break;
case Qt::RightButton: e.setButton(SoMouseButtonEvent::BUTTON3); break;
}
if (event->modifiers() & Qt::ShiftModifier)
e.setShiftDown(TRUE);
if (event->modifiers() & Qt::ControlModifier)
e.setCtrlDown(TRUE);
e.setState(SoButtonEvent::DOWN);
e.setPosition(SbVec2s(event->pos().x(), mHeight - event->pos().y()));
if (mSceneManager->processEvent(&e))
{
//processDelayQueue();
//repaint();
updateCursor(true);
}
else
{
updateCursor(false);
}
}
示例5: keyEvent
void QCtkXipSGWidget::keyEvent(QKeyEvent *event)
{
// Pass the QtKeyEvent to open inventor
SoKeyboardEvent e;
SbTime time;
time.setToTimeOfDay();
e.setTime(time);
if (event->modifiers() & Qt::ShiftModifier)
e.setShiftDown(TRUE);
if (event->modifiers() & Qt::ControlModifier)
e.setCtrlDown(TRUE);
if (event->modifiers() & Qt::AltModifier)
e.setAltDown(TRUE);
if(event->type() == QEvent::KeyPress)
e.setState(SoButtonEvent::DOWN);
else if(event->type() == QEvent::KeyRelease)
e.setState(SoButtonEvent::UP);
if(mQtInventorKeyMap.find((Qt::Key)event->key()) != mQtInventorKeyMap.end())
{
e.setKey(mQtInventorKeyMap[(Qt::Key)event->key()]);
}
if(mQtInventorKeyMap.find((Qt::Key)event->nativeVirtualKey()) != mQtInventorKeyMap.end())
{
e.setKey(mQtInventorKeyMap[(Qt::Key)event->nativeVirtualKey()]);
}
event->accept();
if (mSceneManager->processEvent(&e))
{
//repaint();
update();
}
}
示例6: mouseReleaseEvent
void QXipIvWidget::mouseReleaseEvent(QMouseEvent* event)
{
event->accept();
if (m_mouseMode == RESIZE_NONE)
{
SbTime time;
time.setToTimeOfDay();
SoMouseButtonEvent e;
e.setTime(time);
switch (event->button())
{
default:
case Qt::LeftButton: e.setButton(SoMouseButtonEvent::BUTTON1); break;
case Qt::MidButton: e.setButton(SoMouseButtonEvent::BUTTON2); break;
case Qt::RightButton: e.setButton(SoMouseButtonEvent::BUTTON3); break;
}
if (event->modifiers() & Qt::ShiftModifier) e.setShiftDown(TRUE);
if (event->modifiers() & Qt::ControlModifier) e.setCtrlDown(TRUE);
e.setState(SoButtonEvent::UP);
e.setPosition(SbVec2s(event->pos().x(), m_height - event->pos().y()));
if (m_sceneManager->processEvent(&e))
{
processDelayQueue();
updateCursor(true);
}
else
{
updateCursor(false);
}
}
m_mouseMode = RESIZE_NONE;
}
示例7: sosftime_read_value
// Read SbTime from input stream, return TRUE if successful. Used from
// SoSFTime and SoMFTime.
SbBool
sosftime_read_value(SoInput * in, SbTime & t)
{
double val;
if (!in->read(val)) {
SoReadError::post(in, "unable to read floating point value");
return FALSE;
}
if (!coin_finite(val)) {
SoReadError::post(in,
"Detected non-valid floating point number, replacing "
"with 0.0f");
val = 0.0;
// We don't return FALSE, thereby allowing the read process to
// continue, as a convenience for the application programmer.
}
t.setValue(val);
return TRUE;
}
示例8: PUBLIC
//
// checks current time to see if we should start or stop playing
//
void
SoVRMLAudioClipP::timerCB(SoSensor *)
{
SbTime now = SbTime::getTimeOfDay();
SbTime start = PUBLIC(this)->startTime.getValue();
SbTime stop = PUBLIC(this)->stopTime.getValue();
#if COIN_DEBUG && DEBUG_AUDIO
SbString start_str = start.format("%D %h %m %s");
SbString stop_str = stop.format("%D %h %m %s");
SbString now_str = now.format("%D %h %m %s");
#endif // debug
#if COIN_DEBUG && DEBUG_AUDIO
SoDebugError::postInfo("SoVRMLAudioClipP::timerCB", "(timerCB)");
#endif // debug
if (((now>=stop) && (stop>start)) ||
(! SoAudioDevice::instance()->haveSound()) ||
(! SoAudioDevice::instance()->isEnabled()))
{
// we shouldn't be playing now
if (PUBLIC(this)->isActive.getValue())
this->stopPlaying();
return;
}
// if we got this far, ( (now<stop) || (stop<=start) )
if (this->soundHasFinishedPlaying) {
if (PUBLIC(this)->isActive.getValue()) {
// FIXME: perhaps add some additional slack, the size of one buffer? 20021008 thammer.
#if COIN_DEBUG && DEBUG_AUDIO
SoDebugError::postInfo("SoVRMLAudioClipP::timerCB", "soundHasFinishedPlaying");
#endif // debug
this->stopPlaying();
}
return;
}
if (now>=start) {
if (!PUBLIC(this)->isActive.getValue())
this->startPlaying();
}
}
示例9: type
//.........这里部分代码省略.........
case SoKeyboardEvent::UP_ARROW:
case SoKeyboardEvent::RIGHT_ARROW:
case SoKeyboardEvent::DOWN_ARROW:
if (!this->isViewing())
this->setViewing(true);
break;
default:
break;
}
}
// Mouse Button / Spaceball Button handling
if (type.isDerivedFrom(SoMouseButtonEvent::getClassTypeId())) {
const SoMouseButtonEvent * const event = (const SoMouseButtonEvent *) ev;
const int button = event->getButton();
const SbBool press = event->getState() == SoButtonEvent::DOWN ? TRUE : FALSE;
// SoDebugError::postInfo("processSoEvent", "button = %d", button);
switch (button) {
case SoMouseButtonEvent::BUTTON1:
this->lockrecenter = TRUE;
this->button1down = press;
#if 0 // disable to avoid interferences where this key combination is used, too
if (press && ev->wasShiftDown() &&
(this->currentmode != NavigationStyle::SELECTION)) {
this->centerTime = ev->getTime();
float ratio = vp.getViewportAspectRatio();
SbViewVolume vv = viewer->getCamera()->getViewVolume(ratio);
this->panningplane = vv.getPlane(viewer->getCamera()->focalDistance.getValue());
this->lockrecenter = FALSE;
}
else if (!press && ev->wasShiftDown() &&
(this->currentmode != NavigationStyle::SELECTION)) {
SbTime tmp = (ev->getTime() - this->centerTime);
float dci = (float)QApplication::doubleClickInterval()/1000.0f;
// is it just a left click?
if (tmp.getValue() < dci && !this->lockrecenter) {
if (!this->moveToPoint(pos)) {
panToCenter(panningplane, posn);
this->interactiveCountDec();
}
processed = TRUE;
}
}
else
#endif
if (press && (this->currentmode == NavigationStyle::SEEK_WAIT_MODE)) {
newmode = NavigationStyle::SEEK_MODE;
this->seekToPoint(pos); // implicitly calls interactiveCountInc()
processed = TRUE;
}
//else if (press && (this->currentmode == NavigationStyle::IDLE)) {
// this->setViewing(true);
// processed = TRUE;
//}
else if (press && (this->currentmode == NavigationStyle::PANNING ||
this->currentmode == NavigationStyle::ZOOMING)) {
newmode = NavigationStyle::DRAGGING;
this->centerTime = ev->getTime();
processed = TRUE;
}
else if (!press && (this->currentmode == NavigationStyle::DRAGGING)) {
SbTime tmp = (ev->getTime() - this->centerTime);
float dci = (float)QApplication::doubleClickInterval()/1000.0f;
if (tmp.getValue() < dci) {
newmode = NavigationStyle::ZOOMING;
示例10: if
// This function gets called whenever something has happened to any of
// the sensor queues. It starts or reschedules a timer which will
// trigger when a sensor is ripe for plucking.
void
SoGuiP::sensorQueueChanged(void * cbdata)
{
SoSensorManager * sensormanager = SoDB::getSensorManager();
SbTime timevalue;
if (sensormanager->isTimerSensorPending(timevalue)) {
SbTime interval = timevalue - SbTime::getTimeOfDay();
if (interval.getValue() < 0.0) interval.setValue(0.0);
if (SoWinP::timerSensorId != 0) Win32::KillTimer(NULL, SoWinP::timerSensorId);
SoWinP::timerSensorId =
Win32::SetTimer(NULL,
/* ignored because of NULL first argument: */ 0,
interval.getMsecValue(),
(TIMERPROC)SoWinP::timerSensorCB);
}
else if (SoWinP::timerSensorId != 0) {
Win32::KillTimer(NULL, SoWinP::timerSensorId);
SoWinP::timerSensorId = 0;
}
if (sensormanager->isDelaySensorPending()) {
if (SoWinP::idleSensorId == 0) {
SoWinP::idleSensorId =
Win32::SetTimer(NULL,
/* ignored because of NULL first argument: */ 0,
// FIXME: this seems like a rather bogus way
// of setting up a timer to check when the
// system goes idle. Should investigate how
// this actually works, and perhaps if there
// is some other mechanism we could
// use. 20040721 mortene.
0,
(TIMERPROC)SoWinP::idleSensorCB);
}
if (SoWinP::delaySensorId == 0) {
unsigned long timeout = SoDB::getDelaySensorTimeout().getMsecValue();
SoWinP::delaySensorId =
Win32::SetTimer(NULL,
/* ignored because of NULL first argument: */ 0,
timeout,
(TIMERPROC)SoWinP::delaySensorCB);
}
}
else {
if (SoWinP::idleSensorId != 0) {
Win32::KillTimer(NULL, SoWinP::idleSensorId);
SoWinP::idleSensorId = 0;
}
if (SoWinP::delaySensorId != 0) {
Win32::KillTimer(NULL, SoWinP::delaySensorId);
SoWinP::delaySensorId = 0;
}
}
}
示例11: sosftime_write_value
// Write SbTime value to output stream. Used from SoSFTime and
// SoMFTime.
void
sosftime_write_value(SoOutput * out, const SbTime & p)
{
out->write(p.getValue());
}
示例12: parentWidget
void QXipIvWidget::mouseMoveEvent(QMouseEvent* event)
{
QWidget* pWidget = parentWidget()->parentWidget();
// qDebug() << "QXipIvWidget::mouseMoveEvent";
bool onResizeBorder = false;
//if (!event->buttons())
//{
// if ((event->pos().x() > (this->width() - 10)) || (event->pos().y() > (this->height() - 10)))
// {
// if ((event->pos().x() > (this->width() - 10)) || (event->pos().y() > (this->height() - 10)))
// {
// if ((event->pos().x() > (this->width() - 10)) && (event->pos().y() > (this->height() - 10)))
// {
// setCursor(Qt::SizeFDiagCursor);
// onResizeBorder = true;
// }
// else if (event->pos().x() > (this->width() - 10))
// {
// setCursor(Qt::SizeHorCursor);
// onResizeBorder = true;
// }
// else if (event->pos().y() > (this->height() - 10))
// {
// setCursor(Qt::SizeVerCursor);
// onResizeBorder = true;
// }
// }
// }
//}
switch (m_mouseMode)
{
case RESIZE_NONE:
if (!onResizeBorder)
{
event->accept();
SbTime time;
time.setToTimeOfDay();
SoLocation2Event e;
e.setTime(time);
if (event->modifiers() & Qt::ShiftModifier)
e.setShiftDown(TRUE);
if (event->modifiers() & Qt::ControlModifier)
e.setCtrlDown(TRUE);
e.setPosition(SbVec2s(event->pos().x(), m_height - event->pos().y()));
if (m_sceneManager->processEvent(&e))
{
processDelayQueue();
updateCursor(true);
}
else
{
updateCursor(false);
}
} break;
case RESIZE_WIDTH:
{
pWidget->resize(mapTo(pWidget, event->pos()).x() + 3, pWidget->size().height());
event->accept();
} break;
case RESIZE_HEIGHT:
{
pWidget->resize(pWidget->size().width(), mapTo(pWidget, event->pos()).y() + 3);
event->accept();
} break;
case RESIZE_CORNER:
{
pWidget->resize(mapTo(pWidget, event->pos()).x() + 3, mapTo(pWidget, event->pos()).y() + 3);
event->accept();
} break;
}
}
示例13: mousePressEvent
void QXipIvWidget::mousePressEvent(QMouseEvent* event)
{
//m_mouseMode = RESIZE_NONE;
//if ((event->pos().x() > (this->width() - 10)) || (event->pos().y() > (this->height() - 10)))
//{
// //if ((event->pos().x() > (this->width() - 10)) || (event->pos().y() > (this->height() - 10)))
// {
// if ((event->pos().x() > (this->width() - 10)) && (event->pos().y() > (this->height() - 10)))
// {
// m_mouseMode = RESIZE_CORNER;
// setCursor(Qt::SizeFDiagCursor);
// }
// else if (event->pos().x() > (this->width() - 10))
// {
// m_mouseMode = RESIZE_WIDTH;
// setCursor(Qt::SizeHorCursor);
// }
// else if (event->pos().y() > (this->height() - 10))
// {
// m_mouseMode = RESIZE_HEIGHT;
// setCursor(Qt::SizeVerCursor);
// }
// }
// event->accept();
// return;
//}
event->accept();
// Pass the QT mouse button event to open inventor
SbTime time;
time.setToTimeOfDay();
SoMouseButtonEvent e;
e.setTime(time);
switch (event->button())
{
default:
case Qt::LeftButton: e.setButton(SoMouseButtonEvent::BUTTON1); break;
case Qt::MidButton: e.setButton(SoMouseButtonEvent::BUTTON2); break;
case Qt::RightButton: emit mouseRightButtonPressed(); break;
}
if (event->modifiers() & Qt::ShiftModifier)
e.setShiftDown(TRUE);
if (event->modifiers() & Qt::ControlModifier)
e.setCtrlDown(TRUE);
e.setState(SoButtonEvent::DOWN);
e.setPosition(SbVec2s(event->pos().x(), m_height - event->pos().y()));
if (m_sceneManager->processEvent(&e))
{
processDelayQueue();
updateCursor(true);
}
else
{
updateCursor(false);
}
}
示例14: setCursor
void QCtkXipSGWidget::mouseMoveEvent(QMouseEvent *event)
{
bool onResizeBorder = false;
if (!event->buttons())
{
if ((event->pos().x() > (this->width() - 10)) || (event->pos().y() > (this->height() - 10)))
{
if ((event->pos().x() > (this->width() - 10)) || (event->pos().y() > (this->height() - 10)))
{
if ((event->pos().x() > (this->width() - 10)) && (event->pos().y() > (this->height() - 10)))
{
setCursor(Qt::SizeFDiagCursor);
onResizeBorder = true;
}
else if (event->pos().x() > (this->width() - 10))
{
setCursor(Qt::SizeHorCursor);
onResizeBorder = true;
}
else if (event->pos().y() > (this->height() - 10))
{
setCursor(Qt::SizeVerCursor);
onResizeBorder = true;
}
}
}
}
event->accept();
SbTime time;
time.setToTimeOfDay();
// get mouse delta field
//SoSFBool *deltaField = (SoSFBool *) SoDB::getGlobalField("MOUSE_DELTA_MODE");
//if ( deltaField && deltaField->getValue() )
//{
if (mSceneManager && mIsSceneManagerActive)
{
SbTime time;
time.setToTimeOfDay();
//SoLocation2Event event;
//event.setTime(time);
//if (event->modifiers() & Qt::ShiftModifier)
// event.setShiftDown(TRUE);
//if (event->modifiers() & Qt::ControlModifier)
// event.setCtrlDown(TRUE);
SbVec2s pos = SbVec2s(event->pos().x(),event->pos().y());
//SbVec2s delta = pos - mOldPos;
//delta[1] = -delta[1];
mOldPos = pos;
SoLocation2Event e;
e.setTime(time);
if (event->modifiers() & Qt::ShiftModifier)
e.setShiftDown(TRUE);
if (event->modifiers() & Qt::ControlModifier)
e.setCtrlDown(TRUE);
e.setPosition(SbVec2s(event->pos().x(), mHeight - event->pos().y()));
if (mSceneManager->processEvent(&e))
{
//processDelayQueue();
//repaint();
updateCursor(true);
}
else
{
updateCursor(false);
}
}
}
示例15: switch
//.........这里部分代码省略.........
break; \
CASE(MFString,SO__CONCAT(MF,type)): \
for (i = 0; i < ((SoMField *)input)->getNum(); i++) { \
((SoMField *)input)->get1(i, string); \
((SoMField *)outField)->set1(i, string.getString()); \
} \
break
// All types except string:
CONVSTR(BitMask);
CONVSTR(Bool);
CONVSTR(Color);
CONVSTR(Enum);
CONVSTR(Float);
CONVSTR(Int32);
CONVSTR(Matrix);
CONVSTR(Name);
CONVSTR(Node);
CONVSTR(Path);
CONVSTR(Plane);
CONVSTR(Rotation);
CONVSTR(Short);
CONVSTR(UInt32);
CONVSTR(UShort);
CONVSTR(Vec2f);
CONVSTR(Vec3f);
CONVSTR(Vec4f);
#undef CONVSTR
// Special case for time to string; if the time is great enough,
// format as a date:
CASE(SFTime,SFString):
{
SbTime t = ((SoSFTime *)input)->getValue();
if (t.getValue() > 3.15e7) string = t.formatDate();
else string = t.format();
((SoSFString *)outField)->setValue(string);
}
break;
CASE(SFTime,MFString):
{
SbTime t = ((SoSFTime *)input)->getValue();
if (t.getValue() > 3.15e7) string = t.formatDate();
else string = t.format();
((SoMFString *)outField)->set1Value(0, string);
}
break;
CASE(MFTime,SFString):
{
SbTime t = (*((SoMFTime *)input))[0];
if (t.getValue() > 3.15e7) string = t.formatDate();
else string = t.format();
((SoSFString *)outField)->setValue(string);
}
break;
CASE(MFTime,MFString):
{
for (i = 0; i < ((SoMField *)input)->getNum(); i++) {
SbTime t = (*((SoMFTime *)input))[i];
if (t.getValue() > 3.15e7) string = t.formatDate();
else string = t.format();
((SoMFString *)outField)->set1Value(i, string);
}
}
break;
CASE(SFString,SFTime):