本文整理汇总了C++中CLayout::setDimensions方法的典型用法代码示例。如果您正苦于以下问题:C++ CLayout::setDimensions方法的具体用法?C++ CLayout::setDimensions怎么用?C++ CLayout::setDimensions使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CLayout
的用法示例。
在下文中一共展示了CLayout::setDimensions方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createLayout
CLayout* CCopasiSpringLayout::createLayout(
CDataContainer *parent,
const std::set<const CCompartment*>& compartments,
const std::set<const CReaction*>& reactions,
const std::set<const CMetab*>& metabs,
const std::set<const CMetab*>& sideMetabs,
Parameters* mParams
)
{
CLayout *pResult = new CLayout("Layout", parent);
double fontSize = 16.0;
double fontHeight = fontSize * 1.5;
// create a species glyph for each species in metabs
std::map<const CCompartment*, CompartmentInfo> compInfo;
std::map<const CMetab*, CLMetabGlyph*> metabMap;
std::set<const CMetab*>::const_iterator metabIt;
for (metabIt = metabs.begin(); metabIt != metabs.end(); ++metabIt)
{
if (sideMetabs.find(*metabIt) != sideMetabs.end())
continue;
//estimate the size of the glyph
double width = (double)((*metabIt)->getObjectName().length() * fontSize);
double height = (double)fontHeight;
if (width < height)
{
width = height;
}
//create the glyph
CLMetabGlyph* pMetabGlyph = new CLMetabGlyph;
pMetabGlyph->setDimensions(CLDimensions(width + 4, height + 4));
pMetabGlyph->setModelObjectKey((*metabIt)->getKey());
pResult->addMetaboliteGlyph(pMetabGlyph);
metabMap[*metabIt] = pMetabGlyph;
//create the text glyph for the label
CLTextGlyph* pTextGlyph = new CLTextGlyph;
pTextGlyph->setDimensions(CLDimensions(width, height));
pTextGlyph->setGraphicalObjectKey(pMetabGlyph->getKey());
pTextGlyph->setModelObjectKey((*metabIt)->getKey());
pResult->addTextGlyph(pTextGlyph);
//add up the sizes for the compartment
const CCompartment* pComp = NULL;
if (compartments.find((*metabIt)->getCompartment()) != compartments.end())
pComp = (*metabIt)->getCompartment();
compInfo[pComp].add((width + 4) * (height + 4));
}
//now the reaction glyphs
std::set<const CReaction*>::const_iterator reactIt;
for (reactIt = reactions.begin(); reactIt != reactions.end(); ++reactIt)
{
CLReactionGlyph* pReactionGlyph = new CLReactionGlyph;
//pResult->setDimensions(CLDimensions(width, height));
pReactionGlyph->setModelObjectKey((*reactIt)->getKey());
//pReactionGlyph->getCurve().addCurveSegment(CLLineSegment(CLPoint(x, y),
// CLPoint(x + length, y)));
bool isReversible = (*reactIt)->isReversible();
pResult->addReactionGlyph(pReactionGlyph);
//now add the species reference glyphs.
//substrates
const CDataVector < CChemEqElement >& substrates = (*reactIt)->getChemEq().getSubstrates();
bool substrateExists = false;
CDataVector<CChemEqElement>::const_iterator elIt;
for (elIt = substrates.begin(); elIt != substrates.end(); ++elIt)
{
const CMetab* pMetab = elIt->getMetabolite();
if (!pMetab)
continue;
CLMetabGlyph* pMetabGlyph = NULL;
CLMetabReferenceGlyph::Role role; // = CLMetabReferenceGlyph::SUBSTRATE;
CLMetabReferenceGlyph::Role functionalRole;
//is it a side reactant? If yes, create a new metab glyph
if (sideMetabs.find(pMetab) != sideMetabs.end())
{
//estimate the size of the glyph
double width = (double)((pMetab)->getObjectName().length() * fontSize);
double height = (double)fontHeight;
if (width < height)
{
//.........这里部分代码省略.........