Ejemplo n.º 1
0
	void TMenuItem::paintAt(Graphics* g, int x, int y) {
		switch (type) {
			case TYPE_ITEM:
				if (getEnabled()) {
					if (getFocused()) {
						g->setColor(Color::blue);
						g->drawRect(x, y, getWidth(), getHeight());
						g->setColor(COLOR_BLUEGRAY);
						g->fillRect(x + 1, y + 1, getWidth() - 2, getHeight() - 2);
					} else {
						g->setColor(getBackground());
						g->fillRect(x, y, getWidth(), getHeight());
					}
					g->setColor(getForeground());
					g->drawString(title, x + 10, y + 3);
				} else {
					g->setColor(getBackground());
					g->fillRect(x, y, getWidth(), getHeight());
					g->setColor(Color::gray);
					g->drawString(title, 10 + x, 3 + y);
				}
				break;
			case TYPE_SEPARATOR:
				g->setColor(getForeground());
				g->drawLine(x + 5, y + 3, x + getWidth() - 5, y + 3);
				break;
			default:
				break;
		}
	}
Ejemplo n.º 2
0
bool ZSwcSignalFitter::fitSignal(
    Swc_Tree_Node *tn, const ZStack *stack, int channel)
{
  bool succ = false;
  if (tn != NULL && stack != NULL) {
    if (SwcTreeNode::isRegular(tn) && stack->channelNumber() > channel) {
      ZPoint oldCenter = SwcTreeNode::center(tn);

      const Stack *stackData = stack->c_stack(channel);
      SwcTreeNode::translate(tn, -stack->getOffset());
      if (!SwcTreeNode::fitSignal(tn, stackData, getBackground())) {
        succ = SwcTreeNode::fitSignal(
              tn, stackData, getBackground(), 2);
      } else {
        succ = true;
      }
      SwcTreeNode::translate(tn, stack->getOffset());

      if (m_fixingTerminal) {
        if (SwcTreeNode::isTerminal(tn)) {
          SwcTreeNode::setPos(tn, oldCenter);
        }
      }
    }
  }

  return succ;
}
Ejemplo n.º 3
0
void JAbout::paint(JGraphics g) {
  JCanvas::paint(g);
  int delta = 20;
  JRect rect(0, 0, width, height);
  g.draw3DJRect(rect.shrink(delta, delta), -depth);
  JString text = getText();
  if (text.length()) {
    JFontMetrics fm(g);
    int dx, dy;
    JColor c[14] = { 
      JColor::red, JColor::white, 
      JColor::magenta.darker(), JColor::yellow,
      JColor::orange, JColor::blue,
      JColor::pink, JColor::magenta,
      JColor::orange,
	  JColor::green.darker(),
	  JColor::blue,
	  JColor::magenta.darker(),
	  JColor::blue,
	  JColor::yellow };
    dy = (height-fm.getHeight())/2;
    dx = (width-fm.stringWidth(text))/2;
    g.setJColor(getBackground().brighter());
    g.drawJString(text, dx+1, dy+1);
    g.setJColor(getBackground().darker());
    g.drawJString(text, dx-1, dy-1);
    for (int i=0; i<14; i++) {
      JString ch = text(i, i+1);
      g.setJColor(c[i]);
      g.drawJString(ch, dx, dy);
      dx += fm.stringWidth(ch);
    }
  }
}
Ejemplo n.º 4
0
	CloudAtlasControlWindow::CenterWidget::CenterWidget(const std::string& name, float w)
		:osgWidget::Table(name, 3, 1)
		, _centerWidth(w)
	{
		getBackground()->setColor(0.0f, 0.0f, 0.0f, 0.0f);
		getBackground()->setEventMask(osgWidget::EVENT_NONE);
	}
