示例#1
0
void Dictionary::addWord(string& word){
	bool found = false;
	string key = word.substr(0, k);
	map< string, vector < Mot > >::iterator position = words.find(key);
	if(position != words.end()){
		vector<Mot>::iterator it = position->second.begin();
		while(it != position->second.end()){
			if(word.compare(it->getValue()) == 0){
				it->setNbrOccur(it->getNbrOccur() + 1);
				found = true;
				break;
			}
			it ++;
		}
	}
	if(! found){
		Mot nouveau(word);
		if(position != words.end()){
			position->second.push_back(nouveau);
		}else{
			vector<Mot> v;
			v.push_back(nouveau);
			words.insert(pair<string, vector<Mot> >(key, v));
		}
	}
}
示例#2
0
int MainWindow::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: nouveau(); break;
        case 1: s_creerNouveau(); break;
        case 2: s_annulerNouveau(); break;
        case 3: ouvrir(); break;
        case 4: importerTileset(); break;
        case 5: importerHerbe(); break;
        case 6: importerEntite(); break;
        case 7: importerEvenement(); break;
        case 8: sauver(); break;
        case 9: sauverAs(); break;
        case 10: undo(); break;
        case 11: redo(); break;
        case 12: script(); break;
        case 13: selectTileset((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 14: selectHerbe((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 15: selectEntite((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 16: selectEvenement((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 17: addTileset((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 18: addHerbe((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 19: addEntite((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        case 20: addEvenement((*reinterpret_cast< QTreeWidgetItem*(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        default: ;
        }
        _id -= 21;
    }
    return _id;
}
void insertion(Liste_Navires *l, int ideb, int jdeb, int ifin, int jfin) {
	Maillon *m = nouveau(ideb,jdeb,ifin,jfin);
	
	if(l->queue == NULL) { //S'il n'y a pas de queue, alors la liste est vide
		l->tete = m; //Insertion du maillon en tete
	} else {
		l->queue->suivant = m; //L'ancien dernier maillon de la liste pointe sur le nouveau maillon
	}
	
	l->queue = m; //La queue de la liste pointe désormais sur le nouveau maillon
}
示例#4
0
void Dictionary::load(string fileName){
	string value;
	int occ;
	ifstream input(fileName.c_str());
	while(! input.eof()){
		input >> value 
			>> occ;
		string key = value.substr(0, k);
		Mot nouveau(value, occ);
		map< string, vector < Mot > >::iterator position = words.find(key);
		if(position != words.end()){
			position->second.push_back(nouveau);
		}else{
			vector<Mot> v;
			v.push_back(nouveau);
			words.insert(pair<string, vector<Mot> >(key, v));	
		}
	}
	input.close();
}
示例#5
0
/**
 * @brief Constructeur
 *
 * Ce constructeur initialise toutes les fonctions de l'Interface Graphique de cette fenêtre : créer et organiser les
 * objets graphiques, et les connecter avec les bons slots.
 */
UVWindow::UVWindow() {
    setWindowTitle("UTProfiler");
    mainlayout = new QVBoxLayout();
    hlayout1 = new QHBoxLayout();
    pbretour = new QPushButton("Retour");
    lcode = new QLabel("Code : ");
    lecode = new QLineEdit();
    pbrechercher = new QPushButton("Rechercher");
    lresponsable = new QLabel("Responsable : ");
    leresponsable = new QLineEdit();
    hlayout1->addWidget(pbretour);
    hlayout1->addWidget(lcode);
    hlayout1->addWidget(lecode);
    hlayout1->addWidget(pbrechercher);
    hlayout1->addWidget(lresponsable);
    hlayout1->addWidget(leresponsable);
    hlayout2 = new QHBoxLayout();
    tedescription = new QTextEdit();
    vlayout21 = new QVBoxLayout();
    hlayout211 = new QHBoxLayout();
    lprintemps = new QLabel("Printemps : ");
    cbprintemps = new QCheckBox();
    hlayout211->addWidget(lprintemps);
    hlayout211->addWidget(cbprintemps);
    hlayout212 = new QHBoxLayout();
    lautomne = new QLabel("Automne : ");
    cbautomne = new QCheckBox();
    hlayout212->addWidget(lautomne);
    hlayout212->addWidget(cbautomne);
    vlayout21->addLayout(hlayout211);
    vlayout21->addLayout(hlayout212);
    hlayout2->addWidget(tedescription);
    hlayout2->addLayout(vlayout21);
    hlayout3 = new QHBoxLayout();
    lcs = new QLabel("CS : ");
    lecs = new QLineEdit();
    ltm = new QLabel("TM : ");
    letm = new QLineEdit();
    ltsh = new QLabel("TSH :");
    letsh = new QLineEdit();
    lsp = new QLabel("SP : ");
    lesp = new QLineEdit();
    hlayout3->addWidget(lcs);
    hlayout3->addWidget(lecs);
    hlayout3->addWidget(ltm);
    hlayout3->addWidget(letm);
    hlayout3->addWidget(ltsh);
    hlayout3->addWidget(letsh);
    hlayout3->addWidget(lsp);
    hlayout3->addWidget(lesp);

    hlayout4 = new QHBoxLayout();

    ltc = new QLabel("TC : ");
    cbtc = new QCheckBox();
    lhutech = new QLabel("HUTECH : ");
    cbhutech = new QCheckBox();
    lgb = new QLabel("GB : ");
    cbgb = new QCheckBox();
    lgi = new QLabel("GI : ");
    cbgi = new QCheckBox();
    lgm = new QLabel("GM : ");
    cbgm = new QCheckBox();
    lgp = new QLabel("GP : ");
    cbgp = new QCheckBox();
    lgsm = new QLabel("GSM : ");
    cbgsm = new QCheckBox();
    lgsu = new QLabel("GSU : ");
    cbgsu = new QCheckBox();

    hlayout4->addWidget(ltc);
    hlayout4->addWidget(cbtc);
    hlayout4->addWidget(lhutech);
    hlayout4->addWidget(cbhutech);
    hlayout4->addWidget(lgb);
    hlayout4->addWidget(cbgb);
    hlayout4->addWidget(lgi);
    hlayout4->addWidget(cbgi);
    hlayout4->addWidget(lgm);
    hlayout4->addWidget(cbgm);
    hlayout4->addWidget(lgp);
    hlayout4->addWidget(cbgp);
    hlayout4->addWidget(lgsm);
    hlayout4->addWidget(cbgsm);
    hlayout4->addWidget(lgsu);
    hlayout4->addWidget(cbgsu);
    hlayout5 = new QHBoxLayout();
    pbnouveau = new QPushButton("Nouveau");
    pbsupprimer = new QPushButton("Supprimer");
    pbsauver = new QPushButton("Sauver");
    hlayout5->addWidget(pbnouveau);
    hlayout5->addWidget(pbsupprimer);
    hlayout5->addWidget(pbsauver);
    mainlayout->addLayout(hlayout1);
    mainlayout->addLayout(hlayout2);
    mainlayout->addLayout(hlayout3);
    mainlayout->addLayout(hlayout4);
    mainlayout->addLayout(hlayout5);
    this->setLayout(mainlayout);
    QObject::connect(pbretour,SIGNAL(clicked()),this,SLOT(close()));
    QObject::connect(pbsupprimer,SIGNAL(clicked()),this,SLOT(supprimer()));
    QObject::connect(pbnouveau,SIGNAL(clicked()),this,SLOT(nouveau()));
    QObject::connect(lecode,SIGNAL(returnPressed()),this,SLOT(rechercher()));
    QObject::connect(pbrechercher,SIGNAL(clicked()),this,SLOT(rechercher()));
    QObject::connect(pbsauver,SIGNAL(clicked()),this,SLOT(sauver()));
    QObject::connect(leresponsable,SIGNAL(textChanged(QString)),this,SLOT(pbsauverEnable()));
    QObject::connect(tedescription,SIGNAL(textChanged()),this,SLOT(pbsauverEnable()));
    QObject::connect(lecs,SIGNAL(textChanged(QString)),this,SLOT(pbsauverEnable()));
    QObject::connect(letm,SIGNAL(textChanged(QString)),this,SLOT(pbsauverEnable()));
    QObject::connect(letsh,SIGNAL(textChanged(QString)),this,SLOT(pbsauverEnable()));
    QObject::connect(lesp,SIGNAL(textChanged(QString)),this,SLOT(pbsauverEnable()));
    QObject::connect(cbprintemps,SIGNAL(stateChanged(int)),this,SLOT(pbsauverEnable()));
    QObject::connect(cbautomne,SIGNAL(stateChanged(int)),this,SLOT(pbsauverEnable()));
    QObject::connect(cbtc,SIGNAL(stateChanged(int)),this,SLOT(pbsauverEnable()));
    QObject::connect(cbhutech,SIGNAL(stateChanged(int)),this,SLOT(pbsauverEnable()));
    QObject::connect(cbgb,SIGNAL(stateChanged(int)),this,SLOT(pbsauverEnable()));
    QObject::connect(cbgi,SIGNAL(stateChanged(int)),this,SLOT(pbsauverEnable()));
    QObject::connect(cbgm,SIGNAL(stateChanged(int)),this,SLOT(pbsauverEnable()));
    QObject::connect(cbgp,SIGNAL(stateChanged(int)),this,SLOT(pbsauverEnable()));
    QObject::connect(cbgsm,SIGNAL(stateChanged(int)),this,SLOT(pbsauverEnable()));
    QObject::connect(cbgsu,SIGNAL(stateChanged(int)),this,SLOT(pbsauverEnable()));
}
InterfaceImages::InterfaceImages(QWidget *parent) :
    QMainWindow(parent)
{
    //initialisation des méthodes de cryptage
    m_methodesDeCryptage = getMethodes();
    m_indexMethodeDeCryptage = 0;
    m_password = "";

    //initialisation des membres de l'objet
    m_fichierImage = NULL;
    m_vueImage = NULL;
    m_labelDimensionsImage = NULL;
    m_labelPlaceImage = NULL;
    m_nouvelleImage = true;
    m_imageEnCours = false;

    //initialisation des menus
    m_menuFichier = menuBar()->addMenu("&Fichier");
    m_actionNouveau = m_menuFichier->addAction("&Nouveau");
    m_actionNouveau->setShortcut(QKeySequence("Ctrl+n"));

    m_actionOuvrir = m_menuFichier->addAction("&Ouvrir");
    m_actionOuvrir->setShortcut(QKeySequence("Ctrl+O"));

    m_actionEnregistrer = m_menuFichier->addAction("&Enregistrer");
    m_actionEnregistrer->setShortcut(QKeySequence("Ctrl+s"));

    m_actionEnregistrerSous = m_menuFichier->addAction("&Enregistrer Sous");
    m_actionEnregistrerSous->setShortcut(QKeySequence("Ctrl+Alt+s"));

    QList<QKeySequence> raccourcisQuitter;
    raccourcisQuitter.push_back(QKeySequence("Ctrl+Q"));
    raccourcisQuitter.push_back(QKeySequence("Escape"));
    m_actionQuitter = m_menuFichier->addAction("&Quitter");
    m_actionQuitter->setShortcuts(raccourcisQuitter);

    m_menuMethodeCryptage = menuBar()->addMenu("&Méthode de cryptage");
    m_actionChangerMethodeCryptage = m_menuMethodeCryptage->addAction("&Changer de méthode");
    m_actionChangerMethodeCryptage->setShortcut(QKeySequence("Ctrl+c"));
    m_actionChangerPassword = m_menuMethodeCryptage->addAction("&Changer de mot de passe");
    m_actionChangerPassword->setShortcut(QKeySequence("Ctrl+p"));

    //initialisation de la zone centrale
    m_textePasDimageEncours = new QLabel("Sélectionnez une image.", this);
    m_textePasDimageEncours->setAlignment(Qt::AlignCenter);

    m_textEdit = new QTextEdit("", this);
    m_nombreDeCaracteresTexte = new QLabel(this);
    updateNombreCaracteres();
    m_layoutTexte = new QVBoxLayout(this);
    m_layoutTexte->addWidget(m_textEdit);
    m_layoutTexte->addWidget(m_nombreDeCaracteresTexte);
//    std::vector<bool> in = Cryptage::stringToBits("Abc déàî");
//    std::vector<bool> in = Cryptage::uintToBytes(9);
//    std::string texte;
//    for(unsigned int i = 0; i < in.size(); i++)
//    {
//        std::cerr << "coucou";
//        texte += char('0'+in[i]);
//    }
//    Cryptage::bitsToString(in, texte);
//    m_textEdit->setText(QString(texte.c_str()));
//      m_textEdit->setText(QString(texte.c_str()));

//      std::cerr << "test : " << Cryptage::bitsToUint(Cryptage::uintToBits(504)) << std::endl;


    m_vueImage = new QLabel(this);
    m_vueImage->setPixmap(m_image);
    m_labelDimensionsImage = new QLabel(this);
    m_labelPlaceImage = new QLabel(this);

    m_layoutImage = new QVBoxLayout;
    m_layoutImage->addWidget(m_vueImage);
    m_layoutImage->addWidget(m_labelDimensionsImage);
    m_layoutImage->addWidget(m_labelPlaceImage);

    m_frameImage = new QFrame(this);
    m_frameImage->setFrameShape(QFrame::StyledPanel);
    m_frameImage->setLayout(m_layoutImage);
    redimensionnerImage();

    m_layoutPrincipal = new QHBoxLayout;
    m_layoutPrincipal->addLayout(m_layoutTexte);
    m_layoutPrincipal->addWidget(m_frameImage);

    m_zoneCentrale = new QWidget;
    m_zoneCentrale->setLayout(m_layoutPrincipal);
    setCentralWidget(m_textePasDimageEncours);

    //initialisation des signaux et des slots
    connect(m_actionQuitter, SIGNAL(triggered ()), qApp, SLOT(quit()));
    connect(m_actionNouveau, SIGNAL(triggered ()), this, SLOT(nouveau()));
    connect(m_actionOuvrir, SIGNAL(triggered ()), this, SLOT(ouvrir()));
    connect(m_actionEnregistrerSous, SIGNAL(triggered ()), this, SLOT(enregistrerSous()));
    connect(m_actionEnregistrer, SIGNAL(triggered ()), this, SLOT(enregistrer()));
    connect(m_actionChangerMethodeCryptage, SIGNAL(triggered ()), this, SLOT(changerLaMethodeDeCryptage()));
    connect(m_actionChangerPassword, SIGNAL(triggered ()), this, SLOT(changerPassword()));
    connect(m_textEdit, SIGNAL(textChanged ()), this, SLOT(updateNombreCaracteres()));
}
示例#7
0
void PixEditor::addMenu()
{
    //Fichier
    precedent_action=new QAction(tr("&Precedent"),this);
    precedent_action->setIcon(QIcon("./icones/precedent.jpg"));
    precedent_action->setStatusTip(tr("Precedent"));
    QObject::connect(precedent_action,SIGNAL(triggered()),&widgetcentral,SLOT(precedent()));

    //
    nouveau_action = new QAction(tr("&Nouveau"), this);
    nouveau_action->setIcon(QIcon("./icones/window-new-3.png"));
    nouveau_action->setShortcut(tr("Ctrl+N"));
    nouveau_action->setStatusTip(tr("Nouvelle image"));
    QObject::connect(nouveau_action, SIGNAL(triggered()), &widgetcentral, SLOT(nouveau()));

    ouvrir_action = new QAction(tr("&Ouvrir"), this);
    ouvrir_action->setShortcut(tr("Ctrl+O"));
    ouvrir_action->setIcon(QIcon("./icones/OpenButton.png"));
    ouvrir_action->setStatusTip(tr("Charger une image"));
    QObject::connect(ouvrir_action, SIGNAL(triggered()), &widgetcentral, SLOT(ouvrir()));

    sauver_action = new QAction(tr("&Sauvegarder"), this);
    sauver_action->setShortcut(tr("Ctrl+S"));
    sauver_action->setIcon(QIcon("./icones/enregistrer.png"));
    sauver_action->setStatusTip(tr("Sauvegarder l'image"));
    QObject::connect(sauver_action, SIGNAL(triggered()), &widgetcentral, SLOT(sauvegarder()));

    sauversous_action = new QAction(tr("S&auvegarder sous..."), this);
    sauversous_action->setShortcut(tr("Ctrl+Shift+S"));
    sauversous_action->setIcon(QIcon("./icones/enregistrer-sous.png"));
    sauversous_action->setStatusTip(tr("Sauvegarder l'image sous..."));
    connect(sauversous_action, SIGNAL(triggered()), &widgetcentral, SLOT(sauvegarderSous()));

    quitter_action = new QAction(tr("&Quitter"), this);
    quitter_action->setStatusTip(tr("Quitter le programme"));
    quitter_action->setIcon(QIcon("./icones/icone-infos.png"));
    QObject::connect(quitter_action, SIGNAL(triggered()), &widgetcentral, SLOT(quitter()));

    menu_fichier = new QMenu(tr("&Fichier"), this);
    menu_fichier->addAction(precedent_action);
    menu_fichier->addAction(nouveau_action);
    menu_fichier->addAction(ouvrir_action);
    menu_fichier->addAction(sauver_action);
    menu_fichier->addAction(sauversous_action);
    menu_fichier->addAction(quitter_action);

    // Filtre
    flou_action = new QAction(tr("&F&lou"), this);
    flou_action->setStatusTip(tr("Appliquer un flou  l'image"));
    flou_action->setIcon(QIcon("./icones/flou.gif"));
    QObject::connect(flou_action, SIGNAL(triggered()), &widgetcentral, SLOT(loadflou()));

    fusion_action = new QAction(tr("&F&usion"), this);
    fusion_action->setStatusTip(tr("Fusionner l'image avec une autre"));
    QObject::connect(fusion_action, SIGNAL(triggered()), &widgetcentral, SLOT(loadfusion()));

    gris_action = new QAction(tr("&Gris"),this);
    gris_action->setStatusTip("Appliquer un gris l'image");
    QObject::connect(gris_action,SIGNAL(triggered()),&widgetcentral,SLOT(gris()));

    rehaussement_action = new QAction(tr("&Rehaussement de contraste"),this);
    rehaussement_action->setStatusTip("Rehausser le contraste");
    QObject::connect(rehaussement_action,SIGNAL(triggered()),&widgetcentral,SLOT(loadrehausseur()));

    detection_action = new QAction(tr("&Detecter les contours"),this);
    detection_action->setStatusTip("Detection de contour");
    QObject::connect(detection_action,SIGNAL(triggered()),&widgetcentral,SLOT(loaddetection()));

    gradient_action = new QAction(tr("&Gradient"),this);
    gradient_action->setStatusTip("Gradient");
    QObject::connect(gradient_action,SIGNAL(triggered()),&widgetcentral,SLOT(loadgradient()));

    perso_action = new QAction(tr("&Personnaliser"),this);
    perso_action->setStatusTip("Personnaliser le filtre");
    QObject::connect(perso_action,SIGNAL(triggered()),&widgetcentral,SLOT(loadperso()));

    accent_action = new QAction(tr("&Accentuer"),this);
    accent_action->setStatusTip("Accentuer l'image");
    QObject::connect(accent_action,SIGNAL(triggered()),&widgetcentral,SLOT(loadaccentuer()));

    menu_outils = new QMenu(tr("&F&iltre"), this);
    menu_outils->addAction(flou_action);
    menu_outils->addAction(fusion_action);
    menu_outils->addAction(gris_action);
    menu_outils->addAction(rehaussement_action);
    menu_outils->addAction(detection_action);
    menu_outils->addAction(gradient_action);
    menu_outils->addAction(perso_action);
    menu_outils->addAction(accent_action);

    //histogramme
    histo_menu=new QMenu(tr("&Histogramme"),this);

    histoRGB_action = new QAction(tr("&RGB"),this);
    QObject::connect(histoRGB_action, SIGNAL(triggered()), &widgetcentral, SLOT(histogrammeRGB()));
    histo_menu->addAction(histoRGB_action);

    histoHSV_action = new QAction(tr("&HSV"),this);
    QObject::connect(histoHSV_action, SIGNAL(triggered()), &widgetcentral, SLOT(histogrammeHSV()));
    histo_menu->addAction(histoHSV_action);

    egalise_action = new QAction(tr("&Egaliser"),this);
    QObject::connect(egalise_action, SIGNAL(triggered()), &widgetcentral, SLOT(egalisation()));
    histo_menu->addAction(egalise_action);

    linearise_action = new QAction(tr("&Lineariser"),this);
    QObject::connect(linearise_action, SIGNAL(triggered()), &widgetcentral, SLOT(linearisation()));
    histo_menu->addAction(linearise_action);

    negatif_action = new QAction(tr("&Negatif"),this);
    QObject::connect(negatif_action, SIGNAL(triggered()), &widgetcentral, SLOT(negatif()));
    histo_menu->addAction(negatif_action);

    seuillage_action = new QAction(tr("&Seuillage"),this);
    QObject::connect(seuillage_action, SIGNAL(triggered()), &widgetcentral, SLOT(seuillage()));
    histo_menu->addAction(seuillage_action);

    //color_picker
    picker_action = new QAction(tr("&P&i&xelColor"),this);
    picker_action->setStatusTip("Pixel valeur");
    picker_action->setIcon(QIcon("./icones/icones/pixelcolor.jpg"));
    QObject::connect(picker_action, SIGNAL(triggered()), widgetcentral.affichage, SLOT(pixelColor()));
    color_picker = new QMenu(tr("&Picolor"),this);
    color_picker->addAction(picker_action);

    //Selection
    menu_selection = new QMenu(tr("&Se&lection"),this);
    selection_action=new QAction(tr("&selection"),this);
    QObject::connect(selection_action, SIGNAL(triggered()), widgetcentral.affichage, SLOT(selection()));
    menu_selection->addAction(selection_action);

    //redimension

    redim_action = new QAction(tr("&R&edimension"),this);
    redim_action->setStatusTip("Appliquer le redimensionnement  l'image");
    QObject::connect(redim_action,SIGNAL(triggered()),&widgetcentral,SLOT(redimension()));
    seam_action = new QAction(tr("&Seam Carving"),this);
    seam_action->setStatusTip("Redimensionnement intelligent");
    QObject::connect(seam_action,SIGNAL(triggered()),&widgetcentral,SLOT(loadseam()));

    menu_redimension = new QMenu (tr ("&R&e&dimension"), this);
    menu_redimension->addAction(redim_action);
    menu_redimension->addAction(seam_action);

    barre_menu = new QMenuBar(this);
    barre_menu->addMenu(menu_fichier);
    barre_menu->addMenu(menu_outils);
    barre_menu->addMenu(histo_menu);
    barre_menu->addMenu(color_picker);
    barre_menu->addMenu(menu_selection);
    barre_menu->addMenu(menu_redimension);

    setMenuBar(barre_menu);
}