Esempio n. 1
0
void QwtPolarPlot::updateScale( int scaleId )
{
  if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount )
    return;

  ScaleData &d = d_data->scaleData[scaleId];

  double minValue = d.minValue;
  double maxValue = d.maxValue;
  double stepSize = d.stepSize;

  if ( scaleId == QwtPolar::ScaleRadius && d.doAutoScale )
  {
    QwtDoubleInterval interval;

    const QwtPolarItemList& itmList = itemList();
    for ( QwtPolarItemIterator it = itmList.begin();
          it != itmList.end(); ++it )
    {
      const QwtPolarItem *item = *it;
      if ( item->testItemAttribute( QwtPolarItem::AutoScale ) )
        interval |= item->boundingInterval( scaleId );
    }

    minValue = interval.minValue();
    maxValue = interval.maxValue();

    d.scaleEngine->autoScale( d.maxMajor,
                              minValue, maxValue, stepSize );
    d.scaleDiv.invalidate();
  }

  if ( !d.scaleDiv.isValid() )
  {
    d.scaleDiv = d.scaleEngine->divideScale(
                   minValue, maxValue,
                   d.maxMajor, d.maxMinor, stepSize );
  }

  const QwtDoubleInterval interval = visibleInterval();

  const QwtPolarItemList& itmList = itemList();
  for ( QwtPolarItemIterator it = itmList.begin();
        it != itmList.end(); ++it )
  {
    QwtPolarItem *item = *it;
    item->updateScaleDiv( *scaleDiv( QwtPolar::Azimuth ),
                          *scaleDiv( QwtPolar::Radius ), interval );
  }
}
Esempio n. 2
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RiuSummaryQwtPlot::selectClosestCurve(const QPoint& pos)
{
    QwtPlotCurve* closestCurve = NULL;
    double distMin = DBL_MAX;

    const QwtPlotItemList& itmList = itemList();
    for(QwtPlotItemIterator it = itmList.begin(); it != itmList.end(); it++)
    {
        if((*it)->rtti() == QwtPlotItem::Rtti_PlotCurve)
        {
            QwtPlotCurve* candidateCurve = static_cast<QwtPlotCurve*>(*it);
            double dist = DBL_MAX;
            candidateCurve->closestPoint(pos, &dist);
            if(dist < distMin)
            {
                closestCurve = candidateCurve;
                distMin = dist;
            }
        }
    }

    if(closestCurve && distMin < 20)
    {
        RimSummaryCurve* selectedCurve = m_plotDefinition->findRimCurveFromQwtCurve(closestCurve);
        if(selectedCurve)
        {
            RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(selectedCurve);
        }
    }
}
Esempio n. 3
0
/*!
  \brief Calculate the canvas margins

  \param maps QwtPlot::axisCnt maps, mapping between plot and paint device coordinates
  \param canvasRect Bounding rectangle where to paint
  \param left Return parameter for the left margin
  \param top Return parameter for the top margin
  \param right Return parameter for the right margin
  \param bottom Return parameter for the bottom margin

  Plot items might indicate, that they need some extra space
  at the borders of the canvas by the QwtPlotItem::Margins flag.

  updateCanvasMargins(), QwtPlotItem::getCanvasMarginHint()
 */
