Example #1
0
File: launch.cpp Project: mpiz/Labs
int main(int agrc, char** argv) {
	DiophantineSolver solver;


	solver.input(filestr(string(argv[1])));
	solver.solve();
	solver.output(filestr(string(argv[2])));
}
Example #2
0
bool Binairo::LireFichierText(const string & nomFichier)
{
	//Variable///////////////////////////////
	binairoGrille = Matrice <char>(NBLIGNES, NBCOLONNES);
	string ligne;
	ifstream filestr(nomFichier + ".txt");
	////////////////////////////////////////
	if (filestr)
	{
		while (getline(filestr, ligne))
		{
			for (int i = 0; i < binairoGrille.GetNbLignes(); i++)
			{
				for (int j = 0; j < binairoGrille.GetNbColonnes(); j++)
				{
					binairoGrille[i][j] = ligne[j];
				}
				getline(filestr, ligne);
			}
		}
		return true;
	}
	else
	{
		cerr << endl << "Erreur: Impossible d'ouvrir le fichier !!!" << endl;
		return false;
	}
}
Example #3
0
QStringList Manager::getAllFiles(QString dir, bool fulllocation)
{
    try
    {
        QStringList files;
        QDirIterator localIterator(dir, QDir::Files);
        while (localIterator.hasNext()) {
            QString filestr(localIterator.next());

            if(!fulllocation)
            {
                if(filestr.contains("/"))
                {
                    int lenght = filestr.split("/").count() - 1;
                    QString filename = QString(filestr.split("/")[lenght]);
                    files.append(filename);
                }
            } else files.append(filestr);
        }
        return files;
    } catch(QException* error)
    {
        logs->append(QApplication::tr("<span style=\"color: #ea7878\"><b>•</b> Error in function getAllfiles: %1</span>").arg(error->what()));
        return QStringList();
    }
}
void CRCapture::Capture (const char *file, int line)
{
    wxString filestr(file, *wxConvCurrent);
    CRCppEmitter::GetInstance ()->SetTestCaseFileContext (filestr, line);

    this->Show ();
}
void ParameterLoader::saveParametersToFile(std::string filename)
{
	std::fstream filestr(filename.c_str(), std::fstream::trunc | std::fstream::out);
	for (std::map<std::string, double>::iterator it=parameters.begin();
		 it!=parameters.end(); ++it) {
		filestr << it->first << ", " << it->second << std::endl;
	}
	filestr.close();
}
Example #6
0
int main(int argc, char **argv) {
	OCR o;
	std::string line1, line2, line3, line4;
	std::string accountNumber;
	std::string accountStatus;
	std::ifstream filestr ("test.input");
	std::ofstream story3 ("story3.txt");
	std::ofstream story4 ("story4.txt");

	if(filestr.is_open()){
		while(filestr.good()){
			getline (filestr, line1);
			getline (filestr, line2);
			getline (filestr, line3);
			getline (filestr, line4);

			//user story 1
			std::cout << line1 <<std::endl;
			std::cout << line2 <<std::endl;
			std::cout << line3 <<std::endl;
			std::cout << line4 <<std::endl;
			accountNumber = o.convertScannedLines(line1, line2, line3, line4);

			//user story 2
			std::cout << std::endl << "=> " << accountNumber;
			std::cout << ((o.processCheckSum(accountNumber)==0) ? " valid":" invalid") << " checksum" << std::endl;

			//user story 3
			accountStatus = o.validateAccount(accountNumber);
			if (story3.is_open()){
				story3 << accountNumber << accountStatus << std::endl;
			}

			//user story 4
			if(accountStatus == " ILL"){
				story4 << o.fixMissingDigit(accountNumber);
			}else if(accountStatus == " ERR"){
				story4 << o.fixBadCheckSum(accountNumber);
			}else{
				story4 << accountNumber;
			}
			story4 << std::endl;
		}
	}

	std::cout << "[file done processing]";
	story3 << "[file done processing]";
	story4 << "[file done processing]";

	filestr.close();
	story3.close();
	story4.close();
} //end main
Example #7
0
pascal Boolean CrossPlatformFilterCallback (
    AEDesc *theItem,
    void *info,
    void *callBackUD,
    NavFilterModes filterMode
)
{
    bool display = true;
    DialogData* data = (DialogData*)(callBackUD);
	
    if (filterMode == kNavFilteringBrowserList)
    {
        NavFileOrFolderInfo* theInfo = (NavFileOrFolderInfo*) info ;
        if ( !theInfo->isFolder )
        {
            /*
			if (theItem->descriptorType == typeFSS )
            {
                FSSpec    spec;
                memcpy( &spec , *theItem->dataHandle , sizeof(FSSpec) ) ;
				std::cout << "unhandled" << std::endl;
			}
            else 
			*/
			if ( theItem->descriptorType == typeFSRef )
            {
                FSRef fsref ;
                memcpy( &fsref , *theItem->dataHandle , sizeof(FSRef) ) ;

                CFURLRef fullURLRef;
                fullURLRef = ::CFURLCreateFromFSRef(NULL, &fsref);
                CFURLPathStyle pathstyle = kCFURLPOSIXPathStyle;
                CFStringRef cfString = CFURLCopyFileSystemPath(fullURLRef, pathstyle);
                ::CFRelease( fullURLRef ) ;
				char buffer[2048];
				
				if (CFStringGetCString(cfString, buffer, 2048, kCFStringEncodingUTF8)) {
					std::string filestr(buffer);
					std::string ext(osgDB::getFileExtension(filestr));
					display = (data->allowedExtensions.find(ext) != data->allowedExtensions.end());
					
				}
				::CFRelease( cfString );
				
			}
        }
    }

    return display;
}
Example #8
0
bool LocalAssetProvider::RequestAsset(const std::string& asset_id, const std::string& asset_type, request_tag_t tag)
{
    if (!IsValidId(asset_id, asset_type))
        return false;
    
    Foundation::ServiceManagerPtr service_manager = framework_->GetServiceManager();
    boost::shared_ptr<Foundation::AssetServiceInterface> asset_service =
        service_manager->GetService<Foundation::AssetServiceInterface>(Foundation::Service::ST_Asset).lock();
    if (!asset_service)
        return false;
    
    AssetModule::LogDebug("New local asset request: " + asset_id);
    
    // Strip file:
    std::string filepath = asset_dir_ + asset_id.substr(7);
    
    boost::filesystem::path file_path(filepath);
    std::ifstream filestr(file_path.native_directory_string().c_str(), std::ios::in | std::ios::binary);
    if (filestr.good())
    {
        filestr.seekg(0, std::ios::end);
        uint length = filestr.tellg();
        filestr.seekg(0, std::ios::beg);
        
        if (length > 0)
        {
            RexAsset* new_asset = new RexAsset(asset_id, asset_type);
            Foundation::AssetPtr asset_ptr(new_asset);
            
            RexAsset::AssetDataVector& data = new_asset->GetDataInternal();
            data.resize(length);
            filestr.read((char *)&data[0], length);
            filestr.close();
            
            // Store to cache
            asset_service->StoreAsset(asset_ptr);
            // Send asset_ready event as delayed
            Events::AssetReady* event_data = new Events::AssetReady(asset_ptr->GetId(), asset_ptr->GetType(), asset_ptr, tag);
            framework_->GetEventManager()->SendDelayedEvent(event_category_, Events::ASSET_READY, Foundation::EventDataPtr(event_data));
            
            return true;
        }
        else
            filestr.close();
    }
    
    AssetModule::LogInfo("Failed to load local asset " + asset_id.substr(7));
    return false;
}
Example #9
0
void	Debug::write(const char *str, int x, int y)
{
  std::fstream filestr ("debug.txt", std::fstream::in | std::fstream::out | std::fstream::app);

  std::stringstream	ss;
  std::stringstream	ss2;
  std::string a1;
  std::string a2;
  ss << x;
  ss >> a1;
  ss2 << y;
  ss2 >> a2;

  std::string res;
  res = std::string(str) + std::string(" ") + a1 + std::string(" ") + a2 + std::string("|");
  filestr << res << std::endl;
  filestr.close();
}
Example #10
0
void constructK1ProblemStandard_1(ulong nBits, int nPartitions, FileRawBuffer * frwb, char * fileName){
    RandomNumberGenerator rng(frwb);
    mpz_class max;
    mpz_pow_ui(max.get_mpz_t(),mpz_class(2).get_mpz_t(),nBits);
    max--;
    double log1=(nPartitions-1)*(log(max)/log(nPartitions));
    int nElem=ceil(log1);
    ofstream filestr(fileName);
    filestr << 3600 << endl;
    filestr << "~" << endl;
    filestr << nElem<< endl;
    filestr << "~" << endl;
    filestr << nPartitions << endl;
    filestr << "~" << endl;
    for (int i = 0; i < nElem; i++) {
        filestr << rng.getNumberWithMaxBits(nBits) << endl;
    }
    filestr.close();
}
Example #11
0
void constructProblem(int nElements, int nBits, int nPartitions, int nTime, char * fileName) {
    srand(time(NULL));
    Cronometro c(Cronometro::NANO_S);
    c.start();
    gmp_randclass r4(gmp_randinit_default);
    r4.seed(c.elapsed());
    c.end();
    ofstream filestr(fileName);
    filestr << nTime << endl;
    filestr << "~" << endl;
    filestr << nElements << endl;
    filestr << "~" << endl;
    filestr << nPartitions << endl;
    filestr << "~" << endl;
    for (int i = 0; i < nElements; i++) {
        mpz_class num(r4.get_z_bits(nBits));
        filestr << num << endl;
    }
    filestr.close();
}
Example #12
0
/**
 * Main function
 */
