Exemplo n.º 1
0
void uploadClipboard() {
    QClipboard *clipboard = qApp->clipboard();
    const QMimeData *data = clipboard->mimeData();

    if (data->hasText()) {
        upload(PuushFile{data->text().toUtf8(), generateFilename("clipboard (%1).txt")});
    } else if (data->hasImage()) {
        QImage img = data->imageData().value<QImage>();
        upload(compressImage("clipboard", img));
    } else {
        QStringList formats = data->formats();
        if (formats.isEmpty()) {
            trayicon->showMessage(QObject::tr("Error."), QObject::tr("The clipboard is empty."), QSystemTrayIcon::Critical);
            return;
        }

        QByteArray buffer = data->data(formats.first());
        if (buffer.isEmpty()) {
            trayicon->showMessage(QObject::tr("Error."), QObject::tr("The clipboard is empty."), QSystemTrayIcon::Critical);
            return;
        }

        upload(PuushFile{buffer, generateFilename("clipboard (%1).bin")});
    }
}
Exemplo n.º 2
0
PuushFile compressImage(QString type, T &pix) {
    QByteArray jpgData, pngData;
    QBuffer jpgBuffer(&jpgData), pngBuffer(&pngData);

    pix.save(&jpgBuffer, "JPG", 95);
    pix.save(&pngBuffer, "PNG");

    if (pngData.size() < jpgData.size())
        return PuushFile { pngData, generateFilename(type + " (%1).png") };
    else
        return PuushFile { jpgData, generateFilename(type + " (%1).jpg") };
}
	string SimulatorParameters::getFilename(string meshName){
		char s1[256], s4[256];
		generateFilename(meshName,s1);
		sprintf(s4,"%s_CFL%.2f-%d-of-%d",s1,CFL(),P_pid(),P_size());
		string s5(s4);
		return s5;
	}
