• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ glib::TimeVal类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中glib::TimeVal的典型用法代码示例。如果您正苦于以下问题:C++ TimeVal类的具体用法?C++ TimeVal怎么用?C++ TimeVal使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了TimeVal类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: update

bool ViewProgress::update (const double value, bool take_priority)
{
  // Don't allow progress to go backward
  if (value < m_bar_cur)
    return do_continue;

  m_bar_cur = CLAMP(value, 0, 1.0);
  m_bar->set_fraction(value / m_bar_max);
  ostringstream o;
  if(floor(value) != value && floor(m_bar_max) != m_bar_max)
    o.precision(1);
  else
    o.precision(0);
  o << fixed << value <<"/"<< m_bar_max;
  m_bar->set_text(o.str());
  if (to_terminal) {
    int perc = (int(m_bar->get_fraction()*100));
    cerr << m_label->get_label() << " " << o.str() << " -- " << perc << "%              \r";
  }

  if (value > 0) {
    Glib::TimeVal now;
    now.assign_current_time();
    const double used = (now - start_time).as_double(); // seconds
    const double total = used * m_bar_max  / value;
    const long left = (long)(total-used);
    m_label->set_label(label+" ("+timeleft_str(left)+")");
  }

  if (take_priority)
    while( gtk_events_pending () )
      gtk_main_iteration ();
  Gtk::Main::iteration(false);
  return do_continue;
}
开发者ID:13793297073,项目名称:ERICLI,代码行数:35,代码来源:progress.cpp


示例2: animate

bool Forest::animate(GlView & view)
{
    Glib::TimeVal delta = m_model.m_mainWindow.time();
    delta.subtract(m_lastUpdate);
    m_lastUpdate = m_model.m_mainWindow.time();
    m_cal3dModel.onUpdate(delta.as_double());
    return true;
}
开发者ID:alriddoch,项目名称:equator,代码行数:8,代码来源:Forest.cpp


示例3: AutoArrange

// rearrange unselected shapes in random sequence
bool Model::AutoArrange(vector<Gtk::TreeModel::Path> &path)
{
  // all shapes
  vector<Shape*>   allshapes;
  vector<Matrix4d> transforms;
  objtree.get_all_shapes(allshapes, transforms);

  // selected shapes
  vector<Shape*>   selshapes;
  vector<Matrix4d> seltransforms;
  objtree.get_selected_shapes(path, selshapes, seltransforms);

  // get unselected shapes
  vector<Shape*>   unselshapes;
  vector<Matrix4d> unseltransforms;

  for(uint s=0; s < allshapes.size(); s++) {
    bool issel = false;
    for(uint ss=0; ss < selshapes.size(); ss++)
      if (selshapes[ss] == allshapes[s]) {
	issel = true; break;
      }
    if (!issel) {
      unselshapes.    push_back(allshapes[s]);
      unseltransforms.push_back(transforms[s]);
    }
  }

  // find place for unselected shapes
  int num = unselshapes.size();
  vector<int> rand_seq(num,1); // 1,1,1...
  partial_sum(rand_seq.begin(), rand_seq.end(), rand_seq.begin()); // 1,2,3,...,N

  Glib::TimeVal timeval;
  timeval.assign_current_time();
  srandom((unsigned long)(timeval.as_double()));
  random_shuffle(rand_seq.begin(), rand_seq.end()); // shuffle

  for(int s=0; s < num; s++) {
    int index = rand_seq[s]-1;
    // use selshapes as vector to fill up
    Vector3d trans = FindEmptyLocation(selshapes, seltransforms, unselshapes[index]);
    selshapes.push_back(unselshapes[index]);
    seltransforms.push_back(unseltransforms[index]); // basic transform, not shape
    selshapes.back()->transform3D.move(trans);
    CalcBoundingBoxAndCenter();
  }
  ModelChanged();
  return true;
}
开发者ID:semiLab,项目名称:repsnapper,代码行数:51,代码来源:model.cpp


示例4: draw_geometry

