Exemplo n.º 1
0
/**
 * Set up starting values for cached variables
 */
void MDNormSCD::cacheInputs() {
  m_inputWS = getProperty("InputWorkspace");
  if (inputEnergyMode() != "Elastic") {
    throw std::invalid_argument("Invalid energy transfer mode. Algorithm "
                                "currently only supports elastic data.");
  }
  // Min/max dimension values
  const auto hdim(m_inputWS->getDimension(0)), kdim(m_inputWS->getDimension(1)),
      ldim(m_inputWS->getDimension(2));
  m_hmin = hdim->getMinimum();
  m_kmin = kdim->getMinimum();
  m_lmin = ldim->getMinimum();
  m_hmax = hdim->getMaximum();
  m_kmax = kdim->getMaximum();
  m_lmax = ldim->getMaximum();

  const auto &exptInfoZero = *(m_inputWS->getExperimentInfo(0));
  auto source = exptInfoZero.getInstrument()->getSource();
  auto sample = exptInfoZero.getInstrument()->getSample();
  if (source == nullptr || sample == nullptr) {
    throw Kernel::Exception::InstrumentDefinitionError(
        "Instrument not sufficiently defined: failed to get source and/or "
        "sample");
  }
  m_samplePos = sample->getPos();
  m_beamDir = m_samplePos - source->getPos();
  m_beamDir.normalize();
}
Exemplo n.º 2
0
void ScrollBar::setMajorAxisScrollBarPosition(const Pnt2f& Pos)
{

    UInt16 MajorAxis, MinorAxis;
    if(getOrientation() == ScrollBar::VERTICAL_ORIENTATION)
    {
        MajorAxis = 1;
    }
    else
    {
        MajorAxis = 0;
    }
    MinorAxis = (MajorAxis+1)%2;

    //Calculate the Value Based on the Bar Position
    //Int32 ScrollValue( static_cast<Real32>(Pos - editScrollField()->getPosition()[MajorAxis])/static_cast<Real32>(editScrollField()->getSize()[MajorAxis]) * (getMaximum() - getMinimum()) + getMinimum());
    Int32 ScrollValue(calculateValueFromPosition(Pos));
    if(ScrollValue < getMinimum())
    {
        ScrollValue = getMinimum();
    }
    else if(ScrollValue + getExtent() > getMaximum())
    {
        ScrollValue = getMaximum() - getExtent();
    }
    getRangeModel()->setValue(ScrollValue);
}
void FilmstripSlider::paint(Graphics& g)
{
	if (filmStripImage.isValid())
	{
		int value = (int) ((getValue() - getMinimum()) / (getMaximum() - getMinimum()) * (numFrames - 1));

		int imageHeight; 
		int imageWidth;
        
		if (getTextBoxPosition() == TextBoxBelow)
        {
			imageWidth = getWidth() - getTextBoxHeight();
			imageHeight = getHeight() - getTextBoxHeight();
		}
		else
        {
			imageWidth = getWidth();
			imageHeight = getHeight();
		}
		
		if(isHorizontal)
        {
			g.drawImage(filmStripImage, (getWidth() - imageWidth) * 0.5, 0, imageWidth, imageHeight,
						value * frameWidth, 0, frameWidth, frameHeight);
        }
		else
        {
			g.drawImage(filmStripImage, 0, 0, imageWidth, imageHeight,
						0, value * frameHeight, frameWidth, frameHeight);
        }
	}
}
Exemplo n.º 4
0
void Slider::setValue(Int32 n)
{
    if(getSnapToTicks())
    {
        //Determine the closest tickmark to the value we are trying to set

        Int32 Div, Mod;

        Div = (n-getMinimum())/getMinorTickSpacing();
        Mod = (n-getMinimum())%getMinorTickSpacing();

        if(Mod <= getMajorTickSpacing()/2)
        {
            getRangeModel()->setValue(getMinorTickSpacing() * Div + getMinimum());
        }
        else
        {
            getRangeModel()->setValue(getMinorTickSpacing() * (Div + 1) + getMinimum());
        }
    }
    else
    {
        getRangeModel()->setValue(n);
    }

}
Exemplo n.º 5
0
/**
 * Set up starting values for cached variables
 */
