MainStarterWidget::MainStarterWidget()
{
    QVBoxLayout* layout = new QVBoxLayout(this);

    QWidget* w;
    w = new QuickStartWidget();
    connect(w, SIGNAL(startRadio(RadioStation)), SIGNAL(startRadio(RadioStation)));
    layout->addWidget(w);

    w = m_recentStationsWidget = new RecentStationsWidget();
    connect(w, SIGNAL(startRadio(RadioStation)), SIGNAL(startRadio(RadioStation)));
    connect(w, SIGNAL(showMoreRecentStations()), SIGNAL(showMoreRecentStations()));
    layout->addWidget(w);

    w = new YourStationsWidget();
    connect(w, SIGNAL(startRadio(RadioStation)), SIGNAL(startRadio(RadioStation)));
    layout->addWidget(w);

    w = new MoreStationsWidget();
    connect(w, SIGNAL(combo()), SIGNAL(combo()));
    connect(w, SIGNAL(tags()), SIGNAL(yourTags()));
    connect(w, SIGNAL(friends()), SIGNAL(yourFriends()));
    connect(w, SIGNAL(playlists()), SIGNAL(yourPlaylists()));
    layout->addWidget(w);
}
示例#2
0
QComboBox *QmvListItem::combo()
{
    if ( comb )
	return comb;
    comb = new QComboBox( FALSE, listview->viewport() );
    comb->hide();

    connect( comb, SIGNAL( activated( int ) ),
	     this, SLOT( setValue() ) );
    comb->installEventFilter( listview );
    combo()->blockSignals( TRUE );
    combo()->clear();
    combo()->listBox()->setColumnMode(1);

        // Load from foreign class of this attribute.
    const QString & att = shuttletupleattribute->attributeName();
    
    QmvClass * fk_class = shuttleclass->foreignRelation( att );

    if (fk_class)
        for (int i = 0; i < fk_class->count(); i++)
            comb->insertItem( fk_class->attributeValue( i, shuttleclass->foreignView( att ) ), i );
    
    combo()->blockSignals( FALSE );
    return comb;
}
示例#3
0
void QmvListItem::setValue( const QString &v )
{
    if ( !comb )
	return;
    setText( 1, combo()->currentText() );
    QmvItem::setValue( combo()->currentText() );
    notifyValueChange();
    oldInt = currentIntItem();
    oldString = currentItem();
}
示例#4
0
void QmvBoolItem::setValue()
{
    if ( !comb )
	return;
    setText( 1, combo()->currentText() );
    if ( combo()->currentItem() == 0 )
        QmvItem::setValue( str_true );
    else
        QmvItem::setValue( str_false );
    notifyValueChange();
}
示例#5
0
/*!
  Set the selected item in the list to index \em i

  \param i      index of list item to select
*/
void QmvListItem::setCurrentItem( int i )
{
    if ( comb && i == combo()->currentItem() )
	return;

    if ( !comb )
	combo();
    
    combo()->setCurrentItem( i );
    setText( 1, combo()->currentText() );
    oldInt = currentIntItem();
    oldString = currentItem();
}
示例#6
0
/*!
  Set the selected item in the list to \em s

  \param s      String to find in list
*/
void QmvListItem::setCurrentItem( const QString &s )
{
    if ( comb && currentItem().lower() == s.lower() )
 	return;

    if ( !comb )
	combo();
        
    for ( uint i = 0; i < combo()->listBox()->count(); ++i ) {
	if ( combo()->listBox()->item( i )->text().lower() == s.lower() ) {
	    setCurrentItem( i );
	    break;
	}
    }
}
示例#7
0
void Nmr::on_isotopeCombo_currentIndexChanged(QString const& text)
{
   QString isotope(currentIsotope(text));

   Data::NmrReferenceLibrary& library(Data::NmrReferenceLibrary::instance());
   QList<Data::NmrReference const*> refs(library.filter(isotope));

   QStringList systems;
   QList<Data::NmrReference const*>::iterator iter;
   for (iter = refs.begin(); iter != refs.end(); ++iter) {
       QString system((*iter)->system());
       if (!systems.contains(system)) systems.append(system);
   }

   QComboBox* combo(m_ui->systemCombo);
   combo->clear();
   combo->addItems(systems);

   loadShifts(currentReference(), isotope);

   QPair<double, double> range(standardRange(isotope));
   m_plot->xAxis->setRange(range.first, range.second);

   updatePlot();
}
示例#8
0
INT_PTR Main_OnInitDialog(HWND hWnd, HWND /*hWndFocus*/, LPARAM)
{
	WORD	wDefLangID = MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US);

	// Set the icon.
	CIconHandle hIcon;
	hIcon.LoadIcon(IDI_ICON_UPDATESTR);
	CWindow wnd(hWnd);
	wnd.SetIcon(hIcon, TRUE);
	wnd.SetIcon(hIcon, FALSE);

	CComboBox combo(wnd.GetDlgItem(IDC_COMBO_LANGUAGES));
	CString strBuf;
	// Fill the languages-combobox.
	int nDefIndex = 0;
	for(int i = 0; i < NO_OF_LANGUAGES; i++ )
	{
		// Load the string, insert it & specify the language ID as
		// the item data.
		strBuf.LoadString(s_langInfo[i].nStrID);
		int nIndex = combo.AddString(strBuf);
		combo.SetItemData(nIndex, s_langInfo[i].wLangID);
		if( wDefLangID == s_langInfo[i].wLangID )
			nDefIndex = nIndex;
	}

	// Select the default index.
	combo.SetCurSel(nDefIndex);

	return TRUE;
}
示例#9
0
/*
 * 说明:
 *    删除台号信息
 * 参数:
 *    hwnd [in] 主窗口句柄
 * 返回值
 *    成功返回true
 */
