Drawing on Petrel map window - ocean

I'm working on a plug in for petrel in I require drawing lines, polygons on a petrel map window, can it be possible using mouse events?

Yes, you can create a process that takes mouse button clicks in a map window and creates lines or polygons from the input picks provided (MapPickedPoint). The process could create a new polyline object in a folder in the Petrel input tree that would be updated with each pick, or you can create your own custom domain object that is updated with each point pick. If you create a custom domain object you will need to also provide the method to draw the object in the map window.

Related

Locating canvas objects with Selenium

I'm using Selenium to develop automated tests for a web application. I have to simulate clicks on certain objects that reside inside a canvas element. In particular, I'm using vis.js to visualize nodes/edges and I need to test the effect of clicking on particular nodes/edges that are visible on the canvas.
The problem is that the positions of the nodes/edges aren't determined in advance. Therefore, I'm not sure how I'm supposed to locate them. If I were able to find the coordinates of a canvas object's position, it would've been possible for me to simulate clicking on the object using Selenium's moveByOffset:
x, y = find_node_coordinates_on_canvas(node_id) # how to do this?
canvas = self.driver.find_element_by_id("vis_canvas")
action = ActionChains(self.driver).move_by_offset(x, y).click(canvas).release()
The problem is that I don't know how to implement find_node_coordinates_on_canvas. That is, given the identifier of an object on the canvas, how do I find the coordinates of its position?

Design pattern for child calling method in parent

I am currently working on my biggest project and I am having trouble figuring out how to structure my code. I'm looking for some guidance.
I have 2 objects a Tile and Container. Each Tile has a 2D coordinate and are all children of the Container. The Container has methods that return tile for location, switch tiles, add tiles, and remove tiles.
Now when you click on a tile it disappears, that was easy because it was self contained. The problem comes when I created different types of tiles that inherit from the base Tile. Each different type of tile does a different action when you click on it. Some destroy surrounding tiles some switch with other tiles and others add new tiles. For simplicity we will call these 3 subclasses Tile-destroy, Tile-swap, and Tile-add.
My problem is when I click on these tiles how can they act on other tiles in the Container. Should I just call functions in the parent class or is there a better way to do this? I am having trouble #including the Tile in the Container as well as the other way around. I feel like its not a proper pattern.
I have it set up so when a click takes place the Container handles it and checks the type of tile that is clicked and acts from there with a large else-if statement however this makes it very difficult to add new tile types. Ideally all the information for what happens when you click on a tile is contained within each tile subclass.
Any ideas?
I can suggest you the simpliest design:
Your Container will be a game controller
Each tile has Parent property which is refer to Container
When you click on tile it sends Command to Container (for example, DestroyTile(x, y) or AddTile(x, y)
Container handle this commands and destroys, adds or swap tiles.
If you want really good and more decoupled design you can also create handlers for all operation types DestroyTileHandler, AddTileHandler. In Container on different commands you will just pass them [commands] to appropriate handler. Also you need to pass context object (like Field with tiles) to handler. This allows you to add and modify new operations without even changing Container code.
See related patterns: Command, Observer
Feel free to ask questions and good luck!

How to I get location when click bingmap in Windows 8.1 Store App?

I have to a Windows 8.1 store project and I must use bingmap or other maps for this project( I tried Bing Map). When I click on the map I want to take location(Latidude , Longtitude) of the this point.
How can I do?
To get the coordinate of where the user clicked you will need to first add a click event to the map. In the event handler you will be able to get the pixel coordinates of the click event. You can pass these through the maps TryPixelToLocation method which will convert the pixel coordinates into a map coordinate. You can find a full code sample here: https://code.msdn.microsoft.com/Bing-Maps-C-Pixel-to-3eb9fff0#content

Dragging in processing.js

I am a physics teacher in London and I am trying to learn processing.js
To make teaching resources a very important technique is to be able to drag shapes around. Although I know how to do this in PJS, I have found that the code for having several draggable objects quickly gets messy. (especially if the object is "locked", so that it does not matter if the cursor goes off the object)
Does anybody know how to run the dragging spript from a separate file? i.e. so that the main script calls the dragging script for objects? The idea is that you would draw shapes and simply make them draggable, with the dragging code in a separate file? This would make the creation of teacher resources a lot easier.
It would be great if people could provide some ideas on this. I have seen the drag demos on the main PJS website, but I am looking for something quicker/easier.
Many thanks
Matt Klein
ruby_murray1[AT]hotmail.com
Well, I do processing.js in pure javascript code without bothering with the Processing syntax but it should go something similar:
Make the objects that you want draggable adhere to a Draggable interface, the draggable interface indicates what is draggable and provides a method to move an object
When drag starts, see if there is a Draggable object under the mouse that you want to drag, store it locally and use the Draggable interface method to move the object around. This way your local dragging code is generic to any Draggable object and objects handle their own movement.
On drag end, remove the Draggable object from your local store (and stop calling its move method).
You could pull out this entire dragging logic into an external file as well, as long as you hook it into the correct mouse events.
About Interfaces: http://forum.processing.org/topic/class-interface-block-example

how to create a round/circular button in win32 API using visual c++

I have a Window (Win32 API) Application in Visual C++. I am not using MFC. I have to create a round/circular button with bitmap image. My application have a skinned view. Can any one help me out in achieving this task.
Buttons are windows. You can create a button with the CreateWindow or CreateWindowEx call:
-http://msdn.microsoft.com/en-us/library/ms632680(VS.85).aspx
When you create your button window ensure that you pass the BS_OWNDERDRAW style:
-http://msdn.microsoft.com/en-us/library/bb775951(VS.85).aspx
That will tell the button to send WM_DRAWITEM messages to your buttons' WNDPROC:
-http://msdn.microsoft.com/en-us/library/bb775923(v=VS.85).aspx
In your buttons' WNDPROC you would handle the WM_DRAWITEM message and paint your button according to the information in the DRAWITEMSTRUCT received as a pointer in lParam.
To render a bitmap as anything but rectangular you will need to provide a 1-bit bitmask bitmap the same size as the bitmap you wish to render for your button. The bitmask has bits set where you want the pixels in your button bitmap to be set on the screen. The pixels in your button bitmap that do not display need to be black. Bitblt your bitmask bitmap to the screen with the AND operator then OR your button bitmap. Of course you will need to account for the various button states (normally a push button is only two states.)
I may have mixed the black/white or set/unset bits in the explanation above, but the AND / OR bitwise (SRCAND/SRCPAINT) Raster Operations are the correct operations for what you are trying to acheive.
-http://msdn.microsoft.com/en-us/library/aa930997.aspx
Hope that helps.
You can google to find techniques for BitBlting images using memory DC and various ROP2 settings to achieve a masking effect. Your round image that represents the button would use a specific color to represent transparency. I don't have the specific code at hand but it is non-trivial.
The key api call you need to know is SetWindowRgn. This is what you call to tell windows that the the window is not rectangular but an irregular region. If you google around for that, you will find lots of sample code.
One promising example is this project. It does depend on MFC, but you can use it to learn what you need to call in what order to get the desired effect.