Exemplo n.º 4
0
/********************************************************************
* Prints everything
********************************************************************/
void Scan::writeAll(const double epsilon, const int mi) {
    std::string name;
    name = generateFilename(epsilon, mi);
    writeClusters(name + "clusters.txt");
    writeHubs(name + "hubs.txt");
    writeOutliers(name + "outliers.txt");
}
Exemplo n.º 5
0
bool DebugIR::runOnModule(Module &M) {
  OwningPtr<int> fd;

  if (isMissingPath() && !getSourceInfo(M)) {
    if (!WriteSourceToDisk)
      report_fatal_error("DebugIR unable to determine file name in input. "
                         "Ensure Module contains an identifier, a valid "
                         "DICompileUnit, or construct DebugIR with "
                         "non-empty Filename/Directory parameters.");
    else
      generateFilename(fd);
  }

  if (!GeneratedPath && WriteSourceToDisk)
    updateExtension(".debug-ll");

  // Clear line numbers. Keep debug info (if any) if we were able to read the
  // file name from the DICompileUnit descriptor.
  DebugMetadataRemover::process(M, !ParsedPath);

  OwningPtr<Module> DisplayM;
  createDebugInfo(M, DisplayM);
  if (WriteSourceToDisk) {
    Module *OutputM = DisplayM.get() ? DisplayM.get() : &M;
    writeDebugBitcode(OutputM, fd.get());
  }

  DEBUG(M.dump());
  return true;
}
Exemplo n.º 6
0
Logger::Logger()
: blackboardVersion(0),
  readIndex(0),
  writeIndex(0),
  frameCounter(0),
  writerIdle(true),
  writerIdleStart(0)
{
  InMapFile stream("logger.cfg");
  if(stream.exists())
    stream >> parameters;

#ifndef TARGET_ROBOT
  parameters.enabled = false;
  parameters.logFilePath = "Logs/";
#endif

  if(parameters.enabled)
  {
    buffer.reserve(parameters.maxBufferSize);
    for(int i = 0; i < parameters.maxBufferSize; ++i)
    {
      buffer.push_back(new MessageQueue());
      buffer.back()->setSize(parameters.blockSize);
    }
    logFilename = generateFilename();
    writerThread.setPriority(parameters.writePriority);
  }
}
Exemplo n.º 7
0
void chip8emu::Chip8Emu::loadRom(const std::string &filename)
{
   mRomName = filename;

   // Remove directory if present.
   const size_t lastSlashIdx = mRomName.find_last_of("\\/");
   if (std::string::npos != lastSlashIdx) {
      mRomName.erase(0, lastSlashIdx + 1);
   }

   // Remove extension if present.
   const size_t periodIdx = mRomName.rfind('.');
   if (std::string::npos != periodIdx) {
      mRomName.erase(periodIdx);
   }
   
   mCpu->loadRom(filename);
      
   // Fetch the name of the last save state, ...
   std::string stateFile = generateFilename("chip8_", ".bak", true);
   
   // ... check if the file exists.
   if(std::ifstream(stateFile)) {
      std::cout << "Loading safe state from " << stateFile << " ..." << std::endl;
      loadState(stateFile);
   }
}
Exemplo n.º 8
0
void
DataCapture::rgb_callback (const openni_wrapper::Image::Ptr &image)
{
  evaluateFrameRate ();

  if (continuous_capture_)
  {
    std::string filename = generateFilename ();
    saveRgb (filename, *image);
  }
  else if (save_)
  {
    save_ = false;
    std::string filename = generateFilename ();
    saveRgb (filename, *image);
  }
}
Exemplo n.º 9
0
void
DataCapture::depth_callback (const openni_wrapper::DepthImage::Ptr &depthmap)
{
  evaluateFrameRate ();

  if (continuous_capture_)
  {
    std::string filename = generateFilename ();
    saveDepthmap (filename, *depthmap, 16);
  }
  else if (save_)
  {
    save_ = false;
    std::string filename = generateFilename ();
    saveDepthmap (filename, *depthmap, 16);
  }
}
Exemplo n.º 10
0
 virtual void write(const PointViewPtr view) final
 {
     if (m_hashPos != std::string::npos)
         readyFile(generateFilename());
     writeView(view);
     if (m_hashPos != std::string::npos)
         doneFile();
 }
