private void UpdateUiFormArgs() { if (tmpargs.AzField != null) { presentationBox1.Text = tmpargs.AzField.Description.Name; IImageInfoFactory imgSvc = CoreSystem.GetService <IImageInfoFactory>(tmpargs.AzField); presentationBox1.Image = imgSvc.GetImageInfo(tmpargs.AzField).TypeImage; } else { presentationBox1.Text = ""; presentationBox1.Image = null; } if (tmpargs.HeiField != null) { presentationBox2.Text = tmpargs.HeiField.Description.Name; IImageInfoFactory imgSvc = CoreSystem.GetService <IImageInfoFactory>(tmpargs.HeiField); presentationBox2.Image = imgSvc.GetImageInfo(tmpargs.HeiField).TypeImage; } else { presentationBox2.Text = ""; presentationBox2.Image = null; } btnOK.Enabled = !(tmpargs.AzField == null || tmpargs.HeiField == null); }
public override void Execute(Slb.Ocean.Petrel.Contexts.Context context) { //TODO: Add command execution logic here /* * Template twtTemplate = PetrelProject.WellKnownTemplates.GeometricalGroup.TimeTwoWay; * * ITemplateSettingsInfoFactory factory = CoreSystem.GetService<ITemplateSettingsInfoFactory>(twtTemplate); * TemplateSettingsInfo info = factory.GetTemplateSettingsInfo(twtTemplate); * //arguments.Label = info.LegendLabel; * //arguments.DisplayUnit = info.Unit.Symbol; * //arguments.Precision = info.NumericPrecision.PrecisionValue; * * // create custom template with more detailed info * TemplateCollection parent = twtTemplate.TemplateCollection; * ITemplateService ts = PetrelSystem.TemplateService; * string newName = ts.GetUniqueName("My New Detailed Time"); * Template newTWT = Template.NullObject; * * using (ITransaction txn = DataManager.NewTransaction()) * { * txn.Lock(parent); * newTWT = parent.CreateTemplate(newName, info.DefaultColorTable, twtTemplate.UnitMeasurement); * newTWT.Comments = "New two way time with more digits"; * newTWT.TemplateType = twtTemplate.TemplateType.; * txn.Commit(); * } * factory = CoreSystem.GetService<ITemplateSettingsInfoFactory>(newTWT); * TemplateSettingsInfo info2 = factory.GetTemplateSettingsInfo(newTWT); * info2.NumericPrecision = new NumericPrecision(6, WellKnownPrecisionTypes.DecimalPlaces); */ PetrelLogger.InfoOutputWindow(string.Format("{0} clicked", @"GetTemplateIcon")); foreach (object obj in context.GetSelectedObjects()) { Template g = obj as Template; string gname = "D:\\test\\" + obj.GetHashCode() + ".bmp"; ITemplateService imageFact; imageFact = CoreSystem.GetService <ITemplateService>(); Bitmap imageInfo = imageFact.GetTemplateTypeImage(g.TemplateType); using (MemoryStream mem = new MemoryStream()) { //这句很重要,不然不能正确保存图片或出错(关键就这一句) Bitmap bmp = new Bitmap(imageInfo); //保存到磁盘文件 bmp.Save(gname, imageInfo.RawFormat); bmp.Dispose(); MessageBox.Show("附件另存成功!", "注意", MessageBoxButtons.OK, MessageBoxIcon.Information); MessageBox.Show("附件另存成功a"); } } }
private static void UpdateWellPresenterFromWell(PresentationBox presenter, Borehole borehole) { var nameInfoFactory = CoreSystem.GetService <INameInfoFactory>(borehole); var imageInfoFactory = CoreSystem.GetService <IImageInfoFactory>(borehole); // var nameInfo = nameInfoFactory?.GetNameInfo(borehole); var imageInfo = imageInfoFactory?.GetImageInfo(borehole); // presenter.Text = nameInfo?.Name; presenter.Image = imageInfo?.GetDisplayImage(new ImageInfoContext()); presenter.Tag = borehole; }
private void seismicCubeToolStripMenuItem_Click(object sender, EventArgs e) { /* * Send object code is o * Object Type for Seismic Cube is 0 */ /*tryclass o1 = new tryclass(1, 'a'); * tryclass o2 = new tryclass(2, 'b'); * tryclass o3 = new tryclass(3, 'c'); * List<string> ObjList = new List<string>(); * List<tryclass> obj = new List<tryclass>(); * ObjList.Add("1"); * ObjList.Add("2"); * ObjList.Add("3"); * obj.Add(o1); * obj.Add(o2); * obj.Add(o3);*/ List <SeismicCube> col = Discuss.getAllSeismicCubes(); List <string> colNames = new List <string>(); foreach (SeismicCube cube in col) { colNames.Add(cube.Name); } objSelect selector = new objSelect("Select an object", colNames); if (selector.ShowDialog() == DialogResult.OK && objSelect.SelectedIndex >= 0) { try { String name = colNames[objSelect.SelectedIndex]; ClientForm.sendObject = col[objSelect.SelectedIndex]; string fileName = Path.GetTempFileName().Split('.')[0] + ".segy"; ISegyFormat segyFormat; segyFormat = CoreSystem.GetService <ISegyFormat>(); segyFormat.ExportSeismic3D(fileName, col[objSelect.SelectedIndex]); FileInfo f = new FileInfo(fileName); swSender.WriteLine(add + "\"4\"" + myIp + "\"1987\"" + fileName + "\"" + f.Length + "\"1"); //swSender.WriteLine(add + "\"o\"0\"" + myIp + "\"1987\"" + name); // address"o"1"myIp"1987"objname swSender.Flush(); this.UpdateLog("Request has been sent for Seismic Cube transfer"); messageBox.Lines = null; } catch { MessageBox.Show("Error Sending Seismic cube!", "File Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public void convertToSeismic(string fileName) { // Check if parent collection contains any 2D data SeismicCollection coll = (SeismicCollection)FTReciever.parent; while (coll.MemberType == typeof(SeismicLine2DCollection)) { MessageBox.Show("The Seismic Collection you selected was of SeismicLine2DCollection"); List <SeismicCollection> cols = Discuss.getAllSeismicCollections(); List <string> names = new List <string>(); foreach (SeismicCollection col in cols) { names.Add(col.Name); } objSelect selector = new objSelect("Select a Seismic collection to add the cube to", names); if (selector.ShowDialog() == DialogResult.Cancel) { return; } coll = cols[objSelect.SelectedIndex]; } // Get Service ISegyFormat segyFormat = CoreSystem.GetService <ISegyFormat>(); // Find property version IPropertyVersionService pvService = PetrelSystem.PropertyVersionService; ITemplate seisTemplate = PetrelUnitSystem.TemplateGroupSeismicColor.SeismicDefault; PropertyVersion pv = pvService.FindOrCreate(PetrelSystem.GetGlobalPropertyVersionContainer(), seisTemplate); SeismicCube cube = SeismicCube.NullObject; // Lock the parent using (ITransaction txn = DataManager.NewTransaction()) { try { txn.Lock(coll); cube = segyFormat.ImportSeismic3D(fileName, (SeismicCollection)FTReciever.parent, "", Domain.ELEVATION_DEPTH, pv); } catch (InvalidOperationException e) { MessageBox.Show(e.Message); } finally { txn.Commit(); } } }
public override void ExecuteSimple() { CoreLogger.Debug("Hello World from CoreLogger!"); PetrelLogger.InfoOutputWindow("Hello World from PetrelLogger!"); // // var unitServiceSettings = CoreSystem.GetService <IUnitServiceSettings>(); // even if we do not already set a coordinate reference system, this method call will pop up the window so we could select one var coordinateReferenceSystemName = PetrelProject.PrimaryProject.GetCoordinateReferenceSystem().Name; var coordinateReferenceSystemDescription = PetrelProject.PrimaryProject.GetCoordinateReferenceSystem().Description; // PetrelLogger.InfoOutputWindow(unitServiceSettings.CurrentUISystem.Name); PetrelLogger.InfoOutputWindow(coordinateReferenceSystemName); PetrelLogger.InfoOutputWindow(coordinateReferenceSystemDescription); }
private void UpdateUIFormArgs() { boxWellLog.Text = ""; boxWellLog.Image = null; boxGrid.Text = ""; boxGrid.Image = null; btnApply.Enabled = false; btnOK.Enabled = false; btnShow.Enabled = false; ka = false; k = false; boxProp.Text = ""; boxProp.Image = null; lblNumCells.Text = ""; if (tmpargs.NovozhentsevWellLog != null) { INameInfoFactory nameSvc = CoreSystem.GetService <INameInfoFactory>(tmpargs.NovozhentsevWellLog); boxWellLog.Text = string.Format("{0} ({1})", nameSvc.GetNameInfo(tmpargs.NovozhentsevWellLog).Name, tmpargs.NovozhentsevWellLog.Borehole.Description.Name); IImageInfoFactory imgSvc = CoreSystem.GetService <IImageInfoFactory>(tmpargs.NovozhentsevWellLog.Borehole); boxWellLog.Image = imgSvc.GetImageInfo(tmpargs.NovozhentsevWellLog).TypeImage; } if (tmpargs.NovozhentsevGrid != null) { INameInfoFactory nameSvc = CoreSystem.GetService <INameInfoFactory>(tmpargs.NovozhentsevGrid); boxGrid.Text = string.Format("{0} - {1}", nameSvc.GetNameInfo(tmpargs.NovozhentsevGrid).Name, Math.Round(tmpargs.NovozhentsevGrid.BoundingBox.Width * tmpargs.NovozhentsevGrid.BoundingBox.Length)); IImageInfoFactory imgSvc = CoreSystem.GetService <IImageInfoFactory>(tmpargs.NovozhentsevGrid); boxGrid.Image = imgSvc.GetImageInfo(tmpargs.NovozhentsevGrid).TypeImage; } if (tmpargs.NovozhentsevWellLog != null && tmpargs.NovozhentsevGrid != null) { btnApply.Enabled = true; btnOK.Enabled = true; } if (tmpargs.NovozhentsevResultProperty != null) { btnShow.Enabled = true; boxProp.Text = tmpargs.NovozhentsevResultProperty.Description.Name; IImageInfoFactory imgSvc = CoreSystem.GetService <IImageInfoFactory>(tmpargs.NovozhentsevResultProperty); boxProp.Image = imgSvc.GetImageInfo(tmpargs.NovozhentsevResultProperty).TypeImage; } if (tmpargs.NovozhentsevNumCells != 0) { lblNumCells.Text = tmpargs.NovozhentsevNumCells.ToString(); lblNumCells.TextAlign = ContentAlignment.MiddleCenter; } }
private void ClickCallBackSearch(object sender, EventArgs e) { //PetrelLogger.InfoBox("Inside ClickCallBackSearch"); var dockManager = CoreSystem.GetService <IDockManager>(); if (dockManager != null) { if (usercontrol != null) { var isPanelVisible = dockManager.IsContentVisible(usercontrol.Key); dockManager.SetContentVisible(usercontrol.Key, !isPanelVisible); } else { usercontrol = new UserControl1(); ContentDescription cdpdescrption = new ContentDescription(usercontrol.Key, usercontrol.Title); ControlFactoryMethod filterControlFactory = delegate { var view = usercontrol; // Avoid exception on application exit. Sergey is going to fix it: if (view.Parent != null) { return(new System.Windows.Forms.UserControl()); } return(new ElementHost() { Child = view, Text = usercontrol.Title }); }; dockManager.InstallContent(filterControlFactory, cdpdescrption, DockedLocation.Floating, new System.Drawing.Size(300, 300)); var isPanelVisible = dockManager.IsContentVisible(usercontrol.Key); dockManager.SetContentVisible(usercontrol.Key, !isPanelVisible); } } }
public override void ExecuteSimple() { // extract data from arguments var templateName = arguments.Name; var templatePrecision = arguments.Precision; var templateDisplayUnit = arguments.DisplayUnit; var templateLabel = arguments.Label; // // find an appropriate measurment var timeMeasurement = PetrelUnitSystem.GetUnitMeasurement("Time"); // // find an appropriate template collection var timeTwoWayTemplate = PetrelProject.WellKnownTemplates.GeometricalGroup.TimeTwoWay; var geometricalTemplateCollection = timeTwoWayTemplate.TemplateCollection; // // find an appropriate color table var colorTableRoot = ColorTableRoot.Get(PetrelProject.PrimaryProject); var generalContinuousColorTable = colorTableRoot.WellKnownColorTables.Other.GeneralContinuous; // // find appropriate unit var unitServiceSettingsService = CoreSystem.GetService <IUnitServiceSettings>(); var templateUnit = unitServiceSettingsService?.CurrentCatalog.GetUnit(templateDisplayUnit); // using (var transaction = DataManager.NewTransaction()) { transaction.Lock(geometricalTemplateCollection); // var uniqueTemplateName = PetrelSystem.TemplateService.GetUniqueName(templateName); var canCreateTemplate = geometricalTemplateCollection.CanCreateTemplate(timeTwoWayTemplate); if (canCreateTemplate) { var newTemplate = geometricalTemplateCollection.CreateTemplate(uniqueTemplateName, generalContinuousColorTable, timeMeasurement, templateUnit); if (newTemplate != null) { PetrelLogger.InfoOutputWindow("Create a new template with name " + uniqueTemplateName); } } // transaction.Commit(); } }
public override void Modify(Resource resource, Context context) { // find the current item Borehole borehole = context.GetParameter <Borehole>(CommandParameterIds.Option); // if (borehole == Borehole.NullObject) { return; } // // set attributes PetrelSystem.ResourceManager.SetAttributeValue(resource, WellKnownResourceAttributes.OptionText, borehole.Name); // var imageInfoFactory = CoreSystem.GetService <IImageInfoFactory>(borehole); var boreholeImage = ImageData.FromImage(imageInfoFactory.GetImageInfo(borehole).GetDisplayImage(new ImageInfoContext())); PetrelSystem.ResourceManager.SetAttributeValue(resource, WellKnownResourceAttributes.OptionImage16, boreholeImage); PetrelSystem.ResourceManager.SetAttributeValue(resource, WellKnownResourceAttributes.OptionImage32, boreholeImage); }
public override void ExecuteSimple() { PetrelLogger.InfoOutputWindow($"Executing {typeof(ParentInfoFinderWorkstep).Name}"); // object petrelObject = arguments.PetrelTreeObject; var parentSourceFactory = CoreSystem.GetService <IParentSourceFactory>(petrelObject); // if (parentSourceFactory != null) { var parentSource = parentSourceFactory.GetParentSource(petrelObject); var parentObject = parentSource.Parent; // var nameInfoFactory = CoreSystem.GetService <INameInfoFactory>(parentObject); // if (nameInfoFactory != null) { var parentNameInfo = nameInfoFactory.GetNameInfo(parentObject); PetrelLogger.InfoOutputWindow($"Parent Info are: Name = {parentNameInfo.Name}; DisplayName = {parentNameInfo.DisplayName}; TypeName = {parentNameInfo.TypeName}"); } } }
public override void ExecuteSimple() { /* PetrelLogger.InfoOutputWindow(string.Format("Well Log: {0},Grid: {1}", * arguments.NovozhentsevWellLog.Name, * arguments.NovozhentsevGrid.Name)); * PetrelLogger.InfoOutputWindow("Runtime contex: "+ context.GetType().FullName * );*/ Property prop = null; int count = 0; // все действия по изменению данных строго внутри транзакции using (ITransaction trans = DataManager.NewTransaction())//объект удалением которого будет с# { // запрашиваем исключительный доступ к свойствам сетки trans.Lock(arguments.NovozhentsevGrid.PropertyCollection);//подождать пока // создаем новое свойство и задаем его имя prop = arguments.NovozhentsevGrid.PropertyCollection.CreateProperty(arguments.NovozhentsevWellLog.WellLogVersion.Template); prop.Name = string.Format("{0} ({1}) upscaled", arguments.NovozhentsevWellLog.Name, arguments.NovozhentsevWellLog.Borehole.Description.Name); arguments.NovozhentsevResultProperty = prop; // получаем перечислитель замеров каротажки в явном виде IEnumerator <WellLogSample> enumSamples = arguments.NovozhentsevWellLog.Samples.GetEnumerator(); //<> generic type тип элемента коллекции нумератор которой имеет этот тип,итератор // получаем доступ к штатному сервису Petrel: IPillarGridIntersectionService pgIntersection = CoreSystem.GetService <IPillarGridIntersectionService>(); //статический метод пиллар- пилоны -вид сетки // получаем траекторию скважины в виде линии и запрашиваем список пересечений этой линии с ячейками сетки IPolyline3 polyline = arguments.NovozhentsevWellLog.Borehole.Trajectory.Polyline; // IEnumerable <SegmentCellIntersection> intersectionsegments = pgIntersection.GetPillarGridPolylineIntersections(arguments.NovozhentsevGrid, polyline); //набор пересечений полилайна с сеткой грида/коллекция // проходим в цикле по найденным точкам пересечения SegmentCellIntersection enteringSegment = new SegmentCellIntersection(); SegmentCellIntersection leavingSegment; double enteringMD = double.NaN;//measure depth, true vertical depth double leavingMD = double.NaN; bool FirstTime = true; foreach (SegmentCellIntersection segment in intersectionsegments) { // на первой итерации нужно только инициализировать внутренние переменные if (FirstTime) { FirstTime = false; enteringSegment = segment; enteringMD = arguments.NovozhentsevWellLog.Borehole.Transform(arguments.NovozhentsevGrid.Domain, segment.IntersectionPoint.Z, Domain.MD);//домен - система координат, отсчета // проматываем цикл по замерам, пока не дойдем до нужной глубины while (enumSamples.MoveNext()) { if (enumSamples.Current.MD >= enteringMD) { break; } } continue; } leavingSegment = segment; // находим измеренные глубины точек пересечения вдоль ствола скважины enteringMD = arguments.NovozhentsevWellLog.Borehole.Transform(arguments.NovozhentsevGrid.Domain, enteringSegment.IntersectionPoint.Z, Domain.MD); leavingMD = arguments.NovozhentsevWellLog.Borehole.Transform(arguments.NovozhentsevGrid.Domain, leavingSegment.IntersectionPoint.Z, Domain.MD); // находим индекс ячейки Index3 cellIndex = enteringSegment.EnteringCell; float avg = float.NaN; // если текущее значение глубины замера внутри текущей ячейки if (enumSamples.Current.MD <= leavingMD) { int numSamples = 1; float total = enumSamples.Current.Value; // вручную проматываем замеры каротажной кривой в этой ячейке while (enumSamples.MoveNext()) { if (enumSamples.Current.MD <= leavingMD) { numSamples++; total += enumSamples.Current.Value; } else { break; } } // теперь вычисляем усредненное значение свойства avg = (float)(total / numSamples); PetrelLogger.InfoOutputWindow(string.Format("сell= {0}, value={1} ({2})", cellIndex.ToString(), avg, prop.Description.Name)); prop[cellIndex] = avg; count++; enteringSegment = leavingSegment; } // и записываем его в новое свойство сетки } // если проблем нет, следующая строчка создаст наше свойство arguments.NovozhentsevNumCells = count; trans.Commit(); } // TODO: Implement the workstep logic here. }
protected override T Serialize(IStructuredArchive ar, T value) { ar.SerializeReference("Droid", () => value.Droid, (droid) => CoreSystem.GetService <IDomainObjectHost>().Admin.ToIdentifiableFacade <T>(droid)); return(value); }
public override void ExecuteSimple() { // extract domain object var domainObject = arguments.DomainObject; // if (domainObject == null) { return; } // /// Get the Info Factory services from the Core System INameInfoFactory nameInfoFactory = CoreSystem.GetService <INameInfoFactory>(domainObject); IColorInfoFactory colorInfoFactory = CoreSystem.GetService <IColorInfoFactory>(domainObject); ICommentInfoFactory commentInfoFactory = CoreSystem.GetService <ICommentInfoFactory>(domainObject); if (nameInfoFactory != null && colorInfoFactory != null && commentInfoFactory != null) { NameInfo nameInfo = nameInfoFactory.GetNameInfo(domainObject); ColorInfo colorInfo = colorInfoFactory.GetColorInfo(domainObject); CommentInfo commentInfo = commentInfoFactory.GetCommentInfo(domainObject); if (nameInfo != null && colorInfo != null && commentInfo != null) { /// Print the Borehole Domain objects settings data. PetrelLogger.InfoOutputWindow(Environment.NewLine); PetrelLogger.InfoOutputWindow("Settings Info Data Access for : " + domainObject.GetType().Name); PetrelLogger.InfoOutputWindow("---------------------------------------------------------------------------"); PetrelLogger.InfoOutputWindow(" Name : " + nameInfo.Name); PetrelLogger.InfoOutputWindow(" Color : " + colorInfo.Color.ToString()); PetrelLogger.InfoOutputWindow(" TypeName : " + nameInfo.TypeName); PetrelLogger.InfoOutputWindow(" Comments : " + commentInfo.Comment); PetrelLogger.InfoOutputWindow(" Can change the Name : " + nameInfo.CanChangeName.ToString()); } } IHistoryInfoEditor borholeHistoryEditor = HistoryService.GetHistoryInfoEditor(domainObject); if (borholeHistoryEditor != null) { PetrelLogger.InfoOutputWindow(Environment.NewLine); PetrelLogger.InfoOutputWindow("History Data Access for : " + domainObject.GetType().Name); PetrelLogger.InfoOutputWindow("---------------------------------------------------------------------------"); /// add an History Entry HistoryEntry testHistoryEntry = new HistoryEntry(DateTime.Now, DateTime.Now, Environment.UserName, "Test", "Test Arguments", "Test Version"); borholeHistoryEditor.AddHistoryEntry(testHistoryEntry); /// Update the last history record borholeHistoryEditor.UpdateLastHistoryEntry(Environment.UserName, "Test", "Test Arguments", "Test Version"); /// access to old history foreach (HistoryEntry entry in borholeHistoryEditor.History) { PetrelLogger.InfoOutputWindow(" User Name : " + entry.UserName); PetrelLogger.InfoOutputWindow(" Operation : " + entry.Operation); PetrelLogger.InfoOutputWindow(" Arguments : " + entry.Arguments); PetrelLogger.InfoOutputWindow(" AppVersion : " + entry.AppVersion); PetrelLogger.InfoOutputWindow(" Begin Date : " + entry.BeginDate.ToString()); PetrelLogger.InfoOutputWindow(" End Date : " + entry.EndDate.ToString()); PetrelLogger.InfoOutputWindow(Environment.NewLine); } } //Type type = typeof(argumentPackage.Borehole); if (StatisticsService.CanGetStatistics(domainObject.GetType())) { Statistics stats = StatisticsService.GetStatistics(domainObject); if (stats != null) { PetrelLogger.InfoOutputWindow("Statistics Data Access for : " + domainObject.GetType().Name); PetrelLogger.InfoOutputWindow("---------------------------------------------------------------------------"); PetrelLogger.InfoOutputWindow(Environment.NewLine); PetrelLogger.InfoOutputWindow("Axis Info items : "); PetrelLogger.InfoOutputWindow(Environment.NewLine); foreach (AxisInfoItem axis in stats.AxisInfo) { PetrelLogger.InfoOutputWindow(" Axis Name : " + axis.Name); PetrelLogger.InfoOutputWindow(" Axis Min Value : " + axis.Min); PetrelLogger.InfoOutputWindow(" Axis Max Value : " + axis.Max); PetrelLogger.InfoOutputWindow(" Axis Delta Value : " + axis.Delta); PetrelLogger.InfoOutputWindow(" Axis UnitMeasurement : " + axis.UnitMeasurement.ToString()); PetrelLogger.InfoOutputWindow(Environment.NewLine); } PetrelLogger.InfoOutputWindow("Key Value Pair items : "); PetrelLogger.InfoOutputWindow(Environment.NewLine); foreach (KeyValuePair <string, string> keypair in stats.Attributes) { PetrelLogger.InfoOutputWindow(" Key : " + keypair.Key); PetrelLogger.InfoOutputWindow(" Value : " + keypair.Value); PetrelLogger.InfoOutputWindow(Environment.NewLine); } } } }