[GME-commit] GMESRC/GME/MgaUtil ClosureDlg.cpp,NONE,1.1 ClosureDlg.h,NONE,1.1 ClosureRes.cpp,NONE,1.1 ClosureRes.h,NONE,1.1 MakeClosure.cpp,NONE,1.1 MakeClosure.h,NONE,1.1 MgaClosure.cpp,NONE,1.1 MgaClosure.h,NONE,1.1 MgaClosure.rgs,NONE,1.1 MgaUtil.dsp,1.22,1.23 MgaUtil.rc,1.34,1.35 MgaUtilApp.cpp,1.7,1.8 MgaUtilLib.idl,1.6,1.7 resource.h,1.21,1.22

gme-commit at list.isis.vanderbilt.edu gme-commit at list.isis.vanderbilt.edu
Wed Jun 2 17:30:55 CDT 2004


Update of /var/lib/gme/GMESRC/GME/MgaUtil
In directory braindrain:/tmp/cvs-serv31546

Modified Files:
	MgaUtil.dsp MgaUtil.rc MgaUtilApp.cpp MgaUtilLib.idl 
	resource.h 
Added Files:
	ClosureDlg.cpp ClosureDlg.h ClosureRes.cpp ClosureRes.h 
	MakeClosure.cpp MakeClosure.h MgaClosure.cpp MgaClosure.h 
	MgaClosure.rgs 
Log Message:
Selective closure related files checked in.


CVS User: zolmol

--- NEW FILE: ClosureDlg.cpp ---
// ClosureDlg.cpp : implementation file
//

#include "stdafx.h"
#include "gme.h"
#include "ClosureDlg.h"
#include <afxcmn.h>

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CClosureDlg dialog


CClosureDlg::CClosureDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CClosureDlg::IDD, pParent)
	, m_activeFolderContainment( true)
{
	//{{AFX_DATA_INIT(CClosureDlg)
	m_bConnection = FALSE;
	m_bContainment = FALSE;
	m_bFolderContainment = FALSE;
	m_bRefersTo = FALSE;
	m_bSetMember = FALSE;
	m_bMemberOfSets = FALSE;
	m_bReferredBy = FALSE;
	m_bBaseTypes = FALSE;
	m_bDerivedTypes = FALSE;
	m_bPartOfModels = FALSE;
	m_bPartOfFolders = FALSE;
	m_bDigIntoLibraries = FALSE;
	m_strOutputFile = _T("");
	m_outputOption = -1;
	m_direction = -1;
	m_wrappingOption = -1;
	//}}AFX_DATA_INIT
}


void CClosureDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CClosureDlg)
	DDX_Control(pDX, IDC_WRAPMINIPROJ, m_ctrlRadio1);
	DDX_Control(pDX, IDC_WRAPAUTO, m_ctrlRadio2);
	DDX_Control(pDX, IDC_WRAPASIS, m_ctrlRadio3);
	DDX_Control(pDX, IDC_CHECKPARTOFMODEL, m_ctrlPartOfModels);
	DDX_Control(pDX, IDC_CHECKPARTOFFOLDERS, m_ctrlPartOfFolders);
	DDX_Control(pDX, IDC_CHECKCONTAINMENT, m_ctrlContainment);
	DDX_Control(pDX, IDOK, m_ctrlOk);
	DDX_Control(pDX, IDC_BROWSE, m_ctrlBrowse);
	DDX_Control(pDX, IDC_EDIT1, m_ctrlOutputFile);
	DDX_Control(pDX, IDC_CHECKFOLDERCONTAINMENT, m_ctrlFolderContainment);
	DDX_Check(pDX, IDC_CHECKCONNECTION, m_bConnection);
	DDX_Check(pDX, IDC_CHECKCONTAINMENT, m_bContainment);
	DDX_Check(pDX, IDC_CHECKFOLDERCONTAINMENT, m_bFolderContainment);
	DDX_Check(pDX, IDC_CHECKREFERSTO, m_bRefersTo);
	DDX_Check(pDX, IDC_CHECKSETMEMBER, m_bSetMember);
	DDX_Check(pDX, IDC_CHECKMEMBEROF, m_bMemberOfSets);
	DDX_Check(pDX, IDC_CHECKREFERREDBY, m_bReferredBy);
	DDX_Check(pDX, IDC_CHECKBASETYPES, m_bBaseTypes);
	DDX_Check(pDX, IDC_CHECKSUBTYPES, m_bDerivedTypes);
	DDX_Check(pDX, IDC_CHECKPARTOFMODEL, m_bPartOfModels);
	DDX_Check(pDX, IDC_CHECKPARTOFFOLDERS, m_bPartOfFolders);
	DDX_Check(pDX, IDC_DIGINTOLIBRARY, m_bDigIntoLibraries);
	DDX_Text(pDX, IDC_EDIT1, m_strOutputFile);
	DDX_Radio(pDX, IDC_OUTPUTTOCLIPBOARD, m_outputOption);
	DDX_Radio(pDX, IDC_DIRECTIONUP, m_direction);
	DDX_Radio(pDX, IDC_WRAPMINIPROJ, m_wrappingOption);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CClosureDlg, CDialog)
	//{{AFX_MSG_MAP(CClosureDlg)
	ON_BN_CLICKED(IDC_BROWSE, OnBrowse)
	ON_BN_CLICKED(IDC_OUTPUTTOCLIPBOARD, OnOutputtoclipboard)
	ON_BN_CLICKED(IDC_OUTPUTTOFILE, OnOutputtofile)
	ON_BN_CLICKED(IDC_DIRECTIONUP, OnDirectionup)
	ON_BN_CLICKED(IDC_DIRECTIONDN, OnDirectiondn)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CClosureDlg message handlers

