本文整理汇总了C++中CLPoint::getX方法的典型用法代码示例。如果您正苦于以下问题:C++ CLPoint::getX方法的具体用法?C++ CLPoint::getX怎么用?C++ CLPoint::getX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CLPoint
的用法示例。
在下文中一共展示了CLPoint::getX方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: borderProjection
CLPoint CCopasiSpringLayout::borderProjection(CLGraphicalObject* go, const CLPoint & p, double d)
{
CLPoint center = go->getBoundingBox().getCenter();
CLPoint diff = p - center;
CLPoint ret;
if (fabs(diff.getX()) * (fabs(go->getHeight()) * 0.5 + d) > fabs(diff.getY()) * (fabs(go->getWidth()) * 0.5 + d))
{
double f = (fabs(go->getWidth()) * 0.5 + d) / fabs(diff.getX());
ret = center + diff * f;
}
else
{
double f = (fabs(go->getHeight()) * 0.5 + d) / fabs(diff.getY());
ret = center + diff * f;
}
return ret;
}
示例2: updateScrollbars
void CQGLViewport::updateScrollbars()
{
// reset the scollbar range
// TODO check te setting for the scroll range since there seem to be some
// error messages
// disconnect the scrollbar listeners and handle the update so that the GL
// window is only redrawn once
double zoom = this->mpNetworkPainter->getZoomFactor();
CLPoint max = this->mpNetworkPainter->getGraphMax();
CLPoint min = this->mpNetworkPainter->getGraphMin();
double graphWidth = (max.getX() - min.getX()) * zoom;
double graphHeight = (max.getY() - min.getY()) * zoom;
double rectangleHeight = this->contentsRect().height();
double rectangleWidth = this->contentsRect().width();
if (graphHeight < rectangleHeight)
{
this->mpVerticalScrollbar->hide();
this->mpVerticalScrollbar->setValue(0);
}
else
{
this->mpVerticalScrollbar->setPageStep(rectangleHeight);
this->mpVerticalScrollbar->setRange(0, (unsigned int)(graphHeight - rectangleHeight));
this->mpVerticalScrollbar->show();
this->mpNetworkPainter->update();
}
if (graphWidth < rectangleWidth)
{
this->mpHorizontalScrollbar->hide();
this->mpHorizontalScrollbar->setValue(0);
}
else
{
this->mpHorizontalScrollbar->setPageStep(rectangleWidth);
this->mpHorizontalScrollbar->setRange(0, (unsigned int)(graphWidth - rectangleWidth));
this->mpHorizontalScrollbar->show();
this->mpNetworkPainter->update();
}
}
示例3: finalizeState
void CCopasiSpringLayout::finalizeState()
{
unsigned int i;
//update the positions of the dependent glyphs
//this can be done here since we assume that those glyphs
//do not affect the layout.
std::vector<CoordinateRelation>::const_iterator it, itEnd = mFixedRelations.end();
for (it = mFixedRelations.begin(); it != itEnd; ++it)
it->target->setPosition(it->source->getPosition() + it->diff);
//for now, only create curves for the reaction glyphs
for (i = 0; i < mpLayout->getListOfReactionGlyphs().size() ; ++i)
{
CLReactionGlyph* pRG = mpLayout->getListOfReactionGlyphs()[i];
//Determine the average position of substrates and products, giving less weight to side reactants
CLPoint s, p;
double s_c = 0; double p_c = 0;
unsigned int j, jmax = pRG->getListOfMetabReferenceGlyphs().size();
for (j = 0; j < jmax; ++j)
{
if (pRG->getListOfMetabReferenceGlyphs()[j]->getRole() == CLMetabReferenceGlyph::SUBSTRATE)
{
s_c += 1.0;
s = s + pRG->getListOfMetabReferenceGlyphs()[j]->getMetabGlyph()->getBoundingBox().getCenter();
}
if (pRG->getListOfMetabReferenceGlyphs()[j]->getRole() == CLMetabReferenceGlyph::SIDESUBSTRATE)
{
s_c += 0.1;
s = s + pRG->getListOfMetabReferenceGlyphs()[j]->getMetabGlyph()->getBoundingBox().getCenter() * 0.1;
}
if (pRG->getListOfMetabReferenceGlyphs()[j]->getRole() == CLMetabReferenceGlyph::PRODUCT)
{
p_c += 1.0;
p = p + pRG->getListOfMetabReferenceGlyphs()[j]->getMetabGlyph()->getBoundingBox().getCenter();
}
if (pRG->getListOfMetabReferenceGlyphs()[j]->getRole() == CLMetabReferenceGlyph::SIDEPRODUCT)
{
p_c += 0.1;
p = p + pRG->getListOfMetabReferenceGlyphs()[j]->getMetabGlyph()->getBoundingBox().getCenter() * 0.1;
}
}
if (s_c > 0)
s = s * (1 / s_c);
else
s = pRG->getPosition();
if (p_c > 0)
p = p * (1 / p_c);
else
p = pRG->getPosition();
CLPoint dir = p - s; //overall direction of reaction
if (dir.getX() == 0 && dir.getY() == 0)
dir = CLPoint(1, 0);
CLPoint ortho_dir = CLPoint(dir.getY(), -dir.getX());
ortho_dir.scale(1 / sqrt(pow(ortho_dir.getX(), 2) + pow(ortho_dir.getY(), 2)));
CLPoint reaction_s = pRG->getPosition() - (dir * 0.05);
CLPoint reaction_p = pRG->getPosition() + (dir * 0.05);
CLPoint reaction_m1 = pRG->getPosition() + ortho_dir * 10;
CLPoint reaction_m2 = pRG->getPosition() - ortho_dir * 10;
pRG->getCurve().clear();
pRG->getCurve().addCurveSegment(CLLineSegment(reaction_s, reaction_p));
for (j = 0; j < jmax; ++j)
{
//here we need to generate the curves for the MetabReferenceGlyphs.
//we will need to consider the size of the glyphs, role of the metab in the reaction, etc.
//For now, only a primitive implementation: TODO: improve
CLMetabReferenceGlyph* pMRG = pRG->getListOfMetabReferenceGlyphs()[j];
double direction;
double modifierLength = -0.2;
switch (pMRG->getRole())
{
case CLMetabReferenceGlyph::SUBSTRATE :
case CLMetabReferenceGlyph::SIDESUBSTRATE :
{
direction = -0.1;
CLPoint metabPoint = borderProjection(pMRG->getMetabGlyph(), reaction_s + dir * direction /*(modifierLength * 1.5)*/, 5);
pMRG->getCurve().clear();
pMRG->getCurve().addCurveSegment(CLLineSegment(reaction_s,
metabPoint,
reaction_s + dir * direction,
(reaction_s + dir * (direction * 1.5) + metabPoint) * 0.5));
}
break;
case CLMetabReferenceGlyph::PRODUCT :
//.........这里部分代码省略.........
示例4: slotHValueChanged
void CQGLViewport::slotHValueChanged(int value)
{
CLPoint p = this->mpNetworkPainter->getGraphMin();
double zoom = this->mpNetworkPainter->getZoomFactor();
this->mpNetworkPainter->setCurrentPositionX((double)(p.getX() + value / zoom));
}
示例5: finalizeState
void CCopasiSpringLayout::finalizeState()
{
unsigned int i;
//update the positions of the dependent glyphs
//this can be done here since we assume that those glyphs
//do not affect the layout.
updateFixedRelations();
//for now, only create curves for the reaction glyphs
for (i = 0; i < mpLayout->getListOfReactionGlyphs().size() ; ++i)
{
CLReactionGlyph* pRG = &mpLayout->getListOfReactionGlyphs()[i];
//Determine the average position of substrates and products, giving less weight to side reactants
CLPoint s, p;
double s_c = 0; double p_c = 0;
unsigned int j, jmax = pRG->getListOfMetabReferenceGlyphs().size();
for (j = 0; j < jmax; ++j)
{
if (pRG->getListOfMetabReferenceGlyphs()[j].getFunctionalRole() == CLMetabReferenceGlyph::SUBSTRATE)
{
CLMetabGlyph* metabGlyph = pRG->getListOfMetabReferenceGlyphs()[j].getMetabGlyph();
if (metabGlyph != NULL)
{
s_c += 1.0;
s = s + metabGlyph->getBoundingBox().getCenter();
}
}
if (pRG->getListOfMetabReferenceGlyphs()[j].getFunctionalRole() == CLMetabReferenceGlyph::SIDESUBSTRATE)
{
CLMetabGlyph* metabGlyph = pRG->getListOfMetabReferenceGlyphs()[j].getMetabGlyph();
if (metabGlyph != NULL)
{
s_c += 0.1;
s = s + metabGlyph->getBoundingBox().getCenter() * 0.1;
}
}
if (pRG->getListOfMetabReferenceGlyphs()[j].getFunctionalRole() == CLMetabReferenceGlyph::PRODUCT)
{
CLMetabGlyph* metabGlyph = pRG->getListOfMetabReferenceGlyphs()[j].getMetabGlyph();
if (metabGlyph != NULL)
{
p_c += 1.0;
p = p + metabGlyph->getBoundingBox().getCenter();
}
}
if (pRG->getListOfMetabReferenceGlyphs()[j].getFunctionalRole() == CLMetabReferenceGlyph::SIDEPRODUCT)
{
CLMetabGlyph* metabGlyph = pRG->getListOfMetabReferenceGlyphs()[j].getMetabGlyph();
if (metabGlyph != NULL)
{
p_c += 0.1;
p = p + metabGlyph->getBoundingBox().getCenter() * 0.1;
}
}
}
CLPoint position = pRG->getPosition();
if (position.getX() == 0 && position.getY() == 0
&& pRG->getDimensions().getWidth() == 0
&& pRG->getDimensions().getHeight() == 0
&& pRG->getCurve().getNumCurveSegments() > 0)
{
position = pRG->getCurve().getCurveSegments()[0].getStart();
pRG->setPosition(position);
}
if (s_c > 0)
s = s * (1 / s_c);
else
{
s = position;
}
if (p_c > 0)
p = p * (1 / p_c);
else
p = position;
CLPoint dir = p - s; //overall direction of reaction
if (dir.getX() == 0 && dir.getY() == 0)
dir = CLPoint(1, 0);
CLPoint ortho_dir = CLPoint(dir.getY(), -dir.getX());
ortho_dir.scale(1 / sqrt(pow(ortho_dir.getX(), 2) + pow(ortho_dir.getY(), 2)));
CLPoint reaction_s = position - (dir * 0.05);
CLPoint reaction_p = position + (dir * 0.05);
//.........这里部分代码省略.........