예제 #1
0
void ActivityDialog::show_calendar(bool start_cal)
{
  Gtk::Dialog cal_dialog;
  if(start_cal)
    cal_dialog.set_title(_("Start date"));
  else
    cal_dialog.set_title(_("End date"));

  cal_dialog.set_icon_from_file("images/HaPr_high_80x100_ver2.gif");
  cal_dialog.add_button(Gtk::Stock::CANCEL, 0);
  cal_dialog.add_button(Gtk::Stock::OK, 1);

  Gtk::Calendar cal;
  Gtk::Box *cal_box = cal_dialog.get_vbox();
  cal_box->pack_start(cal);

  cal_dialog.show_all_children();

  int response = cal_dialog.run();
  if(response == 1)
  {
    Glib::Date sdate;
    cal.get_date(sdate);
    if(start_cal)
      start_date_entry.set_text(sdate.format_string("%F"));
    else
      end_date_entry.set_text(sdate.format_string("%F"));
  }
}
예제 #2
0
void
Item::ensure_integrity()
{
	if (_ensured) 
		return;
	static const Glib::ustring _empty("Empty title");
	if (_link.empty() && !_guid.empty())
		_link = _guid;
	if (_title.empty())
		_title = _empty;
	const Glib::ustring s = _description;
	remove_markup (s, _description);

    bool rd_is_valid = false;
    if (!_rcvdate.empty())
    {
        Glib::Date my;
        int y, m, d;
        sscanf (_rcvdate.c_str(), "%d-%d-%d", &y, &m, &d);
        my.set_day (d);
        my.set_year (y);
        my.set_month (Glib::Date::JANUARY);
        my.add_months (m-1);
        rd_is_valid = my.valid();
    }
    if (!rd_is_valid)
    {
        g_warning ("Invalid date: %s ... fixing", _rcvdate.c_str());
        Glib::Date now;
        now.set_time_current();
        _rcvdate = now.format_string ("%Y-%m-%d");
    }
	_ensured = true;
}
예제 #3
0
파일: CalendarBox.cpp 프로젝트: SJasson/vle
void CalendarBox::dateBegin(std::string& date)
{
    if (mDialog->run() == Gtk::RESPONSE_OK) {
#if GTKMM_MAJOR_VERSION == 2 && GTKMM_MINOR_VERSION <= 10
        guint year, month, day;
        mCalendar->get_date(year, month, day);
        Glib::Date d((Glib::Date::Day)day, (Glib::Date::Month)month,
                     (Glib::Date::Year)year);
#else
        Glib::Date d;
        mCalendar->get_date(d);
#endif
        Glib::ustring format = "%Y-%m-%d";
        date = d.format_string(format);
    }
    mDialog->hide();
}
예제 #4
0
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();

}
예제 #5
0
std::string NoteOfTheDay::get_title(const Glib::Date & date)
{
  // Format: "Today: Friday, July 01 2005"
  return s_title_prefix + date.format_string(_("%A, %B %d %Y"));
}
예제 #6
0
void GCode::MakeText(string &GcodeTxt, const string &GcodeStart, 
		     const string &GcodeLayer, const string &GcodeEnd,
		     bool RelativeEcode, 
		     ViewProgress * progress)
{
	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();

	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++) {
	  if (i%progress_steps==0) if (!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, RelativeEcode) + "\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);
	}


	  // 	oss.str( "" );
	// 	switch(commands[i].Code)
	// 	{
	// 	case SELECTEXTRUDER:
	// 		oss  << "T0\n";
	// 		add_text_filter_nan(oss.str(), GcodeTxt);
	// 		//GcodeTxt += oss.str();
	// 		break;
	// 	case SETSPEED:
	// 		commands[i].where.z() = LastPos.z();
	// 		commands[i].e = lastE;
	// 	case ZMOVE:
	// 		commands[i].where.x() = LastPos.x();
	// 		commands[i].where.y() = LastPos.y();
	// 	case COORDINATEDMOTION:
	// 		if ((commands[i].where.x() != LastPos.x()) + 
	// 		    (commands[i].where.y() != LastPos.y()) +
	// 		    (commands[i].where.z() != LastPos.z()) != 0 &&
	// 		    AntioozeDistance != 0 && commands[i].e == lastE &&
	// 		    !Use3DGcode && AntioozeDistance != 0)
	// 		{
	// 			if (UseIncrementalEcode)
	// 			{
	// 				oss << "G1 E" << (lastE - AntioozeDistance) << "  F" << AntioozeSpeed << " ;antiooze retract\n";
	// 			}
	// 			else
	// 			{
	// 				oss << "G1 E" << -(AntioozeDistance) << "  F" << AntioozeSpeed << " ;antiooze retract\n";
	// 			}
	// 		}
	// 		oss  << "G1 ";
	// 		if(commands[i].where.x() != LastPos.x())
	// 			oss << "X" << commands[i].where.x() << " ";
	// 		if(commands[i].where.y() != LastPos.y())
	// 			oss << "Y" << commands[i].where.y() << " ";
	// 		if(commands[i].where.z() != LastPos.z())
	// 			oss << "Z" << commands[i].where.z() << " ";
	// 		if(commands[i].e != lastE)
	// 		{
	// 			if(UseIncrementalEcode)	// in incremental mode, the same is nothing
	// 				{
	// 				if(commands[i].e != lastE)
	// 					oss << "E" << commands[i].e << " ";
	// 				}
	// 			else
	// 				{
	// 				if(commands[i].e >= 0.0)
	// 					oss << "E" << commands[i].e << " ";
	// 				}
	// 		}
	// 		oss << "F" << commands[i].f;
	// 		if(commands[i].comment.length() != 0)
	// 			oss << " ;" << commands[i].comment << "\n";
	// 		else
	// 			oss <<  "\n";
	// 		if ((commands[i].where.x() != LastPos.x()) + 
	// 		    (commands[i].where.y() != LastPos.y()) +
	// 		    (commands[i].where.z() != LastPos.z()) != 0 &&
	// 		    AntioozeDistance != 0 &&
	// 		    commands[i].e == lastE  && 
	// 		    !Use3DGcode && AntioozeDistance != 0)
	// 		{
	// 			if (UseIncrementalEcode)
	// 			{
	// 				oss << "G1 E" << lastE << "  F" << AntioozeSpeed << " ;antiooze return\n";
	// 			}
	// 			else
	// 			{
	// 				oss << "G1 E" << AntioozeDistance << "  F" << AntioozeSpeed << " ;antiooze return\n";
	// 			}
	// 		}
	// 		add_text_filter_nan(oss.str(), GcodeTxt);
	// 		//GcodeTxt += oss.str();
	// 		if(commands[i].Code == ZMOVE && commands[i].where.z() != LastPos.z())
	// 		  add_text_filter_nan(GcodeLayer + "\n", GcodeTxt);
	// 		  //GcodeTxt += GcodeLayer + "\n";

	// 		LastPos = commands[i].where;
	// 		if( commands[i].e >= 0.0)
	// 			lastE = commands[i].e;
	// 		break;
	// 	case EXTRUDERON:
	// 	  // Dont switch extruder on/off right after eachother
	// 		if(i != 0 && commands[i-1].Code == EXTRUDEROFF) continue;
	// 		oss  << "M101\n";
	// 		add_text_filter_nan(oss.str(), GcodeTxt);
	// 		//GcodeTxt += oss.str();
	// 		break;
	// 	case EXTRUDEROFF:
	// 	  // Dont switch extruder on/off right after eachother
	// 		if(i != 0 && (i+1) < commands.size() && 
	// 		   commands[i+1].Code == EXTRUDERON) continue;	
	// 		// don't switch extruder off twize
	// 		if(i != 0 && (i+1) < commands.size() && 
	// 		   commands[i+1].Code == EXTRUDEROFF) continue;	
	// 		oss  << "M103\n";
	// 		add_text_filter_nan(oss.str(), GcodeTxt);
	// 		//GcodeTxt += oss.str();
	// 		break;
	// 	case COORDINATEDMOTION3D:
	// 		oss  << "G1 X" << commands[i].where.x() << " Y" << commands[i].where.y() << " Z" << commands[i].where.z();
	// 		oss << " F" << commands[i].f;
	// 		if(commands[i].comment.length() != 0)
	// 			oss << " ;" << commands[i].comment << "\n";
	// 		else
	// 			oss <<  "\n";
	// 		add_text_filter_nan(oss.str(), GcodeTxt);
	// 		//GcodeTxt += oss.str();
	// 		LastPos = commands[i].where;
	// 		break;
	// 	case RAPIDMOTION:
	// 		oss  << "G0 X" << commands[i].where.x() << " Y" << commands[i].where.y() << " Z" << commands[i].where.z()  << "\n";
	// 		add_text_filter_nan(oss.str(), GcodeTxt);
	// 		//GcodeTxt += oss.str();
	// 		LastPos = commands[i].where;
	// 		break;
	// 	case GOTO:
	// 		oss  << "G92";
	// 		if(commands[i].where.x() != LastPos.x() && commands[i].where.x() >= 0)
	// 		{
	// 			LastPos.x() = commands[i].where.x();
	// 			oss << " X" << commands[i].where.x();
	// 		}
	// 		if(commands[i].where.y() != LastPos.y() && commands[i].where.y() >= 0)
	// 		{
	// 			LastPos.y() = commands[i].where.y();
	// 			oss << " Y" << commands[i].where.y();
	// 		}
	// 		if(commands[i].where.z() != LastPos.z() && commands[i].where.z() >= 0)
	// 		{
	// 			LastPos.z() = commands[i].where.z();
	// 			oss << " Z" << commands[i].where.z();
	// 		}
	// 		if(commands[i].e != lastE && commands[i].e >= 0.0)
	// 		{
	// 			lastE = commands[i].e;
	// 			oss << " E" << commands[i].e;
	// 		}
	// 		oss <<  "\n";
	// 		add_text_filter_nan(oss.str(), GcodeTxt);
	// 		//GcodeTxt += oss.str();
	// 		break;
	// 	default:
	// 		break; // ignored CGCode
	// 	}
	// 	pos = commands[i].where;
	// cerr<< oss.str()<< endl;
	//}

}
예제 #7
0
void SubVisitWindow::setSubVisitDate(const Glib::Date& val)
{
	m_txtVisitDate->set_text(val.format_string("%Y-%m-%d"));
}