Author Topic: What I have been doing lately  (Read 3794 times)

0 Members and 1 Guest are viewing this topic.

LE

  • Guest
What I have been doing lately
« on: January 03, 2007, 10:20:11 PM »
I tried to be busy, doing some MFC dialog updates.


Here is the latest dialog and the second is the previous one:

I removed the images from here, the topic is focus about how to draw or use the graphical buttons in a MFC dialog...
« Last Edit: January 04, 2007, 10:46:34 AM by LE »

LE

  • Guest
Re: What I have been doing lately
« Reply #1 on: January 03, 2007, 10:49:13 PM »
With Visual Studio 2005 - and 2002

LE

  • Guest
Re: What I have been doing lately
« Reply #2 on: January 03, 2007, 11:08:17 PM »
C++ ??

What is special about them ?




Kerry;

All the functions are in C++, that's why and the dialog is in MFC... I started ported the project into C#, but found about the exposing of the source code, and do not like the obfuscation software (there is one available in the VS 2005)... :)

... what do you mean about special?

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 6923
  • AKA Daniel
Re: What I have been doing lately
« Reply #3 on: January 03, 2007, 11:15:03 PM »
Very Nice LE.... How you do like MFC? I want to learn it but I am afraid it's too hard for me scince I don't know C++ that well yet

Dan

LE

  • Guest
Re: What I have been doing lately
« Reply #4 on: January 03, 2007, 11:20:42 PM »
Then also, I ported my lisp application that draws arcs to C++/ARX/MFC... but went into trouble when using the CAdUiBitmapButton Class, or maybe it is my lack of knowledge on how to make sure to get the appropriate dialog and graphical buttons right....

First the one I draw inside of the VS UI.

and the second one the one loaded into autocad, after moving the graphical buttons appart, just for testing.... obviously not right....

LE

  • Guest
Re: What I have been doing lately
« Reply #5 on: January 03, 2007, 11:24:40 PM »
... what do you mean about special?

Just wondered why you were posting piccys of dialogs. Advertising ? or are you sharing something I can't see.



You can come in to my place, and I can let you see all the source code no problem.... he he

even if I advertise something users tend to go to what they know - even if it is not good... so no problem.... :)


I will post some source code here too....
« Last Edit: January 03, 2007, 11:43:09 PM by LE »

LE

  • Guest
Re: What I have been doing lately
« Reply #6 on: January 03, 2007, 11:27:18 PM »
Very Nice LE.... How you do like MFC? I want to learn it but I am afraid it's too hard for me scince I don't know C++ that well yet

Dan

Thanks!

I have done some applications using C++/ARX/MFC and mostly I use the wizards and have been able to get them right (I think), still need to learn more and know about more controls too....

LE

  • Guest
Re: What I have been doing lately
« Reply #7 on: January 03, 2007, 11:36:34 PM »
Some of the source code for the 18 methods to draw arcs...

Here is the class definition for the ARCDRAW project

Code: [Select]
//-----------------------------------------------------------------------------
//----- DialogArcs.h : Declaration of the CDialogArcs
//-----------------------------------------------------------------------------
#pragma once

//-----------------------------------------------------------------------------
#include "acui.h"
#include "Resource.h"
#include "afxwin.h"