BOOL CClosureDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();

	m_wrappingOption = 1;	// automatic
	m_outputOption = 0;		// clipboard
	m_direction = 1;		// downward

	// initially use the value of the activeFolderCntm since the direction is down
	m_ctrlFolderContainment.EnableWindow( m_activeFolderContainment);

	// direction is down
	m_ctrlPartOfFolders.EnableWindow( FALSE);
	m_ctrlPartOfModels.EnableWindow( FALSE);

	m_strOutputFile = "Closure.xme";

	m_ctrlOutputFile.EnableWindow( m_outputOption);
	m_ctrlBrowse.EnableWindow( m_outputOption);

	//m_bConnection = TRUE;
	//m_bContainment = TRUE;
	//m_bFolderContainment = m_activeFolderContainment;

	//m_bRefersTo = TRUE;
	//m_bReferredBy = TRUE;

	//m_bSetMember = TRUE;
	//m_bMemberOfSets = TRUE;

	//m_bPartOfModels = FALSE;
	//m_bPartOfFolders = FALSE;

	//m_bDigIntoLibraries = TRUE;
	
	//m_bBaseTypes = TRUE;
	//m_bDerivedTypes = TRUE;

	UpdateData( FALSE);

	return TRUE;
}

void CClosureDlg::OnOK() 
{
	CDialog::OnOK();
}


void CClosureDlg::OnBrowse() 
{
	UpdateData( TRUE);
	CWaitCursor wait;
	CFileDialog dlg(FALSE, "xme", "Closure.xme",
		OFN_EXPLORER | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
		"GME Exported Files (*.xme;*.xml)|*.xme; *.xml|All Files (*.*)|*.*||");
	if( dlg.DoModal() == IDOK) 
	{
		m_strOutputFile = dlg.GetPathName();
		this->UpdateData( FALSE);
	}
}

void CClosureDlg::OnOutputtoclipboard() 
{
	UpdateData( TRUE);
	
	m_ctrlOutputFile.EnableWindow( m_outputOption);
	m_ctrlBrowse.EnableWindow( m_outputOption);
}

void CClosureDlg::OnOutputtofile() 
{
	OnOutputtoclipboard();
}

void CClosureDlg::OnDirectionup() 
{
	// if the closure direction is up: the folder containment should be allowed
	m_ctrlFolderContainment.EnableWindow( FALSE);	
	m_ctrlContainment.EnableWindow( FALSE);
	m_ctrlPartOfFolders.EnableWindow( TRUE);
	m_ctrlPartOfModels.EnableWindow( TRUE);
	m_ctrlRadio1.EnableWindow( FALSE);
	m_ctrlRadio2.EnableWindow( FALSE);
	m_ctrlRadio3.EnableWindow( FALSE);
}


void CClosureDlg::OnDirectiondn() 
{
	// if the closure direction is down: the folder containment should be set
	// according to the variable which indicates if there is any folder involved
	m_ctrlFolderContainment.EnableWindow( m_activeFolderContainment);
	m_ctrlContainment.EnableWindow( TRUE);
	m_ctrlPartOfFolders.EnableWindow( FALSE);
	m_ctrlPartOfModels.EnableWindow( FALSE);
	m_ctrlRadio1.EnableWindow( TRUE);
	m_ctrlRadio2.EnableWindow( TRUE);
	m_ctrlRadio3.EnableWindow( TRUE);
}

--- NEW FILE: ClosureDlg.h ---
#if !defined(AFX_CLOSUREDLG_H__48D48570_0158_4740_B202_295FDF50C394__INCLUDED_)
#define AFX_CLOSUREDLG_H__48D48570_0158_4740_B202_295FDF50C394__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ClosureDlg.h : header file
//
#include "resource.h"
/////////////////////////////////////////////////////////////////////////////
// CClosureDlg dialog
#include <afxcmn.h>

class CClosureDlg : public CDialog
{
// Construction
public:
	CClosureDlg(CWnd* pParent = NULL);   // standard constructor

// Dialog Data
	//{{AFX_DATA(CClosureDlg)
	enum { IDD = IDD_CLOSUREDLG };
	CButton	m_ctrlRadio1;
	CButton	m_ctrlRadio2;
	CButton	m_ctrlRadio3;
	CButton	m_ctrlPartOfModels;
	CButton	m_ctrlPartOfFolders;
	CButton	m_ctrlContainment;
	CButton	m_ctrlOk;
	CButton	m_ctrlBrowse;
	CEdit	m_ctrlOutputFile;
	CButton	m_ctrlFolderContainment;
	BOOL	m_bConnection;
	BOOL	m_bContainment;
	BOOL	m_bFolderContainment;
	BOOL	m_bRefersTo;
	BOOL	m_bSetMember;
	BOOL	m_bMemberOfSets;
	BOOL	m_bReferredBy;
	BOOL	m_bBaseTypes;
	BOOL	m_bDerivedTypes;
	BOOL	m_bPartOfModels;
	BOOL	m_bPartOfFolders;
	BOOL	m_bDigIntoLibraries;
	CString	m_strOutputFile;
	int		m_outputOption;
	int		m_direction;
	int		m_wrappingOption;
	//}}AFX_DATA


// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CClosureDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:

	// Generated message map functions
	//{{AFX_MSG(CClosureDlg)
	virtual BOOL OnInitDialog();
	virtual void OnOK();
	afx_msg void OnBrowse();
	afx_msg void OnOutputtoclipboard();
	afx_msg void OnOutputtofile();
	afx_msg void OnDirectionup();
	afx_msg void OnDirectiondn();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()

// user added:
public:
	// indicates whether any folder is involved, so the folder containment checkbox 
	// is allowed if this value is true and the closuredirection is "Down"
	bool m_activeFolderContainment;
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_CLOSUREDLG_H__48D48570_0158_4740_B202_295FDF50C394__INCLUDED_)

--- NEW FILE: ClosureRes.cpp ---
// ClosureRes.cpp : implementation file
//

#include "stdafx.h"
#include "mgautil.h"
#include "ClosureRes.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CClosureRes dialog


CClosureRes::CClosureRes(CWnd* pParent /*=NULL*/)
	: CDialog(CClosureRes::IDD, pParent)
{
	//{{AFX_DATA_INIT(CClosureRes)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CClosureRes::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CClosureRes)
	DDX_Control(pDX, IDC_LIST1, m_ctrlList);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CClosureRes, CDialog)
	//{{AFX_MSG_MAP(CClosureRes)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CClosureRes message handlers

BOOL CClosureRes::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	for( unsigned int k = 0; k < m_metaKindsAndFolders.size(); ++k)
	{
		m_ctrlList.InsertString( k, m_metaKindsAndFolders[k].c_str());
	}
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

--- NEW FILE: ClosureRes.h ---
#if !defined(AFX_CLOSURERES_H__C9DCEADD_A5A5_451B_9EB2_4BD2B6F6C9C4__INCLUDED_)
#define AFX_CLOSURERES_H__C9DCEADD_A5A5_451B_9EB2_4BD2B6F6C9C4__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ClosureRes.h : header file
//

#include "resource.h"
#include "vector"
#include "string"
/////////////////////////////////////////////////////////////////////////////
// ClosureRes dialog

class CClosureRes : public CDialog
{
// Construction
public:
	CClosureRes(CWnd* pParent = NULL);   // standard constructor
	vector< string >	m_metaKindsAndFolders;

// Dialog Data
	//{{AFX_DATA(CClosureRes)
	enum { IDD = IDD_CLOSURERES };
	CListBox	m_ctrlList;
	//}}AFX_DATA


// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CClosureRes)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
	//}}AFX_VIRTUAL

// Implementation
protected:

	// Generated message map functions
	//{{AFX_MSG(CClosureRes)
	virtual BOOL OnInitDialog();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_CLOSURERES_H__C9DCEADD_A5A5_451B_9EB2_4BD2B6F6C9C4__INCLUDED_)

--- NEW FILE: MakeClosure.cpp ---
#include "stdafx.h"
#include "MakeClosure.h"

#include "string"
#include "map"

//
// C O M M E N T
// In this file the term "The RootFolder" means the default root folder any project is placed in
// Not to be confused with top folder which means the folder staying on the top of the selected
// object hierarchy
//

inline void nop( IMgaMetaFCO * f)
{
#ifdef _DEBUG
	CComObjPtr<IMgaMetaFCO> ff( f);
	CComBstrObj name; string s;
	COMTHROW( ff->get_Name( PutOut( name)));
[...1317 lines suppressed...]
	
	CComObjPtrVector<IMgaFCO>::iterator i = m_topFcos.begin();
	for( ; i != m_topFcos.end(); ++i)
		COMTHROW(coll->Append( *i));

	*res_fcos = coll.Detach();
}

void CMakeClosure::getTopFolders( IMgaFolders **res_folds)
{
	CComPtr<IMgaFolders> coll;
	COMTHROW(coll.CoCreateInstance(OLESTR("Mga.MgaFolders")));
	
	CComObjPtrVector<IMgaFolder>::iterator i = m_topFolds.begin();
	for( ; i != m_topFolds.end(); ++i)
		COMTHROW(coll->Append( *i));

	*res_folds = coll.Detach();
}


--- NEW FILE: MakeClosure.h ---
#ifndef MAKE_CLOSURE_H
#define MAKE_CLOSURE_H

#include "CommonStl.h"

class GmeEqual
{
	public:
		GmeEqual( CComObjPtr<IMgaObject>);
		GmeEqual( CComObjPtr<IMgaFCO>);
		GmeEqual( CComObjPtr<IMgaFolder>);
		GmeEqual( CComObjPtr<IMgaModel>);

		bool operator() ( CComObjPtr<IMgaObject>& );
		bool operator() ( CComObjPtr<IMgaFCO>& );
		bool operator() ( CComObjPtr<IMgaFolder>& );
		bool operator() ( CComObjPtr<IMgaModel>& );
	private:
		CComObjPtr<IMgaObject>	m_objToFind;
		CComObjPtr<IMgaFCO>		m_fcoToFind;
		CComObjPtr<IMgaFolder>	m_folderToFind;
		CComObjPtr<IMgaModel>	m_modelToFind;
		int						m_which; // which variable is set
};