int	main(int argc, char **argv)
{
  try
    {
      // !both filestr and backup are used for the file logger
      std::ofstream	filestr(FILE_TO_LOG);
      std::streambuf*	backup = std::clog.rdbuf();

      std::clog.rdbuf(filestr.rdbuf());
      std::clog << "#### New session opened ####" << std::endl;

      Glib::OptionContext	oc("Here's the parameters");
      Glib::OptionGroup		og("main", "main description");

      Glib::OptionEntry		verbose;
      verbose.set_long_name("verbose");
      verbose.set_short_name('v');
      verbose.set_description("set verbose level");
      verbose.set_arg_description("verbose level");

      og.add_entry(verbose);

      oc.set_main_group(og);
      oc.set_help_enabled();

      Gtk::Main		kit(argc, argv, oc);
      WindowManager	mywindow;

      Gtk::Main::run();

      std::clog << "#### Session closed ####" << std::endl;
      std::clog.rdbuf(backup);
      filestr.close();
    }
  catch (Glib::OptionError oe)
    {
      std::cerr << "OptionError: " << oe.what() << std::endl;
    }

  return 0;
}
void MSSM_spectrum_plotter::write_to_file(const std::string& file_name) const
{
   if (spectrum.empty())
      return;

   std::ofstream filestr(file_name.c_str(), std::ios::out);
   VERBOSE_MSG("MSSM_spectrum_plotter::write_to_file: opening file: "
               << file_name.c_str());
   if (filestr.fail()) {
      ERROR("MSSM_spectrum_plotter::write_to_file: can't open file "
            << file_name);
      return;
   }

   filestr << "### one-loop pole masses (Q = " << scale << " GeV)\n";
   write_spectrum(spectrum, filestr);

   filestr.close();
   VERBOSE_MSG("MSSM_spectrum_plotter::write_to_file: file written: "
               << file_name.c_str());
}
Example #14
0
    Py::Object read(const Py::Tuple& args)
    {
        char* Name;
        const char* DocName=0;
        if (!PyArg_ParseTuple(args.ptr(), "et|s","utf-8",&Name,&DocName))
            throw Py::Exception();
        std::string EncodedName = std::string(Name);
        PyMem_Free(Name);

        Base::FileInfo file(EncodedName.c_str());
        if (!file.exists())
            throw Py::RuntimeError("File doesn't exist");

        App::Document *pcDoc;
        if (DocName)
            pcDoc = App::GetApplication().getDocument(DocName);
        else
            pcDoc = App::GetApplication().getActiveDocument();
        if (!pcDoc) 
            pcDoc = App::GetApplication().newDocument(DocName);

        try {
            // read the gcode file
            std::ifstream filestr(file.filePath().c_str());
            std::stringstream buffer;
            buffer << filestr.rdbuf();
            std::string gcode = buffer.str();
            Toolpath path;
            path.setFromGCode(gcode);
            Path::Feature *object = static_cast<Path::Feature *>(pcDoc->addObject("Path::Feature",file.fileNamePure().c_str()));
            object->Path.setValue(path);
            pcDoc->recompute();
        }
        catch (const Base::Exception& e) {
            throw Py::RuntimeError(e.what());
        }

        return Py::None();
    }