//-----------------------------------------------------------------------------
class CDialogArcs : public CAcUiDialog {
DECLARE_DYNAMIC (CDialogArcs)

public:
CDialogArcs (CWnd *pParent =NULL, HINSTANCE hInstance =NULL) ;

enum { IDD = IDD_DIALOGARCS} ;

protected:
virtual void DoDataExchange (CDataExchange *pDX) ;
afx_msg LRESULT OnAcadKeepFocus (WPARAM, LPARAM) ;

virtual BOOL OnInitDialog(); // incluimos este evento - LE

DECLARE_MESSAGE_MAP()
public:
CAdUiBitmapButton m_P1P2LA;
public:
CAdUiBitmapButton m_P1P2F;
public:
CAdUiBitmapButton m_P1CLA;
public:
CAdUiBitmapButton m_P2CLA;
public:
CAdUiBitmapButton m_P1P2DELT;
public:
CAdUiBitmapButton m_P1CDELT;
public:
CAdUiBitmapButton m_P2CDELT;
public:
CAdUiBitmapButton m_P1P2P3;
public:
CAdUiBitmapButton m_P1P2C;
public:
CAdUiBitmapButton m_P1CLC;
public:
CAdUiBitmapButton m_P2CLC;
public:
CAdUiBitmapButton m_P1P2R;
public:
CAdUiBitmapButton m_P1P2D;
public:
CAdUiBitmapButton m_P1P2STAN;
public:
CAdUiBitmapButton m_P1P2C1A;
public:
CAdUiBitmapButton m_P1P2C1B;
public:
CAdUiBitmapButton m_P1C1RLC;
public:
CAdUiBitmapButton m_P2C1RLC;

public:
afx_msg void OnBnClickedP1p2la();
public:
afx_msg void OnBnClickedP1p2f();
public:
afx_msg void OnBnClickedP1cla();
public:
afx_msg void OnBnClickedP2cla();
public:
afx_msg void OnBnClickedP1p2delt();
public:
afx_msg void OnBnClickedP1cdelt();
public:
afx_msg void OnBnClickedP2cdelt();
public:
afx_msg void OnBnClickedP1p2p3();
public:
afx_msg void OnBnClickedP1p2c();
public:
afx_msg void OnBnClickedP1clc();
public:
afx_msg void OnBnClickedP2clc();
public:
afx_msg void OnBnClickedP1p2r();
public:
afx_msg void OnBnClickedP1p2d();
public:
afx_msg void OnBnClickedP1p2stan();
public:
afx_msg void OnBnClickedP1p2c1a();
public:
afx_msg void OnBnClickedP1p2c1b();
public:
afx_msg void OnBnClickedP1c1rlc();
public:
afx_msg void OnBnClickedP2c1rlc();
} ;

The CPP file for all the functions definitions...

Code: [Select]
//-----------------------------------------------------------------------------
//----- DialogArcs.cpp : Implementation of CDialogArcs
//-----------------------------------------------------------------------------
#include "StdAfx.h"
#include "resource.h"
#include "DialogArcs.h"

///////////////////////////////////////////////////////////////////////////////

#define BAD 0
#define TRUE 1
#define FALSE 0
#define HORARIO 1
#define CONTRAHORARIO -1
#define PI 3.141592653589793238462643383279502884197169399375105820974944592308
#define DOSPI 6.28318530717958647692528676655901
#define MIN(x,y) (x < y ? x : y)
#define MAX(x,y) (x > y ? x : y)
//#define INGLES 1

#define EPS 1e-05
#define PI90 1.5707963267948966192313216916398
#define PI270 4.7123889803846898576939650749193
#define PI360 6.283185307179586476925286766559
#define Absolute(a)  ((a) >= 0.0 ? (a) : -(a))
#define EQN(x,y) (Absolute((x) - (y)) <= EPS)
#define EQNPLUS(x, y)(EQN(x,y) || x > y)
#define EQNMINUS(x,y)(EQN(x,y) || x < y)

// For checking near equal floating-point values
#define EPSILON 0.001 //0.0000000001 //0.0001   // tolerance.
#define DOUBLE_EQ(x,v) (((v - EPSILON) < x) && (x <( v + EPSILON)))

// divide un segmento en n numero de partes
static void PtNdiv(ads_point p1, ads_point p2, double ndiv, ads_point ptres)
{
ptres[0] = p1[0] + (p2[0] - p1[0]) / ndiv;
ptres[1] = p1[1] + (p2[1] - p1[1]) / ndiv;
ptres[2] = p1[2] + (p2[2] - p1[2]) / ndiv;
}