void Shape::draw_geometry(uint max_triangles)
{

  bool listDraw = (max_triangles == 0); // not in preview mode
  bool haveList = gl_List >= 0;

  if (!listDraw && haveList) {
    if (gl_List>=0)
      glDeleteLists(gl_List,1);
    gl_List = -1;
    haveList = false;
  }
  if (listDraw && !haveList) {
    gl_List = glGenLists(1);
    glNewList(gl_List, GL_COMPILE);
  }
  if (!listDraw || !haveList) {
	uint step = 1;
	if (max_triangles>0) step = floor(triangles.size()/max_triangles);
	step = max((uint)1,step);

	glBegin(GL_TRIANGLES);
	for(size_t i=0;i<triangles.size();i+=step)
	{
		glNormal3dv(triangles[i].Normal);
		glVertex3dv(triangles[i].A);
		glVertex3dv(triangles[i].B);
		glVertex3dv(triangles[i].C);
	}
	glEnd();
  }
  if (listDraw && !haveList) {
    glEndList();
  }

  if (listDraw && gl_List >= 0) { // have stored list
    Glib::TimeVal starttime, endtime;
    if (!slow_drawing) {
      starttime.assign_current_time();
    }
    glCallList(gl_List);
    if (!slow_drawing) {
      endtime.assign_current_time();
      Glib::TimeVal usedtime = endtime-starttime;
      if (usedtime.as_double() > 0.2) slow_drawing = true;
    }
    return;
  }
}
开发者ID:13793297073,项目名称:ERICLI,代码行数:49,代码来源:shape.cpp


示例5: stop

void ViewProgress::stop (const char *label)
{
  if (to_terminal) {
    Glib::TimeVal now;
    now.assign_current_time();
    const int time_used = (int) round((now - start_time).as_double()); // seconds
    cerr << m_label->get_label() << " -- " << _(" done in ") << time_used << _(" seconds") << "       " << endl;
  }
  this->label = label;
  m_label->set_label (label);
  m_bar_cur = m_bar_max;
  m_bar->set_fraction(1.0);
  m_box->hide();
  Gtk::Main::iteration(false);
}
开发者ID:13793297073,项目名称:ERICLI,代码行数:15,代码来源:progress.cpp


示例6: vComputeFrameskip

void Window::vComputeFrameskip(int _iRate)
{
    static Glib::TimeVal uiLastTime;
    static int iFrameskipAdjust = 0;

    Glib::TimeVal uiTime;
    uiTime.assign_current_time();

    if (m_bWasEmulating) {
        if (m_bAutoFrameskip) {
            Glib::TimeVal uiDiff = uiTime - uiLastTime;
            const int iWantedSpeed = 100;
            int iSpeed = iWantedSpeed;

            if (uiDiff != Glib::TimeVal(0, 0)) {
                iSpeed = (1000000 / _iRate) / (uiDiff.as_double() * 1000);
            }

            if (iSpeed >= iWantedSpeed - 2) {
                iFrameskipAdjust++;
                if (iFrameskipAdjust >= 3) {
                    iFrameskipAdjust = 0;
                    if (systemFrameSkip > 0) {
                        systemFrameSkip--;
                    }
                }
            } else {
                if (iSpeed < iWantedSpeed - 20) {
                    iFrameskipAdjust -= ((iWantedSpeed - 10) - iSpeed) / 5;
                } else if (systemFrameSkip < 9) {
                    iFrameskipAdjust--;
                }

                if (iFrameskipAdjust <= -4) {
                    iFrameskipAdjust = 0;
                    if (systemFrameSkip < 9) {
                        systemFrameSkip++;
                    }
                }
            }
        }
    } else {
        m_bWasEmulating = true;
    }

    uiLastTime = uiTime;
}
开发者ID:bsantos,项目名称:visualboyadvance-m,代码行数:47,代码来源:window.cpp


示例7: lock

unsigned long Gobby::GSelector::get_timeout(const net6::socket& sock) const
{
	Glib::RecMutex::Lock lock(*m_mutex);
	map_type::const_iterator iter = m_map.find(&sock);

	// No timeout set for this socket
	if(iter == m_map.end() ) return 0;
	if(!iter->second.time_conn.connected() ) return 0;

	// Returns the remaining time for the timeout to be elapsed
	Glib::TimeVal val;
	val.assign_current_time();
	val -= iter->second.timeout_begin;

	unsigned long elapsed = (val.tv_sec * 1000 + val.tv_usec / 1000);
	if(elapsed >= iter->second.timeout) return 1;

	return iter->second.timeout - elapsed;
}
开发者ID:bb-generation,项目名称:gobby,代码行数:19,代码来源:gselector.cpp