void MDNormDirectSC::cacheInputs() {
  m_inputWS = getProperty("InputWorkspace");
  bool skipCheck = getProperty("SkipSafetyCheck");
  if (!skipCheck && (inputEnergyMode() != "Direct")) {
    throw std::invalid_argument("Invalid energy transfer mode. Algorithm only "
                                "supports direct geometry spectrometers.");
  }
  // Min/max dimension values
  const auto hdim(m_inputWS->getDimension(0)), kdim(m_inputWS->getDimension(1)),
      ldim(m_inputWS->getDimension(2)), edim(m_inputWS->getDimension(3));
  m_hmin = hdim->getMinimum();
  m_kmin = kdim->getMinimum();
  m_lmin = ldim->getMinimum();
  m_dEmin = edim->getMinimum();
  m_hmax = hdim->getMaximum();
  m_kmax = kdim->getMaximum();
  m_lmax = ldim->getMaximum();
  m_dEmax = edim->getMaximum();

  const auto &exptInfoZero = *(m_inputWS->getExperimentInfo(0));
  auto source = exptInfoZero.getInstrument()->getSource();
  auto sample = exptInfoZero.getInstrument()->getSample();
  if (source == nullptr || sample == nullptr) {
    throw Kernel::Exception::InstrumentDefinitionError(
        "Instrument not sufficiently defined: failed to get source and/or "
        "sample");
  }
  m_samplePos = sample->getPos();
  m_beamDir = m_samplePos - source->getPos();
  m_beamDir.normalize();

  double originaldEmin = exptInfoZero.run().getBinBoundaries().front();
  double originaldEmax = exptInfoZero.run().getBinBoundaries().back();
  if (exptInfoZero.run().hasProperty("Ei")) {
    Kernel::Property *eiprop = exptInfoZero.run().getProperty("Ei");
    m_Ei = boost::lexical_cast<double>(eiprop->value());
    if (m_Ei <= 0) {
      throw std::invalid_argument("Ei stored in the workspace is not positive");
    }
  } else {
    throw std::invalid_argument("Could not find Ei value in the workspace.");
  }
  double eps = 1e-7;
  if (m_Ei - originaldEmin < eps) {
    originaldEmin = m_Ei - eps;
  }
  if (m_Ei - originaldEmax < eps) {
    originaldEmax = m_Ei - 1e-7;
  }
  if (originaldEmin == originaldEmax) {
    throw std::runtime_error("The limits of the original workspace used in "
                             "ConvertToMD are incorrect");
  }
  const double energyToK = 8.0 * M_PI * M_PI * PhysicalConstants::NeutronMass *
                           PhysicalConstants::meV * 1e-20 /
                           (PhysicalConstants::h * PhysicalConstants::h);
  m_ki = std::sqrt(energyToK * m_Ei);
  m_kfmin = std::sqrt(energyToK * (m_Ei - originaldEmin));
  m_kfmax = std::sqrt(energyToK * (m_Ei - originaldEmax));
}
Exemplo n.º 6
0
	void Scrollbar::paint(Graphics* g)
	{
		int w = getWidth();
		int h = getHeight();
		
		// 外枠
		g->setColor(Color::gray);
		g->fillRect(0, 0, w, h);
		g->setColor(Color::black);
		g->drawRect(0, 0, w, h);
		
		// 非活性のときはボタンを描画しない
		// 最大値と最小値が等しいときはボタンを描画しない
		if (getEnabled() == false || (getMaximum() - getMinimum()) == 0) return;
		
		// 垂直スクロールバー
		if (this->orientation == VERTICAL) {
			// 上向き矢印
			for (int i = 0; i < 16; i++) {
				for (int j = 0; j < 16; j++) {
					g->drawPixel(j, i, arrow_palette[arrow1_data[i * 16 + j] & 0xFF]);
				}
			}
			// 下向き矢印
			for (int i = 0; i < 16; i++) {
				for (int j = 0; j < 16; j++) {
					g->drawPixel(j, i + h - 16, arrow_palette[arrow2_data[i * 16 + j] & 0xFF]);
				}
			}
			// ボタン
			int offset = 15 + (h - 47) * (getValue() - getMinimum()) / (getMaximum() - getMinimum());
			for (int i = 0; i < 17; i++) {
				for (int j = 0; j < 16; j++) {
					g->drawPixel(j, i + offset, button_palette[button_data[i * 16 + j] & 0xFF]);
				}
			}
		// 水平スクロールバー
		} else {
			// 左向き矢印
			for (int i = 0; i < 16; i++) {
				for (int j = 0; j < 16; j++) {
					g->drawPixel(i, j, arrow_palette[arrow1_data[i * 16 + j] & 0xFF]);
				}
			}
			// 右向き矢印
			for (int i = 0; i < 16; i++) {
				for (int j = 0; j < 16; j++) {
					g->drawPixel(i + w - 16, j, arrow_palette[arrow2_data[i * 16 + j] & 0xFF]);
				}
			}
			// ボタン
			int offset = 15 + (w - 47) * (getValue() - getMinimum()) / (getMaximum() - getMinimum());
			for (int i = 0; i < 17; i++) {
				for (int j = 0; j < 16; j++) {
					g->drawPixel(i + offset, j, button_palette[button_data[i * 16 + j] & 0xFF]);
				}
			}
		}
	}
