Пример #1
0
void PhysicsShape::setScale(float scaleX, float scaleY)
{
    if (fabs(_scaleX - scaleX) > FLT_EPSILON || fabs(_scaleY - scaleY) > FLT_EPSILON)
    {
        if (_type == Type::CIRCLE && scaleX != scaleY)
        {
            CCLOG("PhysicsShapeCircle WARNING: CANNOT support setScale with different x and y");
            return;
        }
        _newScaleX = scaleX;
        _newScaleY = scaleY;
        
        updateScale();
        
        // re-calculate area and mass
        _area = calculateArea();
        _mass = _material.density * _area;
        _moment = calculateDefaultMoment();
    }
}
Пример #2
0
		/**
		* Respond to mouse move event. If the left button is down change the min or max.
		*/
		void ColorMapWidget::mouseMoveEvent(QMouseEvent* e)
		{
			if (!m_dragging) return;

			double minValue = m_minValueBox->displayText().toDouble();
			double maxValue = m_maxValueBox->displayText().toDouble();

			if (m_dtype == Bottom)
			{
				minValue += double(e->y() - m_y) / height()*(maxValue - minValue);
				setMinValueText(minValue);
			}
			else
			{
				maxValue += double(e->y() - m_y) / height()*(maxValue - minValue);
				setMaxValueText(maxValue);
			}
			m_y = e->y();
			updateScale();
		}
Пример #3
0
		void tick(float dt) {
			float inverseAR = 1.0f / m_pWindow->getAspectRatio();
			vec3<float> aspectFix = vec3<float>(1, inverseAR, 1);

			if (!instantPositionUpdate)
			{
				m_currentPosition += (m_targetPosition() * aspectFix - m_currentPosition) * dt * 5;
			}
			else
			{
				m_currentPosition = m_targetPosition() * aspectFix;
			}

			if (!instantScaleUpdate)
			{
				m_currentScale += (m_targetScale() - m_currentScale) * dt * 8;
			}
			else
			{
				m_currentScale = m_targetScale();
			}

			updatePosition();
			updateScale();

			if (positionAlign & LEFT)
				m_worldPosition.x += m_worldScale.x * 0.5f;
			if (positionAlign & RIGHT)
				m_worldPosition.x -= m_worldScale.x * 0.5f;
			if (positionAlign & TOP)
				m_worldPosition.y -= m_worldScale.y * 0.5f;
			if (positionAlign & BOTTOM)
				m_worldPosition.y += m_worldScale.y * 0.5f;

			update(dt);
			for (auto child : m_children) {
				child->tick(dt);
			}
		}
Пример #4
0
void QgsMapCanvas::resizeEvent( QResizeEvent * e )
{
  QGraphicsView::resizeEvent( e );
  mResizeTimer->start( 500 );

  QSize lastSize = viewport()->size();

  mSettings.setOutputSize( lastSize );
  mMapRenderer->setOutputSize( lastSize, mSettings.outputDpi() );

  mScene->setSceneRect( QRectF( 0, 0, lastSize.width(), lastSize.height() ) );

  moveCanvasContents( true );

  // notify canvas items of change
  updateCanvasItemPositions();

  updateScale();

  //refresh();

  emit extentsChanged();
}
Пример #5
0
void TextItem::loadSprite()
{
    updateScale();
    
    setRenderSize(QSize(qRound(m_scale*width), qRound(m_scale*height)));
    
    int w = qRound(m_scale*width);
    int h = qRound(m_scale*height);
    
    QPixmap pixmap(QSize(w, h));
    pixmap.fill(Qt::transparent);
    QPainter p(&pixmap);
    int fontSize = fontUtils::fontSize(p, m_text, qRound(w*0.8), h,
                                   fontUtils::DoNotAllowWordWrap);
    
    p.setPen(QColor(255, 255, 255, 220));
    p.setFont(QFont("Helvetica", fontSize, QFont::Bold));
    p.drawText(QRectF(0, 0, w, h), 
                Qt::AlignCenter, m_text);
    m_textPixmap.setPixmap(pixmap);
    
    repaint();
}
Пример #6
0
	void GUIWindow::limitWithinMainWindow()
	{//Prevent window going out of application window

		//Limit size
		if (size.y + header->getHeight() > applicationData->getWindowHeight() - upBorder - downBorder)
		{//Window too high
			setSize(size.x, applicationData->getWindowHeight() - header->getHeight() - upBorder - downBorder);
		}
		if (size.x > applicationData->getWindowWidth() - leftBorder - rightBorder)
		{//Window too wide
			setSize(applicationData->getWindowWidth() - leftBorder - rightBorder, size.y);
		}

		//////Limit position
		////Y
		if (getYGlobal() > applicationData->getWindowHeight() - size.y - upBorder - header->getHeight())
		{//Window too up
			setPositionGlobal(position.x, applicationData->getWindowHeight() - size.y - upBorder - header->getHeight());
		}
		else if (getYGlobal() < downBorder)
		{//Window too down
			setPositionGlobal(position.x, downBorder);
		}
		////X
		if (getXGlobal() > applicationData->getWindowWidth() - size.x - rightBorder)
		{//Window too right
			setPositionGlobal(applicationData->getWindowWidth() - size.x - rightBorder, position.y);
		}
		else if (getXGlobal() < leftBorder)
		{//Window too left
			setPositionGlobal(leftBorder, position.y);
		}

		updateScale();
		updatePosition();
	}