示例8: restart

bool ViewProgress::restart (const char *label, double max)
{
  if (!do_continue) return false;
  //m_box->show();
  if (to_terminal) {
    Glib::TimeVal now;
    now.assign_current_time();
    const int time_used = (int) round((now - start_time).as_double()); // seconds
    cerr << m_label->get_label() << " -- " << _(" done in ") << time_used << _(" seconds") << "       " << endl;
  }
  m_bar_max = max;
  this->label = label;
  m_label->set_label (label);
  m_bar_cur = 0.0;
  m_bar->set_fraction(0.0);
  start_time.assign_current_time();
  //g_main_context_iteration(NULL,false);
  Gtk::Main::iteration(false);
  return true;
}
开发者ID:13793297073,项目名称:ERICLI,代码行数:20,代码来源:progress.cpp


示例9: waitUntilConstructed

bool ASObject::waitUntilConstructed(unsigned long maxwait_ms)
{
	Mutex::Lock lock(constructionMutex);

	if(isConstructed())
		return true;

	// No need to loop over wait() because the construction state
	// will change only once from false to true.
	if(maxwait_ms==0)
	{
		constructionSignal.wait(constructionMutex);
		return true;
	}
	else
	{
		Glib::TimeVal waitEnd;
		waitEnd.assign_current_time();
		waitEnd.add_milliseconds(maxwait_ms);
		return constructionSignal.timed_wait(constructionMutex, waitEnd);
	}
}
开发者ID:lu-zero,项目名称:lightspark,代码行数:22,代码来源:asobject.cpp


示例10: MakeText

void GCode::MakeText(string &GcodeTxt,
		     const Settings &settings,
		     ViewProgress * progress)
{
  string GcodeStart = settings.GCode.getStartText();
  string GcodeLayer = settings.GCode.getLayerText();
  string GcodeEnd   = settings.GCode.getEndText();

	double lastE = -10;
	double lastF = 0; // last Feedrate (can be omitted when same)
	Vector3d pos(0,0,0);
	Vector3d LastPos(-10,-10,-10);
	std::stringstream oss;

	Glib::Date date;
	date.set_time_current();
	Glib::TimeVal time;
	time.assign_current_time();
	GcodeTxt += "; GCode by Repsnapper, "+
	  date.format_string("%a, %x") +
	  //time.as_iso8601() +
	  "\n";

	GcodeTxt += "\n; Startcode\n"+GcodeStart + "; End Startcode\n\n";

	layerchanges.clear();
	if (progress) progress->restart(_("Collecting GCode"), commands.size());
	int progress_steps=(int)(commands.size()/100);
	if (progress_steps==0) progress_steps=1;

	for (uint i = 0; i < commands.size(); i++) {
	  char E_letter;
	  if (settings.Slicing.UseTCommand) // use first extruder's code for all extuders
	    E_letter = settings.Extruders[0].GCLetter[0];
	  else
	    E_letter = settings.Extruders[commands[i].extruder_no].GCLetter[0];
	  if (progress && i%progress_steps==0 && !progress->update(i)) break;

	  if ( commands[i].Code == LAYERCHANGE ) {
	    layerchanges.push_back(i);
	    if (GcodeLayer.length()>0)
	      GcodeTxt += "\n; Layerchange GCode\n" + GcodeLayer +
		"; End Layerchange GCode\n\n";
	  }

	  if ( commands[i].where.z() < 0 )  {
	    cerr << i << " Z < 0 "  << commands[i].info() << endl;
	  }
	  else {
	    GcodeTxt += commands[i].GetGCodeText(LastPos, lastE, lastF,
						 settings.Slicing.RelativeEcode,
						 E_letter,
						 settings.Hardware.SpeedAlways) + "\n";
	  }
	}

	GcodeTxt += "\n; End GCode\n" + GcodeEnd + "\n";

	buffer->set_text (GcodeTxt);

	// save zpos line numbers for faster finding
	buffer_zpos_lines.clear();
	uint blines = buffer->get_line_count();
	for (uint i = 0; i < blines; i++) {
	  const string line = getLineAt(buffer, i);
	  if (line.find("Z") != string::npos ||
	      line.find("z") != string::npos)
	    buffer_zpos_lines.push_back(i);
	}

	if (progress) progress->stop();

}
开发者ID:Funny-DK,项目名称:repsnapper,代码行数:73,代码来源:gcode.cpp


