Example #1
0
int DemoCmdsGate::getDimensions(long mgView, 
                                mgvector<float>& vars, mgvector<char>& types)
{
    int n = vars.count() < types.count() ? vars.count() : types.count();
    return DemoCmdsImpl::getDimensions(toView(mgView), 
        vars.address(), types.address(), n);
}
Example #2
0
/*!
 * \brief Create new view item if it doesn't exist or existent one
 *
 * \param[in] ipSchemaName - Schema name
 * \param[in] ipViewName - View name
 * \param[in] ipMenu - Context menu for new item
 * \param[in] ipPos - Position of new item
 *
 * \return Existent or new view item
 */
ViewItem *
GraphicsScene::newViewItem(const QString &ipSchemaName, const QString &ipViewName, QMenu *ipMenu, const QPoint &ipPos)
{
    DbObjectItem *newItem = findItem(ipSchemaName, ipViewName);

    // if item is currently not on scene
    if (!toView(newItem)) {
        newItem = 0;
        // try to find it in registered items
        QSet<DbObjectItem*>::const_iterator iter = mDbItems.constBegin();

        while (0 == newItem && iter != mDbItems.constEnd()) {
            if (ipViewName == (*iter)->name() && ipSchemaName == (*iter)->schemaName()) {
                newItem = *iter;
            }
            ++iter;
        }

        // if found - just move to the given position (if position is correct)
        if (newItem) {
            if (ipPos.x() > 0 && ipPos.y() > 0) {
                newItem->setX(ipPos.x());
                newItem->setY(ipPos.y());
                newItem->adjustSize();
            }
        // if not found
        } else {
            // create new view
            newItem = new ViewItem(ipSchemaName, ipViewName, ipMenu, ipPos);
            // register this item
            mDbItems.insert(newItem);
        }
    }

    return toView(newItem);
}
Example #3
0
void AxisBase::drawAxisData(QPainter &p)
{
    PlotterBase *plotter = (PlotterBase*)parent();
    QRect rect(plotter->contentsRect());

    double start = m_min;
    double end = m_max;

    int p_start, p_end;
    calculatePoints(p_start, p_end);

    switch (m_orient)
    {
        case Qt::Vertical:
        {
            p.setPen(m_pen);
            p.drawLine(m_offset+2, p_start, m_offset+2, p_end);

            if (m_minor > 1e-100)
            {
                int prevTick = INT_MAX/2;

                for (double i = start; i <= end; i += m_minor)
                {
                    int p_d = toView(i);

                    if (p_d < prevTick-1)
                    {
                        prevTick = p_d;
                        p.setPen(m_minorPen);
                        p.drawLine(m_offset+1, p_d, m_offset+3, p_d);

                        if (m_minorGridPen != Qt::NoPen)
                        {
                            p.setPen(m_minorGridPen);
                            p.drawLine(m_offset+2, p_d, rect.right(), p_d);
                        }
                    }
                }
            }

            if (m_major > 1e-100)
            {
                QRect prevRect;
                int prevTick = INT_MAX/2;

                for (double i = start; i <= end; i += m_major)
                {
                    int p_d = toView(i);

                    if (p_d < prevTick-1)
                    {
                        prevTick = p_d;
                        p.setPen(m_majorPen);
                        p.drawLine(m_offset+0, p_d, m_offset+4, p_d);

                        if (m_majorGridPen != Qt::NoPen)
                        {
                            p.setPen(m_majorGridPen);
                            p.drawLine(m_offset+2, p_d, rect.right(), p_d);
                        }
                    }

                    QString text(QString::number(i));
                    QFontMetrics fm(m_font);
                    QRect textRect(fm.boundingRect(text));

                    int h = textRect.height();
                    QRect drawRect(0, p_d - h/2, m_offset, h);

                    // skip paining the text
                    if (prevRect.isValid() && prevRect.intersects(drawRect))
                        continue;
                    prevRect = drawRect;

                    p.setPen(QPen(m_textColor));
                    p.drawText(drawRect, Qt::AlignRight | Qt::AlignVCenter, text);
                }
            }

            break;
        }

        case Qt::Horizontal:
        {
            p.setPen(m_pen);
            p.drawLine(p_start, rect.height()-m_offset, p_end, rect.height()-m_offset);

            if (m_minor > 1e-100)
            {
                int prevTick = -INT_MAX;

                for (double i = start; i <= end; i += m_minor)
                {
                    int p_d = toView(i);

                    if (p_d > prevTick+1)
                    {
                        prevTick = p_d;
                        p.setPen(m_minorPen);
                        p.drawLine(p_d, rect.height()-m_offset+1, p_d, rect.height()-m_offset+3);

                        if (m_minorGridPen != Qt::NoPen)
                        {
                            p.setPen(m_minorGridPen);
                            p.drawLine(p_d, rect.top(), p_d, rect.height()-m_offset);
                        }
                    }
                }
            }

            if (m_major > 1e-100)
            {
                QRect prevRect;
                int prevTick = -INT_MAX;

                for (double i = start; i <= end; i += m_major)
                {
                    int p_d = toView(i);

                    if (p_d > prevTick+1)
                    {
                        prevTick = p_d;
                        p.setPen(m_majorPen);
                        p.drawLine(p_d, rect.height()-m_offset+0, p_d, rect.height()-m_offset+4);

                        if (m_majorGridPen != Qt::NoPen)
                        {
                            p.setPen(m_majorGridPen);
                            p.drawLine(p_d, rect.top(), p_d, rect.height()-m_offset);
                        }
                    }

                    QString text(QString::number(i));
                    QFontMetrics fm(m_font);
                    QRect textRect(fm.boundingRect(text));

                    int w = textRect.width();
                    QRect drawRect(p_d - w/2, rect.height()-m_offset+3, w, m_offset);

                    // skip paining the text
                    if (prevRect.isValid() && prevRect.intersects(drawRect))
                        continue;
                    prevRect = drawRect;

                    p.setPen(QPen(m_textColor));
                    p.drawText(drawRect, Qt::AlignCenter, text);
                }
            }

            break;

        }
    }
}
Example #4
0
int DemoCmdsGate::registerCmds(long mgView)
{
    return DemoCmdsImpl::registerCmds(toView(mgView));
}