class CMakeClosure
{
 public	: // operations
	CMakeClosure( 
		IMgaFCOs *fcos, IMgaFolders *fols,
		int ref = 1, int refd = 1, 
		int conn = 1, 
		int set_mem = 1, int mem_of_set = 1, 
		int cont = 1, int part_of_mod = 1,
		int fold_cont = 1, int part_of_fold = 1,
		int base_type = 1, int derived_type = 1,
		int into_libr = 1, 
		int container_opt = 0,
		int direction_opt = 1
		)
		: m_bRefersTo( ref == 1)
		, m_bReferredBy( refd == 1)
		, m_bConnection( conn == 1)
		, m_bSetMember( set_mem == 1)
		, m_bMemberOfSets( mem_of_set == 1)
		, m_bContainment( cont == 1)
		, m_bPartOfModels( part_of_mod == 1)
		, m_bFolderContainment( fold_cont == 1)
		, m_bPartOfFolders( part_of_fold == 1)
		, m_bBaseTypes( base_type == 1)
		, m_bDerivedTypes( derived_type == 1)
		, m_bIntoLibraries( into_libr == 1)
		, m_iContainerOption( container_opt)
		, m_bDirection( direction_opt == 1)
	{
		if ( fcos)		CopyTo( fcos, m_selFcos);
		if ( fols)		CopyTo( fols, m_selFolds);

		if ( !m_selFcos.empty())		COMTHROW( m_selFcos.front()->get_Project( PutOut( m_project)) );
		else if ( !m_selFolds.empty())	COMTHROW( m_selFolds.front()->get_Project( PutOut( m_project)) );
		else							ASSERT( 0);

	}

	~CMakeClosure()
	{
		m_selFolds.clear();
		m_selFcos.clear();
		m_newlySelFolds.clear();
		m_newlySelFcos.clear();
		m_topFolds.clear();
		m_topFcos.clear();

		m_acceptingKindsAndFolders.clear();
	}
	
	long process();
	void getFCOs( IMgaFCOs **res_fcos);
	void getFolders( IMgaFolders **res_folds);
	
	bool noTopObjs(); // signals if The RootFolder is the common top (root) of all selected objects
	void getTopFCOs( IMgaFCOs **res_fcos);
	void getTopFolders( IMgaFolders **res_folds);

	vector< string > m_acceptingKindsAndFolders; // the meta names of those kinds which the closure may be inserted into

 protected:

	void initTrans(); // transaction 
	void doneTrans( bool abort);

	void doClosure();
	void processFolders();
	void processFCOs();

	void selectTop();
	void totalWrap();
	void autoWrap();
	string processUpward(IMgaObject *obj, CComObjPtrVector<IMgaFolder>& f_parents, CComObjPtrVector<IMgaModel>& m_parents);

	void checkMeta();

	void procObj( IMgaObject* obj);
	
	void procFolder( IMgaFolder *folder);

	void procModel		( IMgaModel *model);
	void procAtom		( IMgaAtom *atom);
	void procReference	( IMgaReference *reference);
	void procSet		( IMgaSet *set);
	void procConnection	( IMgaConnection *connection);
	void procConnPoint	( IMgaConnPoint *connpoint);

	void procMyConnections		( IMgaFCO * fco);
	void procMyContainerSets	( IMgaFCO * fco);
	void procMyReferences		( IMgaFCO * fco);
	void procMyParent			( IMgaFCO * fco);
	void procMyParent			( IMgaFolder * fco);

	void procMyBaseTypes		( IMgaFCO * fco);
	void procMyDerivedTypes		( IMgaFCO * fco);

	bool isInLibrary( IMgaObject * obj);

	bool findAmongSelected( const CComObjPtr<IMgaFCO>& in);
	bool findAmongSelected( const CComObjPtr<IMgaFolder>& in);
	bool findAmongNews( const CComObjPtr<IMgaFCO>& in);
	bool findAmongNews( const CComObjPtr<IMgaFolder>& in);

	void insertNew( const string& id, bool is_the_top = false);
	void insertNew( const CComObjPtr<IMgaFCO>& in);
	void insertNew( const CComObjPtrVector<IMgaFCO>& in_v);
	void insertNew( const CComObjPtr<IMgaFolder>& in);
	void insertNew( const CComObjPtrVector<IMgaFolder>& in_v);
	void insertNew( const CComObjPtr<IMgaModel>& in);

	template<class INTERFACE, class FUNC_INTERFACE, class COLLECTION>
	void insertNew(INTERFACE p, HRESULT (__stdcall FUNC_INTERFACE::*func)(COLLECTION **q))
	{
		FUNC_INTERFACE *q = p;
		ASSERT( q != NULL );

		typedef TYPENAME_COLL2ELEM(COLLECTION) element_type;

		CComObjPtrVector<element_type> v;
		COMTHROW( (q->*func)(PutOut(v)) );

		CComObjPtrVector<element_type>::iterator i = v.begin();
		CComObjPtrVector<element_type>::iterator e = v.end();
		while( i != e )
		{
			insertNew( *i);

			++i;
		}
	}

 protected: // variables
	CComObjPtr<IMgaProject> m_project;
	CComObjPtr<IMgaTerritory> m_territory;

	CComObjPtrVector<IMgaFolder> m_selFolds; // folders already in closure
	CComObjPtrVector<IMgaFCO> m_selFcos; // fcos already in closure

	CComObjPtrVector<IMgaFCO> m_newlySelFcos; // will be copied into selfcos
	CComObjPtrVector<IMgaFolder> m_newlySelFolds; // will be copied into selfolders