Ejemplo n.º 5
0
//------------------------------------------------------------------------
void CMultiStateButton::draw(CDrawContext* pContext)
{
    long off;

    if (getBackground())
        off = (long)(nStates * heightOfOneState * value);
    else
        off = 0;

    if (getBackground()) {
        if (getTransparency())
            getBackground()->draw(pContext, size, CPoint(0, off), 0.f);
        else
            getBackground()->draw(pContext, size, CPoint(0, off));
    } else {
        if (value)
            pContext->setFillColor(kRedCColor);
        else
            pContext->setFillColor(kGreenCColor);

        pContext->drawRect(size);

        pContext->setFrameColor(kWhiteCColor);

        if (value)
            pContext->drawString("on", size);
        else
            pContext->drawString("off", size);
    }
    setDirty(false);
}
Ejemplo n.º 6
0
void GameLayer::update(float dt) {
    if (tapDown) {
        if ( ! hero->getAwake()) {
            hero->wake();
            tapDown = false;
        } else {
            hero->dive();
        }
    }
    
    hero->limitVelocity();

    int32 velocityIterations = 8;
    int32 positionIterations = 3;
    world->Step(dt, velocityIterations, positionIterations);
    
    hero->updateNodePosition();
    
    float scale = (screenH*4/5) / hero->getPosition().y;
    if (scale > 1) scale = 1;
    terrain->setScale(scale);
    terrain->setOffsetX(hero->getPosition().x);
    
    CCSize size = getBackground()->getTextureRect().size;
    getBackground()->setTextureRect(CCRectMake(getTerrain()->getOffsetX()*0.2f, 0, size.width, size.height));
}
Ejemplo n.º 7
0
	void CloudAtlasControlWindow::initWindow(osgWidget::WindowManager* wm, TemperatureProbeLayer* tLayer, WindowThemeSettings wts)
	{
		setZRange(1.0f);
		_obWM = wm;
		getBackground()->setColor(osgWidget::Color(0, 0, 0, 0));
		getBackground()->setEventMask(osgWidget::EVENT_NONE);
		_wts = wts;
		osgWidget::Table* centerTable = new osgWidget::Table("CenterTable", 2, 1);
		centerTable->getBackground()->setColor(osgWidget::Color(0, 0, 0, 0));
		_centerWidget = new CenterWidget("CloudAtlasCenterWidget", _windowWidth);
		float centerHeight = _centerWidget->buildCenterWidget(tLayer);
		osgWidget::point_type cw = wts._left;
		osgWidget::point_type ch = wts._bottom;
		osgWidget::point_type w = _windowWidth - cw - wts._right;
		osgWidget::point_type h = centerHeight + wts._topTitleHeight;
		osgWidget::Window::EmbeddedWindow* centerEW = new osgWidget::Window::EmbeddedWindow("CenterTableEmbedded", _windowWidth, h);
		centerEW->setCanFill(true);
		centerEW->setLayer(osgWidget::Widget::LAYER_MIDDLE);
		centerEW->setEventMask(osgWidget::EVENT_ALL);
		centerEW->setColor(1, 1, 1, 1);
		centerEW->setImage(wts._bgImage, true);
		addWidget(centerEW, 1, 1);

		osgWidget::Window::EmbeddedWindow* centerWidget = _centerWidget->embed("CenterEmbeddedWindow");
		centerWidget->setEventMask(osgWidget::EVENT_ALL);
		centerWidget->setColor(0, 0, 0, 0);
		centerTable->addWidget(centerWidget, 0, 0);
		_topTitleWidget = new VirtualDataSceneWidget::TopTitleWidget("TopTitle", _windowWidth, wts._topTitleHeight, wts._topTitleImage, wts._topCloseButtonImage);
		osgWidget::Window::EmbeddedWindow* topBorderWidget = _topTitleWidget->embed("TopTitleEmbedded");
		topBorderWidget->setColor(0, 0, 0, 0);
		topBorderWidget->setEventMask(osgWidget::EVENT_ALL);
		centerTable->addWidget(topBorderWidget, 1, 0);
		centerTable->resize(_windowWidth, h);
		setWindow(centerTable);

		//init left bottom right border and corner
		addWidget(new osgWidget::Frame::Corner(osgWidget::Frame::CORNER_LOWER_LEFT, cw, ch), 0, 0);
		addWidget(new osgWidget::Frame::Border(osgWidget::Frame::BORDER_BOTTOM, w, ch), 0, 1);
		addWidget(new osgWidget::Frame::Corner(osgWidget::Frame::CORNER_LOWER_RIGHT, cw, ch), 0, 2);
		addWidget(new osgWidget::Frame::Border(osgWidget::Frame::BORDER_LEFT, cw, h), 1, 0);
		addWidget(new osgWidget::Frame::Border(osgWidget::Frame::BORDER_RIGHT, cw, wts._right), 1, 2);
		addWidget(new osgWidget::Frame::Corner(osgWidget::Frame::CORNER_UPPER_LEFT, cw, wts._top), 2, 0);
		addWidget(new osgWidget::Frame::Border(osgWidget::Frame::BORDER_TOP, w, wts._top), 2, 1);
		addWidget(new osgWidget::Frame::Corner(osgWidget::Frame::CORNER_UPPER_RIGHT, cw, wts._top), 2, 2);

		getCorner(CORNER_UPPER_LEFT)->setImage(wts._leftTopImage, true);
		getBorder(BORDER_TOP)->setImage(wts._topImage, true);
		getCorner(CORNER_UPPER_RIGHT)->setImage(wts._rightTopImage, true);
		getBorder(BORDER_LEFT)->setImage(wts._leftImage, true);
		getBorder(BORDER_RIGHT)->setImage(wts._rightImage, true);
		getCorner(CORNER_LOWER_LEFT)->setImage(wts._leftBottomImage, true);
		getBorder(BORDER_BOTTOM)->setImage(wts._bottomImage, true);
		getCorner(CORNER_LOWER_RIGHT)->setImage(wts._rightBottomImage, true);

		_topTitleWidget->setCloseButtonClickCallback(&CloudAtlasControlWindow::closeButtonClicked, this);
		_topTitleWidget->setDragCallback(&CloudAtlasControlWindow::dragEventCallback, this);
		osgWidget::point_type allHeight = h + ch + wts._top;
		resize(_windowWidth, allHeight);
	}