Exemplo n.º 7
0
//Obtains the turn direction of the minimum value sensor.
enum TurnDirection getTurnDirectionOfSmallestVarianceSensor()
{
    WbDeviceTag leftSideTags[] = {ls0, ls1, ls2, ls3};
    WbDeviceTag rightSideTags[] = {ls4, ls5, ls6, ls7};
    double leftSideMin = getMinimum(4, leftSideTags);
    double rightSideMin = getMinimum(4, rightSideTags);
    
    enum TurnDirection direction = RIGHT;
    if(leftSideMin > rightSideMin)
        direction = LEFT;
        
    return direction;      
}
Exemplo n.º 8
0
	void ProgressBar::setValue(int v)
	{
		if(v < getMinimum())
		{
			value = getMinimum();
		}
		else if(v > getMaximum())
		{
			value = getMaximum();
		}
		else
		{
			value = v;
		}
	}
Exemplo n.º 9
0
        inline bool IntersectWithLine( const Vector3& rayOrigin, Vector3 rayDirection, float &distanceToFrontCollisionOfCube , float &distanceToBackCollisionOfCube ) const
        {
            rayDirection.x = ( rayDirection.x == 0.f ) ? 0.0000001f : rayDirection.x;
            rayDirection.y = ( rayDirection.y == 0.f ) ? 0.0000001f : rayDirection.y;
            rayDirection.z = ( rayDirection.z == 0.f ) ? 0.0000001f : rayDirection.z;
        	Vector3 divisor = 1.f / rayDirection;
        	Vector3 oMin = (m_Min - rayOrigin) * divisor;
        	Vector3 oMax = (m_Max - rayOrigin) * divisor;
        	Vector3 bMax = VectorMax(oMax, oMin);
        	Vector3 bMin = VectorMin(oMax, oMin);
        	distanceToBackCollisionOfCube   = getMinimum(bMax.x, bMax.y, bMax.z);
        	distanceToBackCollisionOfCube   = getMinimum(bMax.x, bMax.y, bMax.z);
        	distanceToFrontCollisionOfCube = getMaximum(bMin.x, 0.0f, bMin.y, bMin.z );

        	return distanceToBackCollisionOfCube > distanceToFrontCollisionOfCube;
        }