bool DeleteTable(HWND hwnd)
{
	CListView table_list(hwnd, IDC_L_TABLE_INFO);
	int select = table_list.GetSelectionMark();
	if (-1 == select) {
		MessageBox(hwnd, TEXT("请在左侧列表款选择要删除的房间编号!"), TEXT("基础信息管理"), MB_ICONINFORMATION);
		return false;
	}
	std::string floor, room, table_no;
	CComboBox combo(hwnd, IDC_TABLE_FLOOR_COMBO);
	combo.GetComboBoxText(floor);              // 获取楼层名
	room = table_list.GetItem(select, 0);      // 获取房间名
	table_no = table_list.GetItem(select, 1);  // 获取台号
		CTableInfo table;
		table.DeleteTable(floor.c_str(), room.c_str(), table_no.c_str());
		CComboBox combox;
		//清空显示
		combox.Initialization(hwnd,IDC_C_FLOOR_NAME);
		combox.DeleteAllString();
		combox.Initialization(hwnd,IDC_C_ROOM_NAME);
		combox.DeleteAllString();
		CEdit edit;
		edit.Initialization(hwnd,IDC_E_TABLE_NO);
		edit.Empty();
		edit.Initialization(hwnd,IDC_E_TABLE_NUM);
		edit.Empty();
		InitTableList(hwnd, IDC_L_TABLE_INFO, floor.c_str(), 0);  // 更新
	return true;
}
//--------------------------------------------------------------------------------
void DbMySQLTableEditorFKPage::combo_box_changed(const int model_column)
{
  Gtk::ComboBox *combo(0);

  if (::bec::FKConstraintListBE::OnUpdate == model_column)
    combo = _fk_update_combo;
  else if (::bec::FKConstraintListBE::OnDelete == model_column)
    combo = _fk_delete_combo;
  
  if ( combo )
    if (!_be->get_fks()->set_field(_fk_node, model_column, get_selected_combo_item(combo)))
    {
      if (::bec::FKConstraintListBE::OnUpdate == model_column)
      {
        if (_fk_node.is_valid())
        {
          std::string  _prev;
          _be->get_fks()->get_field(_fk_node, ::bec::FKConstraintListBE::OnUpdate, _prev);
          set_selected_combo_item(combo, _prev);
        }
      }
      else if (::bec::FKConstraintListBE::OnDelete == model_column)
      {
        if (_fk_node.is_valid())
        {
          std::string  _prev;
          _be->get_fks()->get_field(_fk_node, ::bec::FKConstraintListBE::OnDelete, _prev);
          set_selected_combo_item(combo, _prev);
        }
      }
    }
}
示例#11
0
void Main_OnDisplay( HWND hWnd )
{
	TCHAR			strAppName[MAX_PATH]={0};
	TCHAR			strBlock[10]={0};
	TCHAR*			pEnd=nullptr;
	TABLEDLG_DATA	tblDlgData={0};

	// Get the appname, the selected block ID & the selected
	// language. Create the string block. If the block creation is successful,
	// bring up the table dialog box.

	CWindow wnd(hWnd);
	if (!wnd.GetDlgItemText(IDC_EDIT_APPNAME, strAppName, MAX_PATH))
	{
		DisplayMsg(hWnd, IDS_INVALIDAPPNAME);
		return;
	}

	CComboBox combo(wnd.GetDlgItem(IDC_COMBO_LANGUAGES));
	int nSel = combo.GetCurSel();
	if( CB_ERR == nSel )
	{
		DisplayMsg(hWnd, IDS_INVALIDLANGUAGE);
		return;
	}

	if (!wnd.GetDlgItemText(IDC_EDIT_BLOCKID, strBlock, _countof(strBlock)))
	{
		DisplayMsg(hWnd, IDS_INVALIDBLOCKID);
		return;
	}

	UINT nBlockID = _tcstoul(strBlock, &pEnd, 10);
	if( *pEnd != 0 )
	{
		DisplayMsg(hWnd, IDS_INVALIDBLOCKID);
		return;
	}

	HSTRBLOCK hStrBlock = GetStringBlock(strAppName, nBlockID, s_langInfo[nSel].wLangID);
	if( nullptr == hStrBlock )
	{
		DisplayStatus(hWnd, GetStringBlockError());
		return;
	}

	// Show up the table dialog-box that displays the string block.
	tblDlgData.strAppName	= strAppName;
	tblDlgData.nBlockID		= nBlockID;
	tblDlgData.wStrID		= static_cast<WORD>(s_langInfo[nSel].nStrID);
	tblDlgData.hStrBlock	= hStrBlock;

	DialogBoxParam(GetAppInstance(), MAKEINTRESOURCE(IDD_DIALOG_TABLE), hWnd, 
				   Table_DlgProc, reinterpret_cast<LPARAM>(&tblDlgData));

	// Delete the string block.
	DeleteStringBlock(hStrBlock);
}
示例#12
0
double BezierCurve::bCoef(double n, double i, double t)
{
	//double n: is the degree of our curve, in the case of a cubic curve it is 3
	//double i: the index of the Bernstein coefficient and the control point
	//double t: is the time we are evaluating at

	//Calculate the Bernstein coefficient
	return combo(n, i) * pow(1.0 - t, n - i) * pow(t, i);
}
示例#13
0
void QmvBoolItem::setValue( const QString & v )
{
    if ( ( !hasSubItems() || !isOpen() )
	 && value() == v )
	return;

    if ( comb ) {
	combo()->blockSignals( TRUE );
	if ( v == str_true )
	    combo()->setCurrentItem( 1 );
	else
	    combo()->setCurrentItem( 0 );
	combo()->blockSignals( FALSE );
    }
    
    setText( 1, v );
    QmvItem::setValue( v );
}
示例#14
0
文件: combo.c 项目: julesy89/ttp-java
static void definesolution(allinfo *a)
{
  register item *i, *h, *m;
  register stype psum, wsum, ws;
  item *f, *l;
  btype j, k;
  long t;

  /* endtime(&t); */

  /* full solutions are easy to update */
  if (a->fullsol) {
    for (i = a->fitem, m = a->litem+1, h = a->ffull; i != m; i++,h++) *i = *h;
    return;
  }

  /* partial solutions are more difficult as we only have MAXV last changes */

  /* initialize break solution */
  for (i = a->fitem, m = a->b; i != m; i++) i->x = 1;
  for (i = a->b, m = a->litem+1; i != m; i++) i->x = 0;

  /* backtrack vector */
  psum = a->z - a->psumb;
  wsum = a->zwsum - a->wsumb;
  f    = a->fsol;
  l    = a->lsol;

  /* backtrack */
  for (j = 0; j < MAXV; j++) {
    i = a->d.ovitem[j]; if (i == NULL) continue;
    k = a->d.ovect & ((btype) 1 << j);
    if (i->x == 1) {
      if (i > f) f = i;
      if (k) { psum += i->p; wsum += i->w; i->x = 0; }
    } else {
      if (i < l) l = i;
      if (k) { psum -= i->p; wsum -= i->w; i->x = 1; }
    }
  }
  if ((psum == 0) && (wsum == 0)) return;

  f++; l--; /* new core */
  psum = a->z; wsum = a->zwsum; iterates++;
  if (f > l) error("wrong backtrack");
  for (i=a->fitem, m = f; i != m; i++) if (i->x) { psum-=i->p; wsum-=i->w; }
  for (i=l+1, m=a->litem+1; i != m; i++) if (i->x) { psum-=i->p; wsum-=i->w; }
  for (i = f, m = l+1, ws = 0; i != m; i++) ws += i->w; 
  if (ws == wsum) { 
    for (i = f, m = l+1; i != m; i++) i->x = 1;
  } else {
    combo(f, l, wsum, psum-1, psum, TRUE, TRUE);
  }
}
示例#15
0
void QmvBoolItem::showEditor()
{
    QmvItem::showEditor();
    if ( !comb ) {
	combo()->blockSignals( TRUE );
	if ( value() == str_true )
	    combo()->setCurrentItem( 0 );
	else
	    combo()->setCurrentItem( 1 );
	combo()->blockSignals( FALSE );
    }
    placeEditor( combo() );
    if ( !combo()->isVisible()  || !combo()->hasFocus() ) {
	combo()->show();
	setFocus( combo() );
    }
}
示例#16
0
void PhotonEstimationTask::EstimatePhotonsForObjectAndLight(ObjectPtr Object, LightSource *Light)
{
	int mergedFlags=0;             /* merged flags to see if we should shoot photons */
	ViewThreadData *renderDataPtr = GetViewDataPtr();

	/* first, check on various flags... make sure all is a go for this ObjectPtr */
	LightTargetCombo combo(Light,Object);
	mergedFlags = combo.computeMergedFlags();

	if (!( ((mergedFlags & PH_RFR_ON_FLAG) && !(mergedFlags & PH_RFR_OFF_FLAG)) ||
	       ((mergedFlags & PH_RFL_ON_FLAG) && !(mergedFlags & PH_RFL_OFF_FLAG)) ))
		/* it is a no-go for this object... bail out now */
		return;

	if(!Object) return;

	ShootingDirection shootingDirection(Light,Object);
	shootingDirection.compute();

	/* calculate the spacial separation (spread) */
	renderDataPtr->photonSpread = combo.target->Ph_Density*GetSceneData()->photonSettings.surfaceSeparation;

	/* if rays aren't parallel, divide by dist so we get separation at a distance of 1 unit */
	if (!combo.light->Parallel)
	{
		renderDataPtr->photonSpread /= shootingDirection.dist;
	}

	/* try to guess the number of photons */
	DBL x=shootingDirection.rad / (combo.target->Ph_Density*GetSceneData()->photonSettings.surfaceSeparation);
	x=x*x*M_PI;

	if ( ((mergedFlags & PH_RFR_ON_FLAG) && !(mergedFlags & PH_RFR_OFF_FLAG)) &&
	     ((mergedFlags & PH_RFL_ON_FLAG) && !(mergedFlags & PH_RFL_OFF_FLAG)) )
	{
		x *= 1.5;  /* assume 2 times as many photons with both reflection & refraction */
	}

	if ( !Test_Flag(combo.target, PH_IGNORE_PHOTONS_FLAG) )
	{
		if ( ((mergedFlags & PH_RFR_ON_FLAG) && !(mergedFlags & PH_RFR_OFF_FLAG)) )
		{
			if ( ((mergedFlags & PH_RFL_ON_FLAG) && !(mergedFlags & PH_RFL_OFF_FLAG)) )
				x *= 3;  /* assume 3 times as many photons if ignore_photons not used */
			else
				x *= 2;  /* assume less for only refraction */
		}
	}

	x *= 0.5;  /* assume 1/2 of photons hit target ObjectPtr */

	photonCountEstimate += x;
}
示例#17
0
void LLPanelLogin::removeLogin(bool knot)
{
	if (knot) return;
	LLComboBox* combo(getChild<LLComboBox>("username_combo"));
	const std::string label(combo->getTextEntry());
	if (combo->isTextDirty() || !combo->itemExists(label)) return; // Text entries aren't in the list
	const LLSD& selected = combo->getSelectedValue();
	if (!selected.isUndefined())
	{
		mLoginHistoryData.deleteEntry(selected.get("firstname").asString(), selected.get("lastname").asString(), selected.get("grid").asString());
		combo->remove(label);
		combo->selectFirstItem();
	}
}
示例#18
0
/*

	Overload operator+ to return the concatenation of two lists

*/
AListInt AListInt::operator+(const AListInt& other) const {
	AListInt combo(this->_size + other._size);
	int current_pos = 0;
	if(!this->empty()) {
		for(unsigned int i =0; i < this->_size; ++i) {
			combo.insert(current_pos, this->_data[i]);
			current_pos++;
		}
	}
	if(!other.empty()) {
		for(unsigned int i=0; i <other._size; ++i) {
			combo.insert(current_pos, other._data[i]);
			current_pos++;
		}
	}
	return combo;
}
示例#19
0
void QmvListItem::showEditor()
{
    QmvItem::showEditor();
    if ( !comb )
        combo();
    
    placeEditor( combo() );
    if ( !combo()->isVisible()  || !combo()->hasFocus() ) {
	combo()->show();
	setFocus( combo() );
    }
}
示例#20
0
int ComboWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = CmdWidget::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: { QString _r = text();
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 1: setText((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 2: updateCombo(); break;
        case 3: updateComboVariableSafet((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 4: updateComboVariableSafet(); break;
        case 5: updateComboAutofilterSafet((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 6: updateComboAutofilterSafet(); break;
        case 7: updateComboRecursivefilterSafet((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 8: updateComboRecursivefilterSafet(); break;
        case 9: updateComboListTable((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 10: updateComboListTable(); break;
        case 11: updateComboListLiteral(); break;
        case 12: updateVarGlobal((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 13: updateComboFlow((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 14: updateComboFlow(); break;
        case 15: updateComboConffileSafet((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 16: updateComboConffileSafet(); break;
        case 17: updateComboColorSafet((*reinterpret_cast< bool(*)>(_a[1]))); break;
        case 18: updateComboColorSafet(); break;
        case 19: viewdoc(); break;
        case 20: selColor(); break;
        case 21: insertAndClose(); break;
        case 22: { QString _r = getRealValue((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 23: { QString _r = getVarValue((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        case 24: itemsValueList(); break;
        case 25: itemsRealValueList(); break;
        case 26: { QComboBox* _r = combo();
            if (_a[0]) *reinterpret_cast< QComboBox**>(_a[0]) = _r; }  break;
        case 27: { QString _r = findkeyvalue((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< QString*>(_a[0]) = _r; }  break;
        }
        _id -= 28;
    }
    return _id;
}
示例#21
0
bool CDatabaseQueryRuleCombination::Load(const CVariant &obj, const IDatabaseQueryRuleFactory *factory)
{
  if (!obj.isObject() && !obj.isArray())
    return false;
  
  CVariant child;
  if (obj.isObject())
  {
    if (obj.isMember("and") && obj["and"].isArray())
    {
      m_type = CombinationAnd;
      child = obj["and"];
    }
    else if (obj.isMember("or") && obj["or"].isArray())
    {
      m_type = CombinationOr;
      child = obj["or"];
    }
    else
      return false;
  }
  else
    child = obj;

  for (CVariant::const_iterator_array it = child.begin_array(); it != child.end_array(); it++)
  {
    if (!it->isObject())
      continue;

    if (it->isMember("and") || it->isMember("or"))
    {
      std::shared_ptr<CDatabaseQueryRuleCombination> combo(factory->CreateCombination());
      if (combo && combo->Load(*it, factory))
        m_combinations.push_back(combo);
    }
    else
    {
      std::shared_ptr<CDatabaseQueryRule> rule(factory->CreateRule());
      if (rule && rule->Load(*it))
        m_rules.push_back(rule);
    }
  }

  return true;
}
示例#22
0
bool CTextPropertyToolBar::Create(CWnd* pParentWnd)
{
	if (!this->CreateEx(pParentWnd, AFX_DEFAULT_TOOLBAR_STYLE,  WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_TOP, { 1,1,1,1 }, ID_TB_TEXT))
	{
		TRACE0("Failed to create toolbar\n");
		return false;
	}

	//m_textToolBar.SetPaneStyle(m_textToolBar.GetPaneStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);

	std::vector<ButtonInfo> buttons = theResources.GetTextToolBarButtons();
	for (std::vector<ButtonInfo>::iterator it_buttons = buttons.begin(); it_buttons != buttons.end(); it_buttons++)
	{
		this->LoadBitmap(it_buttons->uiImageResId, 0, 0, TRUE);
		CMFCToolBarButton button(it_buttons->uiCommandId, this->GetAllButtons().GetCount(), it_buttons->strText);
		button.SetStyle(TBBS_CHECKBOX);
		this->InsertButton(button, this->GetAllButtons().GetCount());
	}
	//this->SetOwner(this);
	//this->SetRouteCommandsViaFrame(FALSE);
	//m_textToolBar.EnableCustomizeButton(TRUE, 0, L"");

	CMFCToolBarComboBoxButton combo(ID_FONTCOMBO_TEXT, 0);
	EnumFontFamilies(GetDC()->GetSafeHdc(), NULL,
		(FONTENUMPROC)EnumFamCallBack, (LPARAM)&combo);
	this->InsertButton(combo, this->GetAllButtons().GetCount());

	CMFCToolBarComboBoxButton combo2(ID_SIZECOMBO_TEXT, 0, CBS_DROPDOWNLIST, 40);
	for (int i = 5; i < 16; i++)
	{
		CString size;
		size.Format(_T("%d"), i);
		combo2.AddItem(size);
	}
	this->InsertButton(combo2, this->GetAllButtons().GetCount());

	this->SetWindowText(L"Text Property");
	this->EnableDocking(CBRS_TOP);

	this->EnableReflections();

	return true;
}
示例#23
0
文件: combo.c 项目: julesy89/ttp-java
static void solvesur(allinfo *a, item *f, item *l, stype minsur, stype maxsur, 
              ntype card, stype *ub)
{
  register item *i, *k, *m;
  register stype ps, csur;
  register ntype no;
  stype sur, u, z1;
  boolean feasible;
 
  /* find optimal surrogate multiplier, and update ub */
  surbin(f, l, minsur, maxsur, a->c, a->dantzig, card, &sur, &u);
  optsur = sur;

  /* if bound <= current solution return */
  if ((u <= a->z) || (sur == 0)) {
    if (u > *ub) *ub = u;
    return;
  }
 
  /* add sur to weights and remove items with negative weight */
  csur = a->c + sur * (long) card; ps = 0;
  for (i = f, k = f, m = l+1; i != m; i++) {
    i->w += sur; i->x = 0;
    if (i->w <= 0) { ps += i->p; csur -= i->w; i->x = 1; SWAP(i, k); k++; }
  }

  /* solve problem to optimality */
  z1 = ps + combo(k, l, csur, a->z-ps, 0, TRUE, TRUE);

  /* subtract weight and check cardinality */
  for (i = f, m = l+1, no = 0; i != m; i++) { i->w -= sur; if (i->x) no++; }

  /* if feasible cardinality and improved, save solution in extra array */
  feasible = (no == card); if (feasible) relfeasible++;
  if ((z1 > a->z) && (feasible)) {
    for (i = f, k = a->ffull, m = l+1; i != m; i++, k++) *k = *i;
    a->z = z1; a->fullsol = TRUE;
  }

  /* output: maintain global upper bound */
  if (z1 > *ub) *ub = z1;
}
示例#24
0
void Nmr::on_systemCombo_currentIndexChanged(QString const& text)
{
   QString isotope(currentIsotope());

   Data::NmrReferenceLibrary& library(Data::NmrReferenceLibrary::instance());
   QString method(m_data.method());
   QList<Data::NmrReference const*> refs(library.filter(isotope, text, method));

   QStringList methods;
   QList<Data::NmrReference const*>::iterator iter;
   for (iter = refs.begin(); iter != refs.end(); ++iter) {
       method = (*iter)->method();
       if (!methods.contains(method)) methods.append(method);
   }

   QComboBox* combo(m_ui->methodCombo);
   combo->clear();
   combo->addItems(methods);

   loadShifts(currentReference(), isotope);
   updatePlot();
}
示例#25
0
int main()
{
  read_set_pars("../data_pars");
  read_input("analysis_pars");
  
  
  ////////////////////////// P5 Kaon /////////////////////
  
  jack M_K_P5,ZL_K_P5,ZS_K_P5;
  
  {
    //load P5 Kaon
    jvec K_P5_corr_SL=load_2pts("../CORRELATORS/2pts_P5P5_30_00",RE,L_S_2PTS[im_S0],L_S_2PTS[im_spec]).simmetrized(1);
    jvec K_P5_corr_SS=load_2pts("../CORRELATORS/2pts_P5P5_30_30",RE,L_S_2PTS[im_S0],L_S_2PTS[im_spec]).simmetrized(1);
    
    //fit P5 Kaon
    two_pts_SL_fit(M_K_P5,ZL_K_P5,ZS_K_P5,K_P5_corr_SL,K_P5_corr_SS,tmin_K,tmax_K,tmin_K,tmax_K,"masses_Z/plots/M_K_P5_fit.xmg");
    
    //write the mass and Z
    {
      ofstream raw("masses_Z/plots/raw_K.xmg");
      raw<<"@type xydy"<<endl;
      raw<<K_P5_corr_SL<<"&"<<endl<<K_P5_corr_SS<<endl;
    }
    M_K_P5.write_to_binfile("masses_Z/M_K_P5");
    ZL_K_P5.write_to_binfile("masses_Z/Z_K_P5");

    cout<<"MK "<<M_K_P5<<endl;
    cout<<"ZL2K "<<sqr(ZL_K_P5)<<", ZLK "<<ZL_K_P5<<endl;
    cout<<"ZS2K "<<sqr(ZS_K_P5)<<", ZSK "<<ZS_K_P5<<endl;
  }
    
  /////////////////////////// VK Kaon /////////////////////
  
  /*
    
  jack M_K_VK,ZL_K_VK,ZS_K_VK;
  
  {
    //load VK Kaon
    jvec K_VK_corr_SL=load_2pts("../CORRELATORS/2pts_VKVK_30_00",RE,L_S_2PTS[im_S0],L_S_2PTS[im_spec]).simmetrized(1);
    jvec K_VK_corr_SS=load_2pts("../CORRELATORS/2pts_VKVK_30_30",RE,L_S_2PTS[im_S0],L_S_2PTS[im_spec]).simmetrized(1);
    
    //fit VK Kaon
    two_pts_SL_fit(M_K_VK,ZL_K_VK,ZS_K_VK,K_VK_corr_SL,K_VK_corr_SS,tmin_K,tmax_K,tmin_K,tmax_K,"masses_Z/plots/M_K_VK_fit.xmg");
    
    //write the mass and Z
    M_K_VK.write_to_binfile("masses_Z/M_K_VK");
    ZL_K_VK.write_to_binfile("masses_Z/Z_K_VK");
  }
  */
  
  ////////////////////////// P5 Heavy //////////////////////
  
  //determine M and Z for H meson
  jack M_H_P5,ZL_H_P5,ZS_H_P5;
  
  {
    //load H
    jvec H_P5_corr_SL=load_2pts("../CORRELATORS/2pts_P5P5_30_00",RE,H_S_2PTS[im_S1],L_S_2PTS[im_spec]).simmetrized(1);
    jvec H_P5_corr_SS=load_2pts("../CORRELATORS/2pts_P5P5_30_30",RE,H_S_2PTS[im_S1],L_S_2PTS[im_spec]).simmetrized(1);
    
    //fit H
    two_pts_SL_fit(M_H_P5,ZL_H_P5,ZS_H_P5,H_P5_corr_SL,H_P5_corr_SS,tmin_H,tmax_H,tmin_H,tmax_H,
		   "masses_Z/plots/M_H_P5_fit_SL.xmg","masses_Z/plots/M_H_P5_fit_SS.xmg");
    
    //write the mass and Z
    {
      ofstream raw("masses_Z/plots/raw_H.xmg");
      raw<<"@type xydy"<<endl;
      raw<<H_P5_corr_SL<<"&"<<endl<<H_P5_corr_SS<<endl;
    }
    M_H_P5.write_to_binfile("masses_Z/M_H_P5");
    ZL_H_P5.write_to_binfile("masses_Z/Z_H_P5");
    
    cout<<"MH "<<M_H_P5<<endl;
    cout<<"ZL2H "<<sqr(ZL_H_P5)<<endl;
    cout<<"ZS2H "<<sqr(ZS_H_P5)<<endl;
  }
  
  //////////////////////////////////// P5 {AK,BK,P5,VJ,TJ} VK ////////////////////////////////
  
  //compute matrix elements
  for(int i_ME=0;i_ME<n_ME;i_ME++)
    {
      info_3pts info=info_ME[i_ME];
      
      //create the name with "_"
      char spaced_name[12];
      sprintf(spaced_name,"P5_%c%c_%s",*info.name,*(info.name+1),info.name+2);
      
      //open the output
      ofstream out_ME(combine("matrix_elements/plots/%s.xmg",spaced_name).c_str());
      
      //stored TK for null theta
      jvec null_TKP5,null_VKP5;
      
      //loop over theta
      jvec ME(nth_S0,njack);
      for(int ith=0;ith<nth_S0;ith++)
	{
	  //find the combo
	  combo_3pts combo(SPEC[im_spec],L_S0_3PTS[im_S0],H_S1_3PTS[im_S1],ith);
	  
	  //define the temporal dependance
	  //jack E_K_PV=latt_en((info.name[2]=='P')?M_K_P5:M_K_VK,th_S0[ith]);
	  jack E_K_PV=latt_en(M_K_P5,th_S0[ith]);
	  jvec dT(tsep+1,njack);
	  for(int t=0;t<=tsep;t++)
	    dT[t]=(ZS_K_P5*ZS_H_P5)/(2*E_K_PV*2*M_H_P5)*exp(-E_K_PV*t)*exp(-M_H_P5*(tsep-t));
	  
	  //load the corr and divide it by dT
	  jvec H_P5_ME_K_PV_corr=load_3pts(info,combo);
	  
	  //store "0" for TK
	  if(i_ME==3)
	    {
	      if(ith==0) null_TKP5=H_P5_ME_K_PV_corr;
	      else H_P5_ME_K_PV_corr-=null_TKP5;
	    }
	  
	  //print raw for V0
	  if(i_ME==2) H_P5_ME_K_PV_corr.print_to_file(combine("matrix_elements/plots/raw_V0%d.xmg",ith).c_str());

	  //same for VK
	  if(i_ME==1)
	    {
	      H_P5_ME_K_PV_corr.print_to_file(combine("matrix_elements/plots/raw_VK%d.xmg",ith).c_str());
	      
	      if(ith==0) null_VKP5=H_P5_ME_K_PV_corr;
	      else H_P5_ME_K_PV_corr-=null_VKP5;
	    }
	  
	  H_P5_ME_K_PV_corr/=dT;

	  int tmin_ME=tmin_VK,tmax_ME=tmax_VK;
	  if(i_ME==1){tmin_ME=tmin_VK;tmax_ME=tmax_VK;}
	  if(i_ME==2){tmin_ME=tmin_V0;tmax_ME=tmax_V0;}
	  if(i_ME==3){tmin_ME=tmin_TK;tmax_ME=tmax_TK;}
	  ME[ith]=constant_fit(H_P5_ME_K_PV_corr,tmin_ME,tmax_ME);

	  //output
	  if(ith<5) out_ME<<"@type xydy\n"<<H_P5_ME_K_PV_corr<<"&\n@type xy\n"<<write_constant_with_error(ME[ith],tmin_ME,tmax_ME)<<"&\n";
	}
      
      //write 
      ME.write_to_binfile(combine("matrix_elements/%s",spaced_name).c_str());
    }
  
  //divita ratios
  {
    ofstream out_1("matrix_elements/plots/divita_ratio1.xmg");
    ofstream out_2("matrix_elements/plots/divita_ratio2.xmg");
    ofstream out_3("matrix_elements/plots/divita_ratio3.xmg");
    out_1<<"@type xydy"<<endl;
    out_2<<"@type xydy"<<endl;
    out_3<<"@type xydy"<<endl;
    jvec rat_1(nth_S0,njack);
    jvec rat_2(nth_S0,njack);
    jvec rat_3(nth_S0,njack);
    for(int ith=0;ith<nth_S0;ith++)
	{
	  //find the combo
	  int iVK=1,iV0=2,iTK=3;
	  combo_3pts combo_th(SPEC[im_spec],L_S0_3PTS[im_S0],H_S1_3PTS[im_S1],ith);
	  combo_3pts combo_0(SPEC[im_spec],L_S0_3PTS[im_S0],H_S1_3PTS[im_S1],0);
	  
	  //compute deltaE
	  jack E_K_P5=latt_en(M_K_P5,th_S0[ith]);
	  jack D_K_P5=E_K_P5-M_K_P5;

	  //load and take note
	  jvec rat_1_corr=load_3pts(info_ME[iV0],combo_th)/load_3pts(info_ME[iV0],combo_0);
	  for(int t=0;t<=tsep;t++) rat_1_corr[t]*=exp(D_K_P5*t)*E_K_P5/M_K_P5;
	  rat_1[ith]=constant_fit(rat_1_corr,tmin_VK,tmax_VK);
	  
	  //load and take note
	  jvec rat_2_corr=load_3pts(info_ME[iVK],combo_th)/load_3pts(info_ME[iV0],combo_th)-
	    load_3pts(info_ME[iVK],combo_0)/load_3pts(info_ME[iV0],combo_0);
	  rat_2[ith]=constant_fit(rat_2_corr,tmin_VK,tmax_VK);

	  jvec rat_3_corr=(load_3pts(info_ME[iTK],combo_th)-load_3pts(info_ME[iTK],combo_0))/
	    (load_3pts(info_ME[iVK],combo_th)-load_3pts(info_ME[iVK],combo_0));
	  rat_3[ith]=constant_fit(rat_3_corr,tmin_VK,tmax_VK);


          out_1<<"@type xydy\n"<<rat_1_corr<<"&\n@type xy\n"<<write_constant_with_error(rat_1[ith],tmin_VK,tmax_VK)<<"&\n";
          out_2<<"@type xydy\n"<<rat_2_corr<<"&\n@type xy\n"<<write_constant_with_error(rat_2[ith],tmin_VK,tmax_VK)<<"&\n";
          if(ith) out_3<<"@type xydy\n"<<rat_3_corr<<"&\n@type xy\n"<<write_constant_with_error(rat_3[ith],tmin_VK,tmax_VK)<<"&\n";
	}
    
    rat_1.write_to_binfile("matrix_elements/divita_ratio_1");
    rat_2.write_to_binfile("matrix_elements/divita_ratio_2");
    rat_3.write_to_binfile("matrix_elements/divita_ratio_3");
  }
  
  return 0;
}
示例#26
0
int main() {
    Combo<ExampleEnumeration> combo({{ExampleEnumeration::A, "a"},  //
                                     {ExampleEnumeration::B, "b"},  //
                                     {ExampleEnumeration::C, "c"}});
}
void KisGmicSettingsWidget::createSettingsWidget(ROLE role)
{

    QList<Parameter *> parameters = m_commandDefinition->m_parameters;

    if (parameters.size() == 0)
    {
        dbgPlugins << "No parameters!";
        return;
    }

    QGridLayout * gridLayout(0);
    if (role == CreateRole)
    {
        gridLayout = new QGridLayout(this);
    }

    int row = 0;
    for (int i = 0; i < parameters.size();i++)
    {
        Parameter * p = parameters.at(i);
        dbgPlugins << "Processing: " << qPrintable(p->typeName()) << " " << qPrintable(p->toString());
        switch (p->m_type)
        {
            case Parameter::INT_P:
            {
                IntParameter * intParam = static_cast<IntParameter *>(p);
                KisSliderSpinBox * spinBox(0);
                if (role == CreateRole)
                {
                    spinBox = new KisSliderSpinBox;
                    spinBox->setMinimum(intParam->m_minValue);
                    spinBox->setMaximum(intParam->m_maxValue);

                    // map widget to parameter index
                    m_widgetToParameterIndexMapper[spinBox] = i;
                    mapParameterWidget(intParam, spinBox);

                    // TODO: check if it should update preview!!!, only then recompute preview
                    connect(spinBox, SIGNAL(valueChanged(int)), this, SIGNAL(sigConfigurationItemChanged()));
                    connect(spinBox, SIGNAL(valueChanged(int)), this, SLOT(setIntValue(int)));

                    gridLayout->addWidget(new QLabel(intParam->name()), row, 0);
                    gridLayout->addWidget(spinBox, row, 1, 1, 3);

                    row++;
                }
                else if (role == LoadRole)
                {
                    spinBox = qobject_cast<KisSliderSpinBox *>(widget(intParam));
                }

                if (spinBox)
                {
                    spinBox->setValue(intParam->m_value);
                }
                else
                {
                    dbgPlugins << "Widget not available; Role: " << role << p->m_type;
                }
                break;
            }
            case Parameter::FLOAT_P:
            {
                FloatParameter * floatParam = static_cast<FloatParameter *>(p);

                KisDoubleSliderSpinBox * spinBox(0);
                if (role == CreateRole)
                {
                    spinBox = new KisDoubleSliderSpinBox;
                    // TODO: check if 2 decimals is correct
                    spinBox->setRange(floatParam->m_minValue, floatParam->m_maxValue, 2);

                    m_widgetToParameterIndexMapper[spinBox] = i;
                    mapParameterWidget(floatParam, spinBox);

                    connect(spinBox, SIGNAL(valueChanged(qreal)), this, SIGNAL(sigConfigurationItemChanged()));
                    connect(spinBox, SIGNAL(valueChanged(qreal)), this, SLOT(setFloatValue(qreal)));

                    gridLayout->addWidget(new QLabel(floatParam->name()), row, 0);
                    gridLayout->addWidget(spinBox, row, 1, 1, 3);
                    row++;
                }
                else if (role == LoadRole)
                {
                    spinBox = qobject_cast<KisDoubleSliderSpinBox *>(widget(floatParam));
                }

                if (spinBox)
                {
                    spinBox->setValue(floatParam->m_value);
                }
                else
                {
                    dbgPlugins << "Widget not available; Role: " << role << " TYPE " <<p->m_type;
                }
                break;
            }
            case Parameter::CHOICE_P:
            {
                ChoiceParameter * choiceParam = static_cast<ChoiceParameter *>(p);

                QComboBox * combo(0);
                if (role == CreateRole)
                {
                    combo = new QComboBox;
                    QStringListModel *model = new QStringListModel();
                    model->setStringList(choiceParam->m_choices);
                    combo->setModel(model);

                    m_widgetToParameterIndexMapper[combo] = i;
                    mapParameterWidget(choiceParam, combo);

                    connect(combo, SIGNAL(currentIndexChanged(QString)), this, SIGNAL(sigConfigurationItemChanged()));
                    connect(combo, SIGNAL(currentIndexChanged(int)), this, SLOT(setChoiceIndex(int)));

                    gridLayout->addWidget(new QLabel(choiceParam->name()), row, 0);
                    gridLayout->addWidget(combo, row, 1, 1, 3);
                    row++;
                }
                else if (role == LoadRole)
示例#28
0
BOOL ILaunchDialog::event_command(int control_id, int notify_code)
{
	if(control_id == IDCANCEL)
	{
		destroy();
		return TRUE;
	}
	if(notify_code == BN_CLICKED)
	{
		switch(control_id)
		{
		case ID_BT_CLIENTDIR:
			choose_client_dir();
			return TRUE;
		case ID_BT_SERVERS:
		{
			EditServersDialog dialog(m_config.get_servers());
			// Returns zero if the dialog was cancelled.
			if(dialog.open(m_hwnd) != 0)
			{
				m_config.set_servers(dialog.get_list());
				update_servers_box();
			}
			return TRUE;
		}
		case ID_BT_CLIENTS:
		{
			EditClientsDialog dialog(m_config.get_clients());
			// Returns zero if the dialog was cancelled.
			if(dialog.open(m_hwnd) != 0)
			{
				m_config.set_clients(dialog.get_list());
				update_clients_box();
			}
			return TRUE;
		}
		case ID_BT_IGNITIONCFG:
			choose_ignition_cfg();
			return TRUE;
		case ID_CH_INJECTION:
		{
			ButtonWrapper check_box(m_hwnd, ID_CH_INJECTION);
			m_config.set_use_injection(check_box.get_check());
			return TRUE;
		}
		case ID_CH_CLOSEWHENDONE:
		{
			ButtonWrapper check_box(m_hwnd, ID_CH_CLOSEWHENDONE);
			m_config.set_close(check_box.get_check());
			return TRUE;
		}
		case ID_BT_LAUNCH:
		{
			ButtonWrapper check_box(m_hwnd, ID_CH_INJECTION);
			m_config.set_use_injection(check_box.get_check());
			// Open launch dialog.
			if(m_launching_dialog.open(m_hwnd, m_config, m_address.c_str(),
					m_username.c_str(), m_password.c_str(),
					m_client_path.c_str()) && m_config.get_close())
				// Close the program.
				destroy();
			return TRUE;
		}
		}
	}
	else if(notify_code == CBN_SELCHANGE)
	{
		if(control_id == ID_CB_SERVER)
		{
			ComboBoxWrapper combo(m_hwnd, ID_CB_SERVER);
			int i = combo.get_current_selection();

			if(i != -1)
			{
				ILaunchConfig::serverlist_t & servers=(m_config.get_servers());
				if(i >= 0 && static_cast<size_t>(i) < servers.size())
				{
					m_address = servers[i].m_address;
					m_username = servers[i].m_username;
					m_password = servers[i].m_password;
					m_config.set_last_server(i);
					SetDlgItemText(m_hwnd, ID_ST_ADDRESS, m_address.c_str());
				}
			}
			return TRUE;
		}
		else if(control_id == ID_CB_CLIENT)
		{
			ComboBoxWrapper combo(m_hwnd, ID_CB_CLIENT);
			int i = combo.get_current_selection();

			if(i != -1)
			{
				ILaunchConfig::clientlist_t & clients=(m_config.get_clients());
				if(i >= 0 && static_cast<size_t>(i) < clients.size())
				{
					m_client_path = clients[i].m_path;
					m_config.set_last_client(i);
					SetDlgItemText(m_hwnd, ID_ST_EXEPATH,
						m_client_path.c_str());
				}
			}
			return TRUE;
		}
	}
	return FALSE;
}
示例#29
0
void QmvBoolItem::hideEditor()
{
    QmvItem::hideEditor();
    combo()->hide();
}
示例#30
0
void QmvListItem::hideEditor()
{
    QmvItem::hideEditor();
    combo()->hide();
}