Пример #1
0
    vector<Edge*> Kruskal(int numVertices, vector<Edge> &edges)
    {
        auto minSpanForest = vector<Edge*>();

        for( int i=0; i<numVertices; i++) {
            Parents.push_back(i);
        }

        sort(edges.begin(), edges.end());

        for( auto pE = edges.begin(); pE != edges.end(); pE++ ) {
            auto rootS = FindRoot(pE->Start);
            auto rootE = FindRoot(pE->End);
            if( rootE == rootS ) {
                continue;
            }
            if( rootS == pE->Start ) {
                SetRoot(pE->Start, rootE);
            }
            else {
                SetRoot(pE->End, rootS);
            }
            minSpanForest.push_back(&(*pE));

        }
        return minSpanForest;
    }
Пример #2
0
void DisplayManager::RemoveElementReferences (DisplayElement *pElem)
{
	if (mpFocus && (mpFocus == pElem))
	{
		mpFocus->ClearFlag(DISPLAY_FLAG_FOCUS);
		mpFocus = 0;
	}

	if (mpMouseOverElement == pElem)
	{
		mpMouseOverElement = 0;
	}

	if (mpMouseDownElement == pElem)
	{
		mpMouseDownElement = 0;
	}

	ReleasePointer(pElem);

	if (GetRoot() == pElem)
	{
		SetRoot(0);
	}
}
Пример #3
0
shared_ptr<const DistMatrix<T,U,V>> 
ReadProxy( const ElementalMatrix<S>* A, const ProxyCtrl& ctrl )
{
    typedef DistMatrix<T,U,V> DM;
    if( std::is_same<S,T>::value )
    {
        const DM* ACast = dynamic_cast<const DM*>(A);

        const bool haveDist = (ACast != nullptr);
        const bool haveColAlign = haveDist && 
            (!ctrl.colConstrain || A->ColAlign() == ctrl.colAlign);
        const bool haveRowAlign = haveDist &&
            (!ctrl.rowConstrain || A->RowAlign() == ctrl.rowAlign);
        const bool haveRoot = haveDist &&
            (!ctrl.rootConstrain || A->Root() == ctrl.root);

        if( haveColAlign && haveRowAlign && haveRoot )
            return shared_ptr<const DM>( ACast, []( const DM* B ) { } );
    }

    auto AShared = make_shared<DM>( A->Grid() );
    if( ctrl.rootConstrain )
        AShared->SetRoot( ctrl.root );
    if( ctrl.colConstrain )
        AShared->AlignCols( ctrl.colAlign );
    if( ctrl.rowConstrain )
        AShared->AlignRows( ctrl.rowAlign );
    Copy( *A, *AShared );
    return AShared;
}
Пример #4
0
Element * Document::SetRoot(const string &name, const string &nsUri, const string &nsPrefix)
{
    Element * newRoot = new Element(name, this, nsUri, nsPrefix);
    Element * result = SetRoot(newRoot);
    if ( result != newRoot )
        delete newRoot;
    return newRoot;
}
Пример #5
0
list insert(element e, list l)
{
	list l1 = cons(e);
	l1->next = l;
	SetRoot(l, l1);

	return l1;
}
Пример #6
0
void FindAndReplace(btree* root, const int find, void* newPayLoad)
{
    btree* found = NULL;

    if(newPayLoad == NULL)
        return;

    found = SearchBinaryTree(GetRoot(), find);

    if(found != NULL)
    {
        printf("Found [%s] to replace with [%c]\n", (char *)found->payload, _getLetter(newPayLoad));

        SetRoot(DeleteBinaryTreeNode(GetRoot(), _getLetter(found->payload)));
        SetRoot(InsertRoot(GetRoot(), newPayLoad));
    }
}
Пример #7
0
JTree::JTree
	(
	JTreeNode* root
	)
	:
	itsIsDestructingFlag(kJFalse)
{
	SetRoot(root);
}
Пример #8
0
list DelFirst(list l)
{
	list next = tail(l);
	DeleteElement(head(l));
	free(l);
	SetRoot(next, next);
	
	return next;
}
Пример #9
0
void CTreeCtrlFolder::Inform()
{
	CWnd* parent = GetParent();
	if (parent != NULL)
	{	/*CFolder* folder = (CFolder*) GetItemData(m_selectedItem);
		parent->SendMessage(WM_SELECTITEM_CHANGE, (WPARAM)folder);*/
		SetRoot (m_selectedItem);
		m_comboBoxFolder->SetFocus();
	}
}
CBrowseForFolder::CBrowseForFolder(const HWND hParent, const LPITEMIDLIST pidl, const CString& strTitle)
{
	m_hwnd = NULL;
	SetOwner(hParent);
	SetRoot(pidl);
	SetTitle(strTitle);
	m_bi.lpfn = BrowseCallbackProc;
	m_bi.lParam = reinterpret_cast<long>(this);
	m_bi.pszDisplayName = m_szSelected;
}
CBrowseForFolder::CBrowseForFolder(const HWND hParent /*= NULL*/, const LPITEMIDLIST pidl /*= NULL*/, const int nTitleID /*= 0*/)
{
	m_hwnd = NULL;
	SetOwner(hParent);
	SetRoot(pidl);
	SetTitle(nTitleID);
	m_bi.lpfn = BrowseCallbackProc;
	m_bi.lParam = reinterpret_cast<long>(this);
	m_bi.pszDisplayName = m_szSelected;
}
Пример #12
0
list append(list l1, list l2)
{
	list r = l1;
	while (empty(tail(l1)) == false)
	{
		l1 = tail(l1);
	}
	l1->next = l2;
	SetRoot(l2, r);
	return r;
}
Пример #13
0
	void Tree::swap (Tree & srcTree)
	{
		if (srcTree.GetRoot () != 0)
		{
			std::auto_ptr<Node> srcRoot = srcTree.PopRoot ();
			if (GetRoot () != 0)
			{
				std::auto_ptr<Node> myRoot = _top.PopChild ();
				srcTree.SetRoot (myRoot);
			}
			SetRoot (srcRoot);
		}
	}