void QwtPlot::getCanvasMarginsHint(
    const QwtScaleMap maps[], const QRectF &canvasRect,
    double &left, double &top, double &right, double &bottom) const
{
    left = top = right = bottom = -1.0;

    const QwtPlotItemList& itmList = itemList();
    for ( QwtPlotItemIterator it = itmList.begin();
        it != itmList.end(); ++it )
    {
        const QwtPlotItem *item = *it;
        if ( item->testItemAttribute( QwtPlotItem::Margins ) )
        {
            double m[ QwtPlot::axisCnt ];
            item->getCanvasMarginHint(
                maps[ item->xAxis() ], maps[ item->yAxis() ],
                canvasRect, m[yLeft], m[xTop], m[yRight], m[xBottom] );

            left = qMax( left, m[yLeft] );
            top = qMax( top, m[xTop] );
            right = qMax( right, m[yRight] );
            bottom = qMax( bottom, m[xBottom] );
        }
    }
}
Esempio n. 4
0
void QwtPlot::drawItems( QPainter *painter, const QRectF &canvasRect,
        const QwtScaleMap maps[axisCnt] ) const
{
    const QwtPlotItemList& itmList = itemList();
    for ( QwtPlotItemIterator it = itmList.begin();
        it != itmList.end(); ++it )
    {
        QwtPlotItem *item = *it;
        if ( item && item->isVisible() )
        {
            painter->save();

            painter->setRenderHint( QPainter::Antialiasing,
                item->testRenderHint( QwtPlotItem::RenderAntialiased ) );
            painter->setRenderHint( QPainter::HighQualityAntialiasing,
                item->testRenderHint( QwtPlotItem::RenderAntialiased ) );

            item->draw( painter,
                maps[item->xAxis()], maps[item->yAxis()],
                canvasRect );

            painter->restore();
        }
    }
}
Esempio n. 5
0
void TVPlot::setMode( int mode )
{
    QwtPlotItemList items = itemList( QwtPlotItem::Rtti_PlotHistogram );

    for ( int i = 0; i < items.size(); i++ )
    {
        QwtPlotHistogram *histogram = static_cast<QwtPlotHistogram *>( items[i] );
        if ( mode < 3 )
        {
            histogram->setStyle( static_cast<QwtPlotHistogram::HistogramStyle>( mode ) );
            histogram->setSymbol( NULL );

            QPen pen( Qt::black, 0 );
            if ( mode == QwtPlotHistogram::Lines )
                pen.setBrush( histogram->brush() );

            histogram->setPen( pen );
        }
        else
        {
            histogram->setStyle( QwtPlotHistogram::Columns );

            QwtColumnSymbol *symbol = new QwtColumnSymbol( QwtColumnSymbol::Box );
            symbol->setFrameStyle( QwtColumnSymbol::Raised );
            symbol->setLineWidth( 2 );
            symbol->setPalette( QPalette( histogram->brush().color() ) );

            histogram->setSymbol( symbol );
        }
    }
}
Esempio n. 6
0
// Select the point at a position.
void XtalOptPlot::select(const QPoint& pos)
{
  QwtPlotMarker* selection = nullptr;

  // Must be within 10 pixels at least
  double dist = 10.0;

  const QwtPlotItemList& itmList = itemList();
  for (QwtPlotItemIterator it = itmList.begin(); it != itmList.end(); ++it) {
    if ((*it)->rtti() == QwtPlotItem::Rtti_PlotMarker) {
      QwtPlotMarker* m = static_cast<QwtPlotMarker*>(*it);
      // We have to map the plot coordinates onto widget coordinates before
      // comparing
      const QwtScaleMap& xMap = canvasMap(m->xAxis());
      const QwtScaleMap& yMap = canvasMap(m->yAxis());
      double mx = xMap.transform(m->xValue());
      double my = yMap.transform(m->yValue());
      double d = distance(QPointF(mx, my), pos);
      if (d < dist) {
        selection = m;
        dist = d;
      }
    }
  }

  selectMarker(selection);
}
Esempio n. 7
0
HistPlot::HistPlot(QWidget *parent):
QwtPlot(parent)
{
	setCanvasBackground(QColor(Qt::black));
	plotLayout()->setAlignCanvasToScales(true);

	//QwtLegend *legend = new QwtLegend;
	//legend->setItemMode(QwtLegend::CheckableItem);
	//insertLegend(legend, QwtPlot::RightLegend);

	//populate();

	//connect(this, SIGNAL(legendChecked(QwtPlotItem *, bool)),
	//	SLOT(showItem(QwtPlotItem *, bool)));

	//replot(); // creating the legend items

	QwtPlotItemList items = itemList(QwtPlotItem::Rtti_PlotHistogram);
	for ( int i = 0; i < items.size(); i++ )
	{
		if ( i == 0 )
		{
			//QwtLegendItem *legendItem = (QwtLegendItem *)legend->find(items[i]);
			//if ( legendItem )
			//	legendItem->setChecked(true);
			items[i]->setVisible(true);
		}
		else
			items[i]->setVisible(false);
	}

	setAutoReplot(true);
}
Esempio n. 8
0
/****************************************************************************
**
** Copyright (C) 2015
**
** This file is part of the Magus toolkit
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
****************************************************************************/

#include "qtbuildermenu.h"
#include "constants.h"
#include "applicationtemplate.h"
#include "utils.h"

//****************************************************************************/
QtMenuBuilder::QtMenuBuilder()
{
}

//****************************************************************************/
QtMenuBuilder::~QtMenuBuilder()
{
}

//****************************************************************************/
QString QtMenuBuilder::createInclude(const QString &s)
{
    // Add the #include
    QString str = s;
    str = str +
    QString("#include <QMenu>") +
    QString("\n");
    return str;
}

