Exemplo n.º 1
0
J9TDFGroup *
TraceGen::getDefaultGroupSet(unsigned int *groupCount)
{
	J9TDFGroup *head = NULL;
	*groupCount = 0;

	/* pre-populate groups */
	J9TDFGroup *prePop = NULL;

	prePop = newGroup("Entry", groupCount);
	if (NULL == prePop) {
		eprintf("Failed to allocate memory");
		goto failed;
	}
	prePop->nextGroup = head;
	head = prePop;

	prePop = newGroup("Exit", groupCount);
	if (NULL == prePop) {
		eprintf("Failed to allocate memory");
		goto failed;
	}
	prePop->nextGroup = head;
	head = prePop;

	prePop = newGroup("Event", groupCount);
	if (NULL == prePop) {
		eprintf("Failed to allocate memory");
		goto failed;
	}
	prePop->nextGroup = head;
	head = prePop;

	prePop = newGroup("Exception", groupCount);
	if (NULL == prePop) {
		eprintf("Failed to allocate memory");
		goto failed;
	}
	prePop->nextGroup = head;
	head = prePop;

	prePop = newGroup("Debug", groupCount);
	if (NULL == prePop) {
		eprintf("Failed to allocate memory");
		goto failed;
	}
	prePop->nextGroup = head;
	head = prePop;

	return head;

failed:
	freeGroups(head);
	head = NULL;
	return NULL;
}
void FedgeConfigAccounts::slotKmail() {
		
	KConfig config("kmailrc", true);
	QStringList list;
	QMap<QString, QString> configmap;
	int i = 1;

	while (config.hasGroup("Account " + QString::number(i))) {

		QString account = "Account " + QString::number(i++);
		configmap = config.entryMap(account);	
		if (!configmap.empty()) list << account;
	} 

	int accno = 1;

	if (list.empty()) return;
	if (list.size() > 1) {

		FedgeSelectDialog fsd(0, "Select Kmail Account:", list);
		accno = fsd.exec();	
	}

	KmailAccount account("Account " + QString::number(accno));

	m_config->setGroup(newGroup());
	addAccount(&account);
	
	m_changed = true;
   emit accountsChanged();
}
Exemplo n.º 3
0
Arquivo: vartree.c Projeto: dzhus/knr
/**
    Add a variable occurency to tree
*/
Group * insertGroup(Group * g_root, char * tag, char * name, int line)
{
  int cmp;
  
#ifdef DEBUG
  printf("Got %s, %s at %d\n", tag, name, line);
#endif
  
  if (g_root == NULL)
    {
      g_root = newGroup(tag);
      g_root->var = insertVariable(g_root->var, name, line);
    }
  else
    if ((cmp = strcmp(tag, g_root->tag)) == 0)
      {
        g_root->total_count++;
        g_root->var = insertVariable(g_root->var, name, line);
      }
    else
      if (cmp > 0)
        g_root->right = insertGroup(g_root->right, tag, name, line);
      else
        g_root->left = insertGroup(g_root->left, tag, name, line);
  
  return g_root;
}
Exemplo n.º 4
0
void GxsGroupDialog::initMode()
{
	setAllReadonly();
	switch (mode())
	{
		case MODE_CREATE:
		{
            ui.stackedWidget->setCurrentIndex(0);
			ui.buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
			newGroup();
		}
		break;

		case MODE_SHOW:
		{
			ui.stackedWidget->setCurrentIndex(1);
			mReadonlyFlags = 0xffffffff; // Force all to readonly.
			ui.buttonBox->setStandardButtons(QDialogButtonBox::Close);
			requestGroup(mGrpMeta.mGroupId);
		}
		break;

		case MODE_EDIT:
		{
            ui.stackedWidget->setCurrentIndex(0);
			ui.buttonBox->setStandardButtons(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
			ui.buttonBox->button(QDialogButtonBox::Ok)->setText(tr("Submit Group Changes"));
			requestGroup(mGrpMeta.mGroupId);
		}
		break;
	}
}
void ConstantTimeGroupCollection::addGroup(int newGroupExponent) {
#ifdef DEBUG
  if (newGroupExponent<=maxGroupExponent && newGroupExponent>=minGroupExponent) {
    std::cout << "StochKit ERROR (ConstantTimeGroupCollection::addGroup): (DEBUG flag set) attempted to add a group that already exists (newGroupExponent="<<newGroupExponent<<", current min="<<minGroupExponent<<", max="<<maxGroupExponent<<"). Terminating.\n";
    exit(1);
  }
#endif
  while (newGroupExponent<minGroupExponent) {
    ConstantTimeGroup newGroup(--minGroupExponent);
    groups.push_back(newGroup);
  }
  while (newGroupExponent>maxGroupExponent) {
    ConstantTimeGroup newGroup(++maxGroupExponent);
    groups.push_front(newGroup);    
  }
}
Exemplo n.º 6
0
static int group(int p1,int p2) {
  if(P_IS(p1,P_NOT_ALLOWED)) return p1;
  if(P_IS(p2,P_NOT_ALLOWED)) return p2;
  if(P_IS(p1,P_EMPTY)) return p2;
  if(P_IS(p2,P_EMPTY)) return p1;
  return newGroup(p1,p2);
}
Exemplo n.º 7
0
void Configuration::loadInformationToGroupsData()
{
    if(!documentObject.isEmpty() && m_data!=nullptr)
    {
        QJsonArray arrayGroupsName=documentObject["groups"].toArray();
        for(auto it:arrayGroupsName)
            if(it.toObject()["id"].toInt()!=-1)
                emit newGroup(it.toObject()["name"].toString(),it.toObject()["id"].toInt(),false);
    }
}
void AddgroupWidget::emit_signal_infosend()
{
    groupinfo gi;
    gi.id = getGroupsnum(username) + 1;
    gi.name = nameEdit->text();
    gi.friendsingroup = 0;
    newGroup(username, gi);
    emit infoSend(gi);
    close();
}
Exemplo n.º 9
0
void MGFixedBoard::syncall(int i, int j)
{
	if (board[i][j]->Num() != SENTINEL) {
		MGFixedPiece* piece = dynamic_cast<MGFixedPiece*>(board[i][j]);
		// 爆弾はグループなしとする
		// 以下では爆弾以外について考える
		// 上下左右の1マスを調べる

		// 周囲の爆弾数0のところとグループ同期

		int x, y;
		for (x = -1; x <= 1; x++){
			for (y = -1; y <= 1; y++){
				if (x + i >= 0 && x + i < sqrNum&&y + j >= 0 && y + j < sqrNum){
					sync(i, j, x + i, y + j);
				}
			}
		}

		/*int x = i, y = j - 1;
		if (y >= 0 && y < sqrNum) {
		// 1マス上のマスとグループを同期
		sync(i, j, x, y);
		}
		y = j + 1;
		if (y >= 0 && y < sqrNum) {
		// 1マス下のマスとグループを同期
		sync(i, j, x, y);
		}
		x = i - 1, y = j;
		if (x >= 0 && x < sqrNum) {
		// 1マス左のマスとグループを同期
		sync(i, j, x, y);
		}
		x = i + 1;
		if (x >= 0 && x < sqrNum) {
		// 1マス右のマスとグループを同期
		sync(i, j, x, y);
		}*/

		// ここまでで周囲とのグループ同期は完了
		// ここでまだグループ未所属(0)ならば新規グループを作る
		// ただし周囲の爆弾数0のところに限る
		if (piece->Group() == 0 && piece->Num() == 0) {
			try {
				newGroup(i, j);
			}
			catch (MGGroupError& err) {
				cout << err;
			}
		}
	}
}
Exemplo n.º 10
0
Group& Group::operator+(const Group &input) {
	shared_ptr<Group> newGroup(new Group());
	newGroup->setName(this->getName() + " and " + input.getName());
	list<Student> newList = this->getStudents();
	newList.insert(newList.end(), input.getStudents().begin(),
		input.getStudents().end());
	newGroup->setStudents(newList);
	newGroup->setStudentNumber(this->getStudentNumber()
		+ input.getStudentNumber());
	newGroup->setSubjNumber(this->getSubjNumber()
		+ input.getSubjNumber());
	return *newGroup;
}
Exemplo n.º 11
0
/* SAction::initActions
 * Loads and parses all SActions configured in actions.cfg in the
 * program resource archive
 *******************************************************************/
bool SAction::initActions()
{
	// Get actions.cfg from slade.pk3
	auto cfg_entry = theArchiveManager->programResourceArchive()->entryAtPath("actions.cfg");
	if (!cfg_entry)
		return false;

	Parser parser(cfg_entry->getParentDir());
	if (parser.parseText(cfg_entry->getMCData(), "actions.cfg"))
	{
		auto root = parser.parseTreeRoot();
		for (unsigned a = 0; a < root->nChildren(); a++)
		{
			auto node = root->getChildPTN(a);

			// Single action
			if (S_CMPNOCASE(node->type(), "action"))
			{
				auto action = new SAction(node->getName(), node->getName());
				if (action->parse(node))
					actions.push_back(action);
				else
					delete action;
			}

			// Group of actions
			else if (S_CMPNOCASE(node->getName(), "group"))
			{
				int group = newGroup();

				for (unsigned b = 0; b < node->nChildren(); b++)
				{
					auto group_node = node->getChildPTN(b);
					if (S_CMPNOCASE(group_node->type(), "action"))
					{
						auto action = new SAction(group_node->getName(), group_node->getName());
						if (action->parse(group_node))
						{
							action->group = group;
							actions.push_back(action);
						}
						else
							delete action;
					}
				}
			}
		}
	}

	return true;
}
void ConstantTimeGroupCollection::build(std::vector<double> &propensities) {
#ifdef DEBUG
  if (groups.size()>0 || maxGroupExponent!=std::numeric_limits<int>::min() || minGroupExponent!=std::numeric_limits<int>::max()) {
    std::cout << "StochKit ERROR (ConstantTimeGroupCollection::build): (DEBUG flag set) repeat call of build method? Terminating.\n";
    exit(1);
  }
#endif
  groups.clear();

  bool oneNonZeroPropensity=false;

  for (std::size_t i=0; i!=propensities.size(); ++i) {
#ifdef DEBUG
    std::cout << "building groups: propensity["<<i<<"]="<<propensities[i]<<"\n";
#endif
    if (!oneNonZeroPropensity) {
      if (propensities[i]>0.0) {
#ifdef DEBUG
	std::cout << "found first nonzero propensity\n";
#endif
	oneNonZeroPropensity=true;
	int exponent=ConstantTimeGroup::calculateGroupExponent(propensities[i]);
	minGroupExponent=exponent;
	maxGroupExponent=exponent;
	ConstantTimeGroup newGroup(exponent);
	groups.push_front(newGroup);
	groups[0].insert(propensities[i],i,withinGroupIndexes);
	propensitySum=propensities[i];
#ifdef DEBUG
	std::cout << "after pushing initial group (exponent="<<exponent<<") onto deque, groups.size="<<groups.size()<<"\n";
	printGroups();
#endif
      }
    }
    else {
      if (propensities[i]>0.0) {
	update(i,0.0,propensities[i]);
      }
    }
  }

  if (!oneNonZeroPropensity) {
    std::cout << "StochKit ERROR (ConstantTimeGroupCollection::build): All propensities are zero. Exiting.\n";
    exit(1);
  }
  
#ifdef DEBUG
  std::cout << "finished build...\n";
  printGroups();
#endif
}
// Add a new Group (if the name is not used yet) to the Groups list
bool EntityManager_AddGroup(EntityManager *entityManager, const char *name) {
  groupData *entity = NULL;

  if (entityManager == NULL || name == NULL) {
    snprintf(errStr, sizeof(errStr), "EntityManager_AddGroup entityManager (isNull %d) and user name '%s' must not be NULL", entityManager == NULL, name);
    return false;
  }
  if (checkAddValidParams(entityManager, name) == false) return false;
  if (newGroup(&entity, name) == false) return false;
  if (ItemsList_AddItem(entityManager->Groups, name, entity) == false) {
    freeGroup(entity);
    return false;
  }
  return true;
}
MultiColumnFragmentainerGroup& LayoutMultiColumnSet::appendNewFragmentainerGroup()
{
    MultiColumnFragmentainerGroup newGroup(*this);
    { // Extra scope here for previousGroup; it's potentially invalid once we modify the m_fragmentainerGroups Vector.
        MultiColumnFragmentainerGroup& previousGroup = m_fragmentainerGroups.last();

        // This is the flow thread block offset where |previousGroup| ends and |newGroup| takes over.
        LayoutUnit blockOffsetInFlowThread = previousGroup.logicalTopInFlowThread() + fragmentainerGroupCapacity(previousGroup);
        previousGroup.setLogicalBottomInFlowThread(blockOffsetInFlowThread);
        newGroup.setLogicalTopInFlowThread(blockOffsetInFlowThread);
        newGroup.setLogicalTop(previousGroup.logicalTop() + previousGroup.logicalHeight());
        newGroup.resetColumnHeight();
    }
    m_fragmentainerGroups.append(newGroup);
    return m_fragmentainerGroups.last();
}
Exemplo n.º 15
0
uiGroup *makePage7a(void)
{
	uiGroup *group;
	uiBox *box, *box2;

	handler.ah.Draw = handlerDraw;
	handler.ah.MouseEvent = handlerMouseEvent;
	handler.ah.MouseCrossed = handlerMouseCrossed;
	handler.ah.DragBroken = handlerDragBroken;
	handler.ah.KeyEvent = handlerKeyEvent;

	group = newGroup("Arc Test");

	box = newVerticalBox();
	uiGroupSetChild(group, uiControl(box));

	area = uiNewArea((uiAreaHandler *) (&handler));
	uiBoxAppend(box, uiControl(area), 1);

	box2 = newHorizontalBox();
	uiBoxAppend(box, uiControl(box2), 0);

	uiBoxAppend(box2, uiControl(uiNewLabel("Start Angle")), 0);
	startAngle = uiNewEntry();
	uiEntryOnChanged(startAngle, entryChanged, NULL);
	uiBoxAppend(box2, uiControl(startAngle), 1);

	box2 = newHorizontalBox();
	uiBoxAppend(box, uiControl(box2), 0);

	uiBoxAppend(box2, uiControl(uiNewLabel("Sweep")), 0);
	sweep = uiNewEntry();
	uiEntryOnChanged(sweep, entryChanged, NULL);
	uiBoxAppend(box2, uiControl(sweep), 1);

	negative = uiNewCheckbox("Negative");
	uiCheckboxOnToggled(negative, checkboxToggled, NULL);
	uiBoxAppend(box, uiControl(negative), 0);

	radians = uiNewCheckbox("Radians");
	uiCheckboxOnToggled(radians, checkboxToggled, NULL);
	uiBoxAppend(box, uiControl(radians), 0);

	return group;
}
Exemplo n.º 16
0
bool ccWebsocketManager::addWebsocket(std::shared_ptr<ccWebsocket> pNewWS)
{
    if (!hasUri(pNewWS->getUri()))
        return false;

    //  add new group
    auto it = _aWSGList.find(pNewWS->getUri());

    if (it != _aWSGList.end())
        it->second->add(pNewWS);
    else
    {
        std::shared_ptr<ccWebsocketGroup> newGroup(new ccWebsocketGroup(pNewWS->getUri()));
        _aWSGList[pNewWS->getUri()] = newGroup;

        newGroup->add(pNewWS);
    }

    return true;
}
Exemplo n.º 17
0
void CAnalysis::buildGroups()
{
  // Durch alle Gruppen iterieren und groupList_ anlegen
  for (int i=0; i < firstInterface_->getGroupNumber(); i++)
  {
    CGroupInterface* group = firstInterface_->getGroupAt(i);
    
    // Durch alle Gruppeneinträge iterieren
    for (int j=0; j < group->getRowCount(); j++)
    {
      int number = group->getTable()->item(j,0)->text().toInt();
      string name = group->getTable()->item(j,1)->text().toStdString();
      
      // Überprüfung, ob Gruppe vorhanden ist
      if (groupList_.count(number) == 0)
      {
        groupList_.insert(groupList_.begin(),pair<int, CGroup*> (number, newGroup(name, number)));
      }
    }
  }
}
Exemplo n.º 18
0
/*! 
 * Shows popup menu.
 * \param item (in) - current item.
 * \param p (in) - mouse pointer position.
 * \param col (in) - current column.
 */
void 
aListView::showMenu( QListViewItem* item, const QPoint& p, int col)
{
	delete menu;
	menu = new QPopupMenu();
	if(toSelect)
	{
		menu->insertItem(tr("Select"),	this,	SLOT(select()));
		menu->insertSeparator();
	}
	menu->insertItem(tr("Edit"), 	this, 	SLOT(edit()));
	menu->insertSeparator();
	menu->insertItem(tr("New element"),	this, 	SLOT(newItem())); 
	menu->insertItem(tr("New group"),	this, 	SLOT(newGroup()));
	menu->insertSeparator();
	//menu->setItemEnabled(menu->idAt(3),false);
	menu->insertItem(tr("Undo mark delete"),	this,	SLOT(undoMarkDeleted()));
	menu->insertItem(tr("Delete (mark deleted)"),this, 	SLOT(markDeleted()));
	menu->insertItem(tr("Delete (phisical)"),	this, 	SLOT(delItem()));
	parentItem = item;
	if(col==-1) col = 0;
	columnClicked = col;
	menu->popup( p );
}
Exemplo n.º 19
0
KSegSelectionGroupDialog::KSegSelectionGroupDialog(KSegView *view,
						   vector<KSegSelectionGroup *> &inGroups,
						   KSegDocument *inDoc)
  : QDialog(view), justMade(true), doc(inDoc), groups(inGroups)
{
  QHBoxLayout *hbl = new QHBoxLayout(this);

  groupLBox = new QListWidget(this);
  groupLBox->setMinimumSize(140, 300);
  hbl->addWidget(groupLBox);

  hbl->addSpacing(8);
  
  QVBoxLayout *vbl = new QVBoxLayout();

  selectBut = new QPushButton(tr("Select"), this);
  deselectBut = new QPushButton(tr("Deselect"), this);
  newBut = new QPushButton(tr("New Group"), this);
  deleteBut = new QPushButton(tr("Delete Group"),this);
  closeBut = new QPushButton(tr("Close"), this);
  affectInvisible = new QCheckBox(tr("Affect\nInvisible\nItems"), this);

  QToolTip::add(selectBut, tr("Hold SHIFT and click to add to current selection"));
  selectBut->installEventFilter(this);

  QToolTip::add(affectInvisible, tr("Whether the \"All <Type>\" groups also (de)select invisible objects"));

  vbl->addSpacing(8);
  vbl->addWidget(selectBut);
  vbl->addWidget(deselectBut);
  vbl->addWidget(newBut);
  vbl->addWidget(deleteBut);
  vbl->addWidget(closeBut);
  vbl->addSpacing(16);

  vbl->addWidget(affectInvisible);

  vbl->addItem(new QSpacerItem(0, 0));
  hbl->addLayout(vbl);
  hbl->addSpacing(8);  

  //now set up items properties

  connect(groupLBox, SIGNAL(itemSelectionChanged()), this, SLOT(updateButtons()));
  connect(doc, SIGNAL(documentChanged()), this, SLOT(updateButtons()));

  connect(selectBut, SIGNAL(clicked()), this, SLOT(select()));
  connect(deselectBut, SIGNAL(clicked()), this, SLOT(deselect()));
  connect(newBut, SIGNAL(clicked()), this, SLOT(newGroup()));
  connect(deleteBut, SIGNAL(clicked()), this, SLOT(deleteGroup()));
  connect(closeBut, SIGNAL(clicked()), this, SLOT(close()));

  groupLBox->setSelectionMode(QAbstractItemView::ExtendedSelection);

  groupLBox->addItem("*" + tr("All Points"));
  groupLBox->addItem("*" + tr("All Segments"));
  groupLBox->addItem("*" + tr("All Rays"));
  groupLBox->addItem("*" + tr("All Lines"));
  groupLBox->addItem("*" + tr("All Circles"));
  groupLBox->addItem("*" + tr("All Arcs"));
  groupLBox->addItem("*" + tr("All Polygons"));
  groupLBox->addItem("*" + tr("All Circle Interiors"));
  groupLBox->addItem("*" + tr("All Arc Sectors"));
  groupLBox->addItem("*" + tr("All Arc Segments"));
  groupLBox->addItem("*" + tr("All Loci"));
  groupLBox->addItem("*" + tr("All Measurements"));
  groupLBox->addItem("*" + tr("All Calculations"));

  numFixedGroups = groupLBox->count();

  int i;
  for(i = 0; i < (int)groups.size(); ++i) {
    groupLBox->addItem(" " + groups[i]->getName());
  }
}
Exemplo n.º 20
0
void WikiDialog::OpenOrShowAddGroupDialog()
{
	newGroup();
}
Exemplo n.º 21
0
MolconvWindow::MolconvWindow(QMainWindow *parent)
    : QMainWindow(parent)
    , d(new MolconvWindowPrivate)
    , ui(new Ui::MolconvWindow)
{
    ui->setupUi(this);

    d->m_ImportDialog = new ImportDialog(this);
    d->m_ExportDialog = new ExportDialog(this);
    d->m_NewGroupDialog = new NewGroupDialog(this);
    d->m_setBasisDialog = new setBasisDialog(this);
    d->m_ListOfMolecules = new ListOfMolecules(this);
    d->m_MoleculeSettings = new MoleculeSettings(this);

    addDockWidget(Qt::BottomDockWidgetArea, d->m_ListOfMolecules);
    addDockWidget(Qt::LeftDockWidgetArea, d->m_MoleculeSettings);

    ui->actionSet_internal_basis->setEnabled(false);
    ui->actionDuplicate->setEnabled(false);
    ui->actionRemove->setEnabled(false);
    ui->actionZero_Coordinates->setEnabled(false);
    ui->actionReset_Coordinates->setEnabled(false);
    ui->actionProperties->setEnabled(false);
    ui->actionAdd_To_Group->setEnabled(false);
    ui->actionAlign->setEnabled(false);

    connect(qApp, SIGNAL(aboutToQuit()), SLOT(quit()));

    connect(ui->actionImport_Molecule, SIGNAL(triggered()), SLOT(startImportDialog()));
    connect(ui->actionExport_Molecule, SIGNAL(triggered()), SLOT(startExportDialog()));
    connect(ui->actionQuit, SIGNAL(triggered()), SLOT(quit()));
    connect(ui->actionAbout, SIGNAL(triggered()), SLOT(about()));
    connect(ui->actionNew_Molecule_Group, SIGNAL(triggered()), SLOT(startNewGroupDialog()));
    connect(ui->actionSet_internal_basis, SIGNAL(triggered()), SLOT(startBasisDialog()));
    connect(ui->actionDuplicate, SIGNAL(triggered()), SLOT(DuplicateActiveMolecule()));
    connect(ui->actionRemove, SIGNAL(triggered()), SLOT(removeActiveMolecule()));
    connect(ui->actionReset, SIGNAL(triggered()), SLOT(ResetView()));
    connect(ui->actionZero_Coordinates, SIGNAL(triggered()), SLOT(zeroCoords()));
    connect(ui->actionReset_Coordinates, SIGNAL(triggered()), SLOT(resetCoords()));
    connect(ui->actionAlign, SIGNAL(triggered()), d->m_ListOfMolecules, SLOT(alignMolecules()));
    connect(ui->actionNavigate, SIGNAL(triggered()), SLOT(useNavigateTool()));
    connect(ui->actionSelect, SIGNAL(triggered()), SLOT(useSelectTool()));

    connect(d->m_ImportDialog, SIGNAL(accepted()), SLOT(openFile()));
    connect(d->m_NewGroupDialog, SIGNAL(accepted()), this, SLOT(newGroup()));
    connect(d->m_setBasisDialog, SIGNAL(ready()), SLOT(changeOriginBasis()));
    connect(d->m_ListOfMolecules, SIGNAL(newMoleculeSelected(molconv::moleculePtr&)), d->m_MoleculeSettings, SLOT(setMolecule(molconv::moleculePtr&)));
    connect(d->m_ListOfMolecules, SIGNAL(newMoleculeSelected(molconv::moleculePtr&)), SLOT(updateActiveMolecule(molconv::moleculePtr&)));
    connect(d->m_ListOfMolecules, SIGNAL(newGroupSelected(molconv::MoleculeGroup*)), d->m_MoleculeSettings, SLOT(setGroup(molconv::MoleculeGroup*)));
    connect(d->m_MoleculeSettings, SIGNAL(basisChanged()), SLOT(updateAxes()));
    connect(d->m_MoleculeSettings, SIGNAL(basisChanged()), SLOT(updateSelection()));

    GraphicsAxisItem *axes = new GraphicsAxisItem;
    ui->molconv_graphicsview->addItem(axes);

    d->m_Selection = new GraphicsSelectionItem;
    ui->molconv_graphicsview->addItem(d->m_Selection);

    d->m_navigatetool = boost::make_shared<NavigateTool>();
    d->m_selecttool = boost::make_shared<SelectTool>(this);
    useNavigateTool();

    ui->molconv_graphicsview->update();
}
Exemplo n.º 22
0
/*! Key press event handler. Emit signal keyEnterPressed().
 * \param e (in) - key press event.
 */
void
aListView::keyPressEvent(QKeyEvent *e)
{

	switch(e->key())
	{
	case Qt::Key_Return:
		e->accept();
		parentItem = selectedItem();
		columnClicked = 0;
		if(toSelect)
		{
			select();
		}
		else
		{
			edit();
		}
		break;
	case Qt::Key_Insert:	
		parentItem = selectedItem();
		columnClicked = 0;
		switch(QMessageBox::question(this,
				tr("Type of new item"),
				tr("<p align=\"center\">Select type of new item</p>"),
				tr("&Elemnt"), tr("&Group")))
		{
		case 0:
			newItem();	
			break;	
		case 1:
			newGroup();	
			break;	
		default:
			break;
		}
		break;
	case Qt::Key_Delete:	
		parentItem = selectedItem();
		columnClicked = 0;
		switch(QMessageBox::question(this,
				tr("Delete item"),
				tr("<p align=\"center\">Mark deleted or delete?</p>"),
				tr("&Mark deleted"), tr("&Delete")))
		{
		case 0:
			markDeleted();	
			break;	
		case 1:
			delItem();	
			break;	
		default:
			break;
		}
		break;
	default:
		e->ignore();
		break;
	}
	QListView::keyPressEvent(e);
	
}
Exemplo n.º 23
0
void CAttackHandler::Update()
{
	int frameNr = ai->cb->GetCurrentFrame();
	if (frameNr < 2) UpdateKMeans();
	
	//set the map data here so i dont have to do it in each group or whatever
	//TODO: movement map PATHTOUSE = hack
	ai->pather->micropather->SetMapData(ai->pather->MoveArrays[PATHTOUSE],ai->tm->ThreatArray,ai->tm->ThreatMapWidth,ai->tm->ThreatMapHeight);
	
	//update the k-means
	int frameSpread = 300; //frames between each update
	//calculate and draw k-means for the base perimeters
	if (frameNr % frameSpread == 0) {
		UpdateKMeans();
	}
	frameSpread = 300;
	if (frameNr % frameSpread == 0) {
		int num = ai->uh->NumIdleUnits(CAT_G_ATTACK);
		for (int i = 0; i < num; i++) {
			int unit = ai->uh->GetIU(CAT_G_ATTACK);
			if (this->PlaceIdleUnit(unit) && !ai->cb->GetUnitDef(unit)->canfly)  {
				//L("AH: moved idle cat_g_attack unit. unit:" << unit << " groupid:" << ai->MyUnits[unit]->groupID);
				ai->uh->IdleUnitRemove(unit);
			}
		}
//		//L("finished updating position for defense units");
	}

	//check for stuck units in the groups
	if (frameNr % 30 == 0) {
		for (list<CAttackGroup>::iterator it = attackGroups.begin(); it != attackGroups.end(); it++) {
			int stuckUnit = it->PopStuckUnit();
			if (stuckUnit != -1 && ai->cb->GetUnitDef(stuckUnit) != NULL) {
				//this->AddUnit(stuckUnit);
				pair<int, float3> foo;
				foo.first = stuckUnit;
				foo.second = ai->cb->GetUnitPos(stuckUnit);
				stuckUnits.push_back(foo);
				//L("AttackHandler: popped a stuck unit from attack group " << it->GetGroupID() << " and put it in the stuckUnits list which is now of size " << stuckUnits.size());
				ai->MyUnits[stuckUnit]->Stop();
				ai->MyUnits[stuckUnit]->groupID = STUCK_GROUP_ID;
			}
			//check if the group is now empty
			int groupSize = it->Size();
			if (groupSize == 0) {
				attackGroups.erase(it);
				break;
			}
		}
	}

	//combine groups that are defending and too weak to attack anything
	if (frameNr % 300 == 0) {
		CombineGroups();
	}

	//check if we have any new units, add them to a group.
	if (frameNr % 30 == 0 && units.size() > 0) {
		//L("AH: add units to group");
		CAttackGroup* existingGroup = NULL;
		//find a defending group:
		for (list<CAttackGroup>::iterator it = attackGroups.begin(); it != attackGroups.end(); it++) {
			if (it->Size() < 16 && it->defending && this->DistanceToBase(it->GetGroupPos()) < 300) {
				existingGroup = &*it;
			}
		}
		if (existingGroup != NULL) {
			//L("AH: adding to existing, num groups:" << attackGroups.size());
			for (list<int>::iterator it = units.begin(); it != units.end(); it++) {
				int unit = *it;
				if (ai->cb->GetUnitDef(unit) != NULL) {
					existingGroup->AddUnit(unit);
					//L("added unit:" << unit << " type:" << ai->cb->GetUnitDef(unit)->humanName);
				}
			}
			units.clear();
		} else {
			//we dont have a good group, make one
			newGroupID++;
			//L("creating new att group: group " << newGroupID);
			CAttackGroup newGroup(ai, newGroupID);
			newGroup.defending = true;
			for (list<int>::iterator it = units.begin(); it != units.end(); it++) {
				int unit = *it;
				if (ai->cb->GetUnitDef(unit) != NULL) {
					newGroup.AddUnit(unit);
					//L("added unit:" << unit << " type:" << ai->cb->GetUnitDef(unit)->humanName);
				}
			}
			units.clear();
			attackGroups.push_back(newGroup);
		}
	}

	//update all the air units:
	UpdateAir();
	//basic attack group formation from defense units:
	this->AssignTargets();
	
	//update current groups
	int counter = 0;
	for (list<CAttackGroup>::iterator it = attackGroups.begin(); it != attackGroups.end(); it++) {
		it->Update();
	}

	//print out the totals
	frameSpread = 7200; //frames between each update
	if (ai->cb->GetCurrentFrame() % frameSpread == 0) {
		//L("---------------------------------------------------------------------------");
		//L("AttackHandler: writing out the number of total units");
		int sum = 0;
		float powerSum = 0;
		for (list<CAttackGroup>::iterator it = attackGroups.begin(); it != attackGroups.end(); it++) {
			int size = it->Size();
			sum += size; 
			//L("an attack group had " << size << " units and power:" << it->Power() << ":");
			powerSum += it->Power();
			it->Log();
		}
		float airPower = 0;
		int counter_ = 0;
		for (list<int>::iterator it = airUnits.begin(); it != airUnits.end(); it++) {
			airPower +=  ai->cb->GetUnitPower(*it);
			//airPower 
			//L("" << counter++ << ":" << ai->MyUnits[*it]->def()->humanName);
		}
		//L("airUnits: " << airUnits.size() << " units and power:" << airPower);
		sum += airUnits.size();
		powerSum += airPower;
		//L("total units: " << sum << " total power:" << powerSum);
		//L("in inactive group: " << units.size());
		//L("in stuck group: " << stuckUnits.size());
		//L("---------------------------------------------------------------------------");
	}
}
Exemplo n.º 24
0
PolkaView::PolkaView(QWidget *parent)
  : QWidget( parent )
{
  m_model = new PolkaModel( this );
  connect( m_model, SIGNAL( dataWritten() ), SIGNAL( dataWritten() ) );
  
  QBoxLayout *topLayout = new QVBoxLayout( this );

  
  QBoxLayout *buttonLayout = new QHBoxLayout;
  topLayout->addLayout( buttonLayout );

  // FIXME: Use proper icon
  m_backButton = new QPushButton( "<" );
  buttonLayout->addWidget( m_backButton );
  connect( m_backButton, SIGNAL( clicked() ), SLOT( goBack() ) );
  m_backButton->setEnabled( false );

  buttonLayout->addStretch( 1 );

  m_groupNameLabel = new QLabel;
  buttonLayout->addWidget( m_groupNameLabel );

  buttonLayout->addStretch( 1 );

  m_searchEdit = new SearchEdit;
  buttonLayout->addWidget( m_searchEdit );
  connect( m_searchEdit, SIGNAL( search( const QString & ) ),
    SLOT( showSearch( const QString & ) ) );
  connect( m_searchEdit, SIGNAL( stopSearch() ), SLOT( stopSearch() ) );

  QPushButton *button = new QPushButton( i18n("...") );
  buttonLayout->addWidget( button );
  connect( button, SIGNAL( clicked() ), SLOT( showOverview() ) );

  button->setFocus();

  QBoxLayout *viewLayout = new QHBoxLayout;
  topLayout->addLayout( viewLayout );

  m_groupWidget = new QWidget;
  viewLayout->addWidget( m_groupWidget );
  
  m_listLayout = new QStackedLayout( m_groupWidget );

  m_overview = new Overview;
  m_listLayout->addWidget( m_overview );
  connect( m_overview, SIGNAL( showGroupView() ), SLOT( showGroupView() ) );
  connect( m_overview, SIGNAL( showListView() ), SLOT( showListView() ) );
  connect( m_overview, SIGNAL( showHistory() ), SLOT( showHistory() ) );

  m_groupListView = new GroupListView( m_model );
  m_listLayout->addWidget( m_groupListView );
  connectGroupView( m_groupListView );

  m_groupGraphicsView = new GroupGraphicsView( m_model );
  m_listLayout->addWidget( m_groupGraphicsView );
  connectGroupView( m_groupGraphicsView );
  connect( m_groupGraphicsView, SIGNAL( newGroup() ), SLOT( newSubGroup() ) );
  connect( m_groupGraphicsView, SIGNAL( removeIdentity( const Polka::Identity &,
    const Polka::Identity & ) ),
    SLOT( removeIdentity( const Polka::Identity &, const Polka::Identity & ) ) );
  connect( m_groupGraphicsView, SIGNAL( cloneGroup( const Polka::Identity & ) ),
    SLOT( cloneGroup( const Polka::Identity & ) ) );
  connect( m_groupGraphicsView, SIGNAL( removeGroup( const Polka::Identity & ) ),
    SLOT( removeGroup( const Polka::Identity & ) ) );
  connect( m_groupGraphicsView, SIGNAL( morphedToCompact() ),
    SLOT( finishShowPerson() ) );
  connect( m_groupGraphicsView, SIGNAL( closeRequested() ),
    SLOT( closePersonView() ) );

  m_personView = new PersonView( m_model );
  viewLayout->addWidget( m_personView );
  connect( m_personView, SIGNAL( closeRequested() ),
    SLOT( closePersonView() ) );

  m_historyView = new HistoryView( m_model );
  m_listLayout->addWidget( m_historyView );

  m_searchResultView = new SearchResultView( m_model );
  m_listLayout->addWidget( m_searchResultView );

  m_settingsWidget = new SettingsWidget( m_model );
  topLayout->addWidget( m_settingsWidget );
  connect( m_settingsWidget, SIGNAL( showView() ), SLOT( showView() ) );

  m_settingsWidget->hide();

  readConfig();

  readData();
}
Exemplo n.º 25
0
//***************************************************************
void CAutoGroup::group(CObject *newEntityDesc, const NLMISC::CVectorD &createPosition)
{
	//H_AUTO(R2_CAutoGroup_group)
	CInstance *destGroup = getGroupingCandidate();
	if (!destGroup || !_AutoGroupEnabled) return;
	_AutoGroupEnabled = false; // force user to call 'update' again
	clear();
	// remove any activity, dialog, or event in the copy
	CObject *behav = newEntityDesc->findAttr("Behavior");
	if (behav)
	{
		behav->setObject("Actions", new CObjectTable());
		behav->setObject("Activities", new CObjectTable());
		behav->setObject("ChatSequences", new CObjectTable());
		newEntityDesc->setObject("ActivitiesId", new CObjectTable());
	}
	nlassert(newEntityDesc);
	nlassert(destGroup);
	std::string targetGroupId;
	if (destGroup->isKindOf("NpcGrpFeature"))
	{
		// make relative to newgroup and insert
		CVectorD relPos = createPosition;
		CDisplayerVisual *vd = destGroup->getDisplayerVisual();
		if (vd)
		{
			relPos = relPos - vd->getWorldPos();
		}
		newEntityDesc->setObject("Position", buildVector(relPos));
		targetGroupId = destGroup->getId();
	}
	else
	{
		// other is a standalone entity -> create a new group
		std::auto_ptr<CObject> newGroup(getEditor().getDMC().newComponent("NpcGrpFeature"));
		if (!newGroup.get())
		{
			nlwarning("Syntax error in r2_features_npc_group.lua.");
			getEditor().getDMC().getActionHistoric().endAction();
			getEditor().getDMC().flushActions();
			return;
		}
		ucstring readableName;
		CLuaState &ls = getEditor().getLua();
		R2::getEditor().getEnv()["PaletteIdToGroupTranslation"][newEntityDesc->getAttr("Base")->toString()].push();
		if (ls.isString(-1))
			readableName.fromUtf8(ls.toString(-1));
		ucstring ucGroupName = ucstring(readableName + " " + CI18N::get("uiR2EDNameGroup").toUtf8());

		newGroup->set("Name", getEditor().genInstanceName(ucGroupName).toUtf8());
		getEditor().getDMC().requestInsertNode(destGroup->getParentAct()->getId(),
							   "Features",
							   -1,
							   "",
							   newGroup.get());
		targetGroupId = getString(newGroup.get(), "InstanceId");
		// move target instance in that group (becomes the leader)
		getEditor().getDMC().requestMoveNode(destGroup->getId(), "", -1, targetGroupId, "Components", -1);
	}
	// move newly created entity into target group
	getEditor().getDMC().requestInsertNode(targetGroupId,
							   "Components",
							   -1,
							   "",
							   newEntityDesc);
	getEditor().getDMC().getActionHistoric().endAction();
	getEditor().getDMC().flushActions();
}
Exemplo n.º 26
0
J9TDFGroup *
TraceGen::calculateGroups(J9TDFFile *tdf, unsigned int *groupCount)
{
	const char *EVENT_TYPES[] = {
		"Event",
		"Exception",
		"Entry",
		"Entry-Exception",
		"Exit",
		"Exit-Exception",
		"Mem",
		"MemException",
		"Debug",
		"Debug-Exception",
		"Perf",
		"Perf-Exception",
		"Assertion"
	};

	J9TDFTracepoint *tp = tdf->tracepoints;
	*groupCount = 0;
	unsigned int tpId = 0;

	J9TDFGroup *head = getDefaultGroupSet(groupCount);
	if (NULL == head) {
		goto failed;
	}


	printf("Calculating groups for %s\n", tdf->header.executable);

	/* Add tracepoint ID to tracegroup */
	while (NULL != tp) {
		unsigned int groupIndex = 0;

		/* add TP id to each group it belongs to. */
		if (NULL != tp->groups) {
			while (NULL != tp->groups[groupIndex]) {
				const char *groupName = tp->groups[groupIndex];
				J9TDFGroup *matchGroup = findGroupByName(head, groupName);
				if (NULL == matchGroup) {
					matchGroup = newGroup(groupName, groupCount);
					if (NULL == matchGroup) {
						goto failed;
					}
					if (NULL == head) {
						matchGroup->nextGroup = NULL;
						head = matchGroup;
					} else {
						matchGroup->nextGroup = head;
						head = matchGroup;
					}
				}

				if (RC_OK != addTpIdToGroup(matchGroup, tpId)) {
					goto failed;
				}
				groupIndex += 1;
			}
		}

		/* Add TP id to TP event type group */
		const char *eventType = EVENT_TYPES[tp->type];
		J9TDFGroup *matchGroup = findGroupByName(head, eventType);
		if (NULL == matchGroup) {
			matchGroup = newGroup(eventType, groupCount);
			if (NULL == matchGroup) {
				goto failed;
			}
			if (NULL == head) {
				matchGroup->nextGroup = NULL;
				head = matchGroup;
			} else {
				matchGroup->nextGroup = head;
				head = matchGroup;
			}
		}
		if (RC_OK != addTpIdToGroup(matchGroup, tpId)) {
			goto failed;
		}

		tpId += 1;
		tp = tp->nexttp;
	}
	return head;

failed:
	if (NULL != head) {
		freeGroups(head);
		head = NULL;
	}
	return NULL;
}
Exemplo n.º 27
0
Gui_Groups::Gui_Groups(LinqClient* c, QWidget* parent) : QGridLayout(parent), _client(c) {
    Gui_Avatar* portrait = new Gui_Avatar(QString::fromStdString(_client->avatar()));
    QPushButton* create = new QPushButton("CREATE");
    QLabel* title = new QLabel("NEW GROUP");
    showgrp = new Gui_DisplayInfo;
    newpost = new QTextEdit;
    newgrp = new QLineEdit;
    search = new QLineEdit;
    newbox = new QGroupBox;
    memlbl = new QLabel("Members");
    memlbl->setMaximumSize(80,20);

    grpname = new QLineEdit;
    newgrplayout = new QFormLayout;
    newgrplayout->setSpacing(15);
    newgrplayout->addRow(title);
    newgrplayout->addRow("Group name:", grpname);
    newgrplayout->addRow("Group description:", newgrp);
    newgrplayout->addRow(create);

    newbox->setLayout(newgrplayout);
    if(_client->level() < executive) newbox->hide();

    search->setPlaceholderText("Search group..");
    search->hide();
    connect(search,  SIGNAL(returnPressed()), this, SLOT(searchGroup()));

    post = new QPushButton("POST");
    grplist = new QListWidget;
    memlist = new QListWidget;
    QLabel* grplbl = new QLabel("Groups");
    grplbl->setMaximumSize(120,20);
    createGroups();
    QFormLayout* frm = new QFormLayout;
    mbuttons[0] = new QPushButton;
    mbuttons[0]->setIcon(QPixmap("img/document185.png"));
    mbuttons[0]->setToolTip("New group");
    mbuttons[1] = new QPushButton;
    mbuttons[1]->setIcon(QPixmap("img/cross108.png"));
    mbuttons[1]->setToolTip("Delete group");
    mbuttons[2] = new QPushButton;
    mbuttons[2]->setIcon(QPixmap("img/mop2.png"));
    mbuttons[2]->setToolTip("Delete all posts");
    mbuttons[3] = new QPushButton;
    mbuttons[3]->setIcon(QPixmap("img/exit6.png"));
    mbuttons[3]->setToolTip("Leave this group");
    mbuttons[4] = new QPushButton;
    mbuttons[4]->setIcon(QPixmap("img/enter3.png"));
    mbuttons[4]->setToolTip("Join this group");

    frm->addRow(mbuttons[0]);
    frm->addRow(mbuttons[3]);
    frm->addRow(mbuttons[4]);
    frm->addRow(mbuttons[1]);
    frm->addRow(mbuttons[2]);

    connect(mbuttons[0], SIGNAL(clicked()), this, SLOT(showNewGroup()));
    connect(create, SIGNAL(clicked()), this, SLOT(newGroup()));
    connect(mbuttons[1], SIGNAL(clicked()), this, SLOT(deleteGroup()));
    connect(mbuttons[2], SIGNAL(clicked()), this, SLOT(clearPosts()));
    connect(mbuttons[3], SIGNAL(clicked()), this, SLOT(leaveGroup()));
    connect(mbuttons[4], SIGNAL(clicked()), this, SLOT(addGroup()));

    mbuttons[0]->hide();
    mbuttons[1]->hide();
    mbuttons[2]->hide();
    mbuttons[3]->hide();
    mbuttons[4]->hide();
    if(_client->level() >= executive)
        mbuttons[0]->show();
    tbar = new QToolBar;
    tbuttons[0] = new QToolButton(tbar);
    tbuttons[0]->setIcon(QPixmap("img/cross108.png"));
    tbar->addWidget(tbuttons[0]);

    newpost->setStyleSheet("background: #1a1a1a; font-weight:400");
    newpost->setPlaceholderText("Insert new post into this group.");
    newpost->hide();
    post->hide();
    showgrp->hide();
    memlbl->hide();
    memlist->hide();
    memlist->setContextMenuPolicy(Qt::CustomContextMenu);
    connect(memlist, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(memListMenu(const QPoint&)));

    addWidget(newbox, 0, 1, 1, 1);
    addWidget(portrait, 0, 0, 1, 1, Qt::AlignTop);
    addWidget(showgrp, 0, 1, 3, 1);
    addLayout(frm, 0, 2, 1, 1, Qt::AlignRight);
    addWidget(newpost, 3, 1, 2, 3);
    addWidget(post, 5, 4, 1, 1, Qt::AlignRight);
    addWidget(grplbl, 1, 0, 1, 1);
    addWidget(grplist, 2, 0, 1, 1);
    addWidget(memlbl, 3, 0, 1, 1);
    addWidget(memlist, 4, 0, 1, 1);
    addWidget(search, 5, 0, 1, 1);
    setRowStretch(0, 0);
    setRowStretch(1, 10);
    setColumnStretch(0, 1);
    setColumnStretch(1, 5);
    connect(grplist, SIGNAL(clicked(QModelIndex)), this, SLOT(showGroup()));
    connect(post, SIGNAL(clicked()), this, SLOT(sendPost()));
    connect(this, SIGNAL(created(int)), this, SLOT(refresh(int)));
}