void GameLayer::update(ccTime dt) {
    
    /*
    if (tapDown) {
		hero->run();
	} else {
		hero->walk();
	}
	
	int32 velocityIterations = 8;
	int32 positionIterations = 1;
	
	world->Step(dt, velocityIterations, positionIterations);
	
	hero->updatePosition();
     */
    
    if (tapDown) {
        if ( ! hero->getAwake()) {
            hero->wake();
            tapDown = false;
        } else {
            hero->dive();
        }
    }
    
    hero->limitVelocity();
    
	//terrain->offsetX = hero->position.x - screenW/4;
    //terrain->setOffsetX(hero->getPosition().x - screenW/4);
    
    int32 velocityIterations = 8;
    int32 positionIterations = 3;
    world->Step(dt, velocityIterations, positionIterations);
    //world->ClearForces();
    
    hero->updateNodePosition();
    
    float scale = (screenH*4/5) / hero->getPosition().y;
    if (scale > 1) scale = 1;
    terrain->setScale(scale);
    
    //terrain_.offsetX = hero_.position.x;
    terrain->setOffsetX(hero->getPosition().x);
    
    CCSize size = getBackground()->getTextureRect().size;
    //background_.textureRect = CGRectMake(terrain_.offsetX*0.2f, 0, size.width, size.height);
    getBackground()->setTextureRect(CCRectMake(getTerrain()->getOffsetX()*0.2f, 0, size.width, size.height));
}
Ejemplo n.º 9
0
Layer* Button::getDrawnBackground(void) const
{
    if(getEnabled())
    {
        //if(getFocused())
        //{
        //    return getFocusedTextColor();
        //}
        if(getActive())
        {
            return getActiveBackground();
        }
        else if(_MouseInComponentLastMouse)
        {
            return getRolloverBackground();
        }
        else
        {
            return getBackground();
        }
    }
    else
    {
        return getDisabledBackground();
    }
}
void SplicePicturesPanel::loadImage(int row, int col, QString filePath, bool removeIfExists, bool withUpdate) {
    if (removeIfExists) removeImage(row, col);
    SplicePicturesImageItem item(row, col, filePath);
    QImage *backgroundImage = getBackground(row, col);
    if (backgroundImage != NULL) {
        QImage dodgedImage = BackgroundDodging::dodgeBackground(*item.getImage(), *backgroundImage);
        item.setImage(new QImage(dodgedImage));
        item.setPixmap(new QPixmap(QPixmap::fromImage(dodgedImage)));
        dodgedImage.save(QString("/Users/cosmozhang/work/test/Background/export_dodged/%1.tiff").arg(row * 4 + col + 1));
    }
    SplicePicturesCalibrationItem *calibrationItem = getCalibrationItem(row, col);
    if (calibrationItem != NULL) {
        item.setRotation(calibrationItem->getRotation());
        item.setZoom(calibrationItem->getZoom());
        item.getPixmap()->save(QString("/Users/cosmozhang/work/test/Background/export_calibrated/%1.tiff").arg(row * 4 + col + 1));
    }
    imageList.push_back(item);
    if (imageZoom == 0.0f) {
        if ((double)item.getWidth() / (double)item.getHeight() < (double)uwidth / (double)uheight) {
            imageZoom = (double)uwidth / (double)item.getWidth();
        } else {
            imageZoom = (double)uheight / (double)item.getHeight();
        }
    }
    if (withUpdate) refresh();
}
Ejemplo n.º 11
0
	ListBoxBase(const std::string& name):
	osgWidget::Frame(name),
	_lineColor (0.0f, 0.0f, 0.1f),
	_fillColor (0.7f, 0.8f, 0.8f),
	_lineWidth (1.0f),
	_fontSize  (10) {
		std::ostringstream font;

		font << "Bitstream Vera Sans " << _fontSize;

		_font = new osgPairo::Font(font.str().c_str());

		ButtonTheme* bt = new ButtonTheme();

		bt->renderTheme(
			8.0f,
			_lineWidth,
			osgWidget::Color(_lineColor, 1.0f),
			osgWidget::Color(_fillColor, 1.0f)
		);

		createSimpleFrameWithSingleTexture(bt, 200.0f, 15.0f);
		setFlags(osgWidget::Frame::FRAME_TEXTURE);
		getBackground()->setColor(0.0f, 0.0f, 0.0f, 0.0f);

		getGeode()->getOrCreateStateSet()->setAttributeAndModes(
			new osg::BlendFunc(osg::BlendFunc::ONE, osg::BlendFunc::ONE_MINUS_SRC_ALPHA)
		);
	}
