how to make image tilt correction by user input in matlab - matlab

I am developing a semi user interface , in which I want to introduce a user input in which a popup window should come and asking that "do you want to tilt the image?" with yes or no option.
If I press yes again one window should open and ask me to put the required angle through which you want to rotate the figure. If I press no. program should proceed as before. I have tried like this but not working.
dlgTitle = 'Tilt correction?';
dlgQuestion = 'Do you wish to Tilt the image?';
choice = questdlg(dlgQuestion,dlgTitle,'Yes','No', 'Yes');
prompt={'Enter a value of \theta (in degrees)'};
name = 'Tilt correction';
defaultans = {'30'};
options.Interpreter = 'tex';
answer = inputdlg(prompt,name,[1 40],defaultans,options);
end

i am not sure if i am addressing the right problem, but if its "the proceed at no" issue you missed an "if"
dlgTitle = 'Tilt correction?';
dlgQuestion = 'Do you wish to Tilt the image?';
choice = questdlg(dlgQuestion,dlgTitle,'Yes','No', 'Yes');
if strcmp(choice,'Yes')
prompt={'Enter a value of \theta (in degrees)'};
name = 'Tilt correction';
defaultans = {'30'};
options.Interpreter = 'tex';
answer = inputdlg(prompt,name,[1 40],defaultans,options);
end
if you want to adress the [1,40] range as well you need an additional loop. but this should already work for just yes and no

Related

Roblox studio How do I change a TextLabel text in script

I want to make a gui that show your coordinates in game with text labels but my script seems didn't change the text at all
players = game.Players.LocalPlayer
players.CharacterAdded:Wait()
X = math.floor(players.Character.HumanoidRootPart.Position.X)
Y = math.floor(players.Character.HumanoidRootPart.Position.Y)
Z = math.floor(players.Character.HumanoidRootPart.Position.Z)
text = script.Parent.Text
while true do
text = X..","..Y..","..Z
X = math.floor(players.Character.HumanoidRootPart.Position.X)
Y = math.floor(players.Character.HumanoidRootPart.Position.Y)
Z = math.floor(players.Character.HumanoidRootPart.Position.Z)
end
please help me
I wanted to change the text to XYZ position in string
but everytime i launch the game the text didnt change
and it still at default text in roblox ui text label
The simple answer to your question of how do I change a TextLabel text is you just set the Text property.
script.Parent.Text = "Hello World"
If you want a simple way to track the changing position of a player's character, I would recommend using the Changed signal on the Part. It will fire the connected function every time the property changes, and it allows you to avoid using an infinite while-loop.
local text = script.Parent
local player = game.Players.LocalPlayer
-- wait for the player's character to exist
if not player.Character then
player.CharacterAdded:Wait()
end
-- listen for changes to the player's position
local hrp = player.Character.HumanoidRootPart
hrp:GetPropertyChangedSignal("Position"):Connect(function()
local position = hrp.Position
local x, y, z = math.floor(position.X), math.floor(position.Y), math.floor(position.Z)
-- format the position, and display it in the TextLabel
local positionString = string.format("(%d, %d, %d)", x, y, z)
text.Text = positionString
end)
So I can see that you have made few mistakes here
Explanation:
First of all, players.CharacterAdded:Wait() doesn't always work and never works in studio. So instead of that, you should use players.Character:WaitForChild("HumanoidRootPart").
Second thing. By calling text = script.Parent.Text you were requesting the text inside of it (you were getting it as a string), so to simply fix that you have to use text = script.Parent and then when changing text you will have to use text.Text = "your text".
The next one is making your while loop infinite by using bool true. You can't make it like that or else the playar may experience lag or even script may crash. So I'd suggest to put this to something like wait(0.1).
And the last thing is that you should get X,Y,Z before putting it into the text or else it will be delayed.
And your final script should be looking like this:
players = game.Players.LocalPlayer
players.Character:WaitForChild("HumanoidRootPart")
X = math.floor(players.Character.HumanoidRootPart.Position.X)
Y = math.floor(players.Character.HumanoidRootPart.Position.Y)
Z = math.floor(players.Character.HumanoidRootPart.Position.Z)
text = script.Parent
while wait(0.1) do
X = math.floor(players.Character.HumanoidRootPart.Position.X)
Y = math.floor(players.Character.HumanoidRootPart.Position.Y)
Z = math.floor(players.Character.HumanoidRootPart.Position.Z)
text.Text = X..","..Y..","..Z
end
Keep scripting, nothing is easy without practice,
KubaDC

Simultaneous double left click with two mouse pointers on GlovePie

I am new to GlovePie.
I created a second mouse that moves simultaneously with the first pointer while staying at a fixed distance. My intent is to get a left click from both pointers simultaneously, because my aim is to click on two buttons simultaneously.
Is it possible to do this?
The code I wrote, following the developer's wiki, is this:
Cursor2.PosX = Mouse.CursorPosX + 80
Cursor2.PosY = Mouse.CursorPosY + 0
Cursor2.LeftButton = Mouse.LeftButton
Cursor2.RightButton = Mouse.RightButton
Very simply. Moving works but simultaneous clicks don't. Any suggestions?
A friend of mine found online the solution to my request, which I share here even if I cannot fully understand its code. For example: why there are two mouse (mouse and mouse1) and two cursor (Cursor and Cursor2)? So if any of you are able to comments the lines of code, I would be grateful to understand them!
mouse.Swallow = true
fakemouse.DirectInputX = mouse1.DirectInputX
fakemouse.DirectInputY = mouse1.DirectInputY
var.x1 = mouse1.cursorPosX
var.x2 = 350
mouse.LeftButton = mouse1.LeftButton
if !mouse1.LeftButton then
Cursor2.PosX = var.x1 - var.x2
Cursor2.PosY = mouse1.cursorPosY
endif
if mouse1.LeftButton then
press mouse1.LeftButton
wait 20ms
release mouse1.LeftButton
Cursor2.PosX = var.x1
Cursor.PosX = var.x1 - var.x2
press mouse1.LeftButton
wait 20ms
release mouse1.LeftButton
Cursor2.PosX = var.x1
Cursor.PosX = var.x1 + var.x2
endif

