Example #1
0
void QgsDxfPaintEngine::drawPolygon( const QPointF *points, int pointCount, PolygonDrawMode mode )
{
  Q_UNUSED( mode );
  if ( !mDxf || !mPaintDevice )
  {
    return;
  }

  QgsPolygon polygon( 1 );
  polygon[0].resize( pointCount );

  QgsPolyline &polyline = polygon[0];
  for ( int i = 0; i < pointCount; ++i )
  {
    polyline[i] = toDxfCoordinates( points[i] );
  }

  if ( mode == QPaintEngine::PolylineMode )
  {
    mDxf->writePolyline( polyline, mLayer, "CONTINUOUS", mPen.color(), currentWidth(), true );
  }
  else
  {
    mDxf->writePolygon( polygon, mLayer, "SOLID", mBrush.color() );
  }
}
Example #2
0
void LineWidth::applyOverhang(RenderRubyRun* rubyRun, RenderObject* startRenderer, RenderObject* endRenderer)
{
    int startOverhang;
    int endOverhang;
    rubyRun->getOverhang(m_isFirstLine, startRenderer, endRenderer, startOverhang, endOverhang);

    startOverhang = std::min<int>(startOverhang, m_committedWidth);
    m_availableWidth += startOverhang;

    endOverhang = std::max(std::min<int>(endOverhang, m_availableWidth - currentWidth()), 0);
    m_availableWidth += endOverhang;
    m_overhangWidth += startOverhang + endOverhang;
}
void LineWidth::applyOverhang(LineLayoutRubyRun rubyRun, LineLayoutItem startLayoutItem, LineLayoutItem endLayoutItem)
{
    int startOverhang;
    int endOverhang;
    rubyRun.getOverhang(m_isFirstLine, startLayoutItem, endLayoutItem, startOverhang, endOverhang);

    startOverhang = std::min<int>(startOverhang, m_committedWidth);
    m_availableWidth += startOverhang;

    endOverhang = std::max(std::min<int>(endOverhang, m_availableWidth - currentWidth()), 0);
    m_availableWidth += endOverhang;
    m_overhangWidth += startOverhang + endOverhang;
}
Example #4
0
void LineWidth::applyOverhang(LayoutRubyRun* rubyRun, LayoutObject* startLayoutObject, LayoutObject* endLayoutObject)
{
    int startOverhang;
    int endOverhang;
    rubyRun->getOverhang(m_isFirstLine, startLayoutObject, endLayoutObject, startOverhang, endOverhang);

    startOverhang = std::min<int>(startOverhang, m_committedWidth);
    m_availableWidth += startOverhang;

    endOverhang = std::max(std::min<int>(endOverhang, m_availableWidth - currentWidth()), 0);
    m_availableWidth += endOverhang;
    m_overhangWidth += startOverhang + endOverhang;
}
Example #5
0
void QgsDxfPaintEngine::drawLines( const QLineF* lines, int lineCount )
{
  if ( !mDxf || !mPaintDevice || !lines )
  {
    return;
  }

  for ( int i = 0; i < lineCount; ++i )
  {
    QgsPoint pt1 = toDxfCoordinates( lines[i].p1() );
    QgsPoint pt2 = toDxfCoordinates( lines[i].p2() );
    mDxf->writeLine( pt1, pt2, mLayer, "CONTINUOUS", currentColor(), currentWidth() );
  }
}
Example #6
0
void QgsDxfPaintEngine::drawPolygon( const QPointF* points, int pointCount, PolygonDrawMode mode )
{
  Q_UNUSED( mode );
  if ( !mDxf || !mPaintDevice )
  {
    return;
  }

  QgsPolyline polyline( pointCount );
  for ( int i = 0; i < pointCount; ++i )
  {
    polyline[i] = toDxfCoordinates( points[i] );
  }

  bool closed = ( pointCount > 3 && points[0] == points[pointCount - 1] );
  mDxf->writePolyline( polyline, mLayer, "CONTINUOUS", currentColor(), currentWidth(), closed );
}
Example #7
0
void GLWindow::computeScale()
{
    scaleValue = 16.0f;
    scaleMode = 3;
    float w = (float)currentWidth();
    float h = (float)currentHeight();
    if ( (w/h) <  (16.0f/9.0f))
    {
        if(w>=1920)
        {
            scaleMode = 0;
            scaleValue = 64.0f;
        }
        else if(w>=1440)
        {
            scaleMode = 1;
            scaleValue = 48.0f;
        }
        else if(w>=960)
        {
            scaleMode = 2;
            scaleValue = 32.0f;
        }
    }
    else
    {
        if(h>=1080)
        {
            scaleMode = 0;
            scaleValue = 64.0f;
        }
        else if(h>=810)
        {
            scaleMode = 1;
            scaleValue = 48.0f;
        }
        else if(h>=540)
        {
            scaleMode = 2;
            scaleValue = 32.0f;
        }
    }
}
Example #8
0
int Webcam::getFrameBW(GrayScaleImage &image)
{
        int ret = 0;

        // Dequeue a buffer.
        ret = ioctl(dev, VIDIOC_DQBUF, &buf);
        if (ret < 0)
        {
                KError("Unable to dequeue buffer", errno);
                return EXIT_FAILURE;
        }

        // Save the image.
        //uchar jpegBuf1[buf.bytesused + 420];
        if (fmt.fmt.pix.pixelformat == V4L2_PIX_FMT_MJPEG)
        {
            /*
                if (mjpegToJpeg(mem[buf.index], jpegBuf1, (int) buf.bytesused) == EXIT_SUCCESS)
                        image.loadFromData(jpegBuf1, buf.bytesused+420);
            */
            return EXIT_FAILURE;
        }

        if (fmt.fmt.pix.pixelformat == V4L2_PIX_FMT_YUYV)
        {
                image.setImage(yuvToBW(mem[buf.index], currentWidth(), currentHeight()), currentWidth(), currentHeight());
        }

        // Requeue the buffer.
        ret = ioctl(dev, VIDIOC_QBUF, &buf);
        if (ret < 0)
        {
                KError("Unable to requeue buffer", errno);
                return EXIT_FAILURE;
        }
        if(!imageNotifier->isEnabled())
                imageNotifier->setEnabled(true);

        return EXIT_SUCCESS;
}
Example #9
0
bool LineWidth::fitsOnLineExcludingTrailingWhitespace(float extra) const
{
    return currentWidth() - m_trailingWhitespaceWidth + extra <= m_availableWidth;
}
Example #10
0
bool LineWidth::fitsOnLineIncludingExtraWidth(float extra) const
{
    return currentWidth() + extra <= m_availableWidth;
}
Example #11
0
bool LineWidth::fitsOnLineExcludingTrailingCollapsedWhitespace() const
{
    return currentWidth() - m_trailingCollapsedWhitespaceWidth <= m_availableWidth;
}
Example #12
0
int Webcam::startStreaming()
{
	int i, ret;

	if (!opened)
		return -1;

	if ((ret = setFormat(currentWidth(), currentHeight(), currentPixelFormat())) != 0)
	{
		printf("set format error : %d\n", ret);
		return EXIT_FAILURE;
	}

	//Allocate buffers 
	if (!allocated)
	{
		memset(&rb, 0, sizeof rb);
		rb.count = 2;
		rb.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
		rb.memory = V4L2_MEMORY_MMAP;
	
		ret = ioctl(dev, VIDIOC_REQBUFS, &rb);
		if (ret < 0) 
		{
			KError("Unable to allocate buffers", errno);
			return EXIT_FAILURE;
		}
		allocated = true;
	}

			
	// Map the buffers. /
	memset(&buf, 0, sizeof buf);
	buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
	buf.memory = V4L2_MEMORY_MMAP;
	for (i = 0; i < 2; i++)
	{
		buf.index = i; 
		ret = ioctl(dev, VIDIOC_QUERYBUF, &buf);
		if (ret < 0) {
			KError("Unable to query buffer", errno);
			return EXIT_FAILURE;
		}
		
		mem[i] = (uchar *) mmap(0, buf.length, PROT_READ | PROT_WRITE, MAP_SHARED, dev, buf.m.offset);
		if (mem[i] == MAP_FAILED) {
			KError("Unable to map buffer", errno);
			return EXIT_FAILURE;
		}
		bufLength = buf.length;
		mmaped = true;
	}

	// Queue the buffers. /
	for (i = 0; i < 2; i++)
	{
		buf.index = i;
		ret = ioctl(dev, VIDIOC_QBUF, &buf);
		if (ret < 0) 
		{
			KError("Unable to queue buffer", errno);
			return EXIT_FAILURE;
		}
	}

	// Start streaming.
	ret = ioctl(dev, VIDIOC_STREAMON, &buf.type);
	if (ret < 0) 
	{
		KError("Unable to start capture", errno);
		return EXIT_FAILURE;
	}
	
	imageNotifier->setEnabled(true);
	streaming = true;
	return EXIT_SUCCESS;
}
Example #13
0
void ElidedCheckBox::resizeEvent(QResizeEvent *event)
{
    int diff = event->size().width() - event->oldSize().width();
    updateText(currentWidth() + diff);
    QCheckBox::resizeEvent(event);
}
Example #14
0
void ElidedCheckBox::setBoxText(const QString &text) 
{
    m_text = text;
    int width = currentWidth();
    updateText(width);
}