	// members used for the non-wrapping case
	CComObjPtrVector<IMgaFolder> m_topFolds; // parentless (top) folders
	CComObjPtrVector<IMgaFCO> m_topFcos; // parentless (top) fcos


	bool m_bRefersTo;	// objects references refer to
	bool m_bReferredBy; // references to an fco

	bool m_bConnection; // fcos on the other end of a connection and the connections themselves

	bool m_bSetMember;		// members of a set
	bool m_bMemberOfSets;	// all sets containing the fco

	bool m_bContainment;	// model containment, downward
	bool m_bPartOfModels;	// model containment, upward

	bool m_bFolderContainment;	// folder containment, downward
	bool m_bPartOfFolders;		// folder containment, upward

	bool m_bBaseTypes;		// base types of selected objects
	bool m_bDerivedTypes;	// derived types of selected objects

	bool m_bIntoLibraries;	// process through links that point into a library?

	int m_iContainerOption;	// wrap?

	bool m_bDirection;		// up or down?


};

#endif // MAKE_CLOSURE_H
--- NEW FILE: MgaClosure.cpp ---
#include "stdafx.h"

#include "MgaClosure.h"
#include "ClosureDlg.h"
#include "ClosureRes.h"
#include "MakeClosure.h"


STDMETHODIMP CMgaClosure::SelectiveClosure(
	IMgaFCOs *in_fcos, IMgaFolders *in_folders, 
	IMgaFCOs **sel_fcos, IMgaFolders **sel_folders, 
	IMgaFCOs **top_fcos, IMgaFolders **top_folders, int fc) 
{
	AFX_MANAGE_STATE( AfxGetStaticModuleState());

	CWaitCursor w;
	CClosureDlg dlg;
	dlg.m_activeFolderContainment = fc != 0;
	if ( dlg.DoModal() == IDOK)
	{
		CMakeClosure mc( 
			in_fcos, in_folders,
			dlg.m_bRefersTo, dlg.m_bReferredBy,
			dlg.m_bConnection, 
			dlg.m_bSetMember, dlg.m_bMemberOfSets, 
			// compare the containment options with the direction option
			dlg.m_direction?dlg.m_bContainment:0, !dlg.m_direction?dlg.m_bPartOfModels:0,
			dlg.m_direction?dlg.m_bFolderContainment:0, !dlg.m_direction?dlg.m_bPartOfFolders:0, 
			dlg.m_bBaseTypes, dlg.m_bDerivedTypes, 
			dlg.m_bDigIntoLibraries, 
			dlg.m_wrappingOption,
			dlg.m_direction);

		mc.process(); // do the hard job

		// load the results
		mc.getFCOs( sel_fcos);
		mc.getFolders( sel_folders);

		bool normal_tops = !mc.noTopObjs();
		
		if ( normal_tops) // the top fcos/folds is calculated and The RootFolder is not among them
		{
			mc.getTopFCOs( top_fcos);
			mc.getTopFolders( top_folders);
		}

		
		if ( normal_tops &&								// avoid in case of non-normal tops
			dlg.m_wrappingOption > 0 &&					// avoid in case of miniproject
			mc.m_acceptingKindsAndFolders.size() > 0 )	// avoid if is no accepting kind/folder
		{
			CClosureRes resdlg;
			resdlg.m_metaKindsAndFolders = mc.m_acceptingKindsAndFolders;
			resdlg.DoModal();
		}


		if ( dlg.m_outputOption == 1) // dump to a file
		{
			CComPtr<IMgaDumper> dumper;
			COMTHROW( dumper.CoCreateInstance(L"Mga.MgaDumper") );

			switch( dlg.m_wrappingOption) {
			case 0:
				{
					COMTHROW( dumper->DumpClos( *sel_fcos, *sel_folders, PutInBstr( dlg.m_strOutputFile)) );

					break;
				}
			case 1:
			case 2:
				{
					if ( normal_tops)
						COMTHROW( dumper->DumpClosR( *sel_fcos, *sel_folders, PutInBstr( dlg.m_strOutputFile), *top_fcos, *top_folders));
					else 
						// dump like in miniproject case from The RootFolder
						// if the data is copied to clipboard then the DumpClosR will call the 
						// DumpClos when it will realize the topfco and topfolders are empty
						COMTHROW( dumper->DumpClos( *sel_fcos, *sel_folders, PutInBstr( dlg.m_strOutputFile)) );

					*top_fcos = 0;
					*top_folders = 0;
					break;
				}
			} // switch

			*sel_fcos = 0;
			*sel_folders = 0;
		}
		// else: clipboard
	}
	return S_OK;
}

--- NEW FILE: MgaClosure.h ---
#ifndef MGACLOSURE_H
#define MGACLOSURE_H

// --------------------------- CMgaClosure
//

class ATL_NO_VTABLE CMgaClosure 
	: public CComObjectRootEx<CComSingleThreadModel>
	, public CComCoClass<CMgaClosure, &CLSID_MgaClosure>
	, public IMgaClosure
{
public:
	CMgaClosure() { }
	~CMgaClosure() { }

DECLARE_REGISTRY_RESOURCEID(IDR_MGACLOSURE)
DECLARE_PROTECT_FINAL_CONSTRUCT()

BEGIN_COM_MAP(CMgaClosure)
 	COM_INTERFACE_ENTRY(IMgaClosure)
END_COM_MAP()

// ------- Properties

	STDMETHOD(SelectiveClosure)( IMgaFCOs *in_fcos, IMgaFolders *in_folders, IMgaFCOs **sel_fcos, IMgaFolders **sel_folders, IMgaFCOs **top_fcos, IMgaFolders **top_folders, int fc = 0);

// ------- Attributes and Methods
public:

};