Ejemplo n.º 12
0
void ofxColorPicker_<ColorType>::generateDraw(){
	int minWH = std::min(b.width, b.height);

	colorWheelRadius = (int)std::min(b.width * 0.5f * 0.75f, b.height * 0.9f);
	colorWheelPad = (int)(minWH * 0.05);

	rectBackground.x = (int)(b.x);
	rectBackground.y = (int)(b.y);
	rectBackground.width = (int)(b.width);
	rectBackground.height = (int)(b.height);

	rectColorWheel.x = (int)(b.x + colorWheelPad);
	rectColorWheel.y = (int)(b.y + (rectBackground.height - colorWheelRadius * 2.f) / 2.f);
	rectColorWheel.width = (int)(colorWheelRadius * 2);
	rectColorWheel.height = (int)(colorWheelRadius * 2);

	rectColorScaleBar.width = (int)(colorWheelRadius * 0.2);
	rectColorScaleBar.height = rectColorWheel.height;
	rectColorScaleBar.x = (int)(rectBackground.getMaxX() - rectColorScaleBar.width - colorWheelPad);
	rectColorScaleBar.y	= (int)(rectColorWheel.y);

	geometry.clear();
	geometry.append(getBackground());
	geometry.append(getColorWheel());
	geometry.append(getColorPoint());
	geometry.append(getColorScaleBar());
}
Ejemplo n.º 13
0
Layer* AbstractWindow::getDrawnBackground(void) const
{
	if(getDrawDecorations())
    {
        if(getEnabled())
        {
            if(getFocused())
            {
                return getFocusedBackground();
            }
            else if(_MouseInComponentLastMouse)
            {
                return getRolloverBackground();
            }
            else
            {
                return getBackground();
            }
        }
        else
        {
            return getDisabledBackground();
        }
    }
	else
	{
		return NULL;
	}
}
Ejemplo n.º 14
0
//
// Process the Expose event: draw in the window
//
void MyWindow::onExpose(XEvent& event) {
    // Erase a window
    setForeground(getBackground());
    fillRectangle(m_RWinRect);

    // Draw the coordinate axes
    drawAxes("black", true, "gray");

    // Draw a graph of function
    setForeground("red");
    drawGraphic();

    // Draw a cross on mouse click
    if (clicked) {
        if (mouseButton == Button1)
            setForeground("blue");      // Left button
        else if (mouseButton == Button2)
            setForeground("SeaGreen");  // Middle button
        else if (mouseButton == Button3)
            setForeground("brown");     // Right mouse button
        R2Vector dx(0.2, 0.);
        R2Vector dy(0., 0.2);
        drawLine(lastClick-dx, lastClick+dx);
        drawLine(lastClick-dy, lastClick+dy);
    }
}
Ejemplo n.º 15
0
Mat HistologicalEntities::getBackground(const Mat& img,
		::cciutils::SimpleCSVLogger *logger, ::cciutils::cv::IntermediateResultHandler *iresHandler) {
	CV_Assert(img.channels() == 3);

	std::vector<Mat> bgr;
	split(img, bgr);
	return getBackground(bgr, logger, iresHandler);
}
Ejemplo n.º 16
0
void ComboBox::keyDown(int keyCode, char character)
{
	if ((this != Control::getFocus()) || (!_pnlOptions.isVisible()))
	{
		return;
	}

	int change = 0;

	switch (keyCode)
	{
	case VK_RETURN:
	case VK_SPACE:
		setSelectedIndex(_listIndex);
		return;

	case VK_DOWN:
		change = 1;
		break;

	case VK_UP:
		change = -1;
		break;

	default:
		return;
	}

	vector<Control*> controls;
	_pnlOptions.getAllControls(&controls);

	controls[_listIndex]->setBackground(getBackground());
	controls[_listIndex]->setForeground(getForeground());

	if ((change == -1) && (_listIndex == 0))
	{
		_listIndex = controls.size() - 1;
	}
	else
	{
		_listIndex = (_listIndex + change) % controls.size();
	}

	controls[_listIndex]->setBackground(getForeground());
	controls[_listIndex]->setForeground(getBackground());
}
Ejemplo n.º 17
0
static void updateDisplay() {
	snprintf(text[0], sizeof(text[0]), "Background: %s", getBackground() ? "true" : "false");
	snprintf(text[1], sizeof(text[1]), "Direction: %d", getDirection());
	snprintf(text[2], sizeof(text[2]), "Length: %d", (int)getLength());
	snprintf(text[3], sizeof(text[3]), "IP address: %s", getIpaddress());

	for (int i = 0; i < SETTING_COUNT; ++i) {
		text_layer_set_text(layer[i], text[i]);
	}
}
Ejemplo n.º 18
0
GameLayer::~GameLayer() {
    delete world;
    world = NULL;
    
    getBackground()->release();
    getTerrain()->release();
    
    setBackground(NULL);
    setTerrain(NULL);
}
Ejemplo n.º 19
0
	VInfoTreeWindow::VInfoTreeWindow(osgWidget::WindowManager* wm, const std::string& name, osgWidget::point_type size)
		:osgWidget::Canvas(name)
		, _windowManager(wm)
		, _windowSize(size)
	{
		getBackground()->setColor(0.0f, 0.0f, 0.0f, 0.0f);
		setEventMask(osgWidget::EVENT_MASK_MOUSE_CLICK | osgWidget::EVENT_MASK_MOUSE_MOVE);
		_showCallback = new InfoTreeCallback(this);
		addUpdateCallback(_showCallback);
	}