Example #15
0
/* Es wird ein File geoeffnet und gibt entweder true oder false zurueck */
BOOL CStreamReader::open(const char* sFilenameToOpen) 
{
    	//Die Maskierungsbackslashes aus inputfilename werden entfernt, falls diese beim Aufrufen von Extractor hinzugefühgt worden sind.
        std::string s=sFilenameToOpen;

        int found = s.find_first_of("\\");
        while (found != -1)
        {
            s.erase(found, 1);
            found = s.find_first_of("\\",found+1);
        }
        sFilenameToOpen = s.c_str();
    
	fin.open(sFilenameToOpen, std::ios::binary);
	if (fin.is_open())
	{

		// Nach reichlichen Experimenten scheint dies Sinn zu machen: Es wird das File noch einmal als Filebuffer angepackt und dann
		// seiner Laenge her nach analysiert. Dieser Wert wird zwar so teuer erkauft, allerdings scheint dieser Weg auf den verschiedenen
		// Plattformen der einzig sinnvolle zu sein.
		std::fstream filestr(sFilenameToOpen);
		std::filebuf* pbuf;
		pbuf = filestr.rdbuf();
		// Die Laenge des Files wird bestimmt.
		lFileSize = pbuf->pubseekoff(0, std::ios_base::end);
		// Der Filebuffer wird geschlossen.
		filestr.close();

		// Ganz offensichtlich ist das Laden des Files erfolgreich, daher wird auch der Filename gespeichert.
		sFilename.assign(sFilenameToOpen);

		// Das Objekt wird nun dazu veranlasst, sich zu buffern. Damit wird der gesamte Inhalt in ein Char-Array gelesen.
		buffer();
		return TRUE;
	}	
	else
		return FALSE;
}
// Adds a file to the TFTP server, from C caller
extern "C" int addTFTPFile(void * server, char* filename, unsigned int filenamelen, char* file, unsigned int filelen){
	string filenamestr(filename,filenamelen);
	string filestr(file,filelen);
	((TFTPserv*)server)->addFile(filenamestr,filestr);
	return 0;
}
Example #17
0
int DefaultSource::get_network_state(const std::string& interface, StateMap* states)
{
  // dummy variables
  size_t rcverrs;
  size_t rcvdrop;
  size_t rcvfifo;
  size_t rcvframe;
  size_t rcvcompressed;
  size_t rcvmulticast;

  size_t xmterrs;
  size_t xmtdrop;
  size_t xmtfifo;
  size_t xmtcolls;
  size_t xmtcarrier;
  size_t xmtcompressed;

  old = current;
  std::string current_interface;
  // Declare a file stream, for reading /proc/net/dev.
  std::ifstream filestr("/proc/net/dev", std::fstream::in);
  if(!filestr) return -1;  // Couldn't open file

  {
    // First two lines are table headers, skip those
    std::string header;
    std::getline(filestr, header);
    std::getline(filestr, header);
  }

  // Loop through each line of the file until we find the correct interface.
  while(filestr) {
    std::string current_interface;
    std::getline(filestr, current_interface, ':');
    ::trim(current_interface);
    if(current_interface == interface)
      break;
    std::getline(filestr, current_interface);   // skip rest of the line
  }

  if(!filestr) return -1; // Couldn't find interface

    // Load the new data from the stream into the variables
  filestr >> current.rcvbytes >> current.rcvpackets >> rcverrs
          >> rcvdrop >> rcvfifo >> rcvframe
          >> rcvcompressed >> rcvmulticast
          >> current.xmtbytes >> current.xmtpackets >> xmterrs
          >> xmtdrop >> xmtfifo >> xmtcolls
          >> xmtcarrier >> xmtcompressed;

  if (states != NULL) {
    net_state state;
    state.rcvbytes = current.rcvbytes - old.rcvbytes;
    state.xmtbytes = current.xmtbytes - old.xmtbytes;
    state.rcvpackets = current.rcvpackets - old.rcvpackets;
    state.xmtpackets = current.xmtpackets - old.xmtpackets;
    state.type = DATA_UNKNOWN;
    (*states)[state.type] = state;
  }

  return (!!filestr ? 0 : -1);
}
void ManualTracker::saveLineage(std::string fname)
{
    std::fstream filestr(fname.c_str(), std::fstream::trunc | std::fstream::out);
    sp->saveAllCellsToCsv(filestr);
    emit exportDone();
}
Example #19
0
/**************************************************************************************************
*   inicia o pserve para receber as imagens e plota na ui
**************************************************************************************************/
void MainWindow::start_pserve()
{
    contagem=0;
    pixeis_lidos=0;
    QProcess *myProcess = new QProcess;
    QStringList arguments_pserve;
    process_pserve = Current_Path+"/pserve";
    arguments_pserve<<Count_L<<NImage<<Save_Path;
    myProcess->setProcessChannelMode(QProcess::MergedChannels);
    myProcess->start(process_pserve,arguments_pserve);
    myProcess->waitForStarted();
    QPixmap pixmap;
    float contagem_anterior;
    /**************************************************************************************************
    *   le uma imagem
    **************************************************************************************************/
    if(NImage.toInt()==1)
    {
        if(Count_L.toInt()==0) // 1 bit
        {
            contagem=0;
            pixeis_lidos=0;
            myProcess->waitForFinished((Time.toFloat()*1000)+100);
            QImage image(256,256,QImage::Format_Indexed8);
            if(image.load(Save_Path+"1.ppm","pbm")==true)
            {
                image.invertPixels();
                for(int a=0;a<=255;a++)
                {
                    for(int b=0;b<=255;b++)
                    {
                        contagem=contagem+(1-image.pixelIndex(b,a));
                        pixeis_lidos=contagem;
                    }
                }
            }
            else
            {
                image.fill(Qt::black);
                ui->textBrowser->append("Error Reading Image!!!");
            }
            pixmap = QPixmap::fromImage(image,Qt::ColorOnly);
        }
        else if(Count_L.toInt()==1) // 12 bits
        {
            contagem=0;
            pixeis_lidos=0;
            myProcess->waitForFinished((Time.toFloat()*1000)+1000);
            QImage image(256,256,QImage::Format_RGB16);
            QByteArray teste;
            QFile filestr(Save_Path+"1.ppm");
            if(filestr.open(QIODevice::ReadOnly)==true)
            {
                teste=filestr.readAll();
                QString colorstr(teste);
                QStringList colors = colorstr.split(QRegExp("\\s+"));
                colors.removeLast();
                colors.removeFirst();
                colors.removeFirst();
                colors.removeFirst();
                colors.removeFirst();
                QVector<QRgb> colortable;
                Lookup_Tables ctable;
                colortable=ctable.colorPalete1280();
                image.setColorTable(colortable);
                int cont=0;
                for(int a=0;a<=255;a++)
                {
                    for(int b=0;b<=255;b++)
                    {
                        if(qCeil(colors.at(cont).toInt()/3.2)>=1280)
                        {
                            image.setPixel(b,a, image.colorTable().at(1279));
                        }
                        else
                        {
                            image.setPixel(b,a, image.colorTable().at(qCeil(colors.at(cont).toUInt()/3.2)));
                        }
                        contagem_anterior=contagem;
                        contagem=contagem+colors.at(cont).toFloat();
                        cont++;
                        if(contagem_anterior!=contagem)
                        {
                            pixeis_lidos++;
                        }
                    }
                }
            }
            else
            {
                image.fill(Qt::black);
                ui->textBrowser->append("Error Reading Image!!!");
            }
            pixmap = QPixmap::fromImage(image,Qt::ColorOnly);
        }
        else if(Count_L.toInt()==2) // 6 bits
        {
            contagem=0;
            pixeis_lidos=0;
            myProcess->waitForFinished((Time.toFloat()*1000)+500);
            QImage image(256,256,QImage::Format_Indexed8);
            if(image.load(Save_Path+"1.ppm","pbm")==true)
            {
                QVector<QRgb> colortable;
                Lookup_Tables ctable;
                colortable=ctable.colorPalete64();
                image.setColorTable(colortable);
            }
            else
            {
                image.fill(Qt::black);
                ui->textBrowser->append("Error Reading Image!!!");
            }
            pixmap = QPixmap::fromImage(image,Qt::ColorOnly);

            for(int a=0;a<=255;a++)
            {
                for(int b=0;b<=255;b++)
                {
                    contagem_anterior=contagem;
                    contagem=contagem+image.pixelIndex(b,a);
                    if(contagem_anterior!=contagem)
                    {
                        pixeis_lidos++;
                    }
                }
            }
        }
        else if(Count_L.toInt()==3) // 24 bits
        {
            contagem=0;
            pixeis_lidos=0;
            myProcess->waitForFinished((Time.toFloat()*1000)+1500);
            QImage image(256,256,QImage::Format_RGB32);
            QByteArray teste;
            QFile filestr(Save_Path+"1.ppm");
            if(filestr.open(QIODevice::ReadOnly)==true)
            {
                teste=filestr.readAll();
                QString colorstr(teste);
                QStringList colors = colorstr.split(QRegExp("\\s+"));
                colors.removeLast();
                colors.removeFirst();
                colors.removeFirst();
                colors.removeFirst();
                colors.removeFirst();
                QVector<QRgb> colortable;
                Lookup_Tables ctable;
                colortable=ctable.colorPalete1280();
                image.setColorTable(colortable);
                int cont=0;
                for(int a=0;a<=255;a++)
                {
                    for(int b=0;b<=255;b++)
                    {
                        if(qCeil(colors.at(cont).toInt()/100)>=1536)
                        {
                            image.setPixel(b,a, image.colorTable().at(1535));
                        }
                        else
                        {
                            image.setPixel(b,a, image.colorTable().at(qCeil(colors.at(cont).toUInt()/100)));
                        }
                        contagem_anterior=contagem;
                        contagem=contagem+colors.at(cont).toFloat();
                        cont++;
                        if(contagem_anterior!=contagem)
                        {
                            pixeis_lidos++;
                        }
                    }
                }
            }
            else
            {
                image.fill(Qt::black);
                ui->textBrowser->append("Error Reading Image!!!");
            }
            pixmap = QPixmap::fromImage(image,Qt::ColorOnly);
        }
        pixmap=pixmap.scaled(512,512);
        scene= new QGraphicsScene(this);
        scene->addPixmap(pixmap);
        ui->Plot_Window->setScene(scene);
        QByteArray text_response=myProcess->readAll();
        QString mystr(text_response);
        ui->textBrowser->setText(mystr);
        ui->textBrowser->append("Total Count = "+QString::number(contagem));
        ui->textBrowser->append("Pixel Read = "+QString::number(pixeis_lidos));
    }
    /**************************************************************************************************
    *   le +1 imagem
    **************************************************************************************************/
    else
    {
        Save_Dir.setFilter(QDir::Files | QDir::Hidden | QDir::NoSymLinks);
        Save_Dir.setSorting(QDir::Time);
        QString lee(Image_Name);
        int cont =0;
        lee.append(QString::number(cont));
        for(int a=0;a<=(NImage.toInt()-1);a++)
        {
            if(Count_L.toInt()==0) // 1 bit
            {
                if(a==(NImage.toInt()-1))
                {
                    myProcess->waitForFinished(NImage.toInt()*((Gap.toInt()*1000)+(Time.toFloat()*1000)+300));
                }
                else if(a==0)
                {
                    QThread::msleep((Time.toFloat()*1000)+300);
                }
                else
                {
                    QThread::msleep((Gap.toInt()*1000)+(Time.toFloat()*1000)+300);
                }
                cont++;
                lee.replace(lee.size()-1,1,QString::number(cont));
                QImage image(256,256,QImage::Format_Indexed8);
                image.load(Save_Dir.absolutePath()+"/"+lee+".ppm","pbm");
                image.invertPixels();
                pixmap = QPixmap::fromImage(image,Qt::ColorOnly);
                pixmap=pixmap.scaled(512,512);
                scene= new QGraphicsScene(this);
                scene->addPixmap(pixmap);
                scene->update();
                ui->Plot_Window->setScene(scene);
                ui->Plot_Window->update();
                QByteArray text_response=myProcess->readAll();
                QString mystr(text_response);
                ui->textBrowser->setText(mystr);
                ui->textBrowser->update();
                QCoreApplication::processEvents(QEventLoop::AllEvents);
            }
            else if(Count_L.toInt()==1) // 12 bits
            {
                if(a==(NImage.toInt()-1))
                {
                    myProcess->waitForFinished(NImage.toInt()*((Gap.toInt()*1000)+(Time.toFloat()*1000)+1000));
                }
                else if(a==0)
                {
                    QThread::msleep((Time.toFloat()*1000)+1000);
                }
                else
                {
                    QThread::msleep((Gap.toInt()*1000)+(Time.toFloat()*1000)+1000);
                }
                QByteArray text_response=myProcess->readAll();
                QString mystr(text_response);
                ui->textBrowser->setText(mystr);
                cont++;
                lee.replace(lee.size()-1,1,QString::number(cont));
                QImage image(256,256,QImage::Format_RGB16);
                QByteArray teste;
                QFile filestr(Save_Dir.absolutePath()+"/"+lee+".ppm");
                filestr.open(QIODevice::ReadOnly);
                teste=filestr.readAll();
                QString colorstr(teste);
                QStringList colors = colorstr.split(QRegExp("\\s+"));
                colors.removeLast();
                colors.removeFirst();
                colors.removeFirst();
                colors.removeFirst();
                colors.removeFirst();
                QVector<QRgb> colortable;
                Lookup_Tables ctable;
                colortable=ctable.colorPalete1280();
                image.setColorTable(colortable);
                int cont=0;
                for(int a=0;a<=255;a++)
                {
                    for(int b=0;b<=255;b++)
                    {
                        if(qCeil(colors.at(cont).toInt()/3.2)>=1280)
                        {
                            image.setPixel(b,a, image.colorTable().at(1279));
                        }
                        else
                        {
                            image.setPixel(b,a, image.colorTable().at(qCeil(colors.at(cont).toUInt()/3.2)));
                        }
                        cont++;
                    }
                }
                pixmap = QPixmap::fromImage(image,Qt::ColorOnly);
                pixmap=pixmap.scaled(512,512);
                scene= new QGraphicsScene(this);
                scene->addPixmap(pixmap);
                scene->update();
                ui->Plot_Window->setScene(scene);
                ui->Plot_Window->update();
                QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
            }
            else if(Count_L.toInt()==2) // 6 bits
            {
                if(a==(NImage.toInt()-1))
                {
                    myProcess->waitForFinished(NImage.toInt()*((Gap.toInt()*1000)+(Time.toFloat()*1000)+500));
                }
                else if(a==0)
                {
                    QThread::msleep((Time.toFloat()*1000)+500);
                }
                else
                {
                    QThread::msleep((Gap.toInt()*1000)+(Time.toFloat()*1000)+500);
                }
                QByteArray text_response=myProcess->readAll();
                QString mystr(text_response);
                ui->textBrowser->setText(mystr);
                cont++;
                //QFileInfoList list = Save_Dir.entryInfoList();
                //QFileInfo fileinfo = list.at(0);
                //image1 = fileinfo.fileName();
                lee.replace(lee.size()-1,1,QString::number(cont));
                //qDebug()<<Save_Dir.absolutePath()+"/"+lee+".ppm";
                QImage image(256,256,QImage::Format_Indexed8);
                image.load(Save_Dir.absolutePath()+"/"+lee+".ppm","pgm");
                QVector<QRgb> colortable;
                Lookup_Tables ctable;
                colortable=ctable.colorPalete64();
                image.setColorTable(colortable);
                pixmap=pixmap.scaled(512,512);
                pixmap = QPixmap::fromImage(image,Qt::ColorOnly);
                scene= new QGraphicsScene(this);
                scene->addPixmap(pixmap);
                scene->update();
                ui->Plot_Window->setScene(scene);
                ui->Plot_Window->update();
                QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
            }
            else if(Count_L.toInt()==3) // 24 bits
            {
                if(a==(NImage.toInt()-1))
                {
                    myProcess->waitForFinished(NImage.toInt()*((Gap.toInt()*1000)+(Time.toFloat()*1000)+1500));
                }
                else if(a==0)
                {
                    QThread::msleep((Time.toFloat()*1000)+1500);
                }
                else
                {
                    QThread::msleep((NImage.toInt()*1000)+(Time.toFloat()*1000)+1500);
                }
                QByteArray text_response=myProcess->readAll();
                QString mystr(text_response);
                ui->textBrowser->setText(mystr);
                cont++;
                lee.replace(lee.size()-1,1,QString::number(cont));
                QImage image(256,256,QImage::Format_RGB32);
                QByteArray teste;
                QFile filestr(Save_Dir.absolutePath()+"/"+lee+".ppm");
                filestr.open(QIODevice::ReadOnly);
                teste=filestr.readAll();
                QString colorstr(teste);
                QStringList colors = colorstr.split(QRegExp("\\s+"));
                colors.removeLast();
                colors.removeFirst();
                colors.removeFirst();
                colors.removeFirst();
                colors.removeFirst();
                QVector<QRgb> colortable;
                Lookup_Tables ctable;
                colortable=ctable.colorPalete1280();
                image.setColorTable(colortable);
                int cont=0;
                for(int a=0;a<=255;a++)
                {
                    for(int b=0;b<=255;b++)
                    {
                        if(qCeil(colors.at(cont).toInt()/100)>=1536)
                        {
                            image.setPixel(b,a, image.colorTable().at(1535));
                        }
                        else
                        {
                            image.setPixel(b,a, image.colorTable().at(qCeil(colors.at(cont).toUInt()/100)));
                        }
                        cont++;
                    }
                }
                pixmap = QPixmap::fromImage(image,Qt::ColorOnly);
                pixmap=pixmap.scaled(512,512);
                scene= new QGraphicsScene(this);
                scene->addPixmap(pixmap);
                scene->update();
                ui->Plot_Window->setScene(scene);
                ui->Plot_Window->update();
                QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents);
            }
        }
    }
}
Example #20
0
	void addFile(const File& file) {
		std::fstream filestr (path + "/" + file.name, std::fstream::out);
		filestr << file.content <<std::endl;
		filestr.close();
	}