void FuzzySaver::save(const QMap<QString, RugItem *> &rugs) { if(QFile::exists(m_dirPath)) QFile::remove(m_dirPath); QFile f(m_dirPath); f.open(QIODevice::WriteOnly); QXmlStreamWriter stream(&f); stream.setAutoFormatting(true); stream.writeStartDocument(); stream.writeStartElement("fuzzysession"); ThreadPatternCollection * tpc(ThreadPatternCollection::getInstance()); QString dpath(ThreadPattern::DefaultPattern()->path()); // First save patterns foreach(const QString& k, tpc->getCollection().keys()) { QString path(tpc->value(k)->path()); if(dpath != path) stream.writeTextElement("patternpath", path); } // Now rugs! foreach(const QString& k, rugs.keys()) { RugItem * rug(rugs.value(k)); if(rug->getThreadPattern()->path() != ThreadPattern::DefaultPattern()->path()) { stream.writeStartElement("rug"); stream.writeAttribute("name", rug->getRugName()); stream.writeAttribute("xpos", QString::number(rug->x(), 'f')); stream.writeAttribute("ypos", QString::number(rug->y(), 'f')); stream.writeAttribute("width", QString::number(rug->getRugSize().width(), 'f')); stream.writeAttribute("height", QString::number(rug->getRugSize().height(), 'f')); stream.writeAttribute("threadheight", QString::number(rug->getThreadHeight(), 'f')); stream.writeAttribute("patternsize", QString::number(rug->getPatternSize(), 'f')); stream.writeAttribute("wphundred", QString::number(rug->getWP100(), 'f')); stream.writeTextElement("pattern", rug->getThreadPattern()->getName()); stream.writeEndElement(); // rug } } stream.writeEndElement(); // fuzzysession stream.writeEndDocument(); }
Mix_Chunk* sfx_load_sample(char *filename) { Mix_Chunk *sample; char *path; path = dpath(filename); sample = Mix_LoadWAV(path); r_free(path); if (!sample) { fprintf(stderr, "Mix_LoadWAV: %s\n", Mix_GetError()); exit(-1); } return sample; }
bool IsBeIDEProject(const entry_ref &ref) { DPath dpath(ref); if (!dpath.GetExtension() || strcmp(dpath.GetExtension(), "proj") != 0) return false; BFile file(&ref, B_READ_ONLY); if (file.InitCheck() != B_OK) return false; char magic[5]; if (file.Read(magic, 4) < 4) return false; magic[4] = '\0'; return (strcmp(magic, "MIDE") == 0); }
void sfx_play_music(char *filename) { char *path; if (!has_sound) return; Mix_FreeMusic(music); path = dpath(filename); // load the song if(!(music=Mix_LoadMUS(path))) { fprintf(stderr, "Mix_LoadMUS error (%s)\n", filename); exit(-1); } r_free(path); // set the post mix processor up if (Mix_PlayMusic(music, -1)==-1) { fprintf(stderr, "Mix_LoadMUS error\n"); exit(-1); } }
void pyne::Material::from_hdf5(char * filename, char * datapath, int row, int protocol) { std::string fname (filename); std::string dpath (datapath); from_hdf5(fname, dpath, row, protocol); };
status_t BeIDE2Paladin(const char *path, BString &outpath) { status_t returnVal = BEntry(path).InitCheck(); if (returnVal != B_OK) return returnVal; BeIDEProject beide(path); if (beide.InitCheck() != B_OK) return beide.InitCheck(); DPath dpath(path); Project proj(dpath.GetBaseName(), beide.TargetName()); proj.SetPlatform(PLATFORM_R5); // NOTE: TARGET_* from Project.h & TARGET_* from BeIDEPRoject.h // map perfectly, so no explicit conversion required proj.SetTargetType(beide.TargetType()); BString savepath(dpath.GetFolder()); savepath << "/" << dpath.GetBaseName() << ".pld"; proj.Save(savepath.String()); for (int32 i = 0; i < beide.CountLocalIncludes(); i++) { BString include = beide.LocalIncludeAt(i); if (include.ICompare("{project}") == 0) continue; include.RemoveFirst("{project}/"); proj.AddLocalInclude(include.String()); } for (int32 i = 0; i < beide.CountSystemIncludes(); i++) { BString include = beide.SystemIncludeAt(i); if (include.ICompare("{project}") == 0) continue; include.RemoveFirst("{project}/"); proj.AddSystemInclude(include.String()); } SourceGroup *currentGroup = NULL; for (int32 i = 0; i < beide.CountFiles(); i++) { ProjectFile file = beide.FileAt(i); if (file.path.FindFirst("/_KERNEL_") > 0) continue; SourceFile *srcFile = gFileFactory.CreateSourceFileItem(file.path.String()); if (!srcFile) continue; if (dynamic_cast<SourceFileLib*>(srcFile)) { proj.AddLibrary(srcFile->GetPath().GetFileName()); delete srcFile; continue; } if (!proj.HasGroup(file.group.String())) currentGroup = proj.AddGroup(file.group.String()); BPath newPath; if (proj.LocateFile(srcFile->GetPath().GetFullPath(), newPath)) srcFile->SetPath(newPath.Path()); proj.AddFile(srcFile, currentGroup); } uint32 codeFlags = beide.CodeGenerationFlags(); if (codeFlags & CODEGEN_DEBUGGING) proj.SetDebug(true); if (codeFlags & CODEGEN_OPTIMIZE_SIZE) proj.SetOpForSize(true); proj.SetOpLevel(beide.OptimizationMode()); // Because Paladin doesn't currently support the seemingly 50,000 warning // types, we'll put them in the compiler options for the ones not commonly // used BString options; uint32 warnings = beide.Warnings(); if (warnings & WARN_STRICT_ANSI) options << "-pedantic "; if (warnings & WARN_LOCAL_SHADOW) options << "-Wshadow "; if (warnings & WARN_INCOMPATIBLE_CAST) options << "-Wbad-function-cast "; if (warnings & WARN_CAST_QUALIFIERS) options << "-Wcast-qual "; if (warnings & WARN_CONFUSING_CAST) options << "-Wconversion "; if (warnings & WARN_CANT_INLINE) options << "-Winline "; if (warnings & WARN_EXTERN_TO_INLINE) options << "-Wextern-inline "; if (warnings & WARN_OVERLOADED_VIRTUALS) options << "-Woverloaded-virtual "; if (warnings & WARN_C_CASTS) options << "-Wold-style-cast "; if (warnings & WARN_EFFECTIVE_CPP) options << "-Weffc++ "; if (warnings & WARN_MISSING_PARENTHESES) options << "-Wparentheses "; if (warnings & WARN_INCONSISTENT_RETURN) options << "-Wreturn-type "; if (warnings & WARN_MISSING_ENUM_CASES) options << "-Wswitch "; if (warnings & WARN_UNUSED_VARS) options << "-Wunusued "; if (warnings & WARN_UNINIT_AUTO_VARS) options << "-Wuninitialized "; if (warnings & WARN_INIT_REORDERING) options << "-Wreorder "; if (warnings & WARN_NONVIRTUAL_DESTRUCTORS) options << "-Wnon-virtual-dtor "; if (warnings & WARN_UNRECOGNIZED_PRAGMAS) options << "-Wunknown-pragmas "; if (warnings & WARN_SIGNED_UNSIGNED_COMP) options << "-Wsign-compare "; if (warnings & WARN_CHAR_SUBSCRIPTS) options << "-Wchar-subscripts "; if (warnings & WARN_PRINTF_FORMATTING) options << "-Wformat "; if (warnings & WARN_TRIGRAPHS_USED) options << "-Wtrigraphs "; uint32 langopts = beide.LanguageOptions(); if (langopts & LANGOPTS_ANSI_C_MODE) options << "-ansi "; if (langopts & LANGOPTS_SUPPORT_TRIGRAPHS) options << "-trigraphs "; if (langopts & LANGOPTS_SIGNED_CHAR) options << "-fsigned-char "; if (langopts & LANGOPTS_UNSIGNED_BITFIELDS) options << "-funsigned-bitfields "; if (langopts & LANGOPTS_CONST_CHAR_LITERALS) options << "-Wwrite-strings "; options << beide.ExtraCompilerOptions(); proj.SetExtraCompilerOptions(options.String()); proj.SetExtraLinkerOptions(beide.ExtraLinkerOptions()); proj.Save(); outpath = savepath; return B_OK; }
void PltWin::drawIt(QPainter *p) { QString txt; double x, y, x0, y0, x1, y1, x2, y2, xprev, yprev, shift, ubmin, ubmax, ub, alpha; int n, layer, lay, prev_layer, circDia, i, j, at, ichain, a, istart, iend, icurr, xs, ys; int idx, nmax; bool dum; QPen *pen = new QPen(); QBrush *brush = new QBrush(); QBrush *brush_unrld = new QBrush(); // antialiasing of primitives if ANTIALIASE is set to true if (!paintEPS) p->setRenderHint(QPainter::Antialiasing, ANTIALIASE); // plot the grain boundary line if (isGBfile && showGB) { x0 = ZFact*xyzMin(1) - xPan - (ZFact-1)*xyzCen(1); x1 = ZFact*xyzMax(1) - xPan - (ZFact-1)*xyzCen(1); y = ZFact*gbYcoor - yPan - (ZFact-1)*xyzCen(2); DrawLine(p, x0, y, x1, y); } if (AtomPos==COMPOSITE) { if (!paintEPS) { brush_unrld->setColor( Qt::lightGray ); brush_unrld->setStyle( Qt::SolidPattern ); } } // plotting of atomic arrangement in the initial configuration prev_layer = -1; x0 = y0 = x1 = y1 = 0; // need to construct the neighbor list in the relaxed configuration if (plotType == PLOT_ATOM_NEIGHBORS) { if (AtomPos == UNRELAXED && NeighListInit.data == NULL) InitNeighborList(this, NeighListInit, numNeighInit); if ((AtomPos == RELAXED || AtomPos == COMPOSITE) && NeighListRel.data == NULL) RelNeighborList(this, rcut, NeighListRel, numNeighRel); if (AtomPos == UNRELAXED) { nmax = -1; for (at=1; at<=NInit; at++) { n = numNeighInit(at); if (n > nmax) nmax = n; } colormap(nmax+1, cmap); } if (AtomPos == RELAXED) { nmax = -1; for (at=1; at<=NRel; at++) { n = numNeighRel(at); if (n > nmax) nmax = n; } colormap(nmax+1, cmap); } } if (plotType == PLOT_ATOM_TYPES) { nmax = -1; for (at=1; at<=NInit; at++) { n = atomType(at); if (n > nmax) nmax = n; } colormap(nmax, cmap); } // // Plot the atomic configuration such that the atoms in the front (in the top layer) are plotted // at the end. // for (i=1; i<=NInit; i++) { at = aorder(i); if (!zLayerSel(zLayer(at))) continue; layer = zLayer(at); circDia = zDiamLayer(layer); switch(plotType) { case PLOT_ATOM_LAYERS: layer = zLayer(at); if (!paintEPS && layer != prev_layer) { pen->setColor(zColorLayer(layer, 1)); pen->setWidth(zLineThickLayer(layer)); p->setPen(*pen); brush->setColor(zColorLayer(layer, 2)); brush->setStyle(Qt::SolidPattern); p->setBrush(*brush); } break; case PLOT_ATOM_TYPES: lay = layer; layer = atomType(at); if (!paintEPS && layer != prev_layer) { pen->setColor(Qt::black); pen->setWidth(zLineThickLayer(lay)); p->setPen(*pen); if (layer == 0) { brush->setColor(Qt::lightGray); } else { brush->setColor(cmap[layer-1]); } brush->setStyle(Qt::SolidPattern); p->setBrush(*brush); } break; case PLOT_ATOM_NEIGHBORS: lay = layer; if (AtomPos == UNRELAXED) layer = numNeighInit(at); else if (AtomPos == RELAXED || AtomPos == COMPOSITE) layer = numNeighRel(at); if (!paintEPS && layer != prev_layer) { pen->setColor(Qt::black); pen->setWidth(zLineThickLayer(lay)); p->setPen(*pen); if (layer == 0) brush->setColor(Qt::lightGray); else { brush->setColor(QColor(cmap[layer])); } brush->setStyle(Qt::SolidPattern); p->setBrush(*brush); } break; } if (layer != prev_layer) prev_layer = layer; switch(AtomPos) { case UNRELAXED: x = ZFact*xyzInit(at,1) - xPan - (ZFact-1)*xyzCen(1); y = ZFact*xyzInit(at,2) - yPan - (ZFact-1)*xyzCen(2); DrawAtom(p, at, x, y, circDia); break; case RELAXED: x = ZFact*(xyzInit(at,1) + AtomDispScale*aDisp(at,1)) - xPan - (ZFact-1)*xyzCen(1); y = ZFact*(xyzInit(at,2) + AtomDispScale*aDisp(at,2)) - yPan - (ZFact-1)*xyzCen(2); DrawAtom(p, at, x, y, circDia); break; case COMPOSITE: if (!paintEPS) { p->setBrush( *brush_unrld ); } x = ZFact*xyzInit(at,1) - xPan - (ZFact-1)*xyzCen(1); y = ZFact*xyzInit(at,2) - yPan - (ZFact-1)*xyzCen(2); DrawAtom(p, -1, x, y, circDia); if (!paintEPS) { p->setBrush( *brush ); } x = ZFact*(xyzInit(at,1) + AtomDispScale*aDisp(at,1)) - xPan - (ZFact-1)*xyzCen(1); y = ZFact*(xyzInit(at,2) + AtomDispScale*aDisp(at,2)) - yPan - (ZFact-1)*xyzCen(2); DrawAtom(p, at, x, y, circDia); break; } if (x < x0) x0 = x; if (x > x1) x1 = x; if (y < y0) y0 = y; if (y > y1) y1 = y; // atom numbers if (AtomNumbers) { txt.sprintf("%d", at); shift = circDia/(2.0*factor); DrawText(p, x+shift, y+shift, txt); } } // plot the inert atoms if (InertAtoms) { if (!paintEPS) { pen->setColor(Qt::black); pen->setWidth(zLineThickLayer(layer)); p->setPen(*pen); brush->setColor(Qt::black); brush->setStyle(Qt::NoBrush); p->setBrush( *brush ); } for (at=1; at<=NInert; at++) { // plot only those atoms which belong to the selected (active) layers // if (!zLayerSel(zLayer(n))) // continue; x = ZFact*xyzInert(at,1) - xPan - (ZFact-1)*xyzCen(1); y = ZFact*xyzInert(at,2) - yPan - (ZFact-1)*xyzCen(2); DrawAtom(p, 0, x, y, circDia); } } // highlight the atoms picked if (!paintEPS && napicked > 0) { pen->setColor(Qt::green); pen->setWidth(2); p->setPen(*pen); brush->setStyle(Qt::NoBrush); p->setBrush(*brush); dum = ATOM_3DSPHERE; ATOM_3DSPHERE = false; for (n=1; n<=napicked; n++) { at = apicked(n); x = ZFact*xyzInit(at,1) - xPan - (ZFact-1)*xyzCen(1); y = ZFact*xyzInit(at,2) - yPan - (ZFact-1)*xyzCen(2); DrawAtom(p, at, x, y, circDia+4); if (n > 1) DrawLine(p, xprev, yprev, x, y); xprev = x; yprev = y; } ATOM_3DSPHERE = dum; } // highlight the atoms in selected chains if (!paintEPS && nchain > 0) { pen->setColor(Qt::green); pen->setWidth(2); p->setPen(*pen); for (ichain=1; ichain<=nchain; ichain++) { for (i=1; i<=nachain(ichain); i++) { a = achain(ichain,i); x = ZFact*xyzInit(a,1) - xPan - (ZFact-1)*xyzCen(1); y = ZFact*xyzInit(a,2) - yPan - (ZFact-1)*xyzCen(2); if (i>1) DrawLine(p, x0, y0, x, y); x0 = x; y0 = y; } } if (!paintEPS && nchain >= 2) { QPen *pen2 = new QPen(); pen2->setColor(Qt::green); pen2->setStyle(Qt::DashLine); p->setPen(*pen2); for (i=1; i<nchain; i+=2) { x1 = ZFact*dposchain(i,1) - xPan - (ZFact-1)*xyzCen(1); y1 = ZFact*dposchain(i,2) - yPan - (ZFact-1)*xyzCen(2); x2 = ZFact*dposchain(i+1,1) - xPan - (ZFact-1)*xyzCen(1); y2 = ZFact*dposchain(i+1,2) - yPan - (ZFact-1)*xyzCen(2); DrawLine(p, x1, y1, x2, y2); } } } // plotting the coordinate system centered at the initial position of // the dislocation line if (PlaneTraces) DrawPlaneTraces(p, x0, y0, x1, y1); // plotting of arrows if (arrNeighNum > 0) { if (!paintEPS) { pen->setColor(Qt::black); pen->setWidth(thicknessArrow); p->setPen(*pen); p->setBrush(Qt::black); } switch(DispComponent) { case EDGE: plotEdgeComponent(p); break; case SCREW: plotScrewComponent(p); break; case PROJ: plotScrewComponent(p); // plotted the same way as screw components break; case DIFF_EDGE: case DIFF_SCREW: plotDifference(p); break; } } // position of dislocation center if (DisloCenter) { DrawLine(p, xCore, y0, xCore, y1); DrawLine(p, x0, yCore, x1, yCore); } // small inset to show the active Z-layers if (!paintEPS && showZLayers) ShowActiveZLayers(p); // show color map if (!paintEPS && (plotType == PLOT_ATOM_TYPES || plotType == PLOT_ATOM_NEIGHBORS)) ShowColorMap(p); // lines showing the division of the block into cells (for the linked neighbor list) if (showNeighCells) { if (!paintEPS) { pen->setColor(Qt::black); p->setPen(*pen); } for (i=0; i<=ncell(1); i++) { x = ZFact*(xyzMin(1)+i*cellsize(1)) - xPan - (ZFact-1)*xyzCen(1); y0 = ZFact*xyzMin(2) - yPan - (ZFact-1)*xyzCen(2); y1 = ZFact*xyzMax(2) - yPan - (ZFact-1)*xyzCen(2); DrawLine(p, x, y0, x, y1); for (j=0; j<=ncell(2); j++) { y = ZFact*(xyzMin(2)+j*cellsize(2)) - yPan - (ZFact-1)*xyzCen(2); x0 = ZFact*xyzMin(1) - xPan - (ZFact-1)*xyzCen(1); x1 = ZFact*xyzMax(1) - xPan - (ZFact-1)*xyzCen(1); DrawLine(p, x0, y, x1, y); } } } // coordinate system of the block if (!paintEPS && showCSys) ShowCSys(p); // show the polygon that encompasses the dislocation center if (!paintEPS && ndpoly > 0) { pen->setColor(Qt::green); p->setPen(*pen); for (n=1; n<=ndpoly; n++) { x1 = ZFact*dpoly(n,1) - xPan - (ZFact-1)*xyzCen(1); y1 = ZFact*dpoly(n,2) - yPan - (ZFact-1)*xyzCen(2); if (n<ndpoly) { x2 = ZFact*dpoly(n+1,1) - xPan - (ZFact-1)*xyzCen(1); y2 = ZFact*dpoly(n+1,2) - yPan - (ZFact-1)*xyzCen(2); } else { x2 = ZFact*dpoly(1,1) - xPan - (ZFact-1)*xyzCen(1); y2 = ZFact*dpoly(1,2) - yPan - (ZFact-1)*xyzCen(2); } DrawLine(p, x1, y1, x2, y2); } } if (!paintEPS && ndpath > 0) { pen->setColor(Qt::green); p->setPen(*pen); brush->setColor(Qt::green); brush->setStyle(Qt::NoBrush); p->setBrush(*brush); for (n=1; n<ndpath; n++) { x1 = ZFact*dpath(n,1) - xPan - (ZFact-1)*xyzCen(1); y1 = ZFact*dpath(n,2) - yPan - (ZFact-1)*xyzCen(2); x2 = ZFact*dpath(n+1,1) - xPan - (ZFact-1)*xyzCen(1); y2 = ZFact*dpath(n+1,2) - yPan - (ZFact-1)*xyzCen(2); DrawLine(p, x1, y1, x2, y2); if (n==1) { xyWorldToScreen(x1, y1, xs, ys); xs -= 2; ys -= 2; p->drawEllipse(xs, ys, 4, 4); } xyWorldToScreen(x2, y2, xs, ys); xs -= 2; ys -= 2; p->drawEllipse(xs, ys, 4, 4); } } }