bool Plot3DDialog::updatePlot()
{
	int axis=-1;

	if (generalDialog->currentWidget()==(QWidget*)bars)
	{
		emit updateBars(boxBarsRad->text().toDouble());
	}

	if (generalDialog->currentWidget()==(QWidget*)points)
	{
		if (boxPointStyle->currentItem() == 0)
			emit updatePoints(boxSize->text().toDouble(), boxSmooth->isChecked());
		else if (boxPointStyle->currentItem() == 1)
			emit updateCross(boxCrossRad->text().toDouble(), boxCrossLinewidth->text().toDouble(),
					boxCrossSmooth->isChecked(), boxBoxed->isChecked());
		else if (boxPointStyle->currentItem() == 2)
			emit updateCones(boxConesRad->text().toDouble(), boxQuality->value());
	}

	if (generalDialog->currentWidget()==(QWidget*)title)
	{
		emit updateTitle(boxTitle->text(),titleColor,titleFont);
	}

	if (generalDialog->currentWidget()==(QWidget*)colors)
	{
		emit updateTransparency(boxTransparency->value()*0.01);
		emit updateDataColors(fromColor,toColor);
		emit updateColors(meshColor,axesColor,numColor,labelColor,bgColor,gridColor);
	}

	if (generalDialog->currentWidget()==(QWidget*)general)
	{
		emit showColorLegend(boxLegend->isChecked());
		emit updateMeshLineWidth(boxMeshLineWidth->value());
		emit adjustLabels(boxDistance->value());
		emit updateResolution (boxResolution->value());
		emit showColorLegend(boxLegend->isChecked());
		emit setNumbersFont(numbersFont);
		emit updateZoom(boxZoom->value()*0.01);
		emit updateScaling(boxXScale->value()*0.01,boxYScale->value()*0.01,
				boxZScale->value()*0.01);
	}

	if (generalDialog->currentWidget()==(QWidget*)scale)
	{
		axis=axesList->currentRow();
		QString from=boxFrom->text().toLower();
		QString to=boxTo->text().toLower();
		double start,end;
		bool error=false;
		try
		{
			MyParser parser;
			parser.SetExpr(from.toAscii().constData());
			start=parser.Eval();
		}
		catch(mu::ParserError &e)
		{
			QMessageBox::critical(0,tr("Start limit error"),  QString::fromStdString(e.GetMsg()));
			boxFrom->setFocus();
			error=true;
			return false;
		}
		try
		{
			MyParser parser;
			parser.SetExpr(to.toAscii().constData());
			end=parser.Eval();
		}
		catch(mu::ParserError &e)
		{
			QMessageBox::critical(0,tr("End limit error"), QString::fromStdString(e.GetMsg()));
			boxTo->setFocus();
			error=true;
			return false;
		}

		if (start>=end)
		{
			QMessageBox::critical(0,tr("Input error"),
					tr("Please enter scale limits that satisfy: from < to!"));
			boxTo->setFocus();
			return false;
		}

		if (! error)
			emit updateScale(axis,scaleOptions(axis, start, end,
						boxMajors->text(), boxMinors->text()));
	}

	if (generalDialog->currentWidget()==(QWidget*)axes)
	{
		axis=axesList2->currentRow();
		labels[axis] = boxLabel->text();
		emit updateLabel(axis, boxLabel->text(),axisFont(axis));
		emit updateTickLength(axis,boxMajorLength->text().toDouble(),
				boxMinorLength->text().toDouble());
	}

	return true;
}
Пример #8
0
//! QwtDoubleRange update hook
void QwtDial::rangeChange()
{
    updateScale();
}
Пример #9
0
void ProxyEntity::onSetScale (ProxyObjectPtr proxy, float32 scale )
{
    updateScale(scale);
}
Пример #10
0
int main(int argc, char *argv[])
{
    /* Initialize Artist library, creates window */
    art_initSimple(800, 600, 0);

    /* Initial window settings */
    art_setWinTitle("Artist Demo #7");
    art_setBackgroundColor(0, 0, 0);

    int exit = 0;

    // Load image to a layer
    Art_Layer* image = art_loadImage("media/saturn.jpg");

    float scale = 1.0f;
    float rot = 0.0f;

    /* Drawing loop */
    while (!exit)
    {
        art_setRotation(400, 300, rot);
        art_setColor(255, 255, 255, 255);
        art_drawLayer(image, 80.0f, 25.0f);

        rot += 0.005f;

        /* Update window */
        art_update();

        /* Check events */
        while (art_nextEvent())
        {
            if (art_getEventType() == ART_EVENT_QUIT)
            {
                exit = 1;
            }
            else if (art_getEventType() == ART_EVENT_KEY_DOWN)
            {
                if (art_getKeyCode() == ART_KEY_ESCAPE)
                {
                    exit = 1;
                }
            }
            else if (art_getEventType() == ART_EVENT_MOUSE_WHEEL_UP)
            {
                scale += 0.05f;
                updateScale(scale);
            }
            else if (art_getEventType() == ART_EVENT_MOUSE_WHEEL_DOWN)
            {
                if (scale >= 0.05f)
                {
                    scale -= 0.05f;
                    updateScale(scale);
                }
            }
        }
    }
    
    /* Close artist libarary before exiting program */
    art_close();
    return 0;
}
Пример #11
0
void ProxyEntity::onSetScale (ProxyObjectPtr proxy, float32 scale,const SpaceObjectReference& sporef )
{
    updateScale(scale);
    getScene()->downloadPlanner()->updateObject(proxy);
}
Пример #12
0
/*
 * This dialog is designed to unify the old word, view, and graph type dialogs
 * into a cohesive whole.
 *
 */