Ejemplo n.º 20
0
	void Button::paint(Graphics* g)
	{
		int w = getWidth();
		int h = getHeight();
		
		// 一度背景色でクリア
		g->setColor(getBackground());
		g->fillRect(0, 0, w, h);
		
		// 枠を描画
		g->setColor(Color::black);
		g->drawLine(2, 0, w - 3, 0);
		g->drawLine(2, h - 1, w - 3, h - 1);
		g->drawLine(0, 2, 0, h - 3);
		g->drawLine(w - 1, 2, w - 1, h - 3);
		g->drawLine(1, 1, 1, 1);
		g->drawLine(1, h - 2 , 1, h - 2);
		g->drawLine(w - 2 , 1, w - 2, 1);
		g->drawLine(w - 2 , h - 2, w - 2, h - 2);
		
		if (this->pushed) {
			g->setColor(Color::white);
			g->drawLine(2, h - 2, w - 3, h - 2);
			g->drawLine(w - 2, 2, w - 2, h - 3);
			g->drawLine(w - 3 , h - 3, w - 3, h - 3);
			g->setColor(Color::gray);
			g->drawLine(1, 2, 1, h - 3);
			g->drawLine(2, 1, w - 3, 1);
		} else {
			g->setColor(Color::gray);
			g->drawLine(2, h - 2, w - 3, h - 2);
			g->drawLine(w - 2, 2, w - 2, h - 3);
			g->drawLine(w - 3 , h - 3, w - 3, h - 3);
			g->setColor(Color::white);
			g->drawLine(1, 2, 1, h - 3);
			g->drawLine(2, 1, w - 3, 1);
		}
		
		// 文字
		int fw = getFontMetrics()->getWidth(getLabel());
		int fh = getFontMetrics()->getHeight(getLabel());
		int x = (w - fw) / 2;
		int y = (h - fh) / 2;
		if (this->pushed) {
			x++;
			y++;
		}
		if (getEnabled() == true) {
			g->setColor(getForeground());
		} else {
			g->setColor(Color::gray);
		}
		g->drawString(getLabel(), x, y);
	}
