Académique Documents
Professionnel Documents
Culture Documents
2004
Volume 10 Number 8
INSIDE
ON THE COVER
Active Delphi
Your First
ASP.NET App
ADO.NET:
Adventures in
Continuing his exploration of ADO.NET, Bill Todd explains that the new
architectures lack of a cursor in the DataTable object is a good
thing. As usual, Bills example project demonstrates his key points,
including that the ability to refer to any row at any time using its
index number saves a lot of code.
Refactoring
Do-It-Yourself 3D
The Results Are In!
2004 Readers
Choice Awards
Sound+Vision
11
www.DelphiZine.com
FEATURES
7
Delphi Informant
Do-It-Yourself 3D
Informant Spotlight
16
REVIEWS
20 RemObjects SDK 3.0
23
D E PA R T M E N T S
2 Toolbox
24 File | New by Alan C. Moore, Ph.D.
T O O L B O X
ComponentOne DevKits
for Delphi 8 and Visual
Studio.NET
ComponentOne released ComponentOne
DevKit for Delphi 8 and ComponentOne
DevKit for Visual Studio.NET.
ComponentOne DevKit for Delphi
8 includes Delphi 8 for the Microsoft
.NET Framework and ComponentOne
Studio Enterprise. ComponentOne
DevKit for Visual Studio.NET combines
ComponentOne Studio Enterprise with
Visual Studio.NET Professional.
ComponentOnes Studio Enterprise is a
component subscription that targets all
run-time environments. This integrated
framework delivers over 100 grid,
reporting, charting, data, user-interface,
and eCommerce components.
ComponentOne LLC
Price: See Web site.
Contact: sales@componentone.com
Web Site: www.componentone.com
A C T I V E
ASP.NET
D E L P H I
DELPHI 8
By Nick Hodges
Active
Delphi
style="Z-INDEX:1;LEFT:350px;POSITION:absolute;TOP:238px"
runat="server" text="Button">
</asp:button>
<body ms_positioning="FlowLayout">
<form runat="server">
<asp:button id="Button1" runat="server" text="Button">
</asp:button>
</form>
</body>
Active
Delphi
In addition, if you unfold all the code on the page (rightclick, select Unfold | All), you should see ... well, nothing
else related to Button1. Interesting, eh? You might have
expected to see some code in the InitializeComponents
method that creates and initializes Button1, as you would
in a WebForms application. There is no such code, however, because all the information that the application needs
to create and initialize the button is in the ASPX file, and
the ASP.NET engine uses that information right from the
file to create and initialize the button. In that way, the
ASPX file acts sort of like a DFM file from the VCL.
procedure TWebForm1.InitializeComponent;
begin
Include(Self.Load, Self.Page_Load);
end;
Active
Delphi
Figure 4: The ASP.NET application running, after the button has been pushed.
formatter has a few options you can set via the Tools |
Options | HTML Formatting page. However, if you go to the
Tools | Options menu item and select HTML Tidy Options (see
Figure 2), you can use the open source HTML Tidy
formatter, which gives you much more control over how
your HTML is formatted. (You can find out more about
HTML Tidy at http://tidy.sourceforge.net.) Note that to
use HTML Tidy you must check the checkbox at the top
of the dialog box.
Figure 3: The Project Options dialog box for an ASP.NET application allows you to
set the server host for your application.
C O L U M N S
ADO.NET
&
R O W S
By Bill Todd
StatusBar Panel
Description
Position
Row
Column
Country
Columns
&
Rows
procedure TCountryForm.InitGridCurrencyManager;
begin
CountryGridCurrencyMgr := CountryGrid.BindingContext[
EmpDataSet.Tables['Country'].DefaultView] as
CurrencyManager;
end;
procedure TCountryForm.
CountryGridCurrencyMgr_PositionChanged(
Sender: System.Object; e: System.EventArgs);
begin
ShowCurrentRow;
end;
procedure TCountryForm.InitGridCurrencyManager;
begin
CountryGridCurrencyMgr := CountryGrid.BindingContext[
EmpDataSet.Tables['Country'].DefaultView] as
CurrencyManager;
Include(Self.CountryGridCurrencyMgr.PositionChanged,
Self.CountryGridCurrencyMgr_PositionChanged);
ShowCurrentRow;
end;
Columns
&
Rows
procedure TCountryForm.FirstItem_Click(
Sender: System.Object; e: System.EventArgs);
begin
CountryGridCurrencyMgr.Position := 0;
end;
procedure TCountryForm.InsertItem_Click(
Sender: System.Object; e: System.EventArgs);
begin
CountryGridCurrencyMgr.AddNew;
end;
procedure TCountryForm.LastItem_Click(
Sender: System.Object; e: System.EventArgs);
begin
CountryGridCurrencyMgr.Position :=
CountryGridCurrencyMgr.Count - 1;
end;
procedure TCountryForm.DeleteItem_Click(
Sender: System.Object; e: System.EventArgs);
begin
if CountryGridCurrencyMgr.Count > 0 then
CountryGridCurrencyMgr.RemoveAt(
CountryGridCurrencyMgr.Position);
end;
procedure TCountryForm.DeleteDataViewItem_Click(
Sender: System.Object; e: System.EventArgs);
begin
DataView(CountryGridCurrencyMgr.List).Delete(
CountryGridCurrencyMgr.Position);
end;
First
Last
Next
Prior
Insert
Delete
Insert with DataView
Delete with DataView
Cancel Edit
End Edit
Figure 8 shows the Click event handlers for the First and
Last menu items. Both of these event handlers work by
setting the CurrencyManager.Position property. To go to
the first row, Position is set to zero. To go to the last row,
Position is set to CurrencyManager Count -1 because the
row numbers are zero based.
Figure 9 shows the code for the Next and Prior menu items
Click event handlers. The code for the Next menu item checks
to see if the current row is less than the last row. If so, it adds
one to the Position property. The event handler displays a
warning message if the current row is the last row. The code
for the Prior menu items event handler is almost identical,
except that it checks to see if the current position is zero and,
if not, subtracts one from the Position property.
Figure 10 shows the event handlers for the Insert and Delete
menu items. Insert calls the CurrencyManager.AddNew
9
procedure TCountryForm.InsertDataViewItem_Click(
Sender: System.Object; e: System.EventArgs);
begin
DataView(CountryGridCurrencyMgr.List).AddNew;
end;
Columns
&
Rows
method, on the
other hand, works
as expected.
Figure 13 shows
the event handlers
for the Cancel
Edit and End Edit
menu items.
The Cancel Edit
handler calls the
CurrencyManagers
CancelCurrentEdit Figure 12: The sample application after inserting a
new row with DataView.AddNew.
method to undo
the changes you
made to the current record. The End Edit handler calls
the CurrencyManager.EndCurrentEdit method. When
you change a record in the DataGrid, or any other
user interface control, the change isnt written to the
underlying DataTable until one of two things happens:
1) You change the CurrencyManager.Position property, either
in code, or by moving to another row in the DataGrid.
2) You call the CurrencyManager.EndCurrentEdit method.
If you try to apply your changes to the database before you
move to a new row or call EndCurrentEdit, your change
wont be made in the database, because it hasnt been made
to the DataTable.
Conclusion
When you understand how to work with the current row in
the user interface using the CurrencyManager, the lack of a
cursor in the DataTable object is really a blessing. The ability to refer to any row at any time using its index number
saves a lot of code. In Delphi for Win32 if you want to copy
10
procedure TCountryForm.CancelEditItem_Click(
Sender: System.Object; e: System.EventArgs);
begin
CountryGridCurrencyMgr.CancelCurrentEdit;
end;
procedure TCountryForm.EndEditItem_Click(
Sender: System.Object; e: System.EventArgs);
begin
CountryGridCurrencyMgr.EndCurrentEdit;
end;
values from the fields in one row to the fields in another row
in the same table, you must use two dataset components. In
ADO.NET all you need to know is the index number of each
row and you can do the job with a simple for loop. If you
need to work with the DataRowView or the entire DataView
behind the current row in the user interface, you can do so
easily and generically using the CurrencyManagers Current
and List properties. Its a very powerful architecture.
Click here for Part 8 and Part 9.
The example project referenced in this article is available for
download on the Delphi Informant Magazine Complete
Works CD located in INFORM\2004\AUG\DI200408BT.
S O U N D + V I S I O N
ANAGLYPHIC STEREO IMAGES
DELPHI 4-7
By Alexander Gofen
Do-It-Yourself 3D
Creating Anaglyphic Images at Home
Sound+Vision
Do-It-Yourself 3D
TFastMap24 = class(TBitMap)
private
// Scan lines for each line.
Lines : array of PByteArray;
function IsValid(const i,j: Integer): Boolean;
function GetClrComp(const i,j: Integer;
const n: Byte): Byte;
procedure SetClrComp(const i,j: Integer;
const n, ClrComp: Byte);
public
property PixelRGB[const i,j: Integer; const n: Byte]:
Byte read GetClrComp write SetClrComp; default;
destructor Destroy; override;
procedure SetLines;
procedure LoadFromFile(const FileName: string); override;
procedure Assign(Source: TPersistent); override;
procedure AssignTurned(const Source: TFastMap24;
const ang: Single);
end;
Figure 1: The mechanism for fast addressing the pixels as elements of a 2D array is
based on the introduction of a dynamic array, Lines, of the same type PByteArray as
the ScanLine property for each line of the bitmap.
procedure TFastMap24.SetLines;
var
j: Integer;
begin
SetLength(Lines, Height);
for j := 0 to Pred(Height) do
Lines[j] := ScanLine[j]
end;
Figure 4: Convert the bitmap into a 3D array of Single then reconvert it back.
The unit also offers another fast algorithm for massive computations with the color bitmap pixels. Its idea is to convert the
bitmap into a 3D array of Single (to perform massive computation of any complexity over it), and then convert it back.
Both conversions are performed using the fast access process previously described (see Figure 4). This unit opens
the door for many possible massive computations over
bitmaps required in applications. The stereo-photo application in the next section uses it, as well.
Combining Anaglyphic Pictures
The application accompanying this article makes possible the
creation of anaglyphic stereo images of two types. Both types
are overlapped left and right images in different colors.
Sound+Vision
Do-It-Yourself 3D
same procedure, so
that both images
are consistently
converted into gray
scale with optimal
contrast; any image
editor does it).
Figure 5: The horizontal shift between the left and right images determines the convergence point of the eyes: point A (1a) or point C (1b)
shown in Magenta as a result of overlapping Red and Blue. Black points ABCD represent how they are perceived in 3D space: all in front of
the screen (1a) or in front and behind the screen (1b). The whole set CBAD (1a) was rigidly shifted up so that C coincide with C (1b). Such a
shift affects disparities of all pairs. The convergence point (zero disparity) is perceived as lying on the screen. Pairs with disparities of opposite signs correspond to points perceived at the opposite sides of the screen. Therefore the horizontal shift affects the perceived position of
the 3D scene: whether it appears completely in front of the screen, partially, or completely behind the screen.
Sound+Vision
Do-It-Yourself 3D
Figure 6: Disparity and depth. Point A is a convergence point, hence its disparity is zero. For a nearer point B the image B would appear to the left of A, while
image B to the right of A. Disparity of point B then is BRA+ALB=2BRA.
Denoting half-base RC=SA=b, CB=d1 and CA=d, the disparity of B would be
= 2BRA=2(BRS-ARS)=2(arctan(b/d1) - arctan(b/d)).
Figure 7: Black and white 3D pair: left (left top), right (right top), and
overlapped (bottom).
tures, not stereo pairs), if you view it with your one eye (the
other one closed), the perspective hints may appear so strong
(streets, straight edges, obviously different layers of depth), that
with a little brain effort you can suddenly perceive it as though
real 3D stereo. This is known as monocular stereopsis.
Thus, paying attention to the angular setting of your lenses
(focus or zoom factor) vs. the expected conditions for viewing
the hard copy (or the screen image), is always important in
photography.
The comfortable viewing angle for us is something between
40 and 60 degrees. Therefore, the fish-eye lenses or tele-lenses
would be an improper choice for shooting a scene with rich
perspective. Another important limitation is that the brain fuses
stereo pairs only for disparities not exceeding approximately 2
(120). Front images situated too close to the viewer (disparity
overflow) would not fuse, and only hinder the perception.
The limitation from below is that of our visual acuity (about
1). Therefore, disparity of less than 1 is not perceived and
always translates into a plane background in the far (disparity underflow). For example, while viewing naturally at a
real-world scene (eye base 6-7 cm) we can perceive stereopsis
for objects between 0.8 and 200 meters: everything farther is
perceived as a plane background. Shifting the fixation (convergence) point closer, say at 50 cm, and allowing disparity
between -1and 1, we can place the nearest objects at 38 cm,
and the farthest at 70 cm (see the formula in Figure 6).
Sound+Vision
Do-It-Yourself 3D
Same zoom. You must apply exactly the same zoom
for both shots (if your zoom is variable).
No internal flash. You should not use the internal flash
on your camera; it would create confusing non-matching
shadows. Instead, shoot in natural light, possibly with
low-speed exposition (the camera is fixated anyway).
Left/Right not interchangeable. Both images are
intended for the proper eye only, therefore name the
files correspondingly. If you later confuse their order,
you will probably still perceive the stereo effect, albeit
inversely in depth. Generally speaking, this inversion
is not geometrically consistent with the perspective
hints in the image, which may hinder the fusing and
perception. (Only if the perspective hints are purposely minimized by shooting with tele-lenses, the inversion of depth doesnt cause fusing difficulties).
Conclusion
The anaglyphic display is the simplest, yet most efficient
approach to implementing the stereo vision on conventional PCs. Its the best choice for displaying monochromatic stereo images; however, it does compromise color
perception of full-color stereo pictures.
For stereo viewing with uncompromised colors, more
sophisticated gadgets are needed. For example, color stereo
pairs may be displayed next to each other on the left and
right halves of the same screen. To view them, you would
need a viewer with a pair of mirrors (or prisms) inside,
which comfortably helps converging your eyes at each of the
images properly. The ultimate device would be goggles with
small, high-quality monitors for each eye. Then the viewer
enjoys not only the highest quality color stereo vision, but
also full freedom from maintaining the correct place and
position of the head. This freedom is achievable also while
viewing stereo on a big screen through shuttered or polarizes glasses, and through the anaglyph glasses, as well.
Meanwhile, Sharp Inc. (www.sharpsystems.com) introduced the latest Sharp 3D Stereo Notebook computer that
requires no glasses or goggles, but provides plenty of
stunning stereo images and the software to assist in their
creation. However, this model does require the viewer to
always maintain the correct place and position of the head.
We are now at the doorstep of the next stage in the evolution of computer displays, stereo vision, and the 3D Stereo Notebook marks the beginning of this evolution and a
general reawakening of the interest in stereo vision.
The files referenced in this article are available
for download on the Delphi Informant Magazine Complete
Works CD located in INFORM\2004\AUG\DI200408AG.
INFORMA NT
SPOTL IG HT
By Jerry Coffey
BS/1 (25%)
Accounting for Delphi (21%)
BSS Business Systems (10%)
Express Spreadsheet (9%)
other (35%)
Best Add-in
Its a rush. It was a
closer finish, but Developer
Express CodeRush took
first place for the sixth
straight year with 27% of
the vote (last year it took
36%). This years runner-up
brings us our first tie with
Athlant (from Devrace) and
TMS Plugin Framework
(from TMS Software) each
garnering 18%. Last years
runner-up, ModelMaker
Code Explorer, drops to
fourth place with 16%.
CodeRush (27%)
Athlant (18%)
TMS Plugin Framework (18%)
ModelMaker
Code Explorer (16%)
Castalia (12%)
other (9%)
Informant
Spotlight
No competition. This is a
brand new category, so no
one knew what to expect.
What happened was a blowout, with Atozed Softwares
FinalBuilder taking 79% of the
vote. Quality Software Components came in a distant
FinalBuilder (79%)
runner-up with 12% for their
TC Builder (12%)
TC Builder.
Visual Build Professional (7%)
other (2%)
TeeChartPro (45%)
TMS Diagram Studio (13%)
EasyMap VCL (13%)
ExpressOrgChart Suite
(11%)
Chart FX (5%)
other (13%)
DBISAM Database
System (27%)
Advantage Database Server (21%)
NexusDB (21%)
Apollo (6%)
TurboDB (6%)
other (19%)P
FIBPlus (24%)
Direct Access
Components for
MySQL (12%)
IB Objects (10%)
Oracle Data Access
Components (9%)
Advantage TDataSet
Decendant (9%)
other (36%)
IB Expert (25%)
InfoPower (13%)
ExpressQuantumTreeList (11%)
EhLib (10%)
other (41%)
AQtime (25%)
CodeSite (22%)
EurekaLog (17%)
madExcept (14%)
other (22%)
Informant
Spotlight
ImageEn (29%)
LEADTOOLS
Imaging Toolkit (20%)
ImageLib
CORPORATE SUITE (20%)
Billenium Effects (13%)
ImagXpress (6%)
other (12%)
InstallShield (60%)
Wise for Windows Installer (25%)
Ghost Installer Studio (10%)
other (5%)
18
FastReport (42%)
ReportBuilder (33%)
QuickReport
Professional (7%)
Rav BEX (Borland
Edition Extended) (7%)
other (11%)
TMS Security
System (36%)
StreamSec Tools (15%)
ICE License (15%)
other (34%)
Best Library
Check this out. ExpressBars Suite (Developer
Express) wins again with
a convincing 34% of your
votes. The big story in this
category is that FastScript
(FastReports) has come
out of nowhere to take
19% and second place.
CDK (13%)
other (18%)
Best Scheduling/Calendar
StarTeam (34%)
Team Coherence (34%)
AQdevTeam (19%)
PVCS Professional (9%)
other (4%)
Informant
Spotlight
TestComplete (71%)
Rational Robot (16%)
DevPartner Studio (10%)
other (3%)
Best Training
Theyre back! After
falling to third place last
year, InfoCan is back on
top with 28%. And after
winning two years in a row,
Jensen Data Systems slips
to runner-up status with
23% of the vote. Dropping
from the runner-up status
they enjoyed last year,
Falafel Software is still a
player with third place
and 16%.
Best Utility
Retied. This is a first.
Just as they did last year,
ASPack (from ASPack
Software) and VMware
Workstation (VMware) tied
for first place and with
near identical percentages
(each with 24% as compared to last years 23%).
Beyond Compare in third
place is also an exact repetition of last year.
1&1 WebHosting
(27%)
Defined
Systems (27%)
Kylix Host (14%)
other (32%)
19
N E W
&
U S E D
By Mike Riley
Figure 1: One of the more visibly notable improvements from previous versions is
the completely rewritten Service Builder 3.
New
&
Used
21
New
&
Used
T E X T F I L E
F I L E
N E W
Adventures in Refactoring
File
New
Adventures in Refactoring
25