Exemplo n.º 10
0
//==============================================================================
void Knob::paint(Graphics& g)
{
    g.fillAll(Colours::white);

    g.setColour(Colours::black);

    if( image.isValid() ) {
        double range = getMaximum() - getMinimum();
        int numImagePics = image.getWidth() / singleImageWidth;
        int imageOffset = singleImageWidth * (int)((numImagePics-1) * getValue()/range);

        g.drawImage(image,
                    0, 0, singleImageWidth, singleImageHeight,
                    imageOffset, 0, singleImageWidth, singleImageHeight,
                    false);
    }
#if JUCE_MAJOR_VERSION==1 && JUCE_MINOR_VERSION<51
    g.setFont(Font(Typeface::defaultTypefaceNameSans, 13.0, 0));
#else
    g.setFont(Font(Font::getDefaultSansSerifFontName(), 13.0, 0));
#endif
    g.setColour(Colours::white);
    g.drawText(getName(), 0, singleImageHeight-16, singleImageWidth, 16, Justification::verticallyCentred | Justification::horizontallyCentred, true);

}
Exemplo n.º 11
0
void Slider::updateSliderTrack(void)
{
    Pnt2f BorderTopLeft, BorderBottomRight;
    getInsideInsetsBounds(BorderTopLeft, BorderBottomRight);

    UInt16 MajorAxis, MinorAxis;
    if(getOrientation() == VERTICAL_ORIENTATION)
    {
        MajorAxis = 1;
    }
    else
    {
        MajorAxis = 0;
    }
    MinorAxis = (MajorAxis+1)%2;

    //Update the Knob position
    if(getKnobButton() != NULL && getRangeModel() != NULL)
    {
        Vec2f Size;
        Size[MinorAxis] = getKnobButton()->getPreferredSize().x();
        Size[MajorAxis] = getKnobButton()->getPreferredSize().y();
        Pnt2f AlignedPosition;
        //Size[MajorAxis] = getSize()[MajorAxis] - 2;
        Vec2f Alignment(0.5,0.5);
        Alignment[MajorAxis] = static_cast<Real32>(getValue() - getMinimum())/static_cast<Real32>(getMaximum() - getMinimum());

        AlignedPosition = calculateSliderAlignment(getSliderTrackTopLeft(), getSliderTrackSize(), getKnobButton()->getPreferredSize(), Alignment.y(), Alignment.x());

        getKnobButton()->setPosition(AlignedPosition);
        getKnobButton()->setSize(Size);
    }

}
Exemplo n.º 12
0
void CompasCommand::Run(list<string>* parameters, Game * game)
{
	distance.clear();
	unsettledRooms.clear();
	settledRooms.clear();
	predecessors.clear();

	Room* startRoom = game->getPlayer()->getCurrentRoom();
	distance.insert(std::pair<Room*, int>(startRoom, 0));
	unsettledRooms.push_back(startRoom);
	while (!unsettledRooms.empty()) {
		Room* room = getMinimum(unsettledRooms);
		settledRooms.push_back(room);

		for (int i = 0; i < unsettledRooms.size(); i++) { //remove room from unsettledRooms
			if (unsettledRooms[i] == room) {
				unsettledRooms.erase(unsettledRooms.begin() + i);
			}
		}

		findMinimalDistances(room);
	}

	getPath(game->getLevel()->getStairRoom());

	//delete startRoom;
}
Exemplo n.º 13
0
bool TimeWarp::extendAlignmentAlong(const int& endIndexX, DoubleMatrix* alignmentMatrix){
	DoubleVector d;
	//firstMatrix.size()
	int widthSize = (*alignmentMatrix).size();
	if (widthSize < endIndexX){//firstMatrix.size()
		//then we can extend along
		double value = getDistance(widthSize, 0);
		value += getRestrictedMinimum(widthSize, 0, value, 0, 0);
		
		d.push_back(value);
		(*alignmentMatrix).push_back(d);
		
		for (int j = 1;j < (*alignmentMatrix)[widthSize - 1].size();j++){
			value = getDistance(widthSize, j);
			value += getMinimum(widthSize, j, value);
			(*alignmentMatrix)[widthSize].push_back(value);
		}
		
	}
	
	if ((*alignmentMatrix).size() == endIndexX)
		return true;
	else
		return false;
	
}
Exemplo n.º 14
0
void MoveAwayForFineAdjustmentSlider::handleDragWithFineAdjustmentFurtherAway (const MouseEvent& e)
{
    // y position of the mouse
    // -----------------------
    const float mousePos = e.position.y;
    const float mousePosDifference = mousePos - lastMousePos;
    
    // A mousePosDifference > 0 (measured from the top to the bottom) means that
    // the value (which is measured from the bottom to the top) needs to be decreased.
    // That's the reason for the negation.
    // The max absolute value of posDifference is 1.
    double posDifference = - mousePosDifference / (double) sliderRegionSize;
    
    // x position of the mouse
    // -----------------------
    const float horizontalMousePosDifference =  std::abs (e.position.x - mouseDragStartPos.x);
    const float horizontalOffset = 20.0f;
    // If the current mouse position e.position.x is in the interval
    // [mouseDragStartPos.x - horizontalOffset, mouseDragStartPos.x + horizontalOffset]
    // there won't be a decrease of the slider movement.
    const float minimizingFactor = horizontalMousePosDifference < horizontalOffset ?
        1.0f
        : 1.0f / (0.1f * (horizontalMousePosDifference - horizontalOffset) + 1.0f);
    
    // Set valueWhenLastDragged
    // ------------------------
    valueWhenLastDragged = jlimit(getMinimum(), getMaximum(), valueWhenLastDragged + (getMaximum() - getMinimum()) * (posDifference * minimizingFactor));
    
    lastMousePos = mousePos;
}
Exemplo n.º 15
0
void ThresholdSlider::paint(Graphics& g)
{

    ColourGradient grad = ColourGradient(Colour(40, 40, 40), 0.0f, 0.0f,
                                         Colour(80, 80, 80), 0.0, 40.0f, false);

    Path p;
    p.addPieSegment(3, 3, getWidth()-6, getHeight()-6, 5*double_Pi/4-0.2, 5*double_Pi/4+3*double_Pi/2+0.2, 0.5);

    g.setGradientFill(grad);
    g.fillPath(p);

    String valueString;

    if (isActive)
    {
        p = makeRotaryPath(getMinimum(), getMaximum(), getValue());
        g.setColour(Colour(240,179,12));
        g.fillPath(p);

        valueString = String((int) getValue());
    }
    else
    {

        valueString = "";

        for (int i = 0; i < valueArray.size(); i++)
        {
            p = makeRotaryPath(getMinimum(), getMaximum(), valueArray[i]);
            g.setColour(Colours::lightgrey.withAlpha(0.4f));
            g.fillPath(p);
            valueString = String((int) valueArray.getLast());
        }

    }

    font.setHeight(9.0);
    g.setFont(font);
    int stringWidth = font.getStringWidth(valueString);

    g.setFont(font);

    g.setColour(Colours::darkgrey);
    g.drawSingleLineText(valueString, getWidth()/2 - stringWidth/2, getHeight()/2+3);

}
Exemplo n.º 16
0
float AssociatedSlider::getLinearNormalizedValue()
{
	float rawMin = getMinimum();
	float rawMax = getMaximum();
	
	return (getValue() - rawMin) / (rawMax - rawMin);

}
Exemplo n.º 17
0
void SynthSlider::mouseDown(const MouseEvent& e) {
  SynthGuiInterface* parent = findParentComponentOfClass<SynthGuiInterface>();

  if (e.mods.isPopupMenu()) {
    PopupMenu m;

    if (isDoubleClickReturnEnabled())
      m.addItem(kDefaultValue, "Set to Default Value");

    std::vector<mopo::ModulationConnection*> connections;
    if (parent) {
      m.addItem(kArmMidiLearn, "Learn MIDI Assignment");
      if (parent->isMidiMapped(getName().toStdString()))
        m.addItem(kClearMidiLearn, "Clear MIDI Assignment");

      connections = parent->getDestinationConnections(getName().toStdString());

      String disconnect("Disconnect from ");
      for (int i = 0; i < connections.size(); ++i)
        m.addItem(kModulationList + i, disconnect + connections[i]->source);

      if (connections.size() > 1)
        m.addItem(kClearModulations, "Disconnect all modulations");
    }

    int result = m.show();
    if (result == kArmMidiLearn) {
      parent->armMidiLearn(getName().toStdString(), getMinimum(), getMaximum());
    }
    else if (result == kClearMidiLearn) {
      parent->clearMidiLearn(getName().toStdString());
    }
    else if (result == kDefaultValue) {
      setValue(getDoubleClickReturnValue());
    }
    else if (result == kClearModulations) {
      for (mopo::ModulationConnection* connection : connections) {
        std::string source = connection->source;
        parent->disconnectModulation(connection);
      }
    }
    else if (result >= kModulationList) {
      int connection_index = result - kModulationList;
      std::string source = connections[connection_index]->source;
      parent->disconnectModulation(connections[connection_index]);
    }
  }
  else {
    Slider::mouseDown(e);

    if (parent)
      parent->beginChangeGesture(getName().toStdString());
    if (isRotary()) {
      click_position_ = e.getScreenPosition().toFloat();
      setMouseCursor(MouseCursor::NoCursor);
    }
  }
}
C GFBinarySearchTree< C >::remove( C container ) {
    GFBinarySearchTreeNode< C > * father = 0;
    GFBinarySearchTreeNode< C > * node = head;
    C tmpData = 0;
    C tmpData2 = 0;
    int compare;

    while( node ) {
        compare = container->compare( node->getData() );
        //if( container == *node->getData() ) {
        if( compare == 0 ) {
            if( node->childrenNumber() == 2 ) {
                tmpData = remove( getMinimum( node->getLeft() )->getData() );
                tmpData2 = node->getData();
                node->setData( tmpData );
                return( tmpData2 );
            }
            else if( node->childrenNumber() == 1 ) {
                if( father ) {
                    if( father->getLeft() == node ) father->setLeft( node->getTheChild() );
                    else father->setRight( node->getTheChild() );
                }
                else {
                    head = node->getTheChild();
                }
                tmpData = node->getData();
                delete( node );
                return( tmpData );
            }
            else {
                if( father ) {
                    if( father->getLeft() == node ) father->setLeft( 0 );
                    else father->setRight( 0 );
                }
                else {
                    head = 0;
                }
                tmpData = node->getData();
                delete( node );
                return( tmpData );
            }
        }
        //else if( container > *node->getData() ) {
        else if( compare > 0 ) {
            father = node;
            node = node->getLeft();
            continue;
        }
        //else if( container < *node->getData() ) {
        else if( compare < 0 ) {
            father = node;
            node = node->getRight();
            continue;
        }
    }

    return( 0 );
}
Exemplo n.º 19
0
/**
 * Returns a time for a time slice
 * @param workspace: the workspace
 * @return either the first time entry in case of a 4D workspace or else 0.0
 */