#endif // MGACLOSURE_H

--- NEW FILE: MgaClosure.rgs ---
HKCR
{
	Mga.MgaClosure.1 = s 'MgaClosure Class'
	{
		CLSID = s '{D6F2FBC5-3405-40fd-8880-7E99DD10F0BA}'
	}
	Mga.MgaClosure = s 'MgaClosure Class'
	{
		CLSID = s '{D6F2FBC5-3405-40fd-8880-7E99DD10F0BA}'
		CurVer = s 'Mga.MgaClosure.1'
	}
	NoRemove CLSID
	{
		ForceRemove {D6F2FBC5-3405-40fd-8880-7E99DD10F0BA} = s 'MgaClosure Class'
		{
			ProgID = s 'Mga.MgaClosure.1'
			VersionIndependentProgID = s 'Mga.MgaClosure'
			ForceRemove 'Programmable'
			InprocServer32 = s '%MODULE%'
			{
				val ThreadingModel = s 'Apartment'
			}
			'TypeLib' = s '{461F30AE-3BF0-11D4-B3F0-005004D38590}'
		}
	}
}

Index: MgaUtil.dsp
===================================================================
RCS file: /var/lib/gme/GMESRC/GME/MgaUtil/MgaUtil.dsp,v
retrieving revision 1.22
retrieving revision 1.23
diff -C2 -d -r1.22 -r1.23
*** MgaUtil.dsp	8 Apr 2004 18:02:55 -0000	1.22
--- MgaUtil.dsp	2 Jun 2004 21:30:44 -0000	1.23
***************
*** 135,138 ****
--- 135,146 ----
  # Begin Source File
  
+ SOURCE=.\ClosureDlg.cpp
+ # End Source File
+ # Begin Source File
+ 
+ SOURCE=.\ClosureRes.cpp
+ # End Source File
+ # Begin Source File
+ 
  SOURCE=.\colorbtn.cpp
  # End Source File
***************
*** 183,186 ****
--- 191,198 ----
  # Begin Source File
  
+ SOURCE=.\MakeClosure.cpp
+ # End Source File
+ # Begin Source File
+ 
  SOURCE=.\MetaDlg.cpp
  # End Source File
***************
*** 191,194 ****
--- 203,210 ----
  # Begin Source File
  
+ SOURCE=.\MgaClosure.cpp
+ # End Source File
+ # Begin Source File
+ 
  SOURCE=.\MgaLauncher.cpp
  # End Source File
***************
*** 297,300 ****
--- 313,324 ----
  # Begin Source File
  
+ SOURCE=.\ClosureDlg.h
+ # End Source File
+ # Begin Source File
+ 
+ SOURCE=.\ClosureRes.h
+ # End Source File
+ # Begin Source File
+ 
  SOURCE=.\colorbtn.h
  # End Source File
***************
*** 337,340 ****
--- 361,368 ----
  # Begin Source File
  
+ SOURCE=.\MakeClosure.h
+ # End Source File
+ # Begin Source File
+ 
  SOURCE=.\MetaDlg.h
  # End Source File
***************
*** 345,348 ****
--- 373,380 ----
  # Begin Source File
  
+ SOURCE=.\MgaClosure.h
+ # End Source File
+ # Begin Source File
+ 
  SOURCE=.\MgaLauncher.h
  # End Source File
***************
*** 442,445 ****
--- 474,481 ----
  
  SOURCE=.\res\icon_regundef.ico
+ # End Source File
+ # Begin Source File
+ 
+ SOURCE=.\mgaclosure.rgs
  # End Source File
  # Begin Source File

Index: MgaUtil.rc
===================================================================
RCS file: /var/lib/gme/GMESRC/GME/MgaUtil/MgaUtil.rc,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** MgaUtil.rc	8 Apr 2004 18:02:55 -0000	1.34
--- MgaUtil.rc	2 Jun 2004 21:30:44 -0000	1.35
***************
*** 433,436 ****
--- 433,502 ----
  END
  
