public FormSelectSchema(DocProject project) : this() { this.m_project = project; foreach (DocSection docSection in project.Sections) { if (docSection.Schemas.Count > 0) { TreeNode tnSection = new TreeNode(); tnSection.Tag = docSection; tnSection.Text = docSection.Name; tnSection.ImageIndex = 1; this.treeView.Nodes.Add(tnSection); foreach (DocSchema docSchema in docSection.Schemas) { TreeNode tnSchema = new TreeNode(); tnSchema.Tag = docSchema; tnSchema.Text = docSchema.Name; tnSchema.ImageIndex = 0; tnSection.Nodes.Add(tnSchema); } tnSection.Expand(); } } }
public static void SaveProject(DocProject project, string filePath) { project.SortProject(); string ext = System.IO.Path.GetExtension(filePath).ToLower(); switch (ext) { case ".ifcdoc": using (FileStream streamDoc = new FileStream(filePath, FileMode.Create, FileAccess.ReadWrite)) { StepSerializer formatDoc = new StepSerializer(typeof(DocProject), SchemaDOC.Types, "IFCDOC_12_0", "IfcDoc 12.0", "BuildingSmart IFC Documentation Generator"); formatDoc.WriteObject(streamDoc, project); // ... specify header...IFCDOC_11_8 } break; #if MDB case ".mdb": using (FormatMDB format = new FormatMDB(this.m_file, SchemaDOC.Types, this.m_instances)) { format.Save(); } break; #endif case ".ifcdocxml": using (FileStream streamDoc = new FileStream(filePath, FileMode.Create, FileAccess.ReadWrite)) { XmlSerializer formatDoc = new XmlSerializer(typeof(DocProject)); formatDoc.WriteObject(streamDoc, project); // ... specify header...IFCDOC_11_8 } break; } }
/// <summary> /// /// </summary> /// <param name="stream">Stream for the zip file.</param> /// <param name="project">Project.</param> /// <param name="included">Map of included definitions</param> /// <param name="type">Optional type of data to export, or null for all; DocPropertySet, DocQuantitySet are valid</param> public FormatZIP(Stream stream, DocProject project, Dictionary<DocObject, bool> included, Type type) { this.m_stream = stream; this.m_project = project; this.m_included = included; this.m_type = type; }
public CheckGridExchange(DocExchangeDefinition docExchange, DocModelView docView, DocProject docProject) { this.m_project = docProject; this.m_view = docView; this.m_exchange = docExchange; this.m_listTemplate = docProject.GetTemplateList(); // filter out template list to only those that are currently used for (int i = this.m_listTemplate.Count - 1; i >= 0; i--) { bool used = false; foreach (DocConceptRoot docRoot in this.m_view.ConceptRoots) { foreach (DocTemplateUsage docUsage in docRoot.Concepts) { if (docUsage.Definition == this.m_listTemplate[i]) { used = true; break; } } } if (!used) { this.m_listTemplate.RemoveAt(i); } } }
/// <summary> /// /// </summary> /// <param name="filename">Local file path</param> /// <param name="docSchema">Schema of diagram</param> /// <param name="docProject">Project</param> /// <param name="uml">Diagram format</param> public SchemaSVG(string filename, DocSchema docSchema, DocProject docProject, DiagramFormat format) { this.m_filename = filename; this.m_schema = docSchema; this.m_project = docProject; this.m_format = format; }
public bool SaveProject(DocProject docProject, string filename) { try { using (new ProjectWriteLock()) { // retry multiple times on any write failure for (int i = 0; i < 4; i++) { using (var stream = new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.None)) { using (var writer = new StreamWriter(stream)) using (var jsonTextWriter = new JsonTextWriter(writer)) { try { Serializer.Serialize(jsonTextWriter, docProject); break; } catch { // retry Task.Delay(15); } } } } } } catch (Exception ex) { SetError($"{DocumentationMonsterResources.FailedToSaveHelpFile}: {ex.Message}"); } return(true); }
public void FormatData(Stream stream, DocProject docProject, DocPublication docPublication, DocExchangeDefinition docExchange, Dictionary <string, DocObject> map, Dictionary <string, Type> typemap, Dictionary <long, SEntity> instances, SEntity root, bool markup) { this.m_stream = stream; this.Instance = root; this.Markup = markup; this.Save(); }
public void LoadProject(DocProject project) { if (Model.Project != null) { Model.KavaDocsModel.Configuration.AddRecentProjectItem(Model.Project.Filename, Model.KavaDocsModel.ActiveTopic?.Id, Model.Project.Title); } Model.Project = project; if (Model.Project == null) { Model.TopicTree = new ObservableCollection <DocTopic>(); return; } project.GetTopicTree(); //StringBuilder sb = new StringBuilder(); //project.WriteTopicTree(project.Topics, 0, sb); if (project.Topics != null && project.Topics.Count > 0) { Model.KavaDocsModel.ActiveTopic = project.Topics[0]; } Model.TopicTree = project.Topics; Model.KavaDocsModel.Configuration.AddRecentProjectItem(project.Filename, projectTitle: project.Title); }
public void LoadProjectTest() { var project = DocProject.LoadProject(projectFile); project.GetTopicTree(project.Topics); WriteChildTopics(project.Topics, 0); }
public FormSelectPropertyEnum(DocProject project, DocPropertyEnumeration selection) : this() { this.m_project = project; SortedList<string, DocPropertyEnumeration> list = new SortedList<string, DocPropertyEnumeration>(); foreach(DocSection section in project.Sections) { foreach(DocSchema schema in section.Schemas) { foreach(DocPropertyEnumeration enumeration in schema.PropertyEnums) { list.Add(enumeration.Name, enumeration); } } } foreach (string s in list.Keys) { DocPropertyEnumeration enumeration = list[s]; ListViewItem lvi = new ListViewItem(); lvi.Tag = enumeration; lvi.Text = enumeration.Name; lvi.ImageIndex = 0; this.listView.Items.Add(lvi); if (selection == enumeration) { lvi.Selected = true; } } }
/// <summary> /// Connects to Data Dictionary and returns session ID. /// </summary>1 /// <param name="project"></param> /// <param name="worker"></param> /// <param name="baseurl"></param> /// <param name="username"></param> /// <param name="password"></param> /// <returns></returns> public static string Connect(DocProject project, BackgroundWorker worker, string baseurl, string username, string password) { string url = baseurl + "api/4.0/session/login?email=" + HttpUtility.UrlEncode(username) + "&password="******"POST"; request.ContentLength = 0; request.ContentType = "application/x-www-form-urlencoded"; request.Accept = "application/json"; HttpWebResponse response = (HttpWebResponse)request.GetResponse(); System.IO.Stream stream = response.GetResponseStream(); System.IO.StreamReader reader = new System.IO.StreamReader(stream); string body = reader.ReadToEnd(); string cookie = response.Headers.Get("Set-Cookie"); string[] parts = cookie.Split(new char[] { ';', ',' }); // bug? comma separates session ID string match = "peregrineapisessionid="; string sessionid = null; foreach (string part in parts) { if (part.StartsWith(match)) { sessionid = part.Substring(match.Length); break; } } return(sessionid); }
public string FormatDefinitions(DocProject docProject, DocPublication docPublication, Dictionary <string, DocObject> map, Dictionary <DocObject, bool> included) { StringBuilder sb = new StringBuilder(); foreach (DocSection docSection in docProject.Sections) { foreach (DocSchema docSchema in docSection.Schemas) { foreach (DocType docType in docSchema.Types) { bool use = true; if (included != null) { use = false; included.TryGetValue(docType, out use); } if (use) { if (docType is DocDefined) { DocDefined docDefined = (DocDefined)docType; string text = this.FormatDefined(docDefined, map, included); sb.AppendLine(text); } else if (docType is DocSelect) { DocSelect docSelect = (DocSelect)docType; string text = this.FormatSelect(docSelect, map, included); sb.AppendLine(text); } else if (docType is DocEnumeration) { DocEnumeration docEnumeration = (DocEnumeration)docType; string text = this.FormatEnumeration(docEnumeration, map, included); sb.AppendLine(text); } } } foreach (DocEntity docEntity in docSchema.Entities) { bool use = true; if (included != null) { use = false; included.TryGetValue(docEntity, out use); } if (use) { string text = this.FormatEntity(docEntity, map, included); sb.AppendLine(text); } } } } return(sb.ToString()); }
public FormSelectPropertyEnum(DocProject project, DocPropertyEnumeration selection) : this() { this.m_project = project; SortedList <string, DocPropertyEnumeration> list = new SortedList <string, DocPropertyEnumeration>(); foreach (DocPropertyEnumeration enumeration in project.PropertyEnumerations) { list.Add(enumeration.Name, enumeration); } foreach (string s in list.Keys) { DocPropertyEnumeration enumeration = list[s]; ListViewItem lvi = new ListViewItem(); lvi.Tag = enumeration; lvi.Text = enumeration.Name; lvi.ImageIndex = 0; this.listView.Items.Add(lvi); if (selection == enumeration) { lvi.Selected = true; } } }
public FormValidateMappings(DocProject docProject, DocModelView docView, Dictionary <string, DocObject> mapEntity, Dictionary <long, object> instances) : this() { this.m_project = docProject; this.m_view = docView; this.m_mapEntity = mapEntity; this.m_instances = instances; }
/// <summary> /// Saves a topic in the tree and then saves the project to /// disk. /// </summary> /// <param name="topic"></param> /// <param name="project"></param> /// <param name="async"></param> /// <returns>false if data wasn't written (could be because there's nothing that's changed)</returns> public bool SaveProjectFileForTopic(DocTopic topic, DocProject project = null, bool async = false) { if (topic == null) { return(false); } if (!topic.TopicState.IsDirty) { return(false); } if (project == null) { project = kavaUi.AddinModel.ActiveProject; } if (async) { project.SaveProjectAsync(); topic.TopicState.IsDirty = false; return(true); } bool result = project.SaveProject(); if (result) { topic.TopicState.IsDirty = false; } return(result); }
public static Type CompileProject(DocProject docProject, bool psets) { Compiler compiler = new Compiler(docProject, null, null, psets); System.Reflection.Emit.AssemblyBuilder assembly = compiler.Assembly; Type[] types = null; try { types = assembly.GetTypes(); } catch (System.Reflection.ReflectionTypeLoadException) { // schema could not be compiled according to definition } foreach (Type t in types) { // todo: make root type configurable with schema if (t.Name.Equals("IfcProject")) { return(t); } } return(null); // no root type }
/// <summary> /// Generates folder of definitions /// </summary> /// <param name="path"></param> public static void GenerateCode(DocProject project, string path) { foreach (DocSection docSection in project.Sections) { foreach (DocSchema docSchema in docSection.Schemas) { foreach (DocType docType in docSchema.Types) { using (FormatJAV format = new FormatJAV(path + @"\" + docSchema.Name + @"\" + docType.Name + ".java")) { format.Instance = project; format.Definition = docType; format.Save(); } } foreach (DocEntity docType in docSchema.Entities) { using (FormatJAV format = new FormatJAV(path + @"\" + docSchema.Name + @"\" + docType.Name + ".java")) { format.Instance = project; format.Definition = docType; format.Save(); } } } } }
/// <summary> /// Loads or reloads a project by filename /// </summary> /// <param name="activeProjectFilename"></param> public void LoadProject(string activeProjectFilename) { var proj = DocProject.LoadProject(activeProjectFilename); TopicsTree.LoadProject(proj); ActiveProject = proj; }
/// <summary> /// Opens the IFCDOC model for reading /// </summary> /// <param name="path"></param> public void Open(string path) { Dictionary <long, object> instances; using (var streamDoc = new FileStream(path, FileMode.Open, FileAccess.Read)) { var serializer = new StepSerializer(typeof(DocProject), SchemaDOC.Types); Project = (DocProject)serializer.ReadObject(streamDoc, out instances); } _instances = new Dictionary <Type, List <SEntity> >(); foreach (var instance in instances.Values.OfType <SEntity>()) { var type = instance.GetType(); if (_instances.TryGetValue(type, out List <SEntity> entities)) { entities.Add(instance); } else { _instances.Add(type, new List <SEntity> { instance }); } } }
/// <summary> /// /// </summary> /// <param name="stream">Stream for the zip file.</param> /// <param name="project">Project.</param> /// <param name="included">Map of included definitions</param> /// <param name="type">Optional type of data to export, or null for all; DocPropertySet, DocQuantitySet are valid</param> public FormatZIP(Stream stream, DocProject project, Dictionary <DocObject, bool> included, Type type) { this.m_stream = stream; this.m_project = project; this.m_included = included; this.m_type = type; }
public static ResponseContext GetContexts(DocProject docProject, BackgroundWorker worker, string baseurl, string username, string password) { string sessionid = Connect(docProject, worker, baseurl, username, password); string url = baseurl + "api/4.0/IfdContext/currentUserHasReadAccess"; HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); request.Accept = "application/json"; request.Headers.Add("cookie", "peregrineapisessionid=" + sessionid); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream stream = response.GetResponseStream(); ResponseContext ifdRoot = null; try { DataContractJsonSerializerSettings settings = new DataContractJsonSerializerSettings(); DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(ResponseContext)); ifdRoot = (ResponseContext)ser.ReadObject(stream); } catch { } return(ifdRoot); }
public static CvtValuePath FromTemplateDefinition(DocTemplateDefinition dtd, DocProject docProject) { if (dtd.Rules.Count > 0 && dtd.Rules[0] is DocModelRuleAttribute) { DocModelRuleAttribute docRuleAtt = (DocModelRuleAttribute)dtd.Rules[0]; DocEntity docEnt = docProject.GetDefinition(dtd.Type) as DocEntity; if (docEnt != null) { CvtValuePath pathInner = null; if (docRuleAtt.Rules.Count > 0 && docRuleAtt.Rules[0] is DocModelRuleEntity) { pathInner = FromModelRule((DocModelRuleEntity)docRuleAtt.Rules[0], docProject); } DocAttribute docAtt = docEnt.ResolveAttribute(docRuleAtt.Name, docProject); string identifier = null; if (docRuleAtt.Name.Equals("IsDefinedBy")) { // hack for compat docRuleAtt.ToString(); // look for identifier if (docRuleAtt.Rules.Count > 0) { try { DocModelRuleConstraint docRuleIndexCon = (DocModelRuleConstraint)docRuleAtt.Rules[0].Rules[0].Rules[0].Rules[1].Rules[0].Rules[0]; if (docRuleIndexCon != null) { if (docRuleIndexCon.Expression is DocOpStatement) { DocOpStatement docOpStatement = (DocOpStatement)docRuleIndexCon.Expression; if (docOpStatement.Value != null) { identifier = docOpStatement.Value.ToString(); if (identifier.StartsWith("'") && identifier.EndsWith("'")) { identifier = identifier.Substring(1, identifier.Length - 2); } } } } } catch { } } } CvtValuePath pathRoot = new CvtValuePath(docEnt, docAtt, identifier, pathInner); return(pathRoot); } } return(null); }
public FormSelectAttribute(DocEntity entity, DocProject project, string selection, bool freeform) : this() { this.textBoxAttributeName.Enabled = freeform; this.textBoxAttributeName.Text = selection; this.LoadEntity(entity, project, selection); }
public static void UploadTemplateUsage(DocProject docProject, string baseurl, string sessionid, string parentid, DocTemplateUsage docConc) { // MVD Concept entry is a relationship in BSDD; contexts are exchanges foreach (DocTemplateItem docItem in docConc.Items) { if (docItem.Concepts.Count == 0) { string code = docItem.GetParameterValue("Reference"); if (String.IsNullOrEmpty(code)) { code = docItem.Name; } code = HttpUtility.UrlEncode(code); string name = docItem.GetParameterValue("Name"); if (code != null && name != null) { // if no sub-concepts, then its a property IfdBase ifdItem = CreateConcept(baseurl, sessionid, docItem, code, name, null, IfdConceptTypeEnum.PROPERTY); CreateRelationship(baseurl, sessionid, parentid, ifdItem.guid, IfdRelationshipTypeEnum.ASSIGNS_PROPERTIES); string paramval = docItem.GetParameterValue("Value"); if (!String.IsNullOrEmpty(paramval)) { DocDefinition docDef = docProject.GetDefinition(paramval); if (docDef != null) { // get the measure type IfdBase ifdType = SearchConcept(baseurl, sessionid, docDef.Name, IfdConceptTypeEnum.MEASURE); if (ifdType == null) { // create concept ifdType = CreateConcept(baseurl, sessionid, docDef, docDef.Name, docDef.Name, null, IfdConceptTypeEnum.MEASURE); } CreateRelationship(baseurl, sessionid, ifdItem.guid, ifdType.guid, IfdRelationshipTypeEnum.ASSIGNS_MEASURES); } } } } else { // otherwise its a nest if (docItem.Name != null) { IfdBase ifdItem = CreateConcept(baseurl, sessionid, docItem, docItem.Name, docItem.Name, null, IfdConceptTypeEnum.NEST); CreateRelationship(baseurl, sessionid, parentid, ifdItem.guid, IfdRelationshipTypeEnum.ASSIGNS_COLLECTIONS); // recurse -- e.g. properties within property sets foreach (DocTemplateUsage docInner in docItem.Concepts) { UploadTemplateUsage(docProject, baseurl, sessionid, ifdItem.guid, docInner); } } } } }
public void LoadAndSaveProjectTest() { var project = DocProject.LoadProject(projectFile); project.GetTopicTree(project.Topics); WriteChildTopics(project.Topics, 0); project.Filename = projectFile; project.SaveProject(); }
public CheckGridEntity(DocConceptRoot docRoot, DocModelView docView, DocProject docProject, Dictionary <string, DocObject> map) { this.m_root = docRoot; this.m_view = docView; this.m_project = docProject; this.m_listTemplate = new List <DocTemplateDefinition>(); List <DocTemplateDefinition> listTemplate = docProject.GetTemplateList(); //... filter out templates to only those that apply to entity... foreach (DocTemplateDefinition docTemplate in listTemplate) { if (docTemplate.Rules != null && docTemplate.Rules.Count > 0) // don't include abstract/organizational templates { bool include = false; // check for inheritance DocObject docApplicableEntity = null; if (docTemplate.Type != null && map.TryGetValue(docTemplate.Type, out docApplicableEntity) && docApplicableEntity is DocEntity) { // check for inheritance DocEntity docBase = docRoot.ApplicableEntity; while (docBase != null) { if (docBase == docApplicableEntity) { include = true; break; } if (docBase.BaseDefinition == null) { break; } DocObject docEach = null; if (map.TryGetValue(docBase.BaseDefinition, out docEach)) { docBase = (DocEntity)docEach; } else { docBase = null; } } } if (include) { this.m_listTemplate.Add(docTemplate); } } } }
/// <summary> /// Gets child concepts /// </summary> /// <param name="docProject"></param> /// <param name="worker"></param> /// <param name="baseurl"></param> /// <param name="username"></param> /// <param name="password"></param> /// <param name="ifdParent"></param> /// <param name="direction">True for children, False for parents</param> /// <returns></returns> public static IList <IfdConceptInRelationship> GetConcepts(DocProject docProject, BackgroundWorker worker, string baseurl, string username, string password, IfdConceptInRelationship ifdParent, bool direction) { SortedList <string, IfdConceptInRelationship> list = new SortedList <string, IfdConceptInRelationship>(); string sessionid = Connect(docProject, worker, baseurl, username, password); // get children string nextpage = null; do { string url = baseurl + "api/4.0/IfdConcept/" + ifdParent.guid; if (direction) { url += "/children";//filter/SUBJECT"; // ifc-2X4 } else { url += "/parents"; } if (nextpage != null) { url += "?page=" + nextpage; } HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(url); request.Accept = "application/json"; request.Headers.Add("cookie", "peregrineapisessionid=" + sessionid); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); nextpage = response.Headers.Get("Next-Page"); Stream stream = response.GetResponseStream(); ResponseConceptInRelationship responseSearch = null; try { DataContractJsonSerializerSettings settings = new DataContractJsonSerializerSettings(); DataContractJsonSerializer ser = new DataContractJsonSerializer(typeof(ResponseConceptInRelationship)); responseSearch = (ResponseConceptInRelationship)ser.ReadObject(stream); if (responseSearch != null) { foreach (IfdConceptInRelationship ifdRel in responseSearch.IfdConceptInRelationship) { list.Add(ifdRel.ToString(), ifdRel); } } } catch { break; } }while (!String.IsNullOrEmpty(nextpage)); return(list.Values); }
public FormReference(DocProject docProject, DocDefinition docBase, Dictionary<string, DocObject> map, string value) : this() { this.m_project = docProject; this.m_base = docBase; this.m_map = map; // parse value CvtValuePath valuepath = CvtValuePath.Parse(value, map); LoadValuePath(valuepath); }
public void FormatData(Stream stream, DocProject docProject, DocPublication docPublication, DocExchangeDefinition docExchange, Dictionary <string, DocObject> map, Dictionary <string, Type> typemap, Dictionary <long, SEntity> instances, SEntity root, bool markup) { StringBuilder sb = new StringBuilder(); foreach (DocModelView docView in docPublication.Views) { foreach (DocConceptRoot docRoot in docView.ConceptRoots) { // look for specific concept root dealing with mappings foreach (DocTemplateUsage docConcept in docRoot.Concepts) { if (docConcept.Definition != null && docConcept.Definition.Uuid.Equals(DocTemplateDefinition.guidTemplateMapping) && docConcept.Items.Count > 0) //... { bool included = true; if (docExchange != null) { included = false; // if exhcnage specified, check for inclusion foreach (DocExchangeItem docExchangeItem in docConcept.Exchanges) { if (docExchangeItem.Exchange == docExchange && docExchangeItem.Requirement == DocExchangeRequirementEnum.Mandatory) { included = true; break; } } } // check if there are any instances to populate table if (included) { included = false; foreach (SEntity e in instances.Values) { string eachname = e.GetType().Name; if (docRoot.ApplicableEntity.IsInstanceOfType(e)) { included = true; break; } } } if (included) { string dataconcept = FormatDataConcept(docProject, docPublication, docExchange, map, typemap, instances, root, markup, docView, docRoot, docConcept); sb.Append(dataconcept); } } } } } }
public string FormatData(DocProject docProject, DocPublication docPublication, DocExchangeDefinition docExchange, Dictionary<string, DocObject> map, Dictionary<long, SEntity> instances, SEntity root, bool markup) { this.m_stream = new System.IO.MemoryStream(); this.Instance = root; this.Markup = markup; this.Save(); this.m_stream.Position = 0; StreamReader reader = new StreamReader(this.m_stream); string content = reader.ReadToEnd(); return content; }
public FormReference(DocProject docProject, DocDefinition docBase, Dictionary <string, DocObject> map, string value) : this() { this.m_project = docProject; this.m_base = docBase; this.m_map = map; // parse value CvtValuePath valuepath = CvtValuePath.Parse(value, map); LoadValuePath(valuepath); }
public FormRule(DocModelRule rule, DocProject project, DocTemplateDefinition template) : this() { this.m_rule = rule; this.m_project = project; this.m_template = template; this.Text = this.m_rule.Name; this.textBoxIdentifier.Text = this.m_rule.Identification; this.textBoxIdentifier.Enabled = !String.IsNullOrEmpty(this.m_rule.Identification); if (String.IsNullOrEmpty(this.m_rule.Identification)) { this.comboBoxUsage.SelectedIndex = 0; } else if (this.m_rule.Description != null && this.m_rule.Description.Equals("*")) { // convention indicating filter this.comboBoxUsage.SelectedIndex = 1; } else { // indicates parameter constraint this.comboBoxUsage.SelectedIndex = 2; } if (rule is DocModelRuleEntity) { this.textBoxPrefix.Enabled = true; this.textBoxPrefix.Text = ((DocModelRuleEntity)rule).Prefix; } if (this.m_rule.CardinalityMin == 0 && this.m_rule.CardinalityMax == 0) { this.comboBoxCardinality.SelectedIndex = 0; } else if (this.m_rule.CardinalityMin == -1 && this.m_rule.CardinalityMax == -1) { this.comboBoxCardinality.SelectedIndex = 1; } else if (this.m_rule.CardinalityMin == 0 && this.m_rule.CardinalityMax == 1) { this.comboBoxCardinality.SelectedIndex = 2; } else if (this.m_rule.CardinalityMin == 1 && this.m_rule.CardinalityMax == 1) { this.comboBoxCardinality.SelectedIndex = 3; } else if (this.m_rule.CardinalityMin == 1 && this.m_rule.CardinalityMax == -1) { this.comboBoxCardinality.SelectedIndex = 4; } }
public void LoadTopicTest() { var project = DocProject.LoadProject(@"c:\temp\wconnect_help\wconnect_help.json"); var topic = project.LoadByTitle("West Wind Web Connection"); Assert.True(topic != null, project.ErrorMessage); Console.WriteLine(topic.Body); Assert.NotNull(topic.Body); Assert.IsTrue(topic.Body.Contains("Welcome to West Wind Web Connection")); }
public TopicMiddleware(Func<IDictionary<string, object>, Task> inner, DocProject project, IHtmlGenerator generator, DocSettings settings) { _inner = inner; _project = project; _generator = generator; _settings = settings; var stream = Assembly.GetExecutingAssembly() .GetManifestResourceStream(typeof(TopicMiddleware), "WebsocketsRefresh.txt"); _webSocketScript = stream.ReadAllText(); _topicJS = Assembly.GetExecutingAssembly().GetManifestResourceStream(typeof(Program),"topics.js").ReadAllText(); }
public TopicMiddleware(DocProject project, IHtmlGenerator generator, DocSettings settings) { _project = project; _generator = generator; _settings = settings; var topicAssembly = typeof(TopicMiddleware).GetAssembly(); var stream = topicAssembly.GetManifestResourceStream("dotnet-stdocs.Runner.WebsocketsRefresh.txt"); _webSocketScript = stream.ReadAllText(); _topicJS = topicAssembly.GetManifestResourceStream("dotnet-stdocs.topics.js").ReadAllText(); }
public TopicMiddleware(DocProject project, IHtmlGenerator generator, DocSettings settings) { _project = project; _generator = generator; _settings = settings; var topicAssembly = typeof(TopicMiddleware).GetAssembly(); var stream = topicAssembly.GetManifestResourceStream("StorytellerDocGen.Runner.WebsocketsRefresh.txt"); _webSocketScript = stream.ReadAllText(); _topicJS = topicAssembly.GetManifestResourceStream("StorytellerDocGen.topics.js").ReadAllText(); }
public FormRule(DocModelRule rule, DocProject project, DocTemplateDefinition template) : this() { this.m_rule = rule; this.m_project = project; this.m_template = template; this.Text = this.m_rule.Name; this.textBoxIdentifier.Text = this.m_rule.Identification; this.textBoxIdentifier.Enabled = !String.IsNullOrEmpty(this.m_rule.Identification); if (String.IsNullOrEmpty(this.m_rule.Identification)) { this.comboBoxUsage.SelectedIndex = 0; } else if (this.m_rule.Description != null && this.m_rule.Description.Equals("*")) { // convention indicating filter this.comboBoxUsage.SelectedIndex = 1; } else { // indicates parameter constraint this.comboBoxUsage.SelectedIndex = 2; } if (this.m_rule.CardinalityMin == 0 && this.m_rule.CardinalityMax == 0) { this.comboBoxCardinality.SelectedIndex = 0; } else if (this.m_rule.CardinalityMin == -1 && this.m_rule.CardinalityMax == -1) { this.comboBoxCardinality.SelectedIndex = 1; } else if (this.m_rule.CardinalityMin == 0 && this.m_rule.CardinalityMax == 1) { this.comboBoxCardinality.SelectedIndex = 2; } else if (this.m_rule.CardinalityMin == 1 && this.m_rule.CardinalityMax == 1) { this.comboBoxCardinality.SelectedIndex = 3; } else if (this.m_rule.CardinalityMin == 1 && this.m_rule.CardinalityMax == -1) { this.comboBoxCardinality.SelectedIndex = 4; } this.UpdateBehavior(); }
private void LoadEntity(DocEntity entity, DocProject project, string selection) { if (entity == null) return; // recurse to base if (entity.BaseDefinition != null) { DocEntity docBase = project.GetDefinition(entity.BaseDefinition) as DocEntity; LoadEntity(docBase, project, selection); } // load attributes foreach (DocAttribute docAttr in entity.Attributes) { // if attribute is derived, dont add, but remove existing if (!String.IsNullOrEmpty(docAttr.Derived)) { foreach (ListViewItem lvi in this.listView.Items) { if (lvi.Text.Equals(docAttr.Name)) { lvi.Remove(); break; } } } else { ListViewItem lvi = new ListViewItem(); lvi.Tag = docAttr; lvi.Text = docAttr.Name; lvi.SubItems.Add(docAttr.DefinedType); // INVERSE / SET / LIST / OPTIONAL... this.listView.Items.Add(lvi); if(selection != null && lvi.Text.Equals(selection)) { lvi.Selected = true; } } } }
/// <summary> /// /// </summary> /// <param name="project">The project.</param> public FormSelectView(DocProject project, string description) : this() { this.m_project = project; if (description != null) { this.labelDescription.Text = description; } foreach (DocModelView docView in this.m_project.ModelViews) { ListViewItem lvi = new ListViewItem(); lvi.Tag = docView; lvi.Text = docView.Name; lvi.ImageIndex = 0; lvi.SubItems.Add(docView.Version); this.listView.Items.Add(lvi); } }
public FormValidate(DocProject project, DocModelView docView, DocExchangeDefinition docExchange) : this() { this.textBoxPath.Text = Properties.Settings.Default.ValidateFile; this.checkBoxReport.Checked = Properties.Settings.Default.ValidateReport; foreach (DocModelView docEachView in project.ModelViews) { this.comboBoxView.Items.Add(docEachView); } if (docView == null && project.ModelViews.Count > 0) { docView = project.ModelViews[0]; } this.comboBoxView.SelectedItem = docView; if (docExchange == null && docView != null && docView.Exchanges.Count > 0) { docExchange = docView.Exchanges[0]; } this.comboBoxExchange.SelectedItem = docExchange; }
private static string GenerateTemplateImage(DocTemplateDefinition docTemplate, Dictionary<string, DocObject> mapEntity, DocProject project, string path) { int cx = 0; int cy = 0; System.Drawing.Image image = IfcDoc.Format.PNG.FormatPNG.CreateTemplateDiagram(docTemplate, mapEntity, new Dictionary<System.Drawing.Rectangle, DocModelRule>(), project, null); if (image != null) { using (image) { cx = image.Width; cy = image.Height; string filepath = path + "\\" + docTemplate.Name.ToLower().Replace(' ', '-') + ".png"; image.Save(filepath, System.Drawing.Imaging.ImageFormat.Png); cx = cx / 2; cy = cy / 2; } } return "<br/><img src=\"" + docTemplate.Name.ToLower().Replace(' ', '-') + ".png\" width=\"" + cx + "\" height=\"" + cy + "\"/>"; }
public FormSelectPropertyEnum(DocProject project, DocPropertyEnumeration selection) : this() { this.m_project = project; foreach(DocSection section in project.Sections) { foreach(DocSchema schema in section.Schemas) { foreach(DocPropertyEnumeration enumeration in schema.PropertyEnums) { ListViewItem lvi = new ListViewItem(); lvi.Tag = enumeration; lvi.Text = enumeration.Name; this.listView.Items.Add(lvi); if (selection == enumeration) { lvi.Selected = true; } } } } }
/// <summary> /// /// </summary> /// <param name="selection">Selected template.</param> /// <param name="project">Projet containing templates.</param> /// <param name="entity">The entity for which templates are filtered.</param> public FormSelectTemplate(DocTemplateDefinition selection, DocProject project, DocEntity entity) : this() { this.m_selection = selection; this.m_project = project; this.m_entity = entity; // build map this.m_map = new Dictionary<string, DocObject>(); foreach (DocSection docSection in this.m_project.Sections) { foreach (DocSchema docSchema in docSection.Schemas) { foreach (DocEntity docEntity in docSchema.Entities) { if(!this.m_map.ContainsKey(docEntity.Name)) { m_map.Add(docEntity.Name, docEntity); } } foreach (DocType docType in docSchema.Types) { try { m_map.Add(docType.Name, docType); } catch { } } } } LoadTemplates(project.Templates); }
public string FormatDefinitions(DocProject docProject, Dictionary<string, DocObject> map, Dictionary<DocObject, bool> included) { // clear containers listPropertiesOutput.Clear(); addedIndividuals.Clear(); attribInverses.Clear(); subTypesOfEntity.Clear(); StringBuilder sb = new StringBuilder(); string ifcversion = "IFC4"; // TO DO: customize the IFC version. In case of XSD, the piece of information (the full URL) is read from the .ifcdoc file //string ifcns = "http://www.buildingsmart-tech.org/ifcOWL/" + ifcversion; string ifcns = "http://ifcowl.openbimstandards.org/" + ifcversion; // namespace definitions sb.AppendLine("@prefix : <" + ifcns + "#> ."); sb.AppendLine("@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> ."); sb.AppendLine("@prefix dce: <http://purl.org/dc/elements/1.1/> ."); sb.AppendLine("@prefix owl: <http://www.w3.org/2002/07/owl#> ."); sb.AppendLine("@prefix xsd: <http://www.w3.org/2001/XMLSchema#> ."); sb.AppendLine("@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> ."); sb.AppendLine("@prefix vann: <http://purl.org/vocab/vann/> ."); sb.AppendLine("@prefix list: <https://w3id.org/list#> ."); sb.AppendLine("@prefix expr: <https://w3id.org/express#> ."); sb.AppendLine("@prefix ifc: <" + ifcns + "#> ."); sb.AppendLine("@prefix cc: <http://creativecommons.org/ns#> ."); sb.AppendLine(""); // ontology definition sb.AppendLine("<" + ifcns + ">"); sb.AppendLine("\ta owl:Ontology ;"); sb.AppendLine("\trdfs:comment \"Ontology automatically generated from the EXPRESS schema using the IfcDoc functions developed by Pieter Pauwels ([email protected]) and Walter Terkaj ([email protected]) \" ;"); sb.AppendLine("\tcc:license <http://creativecommons.org/licenses/by/3.0/> ;"); sb.AppendLine("\tdce:contributor \"Jakob Beetz ([email protected])\" , \"Maria Poveda Villalon ([email protected])\" ;"); // \"Aleksandra Sojic ([email protected])\" , sb.AppendLine("\tdce:creator \"Pieter Pauwels ([email protected])\" , \"Walter Terkaj ([email protected])\" ;"); sb.AppendLine("\tdce:date \"2015/10/02\" ;"); sb.AppendLine("\tdce:description \"OWL ontology for the IFC conceptual data schema and exchange file format for Building Information Model (BIM) data\" ;"); sb.AppendLine("\tdce:identifier \"" + ifcversion + "\" ;"); sb.AppendLine("\tdce:language \"en\" ;"); sb.AppendLine("\tdce:title \"" + ifcversion + "\" ;"); sb.AppendLine("\tvann:preferredNamespacePrefix \"ifc\" ;"); sb.AppendLine("\tvann:preferredNamespaceUri \"" + ifcns + "\" ;"); sb.AppendLine("\towl:imports <https://w3id.org/express> ."); sb.AppendLine(); // check which Inverse Attributes must be discarded because of conflicts // get subtypes of an entity foreach (DocSection docSection in docProject.Sections) { foreach (DocSchema docSchema in docSection.Schemas) { foreach (DocEntity docEntity in docSchema.Entities) { // get supertype/subtype if (docEntity.BaseDefinition != null) { if (!subTypesOfEntity.ContainsKey(docEntity.BaseDefinition)) subTypesOfEntity.Add(docEntity.BaseDefinition, new HashSet<string>()); subTypesOfEntity[docEntity.BaseDefinition].Add(docEntity.Name); } // check attributes foreach (DocAttribute docAttr in docEntity.Attributes) { if (docAttr.Inverse != null) { var key = new Tuple<string, string>(docAttr.Inverse, docAttr.DefinedType); if (!attribInverses.ContainsKey(key)) attribInverses.Add(key, 1); else attribInverses[key] += 1; } } } } } // generate definitions foreach (DocSection docSection in docProject.Sections) { foreach (DocSchema docSchema in docSection.Schemas) { foreach (DocType docType in docSchema.Types) { bool use = false; included.TryGetValue(docType, out use); if (use) { if (docType is DocDefined) { DocDefined docDefined = (DocDefined)docType; string text = this.FormatDefinedFull(docDefined, true); sb.Append(text); } else if (docType is DocSelect) { DocSelect docSelect = (DocSelect)docType; string text = this.FormatSelectFull(docSelect, map, included, true); sb.Append(text); } else if (docType is DocEnumeration) { DocEnumeration docEnumeration = (DocEnumeration)docType; string text = this.FormatEnumerationFull(docEnumeration, true); sb.Append(text); } } } foreach (DocEntity docEntity in docSchema.Entities) { bool use = false; included.TryGetValue(docEntity, out use); if (use) { string text = this.FormatEntityFull(docEntity, map, included, true); sb.Append(text); } } } } listPropertiesOutput.Clear(); return sb.ToString(); }
/// <summary> /// Creates an inheritance diagram filtered according to model views in scope. /// </summary> /// <param name="docProject">The project.</param> /// <param name="included">Map of included entities according to filtered model view(s).</param> /// <param name="docRoot">Root of hierarchy to draw.</param> /// <param name="docEntity">Target entity to highlight, if any.</param> /// <param name="font"></param> /// <param name="map"></param> /// <returns></returns> public static Image CreateInheritanceDiagram(DocProject docProject, Dictionary<DocObject, bool> included, DocEntity docRoot, DocEntity docEntity, Font font, Dictionary<Rectangle, DocEntity> map) { Rectangle rc = DrawHierarchy(null, new Point(DX, DX), docRoot, docEntity, docProject, included, font, null); if (rc.IsEmpty) return null; Image image = new Bitmap(rc.Width + CY, rc.Height + CY); using (Graphics g = Graphics.FromImage(image)) { DrawHierarchy(g, new Point(CY/2, CY/2), docRoot, docEntity, docProject, included, font, map); } return image; }
private static void DrawAttribute( Graphics g, int lane, List<int> lanes, DocEntity docEntity, DocModelView docView, DocModelRuleAttribute ruleAttribute, Dictionary<string, DocObject> map, int offset, Dictionary<Rectangle, DocModelRule> layout, DocProject docProject, DocSchema docSchema, SEntity instance) { int x = lane * CX + FormatPNG.Border; int y = lanes[lane] + FormatPNG.Border; // find the index of the attribute List<DocAttribute> listAttr = new List<DocAttribute>(); BuildAttributeList(docEntity, listAttr, map); int iAttr = -1; for (int i = 0; i < listAttr.Count; i++) { if (listAttr[i].Name.Equals(ruleAttribute.Name)) { // found it iAttr = i; break; } } if (iAttr >= 0) { DocAttribute docAttr = listAttr[iAttr]; object valueinstance = null; if (instance != null) { System.Reflection.FieldInfo field = instance.GetType().GetField(docAttr.Name); if(field != null) { valueinstance = field.GetValue(instance); } } // map it foreach (DocModelRule ruleEach in ruleAttribute.Rules) { if (ruleEach is DocModelRuleEntity) { DocModelRuleEntity ruleEntity = (DocModelRuleEntity)ruleEach; DocObject docObj = null; if (docSchema != null) { docObj = docSchema.GetDefinition(ruleEntity.Name); if (docObj is DocDefinitionRef) docObj = null; } if (docObj == null) { map.TryGetValue(ruleEntity.Name, out docObj); } { int dest = FormatPNG.Border; if (lanes.Count > lane + 1) { dest = lanes[lane + 1] + FormatPNG.Border; } if (docObj is DocEntity) { DocEntity docEntityTarget = (DocEntity)docObj; // resolve inverse attribute List<DocAttribute> listTarget = new List<DocAttribute>(); BuildAttributeList(docEntityTarget, listTarget, map); for (int i = 0; i < listTarget.Count; i++) { DocAttribute docAttrTarget = listTarget[i]; if (docAttr.Inverse != null && docAttrTarget.Name.Equals(docAttr.Inverse)) { // found it dest += CY * (i + 1); break; } else if (docAttrTarget.Inverse != null && docAttr.Name.Equals(docAttrTarget.Inverse)) { //...also need to check for type compatibility bool found = false; DocEntity docTest = docEntity; while (docTest != null) { if (docTest.Name.Equals(docAttrTarget.DefinedType)) { found = true; break; } if (docTest.BaseDefinition == null) break; DocObject docBase = null; if (map.TryGetValue(docTest.BaseDefinition, out docBase)) { docTest = docBase as DocEntity; } else { break; } } // found it if (found) { dest += CY * (i + 1); break; } } } // draw the entity, recurse DrawEntity(g, lane + 1, lanes, docEntityTarget, docView, null, ruleEntity, map, layout, docProject, docSchema, valueinstance); } else { int targetY = lanes[lane + 1] + FormatPNG.Border; if (g != null) { Brush brush = Brushes.Black; if (instance != null) { if (valueinstance == null) { brush = Brushes.Red; } else if(valueinstance is System.Collections.IList) { brush = Brushes.Blue; } else { string typename = valueinstance.GetType().Name; if (typename == ruleEntity.Name) { brush = Brushes.Lime; } else { brush = Brushes.Red; } } } g.FillRectangle(brush, x + CX, targetY, CX - DX, CY); g.DrawRectangle(Pens.Black, x + CX, targetY, CX - DX, CY); using (Font font = new Font(FontFamily.GenericSansSerif, 8.0f)) { string content = ruleEntity.Name;//docObj.Name; foreach (DocModelRule ruleConstraint in ruleEntity.Rules) { if (ruleConstraint.Description != null && ruleConstraint.Description.StartsWith("Value=")) { content = ruleConstraint.Description.Substring(6); using (StringFormat fmt = new StringFormat()) { fmt.Alignment = StringAlignment.Far; g.DrawString(content, font, Brushes.White, new RectangleF(x + CX, targetY, CX - DX, CY), fmt); } } } g.DrawString(ruleEntity.Name, font, Brushes.White, x + CX, targetY); if (ruleEntity.Identification == "Value") { // mark rule serving as default value g.FillEllipse(Brushes.Green, new Rectangle(x + CX - DX - CY, y, CY, CY)); } } } // record rectangle if (layout != null) { layout.Add(new Rectangle(x + CX, targetY, CX - DX, CY), ruleEntity); } // increment lane offset for all lanes int minlane = targetY + CY * 2; int i = lane + 1; if (lanes[i] < minlane) { lanes[i] = minlane; } } // draw arrow if (g != null) { int x0 = x + CX - DX; int y0 = y + CY * (iAttr + 1) + CY / 2; int x1 = x + CX; int y1 = dest + CY / 2; int xM = x0 + DX / 2 - offset * 2; if(!String.IsNullOrEmpty(ruleAttribute.Identification)) { // mark the attribute as using parameter //g.DrawRectangle(Pens.Blue, x, y + CY * (iAttr + 1), CX - DX, CY); using (Font font = new Font(FontFamily.GenericSansSerif, 8.0f, FontStyle.Regular)) { using (StringFormat fmt = new StringFormat()) { fmt.Alignment = StringAlignment.Near; g.DrawString(docAttr.Name, font, Brushes.Blue, x, y + CY * (iAttr + 1), fmt); } } } g.DrawLine(Pens.Black, x0, y0, xM, y0); g.DrawLine(Pens.Black, xM, y0, xM, y1); g.DrawLine(Pens.Black, xM, y1, x1, y1); } } } } if (g != null && ruleAttribute.Identification == "Name") { // mark rule serving as default name g.FillEllipse(Brushes.Blue, new Rectangle(x + CX - DX - CY, y + CY * (iAttr+1), CY, CY)); } #if false string card = ruleAttribute.GetCardinalityExpression(); if (g != null && card != null) { card = card.Trim(); switch (docAttr.GetAggregation()) { case DocAggregationEnum.SET: card = "S" + card; break; case DocAggregationEnum.LIST: card = "L" + card; break; } int px = x + CX - DX; int py = y + CY * (iAttr + 1); g.FillRectangle(Brushes.White, px - CX / 5, py, CX / 5, CY); using (Font font = new Font(FontFamily.GenericSansSerif, 8.0f, FontStyle.Regular)) { using (StringFormat fmt = new StringFormat()) { fmt.Alignment = StringAlignment.Far; g.DrawString(card, font, Brushes.Blue, px, py, fmt); } } } #endif } }
public Compiler(DocProject project, DocModelView[] views, DocExchangeDefinition exchange) { this.m_project = project; this.m_views = views; this.m_exchange = exchange; this.m_assembly = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName("IFC4"), AssemblyBuilderAccess.RunAndSave); this.m_module = this.m_assembly.DefineDynamicModule("IFC4.dll", "IFC4.dll"); this.m_definitions = new Dictionary<string, DocObject>(); this.m_types = new Dictionary<string, Type>(); this.m_fields = new Dictionary<Type, Dictionary<string, FieldInfo>>(); this.m_templates = new Dictionary<DocTemplateDefinition, MethodInfo>(); this.m_namespaces = new Dictionary<string, string>(); Dictionary<DocObject, bool> included = null; if (this.m_views != null) { included = new Dictionary<DocObject, bool>(); foreach (DocModelView docView in this.m_views) { this.m_project.RegisterObjectsInScope(docView, included); } } foreach (DocSection docSection in project.Sections) { foreach (DocSchema docSchema in docSection.Schemas) { foreach (DocEntity docEntity in docSchema.Entities) { if (included == null || included.ContainsKey(docEntity)) { if (!this.m_definitions.ContainsKey(docEntity.Name)) { this.m_definitions.Add(docEntity.Name, docEntity); this.m_namespaces.Add(docEntity.Name, docSchema.Name); } } } foreach (DocType docType in docSchema.Types) { if (included == null || included.ContainsKey(docType)) { if (!this.m_definitions.ContainsKey(docType.Name)) { this.m_definitions.Add(docType.Name, docType); this.m_namespaces.Add(docType.Name, docSchema.Name); } } } } } // first register types and fields foreach (string key in this.m_definitions.Keys) { RegisterType(key); } // now register template functions (may depend on fields existing) // find associated ConceptRoot for model view, define validation function if (this.m_views != null) { foreach (DocModelView view in this.m_views) { string viewname = view.Code; foreach (DocConceptRoot root in view.ConceptRoots) { Type tOpen= null; if (this.m_types.TryGetValue(root.ApplicableEntity.Name, out tOpen) && tOpen is TypeBuilder) { TypeBuilder tb = (TypeBuilder)tOpen; foreach (DocTemplateUsage concept in root.Concepts) { CompileConcept(concept, view, tb); } } } } } // seal types once all are built List<TypeBuilder> listBase = new List<TypeBuilder>(); foreach (string key in this.m_definitions.Keys) { Type tOpen = this.m_types[key]; while (tOpen is TypeBuilder) { listBase.Add((TypeBuilder)tOpen); tOpen = tOpen.BaseType; } // seal in base class order for (int i = listBase.Count - 1; i >= 0; i--) { Type tClosed = listBase[i].CreateType(); this.m_types[tClosed.Name] = tClosed; } listBase.Clear(); } }
/// <summary> /// Draws entity and recurses. /// </summary> /// <param name="g">Graphics device.</param> /// <param name="lane">Horizontal lane for which to draw the entity.</param> /// <param name="lanes">List of lanes left-to-right.</param> /// <param name="docEntity">The entity to draw.</param> /// <param name="docView">The model view for which to draw the entity.</param> /// <param name="docTemplate">The template to draw.</param> /// <param name="docRule">Optional rule for recursing.</param> /// <param name="map">Map of definitions.</param> /// <param name="layout">Optional layout to receive rectangles for building image map</param> /// <param name="docProject">Required project.</param> /// <param name="instance">Optional instance where included or missing attributes are highlighted.</param> private static void DrawEntity( Graphics g, int lane, List<int> lanes, DocEntity docEntity, DocModelView docView, DocTemplateDefinition docTemplate, DocModelRuleEntity docRule, Dictionary<string, DocObject> map, Dictionary<Rectangle, DocModelRule> layout, DocProject docProject, DocSchema docSchema, object instance) { List<DocAttribute> listAttr = new List<DocAttribute>(); BuildAttributeList(docEntity, listAttr, map); while(lanes.Count < lane + 1) { int miny = 0; if (lanes.Count > lane) { miny = lanes[lane]; } lanes.Add(miny); } int x = lane * CX + FormatPNG.Border; int y = lanes[lane] + FormatPNG.Border; if (g != null) { Brush brush = Brushes.Black; if (instance != null) { brush = Brushes.Red; if (instance is System.Collections.IList) { string typename = instance.GetType().Name; // keep going until matching instance System.Collections.IList list = (System.Collections.IList)instance; foreach (object member in list) { string membertypename = member.GetType().Name; DocEntity docType = docProject.GetDefinition(membertypename) as DocEntity; while (docType != null) { if (docType == docEntity) { brush = Brushes.Lime; instance = member; break; } docType = docProject.GetDefinition(docType.BaseDefinition) as DocEntity; } if (brush != Brushes.Red) break; } } else { string typename = instance.GetType().Name; DocEntity docType = docProject.GetDefinition(typename) as DocEntity; while (docType != null) { if (docType == docEntity) { brush = Brushes.Lime; break; } docType = docProject.GetDefinition(docType.BaseDefinition) as DocEntity; } } } else if (docEntity.IsAbstract()) { brush = Brushes.Gray; } else { brush = Brushes.Black; } g.FillRectangle(brush, x, y, CX - DX, CY); g.DrawRectangle(Pens.Black, x, y, CX - DX, CY); using (Font font = new Font(FontFamily.GenericSansSerif, 8.0f, FontStyle.Bold)) { g.DrawString(docEntity.Name, font, Brushes.White, x, y); } if (docRule != null && docRule.Identification == "Value") { // mark rule serving as default value g.FillEllipse(Brushes.Green, new Rectangle(x + CX - DX - CY, y, CY, CY)); } g.DrawRectangle(Pens.Black, x, y + CY, CX - DX, CY * listAttr.Count); using (Font font = new Font(FontFamily.GenericSansSerif, 8.0f, FontStyle.Regular)) { for (int iAttr = 0; iAttr < listAttr.Count; iAttr++) { DocAttribute docAttr = listAttr[iAttr]; string display = docAttr.GetAggregationExpression(); brush = Brushes.Black; if (docAttr.Inverse != null) { brush = Brushes.Gray; } if(String.IsNullOrEmpty(display)) { if(docAttr.IsOptional) { display = "[0:1]"; } else { display = "[1:1]"; } } g.DrawString(docAttr.Name, font, brush, x, y + CY * (iAttr + 1)); using (StringFormat fmt = new StringFormat()) { fmt.Alignment = StringAlignment.Far; g.DrawString(display, font, brush, new RectangleF(x, y + CY * (iAttr + 1), CX - DX, CY), fmt); } } } } // record rectangle if (layout != null) { layout.Add(new Rectangle(x, y, CX - DX, CY + CY * listAttr.Count), docRule); } SortedList<int, List<DocModelRuleAttribute>> mapAttribute = new SortedList<int, List<DocModelRuleAttribute>>(); Dictionary<DocModelRuleAttribute, DocTemplateDefinition> mapTemplate = new Dictionary<DocModelRuleAttribute,DocTemplateDefinition>(); if (docRule != null && docRule.Rules != null) { // map inner rules // sort foreach (DocModelRule rule in docRule.Rules) { if (rule is DocModelRuleAttribute) { DocModelRuleAttribute ruleAttribute = (DocModelRuleAttribute)rule; for (int i = 0; i < listAttr.Count; i++) { if (listAttr[i].Name.Equals(ruleAttribute.Name)) { // found it if (!mapAttribute.ContainsKey(i)) { mapAttribute.Add(i, new List<DocModelRuleAttribute>()); } mapAttribute[i].Add(ruleAttribute); break; } } } } } else if (docTemplate != null) { if (docTemplate.Rules != null) { foreach (DocModelRuleAttribute ruleAttribute in docTemplate.Rules) { for (int i = 0; i < listAttr.Count; i++) { if (listAttr[i].Name != null && listAttr[i].Name.Equals(ruleAttribute.Name)) { // found it //iAttr = i; if (!mapAttribute.ContainsKey(i)) { mapAttribute.Add(i, new List<DocModelRuleAttribute>()); } mapAttribute[i].Add(ruleAttribute); break; } } } } } else { // map each use definition at top-level // build list of inherited views List<DocModelView> listViews = new List<DocModelView>(); DocModelView docBaseView = docView; while (docBaseView != null) { listViews.Add(docBaseView); if (!String.IsNullOrEmpty(docBaseView.BaseView)) { Guid guidBase = Guid.Parse(docBaseView.BaseView); if (guidBase != docBaseView.Uuid) { docBaseView = docProject.GetView(guidBase); } else { docBaseView = null; } } else { docBaseView = null; } } // build from inherited entities too List<DocTemplateDefinition> listTemplates = new List<DocTemplateDefinition>(); // keep track of templates so we don't repeat at supertypes List<DocTemplateDefinition> listSuppress = new List<DocTemplateDefinition>(); // list of templates that are suppressed DocEntity docEntitySuper = docEntity; while(docEntitySuper != null) { foreach (DocModelView docEachView in docProject.ModelViews) { if (docView == null || listViews.Contains(docEachView)) { foreach (DocConceptRoot docRoot in docEachView.ConceptRoots) { if (docRoot.ApplicableEntity == docEntitySuper) { foreach (DocTemplateUsage docUsage in docRoot.Concepts) { if (docUsage.Definition != null && docUsage.Definition.Rules != null && !listTemplates.Contains(docUsage.Definition) && !listSuppress.Contains(docUsage.Definition)) { if (docUsage.Suppress) { listSuppress.Add(docUsage.Definition); } else { listTemplates.Add(docUsage.Definition); foreach (DocModelRuleAttribute ruleAttribute in docUsage.Definition.Rules) { for (int i = 0; i < listAttr.Count; i++) { if (listAttr[i].Name.Equals(ruleAttribute.Name)) { // found it if (!mapAttribute.ContainsKey(i)) { mapAttribute.Add(i, new List<DocModelRuleAttribute>()); } mapAttribute[i].Add(ruleAttribute); if (!mapTemplate.ContainsKey(ruleAttribute)) { mapTemplate.Add(ruleAttribute, docUsage.Definition); } break; } } } } } } } } } } DocObject docTest = null; if (docEntitySuper.BaseDefinition != null && map.TryGetValue(docEntitySuper.BaseDefinition, out docTest)) { docEntitySuper = docTest as DocEntity; } else { docEntitySuper = null; } } } int offset = -mapAttribute.Values.Count / 2; DocTemplateDefinition lastTemplate = null; foreach (List<DocModelRuleAttribute> listSort in mapAttribute.Values) { if (docRule == null && docTemplate == null) { // offset all lanes int maxlane = 0; for (int i = 1; i < lanes.Count; i++) { if (lanes[i] > maxlane) { maxlane = lanes[i]; } } for (int i = 1; i < lanes.Count; i++) { lanes[i] = maxlane; } } foreach (DocModelRuleAttribute ruleAttributeSort in listSort) { // indicate each template DocTemplateDefinition eachTemplate = null; if (mapTemplate.TryGetValue(ruleAttributeSort, out eachTemplate)) { // offset for use definition int minlan = 0; for (int i = 1; i < lanes.Count; i++) { if (eachTemplate != lastTemplate) { lanes[i] += CY * 2; } if (lanes[i] > minlan) { minlan = lanes[i]; } } // verify this... for (int i = 1; i < lanes.Count; i++) { if (lanes[i] < minlan) { lanes[i] = minlan; } } if (g != null && eachTemplate != lastTemplate) { using (Font font = new Font(FontFamily.GenericSansSerif, 8.0f, FontStyle.Italic)) { g.DrawString(eachTemplate.Name, font, Brushes.Gray, CX + FormatPNG.Border, lanes[1] - CY * 2 + FormatPNG.Border); } int lineY = lanes[1] - CY * 2 + FormatPNG.Border; g.DrawLine(Pens.Gray, CX + FormatPNG.Border, lineY, 1920, lineY); } lastTemplate = eachTemplate; } DrawAttribute(g, lane, lanes, docEntity, docView, ruleAttributeSort, map, offset, layout, docProject, docSchema, instance as SEntity); } offset++; } // increment lane offset int minlane = y + CY * (listAttr.Count + 2); if (lanes[lane] < minlane) { lanes[lane] = minlane; } }
public FormSelectProperty(DocEntity docEntity, DocProject docProject, bool multiselect) : this() { this.m_entity = docEntity; this.m_project = docProject; if (multiselect) { this.treeViewProperty.CheckBoxes = true; this.Text = "Include Property Sets"; } foreach(DocSection docSection in this.m_project.Sections) { foreach(DocSchema docSchema in docSection.Schemas) { foreach(DocPropertySet docPset in docSchema.PropertySets) { bool include = false; if (docPset.ApplicableType != null) { string[] parts = docPset.ApplicableType.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach(string part in parts) { DocEntity docBase = docEntity; while (docBase != null) { if (part.Contains(docBase.Name)) { include = true; break; } docBase = this.m_project.GetDefinition(docBase.BaseDefinition) as DocEntity; } } } if (this.m_entity == null || include) { TreeNode tnPset = new TreeNode(); tnPset.Tag = docPset; tnPset.Text = docPset.Name; this.treeViewProperty.Nodes.Add(tnPset); if (!this.treeViewProperty.CheckBoxes) { foreach (DocProperty docProp in docPset.Properties) { TreeNode tnProp = new TreeNode(); tnProp.Tag = docProp; tnProp.Text = docProp.Name; tnPset.Nodes.Add(tnProp); } } } } } } this.treeViewProperty.ExpandAll(); }
private static void WriteConceptTemplates(DocProject project, FormatHTM format, bool descriptions, bool all, string path, Dictionary<string, DocObject> mapEntity, Dictionary<DocObject, bool> included) { foreach (DocTemplateDefinition docTemplate in project.Templates) { if (all || included.ContainsKey(docTemplate)) { int count = 1; if (docTemplate.Templates != null) { foreach (DocTemplateDefinition doc2 in docTemplate.Templates) { if (all || included.ContainsKey(doc2)) { count++; if (doc2.Templates != null) { foreach (DocTemplateDefinition doc3 in doc2.Templates) { if (all || included.ContainsKey(doc3)) { count++; } } } } } } string img = ""; if (docTemplate.Rules != null && docTemplate.Rules.Count > 0) { img = GenerateTemplateImage(docTemplate, mapEntity, project, path); //img = "<br/><img src=\"" + docTemplate.Name.ToLower().Replace(' ', '-') + ".png\" width=\"" + cx + "\" height=\"" + cy + "\"/>"; } format.WriteLine("<tr><td rowspan=\"" + count + "\">" + docTemplate.Name + "</td><td></td><td></td>"); if (descriptions) { format.Write("<td>" + docTemplate.Documentation + img + "</td>"); } format.WriteLine("</tr>"); if (docTemplate.Templates != null) { foreach (DocTemplateDefinition doc2 in docTemplate.Templates) { if (all || included.ContainsKey(doc2)) { int count2 = 1; if (doc2.Templates != null) { foreach (DocTemplateDefinition doc3 in doc2.Templates) { if (all || included.ContainsKey(doc3)) { count2++; } } } img = ""; if (doc2.Rules != null && doc2.Rules.Count > 0) { img = GenerateTemplateImage(doc2, mapEntity, project, path); //img = "<br/><img src=\"" + doc2.Name.ToLower().Replace(' ', '-') + ".png\"/>"; } format.WriteLine("<tr><td rowspan=\"" + count2 + "\">" + doc2.Name + "</td><td></td>"); if (descriptions) { format.WriteLine("<td>" + doc2.Documentation + img + "</td>"); } format.Write("</tr>"); if (doc2.Templates != null) { foreach (DocTemplateDefinition doc3 in doc2.Templates) { if (all || included.ContainsKey(doc3)) { img = ""; if (doc3.Rules != null && doc3.Rules.Count > 0) { img = GenerateTemplateImage(doc3, mapEntity, project, path); //img = "<br/><img src=\"" + doc3.Name.ToLower().Replace(' ', '-') + ".png\"/>"; } format.WriteLine("<tr><td>" + doc3.Name + "</td>"); if (descriptions) { format.WriteLine("<td>" + doc3.Documentation + img + "</td>"); } format.WriteLine("</tr>"); } } } } } } } } }
/// <summary> /// Creates an instance diagram for a template. /// </summary> /// <param name="docTemplate"></param> /// <returns></returns> internal static Image CreateTemplateDiagram(DocTemplateDefinition docTemplate, Dictionary<string, DocObject> map, Dictionary<Rectangle, DocModelRule> layout, DocProject docProject, SEntity instance) { DocObject docTarget = null; if (docTemplate.Type == null || !map.TryGetValue(docTemplate.Type, out docTarget) || !(docTarget is DocEntity)) return null; DocEntity docEntity = (DocEntity)docTarget; DocSchema docSchema = docProject.GetSchemaOfDefinition(docEntity); // first, determine bounds of drawing List<int> lanes = new List<int>(); // keep track of position offsets in each lane for (int i = 0; i < 16; i++) { lanes.Add(0); } layout.Clear(); DrawEntity(null, 0, lanes, docEntity, null, docTemplate, null, map, layout, docProject, docSchema, instance); Rectangle rcBounds = new Rectangle(); foreach(Rectangle rc in layout.Keys) { if(rc.Right > rcBounds.Right) { rcBounds.Width = rc.Right; } if(rc.Bottom > rcBounds.Bottom) { rcBounds.Height = rc.Bottom; } } rcBounds.Width += FormatPNG.Border; rcBounds.Height += FormatPNG.Border; Image image = new Bitmap(rcBounds.Width, rcBounds.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb); using (Graphics g = Graphics.FromImage(image)) { g.FillRectangle(Brushes.White, new Rectangle(0, 0, image.Width, image.Height)); lanes = new List<int>(); // keep track of position offsets in each lane for (int i = 0; i < 16; i++) { lanes.Add(0); } layout.Clear(); DrawEntity(g, 0, lanes, docEntity, null, docTemplate, null, map, layout, docProject, docSchema, instance); g.DrawRectangle(Pens.Black, 0, 0, rcBounds.Width - 1, rcBounds.Height - 1); } return image; }
SEntity m_instance; // optional instance to highlight //public FormProperties(DocObject docObject, DocObject docParent, DocProject docProject) : this() public void Init(DocObject[] path, DocProject docProject) { TabPage tabpageExist = this.tabControl.SelectedTab; this.tabControl.TabPages.Clear(); this.m_path = path; if (this.m_path == null) { return; } this.m_loadall = true; this.m_target = path[path.Length-1]; if (path.Length > 1) { this.m_parent = path[path.Length - 2]; } this.m_project = docProject; this.m_map = new Dictionary<string, DocObject>(); DocObject docObject = this.m_target; this.toolStripButtonTranslationRemove.Enabled = false; // build map foreach (DocSection docSection in this.m_project.Sections) { foreach (DocSchema docSchema in docSection.Schemas) { foreach (DocEntity docEntity in docSchema.Entities) { if(!this.m_map.ContainsKey(docEntity.Name)) { this.m_map.Add(docEntity.Name, docEntity); } } foreach (DocType docType in docSchema.Types) { if(!this.m_map.ContainsKey(docType.Name)) { this.m_map.Add(docType.Name, docType); } } } } // General pages applies to all definitions this.tabControl.TabPages.Add(this.tabPageGeneral); this.textBoxGeneralName.Enabled = false; this.textBoxGeneralName.Text = docObject.Name; this.textBoxGeneralDescription.Text = docObject.Documentation; this.listViewLocale.Items.Clear(); foreach (DocLocalization docLocal in docObject.Localization) { ListViewItem lvi = new ListViewItem(); lvi.Tag = docLocal; lvi.Text = docLocal.Locale; lvi.SubItems.Add(docLocal.Name); lvi.SubItems.Add(docLocal.Documentation); this.listViewLocale.Items.Add(lvi); } this.tabControl.TabPages.Add(this.tabPageIdentity); this.textBoxIdentityUuid.Text = docObject.Uuid.ToString(); this.textBoxIdentityCode.Text = docObject.Code; this.textBoxIdentityVersion.Text = docObject.Version; this.comboBoxIdentityStatus.Text = docObject.Status; this.textBoxIdentityAuthor.Text = docObject.Author; this.textBoxIdentityOwner.Text = docObject.Owner; this.textBoxIdentityCopyright.Text = docObject.Copyright; if (docObject is DocModelView) { this.tabControl.TabPages.Add(this.tabPageView); DocModelView docView = (DocModelView)docObject; this.checkBoxViewIncludeAll.Checked = docView.IncludeAllDefinitions; this.textBoxViewRoot.Text = docView.RootEntity; if (docView.BaseView != null) { this.textBoxViewBase.Text = docView.BaseView; try { Guid guidView = new Guid(docView.BaseView); DocModelView docViewBase = this.m_project.GetView(guidView); if (docViewBase != null) { this.textBoxViewBase.Text = docViewBase.Name; } } catch { } } else { this.textBoxViewBase.Text = string.Empty; } this.textBoxViewXsdNamespace.Text = docView.XsdUri; if (docView.XsdFormats != null) { foreach (DocXsdFormat docFormat in docView.XsdFormats) { ListViewItem lvi = new ListViewItem(); lvi.Tag = docFormat; lvi.Text = docFormat.Entity; lvi.SubItems.Add(docFormat.Attribute); lvi.SubItems.Add(docFormat.XsdFormat.ToString()); lvi.SubItems.Add(docFormat.XsdTagless.ToString()); this.listViewViewXsd.Items.Add(lvi); } } } else if (docObject is DocExchangeDefinition) { this.tabControl.TabPages.Add(this.tabPageExchange); DocExchangeDefinition docExchange = (DocExchangeDefinition)docObject; this.checkBoxExchangeImport.Checked = ((docExchange.Applicability & DocExchangeApplicabilityEnum.Import) != 0); this.checkBoxExchangeExport.Checked = ((docExchange.Applicability & DocExchangeApplicabilityEnum.Export) != 0); if (docExchange.Icon != null) { try { this.panelIcon.BackgroundImage = Image.FromStream(new System.IO.MemoryStream(docExchange.Icon)); } catch { } } else { this.panelIcon.BackgroundImage = null; } this.comboBoxExchangeClassProcess.Text = docExchange.ExchangeClass; this.comboBoxExchangeClassSender.Text = docExchange.SenderClass; this.comboBoxExchangeClassReceiver.Text = docExchange.ReceiverClass; } else if (docObject is DocTemplateDefinition) { this.tabControl.TabPages.Add(this.tabPageTemplate); DocTemplateDefinition docTemplate = (DocTemplateDefinition)docObject; this.tabControl.TabPages.Add(this.tabPageOperations); this.tabControl.TabPages.Add(this.tabPageUsage); this.listViewUsage.Items.Clear(); // usage from other templates foreach(DocTemplateDefinition docTemp in this.m_project.Templates) { InitUsageFromTemplate(docTemp, docTemplate); } // usage from model views foreach (DocModelView docView in this.m_project.ModelViews) { foreach (DocConceptRoot docRoot in docView.ConceptRoots) { foreach (DocTemplateUsage docUsage in docRoot.Concepts) { if (docUsage.Definition == docTemplate) { DocObject[] usagepath = new DocObject[] { docRoot.ApplicableEntity, docRoot, docUsage }; ListViewItem lvi = new ListViewItem(); lvi.Tag = usagepath; lvi.Text = docView.Name; lvi.SubItems.Add(docRoot.ApplicableEntity.Name); this.listViewUsage.Items.Add(lvi); } } } } this.ctlRules.Project = this.m_project; this.ctlRules.BaseTemplate = this.m_parent as DocTemplateDefinition; this.ctlRules.Template = docTemplate; this.ctlOperators.Project = this.m_project; this.ctlOperators.Template = docTemplate; this.ctlOperators.Rule = null; } else if (docObject is DocConceptRoot) { this.tabControl.TabPages.Add(this.tabPageConceptRoot); DocConceptRoot docRoot = (DocConceptRoot)docObject; //DocEntity docEntity = (DocEntity)this.m_parent; DocEntity docEntity = docRoot.ApplicableEntity; DocModelView docView = null; foreach (DocModelView docViewEach in this.m_project.ModelViews) { if (docViewEach.ConceptRoots.Contains(docRoot)) { docView = docViewEach; break; } } DocModelView[] listViews = docProject.GetViewInheritance(docView); ; // find all inherited concepts List<DocTemplateDefinition> listTemplate = new List<DocTemplateDefinition>(); Dictionary<DocTemplateDefinition, DocEntity> mapTemplate = new Dictionary<DocTemplateDefinition, DocEntity>(); Dictionary<DocTemplateDefinition, DocModelView> mapView = new Dictionary<DocTemplateDefinition, DocModelView>(); while (docEntity != null) { foreach (DocModelView docSuperView in listViews) { foreach (DocConceptRoot docRootEach in docSuperView.ConceptRoots) { if (docRootEach.ApplicableEntity == docEntity) { foreach (DocTemplateUsage docConcept in docRootEach.Concepts) { if (docConcept.Definition != null) { if (listTemplate.Contains(docConcept.Definition)) { listTemplate.Remove(docConcept.Definition); } listTemplate.Insert(0, docConcept.Definition); mapTemplate[docConcept.Definition] = docEntity; mapView[docConcept.Definition] = docSuperView; } } } } } // recurse upwards docEntity = this.m_project.GetDefinition(docEntity.BaseDefinition) as DocEntity; } this.listViewConceptRoot.Items.Clear(); foreach (DocTemplateDefinition dtd in listTemplate) { ListViewItem lvi = new ListViewItem(); lvi.Tag = dtd; lvi.Text = dtd.Name; DocEntity docTemplateEntity = mapTemplate[dtd]; lvi.SubItems.Add(docTemplateEntity.Name); DocModelView docTemplateView = mapView[dtd]; lvi.SubItems.Add(docTemplateView.Name); // find local override if any lvi.ImageIndex = 3; foreach (DocTemplateUsage docConcept in docRoot.Concepts) { if(docConcept.Definition == dtd) { UpdateConceptInheritance(lvi, docConcept); break; } } this.listViewConceptRoot.Items.Add(lvi); } } else if (docObject is DocTemplateUsage) { this.tabControl.TabPages.Add(this.tabPageConcept); this.tabControl.TabPages.Add(this.tabPageRequirements); DocTemplateUsage docUsage = (DocTemplateUsage)docObject; this.ctlParameters.Project = this.m_project; this.ctlParameters.ConceptRoot = this.m_path[3] as DocConceptRoot; this.ctlParameters.ConceptItem = this.ctlParameters.ConceptRoot; this.ctlParameters.ConceptLeaf = docUsage; this.LoadModelView(); } else if (docObject is DocSchema) { DocSchema docSchema = (DocSchema)docObject; } else if (docObject is DocEntity) { DocEntity docEntity = (DocEntity)docObject; this.tabControl.TabPages.Add(this.tabPageEntity); this.textBoxEntityBase.Text = docEntity.BaseDefinition; this.checkBoxEntityAbstract.Checked = docEntity.IsAbstract(); } else if(docObject is DocDefined) { DocDefined docDefined = (DocDefined)docObject; this.textBoxAttributeType.Text = docDefined.DefinedType; this.tabControl.TabPages.Add(this.tabPageAttribute); this.labelAttributeInverse.Visible = false; this.textBoxAttributeInverse.Visible = false; this.buttonAttributeInverse.Visible = false; this.checkBoxAttributeOptional.Visible = false; this.checkBoxXsdTagless.Visible = false; this.labelAttributeXsdFormat.Visible = false; this.comboBoxAttributeXsdFormat.Visible = false; this.LoadAttributeCardinality(); } else if (docObject is DocAttribute) { DocAttribute docAttribute = (DocAttribute)docObject; this.tabControl.TabPages.Add(this.tabPageAttribute); this.textBoxAttributeType.Text = docAttribute.DefinedType; this.textBoxAttributeInverse.Text = docAttribute.Inverse; this.textBoxAttributeDerived.Text = docAttribute.Derived; this.checkBoxAttributeOptional.Checked = docAttribute.IsOptional; if (docAttribute.XsdTagless != null) { if(docAttribute.XsdTagless == true) { this.checkBoxXsdTagless.CheckState = CheckState.Checked; } else { this.checkBoxXsdTagless.CheckState = CheckState.Unchecked; } } else { this.checkBoxXsdTagless.CheckState = CheckState.Indeterminate; } this.comboBoxAttributeXsdFormat.SelectedItem = docAttribute.XsdFormat.ToString(); this.LoadAttributeCardinality(); } else if (docObject is DocConstraint) { DocConstraint docConstraint = (DocConstraint)docObject; this.tabControl.TabPages.Add(this.tabPageExpression); this.textBoxExpression.Text = docConstraint.Expression; } else if (docObject is DocPropertySet) { this.tabControl.TabPages.Add(this.tabPagePropertySet); DocPropertySet docPset = (DocPropertySet)docObject; this.LoadApplicability(); this.comboBoxPsetType.Text = docPset.PropertySetType; } else if (docObject is DocProperty) { this.tabControl.TabPages.Add(this.tabPageProperty); DocProperty docProp = (DocProperty)docObject; this.comboBoxPropertyType.Text = docProp.PropertyType.ToString(); this.textBoxPropertyData.Text = docProp.PrimaryDataType; if (!String.IsNullOrEmpty(docProp.SecondaryDataType)) { string[] enumhost = docProp.SecondaryDataType.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries); if (enumhost.Length == 2) { string[] enumvals = enumhost[1].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); this.textBoxPropertyData.Text = enumhost[0]; this.listViewPropertyEnums.Items.Clear(); foreach (string eachenum in enumvals) { ListViewItem lvi = new ListViewItem(); lvi.Tag = eachenum; lvi.Text = eachenum; this.listViewPropertyEnums.Items.Add(lvi); } } } } else if (docObject is DocQuantitySet) { this.tabControl.TabPages.Add(this.tabPagePropertySet); this.LoadApplicability(); this.comboBoxPsetType.Enabled = false; } else if (docObject is DocQuantity) { this.tabControl.TabPages.Add(this.tabPageQuantity); DocQuantity docProp = (DocQuantity)docObject; this.comboBoxQuantityType.Text = docProp.QuantityType.ToString(); } else if (docObject is DocExample) { this.tabControl.TabPages.Add(this.tabPagePropertySet); this.tabControl.TabPages.Add(this.tabPageExample); this.LoadApplicability(); this.comboBoxPsetType.Enabled = false; this.buttonApplicabilityAddTemplate.Visible = true; DocExample docExample = (DocExample)docObject; if (docExample.File != null) { this.textBoxExample.Text = Encoding.ASCII.GetString(docExample.File); this.buttonExampleClear.Enabled = true; } else { this.textBoxExample.Text = String.Empty; this.buttonExampleClear.Enabled = false; } this.checkedListBoxExampleViews.Items.Clear(); foreach (DocModelView docView in this.m_project.ModelViews) { this.checkedListBoxExampleViews.Items.Add(docView, (docExample.Views.Contains(docView))); } } else if(docObject is DocChangeAction) { this.tabControl.TabPages.Add(this.tabPageChange); DocChangeAction docChange = (DocChangeAction)docObject; this.toolStripButtonChangeSPF.Checked = docChange.ImpactSPF; this.toolStripButtonChangeXML.Checked = docChange.ImpactXML; switch(docChange.Action) { case DocChangeActionEnum.NOCHANGE: this.toolStripComboBoxChange.SelectedIndex = 0; break; case DocChangeActionEnum.ADDED: this.toolStripComboBoxChange.SelectedIndex = 1; break; case DocChangeActionEnum.DELETED: this.toolStripComboBoxChange.SelectedIndex = 2; break; case DocChangeActionEnum.MODIFIED: this.toolStripComboBoxChange.SelectedIndex = 3; break; case DocChangeActionEnum.MOVED: this.toolStripComboBoxChange.SelectedIndex = 4; break; } this.listViewChange.Items.Clear(); foreach(DocChangeAspect docAspect in docChange.Aspects) { ListViewItem lvi = new ListViewItem(); lvi.Text = docAspect.Aspect.ToString(); lvi.SubItems.Add(docAspect.OldValue); lvi.SubItems.Add(docAspect.NewValue); this.listViewChange.Items.Add(lvi); } } if (tabpageExist != null && this.tabControl.TabPages.Contains(tabpageExist)) { this.tabControl.SelectedTab = tabpageExist; } this.m_loadall = false; }
public string FormatDefinitions(DocProject docProject, Dictionary<string, DocObject> map, Dictionary<DocObject, bool> included) { StringBuilder sb = new StringBuilder(); foreach (DocSection docSection in docProject.Sections) { foreach (DocSchema docSchema in docSection.Schemas) { foreach (DocType docType in docSchema.Types) { bool use = false; included.TryGetValue(docType, out use); if (use) { if (docType is DocDefined) { DocDefined docDefined = (DocDefined)docType; string text = this.Indent(this.FormatDefined(docDefined), 1); sb.AppendLine(text); } else if (docType is DocSelect) { DocSelect docSelect = (DocSelect)docType; string text = this.Indent(this.FormatSelect(docSelect, null, null), 1); sb.AppendLine(text); } else if (docType is DocEnumeration) { DocEnumeration docEnumeration = (DocEnumeration)docType; string text = this.Indent(this.FormatEnumeration(docEnumeration), 1); sb.AppendLine(text); } sb.AppendLine(); } } foreach (DocEntity docEntity in docSchema.Entities) { bool use = false; included.TryGetValue(docEntity, out use); if (use) { string text = this.Indent(this.FormatEntity(docEntity, map, included), 1); sb.AppendLine(text); sb.AppendLine(); } } } } return sb.ToString(); }
/// <summary> /// Create an inheritance diagram for a particular entity, its entire hierarchy of supertypes, and one level of subtypes, within scope. /// </summary> /// <param name="docEntity"></param> /// <param name="font"></param> /// <param name="map"></param> /// <returns></returns> public static Image CreateInheritanceDiagramForEntity(DocProject docProject, Dictionary<DocObject, bool> included, DocEntity docEntity, Font font, Dictionary<Rectangle, DocEntity> map) { // determine items within scope Dictionary<DocObject, bool> hierarchy = new Dictionary<DocObject,bool>(); DocEntity docBase = docEntity; DocEntity docRoot = docBase; while (docBase != null) { docRoot = docBase; if (included == null || included.ContainsKey(docBase)) { hierarchy.Add(docBase, true); } docBase = docProject.GetDefinition(docBase.BaseDefinition) as DocEntity; } foreach (DocSection docSection in docProject.Sections) { foreach (DocSchema docSchema in docSection.Schemas) { foreach (DocEntity docEnt in docSchema.Entities) { if (docEnt.BaseDefinition == docEntity.Name) { if (included == null || included.ContainsKey(docEnt)) { hierarchy.Add(docEnt, true); } } } } } return CreateInheritanceDiagram(docProject, hierarchy, docRoot, docEntity, font, map); }
/// <summary> /// Creates a concept diagram for a particular entity, including all concepts at specified view and base view(s). /// </summary> /// <param name="docEntity"></param> /// <param name="docView"></param> /// <param name="map"></param> /// <param name="layout"></param> /// <param name="docProject"></param> /// <param name="instance"></param> /// <returns></returns> internal static Image CreateConceptDiagram(DocEntity docEntity, DocModelView docView, Dictionary<string, DocObject> map, Dictionary<Rectangle, DocModelRule> layout, DocProject docProject, SEntity instance) { DocSchema docSchema = docProject.GetSchemaOfDefinition(docEntity); layout.Clear(); List<int> lanes = new List<int>(); // keep track of position offsets in each lane for (int i = 0; i < 16; i++) { lanes.Add(0); } // determine boundaries DrawEntity(null, 0, lanes, docEntity, docView, null, null, map, layout, docProject, docSchema, instance); Rectangle rcBounds = Rectangle.Empty; foreach (Rectangle rc in layout.Keys) { if (rc.Right > rcBounds.Width) { rcBounds.Width = rc.Right; } if (rc.Bottom > rcBounds.Bottom) { rcBounds.Height = rc.Bottom; } } rcBounds.Width += FormatPNG.Border; rcBounds.Height += FormatPNG.Border; Image image = new Bitmap(rcBounds.Width, rcBounds.Height, System.Drawing.Imaging.PixelFormat.Format24bppRgb); using (Graphics g = Graphics.FromImage(image)) { g.FillRectangle(Brushes.White, new Rectangle(0, 0, image.Width, image.Height)); layout.Clear(); lanes = new List<int>(); // keep track of position offsets in each lane for (int i = 0; i < 16; i++) { lanes.Add(0); } DrawEntity(g, 0, lanes, docEntity, docView, null, null, map, layout, docProject, docSchema, instance); g.DrawRectangle(Pens.Black, 0, 0, rcBounds.Width - 1, rcBounds.Height - 1); } return image; }
/// <summary> /// Draws entity and subtypes recursively to image /// </summary> /// <param name="g">Graphics where to draw; if null, then just return rectangle</param> /// <param name="pt">Point where to draw</param> /// <param name="docEntity">Entity to draw</param> /// <returns>Bounding rectangle of what was drawn.</returns> private static Rectangle DrawHierarchy(Graphics g, Point pt, DocEntity docEntity, DocEntity docTarget, DocProject docProject, Dictionary<DocObject, bool> included, Font font, Dictionary<Rectangle, DocEntity> map) { if (docEntity == null) return Rectangle.Empty; Rectangle rc = new Rectangle(pt.X, pt.Y, CX, CY); Point ptSub = new Point(pt.X + CY, pt.Y + CY + CY); SortedList<string, DocEntity> subtypes = new SortedList<string, DocEntity>(); // sort to match Visual Express foreach(DocSection docSection in docProject.Sections) { foreach (DocSchema docSchema in docSection.Schemas) { foreach(DocEntity docEnt in docSchema.Entities) { if (included == null || included.ContainsKey(docEnt)) { if (docEnt.BaseDefinition != null && docEnt.BaseDefinition.Equals(docEntity.Name)) { subtypes.Add(docEnt.Name, docEnt); } } } } } foreach(string s in subtypes.Keys) { DocEntity docEnt = subtypes[s];//docProject.GetDefinition(docSub.DefinedType) as DocEntity; if(docEnt != null) { bool vert = (docEnt.Status != "H");//hack Rectangle rcSub = DrawHierarchy(g, ptSub, docEnt, docTarget, docProject, included, font, map); if (g != null) { g.DrawLine(Pens.Black, rcSub.X - CY, pt.Y + CY, rcSub.X - CY, rcSub.Y + CY / 2); g.DrawLine(Pens.Black, rcSub.X - CY, rcSub.Y + CY / 2, rcSub.X, rcSub.Y + CY / 2); } if (vert) { ptSub.Y += rcSub.Height + CY; } else { ptSub.Y = pt.Y + CY + CY; ptSub.X += rcSub.Width + CY + CY + CY + CY + CY; } if (rc.Height < (rcSub.Y + rcSub.Height) - rc.Y) { rc.Height = (rcSub.Y + rcSub.Height) - rc.Y; } if (rc.Width < (rcSub.X + rcSub.Width) - rc.X + CY) { rc.Width = (rcSub.X + rcSub.Width) - rc.X + CY; } } } if (g != null) { Brush brush = Brushes.Black; if(docEntity.IsAbstract()) { brush = Brushes.Gray; } if(docEntity == docTarget) { brush = Brushes.Blue; } g.FillRectangle(brush, pt.X, pt.Y, rc.Width - CY, CY); g.DrawString(docEntity.Name, font, Brushes.White, pt); g.DrawRectangle(Pens.Black, pt.X, pt.Y, rc.Width - CY, CY); } if(map != null && docEntity != docTarget) { Rectangle rcKey = new Rectangle(pt.X, pt.Y, rc.Width - CY, CY); if (!map.ContainsKey(rcKey)) { map.Add(rcKey, docEntity); } } return rc; }
public static void Export(DocProject project, DocModelView docView, string path, Dictionary<string, DocObject> mapEntity, Dictionary<string, string> mapSchema) { Dictionary<DocObject, bool> included = docView.Filter(project); const string HEADERCELL = "<th style=\"-webkit-transform:rotate(90deg); writing-mode:tb-rl; -moz-transform:rotate(90deg); -o-transform: rotate(90deg); white-space:nowrap; display:blocking; ms-filter: \"progid:DXImageTransform.Microsoft.BasicImage(rotation=0.083)\"; >"; // get list of entities in order List<DocEntity> sortEntity = project.GetEntityList(); // build list of templates in use (to preserve sort order) Dictionary<DocTemplateDefinition, List<DocConceptRoot>> mapTemplates = new Dictionary<DocTemplateDefinition, List<DocConceptRoot>>(); // double-loop not optimal, but lists aren't that large foreach (DocEntity docSortEnt in sortEntity) { foreach (DocConceptRoot docRoot in docView.ConceptRoots) { if (docRoot.ApplicableEntity == docSortEnt) { foreach (DocTemplateUsage docConcept in docRoot.Concepts) { if (!mapTemplates.ContainsKey(docConcept.Definition)) { mapTemplates.Add(docConcept.Definition, new List<DocConceptRoot>()); } mapTemplates[docConcept.Definition].Add(docRoot); } } } } // build list of concept roots sorted by entity order List<DocConceptRoot> sortConceptRoot = new List<DocConceptRoot>(); foreach (DocEntity docSortEntity in sortEntity) { foreach (DocConceptRoot docRoot in docView.ConceptRoots) { if (docRoot.ApplicableEntity == docSortEntity) { sortConceptRoot.Add(docRoot); break; } } } using (FormatEXP formatEXP = new FormatEXP(path + @"\" + docView.Code + ".exp")) { formatEXP.Instance = project; formatEXP.ModelViews = new DocModelView[] { docView }; formatEXP.Save(); } using (FormatXSD formatXSD = new FormatXSD(path + @"\" + docView.Code + ".xsd")) { formatXSD.Instance = project; formatXSD.ModelViews = new DocModelView[] { docView }; formatXSD.Save(); } using (FormatSPF format = new FormatSPF(path + @"\" + docView.Code + ".ifc", Schema.IFC.SchemaIfc.Types, new Dictionary<long, SEntity>())) { format.InitHeaders(docView.Code, "IFC4"); Schema.IFC.IfcProject ifcProject = new IfcDoc.Schema.IFC.IfcProject(); Program.ExportIfc(ifcProject, project, included); format.Save(); } using (FormatXML format = new FormatXML(path + @"\" + docView.Code + ".mvdxml", typeof(mvdXML), mvdXML.DefaultNamespace)) { mvdXML mvd = new mvdXML(); Program.ExportMvd(mvd, project, included); format.Instance = mvd; format.Save(); } using (FormatHTM format = new FormatHTM(path + @"\" + docView.Code + ".htm", mapEntity, new Dictionary<string, string>(), included)) { format.WriteHeader(docView.Name, 0, null); // 1 Scope // 1.1 Business Case Description // 1.2 Participants and Stakeholders // 2 Normative References // 3 Terms and definitions // 4 Symbols and abbreviated terms // 5 Business processes // 5.1 Process models provided // 5.2 Representative process models // 5.3 Process models formatting format.WriteLine("<h1>6 Exchange requirements</h1>"); format.WriteLine("<h2>6.1 Exchange requirements legibility</h2>"); format.WriteLine("<h3>6.1.1 Exchange requirements list</h3>"); format.WriteLine("<p>Each exchange is listed by name as follows.</p>"); Dictionary<string, string> mapExchangeClass = new Dictionary<string, string>(); format.WriteLine("<ul>"); foreach (DocExchangeDefinition docExchange in docView.Exchanges) { if (docExchange.ExchangeClass != null && !mapExchangeClass.ContainsKey(docExchange.ExchangeClass) && !String.IsNullOrEmpty(docExchange.ExchangeClass)) { mapExchangeClass.Add(docExchange.ExchangeClass, docExchange.ExchangeClass); } format.WriteLine("<li>" + docExchange.Name + "</li>"); } format.WriteLine("</ul>"); format.WriteLine("<h3>6.1.2 Exchange requirement classification list</h3>"); format.WriteLine("<p>Each phase classification used by this model view is listed by Omniclass notation and title as follows.</p>"); format.WriteLine("<ul>"); foreach (string key in mapExchangeClass.Keys) { format.WriteLine("<li>" + key + "</li>"); } format.WriteLine("</ul>"); format.WriteLine("<h3>6.1.3 Exchange requirement coverage analysis</h3>"); format.WriteLine("<p>Each exchange is listed by name and corresponding classifications for the process undertaken, the sender of the information, and the receiver of the information.</p>"); format.WriteLine("<table class=\"gridtable\">"); format.WriteLine("<tr><th>Exchange</th><th>Process</th><th>Sender</th><th>Receiver</th></tr>"); foreach (DocExchangeDefinition docExchange in docView.Exchanges) { format.WriteLine("<tr><td>" + docExchange.Name + "</td><td>" + docExchange.ExchangeClass + "</td><td>" + docExchange.SenderClass + "</td><td>" + docExchange.ReceiverClass); } format.WriteLine("</table>"); format.WriteLine("<h2>6.2 Exchange requirements detail</h2>"); format.WriteLine("<h3>6.2.1 Exchange requirements definition</h3>"); format.WriteLine("<p>Each exchange is listed by name and a description of the information contained.</p>"); foreach (DocExchangeDefinition docExchange in docView.Exchanges) { format.WriteLine("<h4>" + docExchange.Name + "</h4>"); format.WriteLine(docExchange.Documentation); } format.WriteLine("<h3>6.2.2 Business rule list</h3>"); format.WriteLine("<p>Each exchange consists of a set of entity data definitions with usage defined according to business rule concepts. " + "An entity describes an object class having one or more attributes, where each attribute may refer to values, collections, or references to other objects. "+ "A concept describes usage of object classes, where allowable values and object types are indicated for specific attributes." + "Each heading that follows refers to an exchange, where each table row corresponds to an entity, each table column corresponds to an exchange, and each cell indicates whether the concept is used for the entity within the exchange.</p>"); foreach (DocExchangeDefinition docExchange in docView.Exchanges) { format.WriteLine("<h4>" + docExchange.Name + "</h4>"); List<DocTemplateDefinition> listTemplate = project.GetTemplateList(); List<DocTemplateDefinition> usedTemplate = new List<DocTemplateDefinition>(); foreach (DocConceptRoot docRoot in docView.ConceptRoots) { foreach (DocTemplateUsage docConcept in docRoot.Concepts) { if (!usedTemplate.Contains(docConcept.Definition)) { foreach (DocExchangeItem docExchangeItem in docConcept.Exchanges) { if (docExchangeItem.Exchange == docExchange && (docExchangeItem.Requirement == DocExchangeRequirementEnum.Mandatory || docExchangeItem.Requirement == DocExchangeRequirementEnum.Optional)) { usedTemplate.Add(docConcept.Definition); break; } } } } } for(int i = listTemplate.Count - 1; i >= 0; i--) { if (!usedTemplate.Contains(listTemplate[i])) { listTemplate.RemoveAt(i); } } format.WriteLine("<table class=\"gridtable\">"); format.Write("<tr>"); format.Write("<th>Entity</th>"); for (int i = 0; i < listTemplate.Count; i++) { format.Write(HEADERCELL); format.Write(listTemplate[i].Name); format.Write("</th>"); } format.WriteLine("</tr>"); foreach (DocConceptRoot docRoot in sortConceptRoot) { DocExchangeRequirementEnum[] reqs = new DocExchangeRequirementEnum[listTemplate.Count]; bool include = false; foreach (DocTemplateUsage docConcept in docRoot.Concepts) { foreach (DocExchangeItem docExchangeItem in docConcept.Exchanges) { if (docExchangeItem.Exchange == docExchange && (docExchangeItem.Requirement == DocExchangeRequirementEnum.Mandatory || docExchangeItem.Requirement == DocExchangeRequirementEnum.Optional)) { int index = listTemplate.IndexOf(docConcept.Definition); reqs[index] = docExchangeItem.Requirement; include = true; break; } } } if (include) { format.Write("<tr>"); format.Write("<td>" + docRoot.ApplicableEntity.Name + "</td>"); for (int i = 0; i < reqs.Length; i++) { format.Write("<td>"); switch (reqs[i]) { case DocExchangeRequirementEnum.Mandatory: format.Write("R"); break; case DocExchangeRequirementEnum.Optional: format.Write("O"); break; } format.Write("</td>"); } format.WriteLine("</tr>"); } } format.WriteLine("</table>"); } format.WriteLine("<h3>6.2.3 Business rule definition</h3>"); format.WriteLine("<p>Business rule definitions are all defined as re-usable templates as indicated in Clause 7.3.5.</p>"); format.WriteLine("<h2>6.3 Exchange requirements reusability</h2>"); format.WriteLine("<p>Names and classifications of exchanges are intended to be consistent across other model views where applicable, "+ "while the content of a particular exchange is intended to be unique.</p>"); format.WriteLine("<h3>6.3.1 Related business process list</h3>"); format.WriteLine("<p>Business processes within this model view are correlated with those used in other model views as follows.</p>"); // Rows: Business processes; Columns: Views; Cells: mark if applicable format.WriteLine("<table class=\"gridtable\">"); format.Write("<tr><th>Process</th>"); foreach (DocModelView docEachView in project.ModelViews) { format.Write(HEADERCELL + docEachView.Name + "</th>"); } format.WriteLine("</tr>"); foreach (string proc in mapExchangeClass.Keys) { format.Write("<tr><td>" + proc + "</td>"); foreach (DocModelView docEachView in project.ModelViews) { bool yes = false; foreach (DocExchangeDefinition docEachExchange in docEachView.Exchanges) { if (!String.IsNullOrEmpty(docEachExchange.ExchangeClass) && docEachExchange.ExchangeClass.Equals(proc)) { yes = true; break; } } format.Write("<td>"); if (yes) { format.Write("X"); } format.Write("</td>"); } format.WriteLine("</tr>"); } format.WriteLine("</table>"); format.WriteLine("<h3>6.3.2 Related exchange requirement list</h3>"); format.WriteLine("<p>Exchange requirements within this model view are correlated with those used in other model views as follows.</p>"); // Rows: Exchanges; Columns: Views; Cells: Mark if applicable format.WriteLine("<table class=\"gridtable\">"); format.Write("<tr><th>Exchange</th>"); foreach (DocModelView docEachView in project.ModelViews) { format.Write(HEADERCELL + docEachView.Name + "</th>"); } format.WriteLine("</tr>"); foreach (DocExchangeDefinition docExchange in docView.Exchanges) { format.Write("<tr><td>" + docExchange.Name + "</td>"); foreach (DocModelView docEachView in project.ModelViews) { bool yes = false; foreach (DocExchangeDefinition docEachExchange in docEachView.Exchanges) { if (!String.IsNullOrEmpty(docEachExchange.Name) && docEachExchange.Name.Equals(docExchange.Name)) { yes = true; break; } } format.Write("<td>"); if (yes) { format.Write("X"); } format.Write("</td>"); } format.WriteLine("</tr>"); } format.WriteLine("</table>"); format.WriteLine("<h3>6.3.3 Related exchange requirement reuse analysis</h3>"); format.WriteLine("<p>Exchange requirements across other model views are correlated as follows.</p>"); // Rows: Exchange names; Columns: Views; Cells: Mark if applicable List<string> listExchangeNames = new List<string>(); foreach (DocModelView docEachView in project.ModelViews) { foreach (DocExchangeDefinition docEachExchange in docEachView.Exchanges) { if (!listExchangeNames.Contains(docEachExchange.Name)) { listExchangeNames.Add(docEachExchange.Name); } } } format.WriteLine("<table class=\"gridtable\">"); format.Write("<tr><th>Exchange</th>"); foreach (DocModelView docEachView in project.ModelViews) { format.Write(HEADERCELL + docEachView.Name + "</th>"); } format.WriteLine("</tr>"); foreach (string exchangename in listExchangeNames) { format.Write("<tr><td>" + exchangename + "</td>"); foreach (DocModelView docEachView in project.ModelViews) { bool yes = false; foreach (DocExchangeDefinition docEachExchange in docEachView.Exchanges) { if (!String.IsNullOrEmpty(docEachExchange.Name) && docEachExchange.Name.Equals(exchangename)) { yes = true; break; } } format.Write("<td>"); if (yes) { format.Write("X"); } format.Write("</td>"); } format.WriteLine("</tr>"); } format.WriteLine("</table>"); format.WriteLine("<h1>7 Model view definition</h1>"); format.WriteLine("<h2>7.1 Data Definition</h2>"); format.WriteLine("<h3>7.1.1 Data definitions list</h3>"); format.WriteLine("<p>Each entity data definition is listed by schema and entity name as follows.</p>"); format.WriteLine("<ul>"); string lastschema = null; foreach (DocConceptRoot docRoot in sortConceptRoot) { string schema = mapSchema[docRoot.ApplicableEntity.Name]; if (schema != lastschema) { // close out last if (docRoot != sortConceptRoot[0]) { format.WriteLine("</ul></li>"); } // open next format.WriteLine("<li>" + schema + "<ul>"); lastschema = schema; } format.WriteLine("<li>" + docRoot.ApplicableEntity.Name + "</li>"); } format.WriteLine("</ul></ul>"); format.WriteLine("<h3>7.1.2 Data definitions</h3>"); format.WriteLine("<p>Each entity data definition is described within subsections as follows, with electronic representations provided in EXPRESS and XSD formats.</p>"); FormatXSD formatXSD = new FormatXSD(null); foreach (DocConceptRoot docRoot in sortConceptRoot) { string xsd = formatXSD.FormatEntity(docRoot.ApplicableEntity, mapEntity, included); format.WriteLine("<h4>" + docRoot.ApplicableEntity.Name + "</h4>"); format.WriteLine(docRoot.ApplicableEntity.Documentation); format.WriteLine("<br/>"); format.WriteExpressEntitySpecification(docRoot.ApplicableEntity, true, false); format.WriteLine("<br/>"); format.WriteFormatted(xsd); } format.WriteLine("<h3>7.1.3 Data definition reference schema list</h3>"); format.WriteLine("<p>Each referenced schema is listed by standards body notation and official title.</p>"); format.WriteLine("<table class=\"gridtable\">"); format.WriteLine("<tr><th>Reference</th><th>Description</th></tr>"); format.WriteLine("<tr><td>ISO 16739:2013</td><td>Industry Foundation Classes (IFC) for data sharing in the construction and facilities management industries</td></tr>"); format.WriteLine("</table>"); // 7.2 Concept definitions format.WriteLine("<h2>7.2 Concept definitions</h2>"); format.WriteLine("<h3>7.2.1 Concept list</h3>"); format.WriteLine("<p>Each concept is listed by entity name and concept template within the following table. "+ "Each row corresponds to an entity, each column corresponds to a concept template, and each cell indicates usage of a concept template for an entity.</p>"); format.WriteLine("<table class=\"gridtable\">"); format.Write("<tr><th>Entity</th>"); foreach (DocTemplateDefinition docTemplate in mapTemplates.Keys) { format.Write(HEADERCELL + docTemplate.Name + "</th>"); } format.WriteLine("</tr>"); foreach (DocConceptRoot docRoot in sortConceptRoot) { if (docRoot.Concepts.Count > 0) { format.Write("<tr><td>" + docRoot.ApplicableEntity.Name + "</td>"); foreach (DocTemplateDefinition docTemplate in mapTemplates.Keys) { format.Write("<td>"); foreach (DocTemplateUsage docConcept in docRoot.Concepts) { if (docConcept.Definition == docTemplate) { format.Write("X"); } } format.Write("</td>"); } format.WriteLine("</tr>"); } } format.WriteLine("</table>"); string pathImages = path + "\\" + docView.Code; System.IO.Directory.CreateDirectory(pathImages); format.WriteLine("<h3>7.2.2 Concept definitions</h3>"); format.WriteLine("<p>Each entity is described within subsections, with diagrams indicating the graph of attributes and objects representing the combination of all concepts applied to instances of the entity. "+ "Each block in the diagram represents an entity, where the entity name is shown at the top of the block with background in black. "+ "Each attribute within the entity is shown in order, where black is used to indicate a direct attribute and grey is used to indicate an inverse attribute. "+ "Notation to the right of each attribute indicates aggregation, where S indicates a SET (unordered unique objects) and L indicates a LIST (ordered objects), "+ "the first number in brackets indicates the minimum count, and the second number in brackets indicates the maximum count or “?” for unlimited. "+ "Lines connecting blocks indicates attributes that point to objects of other data definitions.</p>"); foreach (DocConceptRoot docRoot in sortConceptRoot) { format.WriteLine("<h4>" + docRoot.ApplicableEntity.Name + "</h4>"); string img = ""; if (docView.Code != null) { int cx = 0; int cy = 0; try { using (System.Drawing.Image image = IfcDoc.Format.PNG.FormatPNG.CreateConceptDiagram(docRoot.ApplicableEntity, docView, mapEntity, new Dictionary<System.Drawing.Rectangle,DocModelRule>(), project, null)) { cx = image.Width; cy = image.Height; string filepath = path + "\\" + docView.Code.ToLower() + "\\" + docRoot.ApplicableEntity.Name.ToLower() + ".png"; image.Save(filepath, System.Drawing.Imaging.ImageFormat.Png); } } catch { } // shrink for access from MS Word cx = cx / 2; cy = cy / 2; img = "<br/><img src=\"" + docView.Code.ToLower() + "/" + docRoot.ApplicableEntity.Name.ToLower() + ".png\" width=\"" + cx + "\" height=\"" + cy + "\"/>"; } format.WriteLine(docRoot.Documentation); format.WriteLine(img); foreach (DocTemplateUsage docConcept in docRoot.Concepts) { if (!String.IsNullOrEmpty(docConcept.Documentation)) { format.WriteLine("<h5>" + docConcept.Definition.Name + "</h5>"); format.WriteLine(docConcept.Documentation); } } } format.WriteLine("</table>"); format.WriteLine("<h3>7.2.3 Concept attributes list</h3>"); format.WriteLine("<p>Concepts may be defined that use parameters to indicate applicable values. "+ "For example, plumbing objects may make use of ports to enable connectivity to other objects for distribution of water, "+ "and a specific entity such as a hot water heater may have specific ports such as “ColdWaterIn” and “HotWaterOut”. "+ "Defining attributes at concepts enables re-use of concepts where the data structures are the same, but applicable values may differ."+ "Each concept is shown in a subsection as follows, with rows correspoding to entities and rule instances, columns corresponding to template parameters, and cells corresponding to values applied to rules.</p>"); // then format each template foreach (DocTemplateDefinition docTemplate in mapTemplates.Keys) { string[] parameters = docTemplate.GetParameterNames(); if (parameters.Length > 0) { format.WriteLine("<h4>" + docTemplate.Name + "</h4>"); format.WriteLine("<table class=\"gridtable\">"); format.Write("<tr><th>Entity</th>"); foreach (string parm in parameters) { format.Write("<th>" + parm + "</th>"); } format.WriteLine("</tr>"); List<DocConceptRoot> listRoots = mapTemplates[docTemplate]; foreach (DocConceptRoot docRoot in listRoots) { foreach (DocTemplateUsage docConcept in docRoot.Concepts) { if (docConcept.Definition == docTemplate) { if (docConcept.Items.Count == 0) { format.WriteLine("<tr><td>" + docRoot.ApplicableEntity.Name + "</td></tr>"); } else { foreach (DocTemplateItem docItem in docConcept.Items) { if (docItem == docConcept.Items[0]) { format.Write("<tr><td rowspan=\"" + docConcept.Items.Count + "\">" + docRoot.ApplicableEntity.Name + "</td>"); } else { format.Write("<tr>"); } foreach (string parm in parameters) { string val = docItem.GetParameterValue(parm); format.Write("<td>" + val + "</td>"); } format.WriteLine("</tr>"); } } } } } format.WriteLine("</table>"); } } format.WriteLine("<h3>7.2.4 Concept relationship description</h3>"); format.WriteLine("<p>Concepts may inherit from other concepts such that more generic rules may be defined at a higher level and more specific rules at a lower level. "+ "For example, geometry may be defined for a distribution segment (e.g. ducts, pipes, cables) that indicate permitted use of an extruded area solid (IfcExtrudedAreaSolid) "+ "which defines a 2D cross section extruded along a 3D linear segment. "+ "Such rule may be further refined for ducts to indicate that the cross-sections are further restricted to shapes such as hollow rectangles (IfcRectangleHollowProfileDef) "+ "or hollow circles (IfcCircleHollowProfileDef)."+ "Concepts are shown in a hierarchy as follows where inner concepts inherit from outer concepts.</p>"); WriteTemplateList(format, project.Templates, included); format.WriteLine("<h3>7.2.5 Concept requirements applicability</h3>"); format.WriteLine("<p>Each entity is shown in subsections as follows, with rows corresponding to concepts, columns corresponding to exchanges, "+ "and cells indicating requirements where 'R' indicates required and 'O' indicates optional.</p>"); foreach (DocConceptRoot docRoot in sortConceptRoot) { if (docRoot.Concepts.Count > 0) { format.WriteLine("<h4>" + docRoot.ApplicableEntity.Name + "</h4>"); format.WriteLine("<table class=\"gridtable\">"); format.Write("<tr><th>Concept</th>"); for (int i = 0; i < docView.Exchanges.Count; i++) { format.Write(HEADERCELL); format.Write(docView.Exchanges[i].Name); format.Write("</th>"); } format.WriteLine("</tr>"); DocExchangeRequirementEnum[] reqs = new DocExchangeRequirementEnum[docView.Exchanges.Count]; foreach (DocTemplateUsage docConcept in docRoot.Concepts) { StringBuilder sbRequired = new StringBuilder(); StringBuilder sbOptional = new StringBuilder(); foreach (DocExchangeItem docExchangeItem in docConcept.Exchanges) { int index = docView.Exchanges.IndexOf(docExchangeItem.Exchange); reqs[index] = docExchangeItem.Requirement; } format.Write("<tr><td>" + docConcept.Definition.Name + "</td>"); for (int i = 0; i < docView.Exchanges.Count; i++) { format.Write("<td>"); switch (reqs[i]) { case DocExchangeRequirementEnum.Mandatory: format.Write("R"); break; case DocExchangeRequirementEnum.Optional: format.Write("O"); break; } format.Write("</td>"); } format.WriteLine("</tr>"); } format.WriteLine("</table>"); } } format.WriteLine("<h2>7.3 Concept reusability</h2>"); format.WriteLine("<h3>7.3.1 Concept list</h3>"); format.WriteLine("<p>Each concept used within this model view is listed as follows.</p>"); format.WriteLine("<ul>"); foreach (DocTemplateDefinition docTemplate in mapTemplates.Keys) { format.WriteLine("<li>" + docTemplate.Name + "</li>"); } format.WriteLine("</ul>"); format.WriteLine("<h3>7.3.2 Related existing concept list</h3>"); format.WriteLine("<p>In the following table, each row corresponds to a concept used within this model view, "+ "each column corresponds to another model view, and each cell indicates usage of the concept within the corresponding model view.</p>"); format.WriteLine("<table class=\"gridtable\">"); format.Write("<tr><th>Concept</th>"); foreach (DocModelView docEachView in project.ModelViews) { format.Write(HEADERCELL + docEachView.Name + "</th>"); } format.WriteLine("</tr>"); foreach (DocTemplateDefinition docTemplate in mapTemplates.Keys) { format.Write("<tr><td>" + docTemplate.Name + "</td>"); foreach (DocModelView docEachView in project.ModelViews) { bool yes = false; foreach (DocConceptRoot docEachRoot in docEachView.ConceptRoots) { foreach (DocTemplateUsage docEachUsage in docEachRoot.Concepts) { if (docEachUsage.Definition == docTemplate) { yes = true; break; } } } if (yes) { format.Write("<td>X</td>"); } else { format.Write("<td></td>"); } } format.WriteLine("</tr>"); } format.WriteLine("</table>"); format.WriteLine("<h3>7.3.4 Concept business rule list</h3>"); format.WriteLine("<p>Each concept template is defined in a subsection as follows, with rows corresponding to each business rule. "+ "The <i>Reference</i> column identifies the path to the entity and attribute. " + "The <i>Cardinality</i> column indicates whether the number of permitted instances is restricted differently than the underlying schema, using [N:M] notation where N indicates the minimum number of instances, M indicates the maximum number of instances, where '?' indicates unbounded. "+ "The <i>Parameter</i> column indicates the name of a substitutable parameter, if applicable, defined at each usage of the business rule.<p>"); foreach (DocTemplateDefinition docTemplate in mapTemplates.Keys) { format.WriteLine("<h4>" + docTemplate.Name + "</h4>"); format.WriteLine("<table class=\"gridtable\">"); format.WriteLine("<tr><th>Reference</th><th>Cardinality</th><th>Parameter</th></tr>"); if (docTemplate.Rules != null) { foreach (DocModelRule docRule in docTemplate.Rules) { WriteModelRule(format, docRule, "\\" + docTemplate.Type + "." + docRule.Name); } } format.WriteLine("</table>"); } format.WriteLine("<h3>7.3.5 Concept business rule description</h3>"); format.WriteLine("<p>Each concept template is described in a subsection as follows, with diagrams indicating usage of attributes and entities reflecting defined business rules.</p>"); foreach (DocTemplateDefinition docTemplate in mapTemplates.Keys) { format.WriteLine("<h4>" + docTemplate.Name + "</h4>"); format.WriteLine(docTemplate.Documentation); string img = ""; if (docTemplate.Rules != null && docTemplate.Rules.Count > 0) { img = GenerateTemplateImage(docTemplate, mapEntity, project, path); format.WriteLine(img); } } format.WriteLine("<h2>7.4 Implementation</h2>"); format.WriteLine("<h3>7.4.1 MVD Schema Listing</h3>"); format.WriteLine("The schema encapsulating the data definitions for this model view is published in multiple representations. " + "<p>An MVDXML file defines the referenced entities and rules for this model view. This file may be used to validate instance data (in IFC-SPF or IFC-XML files), filter instance data to include entities and attributes within scope of this model view, or generate sub-schemas (including the EXP and XSD representations). " + "<p>An EXP file represents the schema in EXPRESS format (ISO 10303-11) which adapts the referenced Industry Foundation Classes schema (ISO 16739) by including a subset of data definitions and a subset of attributes within each data definition. The EXP file may be used by software development tools for generating programming languages schemas (e.g. C++, C#, Java), database definitions (e.g. SQL DDL), and data transport schema definitions (e.g. XSD). " + "<p>An XSD file represents the schema in XML Data Definition Language (XSD) which adapts the referenced subset of data definitions. The XSD file may be used by software development tools (e.g. Eclipse, Microsoft Visual Studio) to validate XML files and generate language-specific classes. " + "<p>An IFC file represents the dynamic portions of the schema in the form of property sets within an SPF (ISO 10303-21) instance file.</p>" + "<p>The rationale for publishing multiple representations is to provide the richest level of integration for different implementations; "+ "while XSD is often used in defining web standards replacing document-based exchanges (e.g. invoices), it lacks data model information needed for type safety, data integrity, indexing, and optimization; "+ "all of which may be derived from the EXPRESS representation. "+ "</p>"); format.WriteLine("<table class=\"gridtable\">"); format.WriteLine("<tr><th>File</th><th>Format</th></tr>"); format.WriteLine("<tr><td>" + docView.Code + ".exp</td><td>EXPRESS schema definition</td></tr>"); format.WriteLine("<tr><td>" + docView.Code + ".xsd</td><td>XML schema definition (XSD)</td></tr>"); format.WriteLine("<tr><td>" + docView.Code + ".mvdxml</td><td>MVDXML schema transform</td></tr>"); format.WriteLine("<tr><td>" + docView.Code + ".ifc</td><td>IFC dynamic schema definition</td></tr>"); format.WriteLine("</table>"); format.WriteLine("<h3>7.4.2 MVD Format Description</h3>"); format.WriteLine("<p>Implementations of this model view may publish instance data in various formats. "+ "Such format indicates the data encoding and does not necessarily imply that data may only be exchanged using physical files on computers; "+ "formats may be transmitted over the Internet as the “presentation layer” (OSI Layer 6) of any API. "+ "As the IFC data model supports both full and partial data models where all objects can be tagged to indicate merge directives (Create/Update/Delete using IfcOwnerHistory.ChangeAction), "+ "data may be transmitted in whole or in part, such as indicating only data changes.</p>"); format.WriteLine("<p>As other OSI layers are already standardized, a full web API may be defined by referencing each layer as follows:</p>"); format.WriteLine("<table class=\"gridtable\">"); format.WriteLine("<tr><th>OSI Layer</th><th>OSI Layer Name</th><th>Protocol</th><th>Description</th></tr>"); format.WriteLine("<tr><td>7</td><td>Application</td><td>WebDav</td><td>Defines valid operations such as GET, PUT, POST, DELETE, MKCOL, LOCK, UNLOCK</td></tr>"); format.WriteLine("<tr><td>6</td><td>Presentation</td><td>IFC-SPF/IFC-XML</td><td>Defines data encoding</td></tr>"); format.WriteLine("<tr><td>5</td><td>Session</td><td>HTTP/HTTPS</td><td>Defines establishment of sessions, compression, authentication, requests, responses, and errors</td></tr>"); format.WriteLine("<tr><td>4</td><td>Transport</td><td>TCP</td><td>Defines message delivery</td></tr>"); format.WriteLine("<tr><td>3</td><td>Network</td><td>IP</td><td>Defines network paths across multiple nodes</td></tr>"); format.WriteLine("<tr><td>2</td><td>Data Link</td><td>MAC</td><td>Defines data frame communications between two nodes</td></tr>"); format.WriteLine("<tr><td>1</td><td>Physical</td><td>(undefined)</td><td>Defines physical connectivity</td></tr>"); format.WriteLine("</table>"); format.WriteLine("<p>Each supported format is listed by name, with Extension indicating the default file extension to use on applicable platforms (e.g. Windows), MIME type for indicating the HTTP header when transmitting over the Internet, and Reference standard indicating the presentation layer encoding format.</p>"); format.WriteLine("<table class=\"gridtable\">"); format.WriteLine("<tr><th>Format</th><th>Extension</th><th>MIME</th><th>Reference</th></tr>"); format.WriteLine("<tr><td>IFC-SPF</td><td>.ifc</td><td>application/step</td><td>ISO 10303-21</td></tr>"); format.WriteLine("<tr><td>IFC-XML</td><td>.ifcxml</td><td>application/xml</td><td>ISO 10303-28</td></tr>"); format.WriteLine("</table>"); format.WriteLine("<p>IFC-SPF (ISO 10303-21) is a text format optimized to carry data with complex relationships, supporting human readability yet more compact representation (typically around 10% of size of equivalent XML).</p>"); format.WriteLine("<p>IFC-HDF (ISO 10303-26) is a binary file format encapsulating data in a compact, indexable encoding optimized for quick retrieval and minimal memory usage. "); format.WriteLine("<blockquote class=\"note\">NOTE As this file type is not yet widely implemented, it is not officially part of this model view, however implementations may prefer such format for internal use.</blockquote>"); format.WriteLine("<p>IFC-XML (ISO 10303-28) is a hierarchical markup format with wide support from software development tools and platforms, supporting greater human readability at the expense of larger representation. </p>"); format.WriteLine("<blockquote class=\"note\">NOTE As typical buildings contain millions of elements with graphs of relationships resulting in gigabytes of data, " + "XML is not yet suitable for representing complete buildings from a pragmatic standpoint of data size, transmission cost, and loading time. " + "However, using derived formats along with MVDXML to filter data sets may enable more efficient exchanges to take place.</blockquote>"); format.WriteLine("<p>IFC-ZIP (ISO 21320-1) is a compressed file format encapsulating one of the above formats to minimize data size. "); format.WriteLine("<blockquote class=\"note\">NOTE As this model view is primarily intended for web-based exchange, zip compression may be selected by other means according to the client and server; therefore, the IFC-ZIP format is not officially part of this model view.</blockquote>"); format.WriteLine("<h3>7.4.3 MVD Dynamic Schema Analysis</h3>"); format.WriteLine("<p>Portions of data definitions are defined dynamically, to allow software applications to support extensible definitions while minimizing implementation overhead. "+ "Each property set is shown within a subsection as follows, with rows corresponding to properties. See <i>IfcPropertySet</i> for usage information.</p>"); foreach (DocSection docSection in project.Sections) { foreach (DocSchema docSchema in docSection.Schemas) { foreach (DocPropertySet docPset in docSchema.PropertySets) { if (included == null || included.ContainsKey(docPset)) { format.WriteLine("<h4>" + docPset.Name + "</h4>"); format.WriteLine("<table class=\"gridtable\">"); format.WriteLine("<tr><th>Property</th><th>Property Type</th><th>Data Type</th><th>Description</th></tr>"); foreach (DocProperty docProp in docPset.Properties) { string datatype = docProp.PrimaryDataType; if (!String.IsNullOrEmpty(docProp.SecondaryDataType)) { datatype += "/" + docProp.SecondaryDataType; } format.WriteLine("<tr><td>" + docProp.Name + "</td><td>" + docProp.PropertyType + "</td><td>" + datatype + "</td><td>" + docProp.Documentation + "</td></tr>"); } format.WriteLine("</table>"); } } } } format.WriteLine("<h3>7.4.4 Non-Applicable Entity Exclusion Analysis</h3>"); format.WriteLine("<p>The referenced IFC schema is shown in the following table, with each row corresponding to a schema namespace, with data definitions listed within, where bold items indicate definitions within scope of this Model View Definition.</p>"); format.WriteLine("<table class=\"gridtable\">"); format.WriteLine("<tr><th>Namespace</th><th>Definitions</th><th>Usage</th></tr>"); foreach (DocSection docSection in project.Sections) { if (docSection.Schemas.Count > 0) { foreach (DocSchema docSchema in docSection.Schemas) { format.Write("<tr><td>" + docSchema.Name + "</td><td>"); int min = 0; int max = 0; foreach (DocEntity docEntity in docSchema.Entities) { max++; if (included == null || included.ContainsKey(docEntity)) { min++; format.Write("<b>"); } format.Write(docEntity.Name); format.Write("; "); if (included == null || included.ContainsKey(docEntity)) { format.Write("</b>"); } } foreach (DocType docType in docSchema.Types) { max++; if (included == null || included.ContainsKey(docType)) { min++; format.Write("<b>"); } format.Write(docType.Name); format.Write("; "); if (included == null || included.ContainsKey(docType)) { format.Write("</b>"); } } format.Write("</td>"); format.Write("<td>" + min + "/" + max + " (" + (100.0 *(double)min/(double)max).ToString("N0") + "%)</td>"); format.WriteLine("</tr>"); } } } format.WriteLine("</table>"); // 8 Conformance testing procedures // 9 Implementation resources // 10 Revision Plans format.WriteFooter(""); } }