double SaveMDWorkspaceToVTKImpl::selectTimeSliceValue(
    const Mantid::API::IMDWorkspace &workspace) const {
  double time = 0.0;
  if (is4DWorkspace(workspace)) {
    auto timeLikeDimension = workspace.getDimension(3);
    time = static_cast<double>(timeLikeDimension->getMinimum());
  }
  return time;
}
Exemplo n.º 20
0
void XIntegrationControl::setMaximum()
{
  bool ok;
  QString text = m_maxText->text();
  double maxValue = text.toDouble(&ok);
  if (!ok) return;
  double minValue = getMinimum();
  setRange(minValue,maxValue);
}
Exemplo n.º 21
0
	int getMinimum(int start, int end, int position = 1, int rootStart = 0, int rootEnd = SIZE - 1)
	{
		if(start == rootStart && end == rootEnd)
			return data[position];

		int middle = (rootStart + rootEnd) / 2;
		if(end <= middle)
			return getMinimum(start, end, position * 2, rootStart, middle);

		if(start > middle)
			return getMinimum(start, end, position * 2 + 1, middle + 1, rootEnd);

		int a = getMinimum(start, middle, position * 2, rootStart, middle),
			b = getMinimum(middle + 1, end, position * 2 + 1, middle + 1, rootEnd);

		if(element[a] < element[b])
			return a;

		return b;
	}
