예제 #1
0
void QgsCompositionWidget::on_mPaperUnitsComboBox_currentIndexChanged( const QString& text )
{
    Q_UNUSED( text );

    double width = size( mPaperWidthDoubleSpinBox );
    double height = size( mPaperHeightDoubleSpinBox );

    if ( mPaperUnitsComboBox->currentIndex() == 0 )
    {
        // mm, value was inch
        width *= 25.4;
        height *= 25.4;
    }
    else
    {
        // inch, values was mm,
        width /= 25.4;
        height /= 25.4;
    }

    setSize( mPaperWidthDoubleSpinBox, width );
    setSize( mPaperHeightDoubleSpinBox, height );

    if ( mPaperSizeComboBox->currentText() == tr( "Custom" ) )
    {
        adjustOrientation();
        applyWidthHeight();
    }
    else
    {
        adjustOrientation();
        applyCurrentPaperSettings();
    }
}
void QgsCompositionWidget::on_mPaperOrientationComboBox_currentIndexChanged( const QString& text )
{
  if ( mPaperSizeComboBox->currentText() == tr( "Custom" ) )
  {
    adjustOrientation();
    applyWidthHeight();
  }
  else
  {
    adjustOrientation();
    applyCurrentPaperSettings();
  }
}
예제 #3
0
void QgsCompositionWidget::applyCurrentPaperSettings()
{
    if ( mComposition )
    {
        //find entry in mPaper map to set width and height
        QMap<QString, QgsCompositionPaper>::iterator it = mPaperMap.find( mPaperSizeComboBox->currentText() );
        if ( it == mPaperMap.end() )
        {
            return;
        }

        mPaperWidthDoubleSpinBox->setEnabled( true );
        mPaperHeightDoubleSpinBox->setEnabled( true );
        setSize( mPaperWidthDoubleSpinBox, it->mWidth );
        setSize( mPaperHeightDoubleSpinBox, it->mHeight );
        mPaperWidthDoubleSpinBox->setEnabled( false );
        mPaperHeightDoubleSpinBox->setEnabled( false );

        adjustOrientation();
        applyWidthHeight();
    }
}
예제 #4
0
struct psl* pslTransMap(unsigned opts, struct psl *inPsl, struct psl *mapPsl)
/* map a psl via a mapping psl, a single psl is returned, or NULL if it
 * couldn't be mapped. */
{
int mappedPslMax = 8; /* allocated space in output psl */
int iMapBlk = 0;
char inPslOrigStrand[3];
boolean rcInPsl = (pslTStrand(inPsl) != pslQStrand(mapPsl));
boolean cnv1 = (pslIsProtein(inPsl) && !pslIsProtein(mapPsl));
boolean cnv2 = (pslIsProtein(mapPsl) && !pslIsProtein(inPsl));
int iBlock;
struct psl* mappedPsl;

/* sanity check size, but allow names to vary to allow ids to have
 * unique-ifying suffixes. */
if (inPsl->tSize != mapPsl->qSize)
    errAbort("Error: inPsl %s tSize (%d) != mapPsl %s qSize (%d)",
            inPsl->tName, inPsl->tSize, mapPsl->qName, mapPsl->qSize);

/* convert protein PSLs */
if (cnv1)
    pslProtToNA(inPsl);
if (cnv2)
    pslProtToNA(mapPsl);

/* need to ensure common sequence is in same orientation, save strand for later */
safef(inPslOrigStrand, sizeof(inPslOrigStrand), "%s", inPsl->strand);
if (rcInPsl)
    pslRc(inPsl);

mappedPsl = createMappedPsl(inPsl, mapPsl, mappedPslMax);

/* Fill in ungapped blocks.  */
for (iBlock = 0; iBlock < inPsl->blockCount; iBlock++)
    {
    struct block align1Blk = blockFromPslBlock(inPsl, iBlock);
    while (mapBlock(inPsl, mapPsl, &iMapBlk, &align1Blk, mappedPsl,
                    &mappedPslMax))
        continue;
    }

/* finish up psl, or free if no blocks were added */
assert(mappedPsl->blockCount <= mappedPslMax);
if (mappedPsl->blockCount == 0)
    pslFree(&mappedPsl);  /* nothing made it */
else
    {
    setPslBounds(mappedPsl);
    adjustOrientation(opts, inPsl, inPslOrigStrand, mappedPsl);
    }

/* restore input */
if (rcInPsl)
    {
    pslRc(inPsl);
    strcpy(inPsl->strand, inPslOrigStrand);
    }
if (cnv1)
    pslNAToProt(inPsl);
if (cnv2)
    pslNAToProt(mapPsl);

return mappedPsl;
}
예제 #5
0
/**
  This method is EXTREMELY important.
  Virtually every geometry-editing-function passes through here.
*/
bool EdgeWidget::setPosition(int location, ScreenEdge edge, const QSize &newSize)
{
	// Store some important variables to be able to restore them if things don't go well.
	QRect oldDg = _desiredGeometry;
	ScreenEdge oldEdge = _edge;

	// This really is not the best way to solve the problem with posdragging, but for now it will suffice.
	QPoint oldPosDragging;
	if (_posDragging)
		oldPosDragging = *_posDragging;

	// Set the size of desiredGeometry to do the coming calculations on the new desired size (location and such)
	_desiredGeometry.setSize(newSize);

	// Make sure we only deal with "real" edges, we don't want to have to check for SameEdge everywhere.
	if (edge == SameEdge)
		edge = oldEdge;

	// We only tranpose for now, we don't emit edgeChange-signals to trigger reorienting widgets,
	// in case things don't work out with the new geometry.
	if ((edge != oldEdge) && _edgeAdjust)
			adjustOrientation(_desiredGeometry, edge);

	// Do all coming calculations based on the new edge
	_edge = edge;

	// Check we're not moving out of screen
	int minLocation = 0;
	int maxLocation = (orientation(edge) == Horizontal)?
			_screen->width() - _desiredGeometry.width():
			_screen->height() - _desiredGeometry.height();
	if (location < minLocation)
		location = minLocation;
	if (location > maxLocation)
		location = maxLocation;

	// Now, we should have figured the final size, edge and location, just make it so.
	switch (edge)
	{
		case TopEdge:
			_desiredGeometry.moveLeft(location);
			_desiredGeometry.moveTop(-_currentOffset);
			break;
		case BottomEdge:
			_desiredGeometry.moveLeft(location);
			_desiredGeometry.moveBottom(_screen->height()+_currentOffset);
			break;
		case LeftEdge:
			_desiredGeometry.moveLeft(-_currentOffset);
			_desiredGeometry.moveTop(location);
			break;
		case RightEdge:
			_desiredGeometry.moveRight(_screen->width()+_currentOffset);
			_desiredGeometry.moveTop(location);
			break;
		default:
			_desiredGeometry.moveLeft(0);
			_desiredGeometry.moveTop(0);
	}

	// Check for collsion, this is a recursive call.
	if (EdgeWidgetManager::instance()->checkCollision(*this))
	{
		// If things did not work out, restore the desired geometry and edge to the way they were before.
		_desiredGeometry = oldDg;
		_edge = oldEdge;

		if (_posDragging)
			*_posDragging = oldPosDragging;

		// False indicates the new geometry had unresolved collisions.
		return false;
	}
	else
	{
		// Apply the new geometry
		QWidget::setGeometry(_desiredGeometry);

		// Ok, new geometry was OK, emit the edgechange signal and give the widget a chance to adjust.
		if (oldEdge != edge)
			emit edgeChanged(oldEdge, edge);

		if (pos() != _desiredGeometry.topLeft())
		{
			if (!_posDragging)
				emit positionChanged();
			emit positionChanging();
		}

		if (size() != _desiredGeometry.size())
		{
			if (!_sizeDragging)
				emit sizeChanged();
			emit sizeChanging();
		}

		// True indicates there were no unresolved problems with the new geometry.
		return true;
	}
}