本文整理汇总了C++中saveFile函数的典型用法代码示例。如果您正苦于以下问题:C++ saveFile函数的具体用法?C++ saveFile怎么用?C++ saveFile使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了saveFile函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WinMain
//.........这里部分代码省略.........
return 1;
}
double dx = 0;
double dy = 0;
double maxSpeed = 5;
double accel = 0.1f;
MSG message;
game = (Game*)calloc(1, sizeof(Game));
initGL();
initGame(game);
int counter = 0;
LARGE_INTEGER cps;
LARGE_INTEGER curCount;
LARGE_INTEGER prevCount;
LONGLONG countDifference;
QueryPerformanceFrequency(&cps);
double secsPassed = 0;
QueryPerformanceCounter(&curCount);
float pan = 0.2;
float topPan = 1;
float lowPan = 0.2;
while(!game->done)
{
prevCount = curCount;
QueryPerformanceCounter(&curCount);
countDifference = curCount.QuadPart - prevCount.QuadPart;
secsPassed = (long double)countDifference / (long double)cps.QuadPart;
while(PeekMessage(&message, hWindow, 0, 0, PM_REMOVE))
{
if(message.message == WM_QUIT)
{
game->done = true;
}
TranslateMessage(&message);
DispatchMessage(&message);
}
dx = 0;
dy = 0;
if(game->keys[VK_SHIFT])
{
pan = topPan;
}
else
{
pan = lowPan;
}
if(game->keys['W'])
{
camY+=pan;
}
if(game->keys['A'])
{
camX-=pan;
}
if(game->keys['S'])
{
camY-=pan;
}
if(game->keys['D'])
{
camX+=pan;
}
if(game->keys['Q'])
{
camZoom += 0.01;
if(camZoom > 6) camZoom = 6;
resize(windowWidth, windowHeight);
}
if(game->keys['E'])
{
camZoom -= 0.01;
if(camZoom < 1) camZoom = 1;
resize(windowWidth, windowHeight);
}
if(game->keys[VK_SPACE])
{
saveFile(game);
}
updateGame(game, dx, dy, secsPassed);
drawScene(game);
SwapBuffers(hDeviceContext);
}
free(game);
killWindow(className);
return 0;
}
示例2: saveFile
void PaletteEditor::saveGradientAction()
{
QString saveFile( QFileDialog::getSaveFileName(this,
tr("Save gradient to a cpt file"),
QFileInfo(m_lastBrowseDir).absoluteFilePath(),
tr("CPT Gradient Files (*.cpt)")) );
if (saveFile.isEmpty())
return;
QFileInfo file( saveFile );
QString openDir( file.absoluteFilePath() );
logInfo(QString("PaletteEditor::saveGradientAction : saving gradient to %1").arg(saveFile));
if (openDir != m_lastBrowseDir)
m_lastBrowseDir = openDir;
QFile data(file.absoluteFilePath());
if (!data.open(QFile::ReadWrite))
{
QMessageBox msgBox;
msgBox.setText(tr("Error: Couldn't open file %1").arg(file.filePath()));
msgBox.setIcon(QMessageBox::Warning);
msgBox.exec();
return;
}
QTextStream os(&data);
os << "# COLOR_MODEL = RGB" << endl
<< scientific << qSetRealNumberPrecision(6) << qSetFieldWidth(4);
p_stops = m_gradientStops->getStops();
qStableSort(p_stops.begin(), p_stops.end(), GradientStop::lessThanGradientStopComparison);
GradientStops::const_iterator i = p_stops.constBegin();
os << left << (*i).first
<< right
<< (*i).second.red()
<< (*i).second.green()
<< (*i).second.blue() << ' ';
++i;
for ( ; i != p_stops.constEnd(); ++i)
{
os << left << (*i).first
<< right
<< (*i).second.red()
<< (*i).second.green()
<< (*i).second.blue() << endl;
if (i + 1 != p_stops.constEnd())
os << left << (*i).first
<< right
<< (*i).second.red()
<< (*i).second.green()
<< (*i).second.blue() << ' ';
}
os << "B 0 0 0" << endl
<< "F 255 255 255" << endl
<< "N 255 0 0" << endl;
data.close();
if (data.error() != QFile::NoError)
{
QMessageBox msgBox;
msgBox.setText(tr("Error: Couldn't write to file %1").arg(file.filePath()));
msgBox.setIcon(QMessageBox::Warning);
msgBox.exec();
}
}
示例3: _state
MainWindow::MainWindow(AmViewerState *state) : _state(state) {
_state->recon_tree = NULL;
_state->amEvent = NULL;
_state->show_dBm = false;
_state->filtered = true;
_state->sumpols = false;
_state->resetSearch(); // couldn't hurt?
setWindowTitle("AmViewer");
// creat dialogs
_searchWindow = new SearchWindow(this,_state);
_visWindow = new VisWindow(this,_state);
_fovWindow = new FovWindow(this,_state);
_filterWindow = NULL;
_infoWindow = NULL;
QWidget *centralWidget = new QWidget();
setCentralWidget(centralWidget);
QVBoxLayout *bigLayout = new QVBoxLayout(centralWidget);
// File menu
QAction *quitMenu = new QAction("&Exit",this);
quitMenu->setShortcut(tr("Ctrl+Q"));
connect(quitMenu,SIGNAL(triggered()),qApp,SLOT(quit()));
QAction *openMenu = new QAction("&Open ROOT file...",this);
openMenu->setShortcut(tr("Ctrl+O"));
connect(openMenu,SIGNAL(triggered()),this,SLOT(openFile()));
_saveMenu = new QAction("&Save event candidates...",this);
connect(_saveMenu,SIGNAL(triggered()),this,SLOT(saveFile()));
QMenu *fileDrop;
fileDrop = menuBar()->addMenu("&File");
fileDrop->addAction(openMenu);
fileDrop->addAction(_saveMenu);
fileDrop->addAction(quitMenu);
_saveMenu->setEnabled(false);
// View menu
_unitsMenu = new QAction("&Display dBm",this);
_unitsMenu->setCheckable(true);
_unitsMenu->setChecked(false);
connect(_unitsMenu,SIGNAL(triggered()),this,SLOT(applyUnits()));
// Filter dialog
_filterMenu = new QAction("&Filter Settings",this);
connect(_filterMenu,SIGNAL(triggered()),this,SLOT(openFilter()));
// Polarization checkbox
_polMenu = new QAction("&Sum Polarizations",this);
_polMenu->setCheckable(true);
_polMenu->setChecked(false);
_polMenu->setEnabled(false);
connect(_polMenu,SIGNAL(triggered()),this,SLOT(applySumPol()));
QMenu *viewDrop;
viewDrop = menuBar()->addMenu("&View");
viewDrop->addAction(_unitsMenu);
viewDrop->addAction(_polMenu);
viewDrop->addAction(_filterMenu);
_filterMenu->setEnabled(false);
// Analysis menu
QAction *infoMenu = new QAction("&Event Info",this);
connect(infoMenu,SIGNAL(triggered()),this,SLOT(openInfo()));
_analysisDrop = menuBar()->addMenu("&Analysis");
_analysisDrop->addAction(infoMenu);
QAction *searchMenu = new QAction("&Search Parameters",this);
connect(searchMenu,SIGNAL(triggered()),this,SLOT(openSearch()));
_analysisDrop->addAction(searchMenu);
_analysisDrop->setEnabled(false);
QAction *visMenu = new QAction("&Event Visualization",this);
connect(visMenu,SIGNAL(triggered()),this,SLOT(openVis()));
_analysisDrop->addAction(visMenu);
QAction*fovMenu = new QAction("&AMBER Field of View",this);
connect(fovMenu,SIGNAL(triggered()),this,SLOT(openFov()));
_analysisDrop->addAction(fovMenu);
// Set up layout for event browser, pixel windows, graphs
QHBoxLayout *hbox = new QHBoxLayout();
bigLayout->addLayout(hbox);
// Event list stuff
_eventList = new QTreeWidget(this);
_eventList->setColumnCount(2);
_eventList->setColumnHidden(1,true); //'true' valid in C++?
QTreeWidgetItem *_source0 = new QTreeWidgetItem(_eventList);
_source0->setText(0,"Source:0 (LTRIG)");
QTreeWidgetItem *_source1 = new QTreeWidgetItem(_eventList);
_source1->setText(0,"Source:1 (PPS)");
//.........这里部分代码省略.........
示例4: TskException
//.........这里部分代码省略.........
// Determine the parent id of the file.
uint64_t parentId = 0;
if (path.depth() == 0 || path.isDirectory() && path.depth() == 1)
{
// This file or directory lives at the root so our parent id
// is the containing file id (if a containing file was provided).
if (m_containerFile != NULL)
{
parentId = m_containerFile->getId();
}
}
else
{
// We are not at the root so we need to lookup the id of our
// parent directory.
std::map<std::string, uint64_t>::const_iterator pos;
pos = directoryMap.find(parent.toString());
if (pos == directoryMap.end())
{
//error!
std::stringstream msg;
msg << "extractFiles: parent ID not mapped for " << it->path.toString();
LOGERROR(msg.str());
}
else
{
parentId = pos->second;
}
}
// Store some extra details about the derived (i.e, extracted) file.
std::stringstream details; ///@todo anything here?
std::string fullpath = "";
if (m_containerFile != NULL)
{
fullpath.append(m_containerFile->getFullPath());
}
fullpath.append("\\");
fullpath.append(path.toString());
uint64_t fileId;
if (m_db.addDerivedFileInfo(name,
parentId,
path.isDirectory(),
it->size,
details.str(),
static_cast<int>(it->ctime),
static_cast<int>(it->crtime),
static_cast<int>(it->atime),
static_cast<int>(it->mtime),
fileId, fullpath) == -1)
{
std::wstringstream msg;
msg << L"addDerivedFileInfo failed for name="
<< name.c_str();
LOGERROR(msg.str());
}
if (path.isDirectory())
{
directoryMap[path.toString()] = fileId;
}
else
{
// For file nodes, recreate file locally
// Will save zero-length files
if (saveFile(fileId, *it) == 0)
{
// Schedule
m_db.updateFileStatus(fileId, TskImgDB::IMGDB_FILES_STATUS_READY_FOR_ANALYSIS);
TskServices::Instance().getScheduler().schedule(Scheduler::FileAnalysis, fileId, fileId);
}
}
}
}
catch (TskException &ex)
{
std::ostringstream msg;
msg << MSG_PREFIX << "TskException: " << ex.message();
LOGERROR(msg.str());
return -1;
}
catch (std::exception &ex)
{
std::ostringstream msg;
msg << MSG_PREFIX << "std::exception: " << ex.what();
LOGERROR(msg.str());
return -1;
}
catch (...)
{
LOGERROR(MSG_PREFIX + "unrecognized exception");
return -1;
}
return 0; //success
}
示例5: QMainWindow
//.........这里部分代码省略.........
SLOT(updateToolbar(const QModelIndex &)));
/*
connect(
table,
SIGNAL(itemChanged(QTableWidgetItem*)),
this,
SLOT(updateStatus(QTableWidgetItem*)));
*/
connect(
formulaInput,
SIGNAL(returnPressed()),
this,
SLOT(returnPressed()));
/*
connect(
table,
SIGNAL(itemChanged(QTableWidgetItem*)),
this,
SLOT(updateLineEdit(QTableWidgetItem*)));
*/
// table->updateColor(0);
connect(
optionsButton,
SIGNAL(clicked()),
optionsDialog,
SLOT(exec()));
connect(
scanButton,
SIGNAL(clicked()),
this,
SLOT(displayBarcodeForm()));
connect(
barcodeViewForm,
SIGNAL(barcodeFound(QString, QString, QString, QString, QString)),
this,
SLOT(addNewRow(QString, QString, QString, QString, QString)));
/*
connect(
optionsDialog,
SIGNAL(editFormula()),
this,
SLOT(something()));
*/
connect(
optionsDialog,
SIGNAL(clearCell()),
this,
SLOT(clearCurrentCell()));
connect(
optionsDialog,
SIGNAL(removeRow()),
this,
SLOT(removeCurrentRow()));
connect(
optionsDialog,
SIGNAL(loadFile()),
this,
SLOT(load()));
connect(
optionsDialog,
SIGNAL(saveFile()),
this,
SLOT(save()));
connect(
optionsDialog,
SIGNAL(saveFileAs()),
this,
SLOT(saveAs()));
// Preferences form:
connect(
preferencesForm,
SIGNAL(beepPreference(bool)),
barcodeViewForm,
SLOT(setBeepPref(bool)));
// Initialize beep preference:
barcodeViewForm->setBeepPref(preferencesForm->getBeepPref());
connect(
preferencesForm,
SIGNAL(ignoreLensCover(bool)),
barcodeViewForm,
SLOT(updateIgnoreCover(bool)));
barcodeViewForm->updateIgnoreCover(preferencesForm->getIgnoreCover());
}
示例6: buffer
void VehicleTemplateExportDialog::saveTemplate(QString path)
{
QJsonObject exportObject;
QList<UAVObject *> objectsToExport;
objectsToExport << StabilizationSettings::GetInstance(m_uavoManager);
objectsToExport << StabilizationSettingsBank1::GetInstance(m_uavoManager);
objectsToExport << StabilizationSettingsBank2::GetInstance(m_uavoManager);
objectsToExport << StabilizationSettingsBank3::GetInstance(m_uavoManager);
objectsToExport << MixerSettings::GetInstance(m_uavoManager);
objectsToExport << EKFConfiguration::GetInstance(m_uavoManager);
m_uavoManager->toJson(exportObject, objectsToExport);
exportObject["type"] = m_type;
exportObject["subtype"] = m_subType;
exportObject["name"] = ui->Name->text();
exportObject["owner"] = ui->Owner->text();
exportObject["nick"] = ui->ForumNick->text();
exportObject["size"] = ui->Size->text();
exportObject["weight"] = ui->Weight->text();
exportObject["motor"] = ui->Motor->text();
exportObject["esc"] = ui->Esc->text();
exportObject["servo"] = ui->Servo->text();
exportObject["battery"] = ui->Battery->text();
exportObject["propeller"] = ui->Propeller->text();
exportObject["controller"] = ui->Controllers->currentText();
exportObject["comment"] = ui->Comment->document()->toPlainText();
QUuid uuid = QUuid::createUuid();
exportObject["uuid"] = uuid.toString();
if (!m_image.isNull()) {
QByteArray bytes;
QBuffer buffer(&bytes);
buffer.open(QIODevice::WriteOnly);
m_image.scaled(IMAGE_SCALE_WIDTH, IMAGE_SCALE_HEIGHT, Qt::KeepAspectRatio,
Qt::SmoothTransformation).save(&buffer, "PNG");
exportObject["photo"] = QString::fromLatin1(bytes.toBase64().data());
}
QJsonDocument saveDoc(exportObject);
const char *fileType = ".optmpl";
QString fileName = QString("%1-%2-%3%4")
.arg(fixFilenameString(ui->Name->text(), 20))
.arg(fixFilenameString(ui->Type->text(), 30))
.arg(fixFilenameString(uuid.toString().right(12)))
.arg(fileType);
QString fullPath;
if (path.isEmpty()) {
fullPath = QString("%1%2%3").arg(QDir::homePath()).arg(QDir::separator()).arg(fileName);
fullPath = QFileDialog::getSaveFileName(this, tr("Export settings"), fullPath, QString("%1 (*%2)").arg(tr("OPTemplates"), fileType));
} else {
fullPath = QString("%1%2%3").arg(path).arg(QDir::separator()).arg(fileName);
}
if (!fullPath.isEmpty()) {
if (!fullPath.endsWith(fileType)) {
fullPath.append(fileType);
}
QFile saveFile(fullPath);
if (saveFile.open(QIODevice::WriteOnly)) {
saveFile.write(saveDoc.toJson());
saveFile.close();
} else {
QMessageBox::information(this, "Export", tr("Settings could not be exported to \n%1(%2).\nPlease try again.")
.arg(QFileInfo(saveFile).absoluteFilePath(), saveFile.error()), QMessageBox::Ok);
}
}
}
示例7: saveFile
void KMiniEdit::fileSaveAs()
{
saveFile(KURL());
}
示例8: QMenu
MainWindow::MainWindow()
{
QMenu *fileMenu = new QMenu(tr("&File"));
QAction *saveAction = fileMenu->addAction(tr("&Save..."));
saveAction->setShortcut(tr("Ctrl+S"));
QAction *quitAction = fileMenu->addAction(tr("E&xit"));
quitAction->setShortcut(tr("Ctrl+Q"));
menuBar()->addMenu(fileMenu);
editor = new QTextEdit();
QTextCursor cursor(editor->textCursor());
cursor.movePosition(QTextCursor::Start);
QTextFrame *mainFrame = cursor.currentFrame();
QTextCharFormat plainCharFormat;
QTextCharFormat boldCharFormat;
boldCharFormat.setFontWeight(QFont::Bold);
/* main frame
//! [0]
QTextFrame *mainFrame = cursor.currentFrame();
cursor.insertText(...);
//! [0]
*/
cursor.insertText("Text documents are represented by the "
"QTextDocument class, rather than by QString objects. "
"Each QTextDocument object contains information about "
"the document's internal representation, its structure, "
"and keeps track of modifications to provide undo/redo "
"facilities. This approach allows features such as the "
"layout management to be delegated to specialized "
"classes, but also provides a focus for the framework.",
plainCharFormat);
//! [1]
QTextFrameFormat frameFormat;
frameFormat.setMargin(32);
frameFormat.setPadding(8);
frameFormat.setBorder(4);
//! [1]
cursor.insertFrame(frameFormat);
/* insert frame
//! [2]
cursor.insertFrame(frameFormat);
cursor.insertText(...);
//! [2]
*/
cursor.insertText("Documents are either converted from external sources "
"or created from scratch using Qt. The creation process "
"can done by an editor widget, such as QTextEdit, or by "
"explicit calls to the Scribe API.", boldCharFormat);
cursor = mainFrame->lastCursorPosition();
/* last cursor
//! [3]
cursor = mainFrame->lastCursorPosition();
cursor.insertText(...);
//! [3]
*/
cursor.insertText("There are two complementary ways to visualize the "
"contents of a document: as a linear buffer that is "
"used by editors to modify the contents, and as an "
"object hierarchy containing structural information "
"that is useful to layout engines. In the hierarchical "
"model, the objects generally correspond to visual "
"elements such as frames, tables, and lists. At a lower "
"level, these elements describe properties such as the "
"style of text used and its alignment. The linear "
"representation of the document is used for editing and "
"manipulation of the document's contents.",
plainCharFormat);
connect(saveAction, SIGNAL(triggered()), this, SLOT(saveFile()));
connect(quitAction, SIGNAL(triggered()), this, SLOT(close()));
setCentralWidget(editor);
setWindowTitle(tr("Text Document Frames"));
}
示例9: saveAs
bool ScriptEditorWidget::save() {
return _currentScript.isEmpty() ? saveAs() : saveFile(_currentScript);
}
示例10: main
//.........这里部分代码省略.........
}
}
else {
//wrong input parameters, inform the user about it.
printf("Usage: ./indexer [TARGET_DIRECTORY] [RESULTS FILENAME]\n");
printf(" or ./indexer [TARGET_DIRECTORY] [RESULTS FILENAME1] [RESULTS FILENAME2] [REWRITEN FILENAME]\n");
printf("You have entered %d parameters\n", (argc - 1));
return 1;
}
// 2. Initialize data structures
// allocate Inverted_index, zero it, and set links to NULL.
inverted_index = calloc(1, sizeof(HashTable));
if(inverted_index == NULL) {
LOG(stdout,"Error: failed to calloc the variable inverted_index\n");
return 1;
}
// 3.print to stdout that the building of index is starting
//printf("\nStarting to build the index\n");
LOG(stdout,"Starting to build the index\n");
// 4. Build the inverted index
if(buildIndexFromDirectory (inverted_index, target_dir)) {
LOG(stdout, "Error: buildIndexFromDirectory() failed\n");
return 1;
}
LOG(stdout,"Building the inverted index\n");
// 5. Save the inverted index
if(!saveFile(inverted_index, results_file1)) {
LOG(stdout,"Successfully saved the inverted index\n");
}
else {
LOG(stdout, "Error: saveFile() failed\n");
}
// 6. Free appropriate memory
destroyHash(inverted_index);
free(target_dir);
free(results_file1);
// 7. If 4 input parameters are detected
if(5 == argc) {
test_index = calloc(1, sizeof(HashTable));
if(test_index == NULL) {
LOG(stdout, "Error: failed to calloc the variable test_index\n");
free(results_file2);
free(rewritten_file);
destroyHash(test_index);
return 1;
}
if(!IsFile(results_file2)) {
printf("Error: %s is not a file\n", results_file2);
free(results_file2);
free(rewritten_file);
destroyHash(test_index);
return 1;
}
示例11: main
//.........这里部分代码省略.........
stub[hierarchyentrypoint].become_SWGBR_Left();
stub[left].become_SWGBR_Right();
stub[right].become_SWGBR_Left();
stub.insert(stub.begin() + hierarchyentrypoint, token_LCMD);
i++; left = i - 2; middle = i - 1; right = i;
stub.erase(stub.begin() + middle);
for (int a = right+1; a < stub.size(); a++) {
if (stub[a].get_type()==TYPBRAC) {
if (stub[a].get_hierarchy() == stub[middle].get_hierarchy()) {
if(stub[a].get_lasthierarchytype() == stub[middle].get_lasthierarchytype()-1)
i=a; left = i - 2; middle = i - 1; right = i;
stub[i].become_SWGBR_Right();
break;
}
}
}
}
}
std::string output;
for (int i = 0; i < stub.size(); i++) {
switch (stub[i].get_type()) {
case TYPBRAC: {
if (chkopenbracket(stub, i)) {
switch (stub[i].get_lasthierarchytype()) {
case RNDBR: {
output += "\\left (";
hierarchytypes.push_back(RNDBR);
break;
}
case SQUBR: {
output += "\\left [";
hierarchytypes.push_back(SQUBR);
break;
}
case SWGBR: {
output += "\\left {";
hierarchytypes.push_back(SWGBR);
break;
}
case ABSBR: {
output += "\\left |";
hierarchytypes.push_back(ABSBR);
break;
}
}
}
else {
switch (hierarchytypes[hierarchytypes.size() - 1]) {
case RNDBR: {
output += "\\right )";
hierarchytypes.pop_back();
break;
}
case SQUBR: {
output += "\\right ]";
hierarchytypes.pop_back();
break;
}
case SWGBR: {
output += "\\right }";
hierarchytypes.pop_back();
break;
}
case ABSBR: {
output += "\\right |";
hierarchytypes.pop_back();
break;
}
}
}
break;
}
case TYPWORD: {
std::string variable = "";
std::string parameters = "";
std::string prefix = "";
getwordparameters(wordlist[stub[i].get_wordlistid()], variable, parameters, prefix, rwordlist, correswordlist);
output += prefix + " " + variable + parameters;
break;
}
case TYPLINE: {
output += "\n";
break;
}
case TYPTOKN: {
output += correstokenlist[stub[i].get_wordlistid()];
break;
}
case TYPLCMD: {
output += latexcommandslist[stub[i].get_wordlistid()];
}
}
}
std::ofstream saveFile("Save.txt");
saveFile << output;
saveFile.close();
return 0;
}
示例12: saveFile
bool MainWindow::save()
{
if(painter->isNull()) return true;
if(curFile.isEmpty()) return saveAs();
return saveFile(curFile);
}
示例13: tr
void MainWindow::file_SaveAs()
{
QString fileName = QFileDialog::getSaveFileName(this, tr("Save As"), curFile, tr("SPICE Netlist (*.sp)"));
if(!fileName.isEmpty())
saveFile(fileName);
}
示例14: CV
//.........这里部分代码省略.........
double logm2 = loglin2->GetParameter(1);
double elogq1 = loglin1->GetParError(0);
double elogq2 = loglin2->GetParError(0);
double elogm1 = loglin1->GetParError(1);
double elogm2 = loglin2->GetParError(1);
assert((logm1-logm2)!=0);
double logvdep = (logq1-logq2)/(logm2-logm1);
vdepl = TMath::Power(10.,logvdep);
double Deltam = sqrt(TMath::Power(elogm1,2.)+TMath::Power(elogm2,2.));
double Deltaq = sqrt(TMath::Power(elogq1,2.)+TMath::Power(elogq2,2.));
evdepl = sqrt(TMath::Power(Deltaq,2.)/TMath::Power((logm2-logm1),2.) + TMath::Power(Deltam,2.)*TMath::Power((logq1-logq2),2.)/TMath::Power((logm2-logm1),2.));
evdepl = TMath::Power(10.,evdepl);
TF1 *flog1 = new TF1("flog1","[0]+[1]*x",logv1*0.8,logv2*1.2);
TF1 *flog2 = new TF1("flog2","[0]+[1]*x",logv3*0.8,logv4*1.2);
flog1->SetParameters(logq1,logm1);
flog2->SetParameters(logq2,logm2);
flog1->SetLineStyle(7);
flog1->SetLineColor(loglin1->GetLineColor());
flog2->SetLineStyle(kDashed);
flog2->SetLineColor(loglin2->GetLineColor());
grlogClogV->Draw("AP");
flog1->Draw("same");
flog2->Draw("same");
loglin1->Draw("same");
loglin2->Draw("same");
TCanvas *c3 = new TCanvas("c3","",2000,1000);
c3->cd();
TGraph *grC2V = new TGraph(i,V,C2);
grC2V->SetName("grC2V");
grC2V->SetTitle("");
grC2V->SetMarkerColor(kBlue);
grC2V->SetMarkerStyle(24);
grC2V->SetMarkerSize(1.2);
grC2V->SetLineColor(kBlue);
grC2V->Draw("AP");
grC2V->GetYaxis()->SetTitle("C^{-2} [F^{-2}]");
grC2V->GetXaxis()->SetTitle("V_{bias} [V]");
c3->SetTicks(1);
c3->SetGrid(1,1);
grC2V->Fit("pol1","R","",v1,v2);
TF1 *lin = (TF1*)gROOT->GetFunction("pol1");
lin->SetLineColor(kRed);
double C2der = lin->GetParameter(1);
double eC2der = lin->GetParError(1);
neff = 2./A/A/q0/eR/e0/C2der;
eneff = 2./A/A/q0/eR/e0/C2der/C2der*eC2der;
w = TMath::Power(2.*eR*e0*vdepl/q0/neff,0.5);
double ewA = 2*eR*e0/q0;
ewA = TMath::Power(ewA,0.5);
double ewNeff = 0.5*ewA*TMath::Power(vdepl,0.5)*TMath::Power(neff,-1.5)*eneff;
double ewV = 0.5*ewA*TMath::Power(vdepl,-0.5)*TMath::Power(neff,-0.5)*evdepl;
ew = TMath::Sqrt(ewNeff*ewNeff+ewV*ewV);
std::cout << "v1 = " << v1 << " V\n";
std::cout << "v2 = " << v2 << " V\n";
std::cout << "v3 = " << v3 << " V\n";
std::cout << "v4 = " << v4 << " V\n";
std::cout << "vdepl = " << vdepl << " V \n";
std::cout << "evdepl = " << evdepl << " V \n";
std::cout << "neff = " << neff << " 1./cm^3\n";
std::cout << "eneff = " << eneff << " 1./cm^3\n";
std::cout << "w = " << w*1e+4 << " um\n";
std::cout << "ew = " << ew*1e+4 << " um\n";
file.close();
if ( savePlots == true ) {
std::cout << "I will save plots\n";
TString saveFile(fileName);
TString cvFile = saveFile;
cvFile.ReplaceAll(".dat","_CV.png");
TString c2vFile = saveFile;
c2vFile.ReplaceAll(".dat","_C2V.png");
TString logclogvFile = saveFile;
logclogvFile.ReplaceAll(".dat","_logClogV.png");
c1->Draw();
c1->SaveAs(cvFile.Data());
c2->Draw();
c2->SaveAs(logclogvFile.Data());
c3->Draw();
c3->SaveAs(c2vFile.Data());
}
}
示例15: connect
void MainWindow::initial()
{
my_sync_widget->setWindowModality(Qt::WindowModal);
my_sync_widget->hide();
connect(my_sync_widget, SIGNAL(getSaveFile(QString&)), this, SLOT(syncSaveFile(QString&)));
connect(my_sync_widget, SIGNAL(enableServiceButton(QString&)), this, SLOT(serviceAdded(QString&)));
connect(this, SIGNAL(syncClickEmit()), my_sync_widget, SLOT(syncFiles()));
connect(my_sync_widget, SIGNAL(openXml(QString&)), this, SLOT(openXmlRecv(QString&)));
connect(my_sync_widget, SIGNAL(dboxAuthResult(bool)), this, SLOT(dboxAuthStatus(bool)));
connect(my_sync_widget, SIGNAL(dboxRecvResult(bool)), this, SLOT(dboxRecvStatus(bool)));
connect(my_sync_widget, SIGNAL(dboxSendResult(bool)), this, SLOT(dboxSendStatus(bool)));
connect(my_sync_widget, SIGNAL(googleAuthResult(bool)), this, SLOT(googleAuthStatus(bool)));
connect(my_sync_widget, SIGNAL(googleRecvResult(bool)), this, SLOT(googleRecvStatus(bool)));
connect(my_sync_widget, SIGNAL(googleSendResult(bool)), this, SLOT(googleSendStatus(bool)));
fileMenu = menuBar()->addMenu(tr("&File"));
newList = new QAction( tr("&New lists..."), this );
newList->setShortcuts(QKeySequence::New);
fileMenu->addAction(newList);
connect(newList, SIGNAL(triggered()),
this->my_task_list,SLOT(new_list()));
fileMenu->addSeparator();
loadAction = new QAction(tr("&Open XML..."), this);
loadAction->setShortcuts(QKeySequence::Open);
fileMenu->addAction(loadAction);
connect(loadAction, SIGNAL(triggered()),
this, SLOT(loadFile()));
saveAction = new QAction( tr("&Save..."), this );
saveAction->setShortcuts(QKeySequence::Save);
fileMenu->addAction(saveAction);
connect(saveAction, SIGNAL(triggered()),
this, SLOT(saveFile()));
saveAsAction = new QAction( tr("&Save as..."), this );
//saveAsAction->setShortcuts(QKeySequence::SaveAs);
fileMenu->addAction(saveAsAction);
connect(saveAsAction, SIGNAL(triggered()),
this, SLOT(saveasFile()));
fileMenu->addSeparator();
printAction = new QAction(tr("&Print"),this);
printAction->setShortcuts(QKeySequence::Print);
fileMenu->addAction(printAction);
connect(printAction, SIGNAL(triggered()),
this,SLOT(print()));
fileMenu->addSeparator();
exitAction = new QAction(tr("&Exit"), this);
fileMenu->addAction(exitAction);
connect(exitAction, SIGNAL(triggered()),
this, SLOT(close()));
OptMenu = menuBar()->addMenu(tr("&Options"));
change_font = new QAction(tr("&Change Font"),this);
OptMenu->addAction(change_font);
display_note = new QAction(tr("&Display/Hide Note"), this);
OptMenu->addAction(display_note);
search_for= new QAction(tr("&Search"),this);
search_for->setShortcut(QKeySequence::Find);
OptMenu->addAction(search_for);
connect(search_for,SIGNAL(triggered()),this,SLOT(search_start()));
Template = menuBar()->addMenu(tr("&Template"));
new_grocery = new QAction(tr("&Groceries"),this);
Template->addAction(new_grocery);
new_week_task = new QAction(tr("&Weekly Task"),this);
Template->addAction(new_week_task);
Sync = menuBar()->addMenu(tr("&Sync Menu"));
new_service = new QAction(tr("&Add Service"), this);
Sync->addAction(new_service);
sync_service = new QAction(tr("&Sync Services (On)"), this);
Sync->addAction(sync_service);
sync_service_off = new QAction(tr("&Sync Services Off"), this);
Sync->addAction(sync_service_off);
send_service = new QAction(tr("&Send Current File"), this);
Sync->addAction(send_service);
get_service = new QAction(tr("&Get Dropbox Files"), this);
Sync->addAction(get_service);
send_service_gtask = new QAction(tr("&Send Current File (GTask)"), this);
Sync->addAction(send_service_gtask);
get_service_gtask = new QAction(tr("&Get GTask Files"), this);
Sync->addAction(get_service_gtask);
//.........这里部分代码省略.........