Access VBA to Change an Image in a Continuous Form

I am trying to create a receipt form where people will confirm if they've received the full quantity of an order. As part of this, I want the following to happen:
If they received the full quantity, a green check mark appears
If they received a partial quantity, an orange triangle appears
If they received no items, a red x appears
To accomplish this, I'm using a continuous form with 3 image files for each situation. I'm using the code below to change the image when the quantity is changed. The problem is, when the quantity is change on 1 line, the symbol changes for all lines. I'll post pictures as well.
Any thoughts on how I can fix this?
I'm open to other methods of accomplishing this idea too.
Private Sub FinalQTY_AfterUpdate()
If IsNull(Me.FinalQty) Then
MsgBox "You must enter a quantity for this item"
Me.FinalQty.SetFocus
Exit Sub
Else
LValue = Me.[FinalQty]
If IsNumeric(LValue) = 0 Then
Me.FinalQty = ""
MsgBox "Qty must be a numeric value"
Me.QTY.SetFocus
Exit Sub
End If
End If
Me.FinalTotalPrice = Me.FinalPrice * Me.FinalQty
If Me.FinalQty = 0 Then
Me.Yes.Visible = False
Me.Change.Visible = False
Me.No.Visible = True
End If
If Me.FinalQty < Me.QTY Then
Me.Yes.Visible = False
Me.Change.Visible = True
Me.No.Visible = False
End If
If Me.FinalQty = Me.QTY Then
Me.Yes.Visible = True
Me.Change.Visible = False
Me.No.Visible = False
End If
End Sub
This is before I adjust the quantity:
This is after I adjust the qty of only the second line:
Since the formatting of each record displayed by a continuous form is inherited from the form design template, any changes to the template will be automatically applied to all records displayed by the form, aside from Conditional Formatting rules in effect or the handful of properties which may changed via the OnPaint event of the Detail section.
One possible alternative might be to add a new field to your table with a data type of OLE Object and populate the value on the AfterUpdate event using the AppendChunk method, sourcing image data from a separate table containing three records corresponding to your green tick, orange triangle, and red cross images.

How do i get the bounding rect of each word in a text (for reading eyetracking)?

For an eye tracking study i need the positions of each word in a text drawn to the window.
I can see how I can get the bounding box of the whole text as a return value using
[nx, ny, textbounds] = DrawFormattedText(win, tstring)
Is there a better way than drawing a whole sentence using this function word by word?
Something like this should do it:
teststr = {'Hello World!' ; 'How are you doing?'}
ystart = 100
xstart = 200
wordgap = 10
for i=1:size(teststr,1)
str=teststr{i};
wordlist = strsplit(str , ' ');
for j=1:size(wordlist)(1)
[nx, ny, textbounds]=DrawFormattedText(win, wordlist{j} ,xstart, ystart);
poslist{j} = textbounds;
xstart=nx+wordgap;
end
end
Not pretty, but it works. You will get problems if you have linebreaks.
EDIT: 2015-07-14: added wordgap suggestion from sven.io

Setting up some properties for a combobox (scroll, edit, jump)

There are 3 properties that I want to set for some VBA form comboboxes and I don't know if it's possible.
I don't want to let the combobox editable. Right now if the user types something in it that it submits the form it will send that value... I want to let him choose only from the values I added in the Combobox.
I want to make the list of items in the combobox scroll-able. Right now I'm able to scroll through the list if I use the scroll-bar but I don't know why I can't scroll with the mouse scroll.
And I want to jump to some item if I start typing. Let's say I have the months of the year in one combobox... if I start to type mar I want it to jump to march. I know that for the html forms this properties is by default but I don't know about VBA forms...
Thanks a lot
Of the behaviours you want, some are possible with settings on the Combo, others you will need to code
List of Months: Put a list of entries on a (hidden) sheet and name the range. Set .RowSource to that range
Match as you type: Set properties .MatchEntry = fmMatchEntryComplete and .MatchRequired = True
Reject non list entries: A Combo with these settings will allow you to type an invalid entry, but will reject it with an error message popup when you commit. If you want to silently reject invalid data as you type, you will need to code it.
If you want the selected value returned to a sheet, set .ControlSource to a cell address (preferable a named range)
By "...scroll with the mouse scroll..." I assume you mean the mouse wheel. Unfortunatley Forms don't support mouse wheel scroll. You will have to code it yourself. There is a Microsoft patch for this at here (not tried it myself yet)
Sample code to silently reject invalid entries
Private Sub cmbMonth_Change()
Static idx As Long
Dim Match As Boolean
Dim i As Long
If cmbMonth.Value = "" Then Exit Sub
If idx = 0 Then idx = 1
i = idx
Match = False
For i = 0 To cmbMonth.ListCount
If cmbMonth.List((i + idx - 1) Mod cmbMonth.ListCount) Like cmbMonth.Value & "*" Then
cmbMonth.ListIndex = (i + idx - 1) Mod cmbMonth.ListCount
Match = True
Exit For
End If
Next
If Not Match Then
cmbMonth.Value = Left(cmbMonth.Value, Len(cmbMonth.Value) - 1)
End If
End Sub
Set the propertie MatchEntry of combobox to 1 (fmMatchEntryComplete) and MatchRequired to true for example
combobox1.MatchEntry=1
combobox1.MatchRequired=True
[]'s