Exemplo n.º 22
0
  void NavigationInputGeometry::calculateExtents( const OgreItemVector& entities )
  {
    auto entity = entities[0];
    auto bbox = entity->getLocalAabb();

    Matrix4 transform = mReferenceNode->_getFullTransformUpdated().inverse() * entity->getParentSceneNode()->_getFullTransformUpdated();
    assert( transform.isAffine() );
    bbox.transformAffine( transform );

    Vector3 bbmin = bbox.getMinimum();
    Vector3 bbmax = bbox.getMaximum();

    for ( auto iterator : entities )
    {
      entity = iterator;
      bbox = entity->getLocalAabb();
      transform = mReferenceNode->_getFullTransformUpdated().inverse() * entity->getParentSceneNode()->_getFullTransformUpdated();
      assert( transform.isAffine() );
      bbox.transformAffine( transform );

      Vector3 min2 = bbox.getMinimum();
      if ( min2.x < bbmin.x )
        bbmin.x = min2.x;
      if ( min2.y < bbmin.y )
        bbmin.y = min2.y;
      if ( min2.z < bbmin.z )
        bbmin.z = min2.z;

      Vector3 max2 = bbox.getMaximum();
      if ( max2.x > bbmax.x )
        bbmax.x = max2.x;
      if ( max2.y > bbmax.y )
        bbmax.y = max2.y;
      if ( max2.z > bbmax.z )
        bbmax.z = max2.z;
    }

    Math::ogreVec3ToFloatArray( bbmin, mBBoxMin );
    Math::ogreVec3ToFloatArray( bbmax, mBBoxMax );
  }
Exemplo n.º 23
0
	void Slider::setValue(float v)
	{
		if(v < getMinimum())
		{
			value = getMinimum();
		}
		else if(v > getMaximum())
		{
			value = getMaximum();
		}
		else
		{
			value = v;
		}

		event::ChangeListenerList::iterator iter;

		for(iter = changeListenerList.begin(); iter != changeListenerList.end(); ++iter)
		{
			(*iter)->stateChanged(event::ChangeEvent(this,event::ChangeEvent::RANGE));
		}
	}