+ IDD_CLOSUREDLG DIALOG DISCARDABLE  0, 0, 280, 202
+ STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+ CAPTION "Selective Closure"
+ FONT 8, "MS Sans Serif"
+ BEGIN
+     GROUPBOX        "Direction and relations to be considered",IDC_STATIC,21,
+                     4,236,90
+     CONTROL         "Up",IDC_DIRECTIONUP,"Button",BS_AUTORADIOBUTTON | 
+                     WS_GROUP | WS_TABSTOP,34,15,37,8
+     CONTROL         "Down",IDC_DIRECTIONDN,"Button",BS_AUTORADIOBUTTON,34,26,
+                     37,8
+     CONTROL         "Part of Models",IDC_CHECKPARTOFMODEL,"Button",
+                     BS_AUTOCHECKBOX | WS_TABSTOP,86,15,61,8
+     CONTROL         "Part of Folders",IDC_CHECKPARTOFFOLDERS,"Button",
+                     BS_AUTOCHECKBOX | WS_TABSTOP,164,15,61,8
+     CONTROL         "Containment",IDC_CHECKCONTAINMENT,"Button",
+                     BS_AUTOCHECKBOX | WS_TABSTOP,86,26,77,8
+     CONTROL         "Folder Containment",IDC_CHECKFOLDERCONTAINMENT,"Button",
+                     BS_AUTOCHECKBOX | WS_TABSTOP,164,26,77,8
+     CONTROL         "Refers To",IDC_CHECKREFERSTO,"Button",BS_AUTOCHECKBOX | 
+                     WS_TABSTOP,86,47,53,8
+     CONTROL         "Referred by",IDC_CHECKREFERREDBY,"Button",
+                     BS_AUTOCHECKBOX | WS_TABSTOP,86,58,51,8
+     CONTROL         "Connection",IDC_CHECKCONNECTION,"Button",
+                     BS_AUTOCHECKBOX | WS_TABSTOP,86,69,53,8
+     CONTROL         "Base type of",IDC_CHECKBASETYPES,"Button",
+                     BS_AUTOCHECKBOX | WS_TABSTOP,86,80,55,8
+     CONTROL         "Set Member",IDC_CHECKSETMEMBER,"Button",BS_AUTOCHECKBOX | 
+                     WS_TABSTOP,164,47,77,8
+     CONTROL         "Member Of Sets",IDC_CHECKMEMBEROF,"Button",
+                     BS_AUTOCHECKBOX | WS_TABSTOP,164,58,77,8
+     CONTROL         "Into Libraries",IDC_DIGINTOLIBRARY,"Button",
+                     BS_AUTOCHECKBOX | WS_TABSTOP,164,69,61,8
+     CONTROL         "Derived type of",IDC_CHECKSUBTYPES,"Button",
+                     BS_AUTOCHECKBOX | WS_TABSTOP,164,80,61,8
+     CONTROL         "Miniproject",IDC_WRAPMINIPROJ,"Button",
+                     BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,26,108,49,8
+     CONTROL         "Automatic",IDC_WRAPAUTO,"Button",BS_AUTORADIOBUTTON | 
+                     WS_TABSTOP,120,108,49,8
+     CONTROL         "As is",IDC_WRAPASIS,"Button",BS_AUTORADIOBUTTON | 
+                     WS_TABSTOP,214,108,32,8
+     CONTROL         "Clipboard",IDC_OUTPUTTOCLIPBOARD,"Button",
+                     BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,25,136,49,9
+     CONTROL         "File",IDC_OUTPUTTOFILE,"Button",BS_AUTORADIOBUTTON,25,
+                     148,25,9
+     EDITTEXT        IDC_EDIT1,56,146,163,12,ES_AUTOHSCROLL
+     PUSHBUTTON      " ... ",IDC_BROWSE,229,146,15,12
+     DEFPUSHBUTTON   "OK",IDOK,63,175,50,14
+     PUSHBUTTON      "Cancel",IDCANCEL,157,175,50,14
+     GROUPBOX        "Wrap selected closure",IDC_STATIC,21,98,236,22
+     GROUPBOX        "Output to",IDC_STATIC,21,125,235,38
+ END
+ 
+ IDD_CLOSURERES DIALOG DISCARDABLE  0, 0, 274, 126
+ STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
+ CAPTION "Selective Closure Result"
+ FONT 8, "MS Sans Serif"
+ BEGIN
+     DEFPUSHBUTTON   "OK",IDOK,212,30,50,14
+     PUSHBUTTON      "Cancel",IDCANCEL,211,69,50,14
+     LISTBOX         IDC_LIST1,31,22,160,82,LBS_NOINTEGRALHEIGHT | LBS_NOSEL | 
+                     WS_VSCROLL | WS_HSCROLL | WS_TABSTOP
+     GROUPBOX        "Folders or Kinds the closure can be inserted to",
+                     IDC_STATIC,21,10,178,103
+ END
+ 
  
  #ifdef APSTUDIO_INVOKED
***************
*** 527,530 ****
--- 593,597 ----
  IDR_COMPONENTPROXY      REGISTRY DISCARDABLE    "ComponentProxy.rgs"
  IDR_MGAXSLTFILESEL      REGISTRY DISCARDABLE    "MgaXsltFileSel.rgs"
+ IDR_MGACLOSURE          REGISTRY DISCARDABLE    "MgaClosure.rgs"
  
  /////////////////////////////////////////////////////////////////////////////
***************
*** 640,643 ****
--- 707,726 ----
          TOPMARGIN, 7
          BOTTOMMARGIN, 144
+     END
+ 
+     IDD_CLOSUREDLG, DIALOG
+     BEGIN
+         LEFTMARGIN, 7
+         RIGHTMARGIN, 273
+         TOPMARGIN, 7
+         BOTTOMMARGIN, 195
+     END
+ 
+     IDD_CLOSURERES, DIALOG
+     BEGIN
+         LEFTMARGIN, 7
+         RIGHTMARGIN, 267
+         TOPMARGIN, 7
+         BOTTOMMARGIN, 119
      END
  END

Index: MgaUtilApp.cpp
===================================================================
RCS file: /var/lib/gme/GMESRC/GME/MgaUtil/MgaUtilApp.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** MgaUtilApp.cpp	8 Apr 2004 18:02:55 -0000	1.7
--- MgaUtilApp.cpp	2 Jun 2004 21:30:44 -0000	1.8
***************
*** 14,17 ****
--- 14,18 ----
  #include "MgaLauncher.h"
  #include "MgaProgressDlg.h"