Exemplo n.º 11
0
template <typename PointT> void
DataCapture::cloud_callback (const typename pcl::PointCloud<PointT>::ConstPtr &cloud)
{
    evaluateFrameRate();

    if (continuous_capture_)
    {
        std::string filename = generateFilename();
        saveCloud<PointT> (filename, *cloud);
    }
    else if (save_)
    {
        save_ = false;
        std::string filename = generateFilename();
        saveCloud<PointT> (filename, *cloud);
    }

}
Exemplo n.º 12
0
void chip8emu::Chip8Emu::saveState()
{
   // Generate the save state filename ...
   std::string filename = generateFilename("chip8_", ".bak");

   // ... and store the current state as binary file.
   mCpu->saveState(filename);
   
   std::cout << "Saved machine state as " << filename << " ..." << std::endl;
}
Exemplo n.º 13
0
void
DataCapture::depthrgb_callback (const openni_wrapper::Image::Ptr &image, const openni_wrapper::DepthImage::Ptr &depthmap, float constant)
{
  evaluateFrameRate ();

  // save depth map with 16 bit, as provided by the OpenNI driver
  if (continuous_capture_)
  {
    std::string filename = generateFilename ();
    saveRgb (filename, *image);
    saveDepthmap (filename, *depthmap, 16);
  }
  else if (save_)
  {
    save_ = false;
    std::string filename = generateFilename ();
    saveRgb (filename, *image);
    saveDepthmap (filename, *depthmap, 16);
  }
}
Exemplo n.º 14
0
void chip8emu::Chip8Emu::takeSnapshot()
{
   // Generate the snapshot filename ...
   std::string filename = generateFilename("snap_", ".bmp");

   // ... and store the current screen as bitmap.
   std::shared_ptr<SDL_Surface> sshot = std::shared_ptr<SDL_Surface>(SDL_GetWindowSurface(mWindow.get()), SDL_FreeSurface);
   Uint32 format = SDL_GetWindowPixelFormat(mWindow.get());
   SDL_RenderReadPixels(mRenderer.get(), nullptr, format, sshot->pixels, sshot->pitch);
   SDL_SaveBMP(sshot.get(), filename.c_str());
   
   std::cout << "Saved snapshot as " << filename << " ..." << std::endl;
}
Exemplo n.º 15
0
CPO_BOOL
Reporter::init ( const char * appName,
                 const BITFIELD prefixMask,
                 const BITFIELD destination,
                 const char * path )
{
  char tmpFile [ CPO_MAX_FILENAME_LEN + 1 ];
  char tmpPath [ CPO_MAX_FILENAME_LEN + 1 ];
  
  // must not be initialised
  if ( state & CPO_CONNECTED )
  {
    return ( CPO_FALSE );
  }

// initialise variables
  prepare ( );
  
  // because we supplied a path, make sure we are setup for file output
  state = destination;
  if ( !(state & RPT_FILE) )
  {
    state += RPT_FILE;
  }

  // generate the output filename
  generateFilename ( tmpFile, appName );

  // add a backslash if there isn't one
  strcpy(tmpPath, path);
  if ((*(tmpPath + strlen(tmpPath) - 1)) != '\\')
	strcat(tmpPath, "\\");

  (void) sprintf ( filename, "%s%s", tmpPath, tmpFile );
  
  // final preparations
  if ( ! ( setup ( appName, prefixMask ) ) )
  {
    return ( CPO_FALSE );
  }

#ifdef RPT_DEBUG_PROG
    (void) fprintf ( stdout, 
                     "appname [%s] prefix %ld dest %ld file [%s] state %ld\n", 
                     appName, prefixMask, destination, filename, state );
    (void) fflush ( stdout );
#endif  
    
  InitializeCriticalSection(&aCriticalSection);
  return ( CPO_TRUE );
}
Exemplo n.º 16
0
///////////////////////////////////////////////////////////////////////////////////////////////////
// template specialization for RGB point cloud, which is also visualized
template <> void
DataCapture::cloud_callback<pcl::PointXYZRGBA> (const pcl::PointCloud<pcl::PointXYZRGBA>::ConstPtr &cloud)
{
    // provide new cloud to visualization
    cloud_viewer_.setCloud (cloud);

    // only save the cloud, if requested so
    if (capture_method_ == CLOUD_RGB)
    {
        evaluateFrameRate();

        if (continuous_capture_)
        {
            std::string filename = generateFilename();
            saveCloud<pcl::PointXYZRGBA> (filename, *cloud);
        }
        else if (save_)
        {
            save_ = false;
            std::string filename = generateFilename();
            saveCloud<pcl::PointXYZRGBA> (filename, *cloud);
        }
    }
}
Exemplo n.º 17
0
	//---------------------------------------------------------------------
	bool Page::prepareImpl(PageData* dataToPopulate)
	{
		// Procedural preparation
		if (mParent->_prepareProceduralPage(this))
			return true;
		else
		{
			// Background loading
			String filename = generateFilename();

			DataStreamPtr stream = Root::getSingleton().openFileStream(filename, 
				getManager()->getPageResourceGroup());
			StreamSerialiser ser(stream);
			return prepareImpl(ser, dataToPopulate);
		}


	}