//****************************************************************************/
QString QtMenuBuilder::createPrivateMembers(WindowMenuProperties* windowMenuProperties, const QString &s)
{
    QString str = s;
    QString menuItemName;
    QString subMenuItemName;
    WindowMenuItemProperties* item = 0;
    if (windowMenuProperties)
    {
        QVectorIterator<WindowMenuItemProperties*> itemList(windowMenuProperties->mWindowMenuItemPropertiesList);

        // Define private members
        while (itemList.hasNext())
        {
            item = itemList.next();
            menuItemName = Utils::makePrivateAttribute (item->mItemName) + QString("Menu");

            // Define private members
            str = str +
                TAB +
                TAB +
                QString("QMenu* ") +
                menuItemName +
                QString(";") +
                QString("\n");
        }
    }
    return str;
}
Esempio n. 9
0
/*!
  Redraw the canvas items.

  \param painter Painter used for drawing
  \param azimuthMap Maps azimuth values to values related to 0.0, M_2PI
  \param radialMap Maps radius values into painter coordinates.
  \param pole Position of the pole in painter coordinates
  \param radius Radius of the complete plot area in painter coordinates
  \param canvasRect Contents rect of the canvas in painter coordinates
*/
void QwtPolarPlot::drawItems( QPainter *painter,
    const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
    const QPointF &pole, double radius,
    const QRectF &canvasRect ) const
{
    const QRectF pr = plotRect( canvasRect );

    const QwtPolarItemList& itmList = itemList();
    for ( QwtPolarItemIterator it = itmList.begin();
            it != itmList.end(); ++it )
    {
        QwtPolarItem *item = *it;
        if ( item && item->isVisible() )
        {
            painter->save();

            // Unfortunately circular clipping slows down
            // painting a lot. So we better try to avoid it.

            bool doClipping = false;
            if ( item->rtti() != QwtPolarItem::Rtti_PolarGrid )
            {
                const QwtInterval intv =
                    item->boundingInterval( QwtPolar::Radius );

                if ( !intv.isValid() )
                    doClipping = true;
                else
                {
                    if ( radialMap.s1() < radialMap.s2() )
                        doClipping = intv.maxValue() > radialMap.s2();
                    else
                        doClipping = intv.minValue() < radialMap.s2();
                }
            }

            if ( doClipping )
            {
                const int margin = item->marginHint();

                const QRectF clipRect = pr.adjusted(
                    -margin, -margin, margin, margin );
                if ( !clipRect.contains( canvasRect ) )
                {
                    QRegion clipRegion( clipRect.toRect(), QRegion::Ellipse );
                    painter->setClipRegion( clipRegion, Qt::IntersectClip );
                }
            }

            painter->setRenderHint( QPainter::Antialiasing,
                item->testRenderHint( QwtPolarItem::RenderAntialiased ) );

            item->draw( painter, azimuthMap, radialMap,
                pole, radius, canvasRect );

            painter->restore();
        }
    }
}
SPItem *Selection::singleItem() {
    std::vector<SPItem*> const items=itemList();
    if ( items.size()==1) {
        return items[0];
    } else {
        return NULL;
    }
}
Esempio n. 11
0
const QwtPlotCurve* Plot::curve( int index ) const
{
    const QwtPlotItemList curves = itemList( QwtPlotItem::Rtti_PlotCurve );
    if ( index >= 0 && index < curves.size() )
        return dynamic_cast<const QwtPlotCurve*>( curves[index] );

    return NULL;
}   
std::vector<XML::Node*> const &Selection::reprList() {
    if (!_reprs.empty()) { return _reprs; }
    std::vector<SPItem*> list = itemList();
    for ( std::vector<SPItem*>::const_iterator iter=list.begin();iter!=list.end(); ++iter) {
        SPObject *obj = *iter;
        _reprs.push_back(obj->getRepr());
    }
    return _reprs;
}
Esempio n. 13
0
QList<QGraphicsItem*> LiveLayerItem::findAllChildItems(const QGraphicsItem *item) const
{
    QList<QGraphicsItem*> itemList(item->childItems());

    foreach (QGraphicsItem *childItem, item->childItems())
        itemList += findAllChildItems(childItem);

    return itemList;
}
Esempio n. 14
0
void matrixofpixels::changeitems()
{
    QwtPlotItemList items = itemList(QwtPlotItem::Rtti_PlotItem);
     for ( int i = 0; i < items.size(); i++ )
     {
         items[i]->detach();
     }
     this->replot();
}
Esempio n. 15
0
/*!
  \brief Insert a legend

  If the position legend is \c QwtPolarPlot::LeftLegend or \c QwtPolarPlot::RightLegend
  the legend will be organized in one column from top to down.
  Otherwise the legend items will be placed in a table
  with a best fit number of columns from left to right.

  If pos != QwtPolarPlot::ExternalLegend the plot widget will become
  parent of the legend. It will be deleted when the plot is deleted,
  or another legend is set with insertLegend().

  \param legend Legend
  \param pos The legend's position. For top/left position the number
             of colums will be limited to 1, otherwise it will be set to
             unlimited.

  \param ratio Ratio between legend and the bounding rect
               of title, canvas and axes. The legend will be shrinked
               if it would need more space than the given ratio.
               The ratio is limited to ]0.0 .. 1.0]. In case of <= 0.0
               it will be reset to the default ratio.
               The default vertical/horizontal ratio is 0.33/0.5.

  \sa legend(), QwtPolarLayout::legendPosition(),
      QwtPolarLayout::setLegendPosition()
*/
void QwtPolarPlot::insertLegend( QwtLegend *legend,
                                 QwtPolarPlot::LegendPosition pos, double ratio )
{
  d_data->layout->setLegendPosition( pos, ratio );
  if ( legend != d_data->legend )
  {
    if ( d_data->legend && d_data->legend->parent() == this )
      delete d_data->legend;

    d_data->legend = legend;

    if ( d_data->legend )
    {
      if ( pos != ExternalLegend )
      {
        if ( d_data->legend->parent() != this )
        {
#if QT_VERSION < 0x040000
          d_data->legend->reparent( this, QPoint( 0, 0 ) );
#else
          d_data->legend->setParent( this );
#endif
        }
      }

      const QwtPolarItemList& itmList = itemList();
      for ( QwtPolarItemIterator it = itmList.begin();
            it != itmList.end(); ++it )
      {
        ( *it )->updateLegend( d_data->legend );
      }

      QLayout *l = d_data->legend->contentsWidget()->layout();
      if ( l && l->inherits( "QwtDynGridLayout" ) )
      {
        QwtDynGridLayout *tl = ( QwtDynGridLayout * )l;
        switch ( d_data->layout->legendPosition() )
        {
          case LeftLegend:
          case RightLegend:
            tl->setMaxCols( 1 ); // 1 column: align vertical
            break;
          case TopLegend:
          case BottomLegend:
            tl->setMaxCols( 0 ); // unlimited
            break;
          case ExternalLegend:
            break;
        }
      }

    }
  }
  updateLayout();
}
Esempio n. 16
0
//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
QPointF RiuSummaryQwtPlot::closestCurvePoint(const QPoint& cursorPosition, QString* valueString, QString* timeString, int* yAxis) const
{
    QPointF samplePoint;

    QwtPlotCurve* closestCurve = nullptr;
    double distMin = DBL_MAX;
    int closestPointSampleIndex = -1;

    const QwtPlotItemList& itmList = itemList();
    for (QwtPlotItemIterator it = itmList.begin(); it != itmList.end(); it++)
    {
        if ((*it)->rtti() == QwtPlotItem::Rtti_PlotCurve)
        {
            QwtPlotCurve* candidateCurve = static_cast<QwtPlotCurve*>(*it);
            double dist = DBL_MAX;
            int candidateSampleIndex = candidateCurve->closestPoint(cursorPosition, &dist);
            if (dist < distMin)
            {
                closestCurve = candidateCurve;
                distMin = dist;
                closestPointSampleIndex = candidateSampleIndex;
            }
        }
    }

    if (closestCurve && distMin < 50)
    {
        samplePoint = closestCurve->sample(closestPointSampleIndex);

        if (yAxis) *yAxis = closestCurve->yAxis();
    }


    if (timeString)
    {
        const QwtScaleDraw* timeAxisScaleDraw = axisScaleDraw(QwtPlot::xBottom);
        if (timeAxisScaleDraw)
        {
            *timeString = timeAxisScaleDraw->label(samplePoint.x()).text();
        }
    }

    if (valueString && closestCurve)
    {
        const QwtScaleDraw* yAxisScaleDraw = axisScaleDraw(closestCurve->yAxis());
        if (yAxisScaleDraw)
        {
            *valueString = yAxisScaleDraw->label(samplePoint.y()).text();
        }
    }

    return samplePoint;
}
Esempio n. 17
0
WebDragData DataObject::toWebDragData() {
  WebDragData data;
  data.initialize();
  data.setModifierKeyState(m_modifiers);
  WebVector<WebDragData::Item> itemList(length());

  for (size_t i = 0; i < length(); ++i) {
    DataObjectItem* originalItem = item(i);
    WebDragData::Item item;
    if (originalItem->kind() == DataObjectItem::StringKind) {
      item.storageType = WebDragData::Item::StorageTypeString;
      item.stringType = originalItem->type();
      item.stringData = originalItem->getAsString();
    } else if (originalItem->kind() == DataObjectItem::FileKind) {
      if (originalItem->sharedBuffer()) {
        item.storageType = WebDragData::Item::StorageTypeBinaryData;
        item.binaryData = originalItem->sharedBuffer();
      } else if (originalItem->isFilename()) {
        Blob* blob = originalItem->getAsFile();
        if (blob->isFile()) {
          File* file = toFile(blob);
          if (file->hasBackingFile()) {
            item.storageType = WebDragData::Item::StorageTypeFilename;
            item.filenameData = file->path();
            item.displayNameData = file->name();
          } else if (!file->fileSystemURL().isEmpty()) {
            item.storageType = WebDragData::Item::StorageTypeFileSystemFile;
            item.fileSystemURL = file->fileSystemURL();
            item.fileSystemFileSize = file->size();
          } else {
            // FIXME: support dragging constructed Files across renderers, see
            // http://crbug.com/394955
            item.storageType = WebDragData::Item::StorageTypeString;
            item.stringType = "text/plain";
            item.stringData = file->name();
          }
        } else {
          ASSERT_NOT_REACHED();
        }
      } else {
        ASSERT_NOT_REACHED();
      }
    } else {
      ASSERT_NOT_REACHED();
    }
    item.title = originalItem->title();
    item.baseURL = originalItem->baseURL();
    itemList[i] = item;
  }
  data.swapItems(itemList);
  return data;
}
Esempio n. 18
0
/**
 * Loads the Item List Box.
 */