// nueva!
int CenCir(ads_point p0, ads_point pm, ads_point p1, ads_point ptres)
{
AcGeVector3d v1(asPnt3d(p0)-asPnt3d(pm)),
v2(asPnt3d(p1)-asPnt3d(pm));
if (v1.isParallelTo(v2)) return FALSE;
AcGeCircArc3d crc(asPnt3d(p0),asPnt3d(pm),asPnt3d(p1));
ads_point_set(ptres,asDblArray(crc.center()));
return TRUE;
}

// revisa si un numero real/double es igual a otro
// dando una tolerancia similar a el macro: DOUBLE_EQ
static bool equal_real(ads_real i1, ads_real i2, ads_real ftol)
{
double nom,denom,error;
nom=fabs(i1-i2);
denom=fabs(i1)+fabs(i2);
if (denom != 0)
{
error=2*nom/denom;
return (error <= ftol);
}
return TRUE;
}

double ang_dec()
{
double delta;
TCHAR var[1024];
if (acedGetEnv(_T("ArcDrawAngleInput"),var) != RTNORM)
{
acedSetEnv(_T("ArcDrawAngleInput"),_T("1"));
acedGetEnv(_T("ArcDrawAngleInput"),var);
}
switch (_wtoi(var))
{
case 1:
acutPrintf(_T("\nFormato angulos: Sexagesimales\n"));
ads_real grad,mnt,seg;
acedInitGet(RSG_NONEG,_T(""));
if (acedGetReal(_T("\nGrados: "),&grad)==RTNORM)
{
acedInitGet(RSG_NONEG,_T(""));
if (acedGetReal(_T("\nMinutos: "),&mnt)==RTNORM)
{
acedInitGet(RSG_NONEG,_T(""));
if (acedGetReal(_T("\nSegundos: "),&seg)==RTNORM)
{
return delta=(grad+(mnt/60.0)+(seg/3600.0));
//return TRUE;
}//if seconds
}//if minutes
}//if degrees
//else {return FALSE;}
break;
case 0:
acutPrintf(_T("\nFormato angulos: Centesimales\n"));
ads_real decDeg;
acedInitGet(RSG_NONEG,_T(""));
if (acedGetReal(_T("\nGrados centesimales: "),&decDeg)==RTNORM)
{
return delta=((decDeg/400) * 360);
//return TRUE;
}//if decimal degrees
//else {return FALSE;}
break;
}
//return (RSRSLT);
}

void CmdCall (struct resbuf *cmdlist)
{
if (cmdlist==NULL)
{
acdbFail(_T("\nError: Al tratar de crear la lista dinamica.\n"));
acutRelRb(cmdlist);
}
else
{
int status;
struct resbuf rb, rb1;
// valor original de cmdecho
acedGetVar(_T("CMDECHO"), &rb);
// guardar dentro de rb1 el valor de 0
rb1.restype = RTSHORT;
rb1.resval.rint = 0;
// pasar el valor de 0 a cmdecho
acedSetVar(_T("CMDECHO"), &rb1);
// pasar la lista al comando
status=acedCmd(cmdlist);
// descargar la lista
acutRelRb(cmdlist);
if ((status==RTNORM)&&(rb.restype == RTSHORT))
{
// regresar el valor original de cmdecho
acedSetVar(_T("CMDECHO"), &rb);
}//comando normal regresar el valor original de cmdecho
if ((status==RTCAN)&&(rb.restype==RTSHORT))
{
acedSetVar(_T("CMDECHO"), &rb);
}//if cancel
}//else es valida la lista a pasar a acedCmd()
}