Пример #14
0
void BacaDict(Tree *T)
{	
	char s[20];
	/* ALGORITMA */
	STARTKATA("Dictionary.txt");
	CreateTree(T);
	SetRoot(T,'\0', false);
	while(!EndKata)
	{
		KataToString(s);
		AddWord(T, s);
		ADVKATA();
	}
}
Пример #15
0
void CleanUpBinaryTree()
{
    btree* nodeToDelete = NULL;

    if(GetRoot() == NULL)
        return;

    while(GetRoot() != NULL)
    {
        nodeToDelete = (btree *) _postOrder(GetRoot());

        printf("Freeing node [%c]\n", _getLetter(nodeToDelete->payload));

        SetRoot(DeleteBinaryTreeNode(GetRoot(), _getLetter(nodeToDelete->payload)));
    }
}
Пример #16
0
SHBrowseWrapper::SHBrowseWrapper(
	const CWnd*				pParent, 
	const LPITEMIDLIST	pidl, 
	const CString*			pstrTitle
) :

	// Init vars.
	m_hwnd( 0 )

{
	SetOwner( pParent->GetSafeHwnd() );
	SetRoot(pidl);
	SetTitle( pstrTitle );
	m_bi.lpfn = BrowseCallbackProc;
	m_bi.lParam = reinterpret_cast<long>(this);
	m_bi.pszDisplayName = m_szSelected;
}
Пример #17
0
shared_ptr<DistMatrix<T,U,V>> 
ReadProxy( ElementalMatrix<S>* A, const ProxyCtrl& ctrl )
{
    typedef DistMatrix<T,U,V> DM;
    if( std::is_same<S,T>::value )
    {
        DM* ACast = dynamic_cast<DM*>(A);

        const bool haveDist = (ACast != nullptr);
        const bool haveColAlign = haveDist && 
            (!ctrl.colConstrain || A->ColAlign() == ctrl.colAlign);
        const bool haveRowAlign = haveDist &&
            (!ctrl.rowConstrain || A->RowAlign() == ctrl.rowAlign);
        const bool haveRoot = haveDist &&
            (!ctrl.rootConstrain || A->Root() == ctrl.root);

        if( haveColAlign && haveRowAlign && haveRoot )
        {
            // Constrain the proxy to have the forced alignemnts.
            // This is somewhat tricky since a subsequent write could otherwise
            // change the alignment.
            if( ctrl.colConstrain )
                A->AlignCols( ctrl.colAlign );
            if( ctrl.rowConstrain )
                A->AlignRows( ctrl.rowAlign );
            if( ctrl.rootConstrain )
                A->SetRoot( ctrl.root );
            return shared_ptr<DM>( ACast, []( const DM* B ) { } );
        }
    }

    auto AShared = make_shared<DM>( A->Grid() );
    if( ctrl.rootConstrain )
        AShared->SetRoot( ctrl.root );
    if( ctrl.colConstrain )
        AShared->AlignCols( ctrl.colAlign );
    if( ctrl.rowConstrain )
        AShared->AlignRows( ctrl.rowAlign );
    Copy( *A, *AShared );
    return AShared;
}
Пример #18
0
int main()
{
	int input1, input2;
	int head1, head2;
	int result = 0;

	memset(setArr, -1, sizeof(setArr));

	while (1)
	{
		if (scanf("%d", &input1) == EOF)
		{
			break;
		}
		if (input1 == -1)
		{
			printf("%d\n", result);
			result = 0;
			memset(setArr, -1, sizeof(setArr));
			continue;
		}
		scanf("%d", &input2);

		if (setArr[input1] == -1)
			setArr[input1] = input1;
		if (setArr[input2] == -1)
			setArr[input2] = input2;

		head1 = GetRoot(input1);
		head2 = GetRoot(input2);

		if (head1 == head2)
		{
			result++;
		}
		else
		{
			SetRoot(input2, head1);
		}
	}
}
Пример #19
0
bool c4_Persist::Rollback(bool full_) {
  _root->DetachFromParent();
  _root->DetachFromStorage(true);
  _root = 0;

  if (_space != 0)
    _space->Initialize();

  c4_HandlerSeq *seq = d4_new c4_HandlerSeq(this);
  seq->DefineRoot();
  SetRoot(seq);

  if (full_) {
    delete _differ;
    _differ = 0;
  }

  LoadAll();

  return _strategy._failure == 0;
}
Пример #20
0
void FbExportTreeModel::Create()
{
	FbExportParentData * root = new FbExportParentData(*this, NULL, wxT('.'));
	SetRoot(root);

	wxString sql = wxT("\
		SELECT DISTINCT \
			books.id, file_size, title, file_type, file_name, lang, md5sum, letter, \
			full_name, first_name, middle_name, last_name, sequences.value AS sequence, bookseq.number\
		FROM books \
			LEFT JOIN authors ON authors.id=books.id_author \
			LEFT JOIN bookseq ON bookseq.id_book=books.id \
			LEFT JOIN sequences ON bookseq.id_seq=sequences.id \
		WHERE books.id IN (%s) %s \
		ORDER BY full_name, sequence\
	");

	wxString filter;
	if ( m_author) filter = wxString::Format(wxT("AND (books.id_author=%d)"), m_author);
	sql = wxString::Format(sql, m_books.c_str(), filter.c_str());

	FbExportTreeContext context(this);
	FbSortedArrayInt items(FbArrayEvent::CompareInt);

	FbCommonDatabase database;
	FbSQLite3ResultSet result = database.ExecuteQuery(sql);
	while (result.NextRow()) {
		int book = result.GetInt(0);
		int size = result.GetInt(1);
		if (items.Index(book) != wxNOT_FOUND) continue;
		items.Add(book);

		wxFileName filename = context.GetFilename(result);
		wxArrayString dirs = filename.GetDirs();
		FbExportParentData * parent = root->GetDir(*this, dirs);
		if (parent) parent->Append(*this, book, filename, size);
	}
	root->Sort(*this);
}
Пример #21
0
void pawsTreeStruct::InsertChild(const csString &parent, pawsTreeNode* node, const csString &nextSibling)
{
    pawsTreeNode* parentNode, * nextSiblingNode;

    parentNode = FindNodeByName(parent);
    // Allows a root to be added automatically.
    if(!parentNode)
    {
        if(!root)
        {
            SetRoot(node);
            node->SetTree(this);
            return;
        }
        else
        {
            parentNode = root;
        }
    }
    nextSiblingNode = FindNodeByName(nextSibling);
    parentNode->InsertChild(node, nextSiblingNode);
}
Пример #22
0
/// Tries to open an existing file; if not, creates a new one.
/// Clears contents if unexpected root node name.
/// Reports problems in a message box.
/// @param parent Window to parent message boxes.
/// @param filename Name only of file - will be created in standard user config directory.
SavedState::SavedState(wxWindow * parent, const wxString & filename)
{
    mFilename = wxStandardPaths::Get().GetUserConfigDir() + wxFileName::GetPathSeparator() + filename;
    bool ok = false;
    if (!wxFile::Exists(mFilename)) {
        wxMessageDialog dlg(parent, wxT("No saved preferences file found.  Default values will be used."), wxT("No saved preferences"));
        dlg.ShowModal();
    }
    else if (!Load(mFilename)) { //already produces a warning message box
    }
    else if (wxT("Ingexgui") != GetRoot()->GetName()) {
        wxMessageDialog dlg(parent, wxT("Saved preferences file \"") + mFilename + wxT("\": has unrecognised data: re-creating with default values."), wxT("Unrecognised saved preferences"), wxICON_EXCLAMATION | wxOK);
        dlg.ShowModal();
    }
    else {
        ok = true;
    }
    if (!ok) {
        SetRoot(new wxXmlNode(wxXML_ELEMENT_NODE, wxT("Ingexgui")));
        Save();
    }
}
Пример #23
0
bool pawsTreeStruct::Load(iDocumentNode* node)
{
    csRef<iDocumentNode> xmlRoot;
    csString factory;
    pawsWidget* rootAsWidget;
    pawsTreeNode* newRoot;

    version++;

    xmlRoot = node->GetNode("widget");
    if(xmlRoot == NULL)
    {
        Error1("<widget> tag not found");
        return true;
    }

    factory = xmlRoot->GetAttributeValue("factory");
    rootAsWidget = PawsManager::GetSingleton().CreateWidget(factory);
    if(rootAsWidget == NULL)
    {
        Error2("Could not create root from factory: %s", factory.GetData());
        return false;
    }

    newRoot = dynamic_cast<pawsTreeNode*>(rootAsWidget);
    if(newRoot == NULL)
    {
        Error2("Root(%s) is not pawsTreeNode",rootAsWidget->GetType());
        delete rootAsWidget;
        return false;
    }
    SetRoot(newRoot);

    root->SetTree(this);
    return root->Load(xmlRoot);
}
Пример #24
0
//	Author: PCMan (HZY) 2004/07/22	07:51 AM
//	I finally came up with a really smart way to maintain ini file.
//	Every time I add a variable to CAppConfig, all I need to do is
//	adding the variable in my "Config Table," and all the data will
//	be load and save automatically.  This is not the most efficient way.
//	In my first version I use some more efficient method, but at last I change
//	my code to what it is now.  Because I think in a program not time-critical,
//	easy-maintaining is much more important.
bool CAppConfig::DoDataExchange(bool bLoad)
{
	BEGIN_CONFIG_SECT(Window)
		CFG_INT( MainWndX )
		CFG_INT( MainWndY )
		CFG_INT( MainWndW )
		CFG_INT( MainWndH )
/*		CFG_INT( EditorX )
		CFG_INT( EditorY )
		CFG_INT( EditorW )
		CFG_INT( EditorH )
*/
	END_CONFIG_SECT()

	BEGIN_CONFIG_SECT(General)
//		CFG_STR ( Shadow )
		CFG_BOOL( QueryOnExit)
		CFG_BOOL( QueryOnCloseCon)
		CFG_BOOL( CancelSelAfterCopy)
		CFG_BOOL( CopyTrimTail)
		CFG_BOOL( BeepOnBell )
#ifdef USE_MOUSE
		CFG_BOOL( MouseSupport )
#endif
#ifdef USE_DOCKLET
		CFG_BOOL( ShowTrayIcon )
#endif
		CFG_BOOL( ShowStatusBar )
#ifdef USE_WGET
		CFG_BOOL( UseWgetFiles )
#endif
		CFG_STR ( WebBrowser )
		CFG_STR ( MailClient )
		CFG_BOOL( PopupNotifier )
		CFG_INT ( PopupTimeout )
		CFG_BOOL ( MidClickAsClose )
	END_CONFIG_SECT()

	BEGIN_CONFIG_SECT(Display)
		CFG_STR ( FontFamily )
		CFG_INT ( FontSize )
		CFG_STR ( FontFamilyEn )
		CFG_INT ( FontSizeEn )
		CFG_BOOL( AntiAliasFont )
		CFG_BOOL( CompactLayout )
		_CFG_BOOL ( "HorizontalCenterAlign", m_DefaultSite.m_bHorizontalCenterAlign )
		_CFG_BOOL ( "VerticalCenterAlign", m_DefaultSite.m_bVerticalCenterAlign )
		CFG_INT ( CharPaddingX)
		CFG_INT ( CharPaddingY)
	END_CONFIG_SECT()

	BEGIN_CONFIG_SECT(Color)
		_CFG_CLR( "Black", CTermCharAttr::m_DefaultColorTable[0] )
		_CFG_CLR( "DarkRed", CTermCharAttr::m_DefaultColorTable[1] )
		_CFG_CLR( "DarkGreen", CTermCharAttr::m_DefaultColorTable[2] )
		_CFG_CLR( "Brown", CTermCharAttr::m_DefaultColorTable[3] )
		_CFG_CLR( "DarkBlue", CTermCharAttr::m_DefaultColorTable[4] )
		_CFG_CLR( "DarkMagenta", CTermCharAttr::m_DefaultColorTable[5] )
		_CFG_CLR( "DarkCyan", CTermCharAttr::m_DefaultColorTable[6] )
		_CFG_CLR( "LightGray", CTermCharAttr::m_DefaultColorTable[7] )
		_CFG_CLR( "Gray", CTermCharAttr::m_DefaultColorTable[8] )
		_CFG_CLR( "Red", CTermCharAttr::m_DefaultColorTable[9] )
		_CFG_CLR( "Green", CTermCharAttr::m_DefaultColorTable[10] )
		_CFG_CLR( "Yellow", CTermCharAttr::m_DefaultColorTable[11] )
		_CFG_CLR( "Blue", CTermCharAttr::m_DefaultColorTable[12] )
		_CFG_CLR( "Magenta", CTermCharAttr::m_DefaultColorTable[13] )
		_CFG_CLR( "Cyan", CTermCharAttr::m_DefaultColorTable[14] )
		_CFG_CLR( "White", CTermCharAttr::m_DefaultColorTable[15] )
		CFG_CLR( HyperLinkColor )
	END_CONFIG_SECT()

	BEGIN_CONFIG_SECT(Site)
		_CFG_INT ( "AutoReconnect", m_DefaultSite.m_AutoReconnect )
		_CFG_INT ( "AntiIdle", m_DefaultSite.m_AntiIdle )
		_CFG_STR ( "AntiIdleStr", m_DefaultSite.m_AntiIdleStr )
		_CFG_INT ( "Cols", m_DefaultSite.m_ColsPerPage )
		_CFG_INT ( "Rows", m_DefaultSite.m_RowsPerPage )
		_CFG_STR ( "TermType", m_DefaultSite.m_TermType )
		_CFG_STR ( "Encoding", m_DefaultSite.m_Encoding )
		_CFG_INT ( "CRLF", m_DefaultSite.m_CRLF )
		_CFG_STR ( "ESCConv", m_DefaultSite.m_ESCConv )
		_CFG_INT ( "DetectDBChar", m_DefaultSite.m_DetectDBChar )
#ifdef USE_EXTERNAL
		_CFG_BOOL ( "UseExternalSSH",
			m_DefaultSite.m_UseExternalSSH )
		_CFG_BOOL ( "UseExternalTelnet",
			m_DefaultSite.m_UseExternalTelnet )
#endif
		CFG_INT  ( SocketTimeout )
#ifdef USE_PROXY
		_CFG_INT ( "ProxyType", m_DefaultSite.m_ProxyType )
		_CFG_STR ( "ProxyAddr", m_DefaultSite.m_ProxyAddr )
		_CFG_STR ( "ProxyPort", m_DefaultSite.m_ProxyPort )
		_CFG_STR ( "ProxyUser", m_DefaultSite.m_ProxyUser )
		_CFG_STR ( "ProxyPass", m_DefaultSite.m_ProxyPass )
#endif
	END_CONFIG_SECT()

	BEGIN_CONFIG_FILE( ConfigFile )
		CFG_SECT( Window )
		CFG_SECT( General )
		CFG_SECT( Display )
		CFG_SECT( Color )
		CFG_SECT( Site )
	END_CONFIG_FILE()

	SetRoot(ConfigFile);

	bool ret = CConfigFile::DoDataExchange(bLoad);

	if( bLoad )
		AfterLoad();

	return ret;
}
Пример #25
0
Document::Document(Element * rootElement) : Document()
{
    if ( SetRoot(rootElement) == nullptr )
        throw InternalError("Failed to set document root element");
}
Пример #26
0
bool wxXmlDocument::Load(wxInputStream& stream, const wxString& encoding, int flags)
{
#if wxUSE_UNICODE
    (void)encoding;
#else
    m_encoding = encoding;
#endif

    const size_t BUFSIZE = 1024;
    char buf[BUFSIZE];
    wxXmlParsingContext ctx;
    bool done;
    XML_Parser parser = XML_ParserCreate(NULL);

    ctx.root = ctx.node = NULL;
    ctx.encoding = wxT("UTF-8"); // default in absence of encoding=""
    ctx.conv = NULL;
#if !wxUSE_UNICODE
    if ( encoding.CmpNoCase(wxT("UTF-8")) != 0 )
        ctx.conv = new wxCSConv(encoding);
#endif
    ctx.removeWhiteOnlyNodes = (flags & wxXMLDOC_KEEP_WHITESPACE_NODES) == 0;

    XML_SetUserData(parser, (void*)&ctx);
    XML_SetElementHandler(parser, StartElementHnd, EndElementHnd);
    XML_SetCharacterDataHandler(parser, TextHnd);
    XML_SetStartCdataSectionHandler(parser, StartCdataHnd);
    XML_SetCommentHandler(parser, CommentHnd);
    XML_SetDefaultHandler(parser, DefaultHnd);
    XML_SetUnknownEncodingHandler(parser, UnknownEncodingHnd, NULL);

    bool ok = true;
    do
    {
        size_t len = stream.Read(buf, BUFSIZE).LastRead();
        done = (len < BUFSIZE);
        if (!XML_Parse(parser, buf, len, done))
        {
            wxString error(XML_ErrorString(XML_GetErrorCode(parser)),
                           *wxConvCurrent);
            wxLogError(_("XML parsing error: '%s' at line %d"),
                       error.c_str(),
                       XML_GetCurrentLineNumber(parser));
            ok = false;
            break;
        }
    } while (!done);

    if (ok)
    {
        if (!ctx.version.empty())
            SetVersion(ctx.version);
        if (!ctx.encoding.empty())
            SetFileEncoding(ctx.encoding);
        SetRoot(ctx.root);
    }
    else
    {
        delete ctx.root;
    }

    XML_ParserFree(parser);
#if !wxUSE_UNICODE
    if ( ctx.conv )
        delete ctx.conv;
#endif

    return ok;

}
DirectFilenameDB::DirectFilenameDB( RString root_ )
{
	ExpireSeconds = 30;
	SetRoot( root_ );
}
Пример #28
0
MainView::MainView(const Rect& cRect) : LayoutView(cRect, "MainView")
//	Here is where we construct the window e.g views, buttons, textviews, etc...
{

//create the vertical root layout node
	LayoutNode* pcRootNode = new VLayoutNode("Root");

//create textview
//top spacer
	pcRootNode->AddChild(new VLayoutSpacer("Spacer1", 19, 19));
//create output box
  	Rect y;
	y.Resize(0,0,0,0);
	textOutputView = new TextView (y, "OutputView", "", CF_FOLLOW_ALL );
	textOutputView ->SetMultiLine(true);
	textOutputView ->SetReadOnly(true);
	pcRootNode->AddChild(textOutputView);
//spacer between input and output
	pcRootNode->AddChild(new VLayoutSpacer("Spacer2", 5, 5));
//create horizontal layer
	LayoutNode* pcButtonNode = new HLayoutNode("Buttons", 0);
	
	pcButtonNode->AddChild(new HLayoutSpacer("Spacer3", 5, 5));
//create input box
  	Rect x;
	x.Resize( 0,0,0,0);
//	TextView* textInputView = new TextView (x, "InputView", "Input", CF_FOLLOW_ALL );
	textInputView = new TextView (x, "InputView", "Input", CF_FOLLOW_ALL );	
	pcButtonNode->AddChild(textInputView);
//bottom spacer
	pcButtonNode->AddChild(new HLayoutSpacer("Spacer4", 5, 5));
	m_pcStart = new Button(Rect(0, 0, 0, 0), "Send", "Send", new Message(MSG_SEND));
	m_pcStart->GetFont()->SetSize(10);
	pcButtonNode->AddChild(m_pcStart);
	pcButtonNode->AddChild(new HLayoutSpacer("Spacer5", 5, 5));
	m_pcStart->GetPreferredSize (false).y;
	
//add the row of buttons to the vertical layout node	
	pcRootNode->AddChild(new VLayoutSpacer("Spacer6", 10, 10));
	pcRootNode->AddChild(pcButtonNode);
	pcRootNode->AddChild(new VLayoutSpacer("Spacer7", 10, 10));

//add it all to this layout view
	SetRoot(pcRootNode);

//	Menu *mainMenuBar, *tempMenu; 
	mainMenuBar = new Menu( Rect(0,0,0,0), "mainMenuBar", ITEMS_IN_ROW ); 
	mainMenuBar ->SetFrame ( Rect (0, 0, GetBounds().Width() + 1, 18) );

// App menu 
	tempMenu = new Menu( Rect(0,0,0,0), "Application", ITEMS_IN_COLUMN ); 
	tempMenu->AddItem( "Settings", new Message(MSG_SETTINGS)); 
	tempMenu->AddItem("About", new Message(M_MENU_ABO)); 
	tempMenu->AddItem("Quit", new Message(M_MENU_QUIT)); 
	mainMenuBar->AddItem( tempMenu ); 
// File menu 
	tempMenu = new Menu( Rect(0,0,0,0), "Server", ITEMS_IN_COLUMN ); 
	tempMenu->AddItem( "Connect", new Message(M_MENU_CONNECT) ); 
	tempMenu->AddItem( "Login", new Message(M_MENU_LOGIN) ); 
	tempMenu->AddItem( "Disconnect", new Message(M_MENU_DISCONNECT) ); 
	mainMenuBar->AddItem( tempMenu ); 
// Help menu 
	tempMenu = new Menu( Rect(0,0,0,0), "Channel", ITEMS_IN_COLUMN ); 
	tempMenu->AddItem( "Join Channel", new Message(MSG_JOINCHANNEL) ); 	
	tempMenu->AddItem( "Send Message", new Message(MSG_SEND) ); 
	mainMenuBar->AddItem( tempMenu ); 
	AddChild( mainMenuBar ); 
//	mainMenuBar->SetTargetForItems( this ); 
	
	m_CommThread = new CommThread( this );
	m_CommThread->Run();
	
	AddMailbox("MainView");
  
}
Пример #29
0
void JObjectTree::SetRootPath( const char* path )
{
    JObject* pRoot = g_pObjectServer->FindObject( path, NULL );
    if (pRoot) SetRoot( pRoot );
} // JObjectTree::SetRootPath
Пример #30
0
bool MultiShearCatalog::getPixels(const Bounds& bounds)
{
    // The pixlist object takes up a lot of memory, so at the start 
    // of this function, I clear it out, along with psflist, etc.
    // Then we loop over sections of the coaddCat and only load the information
    // for each single-epoch observation that actually falls within the 
    // bounds for the section we are working on.

    const int nPix = _pix_list.size();

    dbg<<"Start getPixels: memory_usage = "<<memory_usage()<<std::endl;
    for (int i=0;i<nPix;++i) {
        _pix_list[i].clear();
        _psf_list[i].clear();
    }
    dbg<<"After clear: memory_usage = "<<memory_usage()<<std::endl;

    bool des_qa = _params.read("des_qa",false); 

    try {
        dbg<<"Start GetPixels for b = "<<bounds<<std::endl;
        memory_usage(dbgout);
        // Loop over the files and read pixel lists for each object.
        // The Transformation and FittedPSF constructors get the name
        // information from the parameter file, so we use that to set the 
        // names of each component image here.
        const int nfiles = _image_file_list.size();
        for (int ifile=0; ifile<nfiles; ++ifile) {
#ifdef ONLY_N_IMAGES
            if (ifile >= ONLY_N_IMAGES) break;
#endif
            dbg<<"ifile = "<<ifile<<std::endl;

            // Get the file names
            Assert(ifile < int(_image_file_list.size()));
            Assert(ifile < int(_fitpsf_file_list.size()));
            std::string image_file = _image_file_list[ifile];
            std::string fitpsf_file = _fitpsf_file_list[ifile];

            dbg<<"Reading image file: "<<image_file<<"\n";
            // Set the appropriate parameters
            _params["image_file"] = image_file;
            SetRoot(_params,image_file);
            _params["fitpsf_file"] = fitpsf_file;

            if (_shear_file_list.size() > 0) {
                Assert(ifile < int(_shear_file_list.size()));
                std::string shear_file = _shear_file_list[ifile];
                _params["shear_file"] = shear_file;
            }

            if (_skymap_file_list.size() > 0) {
                Assert(ifile < int(_skymap_file_list.size()));
                std::string skymap_file = _skymap_file_list[ifile];
                _params["skymap_file"] = skymap_file;
            }

            // Load the pixels
            dbg<<"Before load pixels for file "<<ifile<<
                ": memory_usage = "<<memory_usage()<<std::endl;
            if (!getImagePixelLists(ifile,bounds)) {
                for (int i=0;i<nPix;++i) {
                    _pix_list[i].clear();
                    _psf_list[i].clear();
                }
                PixelList::reclaimMemory();
                return false;
            }
            dbg<<"After load pixels for file "<<ifile<<
                ": memory_usage = "<<memory_usage()<<std::endl;
        }
    } catch (std::bad_alloc) {
        dbg<<"Caught bad_alloc\n";
        double mem = memory_usage(dbgout);
        double peak_mem = peak_memory_usage();
        dbg<<"memory usage = "<<mem<<" MB\n";
        dbg<<"peak memory usage = "<<peak_mem<<" MB\n";
        if (des_qa) std::cerr<<"STATUS5BEG ";
        std::cerr
            << "Memory exhausted in MultShearCatalog.\n"
            << "Memory Usage in MultiShearCatalog = "
            << calculateMemoryFootprint()<<" MB \n"
            << "Actual Virtual Memory Usage = "
            << mem<<" MB \n"
            << "Try reducing multishear_section_size or "
            << "reducing mam_vmem\n"
            << "(Current values = "
            << _params["multishear_section_size"]
            << " , "<<_params["max_vmem"]<<")";
        if (des_qa) std::cerr<<" STATUS5END";
        std::cerr<<std::endl;
        dbg << "Memory exhausted in MultShearCatalog.\n"
            << "Memory Usage in MultiShearCatalog = "
            << calculateMemoryFootprint()<<" MB \n"
            << "Actual Virtual Memory Usage = "
            << mem<<" MB \n"
            << "Try reducing multishear_section_size or "
            << "reducing mam_vmem\n"
            << "(Current values = "
            << _params["multishear_section_size"]
            << " , "<<_params["max_vmem"]<<")"
            << std::endl;
        exit(1);
    }
    dbg <<"Done getPixels\n";
    dbg << "Memory Usage in MultiShearCatalog = "
        << calculateMemoryFootprint()<<" MB \n";
    double mem = memory_usage(dbgout);
    double peak_mem = peak_memory_usage();
    double max_mem = double(_params["max_vmem"])*1024.;
    _params["peak_mem"] = peak_mem; // Keep track...
    dbg<<"Actual memory usage = "<<mem<<" MB\n";
    dbg<<"Peak memory usage = "<<peak_mem<<" MB\n";
    dbg<<"Max allowed memory usage = "<<max_mem<<" MB\n";
    return true;
}