TQCString StubProcess::commaSeparatedList(QCStringList lst) { if (lst.count() == 0) return TQCString(""); QCStringList::Iterator it = lst.begin(); TQCString str = *it; for (it++; it!=lst.end(); it++) { str += ','; str += *it; } return str; }
extern "C" KDE_EXPORT int kdemain( int argc, char **argv ) { // here we go, construct the Kate version QString kateVersion = KateApp::kateVersion(); KAboutData aboutData ("kate", I18N_NOOP("Kate"), kateVersion.latin1(), I18N_NOOP( "Kate - Advanced Text Editor" ), KAboutData::License_LGPL_V2, I18N_NOOP( "(c) 2000-2005 The Kate Authors" ), 0, "http://kate.kde.org"); aboutData.addAuthor ("Christoph Cullmann", I18N_NOOP("Maintainer"), "*****@*****.**", "http://www.babylon2k.de"); aboutData.addAuthor ("Anders Lund", I18N_NOOP("Core Developer"), "*****@*****.**", "http://www.alweb.dk"); aboutData.addAuthor ("Joseph Wenninger", I18N_NOOP("Core Developer"), "*****@*****.**","http://stud3.tuwien.ac.at/~e9925371"); aboutData.addAuthor ("Hamish Rodda",I18N_NOOP("Core Developer"), "*****@*****.**"); aboutData.addAuthor ("Waldo Bastian", I18N_NOOP( "The cool buffersystem" ), "*****@*****.**" ); aboutData.addAuthor ("Charles Samuels", I18N_NOOP("The Editing Commands"), "*****@*****.**"); aboutData.addAuthor ("Matt Newell", I18N_NOOP("Testing, ..."), "*****@*****.**"); aboutData.addAuthor ("Michael Bartl", I18N_NOOP("Former Core Developer"), "*****@*****.**"); aboutData.addAuthor ("Michael McCallum", I18N_NOOP("Core Developer"), "*****@*****.**"); aboutData.addAuthor ("Jochen Wilhemly", I18N_NOOP( "KWrite Author" ), "*****@*****.**" ); aboutData.addAuthor ("Michael Koch",I18N_NOOP("KWrite port to KParts"), "*****@*****.**"); aboutData.addAuthor ("Christian Gebauer", 0, "*****@*****.**" ); aboutData.addAuthor ("Simon Hausmann", 0, "*****@*****.**" ); aboutData.addAuthor ("Glen Parker",I18N_NOOP("KWrite Undo History, Kspell integration"), "*****@*****.**"); aboutData.addAuthor ("Scott Manson",I18N_NOOP("KWrite XML Syntax highlighting support"), "*****@*****.**"); aboutData.addAuthor ("John Firebaugh",I18N_NOOP("Patches and more"), "*****@*****.**"); aboutData.addAuthor ("Dominik Haumann", I18N_NOOP("Developer & Highlight wizard"), "*****@*****.**"); aboutData.addCredit ("Matteo Merli",I18N_NOOP("Highlighting for RPM Spec-Files, Perl, Diff and more"), "*****@*****.**"); aboutData.addCredit ("Rocky Scaletta",I18N_NOOP("Highlighting for VHDL"), "*****@*****.**"); aboutData.addCredit ("Yury Lebedev",I18N_NOOP("Highlighting for SQL"),""); aboutData.addCredit ("Chris Ross",I18N_NOOP("Highlighting for Ferite"),""); aboutData.addCredit ("Nick Roux",I18N_NOOP("Highlighting for ILERPG"),""); aboutData.addCredit ("Carsten Niehaus", I18N_NOOP("Highlighting for LaTeX"),""); aboutData.addCredit ("Per Wigren", I18N_NOOP("Highlighting for Makefiles, Python"),""); aboutData.addCredit ("Jan Fritz", I18N_NOOP("Highlighting for Python"),""); aboutData.addCredit ("Daniel Naber","",""); aboutData.addCredit ("Roland Pabel",I18N_NOOP("Highlighting for Scheme"),""); aboutData.addCredit ("Cristi Dumitrescu",I18N_NOOP("PHP Keyword/Datatype list"),""); aboutData.addCredit ("Carsten Pfeiffer", I18N_NOOP("Very nice help"), ""); aboutData.addCredit (I18N_NOOP("All people who have contributed and I have forgotten to mention"),"",""); aboutData.setTranslator(I18N_NOOP2("NAME OF TRANSLATORS","Your names"), I18N_NOOP2("EMAIL OF TRANSLATORS","Your emails")); // command line args init and co KCmdLineArgs::init (argc, argv, &aboutData); KCmdLineArgs::addCmdLineOptions (options); KCmdLineArgs::addTempFileOption(); KateApp::addCmdLineOptions (); // get our command line args ;) KCmdLineArgs* args = KCmdLineArgs::parsedArgs(); // now, first try to contact running kate instance if needed if ( args->isSet("use") || (::getenv("KATE_PID")!=0) ) { DCOPClient client; client.attach (); // get all attached clients ;) QCStringList allClients = client.registeredApplications(); // search for a kate app client, use the first found QCString kateApp; if ( args->isSet("start") ) { for (unsigned int i=0; i < allClients.count(); i++) { if (allClients[i] == "kate" || allClients[i].left(5) == "kate-") { DCOPRef ref( allClients[i], "KateApplication" ); QString s = ref.call( "session" ); if ( QString(args->getOption("start")) == s ) { kateApp = allClients[i]; break; } } } } else if ( (args->isSet("pid")) || (::getenv("KATE_PID") !=0 ) ) { QCString tryApp; if ( args->isSet("pid") ) tryApp = args->getOption("pid"); else tryApp = ::getenv("KATE_PID"); if ( client.isApplicationRegistered( tryApp.prepend("kate-") ) ) kateApp = tryApp; } else { for (unsigned int i=0; i < allClients.count(); ++i) { if (allClients[i] == "kate" || allClients[i].left(5) == "kate-") { kateApp = allClients[i]; break; } } } // found a matching kate client ;) if (!kateApp.isEmpty()) { kdDebug () << "kate app: " << kateApp << endl; // make kdeinit happy client.registerAs( "kate" ); DCOPRef kRef (kateApp, "KateApplication"); if (args->isSet ("start")) kRef.call( "activateSession", QString (args->getOption("start")) ); QString enc = args->isSet("encoding") ? args->getOption("encoding") : QCString(""); bool tempfileSet = KCmdLineArgs::isTempFileSet(); for (int z=0; z<args->count(); z++) kRef.call( "openURL", args->url(z), enc, tempfileSet ); if( args->isSet( "stdin" ) ) { QTextIStream input(stdin); // set chosen codec QTextCodec *codec = args->isSet("encoding") ? QTextCodec::codecForName(args->getOption("encoding")) : 0; if (codec) input.setCodec (codec); QString line; QString text; do { line = input.readLine(); text.append( line + "\n" ); } while( !line.isNull() ); kRef.call( "openInput", text ); } int line = 0; int column = 0; bool nav = false; if (args->isSet ("line")) { line = args->getOption ("line").toInt(); nav = true; } if (args->isSet ("column")) { column = args->getOption ("column").toInt(); nav = true; } if (nav) kRef.call( "setCursor", line, column ); // since the user tried to open a document, let us assume [s]he // wants to see that document. // ### what to do about the infamous focus stealing prevention? uint mwn = kRef.call("activeMainWindowNumber"); QCString smwn; DCOPRef wRef( kateApp, QCString( "__KateMainWindow#") + smwn.setNum(mwn) ); if ( wRef.call("minimized") ) { if ( wRef.call( "maximized" ) ) wRef.call( "maximize" ); else wRef.call("restore"); } wRef.call( "raise" ); // stop startup notification KStartupInfo::appStarted( ); return 0; } } // construct the real kate app object ;) KateApp app (args); // app execution should already end :) if (app.shouldExit()) { return 0; } // execute ourself ;) return app.exec(); }
void Qhp::initialize() { /* <QtHelpProject version="1.0"> <namespace>mycompany.com.myapplication.1_0</namespace> <virtualFolder>doc</virtualFolder> <customFilter name="My Application 1.0"> <filterAttribute>myapp</filterAttribute> <filterAttribute>1.0</filterAttribute> </customFilter> <filterSection> <filterAttribute>myapp</filterAttribute> <filterAttribute>1.0</filterAttribute> .. */ QCString nameSpace = Config_getString(QHP_NAMESPACE); QCString virtualFolder = Config_getString(QHP_VIRTUAL_FOLDER); m_doc.declaration("1.0", "UTF-8"); const char * rootAttributes[] = { "version", "1.0", 0 }; m_doc.open("QtHelpProject", rootAttributes); m_doc.openCloseContent("namespace", nameSpace); m_doc.openCloseContent("virtualFolder", virtualFolder); // Add custom filter QCString filterName = Config_getString(QHP_CUST_FILTER_NAME); if (!filterName.isEmpty()) { const char * tagAttributes[] = { "name", filterName, 0 }; m_doc.open("customFilter", tagAttributes); QCStringList customFilterAttributes = QCStringList::split(' ', Config_getString(QHP_CUST_FILTER_ATTRS)); for (int i = 0; i < (int)customFilterAttributes.count(); i++) { m_doc.openCloseContent("filterAttribute", customFilterAttributes[i]); } m_doc.close("customFilter"); } m_doc.open("filterSection"); // Add section attributes QCStringList sectionFilterAttributes = QCStringList::split(' ', Config_getString(QHP_SECT_FILTER_ATTRS)); if (!sectionFilterAttributes.contains("doxygen")) { sectionFilterAttributes << "doxygen"; } for (int i = 0; i < (int)sectionFilterAttributes.count(); i++) { m_doc.openCloseContent("filterAttribute", sectionFilterAttributes[i]); } m_toc.open("toc"); // Add extra root node QCString fullProjectname = getFullProjectName(); QCString indexFile = "index"+Doxygen::htmlFileExtension; const char * const attributes[] = { "title", fullProjectname, "ref", indexFile, NULL }; m_toc.open("section", attributes); m_prevSectionTitle = getFullProjectName(); m_prevSectionLevel = 1; m_sectionLevel = 1; m_index.open("keywords"); m_files.open("files"); }
int main(int argc, char *argv[]) { int i_file, i_v, i_curve; int i_plot; KAboutData aboutData( "kst", I18N_NOOP("Kst"), "0.95-devel", description, KAboutData::License_GPL, I18N_NOOP("(c) 2000-2003 Barth Netterfield"), 0, "http://extragear.kde.org/apps/kst.php"); aboutData.addAuthor("Barth Netterfield", I18N_NOOP("Original author and maintainer."), "*****@*****.**", "http://omega.astro.utoronto.ca/"); aboutData.addAuthor("Staikos Computing Services Inc.", I18N_NOOP("Developed for the University of Toronto."), "*****@*****.**", "http://www.staikos.net/"); KCmdLineArgs::init( argc, argv, &aboutData ); KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. KApplication app; KImageIO::registerFormats(); if (app.isRestored()) { RESTORE(KstApp) } else { KstApp *kst = new KstApp; struct InType in; QColor color; QCStringList ycolList; QCStringList yEqList; QCStringList psdList; QCStringList hsList; QCStringList errorList; unsigned int i_ycol; QCStringList::Iterator psd; QCStringList::Iterator hs; QCStringList::Iterator eq_i; bool nOK; /* temp variables: these all get stuck into list objects */ KstDataSourcePtr file; KstRVector *xvector=NULL; KstRVector *yvector; KstRVector *evector; KstVCurve *curve; KstPSDCurve *psdcurve; KstEquationCurve *eqcurve; KstHistogram *hscurve; KstPlot *plot; int n_y, n_eq=0; /* Parse command line args */ KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); CheckForCMDErrors(args); // Initialise the plugin loader and collection. PluginCollection::self(); /* get Y axis collums */ ycolList = args->getOptionList("y"); yEqList = args->getOptionList("ye"); psdList = args->getOptionList("p"); hsList = args->getOptionList("h"); errorList = args->getOptionList("e"); // y axis or PSD specified, so the files are data files, not kst files. n_y = ycolList.count() + psdList.count() + hsList.count() + yEqList.count(); if (n_y > 0) { SetCMDOptions(args, in, n_y); CreatePlots(in); i_plot = 0; plot = KST::plotList.at(i_plot); /* make stand alone equations if there are no files */ if (args->count()<1) { if (!yEqList.isEmpty()) { QString eqS; double max, min; int n; bool xeq; SetEqXRanges(args->getOption("xe"), &min, &max, &n, &xeq); if (xeq) { for (eq_i = yEqList.begin(); eq_i != yEqList.end(); ++eq_i) { eqS = *eq_i; if (NoVectorEq(eqS)) { eqcurve = new KstEquationCurve(QString("E")+QString::number(n_eq+1)+ "-" + eqS, eqS, min,max,n, KstColorSequence::next()); KST::dataObjectList.lock().writeLock(); KST::dataObjectList.append(eqcurve); KST::dataObjectList.lock().writeUnlock(); plot->addCurve(eqcurve); if (in.sep_plots) { i_plot++; if (i_plot <in.n_plots) plot = KST::plotList.at(i_plot); } } } } } } /* Make the requested curves for each data file */ for (i_curve = i_v = 0, i_file = 0; i_file < args->count(); i_file++) { /* Make the file */ file = KstDataSource::loadSource(args->arg(i_file)); if (!file) { kdWarning() << I18N_NOOP("Error: No data in file: ") << args->arg(i_file) << endl; delete kst; exit(0); } if (!file->isValid() || file->frameCount() < 1) { kdWarning() << I18N_NOOP("Error: No data in file: ") << args->arg(i_file) << endl; // The file might get data later! } KST::dataObjectList.lock().writeLock(); KST::dataSourceList.append(file); KST::dataObjectList.lock().writeUnlock(); if (!ycolList.isEmpty()) { // if there are some xy plots /* make the x axis vector */ xvector = GetOrCreateVector(args->getOption("x"), file, in); /* make the y axis vectors */ for (i_ycol = 0; i_ycol < ycolList.count(); ++i_ycol ) { yvector = GetOrCreateVector(*(ycolList.at(i_ycol)), file, in); /* make the curves */ color = KstColorSequence::next(); curve = new KstVCurve(QString("C") + QString::number(1+i_curve++) + "-" + yvector->getField(), KstVectorPtr(xvector), KstVectorPtr(yvector), 0L, 0L, color); if (in.has_points) { curve->setHasPoints(true); curve->setHasLines(false); } if (i_ycol<errorList.count()) { evector = GetOrCreateVector(*(errorList.at(i_ycol)), file, in); curve->setYError(KstVectorPtr(evector)); } KST::dataObjectList.lock().writeLock(); KST::dataObjectList.append(curve); KST::dataObjectList.lock().writeUnlock(); plot->addCurve(curve); if (in.sep_plots) { i_plot++; if (i_plot < in.n_plots) plot = KST::plotList.at(i_plot); } // end (if they are separate plots) } // next y col } // end (if there are some xy plots) if (!yEqList.isEmpty()) { QString eqS; double max, min; int n; bool xeq, eq_ok; SetEqXRanges(args->getOption("xe"), &min, &max, &n, &xeq); for (eq_i = yEqList.begin(); eq_i != yEqList.end(); ++eq_i) { eqS = *eq_i; ProcessEq(eqS, file, in, &eq_ok); if (xeq) { eqcurve = new KstEquationCurve(QString("E")+QString::number(n_eq+1)+ "-" + eqS, eqS, min,max,n, KstColorSequence::next()); } else { if (xvector==NULL) xvector = GetOrCreateVector(args->getOption("x"), file, in); eqcurve = new KstEquationCurve(QString("E")+QString::number(n_eq+1)+eqS, eqS, KstVectorPtr(xvector), true, KstColorSequence::next()); } KST::dataObjectList.lock().writeLock(); KST::dataObjectList.append(eqcurve); KST::dataObjectList.lock().writeUnlock(); plot->addCurve(eqcurve); if (in.sep_plots) { i_plot++; if (i_plot <in.n_plots) plot = KST::plotList.at(i_plot); } } } if (psdList.count() > 0) { // if there are some psd plots KstRVectorList rvl = kstObjectSubList<KstVector,KstRVector>(KST::vectorList); for(psd = psdList.begin(); psd != psdList.end(); ++psd ) { yvector = GetOrCreateVector(*psd, file, in); color = KstColorSequence::next(); psdcurve = new KstPSDCurve(QString("P") + QString::number(1+i_curve++) + "-" + yvector->getField(), KstVectorPtr(yvector), in.rate, in.len, in.VUnits,in.RUnits, color); if (in.has_points) { psdcurve->setHasPoints(true); psdcurve->setHasLines(false); } KST::dataObjectList.lock().writeLock(); KST::dataObjectList.append(psdcurve); KST::dataObjectList.lock().writeUnlock(); plot->addCurve(psdcurve); if (in.sep_plots) { i_plot++; if (i_plot <in.n_plots) plot = KST::plotList.at(i_plot); } } // next psd } // end (if there are some psds) if (hsList.count()>0) { // if there are some histograms double max, min; int N; KstRVectorList rvl = kstObjectSubList<KstVector,KstRVector>(KST::vectorList); for (hs = hsList.begin(); hs != hsList.end(); ++hs ) { yvector = GetOrCreateVector(*hs, file, in); color = KstColorSequence::next(); KstHistogram::AutoBin(KstVectorPtr(yvector), &N, &max, &min); hscurve = new KstHistogram(QString("H") + QString::number(1+i_curve++) + "-" + yvector->getField(), KstVectorPtr(yvector), min, max, N, KST_HS_NUMBER, color); KST::dataObjectList.lock().writeLock(); KST::dataObjectList.append(KstDataObjectPtr(hscurve)); KST::dataObjectList.lock().writeUnlock(); plot->addCurve(hscurve); if (in.sep_plots) { i_plot++; if (i_plot < in.n_plots) plot = KST::plotList.at(i_plot); } } // next histogram } // end (if there are some histograms) } // next data file for (i_plot = 0; i_plot < in.n_plots; i_plot++) { KST::plotList.at(i_plot)->GenerateDefaultLabels(); } KST::plotList.setPlotCols(in.n_cols); } else if (args->count() > 0) { /* open a kst file */ /* some of the options can be overridden */ kst->openDocumentFile(args->arg(0), args->getOption("F"), // override FileName // override number of frames args->getOption("n").toInt(&nOK), // override starting frame args->getOption("f").toInt(&nOK), // override skip args->getOption("s").toInt(&nOK), // add averaging args->isSet("a")); } else { //kst->openDocumentFile(); } QString printfile; printfile = args->getOption("print"); QString pngfile; pngfile = args->getOption("png"); bool print_and_exit = false; if (printfile!="<none>") { args->clear(); kst->forceUpdate(); kst->immediatePrintToFile(printfile); print_and_exit = true; } if (pngfile!="<none>") { args->clear(); kst->forceUpdate(); kst->immediatePrintToPng(pngfile); print_and_exit = true; } if (print_and_exit) { delete kst; exit(0); } else { args->clear(); app.setMainWidget(kst); kst->show(); } // LEAVE THIS HERE - causes crashes otherwise! int rc = app.exec(); delete kst; return rc; } return app.exec(); }
int main(int argc, char *argv[]) { int i_file, i_v, i_curve; int i_plot; QString fullPath; KAboutData aboutData("kst", I18N_NOOP("Kst"), KSTVERSION, description, KAboutData::License_GPL, I18N_NOOP("(c) 2000-2007 Barth Netterfield"), 0, "http://kst.kde.org/"); aboutData.addAuthor("Barth Netterfield", I18N_NOOP("Original author and maintainer."), "*****@*****.**", "http://omega.astro.utoronto.ca/"); aboutData.addAuthor("Staikos Computing Services Inc.", I18N_NOOP("Developed for the University of Toronto."), "*****@*****.**", "http://www.staikos.net/"); aboutData.addAuthor("Sumus Technology Limited", I18N_NOOP("Developed for the University of British Columbia"), "*****@*****.**", "http://www.sumusltd.com/"); aboutData.addAuthor("Rick Chern", I18N_NOOP("University of British Columbia"), "", ""); aboutData.addAuthor("Duncan Hanson", I18N_NOOP("University of British Columbia"), "", ""); aboutData.addAuthor("Nicolas Brisset", "", "", ""); aboutData.addAuthor("Matthew Truch", "", "http://matt.truch.net/", "*****@*****.**"); aboutData.addAuthor("Theodore Kisner", "", "*****@*****.**", ""); aboutData.setTranslator(I18N_NOOP("_: NAME OF TRANSLATORS\nYour names"), I18N_NOOP("_: EMAIL OF TRANSLATORS\nYour emails")); KCmdLineArgs::init( argc, argv, &aboutData ); KCmdLineArgs::addCmdLineOptions( options ); // Add our own options. KApplication app; KImageIO::registerFormats(); KstDialogs::replaceSelf(new KstGuiDialogs); KstData::replaceSelf(new KstGuiData); KstApp::initialize(); atexit(exitHelper); if (app.isRestored()) { RESTORE(KstApp) } else { KstApp *kst = new KstApp; InType in; QColor color; QCStringList ycolList; QCStringList matrixList; QCStringList yEqList; QCStringList psdList; QCStringList hsList; QCStringList errorList; unsigned int i_ycol; QCStringList::Iterator hs_string; QCStringList::Iterator eq_i; QCStringList::Iterator mat_i; bool showQuickStart = false; bool showDataWizard = false; bool nOK; int n_y = 0; KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); CheckForCMDErrors(args); QString wizardfile = args->getOption("w"); QString printfile = args->getOption("print"); QString pngfile = args->getOption("png"); bool print_and_exit = false; if (printfile != "<none>") { print_and_exit = true; } if (pngfile != "<none>") { print_and_exit = true; } if (!print_and_exit) { app.setMainWidget(kst); QRect rect = KGlobalSettings::desktopGeometry(kst); kst->resize(5 * rect.width() / 6, 5 * rect.height() / 6); kst->show(); } // get Y axis columns ycolList = args->getOptionList("y"); matrixList = args->getOptionList("z"); yEqList = args->getOptionList("ye"); psdList = args->getOptionList("p"); hsList = args->getOptionList("h"); errorList = args->getOptionList("e"); // y axis or PSD specified, so the files are data files, not kst files. n_y = ycolList.count() + psdList.count() + hsList.count() + yEqList.count() + matrixList.count(); if (n_y > 0) { QString creatingEquations = i18n("Creating equations"); QString creatingCurves = i18n("Creating curves"); QString creatingPlots = i18n("Creating plots"); int count; int handled; kst->slotUpdateProgress( 0, 0, QString::null ); SetCMDOptions(args, in, n_y); KstTopLevelViewPtr tlv = kst->activeView(); if (!tlv) { // if there was no active view then we create one... kst->newWindow(false); tlv = kst->activeView(); } if (!tlv) { kstdError() << i18n("Can't create a view.") << endl; return 0; } CreatePlots(in, tlv); Kst2DPlotList plist = kstObjectSubList<KstViewObject, Kst2DPlot>(tlv->children()); i_plot = 0; Kst2DPlotPtr plot = *plist.at(i_plot); KstVCurveList vcurves = kstObjectSubList<KstBaseCurve,KstVCurve>(plot->Curves); // make stand alone equations if there are no files if (args->count() < 1) { if (!yEqList.isEmpty()) { QString eqS; double max, min; int n; bool xeq; SetEqXRanges(args->getOption("xe"), &min, &max, &n, &xeq); if (xeq) { count = yEqList.size(); handled = 0; kst->slotUpdateProgress( count, handled, creatingEquations ); for (eq_i = yEqList.begin(); eq_i != yEqList.end(); ++eq_i) { eqS = *eq_i; if (NoVectorEq(eqS)) { KstEquationPtr eq = new KstEquation(KST::suggestEQName(eqS), eqS, min, max, n); KstVCurvePtr vc = new KstVCurve(KST::suggestCurveName(eq->tag(), true), eq->vX(), eq->vY(), 0L, 0L, 0L, 0L, KstColorSequence::next(vcurves,plot->backgroundColor())); KST::dataObjectList.lock().writeLock(); KST::dataObjectList.append(eq.data()); KST::dataObjectList.append(vc.data()); KST::dataObjectList.lock().unlock(); plot->addCurve(vc.data()); if (in.sep_plots) { i_plot++; if (i_plot < in.n_plots) { plot = *plist.at(i_plot); } } } handled++; kst->slotUpdateProgress( count, handled, creatingEquations ); } } } } // make the requested curves for each data file count = args->count(); handled = 0; kst->slotUpdateProgress( count, handled, creatingCurves ); for (i_curve = i_v = 0, i_file = 0; i_file < args->count(); i_file++) { // make the file if (QFile::exists(args->arg(i_file))) { fullPath = QFileInfo(args->arg(i_file)).absFilePath(); } else { fullPath = args->arg(i_file); } KstDataSourcePtr file = KstDataSource::loadSource(fullPath); if (file) { if (!file->isValid() || file->isEmpty()) { kstdError() << i18n("No data in file %1. Trying to continue...").arg(args->arg(i_file)) << endl; // The file might get data later! } KST::dataObjectList.lock().writeLock(); KST::dataSourceList.append(file); KST::dataObjectList.lock().unlock(); KstRVectorPtr yvector; KstRVectorPtr evector; KstVCurvePtr curve; KstPSDPtr psd; KstHistogramPtr hs; KstRVectorPtr xvector; if (!ycolList.isEmpty()) { // if there are some xy plots // make the x axis vector xvector = GetOrCreateVector(args->getOption("x"), file, in); if (xvector) { // make the y axis vectors for (i_ycol = 0; i_ycol < ycolList.count(); ++i_ycol ) { yvector = GetOrCreateVector(*(ycolList.at(i_ycol)), file, in); if (yvector) { // make the curves color = KstColorSequence::next(vcurves,plot->backgroundColor()); curve = new KstVCurve(KST::suggestCurveName(yvector->tag(), false), KstVectorPtr(xvector), KstVectorPtr(yvector), 0L, 0L, 0L, 0L, color); if (in.has_points) { curve->setHasPoints(true); curve->setHasLines(false); } if (i_ycol<errorList.count()) { evector = GetOrCreateVector(*(errorList.at(i_ycol)), file, in); if (evector) { curve->setYError(KstVectorPtr(evector)); curve->setYMinusError(KstVectorPtr(evector)); } } KST::dataObjectList.lock().writeLock(); KST::dataObjectList.append(curve.data()); KST::dataObjectList.lock().unlock(); plot->addCurve(curve.data()); if (in.sep_plots) { plot->setTagName(curve->tag()); i_plot++; if (i_plot < in.n_plots) { plot = *plist.at(i_plot); } } // end (if they are separate plots) } } // next y col } } // end (if there are some xy plots) if (!yEqList.isEmpty()) { QString eqS; double max, min; int n; bool xeq, eq_ok; SetEqXRanges(args->getOption("xe"), &min, &max, &n, &xeq); for (eq_i = yEqList.begin(); eq_i != yEqList.end(); ++eq_i) { KstEquationPtr eq; eqS = *eq_i; ProcessEq(eqS, file, in, &eq_ok); if (xeq) { eq = new KstEquation(KST::suggestEQName(eqS), eqS, min,max,n); } else { if (!xvector) { xvector = GetOrCreateVector(args->getOption("x"), file, in); } if (xvector) { eq = new KstEquation(KST::suggestEQName(eqS), eqS, KstVectorPtr(xvector), true); } } if (eq) { KstVCurvePtr vc = new KstVCurve(KST::suggestCurveName(eq->tag(), true), eq->vX(), eq->vY(), 0L, 0L, 0L, 0L, KstColorSequence::next(vcurves,plot->backgroundColor())); KST::dataObjectList.lock().writeLock(); KST::dataObjectList.append(eq.data()); KST::dataObjectList.append(vc.data()); KST::dataObjectList.lock().unlock(); plot->addCurve(vc.data()); if (in.sep_plots) { plot->setTagName(eq->tag()); i_plot++; if (i_plot <in.n_plots) { plot = *plist.at(i_plot); } } } } } if (psdList.count() > 0) { // if there are some psd plots KstRVectorList rvl = kstObjectSubList<KstVector,KstRVector>(KST::vectorList); for (QCStringList::ConstIterator it = psdList.begin(); it != psdList.end(); ++it) { yvector = GetOrCreateVector(*it, file, in); if (yvector) { color = KstColorSequence::next(vcurves,plot->backgroundColor()); psd = new KstPSD( KST::suggestPSDName(yvector->tag()), // FIXME: this was yvector->field(), is this right? KstVectorPtr(yvector), in.rate, true, in.len, true, true, in.VUnits, in.RUnits, WindowOriginal); KstVCurvePtr vc = new KstVCurve(KST::suggestCurveName(psd->tag(), true), psd->vX(), psd->vY(), 0L, 0L, 0L, 0L, color); if (in.has_points) { vc->setHasPoints(true); vc->setHasLines(false); } KST::dataObjectList.lock().writeLock(); KST::dataObjectList.append(psd.data()); KST::dataObjectList.append(vc.data()); KST::dataObjectList.lock().unlock(); plot->addCurve(vc.data()); if (in.sep_plots) { plot->setTagName(psd->tag()); i_plot++; if (i_plot <in.n_plots) { plot = *plist.at(i_plot); } } } } // next psd } // end (if there are some psds) if (hsList.count() > 0) { // if there are some histograms double max, min; int N; KstRVectorList rvl = kstObjectSubList<KstVector,KstRVector>(KST::vectorList); for (hs_string = hsList.begin(); hs_string != hsList.end(); ++hs_string) { yvector = GetOrCreateVector(*hs_string, file, in); if (yvector) { color = KstColorSequence::next(vcurves,plot->backgroundColor()); KstHistogram::AutoBin(KstVectorPtr(yvector), &N, &max, &min); hs = new KstHistogram(KST::suggestHistogramName(yvector->tag()), KstVectorPtr(yvector), min, max, N, KST_HS_NUMBER); KstVCurvePtr vc = new KstVCurve(KST::suggestCurveName(hs->tag(), true), hs->vX(), hs->vY(), 0L, 0L, 0L, 0L, color); vc->setHasPoints(false); vc->setHasLines(false); vc->setHasBars(true); vc->setBarStyle(1); KST::dataObjectList.lock().writeLock(); KST::dataObjectList.append(hs.data()); KST::dataObjectList.append(vc.data()); KST::dataObjectList.lock().unlock(); plot->addCurve(vc.data()); if (in.sep_plots) { plot->setTagName(hs->tag()); i_plot++; if (i_plot < in.n_plots) { plot = *plist.at(i_plot); } } } } // next histogram } // end (if there are some histograms) if (matrixList.count() > 0) { // if there are some matrixes for (mat_i = matrixList.begin(); mat_i != matrixList.end(); ++mat_i) { QString tag_name = KST::suggestMatrixName(*mat_i); if (!file->isValidMatrix(*mat_i)) { startupErrors.append(i18n("Failed to create matrix '%1' from file '%2'.").arg(*mat_i).arg(file->fileName())); } KstRMatrixPtr matrix = new KstRMatrix(file, *mat_i, KstObjectTag(tag_name, file->tag()), 0,0,-1,-1,false,false,0); // xStart, yStart, xNumSteps, yNumSteps, //doAve, doSkip, skip); // Time to create the image from the matrix tag_name = KST::suggestImageName(matrix->tag()); QStringList palList = KPalette::getPaletteList(); QString pal; if (palList.contains("IDL 13 RAINBOW")) { pal = QString("IDL 13 RAINBOW"); } else { pal = QString(*palList.at(0)); } KPalette* newPal = new KPalette(pal); KstImagePtr image = new KstImage(tag_name, KstMatrixPtr(matrix), 0.0, 1.0, true, newPal); plot->addCurve(KstBaseCurvePtr(image)); KST::dataObjectList.lock().writeLock(); KST::dataObjectList.append(image.data()); KST::dataObjectList.lock().unlock(); image = 0L; // drop the reference if (in.sep_plots) { plot->setTagName(matrix->tag()); i_plot++; if (i_plot < in.n_plots) { plot = *plist.at(i_plot); } } } } } else { startupErrors.append(i18n("Failed to load file '%1'.").arg(args->arg(i_file))); } handled++; kst->slotUpdateProgress( count, handled, creatingCurves ); } // next data file count = in.n_plots; handled = 0; kst->slotUpdateProgress( count, handled, creatingPlots ); for (i_plot = 0; i_plot < in.n_plots; i_plot++) { plot = *plist.at(i_plot); plot->generateDefaultLabels(); // if we have only images in a plot then set the scale mode to AUTO (instead of AUTOBORDER) KstImageList images = kstObjectSubList<KstBaseCurve,KstImage>(plot->Curves); if (images.count() == plot->Curves.count()) { plot->setXScaleMode(AUTO); plot->setYScaleMode(AUTO); } if (plot->Curves.count() > 3 || in.dolegend) { KstViewLegendPtr vl = plot->getOrCreateLegend(); vl->resizeFromAspect(0.1, 0.1, 0.2, 0.1); vl->setBorderWidth(2); } handled++; kst->slotUpdateProgress( count, handled, creatingPlots ); } kst->slotUpdateProgress( 0, 0, QString::null ); } else if (args->count() > 0) { // open a kst file // some of the options can be overridden kst->openDocumentFile(args->arg(0), args->getOption("F"), // override FileName args->getOption("n").toInt(&nOK), // override number of frames args->getOption("f").toInt(&nOK), // override starting frame args->getOption("s").toInt(&nOK), // override skip args->isSet("a"), // add averaging !print_and_exit); // delayed } else { //kst->openDocumentFile(); showQuickStart = true; } if (args->isSet("nq")) { showQuickStart = false; } if (args->isSet("w")) { showDataWizard = true; showQuickStart = false; } if (printfile != "<none>") { kst->forceUpdate(); kst->immediatePrintToFile(printfile, false); } if (pngfile != "<none>") { kst->forceUpdate(); kst->immediatePrintToPng(pngfile); } kst->document()->setModified(false); if (print_and_exit) { delete kst; return 0; } else { kst->updateDialogs(); if (showQuickStart) { kst->showQuickStartDialog(); } if (showDataWizard) { kst->showDataWizardWithFile(wizardfile); } for (size_t i = 0; i < startupErrors.size(); ++i) { KstDebug::self()->log(startupErrors[i], KstDebug::Error); } startupErrors.clear(); } // LEAVE THIS HERE - causes crashes otherwise! int rc = app.exec(); delete kst; return rc; } return app.exec(); }
int main(int argc, char **argv) { KAboutData about("kstcmd", I18N_NOOP("Kst Command Line"), "1.0", I18N_NOOP("Kst Command Line"), KAboutData::License_GPL, I18N_NOOP("(c) 2005-2006 The University of Toronto"), 0, "http://kst.kde.org/"); about.addAuthor("Staikos Computing Services Inc.", I18N_NOOP("Developed for the University of Toronto"), "*****@*****.**"); KCmdLineArgs::init(argc, argv, &about); KCmdLineArgs::addCmdLineOptions(options); KApplication a(false, false); QCString session; KCmdLineArgs *args = KCmdLineArgs::parsedArgs(); if (args->count() > 0) { session = args->arg(0); } setvbuf(stdout, 0, _IONBF, 0); if (session.isEmpty()) { DCOPClient *client = KApplication::dcopClient(); QCStringList apps = client->registeredApplications(); QCStringList ksts; for (QCStringList::ConstIterator i = apps.begin(); i != apps.end(); ++i) { if ((*i).left(4) == "kst-") { ksts += *i; } } if (ksts.isEmpty()) { char *l = readline(_T("Kst does not appear to be running. Start a new session? ")); if (!l) { return ERR_NONE; } QString lstr = l; free(l); l = 0L; if (lstr.stripWhiteSpace().lower()[0] != 'y') { return ERR_NONE; } int pid = 0; QString err; int rc = KApplication::startServiceByDesktopName("kst", QString::null, &err, &session, &pid); if (rc != 0) { printf(_T("Error starting session: %s\n"), err.latin1()); return ERR_STARTING_SESSION; } if (session.isEmpty()) { session = QString("kst-%1").arg(pid).latin1(); } time_t startTime = time(NULL); printf("%s", _T("Waiting for Kst to start.")); while (!client->isApplicationRegistered(session)) { if (time(NULL) - startTime > 30) { printf("%s", _T("\nTimeout waiting for Kst to start\n")); return ERR_STARTING_SESSION; } printf("."); sleep(1); } printf("\n"); } else if (ksts.count() > 1) { QCString parentKst = QCString("kst-") + QString::number(getppid()).latin1(); if (ksts.contains(parentKst)) { session = parentKst; } else { printf("%s", _T("Please choose a session number to attach to:\n")); int j = 0; for (QCStringList::ConstIterator i = ksts.begin(); i != ksts.end(); ++i) { printf(_T("%2d: %s\n"), ++j, (*i).data()); } printf("> "); char choice[10]; QString l = fgets(choice, 4, stdin); l = l.stripWhiteSpace(); if (l.isEmpty()) { printf("%s", _T("No session found.\n")); return ERR_NO_SESSION; } bool ok = false; int nchoice = l.toInt(&ok); if (ok && nchoice > 0 && nchoice <= j) { session = ksts[nchoice - 1]; } else { printf("%s", _T("No session found.\n")); return ERR_NO_SESSION; } } } else { session = ksts[0]; } } DCOPRef ref(session.data(), "KstScript"); if (ref.isNull() || !KApplication::dcopClient()->registeredApplications().contains(ref.app())) { printf(_T("Error attaching to session %s\n"), session.data()); return ERR_ATTACHING; } printf(_T("Attached to Kst session %s\n"), session.data()); return run(ref); }