MusicRipperSettings::MusicRipperSettings(void) { VerticalConfigurationGroup* rippersettings = new VerticalConfigurationGroup(false); rippersettings->setLabel(QObject::tr("CD Ripper Settings")); rippersettings->addChild(ParanoiaLevel()); rippersettings->addChild(FilenameTemplate()); rippersettings->addChild(NoWhitespace()); rippersettings->addChild(PostCDRipScript()); rippersettings->addChild(EjectCD()); addChild(rippersettings); VerticalConfigurationGroup* encodersettings = new VerticalConfigurationGroup(false); encodersettings->setLabel(QObject::tr("CD Ripper Settings (part 2)")); encodersettings->addChild(EncoderType()); encodersettings->addChild(DefaultRipQuality()); encodersettings->addChild(Mp3UseVBR()); addChild(encodersettings); }
/** Set up variable with value. In this case allow any amount of whitespace, * so re-tokenize the original argument line (minus the command). */ CpptrajState::RetType Control_Set::SetupControl(CpptrajState& State, ArgList& argIn, Varray& CurrentVars) { ArgList remaining = argIn.RemainingArgs(); size_t pos0 = remaining.ArgLineStr().find_first_of("="); if (pos0 == std::string::npos) { mprinterr("Error: Expected <var>=<value>\n"); return CpptrajState::ERR; } size_t pos1 = pos0; bool append = false; if (pos0 > 0 && remaining.ArgLineStr()[pos0-1] == '+') { pos0--; append = true; } std::string variable = NoWhitespace( remaining.ArgLineStr().substr(0, pos0) ); if (variable.empty()) { mprinterr("Error: No variable name.\n"); return CpptrajState::ERR; } ArgList equals( NoLeadingWhitespace(remaining.ArgLineStr().substr(pos1+1)) ); std::string value; if (equals.Contains("inmask")) { AtomMask mask( equals.GetStringKey("inmask") ); Topology* top = State.DSL().GetTopByIndex( equals ); if (top == 0) return CpptrajState::ERR; if (top->SetupIntegerMask( mask )) return CpptrajState::ERR; if (equals.hasKey("atoms")) value = integerToString( mask.Nselected() ); else if (equals.hasKey("residues")) { int curRes = -1; int nres = 0; for (AtomMask::const_iterator at = mask.begin(); at != mask.end(); ++at) { int res = (*top)[*at].ResNum(); if (res != curRes) { nres++; curRes = res; } } value = integerToString( nres ); } else if (equals.hasKey("molecules")) { int curMol = -1; int nmol = 0; for (AtomMask::const_iterator at = mask.begin(); at != mask.end(); ++at) { int mol = (*top)[*at].MolNum(); if (mol != curMol) { nmol++; curMol = mol; } } value = integerToString( nmol ); } else { mprinterr("Error: Expected 'atoms', 'residues', or 'molecules'.\n"); return CpptrajState::ERR; } } else if (equals.hasKey("trajinframes")) { value = integerToString(State.InputTrajList().MaxFrames()); } else value = equals.ArgLineStr(); if (append) CurrentVars.AppendVariable( "$" + variable, value ); else CurrentVars.UpdateVariable( "$" + variable, value ); mprintf("\tVariable '%s' set to '%s'\n", variable.c_str(), value.c_str()); for (int iarg = 0; iarg < argIn.Nargs(); iarg++) argIn.MarkArg( iarg ); return CpptrajState::OK; }
// Action_Density::Init() Action::RetType Action_Density::Init(ArgList& actionArgs, ActionInit& init, int debugIn) { # ifdef MPI trajComm_ = init.TrajComm(); # endif DataFile* outfile = init.DFL().AddDataFile(actionArgs.GetStringKey("out"), actionArgs); std::string dsname = actionArgs.GetStringKey("name"); if (actionArgs.hasKey("x") ) { axis_ = DX; area_coord_[0] = DY; area_coord_[1] = DZ; } else if (actionArgs.hasKey("y") ) { axis_ = DY; area_coord_[0] = DX; area_coord_[1] = DZ; } else if (actionArgs.hasKey("z") ) { axis_ = DZ; area_coord_[0] = DX; area_coord_[1] = DY; } property_ = NUMBER; if (actionArgs.hasKey("number") ) property_ = NUMBER; else if (actionArgs.hasKey("mass") ) property_ = MASS; else if (actionArgs.hasKey("charge") ) property_ = CHARGE; else if (actionArgs.hasKey("electron") ) property_ = ELECTRON; binType_ = CENTER; if (actionArgs.hasKey("bincenter")) binType_ = CENTER; else if (actionArgs.hasKey("binedge") ) binType_ = EDGE; delta_ = actionArgs.getKeyDouble("delta", 0.01); if (delta_ <= 0) { mprinterr("Error: Delta must be > 0.0\n"); return Action::ERR; } // for compatibility with ptraj, ignored because we rely on the atom code to // do the right thing, see Atom.{h,cpp} if (actionArgs.hasKey("efile")) mprintf("Warning: The 'efile' keyword is deprecated.\n"); // read the rest of the command line as a series of masks std::string maskstr; unsigned int idx = 1; while ( (maskstr = actionArgs.GetMaskNext() ) != emptystring) { masks_.push_back( AtomMask(maskstr) ); if (dsname.empty()) dsname = init.DSL().GenerateDefaultName("DENSITY"); MetaData MD(dsname, "avg", idx); MD.SetTimeSeries( MetaData::NOT_TS ); // Hold average density DataSet* ads = init.DSL().AddSet( DataSet::DOUBLE, MD ); if (ads == 0) return Action::ERR; ads->SetLegend( NoWhitespace(masks_.back().MaskExpression()) ); AvSets_.push_back( ads ); if (outfile != 0) outfile->AddDataSet( ads ); // Hold SD density MD.SetAspect("sd"); DataSet* sds = init.DSL().AddSet( DataSet::DOUBLE, MD ); if (sds == 0) return Action::ERR; sds->SetLegend( NoWhitespace("sd(" + masks_.back().MaskExpression() + ")") ); SdSets_.push_back( sds ); if (outfile != 0) outfile->AddDataSet( sds ); # ifdef MPI ads->SetNeedsSync( false ); // Populated in Print() sds->SetNeedsSync( false ); # endif idx++; } if (masks_.empty()) { // If no masks assume we want total system density. if (dsname.empty()) dsname = actionArgs.GetStringNext(); density_ = init.DSL().AddSet(DataSet::DOUBLE, dsname, "DENSITY"); if (density_ == 0) return Action::ERR; if (outfile != 0) outfile->AddDataSet( density_ ); image_.InitImaging( true ); // Hijack delta for storing sum of masses delta_ = 0.0; } else { // Density selected by mask(s) along an axis density_ = 0; histograms_.resize(masks_.size() ); } mprintf(" DENSITY:"); if (density_ == 0) { const char* binStr[] = {"center", "edge"}; mprintf(" Determining %s density for %zu masks.\n", PropertyStr_[property_], masks_.size()); mprintf("\troutine version: %s\n", ROUTINE_VERSION_STRING); mprintf("\tDelta is %f\n", delta_); mprintf("\tAxis is %s\n", AxisStr_[axis_]); mprintf("\tData set name is '%s'\n", dsname.c_str()); mprintf("\tData set aspect [avg] holds the mean, aspect [sd] holds standard deviation.\n"); mprintf("\tBin coordinates will be to bin %s.\n", binStr[binType_]); } else { mprintf(" No masks specified, calculating total system density in g/cm^3.\n"); mprintf("\tData set name is '%s'\n", density_->legend()); } if (outfile != 0) mprintf("\tOutput to '%s'\n", outfile->DataFilename().full()); return Action::OK; }
// Action_Density::Init() Action::RetType Action_Density::Init(ArgList& actionArgs, ActionInit& init, int debugIn) { # ifdef MPI if (init.TrajComm().Size() > 1) { mprinterr("Error: 'density' action does not work with > 1 thread (%i threads currently).\n", init.TrajComm().Size()); return Action::ERR; } # endif DataFile* outfile = init.DFL().AddDataFile(actionArgs.GetStringKey("out"), actionArgs); std::string dsname = actionArgs.GetStringKey("name"); if (dsname.empty()) dsname = init.DSL().GenerateDefaultName("DENSITY"); if (actionArgs.hasKey("x") ) { axis_ = DX; area_coord_[0] = DY; area_coord_[1] = DZ; } else if (actionArgs.hasKey("y") ) { axis_ = DY; area_coord_[0] = DX; area_coord_[1] = DZ; } else if (actionArgs.hasKey("z") ) { axis_ = DZ; area_coord_[0] = DX; area_coord_[1] = DY; } property_ = NUMBER; if (actionArgs.hasKey("number") ) property_ = NUMBER; if (actionArgs.hasKey("mass") ) property_ = MASS; if (actionArgs.hasKey("charge") ) property_ = CHARGE; if (actionArgs.hasKey("electron") ) property_ = ELECTRON; delta_ = actionArgs.getKeyDouble("delta", 0.01); // for compatibility with ptraj, ignored because we rely on the atom code to // do the right thing, see Atom.{h,cpp} if (actionArgs.hasKey("efile")) mprintf("Warning: The 'efile' keyword is deprecated.\n"); // read the rest of the command line as a series of masks std::string maskstr; unsigned int idx = 1; while ( (maskstr = actionArgs.GetMaskNext() ) != emptystring) { masks_.push_back( AtomMask(maskstr) ); MetaData MD(dsname, "avg", idx); MD.SetTimeSeries( MetaData::NOT_TS ); // Hold average density DataSet* ads = init.DSL().AddSet( DataSet::DOUBLE, MD ); if (ads == 0) return Action::ERR; ads->SetLegend( NoWhitespace(masks_.back().MaskExpression()) ); AvSets_.push_back( ads ); if (outfile != 0) outfile->AddDataSet( ads ); // Hold SD density MD.SetAspect("sd"); DataSet* sds = init.DSL().AddSet( DataSet::DOUBLE, MD ); if (sds == 0) return Action::ERR; sds->SetLegend( NoWhitespace("sd(" + masks_.back().MaskExpression() + ")") ); SdSets_.push_back( sds ); if (outfile != 0) outfile->AddDataSet( sds ); # ifdef MPI ads->SetNeedsSync( false ); // Populated in Print() sds->SetNeedsSync( false ); # endif idx++; } if (masks_.empty()) { mprinterr("Error: No masks specified.\n"); return Action::ERR; } minus_histograms_.resize(masks_.size() ); plus_histograms_.resize(masks_.size() ); mprintf(" DENSITY: Determining %s density for %zu masks.\n", PropertyStr_[property_], masks_.size()); mprintf("\troutine version: %s\n", ROUTINE_VERSION_STRING); mprintf("\tDelta is %f\n", delta_); mprintf("\tAxis is %s\n", AxisStr_[axis_]); mprintf("\tData set name is '%s'\n", dsname.c_str()); if (outfile != 0) mprintf("\tOutput to '%s'\n", outfile->DataFilename().full()); return Action::OK; }