+ #include "MgaClosure.h"
  #include "ComponentProxy.h"
  #include "XsltFileSel.h"
***************
*** 84,87 ****
--- 85,89 ----
  OBJECT_ENTRY(CLSID_ComponentProxy, CComponentProxy)
  OBJECT_ENTRY(CLSID_MgaXsltFileSel, CXsltFileSel)
+ OBJECT_ENTRY(CLSID_MgaClosure, CMgaClosure)
  END_OBJECT_MAP()
  

Index: MgaUtilLib.idl
===================================================================
RCS file: /var/lib/gme/GMESRC/GME/MgaUtil/MgaUtilLib.idl,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** MgaUtilLib.idl	8 Apr 2004 18:02:55 -0000	1.6
--- MgaUtilLib.idl	2 Jun 2004 21:30:44 -0000	1.7
***************
*** 89,93 ****
  		[default] interface IMgaXsltFileSel;
  	};
! 	//interface IMgaVersionInfo;
  };
  
--- 89,102 ----
  		[default] interface IMgaXsltFileSel;
  	};
! 
! 	[
! 		uuid(D6F2FBC5-3405-40fd-8880-7E99DD10F0BA),
! 		helpstring("Copy Closure feature")
! 	]
! 	coclass MgaClosure
! 	{
! 		[default] interface IMgaClosure;
! 	}
! 
  };
  

Index: resource.h
===================================================================
RCS file: /var/lib/gme/GMESRC/GME/MgaUtil/resource.h,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** resource.h	8 Apr 2004 18:02:55 -0000	1.21
--- resource.h	2 Jun 2004 21:30:44 -0000	1.22
***************
*** 19,37 ****
--- 19,44 ----
  #define IDC_RADIOSYS                    1026
  #define IDC_AUTOSAVE_SAME_DIR           1026
+ #define IDC_WRAPMINIPROJ                1026
  #define IDC_RADIO2                      1027
  #define IDC_NODELFILES                  1027
  #define IDC_RADIOUSER                   1027
  #define IDC_AUTOSAVE_DEDICATED_DIR      1027
+ #define IDC_WRAPASIS                    1027
  #define IDC_RADIO3                      1028
  #define IDC_RADIOBOTH                   1028
+ #define IDC_WRAPAUTO                    1028
  #define IDC_RADIO4                      1029
  #define IDC_ACTIVEDISP                  1029
+ #define IDC_OUTPUTTOCLIPBOARD           1029
  #define IDC_CONNSRC                     1030
  #define IDC_RADIO5                      1031
  #define IDC_ACTIVE_INACTIVE             1031
+ #define IDC_OUTPUTTOFILE                1031
  #define IDC_CONNSRCPORT                 1032
  #define IDC_RADIO6                      1033
  #define IDC_ALLCOMPS                    1033
+ #define IDC_DIRECTIONUP                 1033
  #define IDC_RADIO7                      1034
+ #define IDC_DIRECTIONDN                 1034
  #define IDC_CONNTYPE                    1035
  #define IDC_RADIO8                      1036
***************
*** 75,78 ****
--- 82,88 ----
  #define IDD_XSLTDIAL                    2059
  #define IDR_MGAXSLTFILESEL              2060
+ #define IDD_CLOSUREDLG                  2063
+ #define IDR_MGACLOSURE                  2064
+ #define IDD_CLOSURERES                  2065
  #define IDR_COMPONENTPROXY              2090
  #define IDC_PROGRESS1                   2150
***************
*** 148,151 ****
--- 158,175 ----
  #define IDC_AUTOSAVE_DIR                2223
  #define IDC_EXT_ENABLE                  2224
+ #define IDC_CHECKREFERSTO               2225
+ #define IDC_CHECKCONNECTION             2226
+ #define IDC_CHECKSETMEMBER              2227
+ #define IDC_CHECKCONTAINMENT            2228
+ #define IDC_CHECKFOLDERCONTAINMENT      2229
+ #define IDC_DIGINTOLIBRARY              2230
+ #define IDC_CHECKSUBTYPES               2231
+ #define IDC_CHECKBASETYPES              2232
+ #define IDC_BROWSE                      2235
+ #define IDC_CHECKREFERREDBY             2236
+ #define IDC_CHECKMEMBEROF               2238
+ #define IDC_CHECKPARTOFMODEL            2239
+ #define IDC_CHECKPARTOFFOLDERS          2240
+ #define IDC_LIST1                       2241
  #define ID_CNTX_ADDNODE                 32774
  #define ID_CNTX_CLEARNODE               32775
***************
*** 157,163 ****
  #ifdef APSTUDIO_INVOKED
  #ifndef APSTUDIO_READONLY_SYMBOLS
! #define _APS_NEXT_RESOURCE_VALUE        2063
  #define _APS_NEXT_COMMAND_VALUE         32778
! #define _APS_NEXT_CONTROL_VALUE         2225
  #define _APS_NEXT_SYMED_VALUE           2091
  #endif
--- 181,187 ----
  #ifdef APSTUDIO_INVOKED
  #ifndef APSTUDIO_READONLY_SYMBOLS
! #define _APS_NEXT_RESOURCE_VALUE        2066
  #define _APS_NEXT_COMMAND_VALUE         32778
! #define _APS_NEXT_CONTROL_VALUE         2242
  #define _APS_NEXT_SYMED_VALUE           2091
  #endif



More information about the GME-commit mailing list