int main(int argc, char **argv) { int X=100, Y=200; FILE *fp; Ihandle *dlg, *mat; fp = fopen("test.dat", "r"); if (fp != NULL) { fread(&X,sizeof(int),1,fp); fread(&Y,sizeof(int),1,fp); fclose(fp); } printf("X,Y=%d,%d\n", X, Y); IupOpen(&argc, &argv); IupControlsOpen (); mat = create_mat(); dlg = IupDialog(mat); IupSetAttribute(dlg,"SHRINK","YES"); IupSetAttribute(dlg, "TITLE", "IupMatrix"); IupSetCallback(dlg, "RESIZE_CB", (Icallback) resize_cb); IupSetCallback(dlg, "CLOSE_CB", (Icallback) close_cb); IupShowXY (dlg,X,Y); IupMainLoop (); IupClose (); return EXIT_SUCCESS; }
Vec* rotate_vec_x(Vec* v, double theta) { Mat* rotate_mat = create_mat(1, 0, 0, 0, 0, cos(theta), sin(theta), 0, 0, -sin(theta), cos(theta), 0, 0, 0, 0, 0); Vec* r = mat_times_vec(rotate_mat, v); delete_mat(rotate_mat); return r; }
/* Main program */ int main(int argc, char **argv) { Ihandle *dlg; IupOpen(&argc, &argv); IupControlsOpen(); IupSetFunction("removeline", (Icallback)removeline); IupSetFunction("addline", (Icallback)addline); IupSetFunction("removecol", (Icallback)removecol); IupSetFunction("addcol", (Icallback)addcol); IupSetFunction("redraw", (Icallback)redraw); createmenu(); dlg = IupDialog( IupTabs( IupSetAttributes( IupVbox((create_mat()), IupText(""), IupLabel("Label Text"), IupVal("HORIZONTAL"), NULL), "MARGIN=10x10, GAP=10, TABTITLE=Test1"), IupSetAttributes( IupVbox(IupFrame(create_mat()), IupText(""), IupLabel("Label Text"), IupVal("HORIZONTAL"), // NULL), "BGCOLOR=\"0 255 255\", MARGIN=10x10, GAP=10, TABTITLE=Test2,FONT=HELVETICA_ITALIC_14"), NULL), "FONT=HELVETICA_NORMAL_12, BGCOLOR=\"0 255 255\", MARGIN=10x10, GAP=10, TABTITLE=Test2"), NULL)); IupSetAttribute(dlg,IUP_TITLE, "IupMatrix"); IupSetAttribute(dlg,IUP_MENU, "mymenu"); // IupSetAttribute(dlg,"BGCOLOR", "255 0 255"); //IupSetAttribute(dlg,"COMPOSITED", "YES"); //IupSetAttribute(dlg,"LAYERED", "YES"); //IupSetAttribute(dlg,"LAYERALPHA", "192"); IupShowXY(dlg,IUP_CENTER,IUP_CENTER) ; IupMainLoop(); iupmaskMatRemove(IupGetHandle("mat1"), 2, 1) ; iupmaskMatRemove(IupGetHandle("mat2"), 2, 1) ; IupDestroy(dlg); IupControlsClose(); IupClose(); return 0; }
void MatrixCbsTest(void) { Ihandle *dlg, *bt; IupMatrixExOpen(); IupSetFunction("removeline", (Icallback)removeline); IupSetFunction("addline", (Icallback)addline); IupSetFunction("removecol", (Icallback)removecol); IupSetFunction("addcol", (Icallback)addcol); IupSetFunction("redraw", (Icallback)redraw); createmenu(); bt = IupButton("Button", NULL); IupSetCallback(bt, "ACTION", bt_cb); IupSetAttribute(bt, "CANFOCUS", "NO"); dlg = IupDialog( // IupZbox( IupTabs( IupSetAttributes( IupVbox((create_mat(1)), bt, IupText(""), IupLabel("Label Text"), IupFrame(IupVal("HORIZONTAL")), NULL), "MARGIN=10x10, GAP=10, TABTITLE=Test1"), IupSetAttributes( IupVbox(IupFrame(create_mat(2)), IupText(""), IupLabel("Label Text"), IupVal("HORIZONTAL"), // NULL), "BGCOLOR=\"0 255 255\", MARGIN=10x10, GAP=10, TABTITLE=Test2,FONT=HELVETICA_ITALIC_14"), // NULL), "FONT=HELVETICA_NORMAL_12, BGCOLOR=\"0 255 255\", MARGIN=10x10, GAP=10, TABTITLE=Test2"), NULL), "BGCOLOR=\"0 255 255\", MARGIN=10x10, GAP=10, TABTITLE=Test2"), NULL)); IupSetAttribute(dlg,"TITLE", "IupMatrix"); IupSetAttribute(dlg,"MENU", "mymenu"); IupSetAttributeHandle(dlg,"DEFAULTENTER", bt); // IupSetAttribute(dlg,"BGCOLOR", "255 0 255"); //IupSetAttribute(dlg,"COMPOSITED", "YES"); //IupSetAttribute(dlg,"OPACITY", "192"); IupShowXY(dlg,IUP_CENTER,IUP_CENTER); }
/* Main program */ int main(int argc, char **argv) { Ihandle *dlg; IupOpen(&argc, &argv); IupControlsOpen (); dlg = IupDialog(create_mat()); IupSetAttribute(dlg, "TITLE", "IupMatrix"); IupShowXY (dlg,IUP_CENTER,IUP_CENTER); IupMainLoop (); IupClose (); return EXIT_SUCCESS; }
int main(int argc, char **argv) { Ihandle *dlg; IupOpen(&argc, &argv); IupMatrixOpen(); matrixHandle = create_mat(); IupSetAttribute(matrixHandle, IUP_CLICK_CB, "CLICK_ACTION"); IupSetFunction("CLICK_ACTION", (Icallback)matrixClickCallback); dlg = IupDialog(matrixHandle); IupShowXY (dlg,IUP_CENTER,IUP_CENTER) ; IupMainLoop () ; IupClose () ; return 0 ; }
int main(int argc, char* argv[]){ int nb_sommets = 0; int i, j ; while((nb_sommets == 0) || (nb_sommets < 0)){ printf("Veuillez entrer le nombre de sommets souhaités : \n"); scanf("%d", &nb_sommets); if(nb_sommets < 0){ fprintf(stderr, "Le nombre de sommets ne peut pas être négatif..."); } } int **matrice = NULL ; matrice = create_mat(nb_sommets); show_mat(matrice, nb_sommets); return 0 ; }
Vec* rotate_vec(Vec* v, Vec* u, double theta) { double c = cos(theta); double s = sin(theta); double x1 = c + u->x * u->x * (1 - c); double x2 = u->x * u->y * (1 - c) - u->z * s; double x3 = u->x * u->z * (1 - c) + u->y * s; double y1 = u->y * u->x * (1 - c) + u->z * s; double y2 = c + u->y * u->y * (1 - c); double y3 = u->y * u->z * (1 - c) - u->x * s; double z1 = u->z * u->x * (1 - c) - u->y * s; double z2 = u->z * u->y * (1 - c) + u->x * s; double z3 = c + u->z * u->z * (1 - c); Mat* rotate_mat = create_mat(x1, y1, z1, 0, x2, y2, z2, 0, x3, y3, z3, 0, 0, 0, 0, 0); Vec* r = mat_times_vec(rotate_mat, v); delete_mat(rotate_mat); return r; }
void func_1 (void) { Ihandle *_cbox, *_cnv_1, *dlg, *img, *_frm_1, *_frm_2, *_frm_3, *hbox, *_ctrl_1, *_list_1, *_list_2, *_list_3, *_text_1, *_ml_1; img = IupImage(32,32, img_bits1); IupSetHandle ("img1", img); IupSetAttribute (img, "0", "0 0 0"); IupSetAttribute (img, "1", "BGCOLOR"); IupSetAttribute (img, "2", "255 0 0"); img = IupImage(32,32, img_bits2); IupSetHandle ("img2", img); IupSetAttribute (img, "0", "0 0 0"); IupSetAttribute (img, "1", "0 255 0"); IupSetAttribute (img, "2", "BGCOLOR"); IupSetAttribute (img, "3", "255 0 0"); _frm_1 = IupFrame( IupVbox( IupSetAttributes(IupButton("Button Text", NULL), "CINDEX=1"), IupSetAttributes(IupButton("", NULL), "IMAGE=img1,CINDEX=2"), IupSetAttributes(IupButton("", NULL), "IMAGE=img1,IMPRESS=img2,CINDEX=3"), NULL)); IupSetAttribute(_frm_1,"TITLE","IupButton"); IupSetAttribute(_frm_1,"CX","10"); IupSetAttribute(_frm_1,"CY","180"); _frm_2 = IupFrame( IupVbox( IupSetAttributes(IupLabel("Label Text"), "CINDEX=1"), IupSetAttributes(IupLabel(""), "SEPARATOR=HORIZONTAL,CINDEX=2"), IupSetAttributes(IupLabel(""), "IMAGE=img1,CINDEX=3"), NULL)); IupSetAttribute(_frm_2,"TITLE","IupLabel"); IupSetAttribute(_frm_2,"CX","200"); IupSetAttribute(_frm_2,"CY","250"); _frm_3 = IupFrame( IupVbox( IupSetAttributes(IupToggle("Toggle Text", NULL), "VALUE=ON,CINDEX=1"), IupSetAttributes(IupToggle("", NULL), "IMAGE=img1,IMPRESS=img2,CINDEX=2"), IupSetAttributes(IupFrame(IupRadio(IupVbox( IupSetAttributes(IupToggle("Toggle Text", NULL), "CINDEX=3"), IupSetAttributes(IupToggle("Toggle Text", NULL), "CINDEX=4"), NULL))), "TITLE=IupRadio"), NULL)); IupSetAttribute(_frm_3,"TITLE","IupToggle"); IupSetAttribute(_frm_3,"CX","400"); IupSetAttribute(_frm_3,"CY","250"); _text_1 = IupText( NULL); IupSetAttribute(_text_1,"VALUE","IupText Text"); IupSetAttribute(_text_1,"SIZE","80x"); IupSetAttribute(_text_1,"CINDEX","1"); IupSetAttribute(_text_1,"CX","10"); IupSetAttribute(_text_1,"CY","100"); _ml_1 = IupMultiLine( NULL); IupSetAttribute(_ml_1,"VALUE","IupMultiline Text\nSecond Line\nThird Line"); IupSetAttribute(_ml_1,"SIZE","80x60"); IupSetAttribute(_ml_1,"CINDEX","1"); IupSetAttribute(_ml_1,"CX","200"); IupSetAttribute(_ml_1,"CY","100"); _list_1 = IupList( NULL); IupSetAttribute(_list_1,"VALUE","1"); IupSetAttribute(_list_1,"1","Item 1 Text"); IupSetAttribute(_list_1,"2","Item 2 Text"); IupSetAttribute(_list_1,"3","Item 3 Text"); IupSetAttribute(_list_1,"CINDEX","1"); IupSetAttribute(_list_1,"CX","10"); IupSetAttribute(_list_1,"CY","10"); _list_2 = IupList( NULL); IupSetAttribute(_list_2,"DROPDOWN","YES"); IupSetAttribute(_list_2,"VALUE","2"); IupSetAttribute(_list_2,"1","Item 1 Text"); IupSetAttribute(_list_2,"2","Item 2 Text"); IupSetAttribute(_list_2,"3","Item 3 Text"); IupSetAttribute(_list_2,"CINDEX","2"); IupSetAttribute(_list_2,"CX","200"); IupSetAttribute(_list_2,"CY","10"); _list_3 = IupList( NULL); IupSetAttribute(_list_3,"EDITBOX","YES"); IupSetAttribute(_list_3,"VALUE","3"); IupSetAttribute(_list_3,"1","Item 1 Text"); IupSetAttribute(_list_3,"2","Item 2 Text"); IupSetAttribute(_list_3,"3","Item 3 Text"); IupSetAttribute(_list_3,"CINDEX","3"); IupSetAttribute(_list_3,"CX","400"); IupSetAttribute(_list_3,"CY","10"); _cnv_1 = IupCanvas( NULL); IupSetAttribute(_cnv_1,"RASTERSIZE","100x100"); IupSetAttribute(_cnv_1,"POSX","0"); IupSetAttribute(_cnv_1,"POSY","0"); IupSetAttribute(_cnv_1,"BGCOLOR","128 255 0"); IupSetAttribute(_cnv_1,"CX","400"); IupSetAttribute(_cnv_1,"CY","150"); _ctrl_1 = IupVal(NULL); IupSetAttribute(_ctrl_1,"CX","600"); IupSetAttribute(_ctrl_1,"CY","200"); _cbox = IupCbox( _text_1, _ml_1, _list_1, _list_2, _list_3, _cnv_1, _ctrl_1, createtree(), create_mat(), _frm_1, _frm_2, _frm_3, NULL); IupSetAttribute(_cbox,"SIZE","480x200"); hbox = IupSetAttributes(IupHbox(_cbox, NULL), "MARGIN=10x10"); dlg = IupDialog(hbox); IupSetHandle("dlg",dlg); IupSetAttribute(dlg,"TITLE","Cbox Test"); }
void func_1 (void) { Ihandle *_cbox, *_cnv_1, *dlg, *img, *_frm_1, *_frm_2, *_frm_3, *hbox, *_ctrl_1, *_list_1, *_list_2, *_list_3, *_text_1, *_ml_1; img = IupImage(32,32, img_bits1); IupSetHandle ("img1", img); IupSetAttribute (img, "0", "0 0 0"); IupSetAttribute (img, "1", "BGCOLOR"); IupSetAttribute (img, "2", "255 0 0"); img = IupImage(32,32, img_bits2); IupSetHandle ("img2", img); IupSetAttribute (img, "0", "0 0 0"); IupSetAttribute (img, "1", "0 255 0"); IupSetAttribute (img, "2", "BGCOLOR"); IupSetAttribute (img, "3", "255 0 0"); _frm_1 = IupFrame( IupVbox( IupSetAttributes(IupButton("Button Text", "action"), "BGCOLOR=\"255 128 0\", CINDEX=1"), IupSetAttributes(IupButton("", "action"), "BGCOLOR=\"255 128 0\", CINDEX=1"), IupSetAttributes(IupButton("", "action"), "IMAGE=img1,BGCOLOR=\"255 128 0\", CINDEX=2"), IupSetAttributes(IupButton("", "action"), "IMAGE=img1,BGCOLOR=\"255 128 0\", IMPRESS=img2,CINDEX=3"), NULL)); IupSetAttribute(_frm_1,IUP_TITLE,"IupButton"); IupSetAttribute(_frm_1,"CX","10"); IupSetAttribute(_frm_1,"CY","180"); _frm_2 = IupFrame( IupVbox( IupSetAttributes(IupLabel("Label Text"), "CINDEX=1,FONT=HELVETICA_ITALIC_14"), IupSetAttributes(IupLabel(""), "SEPARATOR=HORIZONTAL,CINDEX=2"), IupSetAttributes(IupLabel(""), "IMAGE=img1,CINDEX=3"), NULL)); IupSetAttribute(_frm_2,IUP_TITLE,"IupLabel"); IupSetAttribute(_frm_2,"CX","200"); IupSetAttribute(_frm_2,"CY","250"); _frm_3 = IupFrame( IupVbox( IupSetAttributes(IupToggle("Toggle Text", "action"), "VALUE=ON,CINDEX=1,FONT=HELVETICA_ITALIC_14"), IupSetAttributes(IupToggle("", "action"), "IMAGE=img1,IMPRESS=img2,CINDEX=2"), IupSetAttributes(IupFrame(IupRadio(IupVbox( IupSetAttributes(IupToggle("Toggle Text", "action"), "CINDEX=3"), IupSetAttributes(IupToggle("Toggle Text", "action"), "CINDEX=4"), NULL))), "TITLE=IupRadio"), NULL)); IupSetAttribute(_frm_3,IUP_TITLE,"IupToggle"); IupSetAttribute(_frm_3,"CX","400"); IupSetAttribute(_frm_3,"CY","250"); IupSetAttribute(_frm_3,"RASTERSIZE","150x150"); _text_1 = IupText( "action"); IupSetAttribute(_text_1,IUP_VALUE,"IupText Text"); IupSetAttribute(_text_1,IUP_SIZE,"80x"); IupSetAttribute(_text_1,"CINDEX","1"); IupSetAttribute(_text_1,"CX","10"); IupSetAttribute(_text_1,"CY","100"); _ml_1 = IupMultiLine( "action"); IupSetAttribute(_ml_1,IUP_VALUE,"IupMultiline Text\nSecond Line\nThird Line"); IupSetAttribute(_ml_1,IUP_SIZE,"80x60"); IupSetAttribute(_ml_1,"CINDEX","1"); IupSetAttribute(_ml_1,"CX","200"); IupSetAttribute(_ml_1,"CY","100"); _list_1 = IupList( "action"); IupSetAttribute(_list_1,IUP_VALUE,"1"); IupSetAttribute(_list_1,"1","Item 1 Text"); IupSetAttribute(_list_1,"2","Item 2 Text"); IupSetAttribute(_list_1,"3","Item 3 Text"); IupSetAttribute(_list_1,"CINDEX","1"); IupSetAttribute(_list_1,"CX","10"); IupSetAttribute(_list_1,"CY","10"); _list_2 = IupList( "action"); IupSetAttribute(_list_2,IUP_DROPDOWN,"YES"); IupSetAttribute(_list_2,IUP_VALUE,"2"); IupSetAttribute(_list_2,"1","Item 1 Text"); IupSetAttribute(_list_2,"2","Item 2 Text"); IupSetAttribute(_list_2,"3","Item 3 Text"); IupSetAttribute(_list_2,"CINDEX","2"); IupSetAttribute(_list_2,"CX","200"); IupSetAttribute(_list_2,"CY","10"); _list_3 = IupList( "action"); IupSetAttribute(_list_3,"EDITBOX","YES"); IupSetAttribute(_list_3,IUP_VALUE,"3"); IupSetAttribute(_list_3,"1","Item 1 Text"); IupSetAttribute(_list_3,"2","Item 2 Text"); IupSetAttribute(_list_3,"3","Item 3 Text"); IupSetAttribute(_list_3,"CINDEX","3"); IupSetAttribute(_list_3,"CX","400"); IupSetAttribute(_list_3,"CY","10"); _cnv_1 = IupCanvas( "do_nothing"); IupSetAttribute(_cnv_1,IUP_RASTERSIZE,"100x100"); IupSetAttribute(_cnv_1,IUP_POSX,"0.0"); IupSetAttribute(_cnv_1,IUP_POSY,"0.0"); IupSetAttribute(_cnv_1,IUP_BGCOLOR,"128 255 0"); IupSetAttribute(_cnv_1,"CX","400"); IupSetAttribute(_cnv_1,"CY","150"); _ctrl_1 = IupVal(NULL); IupSetAttribute(_ctrl_1,"CX","600"); IupSetAttribute(_ctrl_1,"CY","200"); // _cbox = IupCbox( _cbox = IupCboxBuilder( _text_1, _ml_1, _list_1, _list_2, _list_3, _cnv_1, _ctrl_1, createtree(), create_mat(), _frm_1, _frm_2, _frm_3, NULL); IupSetAttribute(_cbox,IUP_SIZE,"560x200"); hbox = IupHbox( IupSetAttributes(IupFill(), "SIZE=10"), IupVbox( IupSetAttributes(IupFill(), "SIZE=10"), IupFrame(_cbox), IupSetAttributes(IupLabel("Label Text"), "FONT=HELVETICA_ITALIC_14"), NULL), NULL); dlg = IupDialog(hbox); IupSetHandle("dlg",dlg); IupSetAttribute(dlg,IUP_TITLE,"Cbox Test"); IupSetAttribute(dlg,"COMPOSITED","YES"); /* improves a lot the redrawing */ // IupSetAttribute(dlg,"FONT","HELVETICA_ITALIC_14"); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { rnum = 5; cnum = 5; mod = 10; data.assign(rnum * cnum, 0); ui->setupUi(this); update_matrix(); sub_menu = new QMenu(this); ui->tableWidget->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->tableWidget, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(show_menu(QPoint))); createAct = new QAction(this); createAct->setIcon(QIcon::fromTheme("window-new")); createAct->setText("Create new matrix..."); createAct->setStatusTip("CTRL + N"); createAct->setShortcut(Qt::CTRL + Qt::Key_N); connect(createAct, SIGNAL(triggered()),this, SLOT(create_mat())); sub_menu->addAction(createAct); ui->menuFiles->addAction(createAct); ui->mainToolBar->addAction(createAct); fillAct = new QAction(this); fillAct->setIcon(QIcon::fromTheme("view-refresh")); fillAct->setText("Generate matrix values"); fillAct->setStatusTip("CTRL + G"); fillAct->setShortcut(Qt::CTRL + Qt::Key_G); connect(fillAct, SIGNAL(triggered()),this, SLOT(fill_matrix())); sub_menu->addAction(fillAct); ui->menuFiles->addAction(fillAct); ui->mainToolBar->addAction(fillAct); searchAct = new QAction(this); searchAct->setIcon(QIcon::fromTheme("system-search")); searchAct->setEnabled(0); searchAct->setText("Find max"); searchAct->setStatusTip("CTRL + F"); searchAct->setShortcut(Qt::CTRL + Qt::Key_F); connect(searchAct, SIGNAL(triggered()),this, SLOT(find_max())); sub_menu->addAction(searchAct); ui->menuFiles->addAction(searchAct); ui->mainToolBar->addAction(searchAct); deleteAct = new QAction(this); deleteAct->setIcon(QIcon::fromTheme("edit-delete")); deleteAct->setEnabled(0); deleteAct->setText("Delete current row"); deleteAct->setStatusTip("CTRL + X"); deleteAct->setShortcut(Qt::CTRL + Qt::Key_X); connect(deleteAct, SIGNAL(triggered()),this, SLOT(delete_row())); sub_menu->addAction(deleteAct); ui->menuFiles->addAction(deleteAct); ui->mainToolBar->addAction(deleteAct); ui->menuFiles->addSeparator(); closeAct = new QAction(this); closeAct->setIcon(QIcon::fromTheme("window-close")); closeAct->setText("Close file"); closeAct->setStatusTip("CTRL + Q"); closeAct->setShortcut(Qt::CTRL + Qt::Key_Q); connect(closeAct, SIGNAL(triggered()),this, SLOT(close())); ui->menuFiles->addAction(closeAct); ui->mainToolBar->addAction(closeAct); //QToolBar* pr_bar = this->addToolBar("Main toolbar"); //pr_bar->addAction(closeAct); }
Mat* identity_mat() { return create_mat(1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0); }
Mat* zero_mat() { return create_mat(0.0,0.0,0.0,0.0, 0.0,0.0,0.0,0.0, 0.0,0.0,0.0,0.0, 0.0,0.0,0.0,0.0); }