Exemplo n.º 24
0
/**
 * Calculate_displacement calculates the displacement between two histograms
 * @param[in] *edge_histogram  The edge histogram from the current frame_step
 * @param[in] *edge_histogram_prev  The edge histogram from the previous frame_step
 * @param[in] *displacement array with pixel displacement of the sequential edge histograms
 * @param[in] size  Indicating the size of the displacement array
 * @param[in] window Indicating the search window size
 * @param[in] disp_range  Indicating the maximum disparity range for the block matching
 * @param[in] der_shift  The pixel shift estimated by the angle rate of the IMU
 */
void calculate_edge_displacement(int32_t *edge_histogram, int32_t *edge_histogram_prev, int32_t *displacement,
                                 uint16_t size,
                                 uint8_t window, uint8_t disp_range, int32_t der_shift)
{
  int32_t c = 0, r = 0;
  uint32_t x = 0;
  uint32_t SAD_temp[2 * DISP_RANGE_MAX + 1]; // size must be at least 2*D + 1

  int32_t W = window;
  int32_t D = disp_range;


  uint8_t SHIFT_TOO_FAR = 0;
  memset(displacement, 0, sizeof(int32_t)*size);

  int32_t border[2];

  if (der_shift < 0) {
    border[0] =  W + D + der_shift;
    border[1] = size - W - D;
  } else if (der_shift > 0) {
    border[0] =  W + D;
    border[1] = size - W - D - der_shift;
  } else {
    border[0] =  W + D;
    border[1] = size - W - D;
  }

  if (border[0] >= border[1] || abs(der_shift) >= 10) {
    SHIFT_TOO_FAR = 1;
  }
  {
    // TODO: replace with arm offset subtract
    for (x = border[0]; x < border[1]; x++) {
      displacement[x] = 0;
      for (c = -D; c <= D; c++) {
        SAD_temp[c + D] = 0;
        for (r = -W; r <= W; r++) {
          SAD_temp[c + D] += abs(edge_histogram[x + r] - edge_histogram_prev[x + r + c + der_shift]);
        }
      }
      if (!SHIFT_TOO_FAR) {
        displacement[x] = (int32_t)getMinimum(SAD_temp, 2 * D + 1) - D;
      } else {
        displacement[x] = 0;
      }
    }
  }

}
Exemplo n.º 25
0
void MainVerticalSlider::paint(Graphics& g){
    if (getImage() == nullptr){
        Slider::paint(g);
    }else{
        double slider_range = getMaximum() - getMinimum();
        double values_per_frame = slider_range / getNumFrames();
        double pixels_per_frame = getImage()->getHeight() / getNumFrames();
        int frame = getValue() / values_per_frame;
        if (frame >= getNumFrames()) frame=getNumFrames()-1;
        
        g.drawImage(*getImage(), 0, 0, getWidth(), getHeight(), 
                    0, frame*pixels_per_frame, getImage()->getWidth(), pixels_per_frame);
    }       
}
Exemplo n.º 26
0
IMDHistoWorkspace_sptr ReflectometryTransform::executeMDNormPoly(
    MatrixWorkspace_const_sptr inputWs) const {

  auto input_x_dim = inputWs->getXDimension();

  MDHistoDimension_sptr dim0 = MDHistoDimension_sptr(new MDHistoDimension(
      input_x_dim->getName(), input_x_dim->getDimensionId(),
      input_x_dim->getMDFrame(),
      static_cast<Mantid::coord_t>(input_x_dim->getMinimum()),
      static_cast<Mantid::coord_t>(input_x_dim->getMaximum()),
      input_x_dim->getNBins()));

  auto input_y_dim = inputWs->getYDimension();

  MDHistoDimension_sptr dim1 = MDHistoDimension_sptr(new MDHistoDimension(
      input_y_dim->getName(), input_y_dim->getDimensionId(),
      input_y_dim->getMDFrame(),
      static_cast<Mantid::coord_t>(input_y_dim->getMinimum()),
      static_cast<Mantid::coord_t>(input_y_dim->getMaximum()),
      input_y_dim->getNBins()));

  auto outWs = boost::make_shared<MDHistoWorkspace>(dim0, dim1);

  for (size_t nHistoIndex = 0; nHistoIndex < inputWs->getNumberHistograms();
       ++nHistoIndex) {
    const MantidVec X = inputWs->readX(nHistoIndex);
    const MantidVec Y = inputWs->readY(nHistoIndex);
    const MantidVec E = inputWs->readE(nHistoIndex);

    for (size_t nBinIndex = 0; nBinIndex < inputWs->blocksize(); ++nBinIndex) {
      auto value_index = outWs->getLinearIndex(nBinIndex, nHistoIndex);
      outWs->setSignalAt(value_index, Y[nBinIndex]);
      outWs->setErrorSquaredAt(value_index, E[nBinIndex] * E[nBinIndex]);
    }
  }
  return outWs;
}
Exemplo n.º 27
0
/**
 * \return A vector with the minimum components from the given vectors.
 * These might be mixed components from all vectors.
 */