Ejemplo n.º 21
0
void Frame::redraw()
{
	if (!enabled)
		return;

	Image *background = getBackground();
	if (background != 0)
		drawImage(0, 0, screenWidth, screenHeight, *background);

	if (rootWidget != 0 && rootWidget->isVisible())
		rootWidget->redraw();
}
Ejemplo n.º 22
0
int caNumeric::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = ENumeric::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    
#ifndef QT_NO_PROPERTIES
     if (_c == QMetaObject::ReadProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: *reinterpret_cast< QString*>(_v) = getPV(); break;
        case 1: *reinterpret_cast< QColor*>(_v) = getForeground(); break;
        case 2: *reinterpret_cast< QColor*>(_v) = getBackground(); break;
        case 3: *reinterpret_cast< SourceMode*>(_v) = getPrecisionMode(); break;
        case 4: *reinterpret_cast< bool*>(_v) = getFixedFormat(); break;
        case 5: *reinterpret_cast< SourceMode*>(_v) = getLimitsMode(); break;
        case 6: *reinterpret_cast< double*>(_v) = getMaxValue(); break;
        case 7: *reinterpret_cast< double*>(_v) = getMinValue(); break;
        }
        _id -= 8;
    } else if (_c == QMetaObject::WriteProperty) {
        void *_v = _a[0];
        switch (_id) {
        case 0: setPV(*reinterpret_cast< QString*>(_v)); break;
        case 1: setForeground(*reinterpret_cast< QColor*>(_v)); break;
        case 2: setBackground(*reinterpret_cast< QColor*>(_v)); break;
        case 3: setPrecisionMode(*reinterpret_cast< SourceMode*>(_v)); break;
        case 4: setFixedFormat(*reinterpret_cast< bool*>(_v)); break;
        case 5: setLimitsMode(*reinterpret_cast< SourceMode*>(_v)); break;
        case 6: setMaxValue(*reinterpret_cast< double*>(_v)); break;
        case 7: setMinValue(*reinterpret_cast< double*>(_v)); break;
        }
        _id -= 8;
    } else if (_c == QMetaObject::ResetProperty) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyDesignable) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyScriptable) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyStored) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyEditable) {
        _id -= 8;
    } else if (_c == QMetaObject::QueryPropertyUser) {
        _id -= 8;
    }