ViewDimensions::ViewDimensions(MainWindow *parent) :
    Dialog(parent, "Dimensions", true)
{
    WorldDimProp::add(this);

    viewXMin = getUnitDoubleSpinBox();
    connect(viewXMin, SIGNAL(valueChanged(double)), this, SLOT(readjXMax()));
    viewXMax = getUnitDoubleSpinBox();
    connect(viewXMax, SIGNAL(valueChanged(double)), this, SLOT(readjXMin()));
    viewYMin = getUnitDoubleSpinBox();
    connect(viewYMin, SIGNAL(valueChanged(double)), this, SLOT(readjYMax()));
    viewYMax = getUnitDoubleSpinBox();
    connect(viewYMax, SIGNAL(valueChanged(double)), this, SLOT(readjYMin()));

    worldXMin = new QLineEdit();
    connect(worldXMin, SIGNAL(textEdited(QString)), this, SLOT(updateScale()));
    worldXMax = new QLineEdit();
    connect(worldXMax, SIGNAL(textEdited(QString)), this, SLOT(updateScale()));
    worldYMin = new QLineEdit();
    connect(worldYMin, SIGNAL(textEdited(QString)), this, SLOT(updateScale()));
    worldYMax = new QLineEdit();
    connect(worldYMax, SIGNAL(textEdited(QString)), this, SLOT(updateScale()));

    worldType = new QComboBox();
    for (int k=0;k<OPTS_LEN;k++) {
        worldType->addItem(opts[k].iname);
    }
    connect(worldType, SIGNAL(currentIndexChanged(int)), this, SLOT(updateScale()));

    viewSelect = makeButton("Rect Select", SLOT(viewRect()));
    setButtonBold(viewSelect);

    rescaleAxes = makeButton("Autoscale", SLOT(rescaleTicks()));
    setButtonBold(rescaleAxes);

    autoHook(viewXMin);
    autoHook(viewXMax);
    autoHook(viewYMin);
    autoHook(viewYMax);
    autoHook(worldXMin);
    autoHook(worldXMax);
    autoHook(worldYMin);
    autoHook(worldYMax);
    autoHook(worldType);

    QHBoxLayout* header = new QHBoxLayout();
    header->addWidget(makeLabel("Graph Type"), 0);
    header->addWidget(worldType, 0);
    header->addStretch(1);

    QGridLayout* wrldl = new QGridLayout();
    addPair(wrldl, 0, makeLabel("X Min"), worldXMin);
    addPair(wrldl, 1, makeLabel("X Max"), worldXMax);
    addPair(wrldl, 2, makeLabel("Y Min"), worldYMin);
    addPair(wrldl, 3, makeLabel("Y Max"), worldYMax);
    wrldl->setRowMinimumHeight(4, 12);
    wrldl->addWidget(rescaleAxes, 5, 0, 1, 2, Qt::AlignCenter);
    wrldl->setColumnMinimumWidth(1, 100);
    wrldl->setColumnStretch(0, 0);
    wrldl->setColumnStretch(1, 2);

    QGroupBox* wrldb = makeGroupBox("World Coords");
    wrldb->setLayout(wrldl);

    QVBoxLayout* wrld = new QVBoxLayout();
    wrld->addWidget(wrldb, 0);
    wrld->addStretch(1);

    QGridLayout* viewl = new QGridLayout();
    addPair(viewl, 0, makeLabel("X Min"), viewXMin);
    addPair(viewl, 1, makeLabel("X Max"), viewXMax);
    addPair(viewl, 2, makeLabel("Y Min"), viewYMin);
    addPair(viewl, 3, makeLabel("Y Max"), viewYMax);
    viewl->setRowMinimumHeight(4, 12);
    viewl->addWidget(viewSelect, 5, 0, 1, 2, Qt::AlignCenter);
    viewl->setColumnMinimumWidth(1, 120);
    viewl->setColumnStretch(0, 0);
    viewl->setColumnStretch(1, 2);

    QGroupBox* viewb = makeGroupBox("View Coords");
    viewb->setLayout(viewl);

    QVBoxLayout* view = new QVBoxLayout();
    view->addWidget(viewb, 0);
    view->addStretch(1);

    QHBoxLayout* bot = new QHBoxLayout();
    bot->addLayout(wrld);
    bot->addLayout(view);

    QVBoxLayout* ovr = new QVBoxLayout();
    ovr->addLayout(header);
    ovr->addStrut(12);
    ovr->addLayout(bot);

    this->setDialogLayout(ovr);
}
Пример #13
0
ExpoDialog::ExpoDialog(QWidget *parent, ModelData & model, ExpoData *expoData, GeneralSettings & generalSettings, 
                          Firmware * firmware, QString & inputName) :
  QDialog(parent),
  ui(new Ui::ExpoDialog),
  model(model),
  generalSettings(generalSettings),
  firmware(firmware),
  ed(expoData),
  inputName(inputName),
  modelPrinter(firmware, generalSettings, model)
{
  ui->setupUi(this);
  QLabel * lb_fp[] = {ui->lb_FP0,ui->lb_FP1,ui->lb_FP2,ui->lb_FP3,ui->lb_FP4,ui->lb_FP5,ui->lb_FP6,ui->lb_FP7,ui->lb_FP8 };
  QCheckBox * cb_fp[] = {ui->cb_FP0,ui->cb_FP1,ui->cb_FP2,ui->cb_FP3,ui->cb_FP4,ui->cb_FP5,ui->cb_FP6,ui->cb_FP7,ui->cb_FP8 };

  setWindowTitle(tr("Edit %1").arg(modelPrinter.printInputName(ed->chn)));
  QRegExp rx(CHAR_FOR_NAMES_REGEX);

  if (IS_TARANIS(GetEepromInterface()->getBoard())) {
    gvWeightGroup = new GVarGroup(ui->weightGV, ui->weightSB, ui->weightCB, ed->weight, 100, -100, 100);
    gvOffsetGroup = new GVarGroup(ui->offsetGV, ui->offsetSB, ui->offsetCB, ed->offset, 0, -100, 100);
  }
  else {
    gvWeightGroup = new GVarGroup(ui->weightGV, ui->weightSB, ui->weightCB, ed->weight, 100, 0, 100);
    gvOffsetGroup = NULL;
    ui->offsetLabel->hide();
    ui->offsetGV->hide();
    ui->offsetSB->hide();
    ui->offsetCB->hide();
  }

  curveGroup = new CurveGroup(ui->curveTypeCB, ui->curveGVarCB, ui->curveValueCB, ui->curveValueSB, ed->curve, 
                              firmware->getCapability(HasInputDiff) ? 0 : (HIDE_DIFF | HIDE_NEGATIVE_CURVES));

  populateSwitchCB(ui->switchesCB, ed->swtch, generalSettings, MixesContext);

  ui->sideCB->setCurrentIndex(ed->mode-1);

  if (!firmware->getCapability(FlightModes)) {
    ui->label_phases->hide();
    for (int i=0; i<9; i++) {
      lb_fp[i]->hide();
      cb_fp[i]->hide();
    }
  }
  else {
    int mask = 1;
    for (int i=0; i<9; i++) {
      if ((ed->flightModes & mask) == 0) {
        cb_fp[i]->setChecked(true);
      }
      mask <<= 1;
    }
    for (int i=firmware->getCapability(FlightModes); i<9; i++) {
      lb_fp[i]->hide();
      cb_fp[i]->hide();
    }
  }

  if (firmware->getCapability(VirtualInputs)) {
    ui->inputName->setMaxLength(4);
    populateSourceCB(ui->sourceCB, ed->srcRaw, generalSettings, &model, POPULATE_NONE | POPULATE_SOURCES | 
                                                  POPULATE_SWITCHES | POPULATE_TRIMS | POPULATE_TELEMETRY);
    ui->sourceCB->removeItem(0);
    ui->inputName->setValidator(new QRegExpValidator(rx, this));
    ui->inputName->setText(inputName);
  }
  else {
    ui->inputNameLabel->hide();
    ui->inputName->hide();
    ui->sourceLabel->hide();
    ui->sourceCB->hide();
    ui->trimLabel->hide();
    ui->trimCB->hide();
  }

  for(int i=0; i < NUM_STICKS; i++) {
    ui->trimCB->addItem(AnalogString(i), i+1);
  }
  ui->trimCB->setCurrentIndex(1 - ed->carryTrim);

  int expolength = firmware->getCapability(HasExpoNames);
  if (!expolength) {
    ui->lineNameLabel->hide();
    ui->lineName->hide();
  }
  else {
    ui->lineName->setMaxLength(expolength);
  }

  ui->lineName->setValidator(new QRegExpValidator(rx, this));
  ui->lineName->setText(ed->name);

  updateScale();
  valuesChanged();

  connect(ui->lineName, SIGNAL(editingFinished()), this, SLOT(valuesChanged()));
  connect(ui->sourceCB, SIGNAL(currentIndexChanged(int)), this, SLOT(valuesChanged()));
  connect(ui->scale, SIGNAL(editingFinished()), this, SLOT(valuesChanged()));
  connect(ui->trimCB, SIGNAL(currentIndexChanged(int)), this, SLOT(valuesChanged()));
  connect(ui->switchesCB, SIGNAL(currentIndexChanged(int)), this, SLOT(valuesChanged()));
  connect(ui->sideCB, SIGNAL(currentIndexChanged(int)), this, SLOT(valuesChanged()));
  for (int i=0; i<9; i++) {
    connect(cb_fp[i], SIGNAL(toggled(bool)), this, SLOT(valuesChanged()));
  }
  if (firmware->getCapability(VirtualInputs))
    connect(ui->inputName, SIGNAL(editingFinished()), this, SLOT(valuesChanged()));

  QTimer::singleShot(0, this, SLOT(shrink()));
}
Пример #14
0
void SimpleChart::init()
{
    // Set the time to zero
    time = sf::Time(sf::Time::Zero);
    // initialize the axis
    xAxis.setOrigin(xAxis.getLocalBounds().width / 2, xAxis.getLocalBounds().height / 2);
    yAxis.setOrigin(yAxis.getLocalBounds().width / 2, yAxis.getLocalBounds().height / 2);
    xAxis.setPosition(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2);
    yAxis.setPosition(WINDOW_WIDTH / 2, WINDOW_HEIGHT / 2);
    yAxis.rotate(90);
    xAxis.setFillColor(AXIS_COLOR);
    yAxis.setFillColor(AXIS_COLOR);

    // Load the fonts
    quicksandFontBold.loadFromFile(QUICKSAND_BOLD_FONT);
    quicksandFontRegular.loadFromFile(QUICKSAND_REGULAR_FONT);

    // Initialize the title
    title.setString(SIMPLE_TITLE_STRING);
    title.setFont(quicksandFontBold);
    title.setPosition(SIMPLE_TITLE_POS_X, SIMPLE_TITLE_POS_Y);
    title.setCharacterSize((uint)SIMPLE_TITLE_SIZE);

    // initialize the function name
    functionName.setString(getFunctionTitle());
    functionName.setFont(quicksandFontRegular);
    functionName.setPosition(SIMPLE_FUNCTION_POS_X, SIMPLE_FUNCTION_POS_Y);
    functionName.setCharacterSize((uint)SIMPLE_FUNCTION_SIZE);

    // initialize the variable names
    for (int i = 0; i < variables.index.size(); i++) {
        sf::Text newVariableName;
        variableNames.push_back(newVariableName);
        variableNames[i].setFont(quicksandFontBold);
        variableNames[i].setPosition(SIMPLE_OPTION_POS_X[i], SIMPLE_OPTION_POS_Y);
        variableNames[i].setCharacterSize((uint)SIMPLE_OPTION_SIZE);

        // Set the string of the variable names
        variableNames[i].setString(SIMPLE_OPTION[variables.index[i]]);
    }

    // initialize the values of the variables
    for (int i = 0; i < variables.index.size(); i++) {
        sf::Text newVariableValue;
        variableValue.push_back(newVariableValue);
        variableValue[i].setFont(quicksandFontRegular);
        variableValue[i].setPosition(SIMPLE_OPTION_POS_X[i], SIMPLE_OPTION_VALUE_POS_Y);
        variableValue[i].setCharacterSize((uint)SIMPLE_OPTION_SIZE);
    }

    // nitialize the annotations
    for (int i = 0; i < 3; i++) {
        sf::Text newAnnotation;
        annotation.push_back(newAnnotation);
        annotation[i].setFont(quicksandFontRegular);
        annotation[i].setString(ANNOTATION[i]);
        annotation[i].setPosition(ANNOTATION_POS_X, ANNOTATION_POS_Y[i]);
        annotation[i].setCharacterSize((uint)ANNOTATION_SIZE);
    }

    // Start the axis with the default scale
    updateScale();
    // Start the points with the default variables and scale
    updatePoints();

    // initialize the selected option
    selected = 0;
}
Пример #15
0
void ElevationProfilePlotAxis::update()
{
    updateTicks();
    updateScale();
}
Пример #16
0
void StackGraph::logic(float t, float dt) {

    if(paused) return;

    if(activeNode==0) return;

    StackNode* clickedNode = mouseOverNode = 0;

    StackNode* nodeAtMouse = activeNode->mouseOverChildren(mousepos);

    if(nodeAtMouse != 0 && !nodeAtMouse->isLoading()) {
        mouseOverNode = nodeAtMouse;
        if(mouseclicked) clickedNode = nodeAtMouse;
    }

    if(clickedNode != 0) {

        selectNode(clickedNode);

    } else if(mouseclicked) {

        vec2f barclick = mousepos - corner;

        //select parent node
        if(section_bounds.contains(barclick)) {
            StackNode* parent = activeNode->getParent();

            if(parent != 0) {
                setActiveNode(parent);
                resetView();
            }
        }
    }

    if(in_transition>0.0) {
        updateTransition(dt);
    }
    else if(alpha < 1.0) {
        alpha = std::min(1.0f, alpha + dt);
    }

    if(last_update > gStackGraphFetchDelay) {
        last_update = 0.0;
//        activeNode->fetchBets();
    }

    last_update += dt;

    //update the scale of the graph
    updateScale(dt);

    //update active node bets
    activeNode->updateBets(dt);

    //time
    char datestr[256];
    long currtime = time(0);
    struct tm* timeinfo = localtime ( &currtime );
    strftime(datestr, 256, "%d/%m/%Y %X", timeinfo);

    displaydate = datestr;

    mouseclicked = false;
}
Пример #17
0
void QgsMapRenderer::adjustExtentToSize()
{
  double myHeight = mSize.height();
  double myWidth = mSize.width();

  QgsMapToPixel newCoordXForm;

  if ( !myWidth || !myHeight )
  {
    mScale = 1.0;
    newCoordXForm.setParameters( 0, 0, 0, 0 );
    return;
  }

  // calculate the translation and scaling parameters
  // mapUnitsPerPixel = map units per pixel
  double mapUnitsPerPixelY = mExtent.height() / myHeight;
  double mapUnitsPerPixelX = mExtent.width() / myWidth;
  mMapUnitsPerPixel = mapUnitsPerPixelY > mapUnitsPerPixelX ? mapUnitsPerPixelY : mapUnitsPerPixelX;

  // calculate the actual extent of the mapCanvas
  double dxmin, dxmax, dymin, dymax, whitespace;

  if ( mapUnitsPerPixelY > mapUnitsPerPixelX )
  {
    dymin = mExtent.yMinimum();
    dymax = mExtent.yMaximum();
    whitespace = (( myWidth * mMapUnitsPerPixel ) - mExtent.width() ) * 0.5;
    dxmin = mExtent.xMinimum() - whitespace;
    dxmax = mExtent.xMaximum() + whitespace;
  }
  else
  {
    dxmin = mExtent.xMinimum();
    dxmax = mExtent.xMaximum();
    whitespace = (( myHeight * mMapUnitsPerPixel ) - mExtent.height() ) * 0.5;
    dymin = mExtent.yMinimum() - whitespace;
    dymax = mExtent.yMaximum() + whitespace;
  }

  QgsDebugMsg( QString( "Map units per pixel (x,y) : %1, %2" ).arg( qgsDoubleToString( mapUnitsPerPixelX ) ).arg( qgsDoubleToString( mapUnitsPerPixelY ) ) );
  QgsDebugMsg( QString( "Pixmap dimensions (x,y) : %1, %2" ).arg( qgsDoubleToString( myWidth ) ).arg( qgsDoubleToString( myHeight ) ) );
  QgsDebugMsg( QString( "Extent dimensions (x,y) : %1, %2" ).arg( qgsDoubleToString( mExtent.width() ) ).arg( qgsDoubleToString( mExtent.height() ) ) );
  QgsDebugMsg( mExtent.toString() );

  // update extent
  mExtent.setXMinimum( dxmin );
  mExtent.setXMaximum( dxmax );
  mExtent.setYMinimum( dymin );
  mExtent.setYMaximum( dymax );

  QgsDebugMsg( QString( "Adjusted map units per pixel (x,y) : %1, %2" ).arg( qgsDoubleToString( mExtent.width() / myWidth ) ).arg( qgsDoubleToString( mExtent.height() / myHeight ) ) );

  QgsDebugMsg( QString( "Recalced pixmap dimensions (x,y) : %1, %2" ).arg( qgsDoubleToString( mExtent.width() / mMapUnitsPerPixel ) ).arg( qgsDoubleToString( mExtent.height() / mMapUnitsPerPixel ) ) );

  // update the scale
  updateScale();

  QgsDebugMsg( QString( "Scale (assuming meters as map units) = 1:%1" ).arg( qgsDoubleToString( mScale ) ) );

  newCoordXForm.setParameters( mMapUnitsPerPixel, dxmin, dymin, myHeight );
  mRenderContext.setMapToPixel( newCoordXForm );
  mRenderContext.setExtent( mExtent );
}
Пример #18
0
void ControlLayer::zoomOut(CCObject* pSender)
{
	m_pControl->zoomOut();
    updateScale();
}