ShaderManager::ShaderManager(const std::string &VS, const std::string &FS) { m_vertexShaderString = loadTextFromFile(VS); m_fragmentShaderString = loadTextFromFile(FS); m_shaderLoader = new ShaderLoader(m_vertexShaderString.c_str(), m_fragmentShaderString.c_str()); std::cout << "ShaderManager created" << std::endl; }
ShaderInterface::ShaderInterface(const char *VS, const char *FS) { _vertexShaderString = loadTextFromFile(VS); _fragmentShaderString = loadTextFromFile(FS); shader = new ShaderLoader(_vertexShaderString, _fragmentShaderString); free(_vertexShaderString); free(_fragmentShaderString); _aPositionVertex = glGetAttribLocation(shader->getProgramHandle(), "aPositionVertex"); _uColor = glGetUniformLocation(shader->getProgramHandle(), "uColor"); }
ShaderInterface::ShaderInterface(const char *vs, const char *fs) { _vertexShaderString = loadTextFromFile(vs); _fragmentShaderString = loadTextFromFile(fs); shader = new ShaderLoader(_vertexShaderString, _fragmentShaderString); free(_vertexShaderString); free(_fragmentShaderString); _aPositionVertex = glGetAttribLocation(shader->getProgramHandle(), "aPositionVertex"); _aPositionNormal = glGetAttribLocation(shader->getProgramHandle(), "aPositionNormal"); _uColor = glGetUniformLocation(shader->getProgramHandle(), "uColor"); _uPositionLight = glGetUniformLocation(shader->getProgramHandle(), "uPositionLight"); }
TEST(WordCountOpenMPTest, FileParAndSeqTest) { pair<const char*, size_t> text = loadTextFromFile("book.txt"); auto counted1 = countWords(text.first, text.second); auto flipped1 = flipMap<string, int>(counted1); auto counted2 = countWordsOpenMP(text.first, text.second, defaultThreadCount); auto flipped2 = flipMap<string, int>(counted2); ASSERT_TRUE(std::equal(flipped1.rbegin(), flipped1.rend(), flipped2.rbegin())); }
TEST(WordCountOpenMPTest, FileTest) { pair<const char*, size_t> text = loadTextFromFile("book.txt"); auto counted = countWordsOpenMP(text.first, text.second, defaultThreadCount); auto flipped = flipMap<string, int>(counted); wordStatFlipped m = {{20304, "и"}, {10198, "в"}, {8428, "не"}, {7822, "что"}, {6453, "на"}}; ASSERT_TRUE(std::equal(m.rbegin(), m.rend(), flipped.rbegin())); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); preferencesDialog = new PreferencesDialog(); fontDialog = new FontDialog(); errorMessage = new QErrorMessage(); sheetNumberLabel = new QLabel("<h2>1</h2>"); sheetNumberLabel->setToolTip(tr("Number of Current Sheet")); sheetNumberLabel->setFrameShape(QFrame::Panel); sheetNumberLabel->setFrameShadow(QFrame::Sunken); sheetNumberLabel->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); sheetNumberLabel->setMinimumWidth(ui->toolBar->height()); errorMessage->setMinimumSize(200, 150); //----File---- connect(ui->actionConvert_to_Handwritten, SIGNAL(triggered()), this, SLOT(renderFirstSheet())); connect(ui->actionLoad_Text_from_File, SIGNAL(triggered()), this, SLOT(loadTextFromFile())); connect(ui->actionLoad_Font, SIGNAL(triggered()), this, SLOT(loadFont())); connect(ui->actionFont_Editor, SIGNAL(triggered()), fontDialog, SLOT(exec())); connect(ui->actionSave_Current_Sheet_as, SIGNAL(triggered()), this, SLOT(saveSheet())); connect(ui->actionSave_All_Sheets, SIGNAL(triggered()), this, SLOT(saveAllSheets())); connect(ui->actionPrint_Current_Sheet, SIGNAL(triggered()), this, SLOT(printSheet())); connect(ui->actionPrint_All, SIGNAL(triggered()), this, SLOT(printAllSheets())); //----Edit---- //connect menu action "Show Toolbar" connect(ui->actionShow_ToolBar, SIGNAL(triggered(bool)), ui->toolBar, SLOT(setVisible(bool))); connect(ui->toolBar, SIGNAL(visibilityChanged(bool)), ui->actionShow_ToolBar, SLOT(setChecked(bool))); //preferencesDialog connections connect(ui->actionPreferences, SIGNAL(triggered()), preferencesDialog, SLOT(exec())); connect(preferencesDialog, SIGNAL(settingsChanged()), this, SLOT(loadSettings())); //----Help---- connect(ui->actionAbout_Scribbler, SIGNAL(triggered()), this, SLOT(showAboutBox())); connect(ui->actionLicenses_and_Credits, SIGNAL(triggered()), this, SLOT(showLicensesBox())); connect(ui->actionHowTo, SIGNAL(triggered()), this, SLOT(showHowToBox())); //----ToolBar---- //add actions to tool bar and connect them to slots connect(ui->toolBar->addAction(QPixmap("://render.png"), tr("Convert to Handwritten")), SIGNAL(triggered(bool)), this, SLOT(renderFirstSheet())); connect(ui->toolBar->addAction(QPixmap("://printer.png"), tr("Print Sheets")), SIGNAL(triggered(bool)), this, SLOT(printAllSheets())); connect(ui->toolBar->addAction(QPixmap("://save.png"), tr("Save Sheets")), SIGNAL(triggered(bool)), this, SLOT(saveAllSheets())); ui->toolBar->addSeparator(); connect(ui->toolBar->addAction(QPixmap("://left.png"), tr("Previous Sheet")), SIGNAL(triggered(bool)), this, SLOT(renderPreviousSheet())); ui->toolBar->addWidget(sheetNumberLabel); connect(ui->toolBar->addAction(QPixmap("://right.png"), tr("Next Sheet")), SIGNAL(triggered(bool)), this, SLOT(renderNextSheet())); connect(fontDialog, SIGNAL(fontReady()), this, SLOT(updateCurrentSheet())); errorMessage->setModal(true); ui->toolBar->actions()[ToolButton::Render]->setShortcut(Qt::ControlModifier + Qt::Key_R); ui->toolBar->actions()[ToolButton::Print]->setShortcut(Qt::ControlModifier + Qt::Key_P); ui->toolBar->actions()[ToolButton::Save]->setShortcut(Qt::ControlModifier + Qt::Key_S); ui->toolBar->actions()[ToolButton::Next]->setShortcut(Qt::ControlModifier + Qt::Key_Right); ui->toolBar->actions()[ToolButton::Previous]->setShortcut(Qt::ControlModifier + Qt::Key_Left); ui->textEdit->installEventFilter(this); ui->toolBar->actions()[ToolButton::Next]->setDisabled(true); ui->toolBar->actions()[ToolButton::Previous]->setDisabled(true); //initialize some class members sheetPointers.push_back(0); currentSheetNumber = 0; preferencesDialog->loadSettingsFromFile(); preferencesDialog->loadSettingsToFile(); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); preferencesDialog = new PreferencesDialog(); fontDialog = new FontDialog(); //----File---- connect(ui->actionConvert_to_Handwritten, SIGNAL(triggered()), this, SLOT(renderFirstSheet())); connect(ui->actionLoad_Text_from_File, SIGNAL(triggered()), this, SLOT(loadTextFromFile())); connect(ui->actionLoad_Font, SIGNAL(triggered()), this, SLOT(loadFont())); connect(ui->actionFont_Editor, SIGNAL(triggered()), fontDialog, SLOT(exec())); connect(ui->actionSave_Current_Sheet_as, SIGNAL(triggered()), this, SLOT(saveSheet())); connect(ui->actionSave_All_Sheets, SIGNAL(triggered()), this, SLOT(saveAllSheets())); connect(ui->actionPrint_Current_Sheet, SIGNAL(triggered()), this, SLOT(printSheet())); connect(ui->actionPrint_All, SIGNAL(triggered()), this, SLOT(printAllSheets())); //----Edit---- //connect menu action "Show Toolbar" connect(ui->actionShow_ToolBar, SIGNAL(triggered(bool)), ui->toolBar, SLOT(setVisible(bool))); connect(ui->toolBar, SIGNAL(visibilityChanged(bool)), ui->actionShow_ToolBar, SLOT(setChecked(bool))); //preferencesDialog connections connect(ui->actionPreferences, SIGNAL(triggered()), preferencesDialog, SLOT(exec())); connect(preferencesDialog, SIGNAL(settingsChanged()), ui->svgView, SLOT(loadSettingsFromFile())); //----Help---- connect(ui->actionAbout_Scribbler, SIGNAL(triggered()), this, SLOT(showAboutBox())); connect(ui->actionLicenses_and_Credits, SIGNAL(triggered()), this, SLOT(showLicensesBox())); //----ToolBar---- //add actions to tool bar and connect them to slots connect(ui->toolBar->addAction(QPixmap("://render.png"), tr("Convert to Handwritten")), SIGNAL(triggered(bool)), this, SLOT(renderFirstSheet())); connect(ui->toolBar->addAction(QPixmap("://printer.png"), tr("Print Current Sheet")), SIGNAL(triggered(bool)), this, SLOT(printSheet())); connect(ui->toolBar->addAction(QPixmap("://save.png"), tr("Save Current Sheet as Image")), SIGNAL(triggered(bool)), this, SLOT(saveSheet())); ui->toolBar->addSeparator(); connect(ui->toolBar->addAction(QPixmap("://right.png"), tr("Next Sheet")), SIGNAL(triggered(bool)), this, SLOT(renderNextSheet())); connect(ui->toolBar->addAction(QPixmap("://left.png"), tr("Previous Sheet")), SIGNAL(triggered(bool)), this, SLOT(renderPreviousSheet())); connect(fontDialog, SIGNAL(fontReady()), ui->svgView, SLOT(loadFont())); ui->toolBar->actions()[4]->setDisabled(true); ui->toolBar->actions()[5]->setDisabled(true); //initialize some class members sheetPointers.push_back(0); currentSheetNumber = 0; version = "0.4 alpha"; preferencesDialog->loadSettingsFromFile(); /* This is a hack to avoid a bug. When program starts, it needs some time * (at least 1 ms on my configuration, but I set delay to 100 ms just to be sure * that it will work on weaker machines) before it can write settings to file, * otherwise ui->colorButton->palette().background().color() will return * default buttons background color, which will be written to settings * file at once program launches. */ QTime dieTime = QTime::currentTime().addMSecs(100); while (QTime::currentTime() < dieTime) QCoreApplication::processEvents(QEventLoop::AllEvents, 100); preferencesDialog->loadSettingsToFile(); }