#endif // QT_NO_PROPERTIES
    return _id;
}
Ejemplo n.º 23
0
/** Computes a background estimation with an error
  *
  * This method computes an estimate of the average background along with its deviation. Since the background does not
  * follow a normal distribution and may contain outliers, instead of computing the average and standard deviation,
  * the median is used as location estimator and Sn is used as scale estimator. For details regarding the latter
  * refer to PoldiPeakSearch::getSn.
  *
  * @param peakPositions :: Peak positions.
  * @param correlationCounts :: Data from which the peak positions were extracted.
  * @return Background estimation with error.
  */
UncertainValue PoldiPeakSearch::getBackgroundWithSigma(std::list<MantidVec::const_iterator> peakPositions, const MantidVec &correlationCounts) const
{
    MantidVec background = getBackground(peakPositions, correlationCounts);

    /* Instead of using Mean and Standard deviation, which are appropriate
     * for data originating from a normal distribution (which is not the case
     * for background of POLDI correlation spectra), the more robust measures
     * Median and Sn are used.
     */
    std::sort(background.begin(), background.end());
    double meanBackground = getMedianFromSortedVector(background.begin(), background.end());
    double sigmaBackground = getSn(background.begin(), background.end());

    return UncertainValue(meanBackground, sigmaBackground);
}
Ejemplo n.º 24
0
//------------------------------------------------------------------------
bool CAnimationSplashScreen::sizeToFit ()
{
	if (modalView && modalView->getBackground ())
	{
		CRect r = modalView->getViewSize ();
		r.setWidth (modalView->getBackground ()->getWidth ());
		r.setHeight (modalView->getBackground ()->getHeight ());
		if (getFrame ())
		{
			r.centerInside (getFrame ()->getViewSize ());
		}
		modalView->setViewSize (r);
		modalView->setMouseableArea (r);
	}
	if (getBackground ())
	{
		CRect r = getViewSize ();
		r.setWidth (getBackground ()->getWidth ());
		r.setHeight (getBackground ()->getHeight ());
		setViewSize (r);
		setMouseableArea (r);
	}
	return true;
}
Ejemplo n.º 25
0
void SaveDialog::onExpose(XEvent& /* event */) {
    setForeground(getBackground());
    fillRectangle(m_IWinRect);

    setForeground(textColor);
    drawString(
        editor->leftMargin,
        editor->statusLineMargin + editor->ascent,
        "A text has been changed, save it?"
    );

    drawButton(yesButtonRect, "Yes");
    drawButton(noButtonRect, "No");
    drawButton(cancelButtonRect, "Cancel");
}
Ejemplo n.º 26
0
/**
 *  @details    Creates the level menu on the window and its necessary actions
 *              in order to provide functionality for level saving, setting the
 *              background tile of the level and exitting.
 */