void P1CLC(ads_point p1, ads_point cen, ads_real lc, short dir)
{
ads_real r,r1,delta,delt1;
r=acutDistance(cen,p1);
r1= sqrt((pow(r,2) - pow(lc/2,2)));
delta=(2 * atan((lc / (2*r1))));
delt1=((delta*180) / PI);
// si dir es negativo
// multiplicar delt1 por -1
// para cambiarle el signo
// probar con dir==-1
if (dir < 0)
{
delt1=(delt1 * -1);
}
struct resbuf *cmdlist=NULL;
cmdlist=acutBuildList(
RTSTR, _T("_.ARC"),
RTSTR, _T("_C"),
RT3DPOINT, cen,
RT3DPOINT, p1,
RTSTR, _T("_A"),
RTREAL, delt1,
0);
CmdCall(cmdlist);
}

// more functions here...

//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC (CDialogArcs, CAcUiDialog)

BEGIN_MESSAGE_MAP(CDialogArcs, CAcUiDialog)
ON_MESSAGE(WM_ACAD_KEEPFOCUS, OnAcadKeepFocus)
ON_BN_CLICKED(IDC_P1P2LA, &CDialogArcs::OnBnClickedP1p2la)
ON_BN_CLICKED(IDC_P1P2F, &CDialogArcs::OnBnClickedP1p2f)
ON_BN_CLICKED(IDC_P1CLA, &CDialogArcs::OnBnClickedP1cla)
ON_BN_CLICKED(IDC_P2CLA, &CDialogArcs::OnBnClickedP2cla)
ON_BN_CLICKED(IDC_P1P2DELT, &CDialogArcs::OnBnClickedP1p2delt)
ON_BN_CLICKED(IDC_P1CDELT, &CDialogArcs::OnBnClickedP1cdelt)
ON_BN_CLICKED(IDC_P2CDELT, &CDialogArcs::OnBnClickedP2cdelt)
ON_BN_CLICKED(IDC_P1P2P3, &CDialogArcs::OnBnClickedP1p2p3)
ON_BN_CLICKED(IDC_P1P2C, &CDialogArcs::OnBnClickedP1p2c)
ON_BN_CLICKED(IDC_P1CLC, &CDialogArcs::OnBnClickedP1clc)
ON_BN_CLICKED(IDC_P2CLC, &CDialogArcs::OnBnClickedP2clc)
ON_BN_CLICKED(IDC_P1P2R, &CDialogArcs::OnBnClickedP1p2r)
ON_BN_CLICKED(IDC_P1P2D, &CDialogArcs::OnBnClickedP1p2d)
ON_BN_CLICKED(IDC_P1P2STAN, &CDialogArcs::OnBnClickedP1p2stan)
ON_BN_CLICKED(IDC_P1P2C1A, &CDialogArcs::OnBnClickedP1p2c1a)
ON_BN_CLICKED(IDC_P1P2C1B, &CDialogArcs::OnBnClickedP1p2c1b)
ON_BN_CLICKED(IDC_P1C1RLC, &CDialogArcs::OnBnClickedP1c1rlc)
ON_BN_CLICKED(IDC_P2C1RLC, &CDialogArcs::OnBnClickedP2c1rlc)
END_MESSAGE_MAP()

//-----------------------------------------------------------------------------
CDialogArcs::CDialogArcs (CWnd *pParent /*=NULL*/, HINSTANCE hInstance /*=NULL*/) : CAcUiDialog (CDialogArcs::IDD, pParent, hInstance) {
}

