'기본 카테고리' 카테고리의 다른 글
AIMA Python Code 파이썬 인공지능 코드 (0) | 2009.10.18 |
---|---|
Standards and Style for Coding in ANSI C (0) | 2009.10.11 |
추억의 XT 컴퓨터 : GW-BASIC (0) | 2009.10.04 |
Refactoring Tools Review - Part I (0) | 2009.10.03 |
Ansi C 리펙토링 (0) | 2009.10.03 |
AIMA Python Code 파이썬 인공지능 코드 (0) | 2009.10.18 |
---|---|
Standards and Style for Coding in ANSI C (0) | 2009.10.11 |
추억의 XT 컴퓨터 : GW-BASIC (0) | 2009.10.04 |
Refactoring Tools Review - Part I (0) | 2009.10.03 |
Ansi C 리펙토링 (0) | 2009.10.03 |
[출처] http://www.geocities.com/KindlyRat/GWBASIC.html
GW-BASIC
Download GW-BASIC here! Below we have GWBASIC 3.23, GW-BASIC Manual, Compiler, tutorials, examples and games, all absolutly free. Just click on the blue lettered selection, save and un-zip.
Welcome Modern School of Nagpur
--DIRECTIONS--
Click, download and unzip the following zip files:
GWBASIC.EXE.zip - the complete GW-BASIC 3.23 ( 60.3K )
GWBASIC_Help.zip - a complete GW-BASIC manual by Microsoft in "help" format with indexes and easy to use format. Many thanks to Tom Cloud!
gw-man.zip - a complete GW-BASIC manual by Microsoft in html files. Thanks to Thomas Shaffner. Click on index 2 after downloading. It is an excellent linked index.
Another manual for GW-BASIC.
COMPILER.zip - a GW-BASIC compiler. Read the "read me" for all the information that I know. It outputs a stand alone exe file when compiled with the /O option and linked.
OptionList.zip - a list of options for the GW-BASIC compiler (BASCOM). Some do not work.
Compiling GW-BASIC -porting GW-BASIC to QuickBasic2.0 ( probably our compiler ).
GWCOM.html - an optional list of commands. 12 Jun 2002 by KindlyRat before the above manual was recieved.
exil- a Linux / GW-BASIC converter.
basictut.zip - an optional tutorial by Castcoly Software. After unzipping click BT1 and BT2 and press "page up" and "page down" to read.
Free BASIC Compilers and Interpreters
Norman DeForest - deep research into the GW-BASIC language.
Scott's GW-BASIC / Windows solutions!
IconToBasic - run your favorite BASIC programs from desktop Icons!
BASICtoTEXT - change BASIC to Text (Notepad) files.
GWscan - a program from ScottServer that does the same thing. Check out the other programs too!
Here's another good GW-BASIC tutorial.
Here's a link to a TRS-80 (RadioShack) to Windows translator by AW Software.
hbasic.zip - A version of GW-BASIC for Hercules graphics
Commodore Basic for Windows.
Microsoft Small Basic A new BASIC for Windows!.
font.zip - a font set for GW-BASIC for Hercules graphics
Here's some new fonts for the DOS Box that we use with GW-BASIC, Thanks to Matt Gregory!
-- HINTS --
GW-BASIC was once the main language used on home computers and is still useful in learning the fundamentals of computer programming and smaller utility programs. It still runs on Microsoft Windows computers thru WindowsXP, though not in a window, but on the black screen used for MS-DOS programming above that will pop up when you click on the GWBASIC icon.
GW-BASIC is an interpreted language which means that it isn't compiled. You type the program in or copy and paste it into a text ( Notepad ) file saved with the name and a .BAS suffix, surrounded by quotation marks. Entering "run" will start the program. GW-BASIC uses line numbers and runs and saves files with a ".BAS" suffix in the same file as the interpreter. You can also run a program by "dragging and dropping" the program on top of the interpreter.
You can find a Users Guide and Reference at any good garage sale or library. Also don't forget to check Amazon.com's used books and I found a "Microsoft GW-BASIC Users Guide and Reference" at Half.com for $0.75! If all else fails I have a list of GW-Basic commands for download above and several tutorials and links to tutorials.
---GWBASIC GAMES---
note: these games are for GW-BASIC, BUT can be "LIST"ed and clipboarded and saved to notepad. Then you can load them into other BASIC languages. You may have to change a few lines.
dominoes.zip...a good dominoes game
chess1.zip...chess game by RAKASKA
SLOT.zip...slot machine game by ROCHE FAHLANEIGH
MNPLY.zip...monoply game by ROCHE FAHLANEIGH
bluesbox.zip...a song writing / playing program
checkers.zip...a good but dumb game
SantaParavia.zip...( UNDER DEVELOPMENT )
lemonade.zip...run a lemonade stand
HAMURABI.zip...rule a primitive society
HAMURABI3.zip...rule a primitive society
Slot6.zip...a good slot machine game
Pic3.zip...draws random colorful rectangles
BATNUM.zip...a good math game. add line "110 RANDOMIZE TIMER" for better random numbers
23mtch.zip... an old 23 Match game
aceydu.zip... acey deucy anyone?
buzzwd.zip... a buzzword creator
chomp.zip... two or more players. from ScientificAmerican
craps.zip... a good craps game
stars.zip... a number guessing game
fibonacc.zip... a Fibonacci Series Calculator
mugwmp.zip... find the mugwmp on a 10 X 10 grid
eliza.zip... an artificial intelligence game
nim.zip... a good NIM game, use caps
Scott...BASIC programs
salvo1.zip...an artillery game
---CODE EXAMPLES---
archie.zip...learn Structured BASIC Programming!
BAS-INT.zip...C code for a tiny BASIC interpreter.
gwup07.zip...decodes protected GW-BASIC programs
sequential.zip...demonstrates search, list first and read
circles.zip... random circles in SCREEN1
SDOFRND2.zip... predict future by random generators
snails.zip...population sampeling theory test
PIBAS.zip...PI calculation by the casino method
RootSumSquare.zip... prove a calculation method
factor.zip... finds the factors of numbers
demo2.zip... old Zenith BASIC graphics demo
menuet.zip... PLAY music demonstration
binary.zip...demonstrates search, list first and read
dietest.zip...checks the Random Generator
two-buffer.zip...demonstrates sort of A$, list first and read
bubble.zip...demonstrates sort of A$, list first and read
Mandelbrot.zip...Mandelbrot Fractal demonstration
ListDisk.zip... by Eric Tchong, formats BASIC programs for listing or printing.
SortThem... another Eric Tchong QuickBASIC program that demonstrates sorts.
RanHex.zip...random hexadecimal generator
Cypher.zip...a text encoding program
AnimalVegtableMineral.zip...a game/example that learns
99bob.zip...demonstrates messing around in BASIC
combinations.zip...possible combinations of three numbers
MorseConverter...converts a message to Morse Code.
KindlyRat
Standards and Style for Coding in ANSI C (0) | 2009.10.11 |
---|---|
한글필기체 폰트 (0) | 2009.10.04 |
Refactoring Tools Review - Part I (0) | 2009.10.03 |
Ansi C 리펙토링 (0) | 2009.10.03 |
디지털 타임즈 [알아봅시다] 교육의 틀을 바꾸는 `디지털교과서` (0) | 2009.09.20 |
By Uri Lavi
Cross post from IRefactor
Don Roberts and John Brant stated in the book Refactoring - Improving the Design of Existing Code:
"Refactoring with automated tool support feels different from manual refactoring".Indeed - It is!
한글필기체 폰트 (0) | 2009.10.04 |
---|---|
추억의 XT 컴퓨터 : GW-BASIC (0) | 2009.10.04 |
Ansi C 리펙토링 (0) | 2009.10.03 |
디지털 타임즈 [알아봅시다] 교육의 틀을 바꾸는 `디지털교과서` (0) | 2009.09.20 |
C/C++ Programming Links (0) | 2009.09.02 |
General Remarks
On this page we only want to give an overview on some of the methods we apply in the refactoring of C code. These methods differ from the methods decribed e.g. in Martin Fowlers book about refactoring. One of the reasons is that we developed the methods for C where as Martin Fowler describes them for Java. Another even more relevant reason is that we set up the methods for safety critical microcontroller applications which have to use MISRA C and usually use a defined rigid architecture and design rules. Refactoring in this environment has to follow defined rules. For more details we recommend to read the page on refactoring principles where we go into more details on this subject.
Make the Code Error free according to the MISRA checking Tool
I discussed the ideas of a safe coding in C on the pages about design, therefore I will not repeat it here. The main goal of this refactoring step is to let an automatic code checking tool run on your code and analyze its output log file. These tools come up with most of the important errors you can bring into a C-program while you code. These are potential erros like the:
if (a = b){... some code ...}
where almost certainly it was meant to be:
if (a == b){... some code ...}
The tool will also come up with error messages concerning suspicious type casts. If you have:
void my_function(void)
{
unsigned char x;
unsigned short y;
... some code ...
x = y;
... some code ...
}
The assignment of y to the variable x will lead to a loss of the upper 8 data bits. This may be perfectly o.k. because your data range of y is within 8 bit. Then you can do a simple type cast to solve the problem:
void my_function(void)
{
unsigned char x;
unsigned short y;
... some code ...
x = (unsigned char)y;
... some code ...
}
Refactoring at this point has to check the possible data ranges and find a satisfying solution for the problem. This may be a simple type cast to keep the checking tool silent, but it also may mean a bigger re-design of the code portion to avoid the loss of bits in an assignment.
The overall goal is to work on the code util the checking tool does not report any more errors. This will guarantee a certain quality of the code, which is suitable for safety critical systems.
Get rid of Bitfields
The bitfields in focus here are the so called ANSI-bitfields. They are commonly named that way because they already have been defined in the old ANSI-C standard (1989). They are defined as follows:
struct BF {
int bit0:1;
int bit1:1;
int bit2:1;
int bit3:3;
int bit4:1;
int bit5:1;
int bit6:1;
} bitfield;
The access to the individual bit is done as:
bitfield.bit1 = 1;
There are several problems involved in these bitfields. First of all not all compilers allow the same kind of definitions. Some compilers allow multiple data types as e.g. "unsigned short" or "unsigned char" for the definition of the individual bits. The data types can be all basic data types and they can be mixed in the same struct definition. Other compilers rigidly stick to the old ANSI definition which only allows the datatype "int" for the bits and multibit fields in the struct (multibit fields have e.g. the size of 3 bits in our example). However if you are forced to use the data type "int" in reality it makes the individual bit a signed number of the value -1. Therefore if you use a bit in any calculation it will use the -1 or 0 for the calculation although you most likely would expect it to be 1 and 0. This means you have a problem due to unexpected values in your calculation but you also may have a problem with the portability of your code. Only if you restriced yourself to using "int" as datatype for the bits you can be sure that your code is portable across all compilers.
Another problem is that the memory representation of your ANSI-bitfield is completely implementation dependent. You simply do not know how the stuff is stored in the memory. This means you can not access it as a complete word, character or long variable. Such a way of accessing the bitfield may come in handy if you think of a fast initialization. You could initialize the bitfiled by writing to it as a word variable and assigning 0 to it. Since you do not know how it is represented in memory you are forced to initialize it bit by bit via the symbolic expression. Another problem due to the various memory representations may occur if you have to store memory data e.g. to a file in one CPU environment and reload the data in another environment with a different memory representation of bitfields.
Because of these problems I came up with a method to use normal variables such as unsigned short or unsigned long as bitfields. With some smart macros I can set a bit e.g. with the expression bitfiled |= 0x8000; and reset the same bit with the expression bitfield &=~ 0x8000; With a couple of defines for the bits and the operations this leads to an easy to use method for bitfields which can be also accessed as normal variables. Their size is the size of the basic datatype used in the definition. I also came up with some functions to read and write the multibit fields inside a bitfield. They look a bit complex, but runtime measurements showed that this way of dealing with bitfields is even faster than the operations on ANSI-bitfields.
Because of these problems you should have a refactoring step which replaces all ANSI-bitfields with the smarter and less problematic solution.
Data Types have to be used according to the Design Rules
In the design rules I set up we first of all prohibited all floating point variables. Only a few microcontrollers have a floating point unit and can handle them without overhead. A micro which does not have a FPU will go into quite lengthy library calls to deal with them. This is simply a runtime killer. On top of it there was never a series application which really required the precision and data range of floats. Another problem is that floats are a bit tricky in compare operations (if, for, while, etc.). The expression if (a == b) will be rarely fulfilled if both or one of the variables is a float. The same is true for loops. For these reasons I banned floating point values completely out of all systems I was responsible for.
Other datatype issues are mainly related to the mixing of datatypes. You should avoid mixing signed and unsigned calculations. Bring everything to the one kind. However if you are forced to mix them you should make sure that the conversions are save and e.g. the signed value is definitely not negative before you assign it to an unsigned value. Or have you ever seen this example?:
int main(void)
{
unsigned char x;
x = ~0xAA;
if (x == ~0xAA)
{
printf("I should come out here\n\n");
}
else
{
printf("I should not be here\n\n");
}
getchar();
}
Everybody would expect to come out in the "I should come out here" branch. But it doesn't! The problem comes from the implicit promotion (8bit -> 16bit) the C compiler performs and then it casts it back to 8bit. A problem due to the implicit mixing of datatypes. The refactoring should take care of this and bring the code into a save condition.
No Global Variables
I described the danger of global variables sufficiently in the design section of this web-site and there is no need to repeat it here. It is also against the idea of object orientation to have global variables. One of the outstanding features of object orientation is that the data are combined with the operative code lines in the same module and that these data are encapsulated. This means that they can not be accessed from other modules (object) except via the defined get-function. If your code needs global variables it is suffering from much more serious design sins and should be refactored to conform to a true object oriented design. After you have done this it should be no problem to make the global variables at least static and thus not linkable for other modules.
Standard C-Libraries avoided?
Most programmers will be puzzled by this demand to get rid of the use of standard C-Libraries. But here I am talking about safety critical microcontroller applications. The demands of the related international standards show clearly that your source code has to undergo certain quality and test measures before it can be certified in the used system. In other words there is a big fuzz about the code YOU wrote and then you just use the code SOMEBODY ELSE wrote in the form of standard libraries. And on top of it, in most cases you do not even have the source code of the library so that you are not even able to see how it was done. What? Do you believe this code is perfect just because it was sold to you when you bought your compiler? Fairytales! It was done by programmers and they make mistakes. If you want to have the control of what is happening in your safety critical system you must not use third party software and if you have to use it for some reason it has to be transparent regarding the source code, the tests which have been performed on it and the other quality measures which were employed. Usually you do not get this proof. You just get a heap of binaries. Make your own libraries, test them according to the required measures by the international standards and make sure by refactoring that it is used everywhere in your code.
Check the Control and Data Flow
As indicated in the design section a good system should be data flow driven in its design and the data flow should be uni-directional as far as possible. This means that the outputs which have to be generated by the system need certain data. The output should aquire the data it needs to perform the output. This data is processed in some way and in turn relies on further data, until you reach the inputs of your system. In other words your objects should have get-functions but preferably no set-functions. Make sure in the refactoring phase that this design princple is adhered to. It may mean bigger changes in the design if you have to restructure the code, but it is worth while.
Use defined Naming Conventions
Naming conventions are a bit formalistic and thus not very highly esteemed. However if you name your variables, functions and modules consistently and according to a defined system you will have the great benefit that everybody will immediately know what the code is all about. Starting from the programmer himself, the colleagues who does a review, the next programmer who wants to re-use it or do maintenance on it, the tester, all will benefit from it. I will not go into the naming convention itself since I did this on another page, but use this refactoring method and apply the naming convention to make the code better understandable.
Use defined Templates
Define templates for your code and use them! There should be clearly identified sections where you put typedefs, defines, function prototypes, the source code itself, etc. etc. The reasons are similar to those for using defined names for variables and functions. It makes the whole code better understandable and everybody knows where to find what.
Keep the Header Structure simple
Some years ago I came as a newcomer into a project and tried to get all the code and headers collected and tried them to compile. It took me three days to succeed! O.k. there were some configuration managent problems and I had to get some files from certain colleagues instead of beeing able to get it from the code repository. But most of the time I wasted with finding out which headers I needed to get in which of their versions. Finally, after I succeeded, I found that for the literal handful of source code modules I needed almost 50 different header files which were nested, had cross includes and all sorts of dependencies. Many of the headers were included because a single define was needed out of the hundreds it contained. I cleaned it out after I was put in charge of the design. Now the same software needs 5 headers and they do not have any dependencies, cross includes or circular includes. And they are single level includes i.e. there are no nestings. The refactoring step needs to be based on a clear concept and "design" of your headers. You need to know what headers there shall be and what they have to contain. Then make sure that they do not depend on each other. Include them in the right sequence rather than making nestings. The following example shows how to reduce the nestings:
The header file macros.h makes use of a basic data types in the form of a redefinition of "unsigned short"
#define HIGEST_BIT(T_UWORD)0x8000
In order to be able to do this the file macros.h should include the file which contains the redefinition of "unsigned short"
#include"datatypes.h"
#define HIGEST_BIT(T_UWORD)0x8000
The datatype.h file contains the following define:
typedef unsigned shortT_UWORD;
But the problem is that many other headers will also need these data type redefinitions. Now imagine that the same happens with other defines which are located in other headers. The result is a nested header structure with circular and cross includes, like the one I described above. The solution is quite simple. You just have to prohibit sub-includes completely, and then after you have set up a clear concept what shoud be in which header, simply include the headers in the right sequence in your source files:
#include"datatypes.h"
#include"macros.h"
Then all headers which are included after the inclusion of the datatypes have them available and do not need to include it for themselves.
Split up C-Functions
There are a few indicators which tell you if a C-function should be split up or not. One of the indicators is the parameter list. If the pass parameters to a function are more than 4 then you should have a closer look to find a way to split up the function. The number of 4 is based on the usual number of parameters which can be passed to a function in CPU registers. If you have more parameters they go on the stack. This value may differ depending on the CPU and compiler you use. In some cases this may be six parameters, but not more. This rule is concerned about the runtime and resources of your application, but at the same time it can be said that the more parameters a function has the more complex it is. A condidate to be split in several smaller functions.
I have seen functions with 40 input interface variables. Not as pass parameters but as global variables. A closer look showed that the function contained a number of independent sections. Each section had e.g. 10 code lines and used 5 of the variables, but the sections were not related to each other in any way. This was an ideal candidate to make a function out of each of these sections and use a pass parameter interface to hand them the needed data. Generally speaking if a functions is bigger than what you can display on a single screen page you should find a way to split it up.
Use temporary Variables the Right Way
There are some commonly practiced sins concerning local variables. First of all you should not write to a variable which came in by the pass parameter interface. It is an input and a good programming style is that you never ever ovewrite an input. Neither a temporary variable which came in via the pass parameter interface nor static or global data. Always open a new variable if you have to modify something on your inputs. If you do not observe this it may be hard to test your software.
Secondly avoid to reuse the same local variable for different purposes. I saw programs which had a variable called "temp" and it was used in sequence as a loop counter, for storing intermediate calculation results, etc. etc. Open an own variable for each of these purposes. If you fear that you end up with too many local variables in your function and that they are therefore put on the stack, you should split the function!
Use local variables for all operations in your function and interface to the outside world i.e. static variables or get-functions of other objects at the beginning and at the end of your function. This advise is contrary to what you find in other refactoring literature but there are some good reasons for it. First of all there is the subject of runtime again. If you call a get-function multiple times in a piece of code, the function will a be always called and executed. This generates some overhead because in order to call a function the address of the next instruction after the function call will be stored on the stack, some registers may be saved to the stack, there has to be a jump to the called function and finally a jump back to the stored next instruction of your calling program part. All this is some overhead if you compare it to simply accessing a variable in memory. Therefore call the sub-function once and use the value which will be held in a register throughout your part of the program. This is a trade off between an object oriented design on the one hand and an optimized speed on the other hand. The same is true for the use of static data in your piece of code. If a variable which is residing permanent in the memory is used multiple times the program will always do a fetch from the memory each time it comes across the variable. This fetch operation will also consume extra time which you can avoid if the value is loaded to a register (local variable) and then used in the program. The following example will illustrate this. It uses a pseudo Assembler code to illustrate what operations are performed by the CPU on the memory to run through a sequence of code lines:
void my_function()
{
... some code ...
if (My_StaticValue < -8191) Register1 = Memory(My_StaticValue)
Register2 = -8191
Register1 COMPARE TO Register2
{
My_StaticValue = -8191; Memory(My_StaticValue) = Register2
}
else
{
if (My_StaticValue > 8191)Register1 = Memory(My_StaticValue)
Register2 = 8191
Register1 COMPARE TO Register2
{
My_StaticValue = 8191;Memory(My_StaticValue) = Register2
}
}
}
Now I show the example of the same code lines if the value is not residing in memory, but is coming in by the pass parameter interface:
void my_function(My_Value)Register1 contains My_Value
{
... some code ...
if (My_Value < -8191)
Register2 = -8191
Register1 COMPARE TO Register2
{
My_Value = -8191; Register1 = Register2
}
else
{
if (My_Value > 8191)
Register2 = 8191
Register1 COMPARE TO Register2
{
My_Value = 8191;Register1 = Register2
}
}
}
As you can see the second design option uses less code lines and therefore executed faster. Less code simply means faster execution. But on top of it you have to consider that the access to the memory is a slow operation. A line accessing the memory can take double or even more of the time that an operation using registers would take. There are influences like the waitstates and other bus issues which slow down these operations.
But there is another subject which gives us a good reason for interfacing to the outside world and using temporary variables inside the function. As you can see in the above example concerning the data types the implicit promotion and type casting mechanism of C-compilers can play quite nasty tricks on you. By interfacing every used variable to locals you can use local variables which are of the natural bit size of the registers and thus avoid automatic promotion by the compiler. With other words you simply perform a step explicitly which would be done by the compiler anyway implicitly without you being aware of it. The casting and promotion between the various bit sized variable types is under your control after you did this refactoring step. In a code for a 16 bit CPU could look like:
unsigned short my_function(unsigned char my_offset)
{
unsigned short x;
unsigned short y;
x = (unsigned short)my_StaticCharacterX;
y = (unsigned short)my_StaticCharacterY;
if (x <= y)
{
x = y + (unsigned short)my_offset;
}
else
{
x = y - (unsigned short)my_offset;
}
return(x);
}
Resolve multiple Definitions
Have you ever seen data definitions using a struct in a struct in a struct in a blabla and so on?
There is the feeling of the programmer or some other reason to group data together in structs. Certainly there is a place for structs in C but nesting them over more than one level turns into a nightmare. The access to an element would then look like:
My_struct.my_first_substruct.my_second_substruct.yet_another_struct.element = 1;
Because this is quite a mouth full and turns unreadable in the code smart programmers tend to have the idea to make defines to shorten the "mouth full". Then they do something like this:
#define STRUCT_L1 My_struct.my_first_substruct
#define STRUCT_L2 STRUCT_L1.my_second_substruct.yet_another_struct
#define MY_ELEMENT STRUCT_L2.element
And after they did this proud piece of redefinitions they are going to use "MY_ELEMENT" in their code. The result is that the person doing maintenance or testing on these structures and their redefinitions will simply go coo coo after a day of work trying to find the bottom of this swamp. No joke, I have seen nestings of ten levels and more! Get rid of this. Beak it up. There is no logical reason for grouping every single variable or constant used in the system in ONE struct. There are ways you can convince your linker to pack stuff together in the memory, and there are ways to break up the monster structs into smaller ones. Simple basic data types, simple and small structs, if needed a few arrays, that's what you should go for and your refactoring should achieve this.
Use Defines instead of Fixed Numbers
This is a simple refactoring method. Instead of using fixed values like 3.14 you should make a define like:
#define PI 3.14
Then in your code you should write "PI" instead of typing "3.14" at the places you need the constant. This makes the code better understandable, especially if your defines have sensible names. Further you can easily change the define at one place and all your code uses the updated value. Of course only if you used the define consequently at all places. This will avoid to have inconsistencies in case a constant changes. No need to look through all the modules in this case. The change is effiective at all places.
Avoid Function like Macros
Some programmers love function like macros. They seem to use them at every possible occasion. However they have a number of problems and therefore I prohibited them in all projects I was responsible for. Let's look at one of the problems. Imagine we have the following macro to do an absolute value calculation:
#define abs(x) (x>0)?x:-x
Then we use the macro in the follwoing code lines:
int main(void)
{
int b;
int c;
int y;
b = 5;
c = 7;
y = abs(b-c);
}
What you would expect is the result of 2 being assigned to y, because 5 - 7 equals to -2 and the absolute value of -2 is 2. But the function like macro does not do the trick. The actual result is -12 which is simply wrong. The reson for this is that the macro undergoes a text replace and thus the code line y = abs(b-c); extends to:
y = (b-c>0)?b-c:-b-c
Therefore the result is -b-c which is -12.
There are other problems with macros. If you do not explicitly use type casts to make the involved variables the data types you define, they will be automaitcally promoted to "int", which could involve the change of the sign and the bitsize of the value. This also leads to anwanted effects. I simply prohibited them because there is no logical reason for having them. Just make a simple function out of it and if you fear the overhead make the function "inline" and it will be extended to every code portion where the function is called, just like a macro would be, however without the dangers I just pointed out. Just one further hint. Inline functions need to be in the same module as the code which makes use of them, but if you put the inline function into a header it even can be used by every module which includes the header. For this subject you should disregard the MISRA standard. MISRA has no problem to allow function like macros (although they come up with some restrictions) but the 2004 MISRA it prohibits in rule 8.2 to put code into a header. At this point the standard is simply stupid and incorrect and you should do your own sensible rules here, like I pointed out in this refactoring step.
Simplify logical Conditions
Some multiple conditions in C-programms can be very hard to comprehend, and they are even harder to be tested. The same is true for nested "if" conditions. The following line may serve as an example:
if((a == b) || (c == y) || (z != a)) { printf("hello world");}
You can split this up into a few simple if conditions which make it much easier to see what is going on:
tmp = 0;
if(a == b) tmp = 1;
if(c == y) tmp = 1;
if(z != a) tmp = 1;
if (tmp == 1) printf("hello world");
Sorry for this simple example. It should show the principle of this refactoring step. If you look at the assembler lines the compiler makes out of the two examples you will find that the effort is almost the same and runtime or other resource issues can not be an argument against it. But it is much easier to be understood and it is much easier to modify it and test it.
Cut your Modules the Right Way
How should your modules look like? There are a few simple metrics which can help you to set them up in a way that they have a good size. As already mentioned each function in a module should not be bigger than what can be displayed on on screen page. Then there is the number of get-functions in a module. More than 20 is definitely too much and it is an indicator that you should find a way to split it up. Between 10 and 20 is o.k. if it can be justified that the module is good this way. 10 or less get-functions is ideal. Set-functions should be the exception in order to keep the data flow unidirectional. The number of private functions (sub-functions only used inside the same module) can be as much as needed. Again their size should be not bigger than a screen page. If there are very many very little ones you should also have a look into the design of the module. The number of public functions (except get-functions) should not exceed 3. In addition to that there may be a init-function which initializes the module. These numbers are values from experience and could be found in good design I saw so far.
In addition to that you should have a look at the interfaces of a module (object). The best is if they have basic data types. If you have arrays and structs (i.e. pointers to them) at the interfaces you should have a second look to see if this can be avoided. Very often you can get rid of such an interface by simply moving one function from one module to another.
Last but not least you should always make sure that your modules constitute objects in the sense of object orientation. I.e. they should represent an object of the real world, e.g. a sensor, a switch, a solenoid. Of course you should also make sure that you have an architecture which defines layers in your software (e.g. a HW-abstraction layer). All these principles should influence your refactoring activities on the size and shape of your modules.
추억의 XT 컴퓨터 : GW-BASIC (0) | 2009.10.04 |
---|---|
Refactoring Tools Review - Part I (0) | 2009.10.03 |
디지털 타임즈 [알아봅시다] 교육의 틀을 바꾸는 `디지털교과서` (0) | 2009.09.20 |
C/C++ Programming Links (0) | 2009.09.02 |
대학시절 자료복구[일부] http://comphy.iptime.org/~old/ (0) | 2009.08.31 |
Refactoring Tools Review - Part I (0) | 2009.10.03 |
---|---|
Ansi C 리펙토링 (0) | 2009.10.03 |
C/C++ Programming Links (0) | 2009.09.02 |
대학시절 자료복구[일부] http://comphy.iptime.org/~old/ (0) | 2009.08.31 |
PocketPC 일본어 (0) | 2009.08.27 |
[출처] http://www.gtkforums.com/about988.html
C Programming Tutorials
Note: They reason for all of they differant C tutorials is because some explain a particular language features better than others.
C Programming 2nd Edition
This is the classic c book read this if you want to learn c.
[PDF] http://madison-project.wikidot.com/local--files/tutorials/The_C_Programming_Language.pdf
Another Good C Programming Site/Tutorial
[Html] http://www.exforsys.com/tutorials/c-language/c-programming-an-overview.html
More Good C Tutorials
[Html] http://irc.essex.ac.uk/www.iota-six.co.uk/c/
All the C you need to know for GTK+
[Html] http://www.freesoftwaremagazine.com/articles/all_the_c_you_need_for_gtk_development
[Pdf] http://www.freesoftwaremagazine.com/node/2543/pdf
Small C Tutorial from randu.org
[HTML] http://randu.org/tutorials/c/index.php
C Reference Card (ANSI) "Note: Needs to be replaced with one that is easyer to read"
[Pdf] http://users.ece.utexas.edu/~adnan/c-refcard.pdf
A Tutorial on Pointers and Arrays in C.
[Html] http://pweb.netcom.com/~tjensen/ptr/pointers.htm
[Pdf] http://pweb.netcom.com/~tjensen/ptr/pointers.pdf
A Tutorial on Pointers and Memory
[Pdf] http://cslibrary.stanford.edu/102/PointersAndMemory.pdf
If you need small straight to the point examples on how to use differant C lang features & functions.
[Html] http://www.java2s.com/Tutorial/C/CatalogC.htm
[Html] http://www.java2s.com/Code/C/CatalogC.htm
ISO/IEC 9989 Committee Draft "See Annex A (Language syntax summary) this is usefull if you want to build a C syntax parser that can do (Symbol name auto-completion & Symbol lists ) for a Gtk+ code editor."
[HTML] http://www.open-std.org/JTC1/SC22/WG14/www/docs/n1124.pdf
Glibc Tutorials
Multi-Threaded Programming With POSIX Threads
[Html] http://users.actcom.co.il/~choo/lupg/tutorials/multi-thread/multi-thread.html
Embedded Scripting
How to create C/Lua module with swig.
[pdf] http://madison-project.wikidot.com/local--files/tutorials/C_Lua_Swig.pdf
Lua Swig Tutorial
[Html] http://www.swig.org/Doc1.3/Lua.html
How to use Lua with C.
[Html] http://www.gtkforums.com/viewtopic.php?t=1995
How to use Python with C
[HTML] http://www.gtkforums.com/viewtopic.php?p=9055#9055
Gtk+ Programming Tutorials "GUI Toolkit"
GTK+ 2.x Tutorial for Beginners
This tutorial is for beginners describing some of the most common widgets.
[HTML] http://zetcode.com/tutorials/gtktutorial/
How to set the color of a widget
[HTML] http://ometer.com/gtk-colors.html
Gnome2 Developers Guide "Gtk+ 2.0"
[PDF] http://home.cs.tum.edu/~siegel/files/tog2dg.pdf
Gtk+ 2.0 Tutorial
[HTML] http://library.gnome.org/devel/gtk-tutorial/stable/
Gtk+ 2.0 Tree View tutorial
[HTML] http://scentric.net/tutorial/treeview-tutorial.html
[PDF] http://scentric.net/tutorial/treeview-tutorial.pdf
Sources link for the treeview tutorial: http://scentric.net/tutorial/treeview-tutorial.tar.gz
Gtk+ 2.0 Text View tutorial
[HTML] http://www.bravegnu.org/gtktext/
[PDF] http://www.bravegnu.org/gtktext/gtktext-0.4.pdf
Gtk+ 2.0 GtkComboBox Widget Tutorial
[HTML]Part1 http://tadeboro.blogspot.com/2009/04/gtkcombobox-widget-part-1.html
[HTML]Part 2 http://tadeboro.blogspot.com/2009/04/as-promised-im-back-with-second-part-of.html
[HTML]Part 3 http://tadeboro.blogspot.com/2009/04/gtkcombobox-widget-part-3.html
GtkDialog tutorial
[HTML] Part 1: http://tadeboro.blogspot.com/2009/04/gtkdialog-tutorial-part-1.html
[HTML] Part 2: http://tadeboro.blogspot.com/2009/04/gtkdialog-tutorial-part-2.html
Wrapping and resizing GtkLabel dynamically
[HTML] http://tadeboro.blogspot.com/2009/05/wrapping-adn-resizing-gtklabel.html
Using pop-up windows
[HTML] http://tadeboro.blogspot.com/2009/05/using-pop-up-windows.html
Gtk memory management in a nutshell
[HTML] http://www.gtkforums.com/viewtopic.php?t=2412
Glade & Gtk+ Tutorials "Gtk+ Gui Designer"
GTK+ and Glade3 GUI Programming Tutorial
[HTML] http://www.micahcarrick.com/12-24-2007/gtk-glade-tutorial-part-1.html
Creating GtkTreeView with Glade-3
[HTML] Part 1: http://tadeboro.blogspot.com/2009/04/creatin-gtktreeview-with-glade-3.html
[HTML] Part 2: http://tadeboro.blogspot.com/2009/04/creating-gtktreeview-with-glade-3-part.html
Speeding up libglade by precompiling xml-files into shared objects
[PDF] http://syslog.movial.fi/uploads/compiled-libglade.pdf
Glib Tutorials "Gtk+ Utility Library"
Using GLib's GKeyFile Parser
[HTML] http://www.gtkbook.com/tutorial.php?page=keyfile
GNOMEnclature: The wonders of GLib
[HTML] Part 1: http://www.ibm.com/developerworks/linux/library/l-glib.html
[HTML] Part 2: http://www.ibm.com/developerworks/linux/library/l-glib2.html
Writing Unit Tests with GLib
[Html] http://blogs.gnome.org/timj/2008/06/24/23062008-writing-unit-tests-with-glib/
Looks like the start of a glib tutorial "Dated 2008"
[Html] http://w00d5t0ck.info/gnome_tutorial/gnome_tutorial.html
GObject tutorial
[HTML] http://madison-project.wikidot.com/local--files/tutorials/gobject-0.10.0-html.tar.gz
Hildon "Hildon is a user interface toolkit based in GTK that targets mobile devices."
Hildon Tutorial
[HTML] http://maemo.org/api_refs/5.0/beta/tutorial/html/
Pango Tutorials "Gtk+ Text Formating & Rendering Library"
The Pango connection:
[HTML] Part1: http://www.ibm.com/developerworks/library/l-u-pango1/
[HTML] Part 2: http://www.ibm.com/developerworks/library/l-u-pango2/
Cairo "2D Vector Graphics Library"
Cairo graphics tutorial.
It is done in the C programming language.
This tutorial is for beginners and intermediate developers 100+ pages.
[HTML] http://zetcode.com/tutorials/cairographicstutorial/
Cairo Concepts
A one-of-a-kind introduction to cairo concepts and models.
[HTML] http://cairographics.org/tutorial/
Writing a Widget Using Cairo and GTK+ 2.0
[HTML] Part1: http://www.gnomejournal.org/article/34/writing-a-widget-using-cairo-and-gtk28
[HTML] Part2: http://www.gnomejournal.org/article/36/writing-a-widget-using-cairo-and-gtk28-part-2
Clutter "2D/3D Multimedia Toolkit" - "Gtk+, Cairo, Gstreamer, Libvlc, Webkit, MD2, Mozembed plugins available."
Programming with Clutter 0.8
[Html] http://www.openismus.com/d0cuments/clutter_tutorial/0.8/docs/tutorial/html/
[Pdf] http://www.openismus.com/d0cuments/clutter_tutorial/0.8/docs/tutorial/pdf/programming-with-clutter.pdf
Programming with Clutter 0.9
[HTML] http://www.openismus.com/d0cuments/clutter_tutorial/0.9/docs/tutorial/html/index.html
Clutter Plugins
Gtk+, Cairo, Gstreamer Plugins
http://www.clutter-project.org/sources/
Webkit Plugin
git clone git://git.o-hand.com/webkit
VLC Plugin
http://github.com/rno/clutter-vlc/tree/master
MD2 Plugin
http://github.com/bpeel/clutter-md2/tree/master
Mozembed Plugin
http://git.clutter-project.org/cgit.cgi?url=clutter-mozembed/tree/tests
Gstreamer Tutorials "Audio, Video Multimedia Toolkit"
GStreamer is a multimedia framework written in the C programming
language with the type system based on GObject."
Application Development Manual:
[HTML] http://gstreamer.freedesktop.org/data/doc/gstreamer/head/manual/html/index.html
[PDF] http://gstreamer.freedesktop.org/data/doc/gstreamer/stable/manual/manual.pdf
Plugin Writer's Guide :
[HTML] http://gstreamer.freedesktop.org/data/doc/gstreamer/head/pwg/html/index.html
[PDF] http://gstreamer.freedesktop.org/data/doc/gstreamer/stable/pwg/pwg.pdf
GStreamer Quick Hello World type Tutorial
[HTML] Part1: http://bluwiki.com/go/GStreamer
[HTML] Part2: http://bluwiki.com/go/GStreamer/C_Hello_World
GStreamer Plugin Development Video
* An introduction to GStreamer terms, usage and the GStreamer pipeline model.
* Construction of simple pipelines using available GStreamer elements, building a video decoding pipeline
* Look at the requirements for various types of processing elements: Data sources, sinks, filters, converters.
* Development of a simple custom plugin for processing raw video frames
* Extending the custom element in various ways, to render video effects, provide custom communication with the application.
Participants should be familiar with GObject/GLib, as GStreamer code relies heavily on both.
[HTML] http://lca2007.linux.org.au/talk/272.html
[VIDEO] http://mirror.linux.org.au/pub/linux.conf.au/2007/video/talks/272.ogg
Opengl Tutorials "3D Graphics Library"
OpenGL Programming Guide "RedBook"
[PDF] http://madison-project.wikidot.com/local--files/tutorials/OpenGL_Programming_Guide.pdf
OpenGL Reference Manual "BlueBook"
[Pdf] http://madison-project.wikidot.com/local--files/tutorials/OpenGl_Reference_Manual.pdf
GtkGLExt is an OpenGL extension to GTK+ 2.0 or later
[HTML] http://www.k-3d.org/gtkglext/Main_Page <-- Download source for lots of C/Gtk+ example code.
osgGtk is a library of C based Gtk+ and C++ based Gtk-- widgets to support OpenSceneGraph (OSG) applications.
The library also includes several example applications such as osgviewerGtk and osgviewerGtkmm.
[HTML] http://osggtk.wiki.sourceforge.net/main <--Download source for C/Gtk+ example code.
Lexical Analyzer & Parser Generator
Lex & Yacc / Flex & Bison Primer
[Html] http://ds9a.nl/lex-yacc/cvs/output/lexyacc.html#toc1
A little manual for Lex and Yacc
[Html] http://pltplp.net/lex-yacc/
Flex Manual "Lex"
[Html] http://flex.sourceforge.net/manual/
Bison Manual "Yacc"
[Html] http://www.gnu.org/software/bison/manual/html_mono/bison.html
[Pdf] http://www.gnu.org/software/bison/manual/pdf/bison.pdf
Markup language Note: You will find API References and example usage on the provided links.
LibYAML is a YAML 1.1 parser and emitter written in C.
[Html] http://pyyaml.org/wiki/LibYAML
MJSON M's JSON parser is a small library completely written in plain ISO C which handles d0cuments described by the JavaScript Object Notation (JSON) data interchange format.
[Html] http://mjson.sourceforge.net/index.html
LibAxl (or just Axl) is an implementation of the XML 1.0 standard specification written in C
[Html] http://www.aspl.es/axl/
Libxml2 is the XML C parser and toolkit developed for the Gnome project
[Html] http://www.xmlsoft.org/
Libcroco is a general CSS parsing and manipulation library written in C for the GNOME project. It provides a CSS2 parser (SAC and CSSOM API), and a CSS2 selection engine. It uses Libxml2 as underlying XML platform and the GLib as a portability layer.
[Html] https://launchpad.net/libcroco
Portable Document Format (PDF)
Poppler "Poppler is a PDF rendering library and is used with cairo to render PDF's"
[HTML] http://poppler.freedesktop.org/
[Example Viewer] http://www.gtkforums.com/viewtopic.php?p=9086#9086
libharu "libHaru is a free, cross platform, open source library for generating PDF files."
[HTML] http://libharu.org/wiki/Main_Page
[HTML] http://libharu.org/wiki/Documentation
[NOTE] Cairo can also produce PDF's but libharu does a way better job and has tons more features.
Programming & Hardware
The Linux Kernel Module Programming Guide
[Html] http://tldp.org/LDP/lkmpg/2.6/html/index.html
Bluetooth for Programmers "Describes Basic Bluetooth Concepts"
[PDF] http://people.csail.mit.edu/rudolph/Teaching/Articles/PartOfBTBook.pdf
An Introduction to Bluetooth Programming
[Html] http://people.csail.mit.edu/albert/bluez-intro/
LibParted Handbook "Note: LibParted is a library used to create, destroy, resize and copy PC disk partitions"
[Html] http://www.ilug-cal.org/wiki/index.php/Libparted_Handbook
HAL Tutorial "Hardware abstract layer"
[HTML] http://www.share-linux.com/hal1.php
[HTML] http://www.share-linux.com/hal2.php
[PDF] http://madison-project.wikidot.com/local--files/tutorials/Hal_Tutorial.pdf
LIRC Programming Guide "LIRC is a package that allows you to decode and send infra-red signals of many (but not all) commonly used remote controls."
[HTML] http://www.lirc.org/html/technical.html#applications
Libusb Programming Tutorial "libusb is a suite of user-mode routines for controlling data transfer to and from USB devices on Unix-like systems without the need for kernel-mode drivers."
[HTML] http://www.linuxforums.org/forum/linux-tutorials-howtos-reference-material/10865-developing-usb-device-drivers-userspace-using-libusb.html
Libburnia Api Referance and Code Examples "libburnia is a project for reading, mastering and writing optical discs. Currently it is comprised of libraries named libisofs, libburn, libisoburn, a cdrecord emulator named cdrskin, and an integrated multi-session tool named xorriso. The software runs on Linux and FreeBSD."
[HTML] http://api.libburnia-project.org/libburn/
[HTML] http://api.libburnia-project.org/libisofs/index.html
[HTML] http://api.libburnia-project.org/libisoburn/
Libmtp "libmtp is a LGPL library implementation of the Media Transfer Protocol (MTP), a superset of the Picture Transfer Protocol (PTP). "
[HTML] http://libmtp.sourceforge.net/index.php <--Download for API Reference and Examples
Libgpod "libgpod is a shared library to access the contents of an iPod. It supports playlists, smart playlists, playcounts, skipcounts, ratings, podcasts, and cover art. Audio and video are supported, as well as the photo database."
[HTML] http://www.gtkpod.org/libgpod/docs/ <--Download for Examples
Libgphoto2 "libgphoto2 is the core library designed to allow access to digital camera by external programs."
[HTML] http://www.gphoto.org/proj/libgphoto2/ <-- Download for API Reference and Examples
V4L2 "Video4Linux2 or V4L2 is a video capture application programming interface for Linux. Several USB webcams, TV tuners, and other devices are supported. Video4Linux2 is closely integrated with the Linux kernel. Video4Linux2 was named after Video for Windows (which is sometimes abbreviated "V4W"), but is not technically related to it."
[HTML] http://v4l2spec.bytesex.org/spec-single/v4l2.html#AEN163
DBus Tutorial "Message bus system"
[HTML] http://www.share-linux.com/dbus1.php
[HTML] http://www.share-linux.com/dbus2.php
[PDF] http://madison-project.wikidot.com/local--files/tutorials/Dbus_Tutorial.pdf
Database Programming
MySQL Database C API proramming tutorial
[Html] http://zetcode.com/tutorials/mysqlcapitutorial/
PostgreSQL
-------------
PostgreSQL Database libpq C API tutorial
[HTML] http://www.postgresql.org/docs/8.4/static/libpq.html
Accessing PostgreSQL From Code (Beginners C)
[HTML] http://tutorials.freeskills.com/professional-linux-programming-part-1-accessing-postgresql-from-code.htm
Berkley DB C API
-----------------
Getting Started with Data Storage:
[Pdf] http://www.oracle.com/technology/d0cumentation/berkeley-db/db/gsg/C/BerkeleyDB-Core-C-GSG.pdf
[Html] http://www.oracle.com/technology/d0cumentation/berkeley-db/db/gsg/C/index.html
Getting Started with Transaction Processing:
[Pdf] http://www.oracle.com/technology/d0cumentation/berkeley-db/db/gsg_txn/C/BerkeleyDB-Core-C-Txn.pdf
[Html] Getting Started with Transaction Processing
Getting Started with Replication:
[Pdf] http://www.oracle.com/technology/d0cumentation/berkeley-db/db/gsg_db_rep/C/Replication-C-GSG.pdf
[Html] http://www.oracle.com/technology/d0cumentation/berkeley-db/db/gsg_db_rep/C/index.html
Referance Guide:
[Html] http://www.oracle.com/technology/d0cumentation/berkeley-db/db/ref/toc.html
Programmatic API:
[Html] http://www.oracle.com/technology/d0cumentation/berkeley-db/db/api_c/frame.html
Hamster DB
--------------
[Site] http://hamsterdb.com/index
[PDF] http://hamsterdb.com/public/dl/tutorial.pdf
[Examples] http://hamsterdb.com/d0cumentation/samples
Sqlite embedded database.
[HTML] http://souptonuts.sourceforge.net/readme_sqlite_tutorial.html
Archiving Libraries
SCZ
[HTML] http://scz-compress.sourceforge.net/
[API] http://scz-compress.sourceforge.net/api.html
QuickLZ
[HTML] http://www.quicklz.com/manual.html
[Examples] http://www.quicklz.com/download.html
Zlib
[HTML] http://www.zlib.net/zlib_docs.html
[Examples] http://www.zlib.net/zlib_how.html
Libarchive "C library and command-line tools for reading and writing tar, cpio, zip, bzip , gzip, ISO, and other archive formats"
[HTML] http://code.google.com/p/libarchive/
Network Libraries
Licurl "libcurl is a free and easy-to-use client-side URL transfer library, supporting FTP, FTPS, HTTP, HTTPS, SCP, SFTP, TFTP, TELNET, DICT, LDAP, LDAPS and FILE. libcurl supports SSL certificates, HTTP POST, HTTP PUT, FTP uploading, HTTP form based upload, proxies, cook!es, user+password authentication (Basic, Digest, NTLM, Negotiate, Kerberos4), file transfer resume, http proxy tunneling and more! "
[HTML] http://curl.haxx.se/libcurl/c/libcurl-tutorial.html
[API] http://curl.haxx.se/libcurl/c/
[Examples] http://curl.haxx.se/libcurl/c/example.html
glibcurl "glibcurl consists of a small amount of C code which you can include in your program. It integrates the event loops of libcurl and glib. This means that a GTK+ program is able to wait for clicks, button presses etc. at the same time as waiting for data to arrive on the network sockets maintained by libcurl."
[HTML] http://atterer.net/glibcurl/
[API] http://atterer.net/jigdo/api/glibcurl_8h.html
Libpcap "libpcap is a system-independent interface for user-level packet capture. libpcap provides a portable framework for low-level network monitoring. Applications include network statistics collection, security monitoring, network debugging, etc."
[HTML] http://yuba.stanford.edu/~casado/pcap/section1.html
Libsoup "libsoup is an HTTP client/server library for GNOME. It uses GObjects and the glib main loop, to integrate well with GNOME applications."
[HTML] http://library.gnome.org/devel/libsoup/stable/
libEtPan "libEtPan is a mail purpose library. It will be used for low-level mail handling : network protocols (IMAP/NNTP/POP3/SMTP over TCP/IP and SSL/TCP/IP, already implemented), local storage (mbox/MH/maildir), message / MIME parser."
[HTML] http://www.etpan.org/libetpan/
[HTML] http://dinh.viet.hoa.free.fr/wiki/index.php?title=LibEtPan
Source Code Build Tools
Automating Program Compilation - Writing Makefiles
[Html] http://users.actcom.co.il/~choo/lupg/tutorials/writing-makefiles/writing-makefiles.html
GNU Autoconf, Automake, And Libtool "Goat Book"
[Html] http://sources.redhat.com/autobook/autobook/autobook_toc.html#SEC_Contents
Legal Resources
Open Source Licensing
Software Freedom and Intellectual Property Law
[Html] http://www.rosenlaw.com/oslbook.htm
Software Freedom Law Center:
We provide legal representation and other law-related services to protect and advance Free and Open Source Software (FOSS). Founded in 2005, the Center now represents many of the most important and well-established free software and open source projects.
[Html] http://www.softwarefreedom.org/
"Note: Remember never openly research software patents. Or inquire about patents with the us patent office if
you intend to use they patent in question. Because if you ever find your self being sued the fact that you inquired about they patent in question is enough to prove that you deliberately committed patent infringement. "
Patent Commons Project:
The Patent Commons Project is dedicated to d0cumenting the boundaries of The Commons -- a preserve where developers and users of software can innovate, collaborate, and access patent resources in an environment of enhanced safety, protected by pledges of support made by holders of software patents.
[Html] http://www.patent-commons.org/
Example Code
GtkGLExt:
http://oracle.bridgewayconsulting.com.au/~davyd/misc/gtkglext-example.c
Creating and writing to an OpenGL window "GtkGLExt":
http://www.gtkforums.com/viewtopic.php?t=3568
Glib Utility Functions:
http://www.gtkforums.com/viewtopic.php?t=2809
Glib GChecksumType Examples
http://www.gtkforums.com/viewtopic.php?p=9125#9125
WebkitGtk & GtkBuilder:
http://www.gtkforums.com/viewtopic.php?t=3057
GtkIconView:
http://www.gtkforums.com/viewtopic.php?t=3103
GtkSourceView Syntax Highlighting Text Widget:
http://www.gtkforums.com/viewtopic.php?t=3105
Clutter and Clutter-box2d:
http://www.gtkforums.com/viewtopic.php?t=3128
GtkComboBox sample code:
http://www.gtkforums.com/viewtopic.php?t=3375
GTK+, Cairo & Poppler PDF Viewer example:
http://www.gtkforums.com/viewtopic.php?p=9086#9086
Terminal emulator widget VTE example
http://www.gtkforums.com/viewtopic.php?p=9087#9087
Gtk windows with alpha channels and Cairo
http://mikehearn.wordpress.com/2006/03/26/gtk-windows-with-alpha-channels/
[EXAMPLE] http://plan99.net/~mike/files/alphademo.c
A shaped input example with Gtk+, Cairo and XShape 1.1
http://macslow.thepimp.net/?p=26
[EXAMPLE] http://macslow.thepimp.net/projects/input_shape_test.c
Gtk System Tray Example
[HTML] http://yettocome.blogspot.com/2007/08/gtk-system-tray-icon-example.html
Gtk System Tray with Animated Icon Example
[HTML] http://www.gtkforums.com/viewtopic.php?t=3423
Reference Manuals
The following is a list of the most current stable d0cumentation available for GTK+ and its
supporting libraries. These are the standard libaries that you will be using to develop your
own GTK+ applications. Remember that, while GTK+ depends on GLib, that is only a one way
dependency!
ATK: http://library.gnome.org/devel/atk/stable/
GDK: http://library.gnome.org/devel/gdk/stable/
GdkPixbuf: http://library.gnome.org/devel/gdk-pixbuf/stable/
GLib: http://library.gnome.org/devel/glib/stable/
GObject: http://library.gnome.org/devel/gobject/stable/
GTK+: http://library.gnome.org/devel/gtk/stable/
Pango: http://library.gnome.org/devel/pango/stable/
Cairo: http://www.cairographics.org/manual/
Gstreamer: http://gstreamer.freedesktop.org/d0cumentation/
Libglade: http://library.gnome.org/devel/libglade/unstable/
GtkGLExt: http://gtkglext.sourceforge.net/reference/gtkglext/
Clutter 0.8: http://clutter-project.org/docs/clutter/0.8/
Clutter 0.9: http://clutter-project.org/docs/clutter/0.9/
Webkit: http://oe.linuxtogo.org/~zecke/webkit-gtk-api/index.html
Please report any broken links so i can fix them.
Thanks Caracal
Last edited by caracal on Fri Jun 26, 2009 7:15 am; edited 149 times in total
Ansi C 리펙토링 (0) | 2009.10.03 |
---|---|
디지털 타임즈 [알아봅시다] 교육의 틀을 바꾸는 `디지털교과서` (0) | 2009.09.20 |
대학시절 자료복구[일부] http://comphy.iptime.org/~old/ (0) | 2009.08.31 |
PocketPC 일본어 (0) | 2009.08.27 |
파이썬 (python) Ultraedit syntax highlighting (0) | 2009.06.28 |
대학시절 자료복구[일부] http://comphy.iptime.org/~old/
대학시절 자료복구[일부] http://comphy.iptime.org/~old/
대학시절 자료복구[일부] http://comphy.iptime.org/~old/
Year 1993 ~ 1997 까지 기록된 전산물리학, 인공지능, 네트워크,
마이크로컨트롤러 개발 관련 자료 모음
디지털 타임즈 [알아봅시다] 교육의 틀을 바꾸는 `디지털교과서` (0) | 2009.09.20 |
---|---|
C/C++ Programming Links (0) | 2009.09.02 |
PocketPC 일본어 (0) | 2009.08.27 |
파이썬 (python) Ultraedit syntax highlighting (0) | 2009.06.28 |
edwin에서 자주쓰이는 기능만 추려 정리. SICP (0) | 2009.06.28 |
TextViewer ver 3.3a (Download - 아래 리뷰 참조)
▶ 구 분 : PocketPC | 텍스트 | Reader |
▷ 가 격 : Freeware
▷ 작동환경 : Pocket PC (ARM, MIPS, SH3 Processors)
▷ 제 한 :
▷ 평 가 : ★★
▷ 개 발 : Toshiyuki UMEDA http://www.tele.ucl.ac.be/PEOPLE/UMEDA/TextViewer/index-e
▷ 개 발 자 : umeda@tele.ucl.ac.be
▷ 개 발 일 : 2004. 12. 27
▷ 리 뷰 일 : 2005. 1. 27
▷ 비 고 :
TextViewer는 Pocket PC 용 다국어를 지원하는 텍스트 뷰어입니다. 만약에 당신이 영문판의 Pocket PC를 사용한다면, 그 PDA에서는 한국어, 일본어, 중국어를 읽을 수 없습니다. 이 TextViewer는 어쨌든 간에 당신의 PDA에서 여러 언어로 된 텍스트 파일을 읽을 수 있도록 해줍니다. |
다음의 문자 코딩을 선택할 수 있습니다.
- Japanese Shift JIS
- Japanese ISO-2022-JP (JIS)
- Japanese EUC
Unicode (Chinese, Korea 등..)
- Unicode (UTF-8)
- Unicode (UTF-16) (BOM support)
European Language (추가적으로 지원)
- ISO-8859-1 Western
- ISO-8859-2 Central Europe
- ISO-8859-3 South Europe
- ISO-8859-4 Baltic
- ISO-8859-5 Cyrillic
- ISO-8859-7 Greek
Palm Doc Format
- Japanese (Doc/Medoc 포맷)
- Western(ISO-8859-1)
버전 3.0부터는 Palm OS에서 사용하는 Doc 포맷의 파일까지 지원합니다. (Western/Japanese) Palm OS의 역사는 Pocket PC 보다 오래된 만큼 Palm doc 포맷의 무료 E-Book은 수도 없이 많습니다. 이젠 이것들을 Pocket PC에서 별도의 변환 없이 편하게 즐기실 수 있습니다. 단, Japanese와 Western만 됩니다.
Palm Doc 포맷의 경우, TextViewer는 Palm Doc version 1(압축되지 않은 것)과 2 (압축된 것)을 지원합니다. 하지만 커다란 파일(30 KB 이상)을 열 경우, 화면에 표시되는 데까지 약 5~10 여 초의 시간이 필요합니다.
< 설치 >
1. 폰트 설치하기
1) 만약에 단지 일본어 만을 읽고자 한다면, CEFONT를 다운로드 받거나 또는 일본어 폰트를 지원하는 다른 폰트를 다운 받아야 합니다.
- 일본어 폰트 설치 예
a) 다운로드: cefont100.zip (크기: 574k)
b) 다운 받은 cefont100.zip에서 cefont.ttf의 압축을 풉니다.
c) cefont.ttf 파일을 \Windows\Fonts 폴더나 (PocketPC2002) 또는 \Windwos 폴더에 (PocketPC) 복사합니다.
※ 제 iPAQ 2110의 경우에는 \Windows\Fonts 폴더에 복사했더니, 일본어를 뿌려주지 못하더군요. 그래서 다시 \Windwos 폴더에 복사해 넣었더니 제대로 나왔습니다. 혹 출력이 제대로 안 되시는 분들은 폴더를 바꿔가면서 설치해 보십시오.
2) 만약에 일본어 외에 한국어나 중국어 등을 읽어야 한다면, bdfUMplus를 다운로드 하거나 또는 원하는 언어를 지원하는 폰트를 다운로드 받으십시오.
* Free Unicode True Type Font (Windows CE 그리고 PocketPC/PocketPC 2002 용)
(Japanese, Chinese, Korea, Russian, Greek, Western, Central Europe, South Europe, Baltic, Cyrillic)
* 다운로드 bdfUMplus-20030206.zip (크기: 179k)
오리지널 다운로드 링크는 아래와 같습니다.
http://www.tele.ucl.ac.be/PEOPLE/UMEDA/TextViewer/index-e.html
- 한국어나 중국어 폰트 설치 예
a) bdfUMplus-20030206.zip을 다운로드 합니다.
b) 다운 받은 bdfUMplus-20030206.zip에서 bdfUMplus.ttf의 압축을 풉니다.
c) bdfUMplus.ttf파일을 \Windows\Fonts 폴더나 (PocketPC2002) 또는 \Windwos 폴더에 (PocketPC) 복사합니다.
2. TextViewer 프로그램 기종 별 다운로드 및 설치하기
아래의 다운로드 파일 중에서 자신의 기종에 맞는 적당한 Cab 파일을 PDA의 \Temp 폴더에 복사합니다. (Cab 파일들은 zip 파일에 포함되어 있습니다. 자신의 기종에 맞는 zip 파일로부터 압축을 풀어 내십시오) |
a) TextViewer ver 3.3a: PocketPC ARM, MIPS, SH3 기종 용
* TextViewer-PPC-SH3.zip (크기: 28k)
* TextViewer-PPC-MIPS.zip (크기: 28k)
* TextViewer-PPC-ARM.zip (크기: 28k)
b) TextViewer2002 version 4.0: PocketPC 2002 Strong ARM / XScale 기종 용
* TextViewer2k2-4.0.zip (크기: 107k)
c) TextViewer2002 version 4.0: PocketPC 2003 ARM / XScale 기종 용
* TextViewer2k2-4.0a.zip (크기: 108k)
4) PDA에서 Cab 파일을 탭하여 실행합니다. 그러면 프로그램이 자동으로 설치를 시작합니다.
< 사용하기 >
File - Open에서 읽을 파일을 선택합니다. |
왼쪽 그림은 일본어 폰트를 설치하기 전의 화면입니다. 폰트가 없으므로 깨져 보이네요. |
그러면 위에서 알아본 대로 폰트 파일을 설치하시고 TOOL 메뉴 - VIEW를 선택하십시오. 그리고 FONT NAME에서 새로 설치한 일본어 폰트인 "CEFONT"를 선택하고 OK 버튼을 누르십시오.
그러면 옆 그림과 같이 일본어가 표시됩니다. 그런데 아쉽게도 한문은 약간씩 깨진 곳이 있군요. 그래도 Shift JIS 포맷을 PPC에서 볼 수 있다는데 만족합니다. |
왼쪽의 그림은 국산 프리웨어 텍스트 뷰어인 "무식이"에서 폰트를 일본어 폰트로 지정하고 같은 문서를 열어본 화면입니다. 화면이 깨지는군요. 폰트만 선택해서 되는 문제가 아닌가 보죠? |
TOOL 메뉴 - VIEW - LINE STYLE에서는 화면에 밑줄 표시 여부를 None, Line 그리고 Dot 중에서 지정할 수 있습니다. |
이 프로그램이 갖고 있는 또 다른 제약은 불러 들일 수 있는 파일의 크기가 64k까지 라는 것입니다. |
< 기타 기능 >
이 프로그램은 TOOL 메뉴에 EXTENSION, KEY BIND, VIEW의 3가지 주요 메뉴를 갖고 있습니다.
* EXTENSION: 파일의 확장자 별로 이 프로그램에 연결해서 볼 수 있도록 해줍니다. |
* KEY BIND: 하드웨어 버튼에 TextViewer의 스크롤 기능을 연결하여 사용할 수 있습니다. |
* VIEW: 사용할 폰트의 선택이나 인코딩 방식을 선택합니다. |
< 다른 폰트 사용하기 >
위에서 보시다시피 cefont.ttf 폰트를 사용했을 때 한문의 일부가 깨져서, XP의 Windows\Fonts 아래에 있는 일본어 폰트인 msgothic.ttc을 PPC에 복사해 넣었습니다. 그리고서 VIEW 메뉴에서 MS Gothic 폰트를 선택해서 보면 위의 화면과 같습니다. 역시 한문이 몇 개 깨져 보이네요. msgothic.ttc를 PPC에 복사해 넣는 것 까지는 좋았는데 삭제가 안돼서 결국 하드리셋 해버렸다는... ㅠ.ㅜ
"무식이"에서는 메뉴 - 설정 -글자 탭 - 폰트 종류에서 MS Gothic를 선택하고 "Japanese Shift JIS" 포맷의 문서를 불러들여도 완전히 깨지네요... 그렇다면, 허접하기는 해도 TextViewer를 써야 한다는 이야기가 되는데...
대단한 기능을 갖고 있는 프로그램은 아닙니다만, 개중에는 필요하신 분들도 있으리라 생각됩니다. 프로그램의 작동이 다소 안정적이지 않을 지도 모르겠습니다.
C/C++ Programming Links (0) | 2009.09.02 |
---|---|
대학시절 자료복구[일부] http://comphy.iptime.org/~old/ (0) | 2009.08.31 |
파이썬 (python) Ultraedit syntax highlighting (0) | 2009.06.28 |
edwin에서 자주쓰이는 기능만 추려 정리. SICP (0) | 2009.06.28 |
3D Graph ActiveX Control (0) | 2009.05.21 |
파이썬 (python) Ultraedit syntax highlighting
1246152732_UE_python2.txt대학시절 자료복구[일부] http://comphy.iptime.org/~old/ (0) | 2009.08.31 |
---|---|
PocketPC 일본어 (0) | 2009.08.27 |
edwin에서 자주쓰이는 기능만 추려 정리. SICP (0) | 2009.06.28 |
3D Graph ActiveX Control (0) | 2009.05.21 |
2D Graph ActiveX Control (0) | 2009.05.21 |
edwin에서 자주쓰이는 기능만 추려 정리. SICP |
edwin.
요거 참 골때리는 것 같다.
마우스로 되는 거라고는 포인터 움직이는 것 밖에 없다.
요즘은 emacs도 안그런 것 같던데.
검색해보니 다른 구현도 많고, GUI지원되는 구현도 있는 것 같지만.
귀찮아서 그냥 MIT Scheme과 기본제공되는 edwin으로 하는 중.
이게......
edwin에 대한 사용법은 공식사이트에 쥐꼬리만큼 있고 찾아봐도 잘 나오질 않는다.
그러면. 핵심 사항만 추려서 가보자.
우선, edwin을 실행시키면
<ctrl+x-ctrl+f>로 파일열기 명령어를 준다음에
아무 내용이나 입력하자.
sicp를 보는 중이라면 "ex1-31.scm"이런식으로
확장자를 scm으로 주면, scheme모드로 자연스레 들어간다.
우선 코드를 작성하고, 평가를 할때,
()로 둘러쌓인 블록단위로 평가하려면 그 블록에 커서를 갖다놓고
<alt+z>를 살표시 눌러준다.
그러면 그 블록만 평가가 된다.
바뀐부분이 있어서 다시 평가해야 할때 유용하다.
그렇지 않을경우에 지금 작성중인 버퍼에 있는 모든 명령어를 평가하려면
<alt+o>를 눌러준다.
그러면 모든게 평가가된다.
참고로, 평가하면, 맨 밑줄에 마지막으로 평가된 내용만 한줄 나오는데,
모든 내용은 Scheme에 가면 떠있다.
무슨 말인고 허니, edwin을 실행시키면 scheme이 뜨고
그 다음에 edwin이 뜬다.
scheme위에서 edwin이 돌도록 되어 있는 것이다.
그리고 각 작업중인 내용은 버퍼라는 단위에 들어있는데
scheme은 "*scheme*" 작업중인 코드는 "파일이름"이라는 버퍼에 있다.
(ex1-31.scm이라면 버퍼이름이 ex1-31.scm이다.
이 내용은 <ctrl+x ctrl+b>를 눌러보면 확인할 수 있다.)
그래서 <ctrl+x b>를 눌러보자.
(ctrl+x를 누른다음에 ctrl에서 손을떼고 그냥 b만.
<ctrl+x ctrl+b>는 ctrl을 누른채로 x,b를 누르라는 이야기)
"switch to buffer (default is *scheme*) :"
이런 메세지가 뜬다.
그러면, 그냥 엔터키를 누르면 default인 *scheme*으로 넘어가고
이름을 입력하면 그 버퍼로 넘어간다.
엔터를 처서 scheme으로 가보면, 평가한 내용들 에러들이
전부다 기록되어 있는 것을 볼 수 있다.
그리고 평가를 했는데,
아무 응답이 없다면, 밑에서 두번째 시커먼줄을 주목하자.
여기가 listen인데 반응이 없다면, 에러가 난것이므로
scheme으로 가서 에러를 확인하거나 <ctrl+c ctrl+c>로 평가를 취소 시킨다.
그리고 여기거 eval로 된 상태로 응답이 없다면. 무한 루프에 빠진것이다.
참고하자.
그리고 유용한 명령어는
<ctrl+x ctrl+s> 파일저장하기
<ctrl+x ctrl+w> 다른 이름으로 저장하기
<ctrl+x 1> 창이 분할되었을때 창 하나만 보이기
<ctrl+x k> 작업중인 버퍼 지우기
<ctrl+x ctrl+c> edwin종료
뭐 이정도 되겠다.
더 자세항 명령어가 많지만.
귀찮아서 이만. ㅋ
[출처] edwin에서 자주쓰이는 기능만 추려 정리.|작성자 완전초짜
PocketPC 일본어 (0) | 2009.08.27 |
---|---|
파이썬 (python) Ultraedit syntax highlighting (0) | 2009.06.28 |
3D Graph ActiveX Control (0) | 2009.05.21 |
2D Graph ActiveX Control (0) | 2009.05.21 |
A C++ implementation of an improved contour plotting algorithm (0) | 2009.05.20 |
1242906753_3d Graph.zip3D Graph ActiveX ControlBy Nikolai TeofilovAn ATL/STL ActiveX control based on OpenGL library for 3D data visualization | VC6, VC7Win2K, WinXP, ATL, STL, OpenGL, VS6, Dev
|
|
|
This is an ActiveX control based on the OpenGL library, which allows you to plot three-dimensional data. The control is entirely written on ATL/STL, and does not link to MFC libraries.
The control can perform the following functions:
Projection
property you should be able to change the viewing to: (0) Perspective (in which objects that are closer appear larger), and (1) Orthographic (in which the sizes and angles between objects are maintained no matter what their distance from the viewer). TrackMode
property you should be able to do: (1) Zooming, (2) Rotation, and (3) Panning at runtime. To use this control, embed it in an application that supports the use of ActiveX controls. Microsoft Visual Basic applications, all MS Office applications, VBScript and JavaScript in the HTA or Internet Explorer applications, and applications created with the Microsoft Developer Studio�s AppWizard can support the use of ActiveX controls.
Before you start, the control must be register as a COM component using Regsvr32.exe. Regsvr32 takes one argument the DLL or control to register and any of several command-line switches, the most notable of which is /u to uninstall a control. By default that is, when run with only a dll or ocx Regsvr32.exe registers the control.
Note: you must do this on every computer that you are going to use the control!
For more information on how to register and how to include the control in a VC Project, refer to my article 2D Graph ActiveX Control.
Bellow are two listings that demonstrates how to use the control to draw a Torus:
////// Plot Torus//void CDemoDlg::OnButton1() { m_Graph3D.SetCaption ("Torus"); m_Graph3D.ClearGraph(); // Clear all data m_Graph3D.AddElement(); // Add an element to element list m_Graph3D.SetElementLineColor(0, RGB(255,0,0)); m_Graph3D.SetElementType(0, 3); // draw surface double x,y,z,ti,tj; for (int i = 0; i < 41; i++) { ti = (i - 20.0)/20.0 * 3.15; for (int j = 0; j < 41 ; j++) { tj = (j - 20.0)/20.0 * 3.15; x = (cos(tj) + 3.0) * cos(ti); y = sin(tj); z = (cos(tj) + 3.0) * sin(ti); m_Graph3D.PlotXYZ(x,y,z,0); } } //m_Graph3D.SetRange (-4, 4, -1, 1, -4, 4); m_Graph3D.AutoRange();}
'''''''''''''''''''''''''''''' ' Look at the Demo3D.hta file ' Double click on file to start the demo'' Plot Torus'Sub Torus With Graph3D .ClearGraph .AddElement .Caption = "Torus" .ElementType(0) = 3 'Draw Surface For i = 0 To 41 ti = (i - 20.0)/20.0 * 3.15 For j = 0 To 41 tj = (j - 20.0)/20.0 * 3.15 x = (cos(tj) + 3.0) * cos(ti) y = sin(tj) z = (cos(tj) + 3.0) * sin(ti) .PlotXYZ x,y,z,0 Next Next .Autorange End WithEnd Sub
short Appearance
long BorderStyle
VARIANT_BOOL BorderVisible
BSTR Caption
IFontDisp* Font
OLE_COLOR BackColor
OLE_COLOR CaptionColor
short TrackMode
short Projection
BSTR XLabel
BSTR YLabel
BSTR ZLabel
short XGridNumber
short YGridNumber
short ZGridNumber
OLE_COLOR XGridColor
OLE_COLOR YGridColor
OLE_COLOR ZGridColor
OLE_COLOR ElementLineColor(long ElementID, OLE_COLOR newVal)
OLE_COLOR ElementPointColor(long ElementID, OLE_COLOR newVal)
float ElementLineWidth(long ElementID, float newVal)
float ElementPointSize(long ElementID, float newVal)
short ElementType(long ElementID)
BOOL ElementShow(long ElementID)
BOOL ElementSurfaceFill(long ElementID)
BOOL ElementSurfaceFlat(long ElementID)
BOOL ElementLight(long ElementID
short ElementLightingAmbient(long ElementID)
short ElementLightingDiffuse(long ElementID)
short ElementLightingSpecular(long ElementID)
short ElementMaterialAmbient(long ElementID)
short ElementMaterialDiffuse(long ElementID)
short ElementMaterialSpecular(long ElementID)
short ElementMaterialShinines(long ElementID)
short ElementMaterialShinines(long ElementID)
short ElementMaterialEmission(long ElementID)
void SetRange(double xmin, double xmax, double ymin, double ymax, double zmin, double zmax)
void AutoRange()
void ShowPropertyPages()
void AddElement()
void DeleteElement(long ElementID)
void ClearGraph()
void PlotXYZ(double x, double y, double z, long ElementID)
void SetLightCoordinates(long ElementID, float x, float y, float z)
Enjoy!
Note: I am not expert on OpenGL, therefore all good suggestions, code and help for imporving the control are welcome!
Send mail to nteofilov@yahoo.de with questions or comments about this article.
16 Jun 2003 - v1.0 Initial release
22 Jun 2003 - v2.0
ElementType
= {0 (Lines); 1 (Points); 2 (LinePoint); 3 (Surface)} BOOL ElementShow(long ElementID)
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
Nikolai Teofilov Member |
|
파이썬 (python) Ultraedit syntax highlighting (0) | 2009.06.28 |
---|---|
edwin에서 자주쓰이는 기능만 추려 정리. SICP (0) | 2009.06.28 |
2D Graph ActiveX Control (0) | 2009.05.21 |
A C++ implementation of an improved contour plotting algorithm (0) | 2009.05.20 |
Fault-tolerant 시스템과 Erlang (0) | 2009.05.20 |
|
This is a simple OCX control, which allows you to plot two-dimensional data. Despite the large set of controls that comes with VC++, there is no out-of-the-box control that provides a simple and straightforward 2D data visualization. The ActiveX control tutorial by Kapil Chaturvedi inspired me to write my own control, mostly because I wanted to customize the source code when needed. Over time, the functionality of the ActiveX control became more elaborate, and finally I made decision to publish what I have in hand.
XTime/YTime
property to True
. double
format. The Date/Time format is implemented as a as a floating-point value, measuring days from midnight, 30 December 1899. So, midnight, 31 December 1899 is represented by 1.0. Similarly, 6 AM, 1 January 1900 is represented by 2.25, and midnight, 29 December 1899 is 1.0. However, 6 AM, 29 December 1899 is 1.25.COleDateTime
! Before the ActiveX control can be used in your application, it must be registered as a COM Component in the system registry. This is a self registering control. This means that to register the control in the system registry you only need to have an application load the control and call the control�s exported function DllRegisterServer. You can use the REGSVR32 utility or have your setup program do this.
Copy NTGraph.ocx to your directory and type:
regsvr32 NTGraph.ocx
regsvr32 /u NTGraph.ocx
(Unregister server) You can include the control in your project by following the standard steps for ActiveX controls:
CFormView
NTGraph
Control and click Insert CNTGraph
CNTGraph.
The control's customization options are straightforward:
// Customize Graph Properties m_Graph.SetBackColor (RGB(0,0,0));m_Graph.SetAxisColor (RGB(0,255,0));m_Graph.SetLabelColor (RGB(128,255,255));// Control's Frame and Plot area optionsm_Graph.SetFrameColor((RGB(0,0,0));m_Graph.SetPlotAreaColor(RGB(212,222,200));m_Graph.SetFrameStyle(2) // (1) - Flat // (2) - Scope (raised frame and sunken plot area borders) // (3) - 3DFrame (a bitmap frame picture) m_Graph.SetGridColor(RGB(192,192,192));m_Graph.SetShowGrid (TRUE);m_Graph.SetCursorColor (RGB(255,0,0));m_Graph.SetTrackMode (1);m_Graph.SetGraphTitle("XY Plot");m_Graph.SetXLabel ("X Axis");m_Graph.SetYLabel("Y Axis");m_Graph.SetRange(0.,10,-1,1.);
You don't need to call the control Invalidate()
function every time you change a Graph property. The changes are automatically reflected on the control appearance.
To load the data into the control...
////// Customize Graph Elements //// // The Graph elements are dynamically allocated! // Element 0 is allocated by default // Even after a call to the ClearGraph method, // the Element-0 is automaticaly allocated. m_Graph.SetElementLineColor(RGB(255,0,0)); m_Graph.SetElementLinetype(0); m_Graph.SetElementWidth(1); m_Graph.SetElementPointColor(RGB(0,0,255); m_Graph.SetElementPointSymbol(3); m_Graph.SetElementSolidPoint(TRUE); // Allocate a new element: Element-1 m_Graph.AddElement(); m_Graph.SetElementColor (RGB(0,255,0)); m_Graph.SetElementLinewidth(1); m_Graph.SetElementLinetype(2); // Allocate a new element: Element-2 m_Graph.AddElement(); m_Graph.SetElementColor (RGB(0,0,255)); m_Graph.SetElementLinetype(3); // Now change again the properties of Element-1 m_Graph.SetElement(1); m_Graph.SetElementColor (RGB(0,0,255)); ...//// Load Data int the Graph Elements // double y; for (int i = 0; i < NumberOfElements; i++) { for (int x = 0; x < NumberOfPoints; x++) { y = (double)rand() / RAND_MAX * 10.0; y = y / 3 + 10.0 / 2 * i + 1; m_Graph.PlotXY(x, y, i); // or PlotY(double data, long ElementID) } }
With NTGraph1 .PlotAreaColor = vbBlack .FrameStyle = Frame .Caption = "" .XLabel = "" .YLabel = "" .ClearGraph 'delete all elements and create a new one .ElementLineColor = RGB(255, 255, 0) .AddElement ' Add second elements .ElementLineColor = vbGreen For X = 0 To 100 Y = Sin(X / 3.15) * Rnd - 1 .PlotY Y, 0 Y = Cos(X / 3.15) * Rnd + 1 .PlotXY X, Y, 1 .SetRange 0, 100, -3, 3 Next X End With
short Appearance
BSTR Caption
short Appearance
BSTR Caption
BSTR XLabel
BSTR YLabel
OLE_COLOR ControlFrameColor
OLE_COLOR PlotAreaColor
OLE_COLOR AxisColor
OLE_COLOR GridColor
OLE_COLOR LabelColor
OLE_COLOR CursorColor
IPictureDisp* ControlFramePicture
IPictureDisp* PlotAreaPicture
IFontDisp*LabelFont
IFontDisp* TickFont
IFontDisp* TitleFont
IFontDisp* IdentFont
FrameType FrameStyle
short XGridNumber
short YGridNumber
boolean ShowGrid
boolean XLog
boolean YLog
double XCursor
double YCursor
short Element
short ElementCount
OLE_COLOR ElementLineColor
OLE_COLOR ElementPointColor
LineType ElementLinetype
short ElementWidth
SymbolType ElementPointSymbol
boolean ElementSolidPoint
boolean ElementShow
TrackModeState TrackMode
BSTR ElementName
boolean ElementIdent
short Annotation
short AnnoCount
BSTR AnnoLabelCaption
double AnnoLabelX
double AnnoLabelY
OLE_COLOR AnnoLabelColor
boolean AnnoLabelHorizontal
boolean AnnoVisible
short Cursor
short CursorCount
short CursorMode
(0 - Fixed; 1 - Floating; 2 - Snapped to currentlly selected element) double CursorX
double CursorY
OLE_COLOR CursorColor
short CursorStyle
(0 - Crosshair; 1 - X hairline only; 2 - Y hairline only;) boolean CursorVisible
boolean XTime
boolean YTime
BSTR FormatAxisBottom
BSTR FormatAxisLeft
void SetRange(double xmin, double xmax, double ymin, double ymax)
void AutoRange()
void CopyToClipboard()
void PrintGraph()
void ShowProperties()
void AddElement()
void DeleteElement(short ElementID)
void ClearGraph()
double GetElementXValue(short index, short ElementID)
void SetElementXValue(short index, short ElementID, double newValue)
double GetElementYValue(short index, short ElementID)
void SetElementYValue(short index, short ElementID, double newValue)
void PlotXY(double X, double Y, short ElementID)
void PlotY(double Y, short ElementID)
void AddAnnotation()
void DeleteAnnotation(short AnnotationID)
void AddCursor()
void DeleteCursor(short CursorID)
Enjoy!
Send mail to nteofilov@yahoo.de with questions or comments about this article.
22 Nov 2002 - v1.0 Initial release
01 Dec 2002 - v1.1
26 Jan 2003 - v2.0 (Flicker Free versiton of the control)
CMemDC
Autorange
. ElementLinewidth
. ElementLinetype
. 09 Mar 2003 - v2.1
SetElementColor
, SetElementLinewidth
, SetElementLinetype
, so that they accept as a first parameter the ElementID. 01 Jun 2003 - v3.0 New release!
02 Aug 2003 - v4.0 Final release!
Note that since there are significant changes in the last release you should remove (first unregister and than delete) all old versions of the control from your projects! The VBA users who use the control inside of Office applications should also remove the following file NTGRAPHLib.exd in the Temp directory of your computer. This file is automatically created by the Office application and saves properties of the former created control instances. You have to delete this file before you insert the new version of the control, in order to get correctly names in the property browser.
This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.
A list of licenses authors might use can be found here
Nikolai Teofilov Member |
|
edwin에서 자주쓰이는 기능만 추려 정리. SICP (0) | 2009.06.28 |
---|---|
3D Graph ActiveX Control (0) | 2009.05.21 |
A C++ implementation of an improved contour plotting algorithm (0) | 2009.05.20 |
Fault-tolerant 시스템과 Erlang (0) | 2009.05.20 |
구글 안드로이드 플랫폼 아키텍처 (0) | 2009.05.19 |