本文整理汇总了C++中MetaData类的典型用法代码示例。如果您正苦于以下问题:C++ MetaData类的具体用法?C++ MetaData怎么用?C++ MetaData使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MetaData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main2
int main2()
{
MultidimArray<double> preImg, avgCurr, mappedImg;
MultidimArray<double> outputMovie;
Matrix1D<double> meanStdev;
ImageGeneric movieStack;
Image<double> II;
MetaData MD; // To save plot information
FileName motionInfFile, flowFileName, flowXFileName, flowYFileName;
ArrayDim aDim;
// For measuring times (both for whole process and for each level of the pyramid)
clock_t tStart, tStart2;
#ifdef GPU
// Matrix that we required in GPU part
GpuMat d_flowx, d_flowy, d_dest;
GpuMat d_avgcurr, d_preimg;
#endif
// Matrix required by Opencv
cv::Mat flow, dest, flowx, flowy;
cv::Mat flowxPre, flowyPre;
cv::Mat avgcurr, avgstep, preimg, preimg8, avgcurr8;
cv::Mat planes[]={flowxPre, flowyPre};
int imagenum, cnt=2, div=0, flowCounter;
int h, w, levelNum, levelCounter=1;
motionInfFile=foname.replaceExtension("xmd");
std::string extension=fname.getExtension();
if (extension=="mrc")
fname+=":mrcs";
movieStack.read(fname,HEADER);
movieStack.getDimensions(aDim);
imagenum = aDim.ndim;
h = aDim.ydim;
w = aDim.xdim;
if (darkImageCorr)
{
II.read(darkRefFilename);
darkImage=II();
}
if (gainImageCorr)
{
II.read(gianRefFilename);
gainImage=II();
}
meanStdev.initZeros(4);
//avgcurr=cv::Mat::zeros(h, w,CV_32FC1);
avgCurr.initZeros(h, w);
flowxPre=cv::Mat::zeros(h, w,CV_32FC1);
flowyPre=cv::Mat::zeros(h, w,CV_32FC1);
#ifdef GPU
// Object for optical flow
FarnebackOpticalFlow d_calc;
setDevice(gpuDevice);
// Initialize the parameters for optical flow structure
d_calc.numLevels=6;
d_calc.pyrScale=0.5;
d_calc.fastPyramids=true;
d_calc.winSize=winSize;
d_calc.numIters=1;
d_calc.polyN=5;
d_calc.polySigma=1.1;
d_calc.flags=0;
#endif
// Initialize the stack for the output movie
if (saveCorrMovie)
outputMovie.initZeros(imagenum, 1, h, w);
// Correct for global motion from a cross-correlation based algorithms
if (globalShiftCorr)
{
Matrix1D<double> shiftMatrix(2);
shiftVector.reserve(imagenum);
shiftMD.read(globalShiftFilename);
FOR_ALL_OBJECTS_IN_METADATA(shiftMD)
{
shiftMD.getValue(MDL_SHIFT_X, XX(shiftMatrix), __iter.objId);
shiftMD.getValue(MDL_SHIFT_Y, YY(shiftMatrix), __iter.objId);
shiftVector.push_back(shiftMatrix);
}
}
tStart2=clock();
// Compute the average of the whole stack
fstFrame++; // Just to adapt to Li algorithm
lstFrame++; // Just to adapt to Li algorithm
if (lstFrame>=imagenum || lstFrame==1)
lstFrame=imagenum;
imagenum=lstFrame-fstFrame+1;
levelNum=sqrt(double(imagenum));
computeAvg(fname, fstFrame, lstFrame, avgCurr);
// if the user want to save the PSD
if (doAverage)
{
II()=avgCurr;
II.write(foname);
//.........这里部分代码省略.........
示例2: randomize_random_generator
void ProgValidationNonTilt::run()
{
//Clustering Tendency and Cluster Validity Stephen D. Scott
randomize_random_generator();
//char buffer[400];
//sprintf(buffer, "xmipp_reconstruct_significant -i %s --initvolumes %s --odir %s --sym %s --iter 1 --alpha0 %f --angularSampling %f",fnIn.c_str(), fnInit.c_str(),fnDir.c_str(),fnSym.c_str(),alpha0,angularSampling);
//system(buffer);
MetaData md,mdOut,mdOut2;
FileName fnMd,fnOut,fnOut2;
fnMd = fnDir+"/angles_iter001_00.xmd";
fnOut = fnDir+"/clusteringTendency.xmd";
fnOut2 = fnDir+"/validation.xmd";
size_t nSamplesRandom = 250;
md.read(fnMd);
size_t maxNImg;
size_t sz = md.size();
md.getValue(MDL_IMAGE_IDX,maxNImg,sz);
String expression;
MDRow rowP,row2;
SymList SL;
int symmetry, sym_order;
SL.readSymmetryFile(fnSym.c_str());
SL.isSymmetryGroup(fnSym.c_str(), symmetry, sym_order);
double non_reduntant_area_of_sphere = SL.nonRedundantProjectionSphere(symmetry,sym_order);
double area_of_sphere_no_symmetry = 4.*PI;
double correction = std::sqrt(non_reduntant_area_of_sphere/area_of_sphere_no_symmetry);
double validation = 0;
MetaData tempMd;
std::vector<double> sum_u(nSamplesRandom);
//std::vector<double> sum_w(nSamplesRandom);
double sum_w=0;
std::vector<double> H0(nSamplesRandom);
std::vector<double> H(nSamplesRandom);
if (rank==0)
init_progress_bar(maxNImg);
for (size_t idx=0; idx<=maxNImg;idx++)
{
if ((idx+1)%Nprocessors==rank)
{
expression = formatString("imageIndex == %lu",idx);
tempMd.importObjects(md, MDExpression(expression));
if (tempMd.size()==0)
continue;
//compute H_0 from noise
obtainSumU(tempMd,sum_u,H0);
//compute H from experimental
obtainSumW(tempMd,sum_w,sum_u,H,correction);
std::sort(H0.begin(),H0.end());
std::sort(H.begin(),H.end());
double P = 0;
for(size_t j=0; j<sum_u.size();j++)
P += H0.at(j)/H.at(j);
P /= (nSamplesRandom);
rowP.setValue(MDL_IMAGE_IDX,idx);
rowP.setValue(MDL_WEIGHT,P);
mdPartial.addRow(rowP);
//sum_u.clear();
//sum_w.clear();
//H0.clear();
//H.clear();
tempMd.clear();
if (rank==0)
progress_bar(idx+1);
}
}
if (rank==0)
progress_bar(maxNImg);
synchronize();
gatherClusterability();
if (rank == 0)
{
mdPartial.write(fnOut);
std::vector<double> P;
mdPartial.getColumnValues(MDL_WEIGHT,P);
for (size_t idx=0; idx< P.size();idx++)
{
if (P[idx] > 1)
validation += 1;
}
validation /= (maxNImg+1);
//.........这里部分代码省略.........
示例3: mandel
int Computation::mandel(int xpt,int ypt,double xmin,double xmax,double ymin,double ymax , int _type)
{
MetaData m;
long double x = 0;
long double y = 0;
long double xnew = 0;
long double ynew = 0;
double ax;
double ay;
int color;
int h;
int xp = xpt;
int yp = ypt;
double minx = xmin;
double maxx = xmax;
double miny = ymin;
double maxy = ymax;
double pixCorx = (maxx - minx) / m.getWidth();
double pixCory = (maxy - miny) / m.getHeight();
ax = (xp * pixCorx) + (minx);
ay = maxy - (yp * pixCory);
for(h = 1 ; h <= iterations + 1 ; h++)
{
if( _type == MANDEL_TYPE1 )
{
xnew = ((x * x) - (y * y)) + ax;
ynew = (2 * x * y) + ay;
} // if
if( _type == MANDEL_TYPE2 )
{
xnew = ( ( x * x * x ) - ( 3 * x * y * y ) ) + ax;
ynew = ( ( 3 * x * x * y ) - ( y * y * y ) ) + ay;
} // if
if( _type == MANDEL_TYPE3 )
{
xnew = ( ( x * x * x * x ) - ( 6 * x * x * y * y ) + ( y * y * y * y ) ) + ax;
ynew = ( ( 4 * x * x * x * y ) - ( 4 * x * y * y * y ) ) + ay;
} // if
if( _type == MANDEL_TYPE4 )
{
xnew = ( ( x * x * x * x * x ) - ( 10 * x * x * x * y * y ) + ( 5 * x * y * y * y * y ) ) + ax;
ynew = ( ( 5 * x * x * x * x * y ) - ( 10 * x * x * y * y * y ) + ( y * y * y * y * y ) ) + ay;
} // if
if( _type == MANDEL_TYPE5 )
{
xnew = ( ( x * x * x * x * x * x ) - ( 15 * x * x * x * x * y * y ) + (15 * x * x * y * y * y * y ) - ( y * y * y * y * y * y ) ) + ax;
ynew = ( ( 6 * x * x * x * x * x * y ) - ( 20 * x * x * x * y * y * y ) + ( 6 * x * y * y * y * y * y ) ) + ay;
} // if
x = xnew;
y = ynew;
if(((x * x) + (y * y)) > 4)
break;
} // for
if(h >= iterations + 1 )
{
color =0 ;
} // if
else
{
color = h;
} // else
return color;
}
示例4: outputTrainingData_6cls
void outputTrainingData_6cls()
{
FILE *XFile,*YFile;
XFile=fopen("dataX.txt","w");
YFile=fopen("dataY.txt","w");
for(int i=0; i<2208-4; i++)
{
int XCnt=0;
if(checkUseData(i))
{
for(int st=0; st<9; st++)
{
for(int j=0; j<4; j++)
{
if(data[st][i+j].AQI==NullV)
fprintf(XFile,"%f,",2.5);
else
fprintf(XFile,"%d,",data[st][i+j].AQI);
XCnt++;
fprintf(XFile,"%d,",data[st][i+j].temp);
XCnt++;
fprintf(XFile,"%d,",data[st][i+j].pressure);
XCnt++;
fprintf(XFile,"%d,",data[st][i+j].humidity);
XCnt++;
fprintf(XFile,"%f,",data[st][i+j].windSpeed);
XCnt++;
fprintf(XFile,"%d,",data[st][i+j].windDirection);
XCnt++;
fprintf(XFile,"%d,",data[st][i+j].weather);
XCnt++;
}
}
int dircnt[10];
memset(dircnt,0,sizeof(dircnt));
int weacnt[10];
memset(weacnt,0,sizeof(weacnt));
for(int st=0; st<9; st++)
{
int AqiT[10];
memset(AqiT,0,sizeof(AqiT));
int cnt=0;
double tsum=0,psum=0,hsum=0,wsum=0;
for(int j=4; j<16; j++)
{
if(data[st][i+j].AQI==NullV)
;
else AqiT[data[st][i+j].AQI]++;
if(data[st][i+j].temp!=NullV)
{
cnt++;
tsum+=data[st][i+j].temp;
psum+=data[st][i+j].pressure;
hsum+=data[st][i+j].humidity;
wsum+=data[st][i+j].windSpeed;
}
// int t=data[st][i+j].windDirection;
dircnt[data[st][i+j].windDirection]++;
weacnt[data[st][i+j].weather]++;
}
// int sum=n0+n1+n2;
// fprintf(YFile,"%f,%f,%f",(n0+0.0)/sum,(n1+0.0)/sum,(n2+0.0)/sum);
int mostA=0;
for(int i=1;i<6;i++)
if(AqiT[i]>AqiT[mostA])
mostA=i;
fprintf(YFile,"%d",mostA);
if(st!=8)
fprintf(YFile,",");
MetaData tmp;
tmp.windSpeed=wsum/cnt;
tmp.evaluateWindSpeed();
fprintf(XFile,"%f,%f,",tsum/cnt,tmp.windSpeed);
XCnt+=2;
int mostDir=0,mostWea=0;
for(int i=1; i<9; i++)
if(dircnt[i]>dircnt[mostDir])
mostDir=i;
for(int i=1; i<8; i++)
if(weacnt[i]>weacnt[mostWea])
mostWea=i;
fprintf(XFile,"%d,%d,",mostDir,mostWea);
XCnt+=2;
// if(st!=8)
// fprintf(XFile,",");
}
int y,m,d,h;
sscanf(data[0][i].time,"%d-%d-%d %d",&y,&m,&d,&h);
fprintf(XFile,"%d\n",h);
fprintf(YFile,"\n");
}
}
}
示例5: feature
feature_ptr occi_featureset::next()
{
if (rs_ && rs_->next())
{
feature_ptr feature(feature_factory::create(ctx_,feature_id_));
++feature_id_;
if (use_wkb_)
{
Blob blob = rs_->getBlob (1);
blob.open(oracle::occi::OCCI_LOB_READONLY);
int size = blob.length();
if (buffer_.size() < size)
{
buffer_.resize(size);
}
oracle::occi::Stream* instream = blob.getStream(1,0);
instream->readBuffer(buffer_.data(), size);
blob.closeStream(instream);
blob.close();
geometry_utils::from_wkb(feature->paths(), buffer_.data(), size);
}
else
{
boost::scoped_ptr<SDOGeometry> geom(dynamic_cast<SDOGeometry*>(rs_->getObject(1)));
if (geom.get())
{
convert_geometry(geom.get(), feature);
}
}
std::vector<MetaData> listOfColumns = rs_->getColumnListMetaData();
for (unsigned int i = 1; i < listOfColumns.size(); ++i)
{
MetaData columnObj = listOfColumns[i];
std::string fld_name = columnObj.getString(MetaData::ATTR_NAME);
int type_oid = columnObj.getInt(MetaData::ATTR_DATA_TYPE);
/*
int type_code = columnObj.getInt(MetaData::ATTR_TYPECODE);
if (type_code == OCCI_TYPECODE_OBJECT)
{
continue;
}
*/
switch (type_oid)
{
case oracle::occi::OCCIBOOL:
case oracle::occi::OCCIINT:
case oracle::occi::OCCIUNSIGNED_INT:
case oracle::occi::OCCIROWID:
feature->put(fld_name,rs_->getInt (i + 1));
break;
case oracle::occi::OCCIFLOAT:
case oracle::occi::OCCIBFLOAT:
case oracle::occi::OCCIDOUBLE:
case oracle::occi::OCCIBDOUBLE:
case oracle::occi::OCCINUMBER:
case oracle::occi::OCCI_SQLT_NUM:
feature->put(fld_name,rs_->getDouble (i + 1));
break;
case oracle::occi::OCCICHAR:
case oracle::occi::OCCISTRING:
case oracle::occi::OCCI_SQLT_AFC:
case oracle::occi::OCCI_SQLT_AVC:
case oracle::occi::OCCI_SQLT_CHR:
case oracle::occi::OCCI_SQLT_LVC:
case oracle::occi::OCCI_SQLT_RDD:
case oracle::occi::OCCI_SQLT_STR:
case oracle::occi::OCCI_SQLT_VCS:
case oracle::occi::OCCI_SQLT_VNU:
case oracle::occi::OCCI_SQLT_VBI:
case oracle::occi::OCCI_SQLT_VST:
feature->put(fld_name,(UnicodeString) tr_->transcode (rs_->getString (i + 1).c_str()));
break;
case oracle::occi::OCCIDATE:
case oracle::occi::OCCITIMESTAMP:
case oracle::occi::OCCIINTERVALDS:
case oracle::occi::OCCIINTERVALYM:
case oracle::occi::OCCI_SQLT_DAT:
case oracle::occi::OCCI_SQLT_DATE:
case oracle::occi::OCCI_SQLT_TIME:
case oracle::occi::OCCI_SQLT_TIME_TZ:
case oracle::occi::OCCI_SQLT_TIMESTAMP:
case oracle::occi::OCCI_SQLT_TIMESTAMP_LTZ:
case oracle::occi::OCCI_SQLT_TIMESTAMP_TZ:
case oracle::occi::OCCI_SQLT_INTERVAL_YM:
case oracle::occi::OCCI_SQLT_INTERVAL_DS:
case oracle::occi::OCCIANYDATA:
case oracle::occi::OCCIBLOB:
case oracle::occi::OCCIBFILE:
case oracle::occi::OCCIBYTES:
case oracle::occi::OCCICLOB:
case oracle::occi::OCCIVECTOR:
//.........这里部分代码省略.........
示例6: main
int main(int argc, char *argv[])
{
char sig[37];
MetaData m;
struct stat s;
int index = 1;
bool hasmeta = false;
if (argc < 2)
{
printf("Usage: sigapp [-q] [-n] <mp3 file>\n");
printf(" -q => quiet mode\n");
printf(" -l => don't lookup data at musicbrainz\n");
exit(0);
}
if (strcmp(argv[index], "-q") == 0)
{
quiet = 1;
index++;
}
if (strcmp(argv[index], "-l") == 0)
{
nosubmit = 1;
index++;
}
if (get_metadata(argv[index], &m))
{
stat(argv[index], &s);
m.SetSize(s.st_size);
if (!quiet)
{
printf("Local metadata:\n");
printf(" Title: %s\n", m.Title().c_str());
printf(" Album: %s\n", m.Album().c_str());
printf(" Artist: %s\n", m.Artist().c_str());
printf(" Genre: %s\n", m.Genre().c_str());
printf(" Comment: %s\n", m.Comment().c_str());
printf(" Track: %d\n", m.Track());
printf(" Time: %d\n", m.Time());
printf(" Size: %d\n", m.Size());
}
hasmeta = true;
}
if (ff_decode(argv[index], sig, 0, 0, 0, 24000, 0))
{
m.SetGUID(sig);
if (!quiet)
printf("Signature: ");
printf("%s\n", sig);
if (!nosubmit)
{
lookup_metadata(&m);
}
#ifdef SIG_DEBUG
FILE *logfile = fopen("guid_mapping.txt", "a+");
fprintf(logfile,"%s\t%s\n", argv[index], sig);
fclose(logfile);
#endif
}
else
{
if (!quiet)
printf("Error calculating signature.\n");
}
return 0;
}
示例7: updateMetaDataForId
void WorldModel::updateMetaDataForId(ID newId, const MetaData &newData) {
for (string name : newData.GetValueNames()) {
metaData[newId].SetValue(name, newData.GetValue(name));
}
}
示例8: toDBus
QVariantMap toDBus(const MetaData &md) const {
QVariantMap map;
map["mpris:trackid"] = QVariant::fromValue(QDBusObjectPath(dbusTrackId(md.mrl())));
map["mpris:length"] = 1000LL*(qint64)md.duration();
map["xesam:url"] = md.mrl().toString();
map["xesam:title"] = md.title().isEmpty() ? engine->mediaInfo()->name() : md.title();
if (!md.album().isEmpty())
map["xesam:album"] = md.album();
if (!md.artist().isEmpty())
map["xesam:artist"] = QStringList(md.artist());
if (!md.genre().isEmpty())
map["xesam:genre"] = QStringList(md.genre());
return map;
}
示例9: mprintf
/** Given an array of already set up data sets (from e.g. input data files)
* and optional X values, add the sets to this list if they do not exist
* or append any existing sets.
*/
int DataSetList::AddOrAppendSets(std::string const& XlabelIn, Darray const& Xvals,
DataListType const& Sets)
{
if (debug_ > 0)
mprintf("DEBUG: Calling AddOrAppendSets for %zu sets, %zu X values, Xlabel= %s.\n",
Sets.size(), Xvals.size(), XlabelIn.c_str());
if (Sets.empty()) return 0; // No error for now.
// If no X label assume 'Frame' for backwards compat.
std::string Xlabel;
if (XlabelIn.empty())
Xlabel.assign("Frame");
else
Xlabel = XlabelIn;
Dimension Xdim;
// First determine if X values increase monotonically with a regular step
bool isMonotonic = Xdim.SetDimension(Xvals, Xlabel);
if (debug_ > 0) {
mprintf("DEBUG: xstep %g xmin %g\n", Xdim.Step(), Xdim.Min());
if (isMonotonic) mprintf("DEBUG: Xdim is monotonic.\n");
}
for (const_iterator ds = Sets.begin(); ds != Sets.end(); ++ds) {
if (*ds == 0) continue; // TODO: Warn about blanks?
if (debug_ > 0) mprintf("DEBUG: AddOrAppend set '%s'", (*ds)->legend());
if (isMonotonic) (*ds)->SetDim(Dimension::X, Xdim);
DataSet* existingSet = CheckForSet( (*ds)->Meta() );
if (existingSet == 0) {
// New set. If set is scalar 1D but X values are not monotonic,
// convert to XY mesh if necessary.
if ( !isMonotonic &&
(*ds)->Group() == DataSet::SCALAR_1D &&
(*ds)->Type() != DataSet::XYMESH )
{
DataSet* xyptr = AddSet( DataSet::XYMESH, (*ds)->Meta() );
if (xyptr == 0) {
mprinterr("Error: Could not convert set %s to XY mesh.\n", (*ds)->legend());
continue; // TODO exit instead?
}
if ( (*ds)->Size() != Xvals.size() ) { // Sanity check
mprinterr("Error: # of X values does not match set %s size.\n", (*ds)->legend());
continue;
}
DataSet_1D const& set = static_cast<DataSet_1D const&>( *(*ds) );
DataSet_Mesh& xy = static_cast<DataSet_Mesh&>( *xyptr );
for (unsigned int i = 0; i != set.Size(); i++)
xy.AddXY( Xvals[i], set.Dval(i) );
xy.SetDim(Dimension::X, Xdim);
if (debug_ > 0) mprintf(", New set, converted to XY-MESH\n");
// Free memory since set has now been converted.
delete *ds;
} else { // No conversion. Just add.
(*ds)->SetDim(Dimension::X, Xdim);
AddSet( *ds );
if (debug_ > 0) mprintf(", New set\n");
}
} else {
if (debug_ > 0) mprintf(", appending to existing set\n");
// Set exists. Try to append this set to existing set.
bool canAppend = true;
if ( (*ds)->Group() == DataSet::GENERIC ) {
// For GENERIC sets, base Type must match. // TODO: Should this logic be in DataSets?
if ( (*ds)->Type() != existingSet->Type() )
canAppend = false;
} else {
// For non-GENERIC sets, Group must match
if ( (*ds)->Group() != existingSet->Group() )
canAppend = false;
}
if (!canAppend)
mprinterr("Error: Cannot append set of type %s to set of type %s\n",
DataArray[(*ds)->Type()].Description,
DataArray[existingSet->Type()].Description);
// If cannot append or attempt to append fails, rename and add as new set.
if (!canAppend || existingSet->Append( *ds )) { // TODO Dimension check?
if (canAppend)
mprintf("Warning: Append currently not supported for type %s\n",
DataArray[existingSet->Type()].Description);
MetaData md = (*ds)->Meta();
md.SetName( GenerateDefaultName("X") );
mprintf("Warning: Renaming %s to %s\n", (*ds)->Meta().PrintName().c_str(),
md.PrintName().c_str());
(*ds)->SetMeta( md );
AddSet( *ds );
} else // Set was appended to existing set; memory can be freed.
delete *ds;
}
} // END loop over input sets
return 0;
}
示例10: originalAt
const MetaData MetaDataStore::originalAt(int row) const {
const MetaData item = _data[row];
return _backup.contains(item.id()) ? _backup[item.id()] : item;
}
示例11: strncmp
void PLS::AddItem(vector<PlaylistItem*>* list, char *entry,
char *title, int32 len, char *root)
{
int32 index;
uint32 length;
char path[_MAX_PATH];
PlaylistItem *item;
// if this is not a URL then let's
// enable people with different platforms
// to swap files by changing the path
// separator as necessary
if( strncmp(entry, "http://", 7) &&
strncmp(entry, "rtp://", 6) &&
strncmp(entry, "file://", 7))
{
for (index = strlen(entry) - 1; index >=0; index--)
{
if(entry[index] == '\\' && DIR_MARKER == '/')
entry[index] = DIR_MARKER;
else if(entry[index] == '/' && DIR_MARKER == '\\')
entry[index] = DIR_MARKER;
}
}
// get rid of nasty trailing whitespace
for (index = strlen(entry) - 1; index >=0; index--)
{
if(isspace(entry[index]))
{
entry[index] = 0x00;
}
else
break;
}
// is there anything left?
if(strlen(entry))
{
// is it a url already?
if (!strncmp(entry, "http://", 7) ||
!strncmp(entry, "rtp://", 6) ||
!strncmp(entry, "file://", 7))
{
strcpy(path, entry);
}
else
{
// is the path relative?
if( !strncmp(entry, "..", 2) ||
(strncmp(entry + 1, ":\\", 2) &&
strncmp(entry, DIR_MARKER_STR, 1)))
{
strcpy(path, root);
strcat(path, entry);
}
else
{
strcpy(path, entry);
}
// make it a url so we can add it to the playlist
length = strlen(path) + 15;
char *itemurl = new char[length];
if (IsntError(FilePathToURL(path, itemurl, &length)))
strcpy(path, itemurl);
delete [] itemurl;
}
if (title || len > 0)
{
MetaData oData;
if (title)
oData.SetTitle(title);
if (len > 0)
oData.SetTime(len);
item = new PlaylistItem(path, &oData);
}
else
item = new PlaylistItem(path);
list->push_back(item);
}
}
示例12: writeImageParameters
void ProgNmaAlignment::writeImageParameters(const FileName &fnImg) {
MetaData md;
size_t objId = md.addObject();
md.setValue(MDL_IMAGE, fnImg, objId);
md.setValue(MDL_ENABLED, 1, objId);
md.setValue(MDL_ANGLE_ROT, parameters(0), objId);
md.setValue(MDL_ANGLE_TILT, parameters(1), objId);
md.setValue(MDL_ANGLE_PSI, parameters(2), objId);
md.setValue(MDL_SHIFT_X, parameters(3), objId);
md.setValue(MDL_SHIFT_Y, parameters(4), objId);
int dim = numberOfModes;
std::vector<double> vectortemp;
for (int j = 5; j < 5 + dim; j++) {
vectortemp.push_back(parameters(j));
}
md.setValue(MDL_NMA, vectortemp, objId);
md.setValue(MDL_COST, parameters(5 + dim), objId);
md.append(fnOutDir+"/nmaDone.xmd");
}
示例13: main
int main(int argc, char *argv[])
{
CLParserPtr optParser = initParser();
string inPath, bottomAlignmentFile, topAlignmentFile, genomeName;
bool noMarkAncestors;
try {
optParser->parseOptions(argc, argv);
inPath = optParser->getArgument<string>("inFile");
bottomAlignmentFile = optParser->getOption<string>("bottomAlignmentFile");
topAlignmentFile = optParser->getOption<string>("topAlignmentFile");
genomeName = optParser->getArgument<string>("genomeName");
noMarkAncestors = optParser->getFlag("noMarkAncestors");
} catch (exception &e) {
optParser->printUsage(cerr);
return 1;
}
AlignmentPtr mainAlignment = openHalAlignment(inPath, optParser);
AlignmentConstPtr bottomAlignment;
AlignmentConstPtr topAlignment;
bool useTopAlignment = mainAlignment->getRootName() != genomeName;
bool useBottomAlignment = mainAlignment->getChildNames(genomeName).size() != 0;
Genome *mainReplacedGenome = mainAlignment->openGenome(genomeName);
if (useTopAlignment) {
// Not a root genome. Can update using a top alignment.
if (topAlignmentFile == "\"\"") {
throw hal_exception("Cannot replace non-root genome without a top "
"alignment file.");
}
topAlignment = openHalAlignment(topAlignmentFile,
optParser);
const Genome *topReplacedGenome = topAlignment->openGenome(genomeName);
topReplacedGenome->copyDimensions(mainReplacedGenome);
topReplacedGenome->copySequence(mainReplacedGenome);
}
if (useBottomAlignment) {
// Not a leaf genome. Can update using a bottom alignment.
if (bottomAlignmentFile == "\"\"") {
throw hal_exception("Cannot replace non-leaf genome without a bottom "
"alignment file.");
}
bottomAlignment = openHalAlignment(bottomAlignmentFile, optParser);
const Genome *botReplacedGenome = bottomAlignment->openGenome(genomeName);
botReplacedGenome->copyDimensions(mainReplacedGenome);
botReplacedGenome->copySequence(mainReplacedGenome);
}
if (!useTopAlignment && !useBottomAlignment) {
throw hal_exception("Root genome is also a leaf genome.");
}
if (useBottomAlignment) {
copyFromBottomAlignment(bottomAlignment, mainAlignment, genomeName);
}
if (useTopAlignment) {
copyFromTopAlignment(topAlignment, mainAlignment, genomeName);
}
// Clear update flag if present, since the genome has just been updated.
MetaData *metaData = mainReplacedGenome->getMetaData();
if (metaData->has("needsUpdate")) {
metaData->set("needsUpdate", "false");
}
if (!noMarkAncestors) {
markAncestorsForUpdate(mainAlignment, genomeName);
}
if (useTopAlignment) {
topAlignment->close();
}
if (useBottomAlignment) {
bottomAlignment->close();
}
mainAlignment->close();
}
示例14: mprinterr
// Exec_DataSetCmd::ModifyPoints()
Exec::RetType Exec_DataSetCmd::ModifyPoints(CpptrajState& State, ArgList& argIn, bool drop) {
const char* mode;
if (drop)
mode = "Drop";
else
mode = "Kee";
// Keywords
std::string name = argIn.GetStringKey("name");
int start = argIn.getKeyInt("start", 0) - 1;
int stop = argIn.getKeyInt("stop", -1);
int offset = argIn.getKeyInt("offset", -1);
Range points;
if (start < 0 && stop < 0 && offset < 0) {
std::string rangearg = argIn.GetStringKey("range");
if (rangearg.empty()) {
mprinterr("Error: Must specify range or start/stop/offset.\n");
return CpptrajState::ERR;
}
points.SetRange( rangearg );
if (points.Empty()) {
mprinterr("Error: Range '%s' is empty.\n", rangearg.c_str());
return CpptrajState::ERR;
}
mprintf("\t%sping points in range %s\n", mode, rangearg.c_str());
// User args start from 1
points.ShiftBy(-1);
}
// Get data set to drop/keep points from
// Loop over all DataSet arguments
std::string ds_arg = argIn.GetStringNext();
while (!ds_arg.empty()) {
DataSetList dsl = State.DSL().GetMultipleSets( ds_arg );
for (DataSetList::const_iterator it = dsl.begin(); it != dsl.end(); ++it)
{
DataSet* DS = *it;
if (DS->Size() < 1) {
mprinterr("Error: Set '%s' is empty.\n", DS->legend());
return CpptrajState::ERR;
}
// Restrict to 1D sets for now TODO more types
if (DS->Group() != DataSet::SCALAR_1D) {
mprinterr("Error: Currently only works for 1D scalar data sets.\n");
return CpptrajState::ERR;
}
DataSet_1D* ds1 = (DataSet_1D*)DS;
// Output data set
DataSet* out = 0;
if (name.empty()) {
// Modifying this set. Create new temporary set.
out = State.DSL().Allocate( ds1->Type() );
if (out == 0) return CpptrajState::ERR;
*out = *ds1;
mprintf("\tOverwriting set '%s'\n", ds1->legend());
} else {
// Write to new set
MetaData md = ds1->Meta();
md.SetName( name );
out = State.DSL().AddSet(ds1->Type(), md);
if (out == 0) return CpptrajState::ERR;
mprintf("\tNew set is '%s'\n", out->Meta().PrintName().c_str());
}
out->Allocate(DataSet::SizeArray(1, ds1->Size()));
if (points.Empty()) {
// Drop by start/stop/offset. Set defaults if needed
if (start < 0) start = 0;
if (stop < 0) stop = ds1->Size();
if (offset < 0) offset = 1;
mprintf("\t%sping points from %i to %i, step %i\n", mode, start+1, stop, offset);
for (int idx = start; idx < stop; idx += offset)
points.AddToRange( idx );
} // TODO check that range values are valid?
if (State.Debug() > 0) mprintf("DEBUG: Keeping points:");
Range::const_iterator pt = points.begin();
int idx = 0;
int odx = 0;
if (drop) {
// Drop points
for (; idx < (int)ds1->Size(); idx++) {
if (pt == points.end()) break;
if (*pt != idx) {
if (State.Debug() > 0) mprintf(" %i", idx + 1);
KeepPoint(ds1, out, idx, odx);
} else
++pt;
}
// Keep all remaining points
for (; idx < (int)ds1->Size(); idx++) {
if (State.Debug() > 0) mprintf(" %i", idx + 1);
KeepPoint(ds1, out, idx, odx);
}
} else {
// Keep points
for (; pt != points.end(); pt++) {
if (*pt >= (int)ds1->Size()) break;
if (State.Debug() > 0) mprintf(" %i", *pt + 1);
KeepPoint(ds1, out, *pt, odx);
}
}
if (State.Debug() > 0) mprintf("\n");
//.........这里部分代码省略.........
示例15: Q_D
//.........这里部分代码省略.........
}
case INF_POSITION: {
KIO::filesize_t pos = readFilesize_t(stream);
emit position(pos);
break;
}
case INF_SPEED:
stream >> ul;
d->slave_calcs_speed = true;
d->speed_timer.stop();
emit speed( ul );
break;
case INF_GETTING_FILE:
break;
case INF_ERROR_PAGE:
emit errorPage();
break;
case INF_REDIRECTION: {
KUrl url;
stream >> url;
emit redirection( url );
break;
}
case INF_MIME_TYPE:
stream >> str1;
emit mimeType(str1);
if (!d->connection->suspended())
d->connection->sendnow(CMD_NONE, QByteArray());
break;
case INF_WARNING:
stream >> str1;
emit warning(str1);
break;
case INF_MESSAGEBOX: {
kDebug(7007) << "needs a msg box";
QString text, caption, buttonYes, buttonNo, dontAskAgainName;
int type;
stream >> type >> text >> caption >> buttonYes >> buttonNo;
if (stream.atEnd()) {
messageBox(type, text, caption, buttonYes, buttonNo);
} else {
stream >> dontAskAgainName;
messageBox(type, text, caption, buttonYes, buttonNo, dontAskAgainName);
}
break;
}
case INF_INFOMESSAGE: {
QString msg;
stream >> msg;
emit infoMessage(msg);
break;
}
case INF_META_DATA: {
MetaData m;
stream >> m;
if (m.contains(QLatin1String("ssl_in_use"))) {
const QLatin1String ssl_("ssl_");
const MetaData constM = m;
for (MetaData::ConstIterator it = constM.lowerBound(ssl_); it != constM.constEnd(); ++it) {
if (it.key().startsWith(ssl_)) {
d->sslMetaData.insert(it.key(), it.value());
} else {
// we're past the ssl_* entries; remember that QMap is ordered.
break;
}
}
}
emit metaData(m);
break;
}
case MSG_NET_REQUEST: {
QString host;
QString slaveid;
stream >> host >> slaveid;
requestNetwork(host, slaveid);
break;
}
case MSG_NET_DROP: {
QString host;
QString slaveid;
stream >> host >> slaveid;
dropNetwork(host, slaveid);
break;
}
case MSG_NEED_SUBURL_DATA: {
emit needSubUrlData();
break;
}
case MSG_HOST_INFO_REQ: {
QString hostName;
stream >> hostName;
HostInfo::lookupHost(hostName, this, SLOT(slotHostInfo(QHostInfo)));
break;
}
default:
kWarning(7007) << "Slave sends unknown command (" << _cmd << "), dropping slave";
return false;
}
return true;
}