bool SimpleNetworkVisualizationHandler::setNeuralNetwork(ModularNeuralNetwork *network) { TRACE("SimpleNetworkVisualizationHandler::setNeuralNetwork"); QMutexLocker locker(Neuro::getNeuralNetworkManager()->getNetworkExecutionMutex()); QMutex *selectionMutex = 0; if(mOwner != 0) { selectionMutex = mOwner->getSelectionMutex(); } if(selectionMutex != 0) { selectionMutex->lock(); } conserveSelection(); NetworkVisualizationHandler::setNeuralNetwork(network); clearVisualization(); mNetwork = network; bool ok = updateNetworkView(); restoreSelection(); if(selectionMutex != 0) { selectionMutex->unlock(); } return ok; }
////////////////// // Destroy paint structure. Call Windows EndPaint function. // WPPaintDC::~WPPaintDC() { if (anySelected) restoreSelection(); EndPaint((*win)(), &ps); hdc = NULL; }
void PeerListContent::removeRow(not_null<PeerListRow*> row) { auto index = row->absoluteIndex(); auto isSearchResult = row->isSearchResult(); auto &eraseFrom = isSearchResult ? _searchRows : _rows; Assert(index >= 0 && index < eraseFrom.size()); Assert(eraseFrom[index].get() == row); auto pressedData = saveSelectedData(_pressed); auto contextedData = saveSelectedData(_contexted); setSelected(Selected()); setPressed(Selected()); setContexted(Selected()); _rowsById.erase(row->id()); auto &byPeer = _rowsByPeer[row->peer()]; byPeer.erase(ranges::remove(byPeer, row), end(byPeer)); removeFromSearchIndex(row); _filterResults.erase( ranges::remove(_filterResults, row), end(_filterResults)); removeRowAtIndex(eraseFrom, index); restoreSelection(); setPressed(restoreSelectedData(pressedData)); setContexted(restoreSelectedData(contextedData)); }
////////////////// // Destroy Window DC: use ReleaseDC instead of DeleteDC. // WPWinDC::~WPWinDC() { if (anySelected) restoreSelection(); BOOL ret = ReleaseDC((*win)(), hdc); assert(ret); hdc=NULL; }
/** * This function is provided for convenience. Please see * PsiRichText::appendText() documentation for usage details. */ void PsiTextView::appendText(const QString &text) { QTextCursor cursor = textCursor(); Selection selection = saveSelection(cursor); PsiRichText::appendText(document(), cursor, text); restoreSelection(cursor, selection); setTextCursor(cursor); }
////////////////// // Destroy printer: destroy abort dialog if it's still there. // Don't delete the DC if it came from print dialog. // WPPrinter::~WPPrinter() { if (DlgAbort) { DlgAbort->destroyWin(); DlgAbort=NULL; } if (pwin) pwin->enableWin(TRUE); if (anySelected) restoreSelection(); if (!delDC) hdc=NULL; // don't delete the DC }
void SettingsDialog::updateStationsTable() { ui->stationTable->clearContents(); ui->stationTable->setRowCount( 0 ); foreach ( const Station & station, stationList ) { const int currRow = ui->stationTable->rowCount(); ui->stationTable->insertRow( currRow ); ui->stationTable->setItem( currRow, 0, new QTableWidgetItem( station.name ) ); ui->stationTable->setItem( currRow, 1, new QTableWidgetItem( station.description ) ); ui->stationTable->setItem( currRow, 2, new QTableWidgetItem( station.url ) ); ui->stationTable->setItem( currRow, 3, new QTableWidgetItem( station.encoding ) ); } restoreSelection(); }
void Converter::convertSingleDocQuick( const string_t& fileName ) { tDocumentsSp docs = word()->getDocuments(); tDocumentSp doc = docs->open(toUtf16(getInputAbsPath(fileName))); if (!doc) { logError(logger(), "Error while opening document: " + fileName); return; } tCharMappingSp cm; string_t fontName, newFontName; wstring_t text, textUnicode, docAsText; int c = 0; tSelectionSp s = word()->getSelection(); int pos = 0; int totalCharsQty = s->getStoryLength(); do { s->setStart(pos); s->setEnd(pos + 1); s->selectCurrentFont(); fontName = s->getFont()->getName(); if ( canSkipFont(fontName) ) { //s->getFont()->haveCommonAttributes(); pos = s->getEnd(); docAsText += s->getText(); std::cout << "\r" << percentageStr(pos, totalCharsQty - 1); continue; } text = s->getText(); if ( fontName.empty() ) { saveSelection(s); fontName = makeGuess(s); restoreSelection(s); /// if after all we have empty font name, log about that event /// and go forward if (fontName.empty()) { logError(logger(), "EMPTY FONT NAME: Investigate"); pos = s->getEnd(); docAsText += text; std::cout << "\r" << percentageStr(pos, totalCharsQty - 1); continue; } } /// use mapping textUnicode.clear(); cm = getCM(fontName); if (cm) { bool spacingOnly = cm->doConversion(text, textUnicode, fontName); newFontName = getFontSubstitution(cm, fontName); //tFontSp fontDup = s->getFont()->duplicate(); s->setText(textUnicode); //s->getFont()->haveCommonAttributes(); s->getFont()->setName(newFontName); //s->setFont(fontDup); } /// extract text from the document as well docAsText += textUnicode; pos = s->getEnd(); std::cout << "\r" << percentageStr(pos, totalCharsQty - 1); } while ( pos < totalCharsQty - 1 ); /// -------------------------------------------/// /// now save result in the appropriate folder /// string_t outputDir = getOutputAbsPath(fileName); Poco::File(outputDir).createDirectories(); Poco::Path p(fileName); doc->saveAs( outputDir + p.getBaseName() + " QUICK." + p.getExtension() ); doc->close(); if ( config_->getBool("app.saveAlsoAsUTF8", false) ) writeFileAsBinary( outputDir + p.getBaseName() + " UTF8 QUICK.txt", toUtf8(docAsText)); }
WPOwnerDrawDC::~WPOwnerDrawDC() { restoreSelection(); hdc = NULL; }