RVector RVector::getMinimum(const QList<RVector>& vectors) {
    if (vectors.size() == 0) {
        return RVector();
    }

    RVector ret = vectors[0];

    QList<RVector>::const_iterator it = vectors.begin();
    it++;
    for (; it != vectors.end(); it++) {
        ret = getMinimum(ret, *it);
    }

    return ret;
}
Exemplo n.º 28
0
void MoveAwayForFineAdjustmentSlider::mouseDrag (const MouseEvent& e)
{
    DragMode dragMode = notDragging;
    
    const int indent = getLookAndFeel().getSliderThumbRadius(*this);
    int sliderRegionSize = jmax (1, getHeight() - indent * 2);
        
    if (isAbsoluteDragMode (e.mods) || (getMaximum() - getMinimum()) / sliderRegionSize < getInterval())
    {
        dragMode = absoluteDrag;
        // handleAbsoluteDrag (e);
        handleDragWithFineAdjustmentFurtherAway (e); // This sets the valueWhenLastDragged
        
        valueWhenLastDragged = jlimit (getMinimum(), getMaximum(), valueWhenLastDragged);
        
        setValue (snapValue (valueWhenLastDragged, dragMode),
                  sendChangeOnlyOnRelease ? dontSendNotification : sendNotificationSync);
            // This calls pimpl->setValue()
    }
    else
    {
        Slider::mouseDrag(e);
    }
}
Exemplo n.º 29
0
	void Scrollbar::processEvent(Event* event)
	{
		// 非活性の時はイベントを受け付けない
		if (getEnabled() == false) return;
		if (event->getType() == MouseEvent::MOUSE_PRESSED) {
			MouseEvent* me = (MouseEvent *)event;
			int mx = me->getX();
			int my = me->getY();
			// 垂直スクロールバー
			if (this->orientation == VERTICAL) {
				if (0 < my && my < 16) {
					setValue(this->value - this->blocksize);
				} else if (getHeight() - 16 < my && my < getHeight()) {
					setValue(this->value + this->blocksize);
				}
			// 水平スクロールバー
			} else {
				if (0 < mx && mx < 16) {
					setValue(this->value - this->blocksize);
				} else if (getWidth() - 16 < mx && mx < getWidth()) {
					setValue(this->value + this->blocksize);
				}
			}
		} else if (event->getType() == MouseEvent::MOUSE_DRAGGED) {
			MouseEvent* me = (MouseEvent *)event;
			int mx = me->getX();
			int my = me->getY();
			// 垂直スクロールバー
			if (this->orientation == VERTICAL && 16 <= my && my <= getHeight() - 16) {
				setValue((my - 16) * (getMaximum() - getMinimum()) / (getHeight() - 32) + getMinimum());
			// 水平スクロールバー
			} else if (this->orientation == HORIZONTAL && 16 <= mx && mx <= getWidth() - 16) {
				setValue((mx - 16) * (getMaximum() - getMinimum()) / (getWidth() - 32) + getMinimum());
			}
		}
	}
Exemplo n.º 30
0
void MoveAwayForFineAdjustmentSlider::mouseDown (const MouseEvent& e)
{
    Slider::mouseDown(e);
    
    mouseDragStartPos = e.position;
    
    if (isEnabled())
    {
        if (getMaximum() > getMinimum())
        {
            valueOnMouseDown = getValue();
            valueWhenLastDragged = getValue();
            lastMousePos = e.position.y;
        }
    }
}