//-----------------------------------------------------------------------------
void CDialogArcs::DoDataExchange (CDataExchange *pDX) {
CAcUiDialog::DoDataExchange (pDX) ;
DDX_Control(pDX, IDC_P1P2LA, m_P1P2LA);
DDX_Control(pDX, IDC_P1P2F, m_P1P2F);
DDX_Control(pDX, IDC_P1CLA, m_P1CLA);
DDX_Control(pDX, IDC_P2CLA, m_P2CLA);
DDX_Control(pDX, IDC_P1P2DELT, m_P1P2DELT);
DDX_Control(pDX, IDC_P1CDELT, m_P1CDELT);
DDX_Control(pDX, IDC_P2CDELT, m_P2CDELT);
DDX_Control(pDX, IDC_P1P2P3, m_P1P2P3);
DDX_Control(pDX, IDC_P1P2C, m_P1P2C);
DDX_Control(pDX, IDC_P1CLC, m_P1CLC);
DDX_Control(pDX, IDC_P2CLC, m_P2CLC);
DDX_Control(pDX, IDC_P1P2R, m_P1P2R);
DDX_Control(pDX, IDC_P1P2D, m_P1P2D);
DDX_Control(pDX, IDC_P1P2STAN, m_P1P2STAN);
DDX_Control(pDX, IDC_P1P2C1A, m_P1P2C1A);
DDX_Control(pDX, IDC_P1P2C1B, m_P1P2C1B);
DDX_Control(pDX, IDC_P1C1RLC, m_P1C1RLC);
DDX_Control(pDX, IDC_P2C1RLC, m_P2C1RLC);
}

//-----------------------------------------------------------------------------
//----- Needed for modeless dialogs to keep focus.
//----- Return FALSE to not keep the focus, return TRUE to keep the focus
LRESULT CDialogArcs::OnAcadKeepFocus (WPARAM, LPARAM) {
return (TRUE) ;
}

// insertamos esta funcion - manualmente
// dandole el nombre de nuestra clase
BOOL CDialogArcs::OnInitDialog()
{
// Set the dialog name for registry lookup and storage
CAcUiDialog::OnInitDialog();

// definir el titulo de la caja de dialogo - LE
SetWindowText(_T("Dibujo de Arcos"));

//m_P1P2LA.m_bmpWidth(66);
//m_P1P2LA.m_bmpHeight(47);

//m_P1P2F.m_bmpWidth(66);
//m_P1P2F.m_bmpHeight(47);

//m_P1CLA.m_bmpWidth(66);
//m_P1CLA.m_bmpHeight(47);


// aqui cargamos los botones - LE
m_P1P2LA.AutoLoad();
m_P1P2F.AutoLoad();
m_P1CLA.AutoLoad();
m_P2CLA.AutoLoad();
m_P1P2DELT.AutoLoad();
m_P1CDELT.AutoLoad();
m_P2CDELT.AutoLoad();
m_P1P2P3.AutoLoad();
m_P1P2C.AutoLoad();
m_P1CLC.AutoLoad();
m_P2CLC.AutoLoad();
m_P1P2R.AutoLoad();
m_P1P2D.AutoLoad();
m_P1P2STAN.AutoLoad();
m_P1P2C1A.AutoLoad();
m_P1P2C1B.AutoLoad();
m_P1C1RLC.AutoLoad();
m_P2C1RLC.AutoLoad();

return TRUE;  // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDialogArcs::OnBnClickedP1p2la()
{
CAcUiDialog::OnOK();

//BeginEditorCommand();
P1P2LA();
//CompleteEditorCommand();

}

void CDialogArcs::OnBnClickedP1p2f()
{
CAcUiDialog::OnOK();

//BeginEditorCommand();
P1P2F();
//CompleteEditorCommand();
}

void CDialogArcs::OnBnClickedP1cla()
{
CAcUiDialog::OnOK();
//BeginEditorCommand();
P1CLA();
//CompleteEditorCommand();
}

void CDialogArcs::OnBnClickedP2cla()
{
CAcUiDialog::OnOK();

//BeginEditorCommand();
P2CLA();
//CompleteEditorCommand();
}

void CDialogArcs::OnBnClickedP1clc()
{
CAcUiDialog::OnOK();

//BeginEditorCommand();

int iRet;
ads_point p1,cen;
if (acedGetPoint(NULL, _T("\nPunto inicial: "), p1) != RTNORM) return;
if (acedGetPoint(NULL, _T("\nCentro: "), cen) != RTNORM) return;
double r = acutDistance(p1,cen),lc;
TCHAR fmtval[12];
acedInitGet(RSG_NOZERO+RSG_NONEG,_T(""));
while((iRet = acedGetDist(NULL, _T("\nLongitud arco: "), &lc) == RTNORM) && (lc > r))
{
acdbRToS(r, 2, 3, fmtval); // Mode 2 = decimal
acutPrintf(_T("\nLa longitud de arco debe ser mayor a: %s\n"), fmtval);
}
if (iRet == 1)
{
P1CLC(p1,cen,lc,1);
}

//CompleteEditorCommand();
}

// more functions here...

Entry Point...

Code: [Select]
//-----------------------------------------------------------------------------
//----- acrxEntryPoint.h
//-----------------------------------------------------------------------------
#include "StdAfx.h"
#include "resource.h"
#include "DialogArcs.h"
#include "AcExtensionModule.h"

//-----------------------------------------------------------------------------
#define szRDS _RXST("LESQ")

//-----------------------------------------------------------------------------
//----- ObjectARX EntryPoint
class Carcdraw17App : public AcRxArxApp {

public:
Carcdraw17App () : AcRxArxApp () {}

virtual AcRx::AppRetCode On_kInitAppMsg (void *pkt) {
// TODO: Load dependencies here

// You *must* call On_kInitAppMsg here
AcRx::AppRetCode retCode =AcRxArxApp::On_kInitAppMsg (pkt) ;

// TODO: Add your initialization code here

return (retCode) ;
}

virtual AcRx::AppRetCode On_kUnloadAppMsg (void *pkt) {
// TODO: Add your code here

// You *must* call On_kUnloadAppMsg here
AcRx::AppRetCode retCode =AcRxArxApp::On_kUnloadAppMsg (pkt) ;

// TODO: Unload dependencies here

return (retCode) ;
}

virtual void RegisterServerComponents () {
}

public:

// - LESQarcdraw17._ARCOS command (do not rename)
static void LESQarcdraw17_ARCOS(void)
{
CAcModuleResourceOverride res;
CDialogArcs dlg;

// aqui es como definimos nuestro icono para la caja de dialogo
HINSTANCE hMyInstance;
// instancia a donde este cargada nuestra aplicacion
hMyInstance = acrxGetApp()->GetModuleInstance();
// cargamos nuestro icono, el cual dibujamos en el archivo de resources
HICON hMyIcon = LoadIcon(hMyInstance, MAKEINTRESOURCE(IDI_ICON1));
if (hMyIcon != NULL) dlg.SetDialogIcon(hMyIcon);

INT_PTR nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
//  dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
//  dismissed with Cancel
}

}
} ;