示例11: systemGetClock

uint32_t systemGetClock()
{
    Glib::TimeVal time;
    time.assign_current_time();
    return time.as_double() * 1000;
}
开发者ID:bsantos,项目名称:visualboyadvance-m,代码行数:6,代码来源:system.cpp


示例12: ConvertToGCode

void Model::ConvertToGCode()
{
  if (is_calculating) {
    return;
  }
  is_calculating=true;

  // default:
  settings.SelectExtruder(0);

  Glib::TimeVal start_time;
  start_time.assign_current_time();

  gcode.clear();

  GCodeState state(gcode);

  Infill::clearPatterns();

  Vector3d printOffset  = settings.getPrintMargin();
  double   printOffsetZ = printOffset.z();

  // Make Layers
  lastlayer = NULL;


  Slice();

  //CleanupLayers();

  MakeShells();

  if (settings.get_boolean("Slicing","DoInfill") &&
      !settings.get_boolean("Slicing","NoTopAndBottom") &&
      (settings.get_double("Slicing","SolidThickness") > 0 ||
       settings.get_integer("Slicing","ShellCount") > 0))
    // not bridging when support
    MakeUncoveredPolygons( settings.get_boolean("Slicing","MakeDecor"),
			   !settings.get_boolean("Slicing","NoBridges") &&
			   !settings.get_boolean("Slicing","Support") );

  if (settings.get_boolean("Slicing","Support"))
    // easier before having multiplied uncovered bottoms
    MakeSupportPolygons(settings.get_double("Slicing","SupportWiden"));

  MakeFullSkins(); // must before multiplied uncovered bottoms

  MultiplyUncoveredPolygons();

  if (settings.get_boolean("Slicing","Skirt"))
    MakeSkirt();

  CalcInfill();

  if (settings.get_boolean("Raft","Enable"))
    {
      printOffset += Vector3d (settings.get_double("Raft","Size"), 0);
      MakeRaft (state, printOffsetZ); // printOffsetZ will have height of raft added
    }

  state.ResetLastWhere(Vector3d(0,0,0));
  uint count =  layers.size();

  m_progress->start (_("Making Lines"), count+1);

  state.AppendCommand(MILLIMETERSASUNITS,  false, _("Millimeters"));
  state.AppendCommand(ABSOLUTEPOSITIONING, false, _("Absolute Pos"));
  if (settings.get_boolean("Slicing","RelativeEcode"))
    state.AppendCommand(RELATIVE_ECODE, false, _("Relative E Code"));
  else
    state.AppendCommand(ABSOLUTE_ECODE, false, _("Absolute E Code"));

  bool cont = true;
  vector<PLine3> plines;
  bool farthestStart = settings.get_boolean("Slicing","FarthestLayerStart");
  Vector3d start = state.LastPosition();
  for (uint p=0; p<count; p++) {
    cont = (m_progress->update(p)) ;
    if (!cont) break;
    // cerr << "GCode layer " << (p+1) << " of " << count
    // 	 << " offset " << printOffsetZ
    // 	 << " have commands: " <<commands.size()
    // 	 << " start " << start <<  endl;;
    // try {
    if (farthestStart) {
      // Vector2d randstart = layers[p]->getRandomPolygonPoint();
      // start.set(randstart.x(), randstart.y());
      const Vector2d fartheststart = layers[p]->getFarthestPolygonPoint(start);
      start.set(fartheststart.x(), fartheststart.y());
    }
    layers[p]->MakePrintlines(start,
			      plines,
			      printOffsetZ,
			      settings);
    // } catch (Glib::Error &e) {
    //   error("GCode Error:", (e.what()).c_str());
    // }
    // if (layers[p]->getPrevious() != NULL)
    //   cerr << p << ": " <<layers[p]->LayerNo << " prev: "
    // 	   << layers[p]->getPrevious()->LayerNo << endl;
//.........这里部分代码省略.........
开发者ID:maurerpe,项目名称:repsnapper,代码行数:101,代码来源:model_slice.cpp


示例13: loadConfiguration

bool SimVoteWindow::loadConfiguration(std::string pass)
{
	bool loginOk = false;

	if (VotingCentersWrapper::getInstance()->isInstall())
	{
		VotingCenter votingCenter;
		VotingCentersWrapper::getInstance()->getInstallationVotingCenter(votingCenter);
		votingCenterName = votingCenter.getCode();
	}

	std::cout << "Center : " << votingCenterName << std::endl;

	loginOk = MachineOperationManager::getInstance()->authentication(votingCenterName, pass, true);

	//Load precalculate other info needed for the VM
	try
	{
		if(loginOk)

		{

		loginOk = false;

		electoralConfiguration->loadAllData();
		Smartmatic::SAES::Printing::VotePrintDocument::calculateMax(electoralConfiguration);

		std::string openingDateTime = electoralConfiguration->getVotingDevice()->getFirstVotingDevice().getOperation_modes().getOperation_mode()[0].getOpening_date_time();
		std::string closingDateTime = electoralConfiguration->getVotingDevice()->getFirstVotingDevice().getOperation_modes().getOperation_mode()[0].getClosing_date_time();

		Glib::TimeVal openingTime;
		Glib::TimeVal closingTime;

		openingTime.assign_from_iso8601(openingDateTime);
		double openingD = openingTime.as_double();

		closingTime.assign_from_iso8601(closingDateTime);
		double closingD = closingTime.as_double();

		Smartmatic::SAES::Security::Encryption::getInstance()->setMachineTime(openingD + (openingD + closingD)/2);

		Smartmatic::SAES::Voting::OperationStatus::Current()->init();
		Glib::ustring openingCode = Smartmatic::SAES::Voting::OperationStatus::Current()->getElectionStatusWrapper()->getOpeningCode();
		Smartmatic::System::GuidClass openCodeGUID = Smartmatic::System::GuidClass::Parse(openingCode);
		Smartmatic::SAES::Security::Encryption::getInstance()->setOpeningCode(openCodeGUID);

		//Clear previous language
		ElectionInstalationLanguages::getInstance()->clearLanguage();

		Smartmatic::SAES::Voting::Election::Languages::LanguageSequence & sequence (electoralConfiguration->getLanguages().getLanguage());

		for (Smartmatic::SAES::Voting::Election::Languages::LanguageIterator it = sequence.begin(); it != sequence.end(); ++it)
		{
			ElectionInstalationLanguages::getInstance()->addInstallationLanguages((*it));
			Smartmatic::SAES::Voting::SetLanguageFunctionality::setNewVotingLanguageByLanguageCountry(it->getLanguage(),it->getCountry());
			break;
		}


		loginOk = true;
		}
	}
	catch(ElectionException & ex)
	{

		std::cout << "FATAL "<<__func__<< ex.what() << std::endl;

	}
	catch(VotingDeviceException & ex)
	{
		std::cout << "FATAL "<<__func__<< ex.what() << std::endl;
	}
	catch(CryptoException & ex)
	{
		std::cout << "FATAL "<<__func__<< ex.what() << std::endl;
	}
	catch(SignedException & ex)
	{
		std::cout << "FATAL "<<__func__<< ex.what() << std::endl;
	}
	catch(XmlException & ex)
	{
		std::cout << "FATAL "<<__func__<< ex.what() << std::endl;
	}
	catch(GuIdException & ex)
	{
		std::cout << "FATAL "<<__func__<< ex.what() << std::endl;
	}
	catch(FileSystemException & ex)
	{
		std::cout << "FATAL "<<__func__<< ex.what() << std::endl;
	}
	catch(std::exception & ex)
	{
		std::cout << "FATAL "<<__func__<< ex.what() << std::endl;
	}
	catch(...)
	{
		std::cout << "FATAL "<<__func__<< "Unknown exception" << std::endl;
	}
//.........这里部分代码省略.........
开发者ID:albertpadin,项目名称:SAES,代码行数:101,代码来源:SimVoetWindow.cpp


示例14: isInTheFuture

bool CondTime::isInTheFuture() const
{
	Glib::TimeVal now;
	now.assign_current_time();
	return (now-timepoint).negative(); // timepoint > now
}
开发者ID:fbciccio,项目名称:lightspark,代码行数:6,代码来源:threading.cpp



注:本文中的glib::TimeVal类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ glib::ustring类代码示例发布时间:2022-05-31
下一篇:
C++ glib::RefPtr类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap