QSize QToolBarAreaLayoutLine::sizeHint() const
{
    int a = 0, b = 0;
    for (int i = 0; i < toolBarItems.count(); ++i) {
        const QToolBarAreaLayoutItem &item = toolBarItems.at(i);
        if (item.skip())
            continue;

        QSize sh = item.sizeHint();
        a += pick(o, sh);
        b = qMax(b, perp(o, sh));
    }

    QSize result;
    rpick(o, result) = a;
    rperp(o, result) = b;

    return result;
}
Beispiel #2
0
void QxtSpanSliderPrivate::handleMousePress(const QPoint& pos, QStyle::SubControl& control, int value, QxtSpanSlider::SpanHandle handle)
{
    QStyleOptionSlider opt;
    initStyleOption(&opt, handle);
    QxtSpanSlider* p = &qxt_p();
    const QStyle::SubControl oldControl = control;
    control = p->style()->hitTestComplexControl(QStyle::CC_Slider, &opt, pos, p);
    const QRect sr = p->style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, p);
    if (control == QStyle::SC_SliderHandle)
    {
        position = value;
        offset = pick(pos - sr.topLeft());
        lastPressed = handle;
        p->setSliderDown(true);
        emit p->sliderPressed(handle);
    }
    if (control != oldControl)
        p->update(sr);
}
Beispiel #3
0
void pick(int i) {
  int valid;
  int j, n;
  if (i == 9) {
    n = -remain[i];
    if (n < 0 || n > 9) {
      return;
    }
    --remain[n];
    remain[i] += n;
    for (j = 0, valid = 1; j < 10; ++j) {
      if (remain[j] != 0) {
        valid = 0;
        break;
      }
    }
    if (valid) {
      num[i] = n;
      for (j = 0; j < 10; ++j) {
        printf("%d ", num[j]);
      }
      printf("\n");
    } else {
      ++invalid;
    }
    ++remain[n];
    remain[i] -= n;
  } else {
    for (n = 0; n < 10; ++n) {
      num[i] = n;
      --remain[n];
      remain[i] += n;
      if (remain[i] >= 0 && (n > i || remain[n] >= 0)) {
        pick(i + 1);
      }
      /* if (remain[i] >= 0) { */
      /*   pick(i + 1); */
      /* } */
      ++remain[n];
      remain[i] -= n;
    }
  }
}
QSize QToolBarAreaLayoutLine::minimumSize() const
{
    int a = 0, b = 0;
    for (int i = 0; i < toolBarItems.count(); ++i) {
        const QToolBarAreaLayoutItem &item = toolBarItems[i];
        if (item.skip())
            continue;

        QSize ms = item.minimumSize();
        a += pick(o, ms);
        b = qMax(b, perp(o, ms));
    }

    QSize result;
    rpick(o, result) = a;
    rperp(o, result) = b;

    return result;
}
Beispiel #5
0
void RichEdit::InsertTable()
{
	if(IsSelection())
		return;
	WithCreateTableLayout<TopWindow> dlg;
	CtrlLayoutOKCancel(dlg, t_("Insert table"));
	dlg.header = false;
	dlg.columns <<= 2;
	dlg.columns.MinMax(1, 20);
	dlg.ActiveFocus(dlg.columns);
	if(dlg.Run() != IDOK)
		return;
	RichTable::Format fmt;
	int nx = minmax((int)~dlg.columns, 1, 20);
	for(int q = nx; q--;)
		fmt.column.Add(1);
	if(dlg.header)
		fmt.header = 1;
	RichTable table;
	table.SetFormat(fmt);
	for(int i = 0; i < (dlg.header ? 2 : 1); i++)
		for(int j = 0; j < nx; j++) {
			RichText h;
			h.SetStyles(text.GetStyles());
			RichPara p;
			p.format = formatinfo;
			p.format.newpage = false;
			p.format.label.Clear();
			h.Cat(p);
			table.SetPick(i, j, pick(h));
		}
	NextUndo();
	if(cursorp.posinpara)
		InsertLine();
	if(text.GetRichPos(cursor).paralen) {
		InsertLine();
		cursor = anchor = cursor - 1;
		begtabsel = false;
	}
	SaveFormat(cursor, 0);
	AddUndo(new UndoCreateTable(text.SetTable(cursor, table)));
	Finish();
}
QSize QToolBarAreaLayoutInfo::minimumSize() const
{
    int a = 0, b = 0;
    for (int i = 0; i < lines.count(); ++i) {
        const QToolBarAreaLayoutLine &l = lines.at(i);
        if (l.skip())
            continue;

        QSize m = l.minimumSize();
        a = qMax(a, pick(o, m));
        b += perp(o, m);
    }

    QSize result;
    rpick(o, result) = a;
    rperp(o, result) = b;

    return result;
}
Beispiel #7
0
void QSplitterPrivate::setGeo(QSplitterLayoutStruct *sls, int p, int s, bool allowCollapse)
{
    Q_Q(QSplitter);
    QWidget *w = sls->widget;
    QRect r;
    QRect contents = q->contentsRect();
    if (orient == Qt::Horizontal) {
        r.setRect(p, contents.y(), s, contents.height());
    } else {
        r.setRect(contents.x(), p, contents.width(), s);
    }
    sls->rect = r;

    int minSize = pick(qSmartMinSize(w));

    if (orient == Qt::Horizontal && q->isRightToLeft())
        r.moveRight(contents.width() - r.left());

    if (allowCollapse)
        sls->collapsed = s <= 0 && minSize > 0 && !w->isHidden();

    //   Hide the child widget, but without calling hide() so that
    //   the splitter handle is still shown.
    if (sls->collapsed)
        r.moveTopLeft(QPoint(-r.width()-1, -r.height()-1));

    w->setGeometry(r);

    if (!sls->handle->isHidden()) {
        QSplitterHandle *h = sls->handle;
        QSize hs = h->sizeHint();
        int left, top, right, bottom;
        h->getContentsMargins(&left, &top, &right, &bottom);
        if (orient==Qt::Horizontal) {
            if (q->isRightToLeft())
                p = contents.width() - p + hs.width();
            h->setGeometry(p-hs.width() - left, contents.y(), hs.width() + left + right, contents.height());
        } else {
            h->setGeometry(contents.x(), p-hs.height() - top, contents.width(), hs.height() + top + bottom);
        }
    }
}
Beispiel #8
0
void Ctrl::DefferedFocusSync()
{
	GuiLock __;
	while(defferedChildLostFocus.GetCount() || defferedSetFocus) {
		LLOG("Ctrl::DeferredFocusSync, defferedSetFocus = " << UPP::Name(defferedSetFocus));
		Vector< Ptr<Ctrl> > b = pick(defferedChildLostFocus);
		defferedChildLostFocus.Clear();
		for(int i = 0; i < b.GetCount(); i++)
			if(b[i]) {
				LLOG("Ctrl::DeferredFocusSync -> ChildLostFocus " << UPP::Name(b[i]));
				b[i]->ChildLostFocus();
			}
		if(defferedSetFocus) {
			LLOG("Ctrl::DeferredFocusSync -> SetFocus " << UPP::Name(defferedSetFocus));
			defferedSetFocus->SetFocus();
		}
		defferedSetFocus = NULL;
		SyncCaret();
	}
}
Beispiel #9
0
bool HelpWindow::GoTo0(const String& link)
{
	if(IsNull(link) || current_link == link)
		return true;
	Topic t = AcquireTopic(link);
	SetBar();
	if(!IsNull(t.text)) {
		label = t.label;
		topic = t.link;
		Title(FromUtf8(t.title));
		RichText txt = ParseQTF(t.text);
		FinishText(txt);
		view.Pick(pick(txt), zoom);
		view.GotoLabel(label, true);
		current_link = link;
		tree.FindSetCursor(topic);
		return true;
	}
	return false;
}
//-----------------------------------------------------------------------------
// passive button event handler
//-----------------------------------------------------------------------------
void GlutDisplay::mouseEvent(const int button, const int state, const int x, const int y)
{
   if (button == GLUT_LEFT_BUTTON && state == GLUT_DOWN) {
      Graphic* selected = pick();
      if (selected != nullptr) {
         selected->event(INPUT_LEFT_EDGE);
         if (picked != nullptr) picked->unref();
         picked = selected;
         picked->ref();
      }
   }
   if (button == GLUT_LEFT_BUTTON && state == GLUT_UP) {
      if (picked != nullptr) {
         picked->event(ON_SINGLE_CLICK);
         picked->unref();
         picked = nullptr;
      }
   }
   setMouse(x,y);
}
  void PeakPickerSH::pickExperiment(const MSExperiment<> & input, MSExperiment<> & output)
  {
    // make sure that output is clear
    output.clear(true);

    // copy experimental settings
    static_cast<ExperimentalSettings &>(output) = input;

    // resize output with respect to input
    output.resize(input.size());

    std::cout << "Before loop, input size = " << input.size() << std::endl;
    Size progress = 0;
    for (Size scan_idx = 0; scan_idx != input.size(); ++scan_idx)
    {
      output[scan_idx].clear(true);
      output[scan_idx].SpectrumSettings::operator=(input[scan_idx]);
      output[scan_idx].MetaInfoInterface::operator=(input[scan_idx]);
      output[scan_idx].setRT(input[scan_idx].getRT());
      output[scan_idx].setMSLevel(input[scan_idx].getMSLevel());
      output[scan_idx].setName(input[scan_idx].getName());
      output[scan_idx].setType(SpectrumSettings::PEAKS);

      if (input[scan_idx].getMSLevel() != 1)
      {
        // When not considering MS2 data (MS2 fragment mass tracing=0), Lukas leaves out
        // the entire scan (instead of just copying it to the output as seen in
        // another plugin).
        // pick(input[scan_idx], output[scan_idx], 4.0);
      }
      else
      {
        // TODO: Read value 4.0 from parameters # PeakPickerSH.cpp
        pick(input[scan_idx], output[scan_idx], 5.0);
      }
      setProgress(++progress);
    }
    std::cout << "After loop" << std::endl;

    endProgress();
  }
Beispiel #12
0
void * simulator(void * v) {
  uint32_t ngames = ((uint32_t *)v)[0];
  uint32_t * ohs = (uint32_t *)malloc(2*(np-1)*sizeof(uint32_t));
  uint32_t cs[7], myas[7], cs0, cs1, result, result1, i, j, k;
  uint32_t mycounters[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  // int mywins = 0, mydraws = 0;
  deck * d = newdeck();
  for (i=0; i<kc; i++) {
    pick(d, as[i]);
    myas[i] = as[i];
  }
  for (i=0; i<ngames; i++) {
    int64_t score;
    initdeck(d, 52-kc);
    for (j=0; j<2*(np-1); j++) ohs[j] = draw(d);
    for (j=kc; j<7; j++) myas[j] = draw(d);
    for (j=0; j<7; j++) cs[j] = myas[j];
    sort(cs);
    score = eval7(cs);
    result = WIN;
    for (j=0; j<np-1; j++) {
      cs[0] = ohs[2*j];
      cs[1] = ohs[2*j+1];
      for (k=2; k<7; k++) cs[k] = myas[k];
      sort(cs);
      result1 = comp7(cs, score);
      if (result1 < result) result = result1;
      if (result == LOSS) break;
    }
    mycounters[result]++;
    mycounters[hand(score)]++;
  }
  pthread_mutex_lock(&tlock);
  for (i=0; i<12; i++) {
    counters[i] += mycounters[i];
  }
  pthread_mutex_unlock(&tlock);
  free(ohs);
  free(d);
  return NULL;
}
void Rigid_body_viewer:: mouse(int _button, int _state, int _x, int _y)
{
    // need points
    if (body_.points.empty())
        return;

    // mouse button release destroys current mouse spring
    if (_state == GLUT_UP)
    {
        mouse_spring_.active = false;
        return;
    }

    // mouse button press generates new mouse spring
    else if (_state == GLUT_DOWN)
    {
        // get point under mouse cursor
        vec2 p = pick(_x, _y);

        // find closest body point
        unsigned int i, imin;
        float dmin = FLT_MAX;
        for (i=0; i<body_.points.size(); ++i)
        {
            float d = distance(p, body_.points[i]);
            if (d < dmin)
            {
                dmin = d;
                imin = i;
            }
        }

        // setup the mouse spring
        mouse_spring_.active = true;
        mouse_spring_.particle_index = imin;
        mouse_spring_.mouse_position = p;
    }

    glutPostRedisplay();
}
void Mass_spring_viewer::mouse(int _button, int _state, int _x, int _y)
{
    // need particles to do interaction
    if (!body_.particles.empty())
    {
        // mouse button release destroys current mouse spring
        if (_state == GLUT_UP)
        {
            mouse_spring_.active = false;
        }

        // mouse button press generates new mouse spring
        else if (_state == GLUT_DOWN)
        {
            // get point under mouse cursor
            vec2 p = pick(_x, _y);

            // find closest particle
            int   pidx = -1;
            float dmin = FLT_MAX;
            for (unsigned int i=0; i<body_.particles.size(); ++i)
            {
                float d = norm(p - body_.particles[i].position);
                if (d < dmin)
                {
                    dmin = d;
                    pidx = i;
                }
            }

            // construct mouse spring
            mouse_spring_.mouse_position = p;
            mouse_spring_.particle_index = pidx;
            mouse_spring_.active = true;
        }
    }

    glutPostRedisplay();
}
Beispiel #15
0
void CoWork::Pool::DoJob(MJob& job)
{
	job.UnlinkAll();
	LLOG("DoJob (CoWork " << FormatIntHex(job.work) << ")");
	finlock = false;
	Function<void ()> fn = pick(job.fn);
	Free(job);
	CoWork *work = job.work;
	lock.Leave();
	fn();
	if(!finlock)
		lock.Enter();
	if(!work)
		return;
	if(--work->todo == 0) {
		LLOG("Releasing waitforfinish of (CoWork " << FormatIntHex(work) << ")");
		work->waitforfinish.Signal();
	}
	LLOG("DoJobA, todo: " << work->todo << " (CoWork " << FormatIntHex(work) << ")");
	ASSERT(work->todo >= 0);
	LLOG("Finished, remaining todo " << work->todo);
}
Beispiel #16
0
bool TTimeSlider::event(QEvent* event) {

	if (event->type() == QEvent::ToolTip) {
		QHelpEvent* help_event = static_cast<QHelpEvent*>(event);
		QStyleOptionSlider opt;
		initStyleOption(&opt);
        // Rect of handle/knob
        const QRect sliderRect = style()->subControlRect(
            QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, this);
        // Center of handle
		const QPoint center = sliderRect.center() - sliderRect.topLeft();

		int val = pixelPosToRangeValue(pick(help_event->pos() - center));
        int time = qRound(val * _duration / maximum());
        QToolTip::showText(help_event->globalPos(), Helper::formatTime(time),
                           this);
		event->accept();
		return true;
	}

	return QWidget::event(event);
}
Beispiel #17
0
//事件处理函数
bool CPickHandler::handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& aa)
{
	switch(ea.getEventType())
	{
		//每一帧
	case(osgGA::GUIEventAdapter::FRAME):
		{
			osg::ref_ptr<osgViewer::Viewer> viewer = dynamic_cast<osgViewer::Viewer*>(&aa);
			//得到视图矩阵
			viewer ->getCamera() ->getViewMatrixAsLookAt(position, center, up) ;
			if (viewer)
			{	
				//执行PICK动作
				pick(viewer.get(),ea);
			}
			return false;
		}    
	default:
		return false;
	}

}
Beispiel #18
0
void GlWidget::mousePressEvent(QMouseEvent *event)
{
  _lastPos = event->pos();

  pick(event->pos());
  if (_selection >= 0)
  {
    if (event->button() == Qt::RightButton)
    {
      Cube *cube = _cubes[_selection];
      QColor color = QColorDialog::getColor(cube ->color(), this);
      if (color.isValid())
        cube->setColor(color);
    }
    if (event->button() == Qt::LeftButton)
    {
      Cube *cube = _cubes[_selection];
      RotationSelector selector(cube, this);
      selector.exec();
    }
  }
}
Beispiel #19
0
int MIValue::ParseArray(String const &s, int i)
{
	Clear();
	type = MIArray;
	
	// drop opening delimiter
	if(!expect("ParseArray", '[', i, s))
		return s.GetCount();
	i++;
	while(s[i] && isspace(s[i]))
		i++;
	while(s[i] && s[i] != ']')
	{
		while(s[i] && isspace(s[i]))
			i++;
		String name;
		MIValue val;
		if(s[i] == '[')
			i = val.ParseArray(s, i);
		else if(s[i] == '{')
			i = val.ParseTuple(s, i);
		else if(s[i] == '"')
			i = val.ParseString(s, i);
		else if(s[i] == '<')
			i = val.ParseAngle(s, i);
		else
			i = ParsePair(name, val, s, i);
		array.Add() = pick(val);
		while(s[i] && isspace(s[i]))
			i++;
		if(s[i] == ']')
			break;
		if(!expect("ParseArray", ',', i, s))
			return s.GetCount();
		i++;
	}
	return i + 1;
}
bool QToolBarAreaLayoutInfo::insertGap(const QList<int> &path, QLayoutItem *item)
{
    Q_ASSERT(path.count() == 2);
    int j = path.first();
    if (j == lines.count())
        lines.append(QToolBarAreaLayoutLine(o));

    QToolBarAreaLayoutLine &line = lines[j];
    const int k = path.at(1);

    QToolBarAreaLayoutItem gap_item;
    gap_item.gap = true;
    gap_item.widgetItem = item;

    //update the previous item's preferred size
    for(int p = k - 1 ; p >= 0; --p) {
        QToolBarAreaLayoutItem &previous = line.toolBarItems[p];
        if (!previous.skip()) {
            //we found the previous one
            int previousSizeHint = pick(line.o, previous.sizeHint());
            int previousExtraSpace = previous.size - previousSizeHint;

            if (previousExtraSpace > 0) {
                //in this case we reset the space
                previous.preferredSize = -1;
                previous.size = previousSizeHint;

                gap_item.resize(o, previousExtraSpace);
            }

            break;
        }
    }

    line.toolBarItems.insert(k, gap_item);
    return true;

}
Beispiel #21
0
    bool handle( const osgGA::GUIEventAdapter& ea,
            osgGA::GUIActionAdapter& aa )
    {
        osgViewer::Viewer* viewer =
                dynamic_cast<osgViewer::Viewer*>( &aa );
        if (!viewer)
            return false;

        switch( ea.getEventType() )
        {
            case osgGA::GUIEventAdapter::PUSH:
            case osgGA::GUIEventAdapter::MOVE:
            {
                // Record mouse location for the button press
                //   and move events.
                _mX = ea.getX();
                _mY = ea.getY();
                return false;
            }
            case osgGA::GUIEventAdapter::RELEASE:
            {
                // If the mouse hasn't moved since the last
                //   button press or move event, perform a
                //   pick. (Otherwise, the trackball
                //   manipulator will handle it.)
                if (_mX == ea.getX() && _mY == ea.getY())
                {
                    if (pick( ea.getXnormalized(),
                                ea.getYnormalized(), viewer ))
                        return true;
                }
                return false;
            }    

            default:
                return false;
        }
    }