Exemplo n.º 18
0
CPO_BOOL
Reporter::init ( const char * appName,
                 const BITFIELD prefixMask,
                 const BITFIELD destination )
{
  // must not be initialised
  if ( state & CPO_CONNECTED )
  {
    return ( CPO_FALSE );
  }

  // initialise variables
  prepare ( );
  
  // set up logging file
  state = destination;
  if ( state & RPT_FILE )
  {
    generateFilename ( filename, appName );
  }
  
  // final preparations
  if ( ! ( setup ( appName, prefixMask ) ) )
  {
    return ( CPO_FALSE );
  }

#ifdef RPT_DEBUG_PROG
    (void) fprintf ( stdout, 
                     "progname [%s] prefix %ld dest %ld file [%s] state %ld\n",
                     progname, prefixMask, destination, filename, state );
    (void) fflush ( stdout );
#endif  

  InitializeCriticalSection(&aCriticalSection);
  return ( CPO_TRUE );
}
Exemplo n.º 19
0
Logger::Logger()
{
	pthread_mutex_init(&m_logMutex, NULL);
    m_debugAvailable = true;
    m_warningAvailable = true;
    m_errorAvailable = true;
	 std::string filename = generateFilename();

	m_file.open( filename.c_str(), std::ios::out|std::ios::in|std::ios::app );
	 if (!m_file.good())
	 {
		 perror("ERROR: El Logger no pudo abrir el archivo ");
		 perror (filename.c_str());
		 perror (".\n");
		 return;
	 }
	 m_file << "  ===============================================\n"
	          << "    Comienzo del Log ( "
	          << Time::getDate()
	          << " a las "
	          << Time::getTime()
	          << " ) \n  ===============================================\n\n";
	 m_file.flush();
}
Exemplo n.º 20
0
std::string GraphDrawer::generateFilename(std::string stem)
{
	return generateFilename(stem, "png");
}
Exemplo n.º 21
0
YubikoOtpKeyConfig::YubikoOtpKeyConfig(KeyManager& pKeyManager) :
		itsKeyManager(pKeyManager), itsChangedFlag(false) {
	BOOST_LOG_NAMED_SCOPE("YubikoOtpKeyConfig::YubikoOtpKeyConfig");
	generateFilename();
	zeroToken();
}
Exemplo n.º 22
0
 virtual void ready(PointTableRef table) final
 {
     readyTable(table);
     if (m_hashPos == std::string::npos)
         readyFile(generateFilename());
 }
Exemplo n.º 23
0
	//---------------------------------------------------------------------
	void Page::save()
	{
		String filename = generateFilename();
		save(filename);
	}