//-----------------------------------------------------------------------------
IMPLEMENT_ARX_ENTRYPOINT(Carcdraw17App)

ACED_ARXCOMMAND_ENTRY_AUTO(Carcdraw17App, LESQarcdraw17, _ARCOS, ARCOS, ACRX_CMD_TRANSPARENT, NULL)

« Last Edit: January 03, 2007, 11:44:21 PM by LE »

LE

  • Guest
Re: What I have been doing lately
« Reply #8 on: January 04, 2007, 12:05:54 AM »
Eventually I will end up doing that...

To me it is almost similar, with some advantages available in C#.... and also my lack of knowledge and experience using the interface and the controls... but I am getting there, here is the editor:

« Last Edit: January 04, 2007, 09:05:32 PM by LE »

LE

  • Guest
Re: What I have been doing lately
« Reply #9 on: January 04, 2007, 11:03:38 AM »
Here is the latest dialog layout, still needs more work, one thing that I noticed is that if I load it into my other pc, it won't look right..., well, I need to read more...
« Last Edit: January 04, 2007, 09:04:14 PM by LE »

LE

  • Guest
Re: What I have been doing lately
« Reply #10 on: January 04, 2007, 09:12:31 PM »
Now... let start testing the interface using C#.... something that I like is how easy to define the size for the buttons for example... in MFC, so far have not found a better way, rather than using the tab arrows and when moving them, it shows the size (in pixels)... well better than nothing...


Here is a image sample...