Beispiel #22
0
void link_local_start(void)
{
	ip = getenv_IPaddr("llipaddr");
	if (ip != 0 && (ip & IN_CLASSB_NET) != LINKLOCAL_ADDR) {
		puts("invalid link address");
		net_set_state(NETLOOP_FAIL);
		return;
	}
	NetOurSubnetMask = IN_CLASSB_NET;

	seed = seed_mac();
	if (ip == 0)
		ip = pick();

	state = PROBE;
	timeout_ms = 0;
	conflicts = 0;
	nprobes = 0;
	nclaims = 0;
	ready = 0;

	configure_wait();
}
Beispiel #23
0
void pickSort(int armNo, int sortNo)
{
	lcd_print(2,10,armNo,1);
	lcd_print(2,12,sortNo,1);
	buzzer();
	_delay_ms(1000);
	arm[armNo] = sort[sortNo];
	if (((armNo == sortNo) && dir == 0) || ((armNo != sortNo) && dir == 2))
	turn();
	else
	{
		if (dir == 1 || dir == 3)
		{
			if (armNo == 0)
			turnLeft();
			else turnRight();
		}
	}
	pick(armNo);
	sort[sortNo] = -1;
	//..printf("Arm %d picked %d from sort[%d]\n", armNo, arm[armNo], sortNo);
	lcd("exit picksort");
}
bool CSliderMultiPos::handleMousePress(const QPoint& pos, QStyle::SubControl control,
                                            int value,int handleIndex){

    QStyleOptionSlider opt;
    bool hasFind;

    hasFind = false;
    initStyleOption( &opt,handleIndex);//handle );
    const QStyle::SubControl oldControl = control;
    control = this->style()->hitTestComplexControl( QStyle::CC_Slider,&opt,pos,this );
    const QRect sr = this->style()->subControlRect( QStyle::CC_Slider,&opt,QStyle::SC_SliderHandle,this );
    if( control == QStyle::SC_SliderHandle ){
        tempPosition = value;
        offset = pick( pos - sr.topLeft() );
        lastPressedIndex = handleIndex;
        hasFind = true;
        this->setSliderDown( true );
    }
    if( control!=oldControl ){
        this->update( sr );
    }
    return hasFind;
}
Beispiel #25
0
void TemplateDlg::LoadNest(const char *path, bool main, bool recurse)
{
	FindFile ff(AppendFileName(path, "*.*"));
	while(ff) {
		String p = AppendFileName(path, ff.GetName());
		if(ff.IsFolder()) {
			if(recurse)
				LoadNest(p, main);
		}
		else
		if(ToLower(GetFileExt(ff.GetName())) == ".upt") {
			try {
				PackageTemplate t = ReadTemplate(p);
				if(main && t.main || !main && t.sub)
					pt.Add() = pick(t);
			}
			catch(CParser::Error e) {
				Exclamation("Package template [* " + DeQtf(p) + "] is invalid&[* " + e);
			}
		}
		ff.Next();
	}
}
Beispiel #26
0
FilePickBox::FilePickBox (nana::widget &fm, 
						  const nana::string   &label,
						  const nana::string   &DefLayoutFileName )
				:	CompoWidget(fm, label, DefLayoutFileName) 
{
    _label.caption(caption());
    _label.text_align(nana::align::right  ); 

    fb_p.title(STR("Pick ") + caption());

	Pick.events().click([&](){pick(FileName());}	); 

	_fileName.editable(true);

    InitMyLayout();
    SelectClickableWidget( _label);

    _fileName .events().selected   ([this](const nana::arg_combox& arg_cb)
            { 
            //assert((  std::cerr<< "\nBefore calling Validate,in select FilePickBox._fileName: " , true  ));;
            //assert((  std::wcerr<< caption() << std::endl , true  ));;
                      
                //if( this->UserSelected() )   
                    this->Validate(this->_validate_only);
            } );
    _fileName.events().focus([this](const nana::arg_focus & ei)
        {  
            //assert((  std::cerr<< "\nBefore calling validating_only," << (ei.focus.getting ? "geting ":"lossing ") << "Focus: , FilePickBox._fileName: " , true  ));;
            //assert((  std::wcerr<< caption() << std::endl , true  ));;
            
            if (!ei .getting) 
                          this->validate_only();
        });


    _user_selected=true;
}
Beispiel #27
0
int MIValue::Parse(String const &s, int i)
{
	// if starts with '"', it's a string
	// if starts with '[', it's an array
	// if starts with '{', it's a tuple
	// otherwise, it can be a sequence of pair name="value" which is stored like a tuple
	// latter case is an example o bad design of MI interface....
	Clear();
	while(s[i] && isspace(s[i]))
		i++;
	if(s[i] == '"')
		return ParseString(s, i);
	else if(s[i] == '<')
		return ParseAngle(s, i);
	else if(s[i] == '[')
		return ParseArray(s, i);
	else if(s[i] == '{')
		return ParseTuple(s, i);
	else
	{
		String name;
		MIValue val;
		type = MITuple;
		while(s[i])
		{
			i = ParsePair(name, val, s, i);
			tuple.AddPick(name, pick(val));
			while(s[i] && isspace(s[i]))
				i++;
			if(s[i] != ',')
				break;
			i++;
		}

		return i;
	}
}
Beispiel #28
0
//==============================================================================
void DefaultEventHandler::eventPick(const osgGA::GUIEventAdapter& ea)
{
    MouseButtonEvent mbe;
    switch(ea.getEventType())
    {
    case osgGA::GUIEventAdapter::PUSH:
        mbe = BUTTON_PUSH;
        break;
    case osgGA::GUIEventAdapter::DRAG:
        mbe = BUTTON_DRAG;
        break;
    case osgGA::GUIEventAdapter::RELEASE:
        mbe = BUTTON_RELEASE;
        break;
    default:
        return;
    }

    if(   ( (ea.getButtonMask() & osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON)
            && !mSuppressButtonPicks[LEFT_MOUSE][mbe])
            || ( (ea.getButtonMask() & osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON)
                 && !mSuppressButtonPicks[RIGHT_MOUSE][mbe])
            || ( (ea.getButtonMask() & osgGA::GUIEventAdapter::MIDDLE_MOUSE_BUTTON)
                 && !mSuppressButtonPicks[MIDDLE_MOUSE][mbe]))
    {
        pick(mTempPicks, ea);

        if(ea.getButtonMask() & osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON)
            mButtonPicks[LEFT_MOUSE][mbe] = mTempPicks;

        if(ea.getButtonMask() & osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON)
            mButtonPicks[RIGHT_MOUSE][mbe] = mTempPicks;

        if(ea.getButtonMask() & osgGA::GUIEventAdapter::MIDDLE_MOUSE_BUTTON)
            mButtonPicks[MIDDLE_MOUSE][mbe] = mTempPicks;
    }
}
Beispiel #29
0
void slave_procedure(int my_rank, int comm_size, long long the_number) {
	long long from, to;
	long long to_send;
	int shit_happened;
	struct elem* head = NULL;

	from = ((((long long int) sqrt((double) the_number)) / (comm_size - 1))) * (my_rank - 1);
	to = ((((long long int) sqrt((double) the_number)) / (comm_size - 1)) + 1) * (my_rank); // TODO: better square root

	from = from == 0 ? 1 : from; // Because why not

	long long int i;

	#pragma omp parallel shared(from, to) private(i)
	{
		#pragma omp for schedule(auto)
		for(i = 0; i < (to - from); ++i) {
			if(the_number % (from + i) == 0) {
				#pragma omp critical
				{
					add(&head, from + i);
					add(&head, the_number / (from + i));
				}
			}
		}
	}
	do {
		to_send = pick(&head);
		shit_happened = MPI_Ssend(&to_send, 1, MPI_LONG_LONG, 0, 0, MPI_COMM_WORLD);

		if(shit_happened) {
			fprintf(stderr, "Send failed");
			MPI_Abort(MPI_COMM_WORLD, 1);
		}

	}while(to_send != 0);
}
bool ScenePickingHandler::eventFilter(QObject* object, QEvent* event)
{
    if (!m_enabled)
        return QObject::eventFilter(object, event);

    switch (event->type())
    {
      case QEvent::MouseButtonPress:
        {
            const QMouseEvent* mouse_event = static_cast<QMouseEvent*>(event);
            if (mouse_event->button() == Qt::LeftButton &&
                !(mouse_event->modifiers() & (Qt::AltModifier | Qt::ShiftModifier | Qt::ControlModifier)))
            {
                pick(mouse_event->pos());
                return true;
            }
        }
        break;

      case QEvent::MouseMove:
        {
            const QMouseEvent* mouse_event = static_cast<QMouseEvent*>(event);
            set_rgba_label(mouse_event->pos());
        }
        break;

      case QEvent::Leave:
        m_r_label->clear();
        m_g_label->clear();
        m_b_label->clear();
        m_a_label->clear();
        break;
    }

    return QObject::eventFilter(object, event);
}