Exemplo n.º 24
0
std::string GraphDrawer::plot(std::string filename, GraphMap properties,
		vector<vector<double> > xs,
		vector<vector<double> > ys, vector<double> x2,
		vector<double> y2)
{
#ifdef MAC
/*	std::string plotType = "line";
	std::string plotType2 = "line";
	std::string title = "Title";
	std::string xTitle = "x axis";
	std::string yTitle = "y axis";

	if (properties.count("title") > 0)
		title = boost::get<std::string>(properties["title"]);

	if (properties.count("xTitle") > 0)
		xTitle = boost::get<std::string>(properties["xTitle"]);

	if (properties.count("yTitle") > 0)
		yTitle = boost::get<std::string>(properties["yTitle"]);

	if (properties.count("plotType") > 0)
		plotType = boost::get<std::string>(properties["plotType"]);

	if (properties.count("plotType2") > 0)
		plotType2 = boost::get<std::string>(properties["plotType2"]);

	plsdev("png");

	char geometry[] = "-geometry";
	char dims[] = "1600x1250";

	plsetopt(geometry, dims);

	std::string fullName = generateFilename(filename);

	plsfnam(fullName.c_str());
	plscolbg(255, 255, 255);
	plscol0(1, 0, 0, 0);

	double minX = FLT_MAX;
	double maxX = -FLT_MAX;
	double minY = FLT_MAX;
	double maxY = -FLT_MAX;

	for (int j = 0; j < xs.size(); j++)
	{
		for (int i = 0; i < xs[j].size(); i++)
		{
			if (xs[j][i] < minX)
				minX = xs[j][i];
			if (xs[j][i] > maxX)
				maxX = xs[j][i];
			if (ys[j][i] < minY)
				minY = ys[j][i];
			if (ys[j][i] > maxY)
				maxY = ys[j][i];
		}
	}

	if (properties.count("xMin") > 0)
		minX = boost::get<double>(properties["xMin"]);

	if (properties.count("xMax") > 0)
		maxX = boost::get<double>(properties["xMax"]);

	if (properties.count("yMin") > 0)
		minY = boost::get<double>(properties["yMin"]);

	if (properties.count("yMax") > 0)
		maxY = boost::get<double>(properties["yMax"]);

	// Initialize plplot
	plinit();

	// Create a labelled box to hold the plot.
	plenv(minX, maxX, minY, maxY, 0, 0);
	pllab(xTitle.c_str(), yTitle.c_str(), title.c_str());

	for (int i = 0; i < xs.size(); i++)
	{
		vector<double> x = xs[i];
		vector<double> y = ys[i];

		std::ostringstream plotTypeStream;
		plotTypeStream << "plotType_" << i;
		std::string plotTypeName = plotTypeStream.str();

		plssym(0, 0.5);

		std::ostringstream colourStream;
		colourStream << "colour_" << i;
		std::string colourString = colourStream.str();

		if (properties.count(colourString) > 0)
		{
			int colour = boost::get<double>(properties[colourString]);
			plcol0(colour);
		}

		std::string usedPlotType = plotType;
		if (properties.count(plotTypeName) > 0)
			usedPlotType = boost::get<std::string>(properties[plotTypeName]);

		if (usedPlotType == "fill")
		{
			double firstX = xs[i][0];
			double lastX = xs[i][xs[i].size() - 1];

			x.insert(x.begin(), firstX);
			y.insert(y.begin(), 0);
			x.push_back(lastX);
			y.push_back(0);
		}

		int nsize = (int)x.size();

		double *allX = &x[0];
		double *allY = &y[0];

		// Plot the data that was prepared above.

		if (usedPlotType == "point")
			plpoin(nsize, allX, allY, 4);

		if (usedPlotType == "line")
			plline(nsize, allX, allY);

		if (usedPlotType == "fill")
		{
            plscol0(3, 230, 230, 240);
			plcol0(3);
			plfill(nsize, allX, allY);
			plcol0(1);
			plline(nsize, allX, allY);
		}
	}

	if (x2.size() > 0)
	{
		double yMin2 = 0;
		if (properties.count("yMin2") > 0)
			yMin2 = boost::get<double>(properties["yMin2"]);

		double yMax2 = 1;
		if (properties.count("yMax2") > 0)
			yMax2 = boost::get<double>(properties["yMax2"]);

		plscol0(2, 200, 0, 0);
		plcol0(2);
		plwind(minX, maxX, yMin2, yMax2);
		plbox("", 0, 0, "cmstv", 0, 0);
		plwidth(2);

		double *allX = &x2[0];
		double *allY = &y2[0];
		int nsize = (int)x2.size();

		if (plotType2 == "point")
			plpoin(nsize, allX, allY, 4);

		if (plotType2 == "line")
		{
			plline(nsize, allX, allY);
			plpoin(nsize, allX, allY, 4);
		}
	}

	// Close PLplot library
	plend();

    std::ostringstream logged;
	logged << "Plotted " << fullName << std::endl;
    Logger::mainLogger->addStream(&logged, LogLevelDetailed);
*/
#endif
    
    std::string csvName = generateFilename(filename, "csv");
    
    std::ofstream csv;
    csv.open(csvName);
    
    int biggest = 0;
    
    for (int i = 0; i < xs.size(); i++)
    {
        if (xs[i].size() > biggest)
            biggest = (int)xs[i].size();
    }
    
    for (int i = 0; i < biggest; i++)
    {
        for (int j = 0; j < xs.size(); j++)
        {
            if (i < xs[j].size())
                csv << xs[j][i] << "," << ys[j][i] << ",";
            else csv << ",,";
            
        }
        
        csv << std::endl;
    }
    
    csv.close();
    
    return csvName;
}