void ClassifierListPage::reloadItemListBox()
{
    UMLClassifierListItemList itemList(getItemList());

    // remove any items if present
    m_pItemListLB->clear();

    // add each item in the list to the ListBox and connect each item modified signal
    // to the ListItemModified slot in this class
    foreach (UMLClassifierListItem* listItem, itemList) {
        m_pItemListLB->addItem(listItem->toString(Uml::SignatureType::SigNoVis));
        connect(listItem, SIGNAL(modified()), this, SLOT(slotListItemModified()));
    }
Esempio n. 19
0
/*!
  \brief Insert a legend

  If the position legend is \c QwtPlot::LeftLegend or \c QwtPlot::RightLegend
  the legend will be organized in one column from top to down.
  Otherwise the legend items will be placed in a table
  with a best fit number of columns from left to right.

  If pos != QwtPlot::ExternalLegend the plot widget will become
  parent of the legend. It will be deleted when the plot is deleted,
  or another legend is set with insertLegend().

  \param legend Legend
  \param pos The legend's position. For top/left position the number
             of colums will be limited to 1, otherwise it will be set to
             unlimited.

  \param ratio Ratio between legend and the bounding rect
               of title, canvas and axes. The legend will be shrinked
               if it would need more space than the given ratio.
               The ratio is limited to ]0.0 .. 1.0]. In case of <= 0.0
               it will be reset to the default ratio.
               The default vertical/horizontal ratio is 0.33/0.5.

  \sa legend(), QwtPlotLayout::legendPosition(),
      QwtPlotLayout::setLegendPosition()
*/
void QwtPlot::insertLegend( QwtLegend *legend,
    QwtPlot::LegendPosition pos, double ratio )
{
    d_data->layout->setLegendPosition( pos, ratio );

    if ( legend != d_data->legend )
    {
        if ( d_data->legend && d_data->legend->parent() == this )
            delete d_data->legend;

        d_data->legend = legend;

        if ( d_data->legend )
        {
            if ( pos != ExternalLegend )
            {
                if ( d_data->legend->parent() != this )
                    d_data->legend->setParent( this );
            }

            const QwtPlotItemList& itmList = itemList();
            for ( QwtPlotItemIterator it = itmList.begin();
                it != itmList.end(); ++it )
            {
                ( *it )->updateLegend( d_data->legend );
            }

            QwtDynGridLayout *tl = qobject_cast<QwtDynGridLayout *>(
                d_data->legend->contentsWidget()->layout() );
            if ( tl )
            {
                switch ( d_data->layout->legendPosition() )
                {
                    case LeftLegend:
                    case RightLegend:
                        tl->setMaxCols( 1 ); // 1 column: align vertical
                        break;
                    case TopLegend:
                    case BottomLegend:
                        tl->setMaxCols( 0 ); // unlimited
                        break;
                    case ExternalLegend:
                        break;
                }
            }
        }
        updateTabOrder();
    }

    updateLayout();
}
Esempio n. 20
0
void Plot::setMode( int style )
{
    QwtPlotTradingCurve::SymbolStyle symbolStyle =
        static_cast<QwtPlotTradingCurve::SymbolStyle>( style );

    QwtPlotItemList curves = itemList( QwtPlotItem::Rtti_PlotTradingCurve );
    for ( int i = 0; i < curves.size(); i++ )
    {
        QwtPlotTradingCurve *curve =
            static_cast<QwtPlotTradingCurve *>( curves[i] );
        curve->setSymbolStyle( symbolStyle );
    }

    replot();
}
	CFStringRef SelectorControl::CopyItemNameByIndex(UInt32 inItemIndex) const
	{
		CFStringRef answer = NULL;
		UInt32 numberOfItems = GetNumberItems();
		if (numberOfItems > 0)
		{
			ThrowIf(inItemIndex >= numberOfItems, CAException(kCMIOHardwareIllegalOperationError), "SelectorControl::CopyItemNameByIndex: index out of range");			
			CAAutoArrayDelete<UInt32> itemList(numberOfItems);
			UInt32 size = numberOfItems * sizeof(CMIODeviceID);
			UInt32 dataUsed = 0;
			GetPropertyData(PropertyAddress(kCMIOSelectorControlPropertyAvailableItems),0, NULL, size, dataUsed, itemList);
			answer = CopyItemNameByID(itemList[inItemIndex]);
		}
		return answer;
	}
	UInt32 SelectorControl::GetItemIDForIndex(UInt32 inItemIndex) const
	{
		UInt32 answer = 0xFFFFFFFF;	// Default to the featuring being on
		UInt32 numberOfItems = GetNumberItems();
		if (numberOfItems > 0)
		{
			ThrowIf(inItemIndex >= numberOfItems, CAException(kCMIOHardwareIllegalOperationError), "SelectorControl::GetItemIDForIndex: index out of range");			
			CAAutoArrayDelete<UInt32> itemList(numberOfItems);
			UInt32 size = numberOfItems * sizeof(CMIODeviceID);
			UInt32 dataUsed = 0;
			GetPropertyData(PropertyAddress(kCMIOSelectorControlPropertyAvailableItems),0, NULL, size, dataUsed, itemList);
			answer = itemList[inItemIndex];
		}
		return answer;
	}
Esempio n. 23
0
TVPlot::TVPlot( QWidget *parent ):
    QwtPlot( parent )
{
    setTitle( "Watching TV during a weekend" );

    QwtPlotCanvas *canvas = new QwtPlotCanvas();
    canvas->setPalette( Qt::gray );
    canvas->setBorderRadius( 10 );
    setCanvas( canvas );

    plotLayout()->setAlignCanvasToScales( true );

    setAxisTitle( QwtPlot::yLeft, "Number of People" );
    setAxisTitle( QwtPlot::xBottom, "Number of Hours" );

    QwtLegend *legend = new QwtLegend;
    legend->setDefaultItemMode( QwtLegendData::Checkable );
    insertLegend( legend, QwtPlot::RightLegend );

    populate();

    connect( legend, SIGNAL( checked( const QVariant &, bool, int ) ),
        SLOT( showItem( const QVariant &, bool ) ) );

    replot(); // creating the legend items

    QwtPlotItemList items = itemList( QwtPlotItem::Rtti_PlotHistogram );
    for ( int i = 0; i < items.size(); i++ )
    {
        if ( i == 0 )
        {
            const QVariant itemInfo = itemToInfo( items[i] );

            QwtLegendLabel *legendLabel =
                qobject_cast<QwtLegendLabel *>( legend->legendWidget( itemInfo ) );
            if ( legendLabel )
                legendLabel->setChecked( true );

            items[i]->setVisible( true );
        }
        else
        {
            items[i]->setVisible( false );
        }
    }

    setAutoReplot( true );
}
Esempio n. 24
0
QString QuteComboBox::getWidgetLine()
{
#ifdef  USE_WIDGET_MUTEX
	widgetLock.lockForRead();
#endif
	QString line = "ioMenu {" + QString::number(x()) + ", " + QString::number(y()) + "} ";
	line += "{"+ QString::number(width()) +", "+ QString::number(height()) +"} ";
	line += QString::number(((QComboBox *)m_widget)->currentIndex()) + " ";
	line += "303 ";
	line += "\"" + itemList() + "\" ";
	line += m_channel;
#ifdef  USE_WIDGET_MUTEX
	widgetLock.unlock();
#endif
	return line;
}
Esempio n. 25
0
/*!
   \return Maximum of all item margin hints.
   \sa QwtPolarItem::marhinHint()
*/
int QwtPolarPlot::plotMarginHint() const
{
  int margin = 0;
  const QwtPolarItemList& itmList = itemList();
  for ( QwtPolarItemIterator it = itmList.begin();
        it != itmList.end(); ++it )
  {
    QwtPolarItem *item = *it;
    if ( item && item->isVisible() )
    {
      const int hint = item->marginHint();
      if ( hint > margin )
        margin = hint;
    }
  }
  return margin;
}
Esempio n. 26
0
/****************************************************************************
**
** Copyright (C) 2015
**
** This file is part of the Magus toolkit
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
****************************************************************************/

#include "qtbuildermenu.h"
#include "constants.h"
#include "applicationtemplate.h"
#include "utils.h"

//****************************************************************************/
QtMenuBuilder::QtMenuBuilder()
{
}

//****************************************************************************/
QtMenuBuilder::~QtMenuBuilder()
{
}

//****************************************************************************/
QString QtMenuBuilder::createInclude(const QString &s)
{
    // Add the #include
    QString str = s;
    str = str +
    QString("#include <QMenu>") +
    QString("\n");
    return str;
}

//****************************************************************************/
QString QtMenuBuilder::createPrivateMembers(WindowMenuProperties* windowMenuProperties, const QString &s)
{
    QString str = s;
    QString menuItemName;
    QString subMenuItemName;
    WindowMenuItemProperties* item = 0;
    if (windowMenuProperties)
    {
        QVectorIterator<WindowMenuItemProperties*> itemList(windowMenuProperties->mWindowMenuItemPropertiesList);

        // Define private members
        while (itemList.hasNext())
        {
            item = itemList.next();
            menuItemName = Utils::makePrivateAttribute (item->mItemName) + QString("Menu");

            // Define private members
            str = str +
                TAB +
                TAB +
                QString("QMenu* ") +
                menuItemName +
                QString(";") +
                QString("\n");
        }
    }
    return str;
}

//****************************************************************************/
QString QtMenuBuilder::createMenuMainWindow(WindowMenuProperties* windowMenuProperties, const QString &s)
{
    QString str = s;
    QString menuItemName;
    QString subMenuItemName;
    WindowMenuItemProperties* item = 0;
    WindowMenuSubItemProperties* subItem = 0;
    if (windowMenuProperties)
    {
        QVectorIterator<WindowMenuItemProperties*> itemList(windowMenuProperties->mWindowMenuItemPropertiesList);

        // Create the menu entries for a QMainWindow; QMainWindow differs from QDockQWidget
        while (itemList.hasNext())
        {
            item = itemList.next();
            menuItemName = Utils::makePrivateAttribute (item->mItemName) + QString("Menu");

            // Define a menu item (to be connected to the menubar)
            str = str +
                TAB +
                menuItemName +
                QString(" = menuBar()->addMenu(QString(\"") +
                item->mItemName +
                QString("\"));") +
                QString("\n");

            QVectorIterator<WindowMenuSubItemProperties*> subItemList(item->mWindowMenuSubItemPropertiesList);
            while (subItemList.hasNext())
            {
                subItem = subItemList.next();
                subMenuItemName = Utils::makePrivateAttribute (subItem->mSubItemName) + QString("MenuAction");

                // Define code that adds an action to a menu item
                str = str +
                    TAB +
                    menuItemName +
                    QString("->addAction(") +
                    subMenuItemName +
                    QString(");") +
                    QString("\n");
            }
        }
    }
    return str;
}
Esempio n. 27
0
QString QuteComboBox::getCabbageLine()
{
#ifdef  USE_WIDGET_MUTEX
	widgetLock.lockForRead();
#endif
	QString line = "combobox channel(\"" + m_channel + "\"),  ";
	line += QString("bounds(%1,%2,%3,%4), ").arg(x()).arg(y()).arg(width()).arg(height());
	line += "value(" + QString::number(m_value) + "), ";
	line += "items(\"" + itemList() + "\")";
	if (property("QCS_midicc").toInt() >= 0 && property("QCS_midichan").toInt()>0) { // insert only if midi channel is above 0
		line += ", midiCtrl(\"" + QString::number(property("QCS_midichan").toInt()) + ",";
		line +=  QString::number(property("QCS_midicc").toInt()) + "\")";
	}
#ifdef  USE_WIDGET_MUTEX
	widgetLock.unlock();
#endif
	return line;
}
Esempio n. 28
0
void MangaW::ClassicStart(void)
{
	MainLayout = new QGridLayout;
	VBoxLayout = new QVBoxLayout;
	MainItemList = new QTreeWidget;
	ListButton = new QPushButton("Liste des volumes");
	AddButton = new QPushButton("Ajouter une série");
	ModifyButton = new QPushButton("Modifier une série");
	DeleteButton = new QPushButton("Supprimer une série");

	this->setWindowIcon(qApp->windowIcon());
	this->setWindowTitle(qApp->applicationName());
	this->setMinimumSize(500, 250);

	ItemList = T.list_toQList();
	ListButton->setEnabled(false);
	ModifyButton->setEnabled(false);
	DeleteButton->setEnabled(false);

	MainItemList->setColumnCount(2);
	MainItemList->setHeaderLabels(HeadLabels);
	MainItemList->addTopLevelItems(ItemList);
	MainItemList->resizeColumnToContents(0);
    MainItemList->resizeColumnToContents(1);
    MainItemList->setSelectionBehavior(QAbstractItemView::SelectRows);

	VBoxLayout->addWidget(ListButton);
	VBoxLayout->addWidget(AddButton);
	VBoxLayout->addWidget(ModifyButton);
	VBoxLayout->addWidget(DeleteButton);
	MainLayout->addWidget(MainItemList, 0, 0);
	MainLayout->addLayout(VBoxLayout, 0, 1);

	this->setLayout(MainLayout);
	this->show();

	connect(MainItemList, SIGNAL(itemClicked(QTreeWidgetItem *, int)), this, SLOT(itemClicked(QTreeWidgetItem *)));
	connect(MainItemList, SIGNAL(itemActivated(QTreeWidgetItem*,int)), this, SLOT(itemDoubleClicked(QTreeWidgetItem*)));
	//connect(MainItemList, SIGNAL(itemSelectionChanged()));
	connect(ListButton, SIGNAL(clicked()), this, SLOT(itemList()));
	connect(AddButton, SIGNAL(clicked()), this, SLOT(addItem()));
	connect(ModifyButton, SIGNAL(clicked()), this, SLOT(modifyItem()));
	connect(DeleteButton, SIGNAL(clicked()), this, SLOT(deleteItem()));
}
/**
*
*	<B>SubscribeStringList</B>
*
*	Description = subscribe item list to opc server 
*	<p>
*	Specification = 
*	<p>
*	@param sItems  item paths (without common path) seperated by '|'
*	<p>
*	@param sCommonPath path that is common to all items, e.g. "[w-xx].Resource1.". sCommonPath may be empty 
*	<p>
*	@return
*	<p>
*
*/
STDMETHODIMP CAsyncAccess::SubscribeStringList(BSTR sItems, BSTR sCommonPath)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState())

    //TRACE(_T("Subscribe List %s\n"), (LPCTSTR) CString(sItems));

    HRESULT hr = S_OK;
	CString strCommonPath=sCommonPath;
	CString strItems=sItems;
	CItemStringList itemList(strCommonPath,strItems);

	for (int ii=0; ii<itemList.GetSize(); ii++)
	{
		HRESULT hr2=DoSubscribe(itemList.GetAt(ii));
		if (hr2 != S_OK)
			hr = S_FALSE;
	}
	return hr;
}
Esempio n. 30
0
int main()
{
	item itemArr[] = {item(2,1), item(3,4), item(4,3),
							item(5,6), item(6,8)};
	int arrSize = sizeof(itemArr)/sizeof(item);
	vector<item> itemList(itemArr, itemArr+arrSize);
	int capacity;

	cout << "Enter the capacity: ";
	cin >> capacity;

	// create a knapsack object
	knapsack ks(itemList,capacity);

	// ks.displayMaxValueMat();		// add for diagnostics
	// display the solution
	ks.displayKnapsack(); 
	cout << endl << endl;

	return 0;
}