void BBEditorWindow::createMenu()
{
    QMenuBar * menuBar = this->menuBar();
    QAction * saveFileAction;
    QAction * setBackgroundAction;
    QAction * exitAction;

    levelFileMenu = menuBar->addMenu("Level");

    saveFileAction = levelFileMenu->addAction("Save");
    connect(saveFileAction, SIGNAL(triggered()), this, SLOT(saveLevel()));

    setBackgroundAction = levelFileMenu->addAction("Background");
    connect(setBackgroundAction, SIGNAL(triggered()), this, SLOT(getBackground()));

    exitAction = levelFileMenu->addAction("Quit");
    connect(exitAction, SIGNAL(triggered()), this, SLOT(close()));
}
Ejemplo n.º 27
0
void JListBox::paint(JGraphics g) {
  int dx = d2+d2, dy;
  int th = getBaseH();
  int ns = section;
  JString text;
  JFontMetrics fm(g);
  JRect clip = g.getClipJRect();
  JRect frame = JRect(0, 0, width-scroller->width, height);
  JRegion rgn(clip &= frame);
  JColor color = getForeground();
  JColor bkgnd = getBackground();
  JColor light = bkgnd.brighter();
  clip &= frame.shrink(d, d);
  if (base+ns > content.size())
    ns = content.size()-base;
  for (int i=0; i<ns; i++) {
    dy = i*th+d2;
    JRect cell(d2, dy, width-scroller->width-d2*2, th-d);
    JRect area = cell & clip;
    JRect inner = cell.shrink(d, d) & clip;
    if (area.isEmpty()) continue;
    JAssociation &obj = *(JAssociation*)content[i+base];
    text = *(JString*)obj.key();
    g.setClipJRect(cell & clip);
    g.setJColor(bkgnd);
    if (!(int)*(JInteger*)obj.value()) {
      g.fill3DJRect(cell, d);
      g.setJColor(light);
      g.setClipJRect(inner);
      g.drawJString(text, dx+1, dy+1);
    } else {
      g.fill3DJRect(cell, -d);
      g.setJColor(light);
      g.setClipJRect(inner);
      g.drawJString(text, dx-1, dy-1);
    }
    g.setJColor(color);
    g.drawJString(text, dx, dy);
    rgn -= JRegion(area);
  }
  g.setJRegion(rgn);
  g.setJColor(bkgnd);
  g.fill3DJRect(frame, -d);
}
Ejemplo n.º 28
0
void Scene::changeScene(QString tileInfo, int tileSpecial){
    if (getBackground() != tileInfo){
        setBackground(tileInfo);
        QVariant newID (tileInfo);
        sendImageID(newID);

        if (tileSpecial != 0){
            if (tileSpecial == 1 || tileSpecial == 2){
                spawnChest(tileSpecial);
            }
            else if (tileSpecial == 3){
                spawnNPC(tileSpecial);
            }
        }
        else {
            spawnEnemy();
        }
    }
}
Ejemplo n.º 29
0
void TextEdit::createWindow()
{
    if (GWindow::m_Display == 0)
    {  if (!GWindow::initX()) { perror("A connection with X server could not be established"); exit(1); } }

    // Load font, calculate window size, etc.
    initialize();

    strncpy(m_WindowTitle, getFileName(), 127);
    setBgColorName("LightGray");
    setFgColorName("black");

    GWindow::createWindow();

    // Save background and foreground colors
    bgColor = getBackground();
    fgColor = getForeground();

    // Status line colors               /usr/X11R6/lib/X11/rgb.txt
    bgStatusLineColor = allocateColor("MidnightBlue");
    fgStatusLineColor = allocateColor("white");

    setFont(textFont);

    // Hints for window manager
    XSizeHints sizeHints;
    memset(&sizeHints, 0, sizeof(sizeHints));

    // Minimal size 16 * 1
    sizeHints.min_width = 44*dx + leftMargin + rightMargin;
    sizeHints.min_height = 1*dy + topMargin + bottomMargin;

    // Base size
    sizeHints.base_width = 0*dx + leftMargin + rightMargin;
    sizeHints.base_height = 0*dy + topMargin + bottomMargin;

    // Resize increment
    sizeHints.width_inc = dx;
    sizeHints.height_inc = dy;

    sizeHints.flags = (PMinSize | PBaseSize | PResizeInc);
    XSetWMNormalHints(m_Display, m_Window, &sizeHints);
}
Ejemplo n.º 30
0
const CsColour& PptColorSchemeAtom::getSchemeColor(EshColor::SchemeIndex in_index) const
{
    ChLOG_DEBUG_START_FN;
    const CsColour *pReturnColor = NULL;
    switch (in_index)
    {
    case SchemeColor_background:
        pReturnColor = &getBackground();
        break;
    case SchemeColor_text_and_lines:
        pReturnColor = &getTextAndLines();
        break;
    case SchemeColor_shadows:
        pReturnColor = &getShadows();
        break;
    case SchemeColor_title_text:
        pReturnColor = &getTitleText();
        break;
    case SchemeColor_fills:
        pReturnColor = &getFills();
        break;
    case SchemeColor_accent1:
        pReturnColor = &getAccent();
        break;
    case SchemeColor_accent2:
        pReturnColor = &getAccentAndHyperlink();
        break;
    case SchemeColor_accent3:
        pReturnColor = &getAccentAndFollowedHyperlink();
        break;
    default:
        pReturnColor = NULL;
        // TODO: throw exception?
        break;
    }

    ChASSERT(pReturnColor);
    return *pReturnColor;
}