int build_representation (unsigned char *text, unsigned int length, unsigned int *docBeginnings, unsigned int numdocs, char *build_options, void **representation) { sprintf(tmp_filename,"%s.%u", "tmp_filename" ,getpid()); sprintf(tmp_filename_rev,"%s.%u.%s", "tmp_filename" ,getpid(),"rev"); sprintf(tmp_filename_sa,"%s.%u.%s", "tmp_filename" ,getpid(),"rev.sa"); sprintf(tmp_filename_char,"%s.%u.%s", "tmp_filename" ,getpid(),"char"); sprintf(tmp_filename_len,"%s.%u.%s", "tmp_filename" ,getpid(), "len"); sprintf(tmp_filename_sources,"%s.%u.%s", "tmp_filename" ,getpid(), "start"); sprintf(tmp_filename_doc,"%s.%u.%s", "tmp_filename" ,getpid(),"doclen"); saveText(text, length, tmp_filename); LZparser* p; p = new LZEnd2(tmp_filename); p->parse(); lzdoc* repr = (lzdoc*)malloc(sizeof(lzdoc)); repr->extractor = new ExtractorEnd2(tmp_filename, DELTA_SAMPLING); repr->docs = numdocs; unsigned int* doc_len = new unsigned int[numdocs]; for(unsigned int i=0;i<numdocs;i++){ doc_len[i] = docBeginnings[i+1]-docBeginnings[i]; } repr->doc_array = new DeltaCodes(doc_len,numdocs, DELTA_SAMPLING); saveText((unsigned char*)doc_len, repr->docs*sizeof(unsigned int), tmp_filename_doc); delete[] doc_len; *representation = repr; return 0; }
int main() { int input = 0; while( input != 4 ) { puts("=== Text Editor ==="); puts("1. Edit Text"); puts("2. Save Text"); puts("3. Load Text"); puts("4. Exit"); scanf("%d", &input); switch( input ) { case 1: editText(); break; case 2: saveText(); break; case 3: loadText(); break; case 4: break; default: break; } } free(text); }
void MainForm::closeEvent(QCloseEvent *event) { if (!textSaved) { QPixmap icon; icon.load(":/info.png"); QMessageBox messageBox(QMessageBox::NoIcon, "YAGF", trUtf8("There is an unsaved text in the editor window. Do you want to save it?"), QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, this); messageBox.setIconPixmap(icon); int result = messageBox.exec(); if (result == QMessageBox::Save) saveText(); else if (result == QMessageBox::Cancel) { event->ignore(); return; } } scanProcess->terminate(); settings.setFontSize(textEdit->font().pointSize()); settings.setSize(size()); settings.setPosition(pos()); settings.setFullScreen(isFullScreen()); settings.writeSettings(); delTmpFiles(); event->accept(); QXtUnixSignalCatcher::catcher()->disconnectUnixSugnals(); }
void COverlappedWindow::onCommand(WPARAM wParam, LPARAM lParam) { switch (LOWORD(wParam)) { case ID_FILE_EXIT: onClose(); break; case ID_FILE_SAVE: saveText(); ::ModifyMenu(::GetMenu(handle), 0, MF_BYPOSITION | MF_GRAYED, NULL, MF_STRING); ::EnableMenuItem(::GetMenu(handle), ID_FILE_EXIT, MF_DISABLED | MF_GRAYED); break; case ID_WORDSCOUNT: countWordsInText(); break; case IDCLOSE: onDestroy(); break; } if (EN_CHANGE == HIWORD(wParam)) { textChanged = true; } if (HIWORD(wParam) == EN_ERRSPACE || HIWORD(wParam) == EN_MAXTEXT) { ::MessageBox(handleEdit, L"Edit control out of space", L"ERROR", MB_OK | MB_ICONSTOP); } }
void CMyNotepad::onCommand(WPARAM wParam, LPARAM lParam) { switch (LOWORD(wParam)) { case ID_FILE_EXIT: onClose(); break; case ID_FILE_SAVE: saveText(); break; case ID_FILE_OPEN: openFile(); break; case ID_FILE_CLEAR: onClear(); break; case IDCLOSE: onDestroy(); break; } if (EN_CHANGE == HIWORD(wParam)) { textChanged = true; } if (HIWORD(wParam) == EN_ERRSPACE || HIWORD(wParam) == EN_MAXTEXT) { ::MessageBox(handleEdit, L"Edit control out of space", L"ERROR", MB_OK | MB_ICONSTOP); } }
void MainWindow::on_exportSavePushButton_clicked() { QListWidget* savesList = findChild<QListWidget*>("vesselsInSaveListView"); QTextEdit* savePathTextField = this->findChild<QTextEdit*>("SavePathTextEdit"); QString pathToSave = savePathTextField->toPlainText(); QFile saveFile(pathToSave); if(!saveFile.exists() || !pathToSave.endsWith(".sfs") || !saveFile.open(QIODevice::ReadOnly)) { QMessageBox::warning(0, "Unable to open save file for writing", "When attempting to export new save, file was not opened."); } QString saveText(saveFile.readAll()); std::size_t headerEnd = saveText.indexOf("VESSEL"); QString header = saveText.left(headerEnd); saveFile.close(); saveFile.open(QIODevice::WriteOnly | QIODevice::Truncate); m_diagnosticsWindow->append(QString("Isolated header:\n") + header + QString("\n--Writing vessels to save--\n")); std::stringstream stringBuilder; for(int i = 0; i < savesList->count(); i++) { VesselListWidgetItem* item = (VesselListWidgetItem*)savesList->item(i); stringBuilder << item->GetVesselData()->AccessFullText()->toStdString(); } stringBuilder << "}\n}"; saveFile.write(header.toLocal8Bit()); saveFile.write(stringBuilder.str().c_str()); saveFile.close(); }
void CMyNotepad::onClose() { if (textChanged) { UINT buttonPressed = ::MessageBox(handle, L"Do you want to save your work?", L"My application", MB_ICONQUESTION | MB_YESNOCANCEL); if (buttonPressed == IDYES) { saveText(); ::DestroyWindow(handle); } if (buttonPressed == IDNO) { ::DestroyWindow(handle); } if (buttonPressed == IDCANCEL) { return; } } else { ::DestroyWindow(handle); } }
void Transcribe::openTextFile(const QString& path) { // Because the way the UI works, we can assume that the text is not dirty // So if the file exists, we load the contents into the editor window. if (m_text_file) { m_text_file->deleteLater(); } m_text_file = new QFile(path); if (m_text_file->exists()) { if (m_text_file->open(QIODevice::ReadOnly | QIODevice::Text)) { QTextStream in_stream(m_text_file); QVariant text(in_stream.readAll()); QQmlProperty::write(m_text_area, "text", text); m_text_file->close(); setTextDirty(false); // QML has signalled text is dirty because we changed // text, so we need reset this. } else { QString msg = tr("The text file can't be read"); errorDetected(msg); m_text_file = NULL; return; } } else { // If the text file doesn't exist, empty the editor and create the file // by saving the text to it QQmlProperty::write(m_text_area, "text", QVariant("")); if (!saveText()) return; } // Update the gui emit textFileNameChanged(); QQmlProperty::write(m_main_window, "is_editable", QVariant(true)); setTextDirty(false); }
void numColorsBaseModes::appendColorList(QDomDocument* doc, QDomElement* appendee) { if (!clickedColorList().isEmpty()) { ::appendColorList(doc, clickedColorList(), appendee, "mode", saveText()); } }
void PictureShape::saveOdf(KoShapeSavingContext &context) const { // make sure we have a valid image data pointer before saving KoImageData *imageData = qobject_cast<KoImageData*>(userData()); if (imageData == 0) { return; } KoXmlWriter &writer = context.xmlWriter(); writer.startElement("draw:frame"); saveOdfAttributes(context, OdfAllAttributes); writer.startElement("draw:image"); // In the spec, only the xlink:href attribute is marked as mandatory, cool :) QString name = context.imageHref(imageData); writer.addAttribute("xlink:type", "simple"); writer.addAttribute("xlink:show", "embed"); writer.addAttribute("xlink:actuate", "onLoad"); writer.addAttribute("xlink:href", name); saveText(context); writer.endElement(); // draw:image QSizeF scaleFactor(imageData->imageSize().width() / size().width(), imageData->imageSize().height() / size().height()); saveOdfClipContour(context, scaleFactor); writer.endElement(); // draw:frame context.addDataCenter(m_imageCollection); }
void MainWindow::saveAsFile(void) { QString lSaveFileName = QFileDialog::getSaveFileName(this,"Save As ..."); if(lSaveFileName.isEmpty()) return; if(saveText(lSaveFileName)) setFileName(lSaveFileName); }
QGraphicsTekstComp::QGraphicsTekstComp(Tekst *tekst, QGraphicsItem *parent /*= 0*/) : QGraphicsSmartTextItem(tekst, parent), m_pTekstIntern(tekst) { assert(m_pTekstIntern != NULL); setPlainText(QString::fromStdString(m_pTekstIntern->GetInhoud())); // SetFont, SetPos en setTextWidth worden in de constructor van SmartTextItem al opgeroepen! connect(document(), SIGNAL(contentsChanged()), this, SLOT(saveText())); }
void MainWindow::saveFile(void) { if(mFileName.isEmpty()) { saveAsFile(); return; } saveText(mFileName); }
void RectangleShape::saveOdf(KoShapeSavingContext & context) const { if (isParametricShape()) { context.xmlWriter().startElement("draw:rect"); saveOdfAttributes(context, OdfAllAttributes); if (m_cornerRadiusX > 0 && m_cornerRadiusY > 0) { context.xmlWriter().addAttributePt("svg:rx", m_cornerRadiusX * (0.5*size().width()) / 100.0); context.xmlWriter().addAttributePt("svg:ry", m_cornerRadiusY * (0.5*size().height()) / 100.0); } saveOdfCommonChildElements(context); saveText(context); context.xmlWriter().endElement(); } else { KoPathShape::saveOdf(context); } }
void KoConnectionShape::saveOdf(KoShapeSavingContext & context) const { Q_D(const KoConnectionShape); context.xmlWriter().startElement("draw:connector"); saveOdfAttributes(context, OdfMandatories | OdfAdditionalAttributes); switch (d->connectionType) { case Lines: context.xmlWriter().addAttribute("draw:type", "lines"); break; case Straight: context.xmlWriter().addAttribute("draw:type", "line"); break; case Curve: context.xmlWriter().addAttribute("draw:type", "curve"); break; default: context.xmlWriter().addAttribute("draw:type", "standard"); break; } if (d->shape1) { context.xmlWriter().addAttribute("draw:start-shape", context.xmlid(d->shape1, "shape", KoElementReference::Counter).toString()); context.xmlWriter().addAttribute("draw:start-glue-point", d->connectionPointId1); } else { QPointF p(shapeToDocument(d->handles[StartHandle]) * context.shapeOffset(this)); context.xmlWriter().addAttributePt("svg:x1", p.x()); context.xmlWriter().addAttributePt("svg:y1", p.y()); } if (d->shape2) { context.xmlWriter().addAttribute("draw:end-shape", context.xmlid(d->shape2, "shape", KoElementReference::Counter).toString()); context.xmlWriter().addAttribute("draw:end-glue-point", d->connectionPointId2); } else { QPointF p(shapeToDocument(d->handles[EndHandle]) * context.shapeOffset(this)); context.xmlWriter().addAttributePt("svg:x2", p.x()); context.xmlWriter().addAttributePt("svg:y2", p.y()); } // write the path data context.xmlWriter().addAttribute("svg:d", toString()); saveOdfAttributes(context, OdfViewbox); saveOdfCommonChildElements(context); saveText(context); context.xmlWriter().endElement(); }
bool InvokeJavascript_TwoArgs(NPObject *npobj, const char *methodName, const NPVariant &arg1, const NPVariant &arg2, NPVariant *&result) { bool success = false; if (!strcmp(methodName, "saveTextFile") && NPVARIANT_IS_STRING(arg1) && NPVARIANT_IS_STRING(arg2)) { const char *filename = stringFromNpVariant(arg1); const char *contents = stringFromNpVariant(arg2); success = saveText(filename, contents, arg2.value.stringValue.UTF8Length); delete[] contents; delete[] filename; } else if (!strcmp(methodName, "saveBinaryFile") && NPVARIANT_IS_STRING(arg1) && NPVARIANT_IS_OBJECT(arg2)) { const char *filename = stringFromNpVariant(arg1); size_t length; const char *bytes = byteArrayFromNpVariant(arg2, GetInstance(npobj), length); success = saveBinaryFile(filename, bytes, length); delete[] bytes; delete[] filename; } return success; }
QString Matrix::saveToString(const QString &info) { QString s= "<matrix>\n"; s+= QString(name()) + "\t"; s+= QString::number(d_table->numRows())+"\t"; s+= QString::number(d_table->numCols())+"\t"; s+= birthDate() + "\n"; s+= info; s+= "ColWidth\t" + QString::number(d_table->columnWidth(0))+"\n"; s+= "<formula>\n" + formula_str + "\n</formula>\n"; s+= "TextFormat\t" + QString(txt_format) + "\t" + QString::number(num_precision) + "\n"; s+= "WindowLabel\t" + windowLabel() + "\t" + QString::number(captionPolicy()) + "\n"; s+= "Coordinates\t" + QString::number(x_start,'g',15) + "\t" +QString::number(x_end,'g',15) + "\t"; s+= QString::number(y_start,'g',15) + "\t" + QString::number(y_end,'g',15) + "\n"; s+= saveText(); s+="</matrix>\n"; return s; }
void Transcribe::close() { bool may_close = true; if (m_is_text_dirty) { QMessageBox box; box.setText(tr("The latest edits are not saved.")); box.setInformativeText(tr("Do you want to save them now?")); box.setStandardButtons(QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel ); int action = box.exec(); switch (action) { case QMessageBox::Save: may_close = saveText(); break; case QMessageBox::Cancel: may_close = false; break; } } if (may_close) { #ifndef Q_OS_ANDROID // Save window state QSettings settings; settings.beginGroup(CFG_GROUP_SCREEN); if (m_main_window->visibility() == QWindow::Maximized) { settings.setValue(CFG_SCREEN_IS_MAXIMIZED, true); } else { settings.setValue(CFG_SCREEN_IS_MAXIMIZED, false); } settings.setValue(CFG_SCREEN_SIZE, m_main_window->size()); settings.setValue(CFG_SCREEN_POS, m_main_window->position()); settings.endGroup(); settings.sync(); #endif saveHistory(); QApplication::quit(); } }
/* * Save an image to one of the formats implemented by this class */ int RImage::save(char file[100]) { if (strstr(file, ".ppm") != NULL) { savePPM(file); } else if (strstr(file, ".pgm") != NULL){ savePGM(file); } else if (strstr(file, ".jpeg") != NULL || strstr(file, ".jpg") != NULL) { saveJPEG(file, 100); } else if (strstr(file, ".png") != NULL) { fprintf(stderr, "ERROR: Format not supported as yet.\n"); savePNG(file); } else if (strstr(file, ".txt") != NULL) { saveText(file); } else { fprintf(stderr, "ERROR: Cannot save image %s. Unsupported format.\n", file); exit(1); } }
//-------------------- //基本テスト void basic_test() { std::printf("\n"); std::printf("================================================================================\n"); std::printf("[ Test for serialization basic ]\n"); std::printf("\n"); //テストデータ作成 std::printf("----------------------------------------\n"); std::printf("[ Make data ]\n"); basicTestData data; data.m_memberA = 123; data.m_memberB = 4.56f; data.m_memberC[0] = 78; data.m_memberC[1] = 90; data.m_memberD.m_item1 = 987; data.m_memberD.m_item2 = 654; //テストデータの内容表示 std::printf("----------------------------------------\n"); std::printf("[ Print data(1) : before save ]\n"); auto print_data = [](basicTestData& data) { std::printf("basicTestData\n"); std::printf(" .m_memberA = %d\n", data.m_memberA); std::printf(" .m_memberB = %.2f\n", data.m_memberB); std::printf(" .m_memberC = { %d, %d }\n", data.m_memberC[0], data.m_memberC[1]); std::printf(" .m_memberD\n"); std::printf(" .m_item1 = %d\n", data.m_memberD.m_item1); std::printf(" .m_item2 = %d\n", data.m_memberD.m_item2); }; print_data(data); //バイナリ形式セーブデータをセーブ std::printf("----------------------------------------\n"); std::printf("[ Save binary ]\n"); saveBinary(data); //テキスト形式セーブデータをセーブ std::printf("----------------------------------------\n"); std::printf("[ Save text ]\n"); saveText(data); //一旦データをクリア std::memset(&data, 0, sizeof(data)); //テストデータの内容表示 std::printf("----------------------------------------\n"); std::printf("[ Print data(2) : before load ]\n"); print_data(data); //バイナリ形式セーブデータをロード std::printf("----------------------------------------\n"); std::printf("[ Load binary ]\n"); loadBinary(data); #if 0//未実装 //テキスト形式セーブデータをロード std::printf("----------------------------------------\n"); std::printf("[ Load text ]\n"); loadText(data); #endif //テストデータの内容表示 std::printf("----------------------------------------\n"); std::printf("[ Print data(3) : after load ]\n"); print_data(data); std::printf("\n"); std::printf("================================================================================\n"); std::printf("finish.\n"); }
void ChatBase::initMenuBar() { // Icons: /opt/kde2/share/icons/hicolor/16x16/actions menuBar()->clear(); KPopupMenu* fileMenu = new KPopupMenu(menuBar(), "FileMenu"); fileMenu->insertItem(SmallIcon("filesave"), i18n("&Save (Formatted)"), this, SLOT(saveHTML()), ALT+Key_S ); fileMenu->insertItem(SmallIcon("filesave"), i18n("S&ave (Unformatted)"), this, SLOT(saveText()), ALT+Key_A ); fileMenu->insertItem( i18n("&Close"), this, SLOT(quit()) ); menuBar()->insertItem( i18n("&File"), fileMenu ); KPopupMenu* editMenu = new KPopupMenu(menuBar(), "EditMenu"); editMenu->insertItem(SmallIcon("editcopy"), i18n("&Copy"), this, SLOT(copy()), CTRL+Key_C ); editMenu->insertItem(SmallIcon("editcut"), i18n("C&ut"), this, SLOT(cut()), CTRL+Key_X ); editMenu->insertItem(SmallIcon("editpaste"), i18n("&Paste"), this, SLOT(paste()), CTRL+Key_V ); menuBar()->insertItem( i18n("&Edit"), editMenu); #if 0 KPopupMenu* buddyMenu = new KPopupMenu(menuBar(), "BuddyMenu"); buddyMenu->insertItem("&Profile",this,SLOT(profile()),CTRL+Key_P); menuBar()->insertItem("&Buddy", buddyMenu); KPopupMenu viewMenu = new KPopupMenu(menuBar, "ViewMenu"); menuBar->insertItem("&View", viewMenu); KPopupMenu insertMenu = new KPopupMenu(menuBar, "InsertMenu"); menuBar->insertItem("&Insert", insertMenu); KPopupMenu insertFaceMenu = new KPopupMenu(insertMenu, "FaceMenu"); KPopupMenu helpMenu = new KPopupMenu(kmenuBar, "HelpMenu"); menuBar->insertItem("&Help", helpMenu); #endif } // initMenuBar
MainForm::MainForm(QWidget *parent): QMainWindow(parent) { setupUi(this); ///!!!!! //alignButton->hide(); //unalignButton->hide(); setWindowTitle("YAGF"); spellChecker = new SpellChecker(textEdit); spellChecker->enumerateDicts(); selectLangsBox = new QComboBox(); QLabel *label = new QLabel(); label->setMargin(4); label->setText(trUtf8("Recognition language")); frame->show(); toolBar->addWidget(label); selectLangsBox->setFrame(true); toolBar->addWidget(selectLangsBox); graphicsInput = new QGraphicsInput(QRectF(0, 0, 2000, 2000), graphicsView) ; graphicsInput->addToolBarAction(actionHideShowTolbar); graphicsInput->addToolBarAction(this->actionTBLV); graphicsInput->addToolBarAction(this->actionSmaller_view); graphicsInput->addToolBarSeparator(); graphicsInput->addToolBarAction(actionRotate_90_CCW); graphicsInput->addToolBarAction(actionRotate_180); graphicsInput->addToolBarAction(actionRotate_90_CW); graphicsInput->addToolBarAction(actionDeskew); graphicsInput->addToolBarSeparator(); graphicsInput->addToolBarAction(actionSelect_Text_Area); graphicsInput->addToolBarAction(actionSelect_multiple_blocks); graphicsInput->addToolBarAction(ActionClearAllBlocks); statusBar()->show(); imageLoaded = false; useXSane = TRUE; textSaved = TRUE; hasCopy = false; //rotation = 0; m_menu = new QMenu(graphicsView); ifCounter = 0; connect(actionOpen, SIGNAL(triggered()), this, SLOT(loadImage())); connect(actionQuit, SIGNAL(triggered()), this, SLOT(close())); connect(this, SIGNAL(windowShown()), this, SLOT(onShowWindow()), Qt::QueuedConnection); connect(actionScan, SIGNAL(triggered()), this, SLOT(scanImage())); connect(actionPreviousPage, SIGNAL(triggered()), this, SLOT(loadPreviousPage())); connect(actionNextPage, SIGNAL(triggered()), this, SLOT(loadNextPage())); connect(actionRecognize, SIGNAL(triggered()), this, SLOT(recognize())); connect(action_Save, SIGNAL(triggered()), this, SLOT(saveText())); connect(actionAbout, SIGNAL(triggered()), this, SLOT(showAboutDlg())); connect(actionOnlineHelp, SIGNAL(triggered()), this, SLOT(showHelp())); connect(actionCopyToClipboard, SIGNAL(triggered()), this, SLOT(copyClipboard())); textEdit->setContextMenuPolicy(Qt::CustomContextMenu); connect(textEdit, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequested(QPoint))); connect(textEdit, SIGNAL(copyAvailable(bool)), this, SLOT(copyAvailable(bool))); connect(textEdit, SIGNAL(textChanged()), this, SLOT(textChanged())); connect(graphicsInput, SIGNAL(rightMouseClicked(int, int, bool)), this, SLOT(rightMouseClicked(int, int, bool))); tesMap = new TesMap(); fillLanguagesBox(); initSettings(); delTmpFiles(); scanProcess = new QProcess(this); QXtUnixSignalCatcher::connectUnixSignal(SIGUSR2); ba = new QByteArray(); connect(QXtUnixSignalCatcher::catcher(), SIGNAL(unixSignal(int)), this, SLOT(readyRead(int))); connect(textEdit->document(), SIGNAL(cursorPositionChanged(const QTextCursor &)), this, SLOT(updateSP())); //displayLabel->installEventFilter(this); textEdit->installEventFilter(this); QPixmap l_cursor; l_cursor.load(":/resize.png"); resizeCursor = new QCursor(l_cursor); graphicsInput->setMagnifierCursor(resizeCursor); l_cursor.load(":/resize_block.png"); resizeBlockCursor = new QCursor(l_cursor); // textEdit->setContextMenuPolicy(Qt::ActionsContextMenu); this->sideBar->show(); connect(sideBar, SIGNAL(fileSelected(const QString &)), this, SLOT(fileSelected(const QString &))); connect(actionRecognize_All_Pages, SIGNAL(triggered()), this, SLOT(recognizeAll())); graphicsInput->setSideBar(sideBar); QPixmap pm; pm.load(":/align.png"); //alignButton->setIcon(pm); pm.load(":/undo.png"); //unalignButton->setIcon(pm); //connect(unalignButton, SIGNAL(clicked()), this, SLOT(unalignButtonClicked())); //clearBlocksButton->setDefaultAction(ActionClearAllBlocks); loadFromCommandLine(); emit windowShown(); pdfx = NULL; if (findProgram("pdftoppm")) { pdfx = new PDF2PPT(); } else if (findProgram("gs")) { pdfx = new GhostScr(); } if (pdfx) { connect(pdfx, SIGNAL(addPage(QString)), this, SLOT(addPDFPage(QString)), Qt::QueuedConnection); connect (pdfx, SIGNAL(finished()), this, SLOT(finishedPDF())); } pdfPD.setWindowTitle("YAGF"); pdfPD.setLabelText(trUtf8("Importing pages from the PDF document...")); pdfPD.setCancelButtonText(trUtf8("Cancel")); pdfPD.setMinimum(-1); pdfPD.setMaximum(-1); pdfPD.setWindowIcon(QIcon(":/yagf.png")); if (pdfx) connect(&pdfPD, SIGNAL(canceled()), pdfx, SLOT(cancel())); }
void Transcribe::guiReady(QObject* root) { m_main_window = qobject_cast<QWindow*>(root); m_text_area = m_main_window->findChild<QObject*>("text_area"); // Set the icon, which, strangely enough, cannot be done from QML m_main_window->setIcon(QIcon("://window_icon")); #ifndef Q_OS_ANDROID // Restore window state QSettings settings; settings.beginGroup(CFG_GROUP_SCREEN); if (settings.value(CFG_SCREEN_IS_MAXIMIZED, false).toBool()) { m_main_window->setVisibility(QWindow::Maximized); } else { m_main_window->resize(settings.value(CFG_SCREEN_SIZE, QSize(640, 480)).toSize()); m_main_window->setPosition(settings.value(CFG_SCREEN_POS, QPoint(200, 200)).toPoint()); settings.endGroup();\ } #endif // Install the key filter and connect its signals KeyCatcher* catcher = new KeyCatcher(root); connect(catcher, SIGNAL(keyTyped()), &m_keeper, SLOT(keyTyped())); connect(catcher, SIGNAL(saveFile()), this, SLOT(saveText())); connect(catcher, SIGNAL(seekAudio(int)), m_player.get(), SLOT(skipSeconds(int))); connect(catcher, SIGNAL(togglePlayPause()), m_player.get(), SLOT(togglePlayPause())); connect(catcher, SIGNAL(togglePlayPause(bool)), m_player.get(), SLOT(togglePlayPause(bool))); connect(catcher, SIGNAL(boost(bool)), m_player.get(), SLOT(boost(bool))); root->installEventFilter(catcher); #ifdef Q_OS_ANDROID // On Android, we might connect the signals when using the virtual keyboard // in addition to the signals from the physical keyboard. connect(qApp->inputMethod(), SIGNAL(visibleChanged()), this, SLOT(connectVirtualKeyboard())); connectVirtualKeyboard(); #endif // Connect GUI events to their callbacks connect(m_main_window, SIGNAL(audioPositionChanged(int)), m_player.get(), SLOT(setPosition(int))); connect(m_main_window, SIGNAL(playingStateChanged(bool)), m_player.get(), SLOT(togglePlayPause(bool))); connect(m_main_window, SIGNAL(seekAudio(int)), m_player.get(), SLOT(skipSeconds(int))); connect(m_main_window, SIGNAL(boostAudio(bool)), m_player.get(), SLOT(boost(bool))); connect(m_main_window, SIGNAL(saveText()), this, SLOT(saveText())); #ifdef Q_OS_ANDROID connect(m_main_window, SIGNAL(shareText()), this, SLOT(shareText())); connect(m_main_window, SIGNAL(deleteText()), this, SLOT(deleteText())); #endif connect(m_main_window, SIGNAL(pickFiles()), this, SLOT(pickFiles())); connect(m_main_window, SIGNAL(historySelected(int)), this, SLOT(restoreHistory(int))); connect(m_main_window, SIGNAL(signalQuit()), this, SLOT(close())); connect(m_main_window, SIGNAL(numWordsDirty()), this, SLOT(countWords())); }
/** * @function DoLoad * @brief Load world from RSDH file */ void GRIPFrame::DoLoad(string filename, bool savelastload) { continueSimulation = false; size_t numPages = tabView->GetPageCount(); if (mWorld) { // fire SceneUnloaded hooks for(size_t i=0; i< numPages; i++) { GRIPTab* tab = (GRIPTab*)tabView->GetPage(i); tab->GRIPEventSceneUnloaded(); } // delete the world DeleteWorld(); } dart::utils::DartLoader dl; mWorld = dl.parseWorld( filename.c_str() ); // NULL World if( !mWorld ) { std::cout<< "[GRIP] World pointer null. Try again with a good URDF file"<<std::endl; return; } else if(mWorld->getNumSkeletons() == 0) { std::cout<< "[GRIP] Empty world? Neither robots nor objects loaded. Try again loading a world urdf"<< std::endl; return; } // Add floor dart::dynamics::Skeleton* ground = new dart::dynamics::Skeleton(); ground->setName("ground"); dart::dynamics::BodyNode* node = new dart::dynamics::BodyNode("ground"); node->setMass(1.0); dart::dynamics::Shape* shape = new dart::dynamics::BoxShape(Eigen::Vector3d(10.0, 10.0, 0.0001)); shape->setColor(Eigen::Vector3d(0.5, 0.5, 1.0)); node->addCollisionShape(shape); dart::dynamics::Joint* joint = new dart::dynamics::WeldJoint(); joint->setName("groundJoint"); joint->setTransformFromParentBodyNode(Eigen::Isometry3d::Identity()); joint->setTransformFromChildBodyNode(Eigen::Isometry3d::Identity()); node->setParentJoint(joint); ground->addBodyNode(node); ground->setMobile(false); mWorld->addSkeleton(ground); // Compile OpenGL displaylists for(int i=0; i < mWorld->getNumSkeletons(); i++) { viewer->renderer.compileList(mWorld->getSkeleton(i)); } // UpdateTreeView(); cout << "--(v) Done Parsing World information (v)--" << endl; treeView->CreateFromWorld(); cout << "--(v) Done Updating TreeView (v)--" << endl; SetStatusText(wxT("--(i) Done Loading and updating the View (i)--")); /// Extract path to executable & save "lastload" there if (savelastload) { cout << "--(i) Saving " << filename << " to .lastload file (i)--" << endl; wxString filename_string(filename.c_str(), wxConvUTF8); saveText(filename_string,".lastload"); } selectedTreeNode = 0; treeView->ExpandAll(); updateAllTabs(); // fire SceneLoaded hooks for(size_t i=0; i< numPages; i++) { GRIPTab* tab = (GRIPTab*)tabView->GetPage(i); tab->GRIPEventSceneLoaded(); } viewer->DrawGLScene(); }