本文整理匯總了C++中Duration函數的典型用法代碼示例。如果您正苦於以下問題:C++ Duration函數的具體用法?C++ Duration怎麽用?C++ Duration使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了Duration函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: UTIL_ScreenFade
//-----------------------------------------------------------------------------
// Purpose: Input handler that does the screen fade.
//-----------------------------------------------------------------------------
void CEnvFade::InputFade( inputdata_t &inputdata )
{
int fadeFlags = 0;
if ( m_spawnflags & SF_FADE_IN )
{
fadeFlags |= FFADE_IN;
}
else
{
fadeFlags |= FFADE_OUT;
}
if ( m_spawnflags & SF_FADE_MODULATE )
{
fadeFlags |= FFADE_MODULATE;
}
if ( m_spawnflags & SF_FADE_STAYOUT )
{
fadeFlags |= FFADE_STAYOUT;
}
if ( m_spawnflags & SF_FADE_ONLYONE )
{
if ( inputdata.pActivator->IsNetClient() )
{
UTIL_ScreenFade( inputdata.pActivator, m_clrRender, Duration(), HoldTime(), fadeFlags );
}
}
else
{
UTIL_ScreenFadeAll( m_clrRender, Duration(), HoldTime(), fadeFlags|FFADE_PURGE );
}
m_OnBeginFade.FireOutput( inputdata.pActivator, this );
}
示例2: ROS_INFO
bool ObjectManipulation::placeObject(string arm_name, double x_offset, double y_offset, double z_offset, double max_seconds_wait_for_conclusion) {
if (processing_srv_.response.graspable_objects.empty() || processing_srv_.response.collision_object_names.empty()) {
return false;
}
geometry_msgs::PoseStamped place_location;
place_location.header.frame_id = processing_srv_.response.graspable_objects.at(0).reference_frame_id;
place_location.pose.orientation.w = 1;
place_location.header.stamp = ros::Time::now();
place_location.pose.position.x += x_offset;
place_location.pose.position.y += y_offset;
direction_.header.stamp = ros::Time::now();
direction_.header.frame_id = "base_link";
direction_.vector.x = 0;
direction_.vector.y = 0;
direction_.vector.z = -1;
ROS_INFO("Calling the place action");
object_manipulation_msgs::PlaceGoal place_goal;
place_goal.place_locations.push_back(place_location);
place_goal.collision_object_name = processing_srv_.response.collision_object_names.at(0);
place_goal.collision_support_surface_name = processing_srv_.response.collision_support_surface_name;
place_goal.grasp = pickup_result_.grasp;
place_goal.arm_name = arm_name;
place_goal.place_padding = 0.02;
place_goal.desired_retreat_distance = 0.1;
place_goal.min_retreat_distance = 0.05;
place_goal.approach.direction = direction_;
place_goal.approach.desired_distance = z_offset;
place_goal.approach.min_distance = 0.05;
place_goal.use_reactive_place = false;
place_client_.sendGoal(place_goal);
ROS_INFO("Waiting for the place action...");
if (!place_client_.waitForResult(Duration(max_seconds_wait_for_conclusion))) {
return false;
}
object_manipulation_msgs::PlaceResult place_result = *(place_client_.getResult());
if (place_client_.getState() != actionlib::SimpleClientGoalState::SUCCEEDED) {
ROS_ERROR("Place failed with error code %d", place_result.manipulation_result.value);
return false;
}
ROS_INFO("Object moved");
return true;
}
示例3: Duration
////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value.
void ColumnRecur::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{
if (_style == "default" ||
_style == "duration")
{
minimum = maximum = Duration (task.get ("recur")).formatCompact ().length ();
}
else if (_style == "indicator")
{
if (task.has (_name))
minimum = maximum = context.config.get ("recurrence.indicator").length ();
}
else
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
}
示例4: date
////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value.
void ColumnDue::measure (Task& task, int& minimum, int& maximum)
{
minimum = maximum = 0;
if (task.has (_name))
{
if (_style == "countdown")
{
Date date ((time_t) strtol (task.get (_name).c_str (), NULL, 10));
Date now;
minimum = maximum = Duration (now - date).format ().length ();
}
else
ColumnDate::measure (task, minimum, maximum);
}
}
示例5: TimeToPixels
void TExportZone::TrackOutMarker(BPoint mousePt)
{
// Constrain to out time of cue sheet
uint32 outPixels = TimeToPixels( Duration() - StartTime(), GetCurrentTimeFormat(), GetCurrentResolution());
if (mousePt.x > outPixels)
mousePt.x = outPixels;
// Don't allow overlap with m_InRect
if ( (mousePt.x-kExportSliderWidth) < m_InRect.right)
mousePt.x = m_InRect.right + kExportSliderWidth;
// Save oldRect for redraw
BRect oldRect = m_OutRect;
m_OutRect.right = mousePt.x;
m_OutRect.left = m_OutRect.right - kExportSliderWidth;
// Exit if there is no change in position
if (oldRect == m_OutRect)
return;
// Update m_ExportChannel
m_ExportChannel.right = m_OutRect.left;
// Clean up old position
BRect updateRect = oldRect;
if (m_OutRect.left <= oldRect.left)
{
updateRect.left = m_OutRect.left;
}
else
{
updateRect.right = m_OutRect.right;
}
Draw(updateRect);
// Update CueSheet variable
uint32 newOutTime = StartTime() + PixelsToTime(m_OutRect.right, GetCurrentTimeFormat(), GetCurrentResolution());
m_CueSheetWindow->GetCueSheetView()->SetExportStopTime(newOutTime);
// Update text
m_CueSheetWindow->GetExportTimeView()->DrawOutText();
}
示例6: segment_time_elapsed
MoveSpline::UpdateResult MoveSpline::_updateState(int32& ms_time_diff)
{
if (ms_time_diff < 0)
{
ms_time_diff = 0;
return Result_Arrived;
}
if (Finalized())
{
ms_time_diff = 0;
return Result_Arrived;
}
UpdateResult result = Result_None;
int32 minimal_diff = std::min(ms_time_diff, segment_time_elapsed());
ASSERT(minimal_diff >= 0);
time_passed += minimal_diff;
ms_time_diff -= minimal_diff;
if (time_passed >= next_timestamp())
{
++point_Idx;
if (point_Idx < spline.last())
{
result = Result_NextSegment;
}
else
{
if (spline.isCyclic())
{
point_Idx = spline.first();
time_passed = time_passed % Duration();
result = Result_NextSegment;
}
else
{
_Finalize();
ms_time_diff = 0;
result = Result_Arrived;
}
}
}
return result;
}
示例7: Duration
Duration
Time::operator-(const rclcpp::Time & rhs) const
{
if (rcl_time_.clock_type != rhs.rcl_time_.clock_type) {
throw std::runtime_error("can't subtract times with different time sources");
}
if (rclcpp::sub_will_overflow(rcl_time_.nanoseconds, rhs.rcl_time_.nanoseconds)) {
throw std::overflow_error("time subtraction leads to int64_t overflow");
}
if (rclcpp::sub_will_underflow(rcl_time_.nanoseconds, rhs.rcl_time_.nanoseconds)) {
throw std::underflow_error("time subtraction leads to int64_t underflow");
}
return Duration(rcl_time_.nanoseconds - rhs.rcl_time_.nanoseconds);
}
示例8: assert
//--------------------------------------------------------------------------------------
// Name: GetPacketCumulativeBytesSize()
// Desc: Gets the packet count and the total byte size of the 'dpds' chunk.
//--------------------------------------------------------------------------------------
HRESULT WaveFile::GetPacketCumulativeBytesSize(DWORD* pdwPacketCount, DWORD* pdwBufferSize)
{
assert( m_DpdsChunk.IsValid() );
if (!m_DpdsChunk.IsValid())
return E_HANDLE;
WAVEFORMATEXTENSIBLE wfxFormat;
GetFormat( &wfxFormat );
// Packet count: length of the 'data' chunk divided by number of bytes per packet
*pdwPacketCount = Duration() / wfxFormat.Format.nBlockAlign;
*pdwBufferSize = m_DpdsChunk.GetDataSize();
return S_OK;
}
示例9: DoGameMove
void DoGameMove(GAME *Game, int Move, double Value, double Time) {
if (! IsLegalMove(Game->Board,Move)) FatalError("Illegal move in DoGameMove()");
TurnTime = (Trust && Time >= 0.0) ? Time : Duration(TurnBegin,CurrentTime());
ElapsedTime[Game->Board->Colour>0] += TurnTime;
DoMove(Game->Board,Move);
Game->Move[Game->MoveNo].Move = Move;
Game->Move[Game->MoveNo].Value = Value;
Game->Move[Game->MoveNo].Time = TurnTime;
Game->MoveNo++;
Game->Move[Game->MoveNo].Move = NO_MOVE;
TurnBegin = CurrentTime();
}
示例10: Draw
//-----------------------------------------------------------------------
void DebugNavigator::Draw(DrawingContext & drawingContext)
{
constexpr float minFramerate = 10.0f;
constexpr float maxFramerate = 60.0f;
constexpr std::uint16_t maxHistories = 20;
{
if (clock->TotalGameTime() - duration > Duration(0.2))
{
auto frameRate = clock->FrameRate();
frameRateString = StringFormat("%4.2f fps", frameRate);
frameRates.push_back(MathHelper::Clamp(frameRate, minFramerate, maxFramerate));
if (frameRates.size() > maxHistories)
{
frameRates.pop_front();
}
duration = clock->TotalGameTime();
}
}
auto transform = Transform() * drawingContext.Top();
{
auto graphTransform = Matrix3x2::CreateTranslation(Vector2{0, 16}) * transform;
constexpr std::uint16_t maxGraphHeight = 26;
constexpr float graphMarginLeft = 1.0f;
auto graghWidth = (static_cast<float>(Width()) / maxHistories);
std::int32_t startPosition = graghWidth * (maxHistories - frameRates.size());
std::int32_t graphX = startPosition;
for (auto & frameRate: frameRates)
{
auto amount = ((frameRate - minFramerate) / (maxFramerate - minFramerate));
auto graphHeight = MathHelper::Clamp<std::uint16_t>(maxGraphHeight * amount, 1, maxGraphHeight);
drawingContext.DrawRectangle(graphTransform, Color::CornflowerBlue,
Rectangle(graphX, maxGraphHeight - graphHeight, graghWidth - graphMarginLeft, graphHeight));
graphX += graghWidth;
}
}
drawingContext.DrawString(transform * Matrix3x2::CreateTranslation({0.5f, -2.5f}),
Color::White, FontWeight::Bold, FontSize::Medium, frameRateString);
}
示例11: get_state
void
IBeamTool::set_leading_x (const int x)
{
shared_ptr<TimelineState> state = get_state();
// The line below needs handled differently now; ////////////TODO GTK-3
//
//const bool set_playback_period = dragType == Selection;
TimeVar newStartPoint (state->getViewWindow().x_to_time(x));
Offset selectionLength (pinnedDragTime, newStartPoint);
if (newStartPoint > pinnedDragTime)
newStartPoint=pinnedDragTime; // use the smaller one as selection start
selectionControl (TimeSpan (newStartPoint, Duration(selectionLength)));
}
示例12: AverageFrameLength
int64_t
MP3Demuxer::Duration() const {
if (!mNumParsedFrames) {
return -1;
}
// Assume we know the exact number of frames from the VBR header.
int64_t numFrames = mParser.VBRInfo().NumFrames();
if (numFrames < 0) {
if (mStreamLength < 0) {
// Unknown length, we can't estimate duration.
return -1;
}
numFrames = (mStreamLength - mFirstFrameOffset) / AverageFrameLength();
}
return Duration(numFrames);
}
示例13: parse
static Try<Duration> parse(const std::string& s)
{
// TODO(benh): Support negative durations (i.e., starts with '-').
size_t index = 0;
while (index < s.size()) {
if (isdigit(s[index]) || s[index] == '.') {
index++;
continue;
}
Try<double> value = numify<double>(s.substr(0, index));
if (value.isError()) {
return Error(value.error());
}
const std::string unit = s.substr(index);
if (unit == "ns") {
return Duration(value.get(), NANOSECONDS);
} else if (unit == "us") {
return Duration(value.get(), MICROSECONDS);
} else if (unit == "ms") {
return Duration(value.get(), MILLISECONDS);
} else if (unit == "secs") {
return Duration(value.get(), SECONDS);
} else if (unit == "mins") {
return Duration(value.get(), MINUTES);
} else if (unit == "hrs") {
return Duration(value.get(), HOURS);
} else if (unit == "days") {
return Duration(value.get(), DAYS);
} else if (unit == "weeks") {
return Duration(value.get(), WEEKS);
} else {
return Error(
"Unknown duration unit '" + unit + "'; supported units are"
" 'ns', 'us', 'ms', 'secs', 'mins', 'hrs', 'days', and 'weeks'");
}
}
return Error("Invalid duration '" + s + "'");
}
示例14: switch
Duration Duration::fromString(const QString &s, Format format, bool *ok) {
if (ok) *ok = false;
QRegExp matcher;
Duration tmp;
switch (format) {
case Format_Hour: {
matcher.setPattern("^(\\d*)h(\\d*)m$" );
int pos = matcher.indexIn(s);
if (pos > -1) {
tmp.addHours(matcher.cap(1).toUInt());
tmp.addMinutes(matcher.cap(2).toUInt());
if (ok) *ok = true;
}
break;
}
case Format_DayTime: {
matcher.setPattern("^(\\d*) (\\d*):(\\d*):(\\d*)\\.(\\d*)$" );
int pos = matcher.indexIn(s);
if (pos > -1) {
tmp.addDays(matcher.cap(1).toUInt());
tmp.addHours(matcher.cap(2).toUInt());
tmp.addMinutes(matcher.cap(3).toUInt());
tmp.addSeconds(matcher.cap(4).toUInt());
tmp.addMilliseconds(matcher.cap(5).toUInt());
if (ok) *ok = true;
}
break;
}
case Format_HourFraction: {
// should be in double format
bool res;
double f = QLocale().toDouble(s, &res);
if (ok) *ok = res;
if (res) {
return Duration((qint64)(f)*3600*1000);
}
break;
}
default:
qFatal("Unknown format");
break;
}
return tmp;
}
示例15: date
////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value.
//
void ColumnUDA::measure (Task& task, int& minimum, int& maximum)
{
minimum = maximum = 0;
if (_style == "default")
{
std::string value = task.get (_name);
if (value != "")
{
if (_type == "date")
{
// Determine the output date format, which uses a hierarchy of definitions.
// rc.report.<report>.dateformat
// rc.dateformat.report
// rc.dateformat.
Date date ((time_t) strtol (value.c_str (), NULL, 10));
std::string format = context.config.get ("report." + _report + ".dateformat");
if (format == "")
format = context.config.get ("dateformat.report");
if (format == "")
format = context.config.get ("dateformat");
minimum = maximum = date.toString (format).length ();
}
else if (_type == "duration")
{
minimum = maximum = Duration (value).formatCompact ().length ();
}
else if (_type == "string")
{
std::string stripped = Color::strip (value);
maximum = longestLine (stripped);
minimum = longestWord (stripped);
}
else if (_type == "numeric")
{
minimum = maximum = value.length ();
}
}
}
else
throw format (STRING_COLUMN_BAD_FORMAT, _name, _style);
}